use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangResource resourceNode) {
BSymbol resourceSymbol = resourceNode.symbol;
SymbolEnv resourceEnv = SymbolEnv.createResourceActionSymbolEnv(resourceNode, resourceSymbol.scope, env);
visitEntryPoint(resourceNode, resourceEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangService serviceNode) {
BSymbol serviceSymbol = serviceNode.symbol;
SymbolEnv serviceEnv = SymbolEnv.createPkgLevelSymbolEnv(serviceNode, serviceSymbol.scope, env);
serviceNode.vars.forEach(var -> analyzeNode(var, serviceEnv));
analyzeNode(serviceNode.initFunction, serviceEnv);
serviceNode.resources.forEach(resource -> analyzeNode(resource, serviceEnv));
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangAction actionNode) {
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, env);
visitInvokable(actionNode, actionEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TypeChecker method checkFunctionInvocationExpr.
private void checkFunctionInvocationExpr(BLangInvocation iExpr) {
Name funcName = names.fromIdNode(iExpr.name);
Name pkgAlias = names.fromIdNode(iExpr.pkgAlias);
BSymbol funcSymbol = symResolver.lookupSymbolInPackage(iExpr.pos, env, pkgAlias, funcName, SymTag.VARIABLE);
if (funcSymbol == symTable.notFoundSymbol || funcSymbol.type.tag != TypeTags.INVOKABLE) {
dlog.error(iExpr.pos, DiagnosticCode.UNDEFINED_FUNCTION, funcName);
resultTypes = getListWithErrorTypes(expTypes.size());
return;
}
if (funcSymbol.tag == SymTag.VARIABLE) {
// Check for function pointer.
iExpr.functionPointerInvocation = true;
}
// Set the resolved function symbol in the invocation expression.
// This is used in the code generation phase.
iExpr.symbol = funcSymbol;
checkInvocationParamAndReturnType(iExpr);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TypeChecker method visit.
public void visit(BLangUnaryExpr unaryExpr) {
BType exprType = null;
BType actualType = symTable.errType;
if (OperatorKind.TYPEOF.equals(unaryExpr.operator)) {
// Handle typeof operator separately
if (unaryExpr.expr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
BLangSimpleVarRef varRef = (BLangSimpleVarRef) unaryExpr.expr;
Name varRefName = names.fromIdNode((varRef).variableName);
Name pkgAlias = names.fromIdNode((varRef).pkgAlias);
// Resolve symbol for BLangSimpleVarRef
BSymbol varRefSybmol = symResolver.lookupSymbolInPackage(unaryExpr.pos, env, pkgAlias, varRefName, SymTag.VARIABLE);
if (varRefSybmol == symTable.notFoundSymbol) {
// Resolve symbol for User Defined Type ( converted from BLangSimpleVarRef )
BLangTypeofExpr typeAccessExpr = getTypeAccessExpression(varRef);
unaryExpr.expr = typeAccessExpr;
actualType = typeAccessExpr.type;
resultTypes = types.checkTypes(unaryExpr, Lists.of(actualType), expTypes);
return;
} else {
// Check type if resolved as BLangSimpleVarRef
exprType = checkExpr(unaryExpr.expr, env).get(0);
}
} else {
// Check type if resolved as non BLangSimpleVarRef Expression
exprType = checkExpr(unaryExpr.expr, env).get(0);
}
if (exprType != symTable.errType) {
unaryExpr.opSymbol = Symbols.createTypeofOperatorSymbol(exprType, types, symTable, names);
actualType = unaryExpr.opSymbol.type.getReturnTypes().get(0);
}
} else {
exprType = checkExpr(unaryExpr.expr, env).get(0);
if (exprType != symTable.errType) {
BSymbol symbol = symResolver.resolveUnaryOperator(unaryExpr.pos, unaryExpr.operator, exprType);
if (symbol == symTable.notFoundSymbol) {
dlog.error(unaryExpr.pos, DiagnosticCode.UNARY_OP_INCOMPATIBLE_TYPES, unaryExpr.operator, exprType);
} else {
unaryExpr.opSymbol = (BOperatorSymbol) symbol;
actualType = symbol.type.getReturnTypes().get(0);
}
}
}
resultTypes = types.checkTypes(unaryExpr, Lists.of(actualType), expTypes);
}
Aggregations