Search in sources :

Example 36 with BVarSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangVariable varNode) {
    BVarSymbol varSymbol = varNode.symbol;
    int ownerSymTag = env.scope.owner.tag;
    if ((ownerSymTag & SymTag.INVOKABLE) == SymTag.INVOKABLE) {
        varSymbol.varIndex = getLVIndex(varSymbol.type.tag);
        LocalVariableInfo localVarInfo = getLocalVarAttributeInfo(varSymbol);
        localVarAttrInfo.localVars.add(localVarInfo);
    } else {
        // TODO Support other variable nodes
        throw new IllegalStateException("");
    }
    BLangExpression rhsExpr = varNode.expr;
    if (rhsExpr != null) {
        rhsExpr.regIndex = varSymbol.varIndex;
        genNode(rhsExpr, this.env);
    }
}
Also used : LocalVariableInfo(org.wso2.ballerinalang.programfile.LocalVariableInfo) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 37 with BVarSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.

the class CodeGenerator method visitVarSymbol.

private void visitVarSymbol(BVarSymbol varSymbol, VariableIndex variableIndex, LocalVariableAttributeInfo localVarAttrInfo) {
    varSymbol.varIndex = getRegIndexInternal(varSymbol.type.tag, variableIndex.kind);
    LocalVariableInfo localVarInfo = getLocalVarAttributeInfo(varSymbol);
    localVarAttrInfo.localVars.add(localVarInfo);
}
Also used : LocalVariableInfo(org.wso2.ballerinalang.programfile.LocalVariableInfo)

Example 38 with BVarSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.

the class ASTBuilderUtil method createIndexBasesAccessExpr.

static BLangIndexBasedAccess createIndexBasesAccessExpr(DiagnosticPos pos, BType type, BVarSymbol varSymbol, BLangExpression indexExpr) {
    final BLangIndexBasedAccess arrayAccess = (BLangIndexBasedAccess) TreeBuilder.createIndexBasedAccessNode();
    arrayAccess.pos = pos;
    arrayAccess.expr = createVariableRef(pos, varSymbol);
    arrayAccess.indexExpr = indexExpr;
    arrayAccess.type = type;
    return arrayAccess;
}
Also used : BLangIndexBasedAccess(org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)

Example 39 with BVarSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol 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;
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)

Example 40 with BVarSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.

the class ASTBuilderUtil method defineVariable.

static void defineVariable(BLangVariable variable, BSymbol targetSymbol, Names names) {
    variable.symbol = new BVarSymbol(0, names.fromIdNode(variable.name), targetSymbol.pkgID, variable.type, targetSymbol);
    targetSymbol.scope.define(variable.symbol.name, variable.symbol);
}
Also used : BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)

Aggregations

BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)29 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)16 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)15 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)13 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)12 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)12 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)11 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)10 Name (org.wso2.ballerinalang.compiler.util.Name)10 ArrayList (java.util.ArrayList)9 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)9 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)8 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)8 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)8 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)7 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)7 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)7 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)6 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)6 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)6