use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLambdaFunction in project ballerina by ballerina-lang.
the class TaintAnalyzer method analyzeLambdaExpressions.
private void analyzeLambdaExpressions(BLangInvocation invocationExpr, BLangExpression argExpr) {
BLangFunction function = ((BLangLambdaFunction) argExpr).function;
if (function.symbol.taintTable == null) {
addToBlockedList(invocationExpr);
} else {
int requiredParamCount = function.requiredParams.size();
int defaultableParamCount = function.defaultableParams.size();
int totalParamCount = requiredParamCount + defaultableParamCount + (function.restParam == null ? 0 : 1);
Map<Integer, TaintRecord> taintTable = function.symbol.taintTable;
for (int paramIndex = 0; paramIndex < totalParamCount; paramIndex++) {
TaintRecord taintRecord = taintTable.get(paramIndex);
BLangVariable param = getParam(function, paramIndex, requiredParamCount, defaultableParamCount);
if (taintRecord == null) {
addTaintError(argExpr.pos, param.name.value, DiagnosticCode.TAINTED_VALUE_PASSED_TO_SENSITIVE_PARAMETER);
} else if (taintRecord.taintError != null && taintRecord.taintError.size() > 0) {
addTaintError(taintRecord.taintError);
}
if (stopAnalysis) {
break;
}
}
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLambdaFunction in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addLambdaFunctionDef.
public void addLambdaFunctionDef(DiagnosticPos pos, Set<Whitespace> ws, boolean paramsAvail, boolean retParamsAvail, boolean restParamAvail) {
BLangFunction lambdaFunction = (BLangFunction) this.invokableNodeStack.peek();
lambdaFunction.pos = pos;
endCallableUnitSignature(ws, lambdaFunction.getName().value, paramsAvail, retParamsAvail, restParamAvail);
BLangLambdaFunction lambdaExpr = (BLangLambdaFunction) TreeBuilder.createLambdaFunctionNode();
lambdaExpr.function = lambdaFunction;
lambdaExpr.pos = pos;
addExpressionNode(lambdaExpr);
// TODO: is null correct here
endFunctionDef(pos, null, false, false, true, false);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLambdaFunction in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangStreamAction streamAction) {
BLangLambdaFunction function = (BLangLambdaFunction) streamAction.getInvokableBody();
typeChecker.checkExpr(function, env);
}
Aggregations