use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class TypeChecker method checkStructLiteralKeyExpr.
private BType checkStructLiteralKeyExpr(BLangRecordKey key, BType recordType, RecordKind recKind) {
Name fieldName;
BLangExpression keyExpr = key.expr;
if (keyExpr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) {
BLangSimpleVarRef varRef = (BLangSimpleVarRef) keyExpr;
fieldName = names.fromIdNode(varRef.variableName);
} else {
// keys of the struct literal can only be a varRef (identifier)
dlog.error(keyExpr.pos, DiagnosticCode.INVALID_STRUCT_LITERAL_KEY);
return symTable.errType;
}
// Check weather the struct field exists
BSymbol fieldSymbol = symResolver.resolveStructField(keyExpr.pos, this.env, fieldName, recordType.tsymbol);
if (fieldSymbol == symTable.notFoundSymbol) {
dlog.error(keyExpr.pos, DiagnosticCode.UNDEFINED_STRUCT_FIELD, fieldName, recordType.tsymbol);
return symTable.errType;
}
// Setting the struct field symbol for future use in Desugar and code generator.
key.fieldSymbol = (BVarSymbol) fieldSymbol;
return fieldSymbol.type;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class BLangService method bindToEndpoint.
@Override
public void bindToEndpoint(SimpleVariableReferenceNode endpointRef) {
final BLangSimpleVarRef endpointVar = (BLangSimpleVarRef) endpointRef;
this.boundEndpoints.add(0, endpointVar);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createForeach.
static BLangForeach createForeach(DiagnosticPos pos, BLangBlockStmt target, BLangSimpleVarRef collectionVarRef, List<BLangSimpleVarRef> varRefs, List<BType> inputTypes) {
final BLangForeach foreach = (BLangForeach) TreeBuilder.createForeachNode();
foreach.pos = pos;
target.addStatement(foreach);
foreach.body = ASTBuilderUtil.createBlockStmt(pos);
foreach.collection = collectionVarRef;
foreach.varRefs.addAll(varRefs);
foreach.varTypes = inputTypes;
return foreach;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createVariableRef.
static BLangSimpleVarRef createVariableRef(DiagnosticPos pos, BVarSymbol varSymbol) {
final BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = pos;
varRef.variableName = createIdentifier(pos, varSymbol.name.value);
varRef.symbol = varSymbol;
varRef.type = varSymbol.type;
return varRef;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class Desugar method visitFunctionPointerInvocation.
// private functions
private void visitFunctionPointerInvocation(BLangInvocation iExpr) {
BLangVariableReference expr;
if (iExpr.expr == null) {
expr = new BLangSimpleVarRef();
} else {
BLangFieldBasedAccess fieldBasedAccess = new BLangFieldBasedAccess();
fieldBasedAccess.expr = iExpr.expr;
fieldBasedAccess.field = iExpr.name;
expr = fieldBasedAccess;
}
expr.symbol = (BVarSymbol) iExpr.symbol;
expr.type = iExpr.symbol.type;
expr = rewriteExpr(expr);
result = new BFunctionPointerInvocation(iExpr, expr);
}
Aggregations