use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangBind bindNode) {
List<BType> expTypes = new ArrayList<>();
// Check each LHS expression.
BLangExpression varRef = bindNode.varRef;
((BLangVariableReference) varRef).lhsVar = true;
expTypes.add(typeChecker.checkExpr(varRef, env).get(0));
checkConstantAssignment(varRef);
typeChecker.checkExpr(bindNode.expr, this.env, expTypes);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangBinaryExpr binaryExpr) {
ExpressionNode leftExpression = binaryExpr.getLeftExpression();
((BLangExpression) leftExpression).accept(this);
ExpressionNode rightExpression = binaryExpr.getRightExpression();
((BLangExpression) rightExpression).accept(this);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangWindow windowClause) {
ExpressionNode expressionNode = windowClause.getFunctionInvocation();
((BLangExpression) expressionNode).accept(this);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SemanticAnalyzer method handleForeachVariables.
// Private methods
private void handleForeachVariables(BLangForeach foreachStmt, List<BType> varTypes, SymbolEnv env) {
for (int i = 0; i < foreachStmt.varRefs.size(); i++) {
BLangExpression varRef = foreachStmt.varRefs.get(i);
// foreach variables supports only simpleVarRef expressions only.
if (varRef.getKind() != NodeKind.SIMPLE_VARIABLE_REF) {
dlog.error(varRef.pos, DiagnosticCode.INVALID_VARIABLE_ASSIGNMENT, varRef);
continue;
}
BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) varRef;
simpleVarRef.lhsVar = true;
Name varName = names.fromIdNode(simpleVarRef.variableName);
if (varName == Names.IGNORE) {
simpleVarRef.type = this.symTable.noType;
typeChecker.checkExpr(simpleVarRef, env);
continue;
}
// Check variable symbol for existence.
BSymbol symbol = symResolver.lookupSymbol(env, varName, SymTag.VARIABLE);
if (symbol == symTable.notFoundSymbol) {
symbolEnter.defineVarSymbol(simpleVarRef.pos, Collections.emptySet(), varTypes.get(i), varName, env);
typeChecker.checkExpr(simpleVarRef, env);
} else {
dlog.error(simpleVarRef.pos, DiagnosticCode.REDECLARED_SYMBOL, varName);
}
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class TypeChecker method getTypeOfExprInFieldAccess.
private BType getTypeOfExprInFieldAccess(BLangExpression expr) {
// First check whether variable expression is of type enum.
if (expr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
BLangSimpleVarRef varRef = (BLangSimpleVarRef) expr;
BSymbol symbol = symResolver.lookupSymbolInPackage(varRef.pos, env, names.fromIdNode(varRef.pkgAlias), names.fromIdNode(varRef.variableName), SymTag.ENUM);
if (symbol != symTable.notFoundSymbol) {
expr.type = symbol.type;
return symbol.type;
}
}
checkExpr(expr, this.env, Lists.of(symTable.noType));
return expr.type;
}
Aggregations