Search in sources :

Example 36 with BLangVariable

use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.

the class BLangPackageBuilder method endObjectFieldList.

void endObjectFieldList(boolean isPublic) {
    BLangObject objectNode = (BLangObject) this.objectStack.peek();
    this.varListStack.pop().forEach(variableNode -> {
        ((BLangVariable) variableNode).docTag = DocTag.FIELD;
        if (isPublic) {
            ((BLangVariable) variableNode).flagSet.add(Flag.PUBLIC);
        }
        objectNode.addField(variableNode);
    });
    this.varListStack.push(new ArrayList<>());
}
Also used : BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject)

Example 37 with BLangVariable

use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.

the class BLangPackageBuilder method generateBasicVarNode.

private VariableNode generateBasicVarNode(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    var.pos = pos;
    IdentifierNode name = this.createIdentifier(identifier);
    var.setName(name);
    var.addWS(ws);
    var.setTypeNode(this.typeNodeStack.pop());
    if (exprAvailable) {
        var.setInitialExpression(this.exprNodeStack.pop());
    }
    return var;
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 38 with BLangVariable

use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.

the class BLangPackageBuilder method populateStructNode.

private BLangStruct populateStructNode(DiagnosticPos pos, Set<Whitespace> ws, IdentifierNode name, boolean isAnonymous) {
    BLangStruct structNode = (BLangStruct) this.structStack.pop();
    structNode.pos = pos;
    structNode.addWS(ws);
    structNode.name = (BLangIdentifier) name;
    structNode.isAnonymous = isAnonymous;
    this.varListStack.pop().forEach(variableNode -> {
        ((BLangVariable) variableNode).docTag = DocTag.FIELD;
        structNode.addField(variableNode);
    });
    return structNode;
}
Also used : BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct)

Example 39 with BLangVariable

use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.

the class BLangPackageBuilder method addEndpointVariable.

public void addEndpointVariable(DiagnosticPos pos, Set<Whitespace> ws, String endpointName) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    var.pos = pos;
    // endpointName has to be redefine at semantic analyze phase. So appending $ to make it work.
    IdentifierNode name = this.createIdentifier("$" + endpointName);
    var.setName(name);
    var.addWS(ws);
    // Type will be calculated at SymEnter phase.
    if (varListStack.empty()) {
        varListStack.push(new ArrayList<>());
    }
    varListStack.peek().add(0, var);
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 40 with BLangVariable

use of org.wso2.ballerinalang.compiler.tree.BLangVariable in project ballerina by ballerina-lang.

the class BLangPackageBuilder method generateObjectVarNode.

private VariableNode generateObjectVarNode(DiagnosticPos pos, Set<Whitespace> ws, boolean isField, String identifier, boolean exprAvailable) {
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    var.pos = pos;
    IdentifierNode name = this.createIdentifier(identifier);
    var.setName(name);
    var.addWS(ws);
    var.isField = isField;
    if (!isField) {
        var.setTypeNode(this.typeNodeStack.pop());
    }
    if (exprAvailable) {
        var.setInitialExpression(this.exprNodeStack.pop());
    }
    return var;
}
Also used : IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Aggregations

BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)77 ArrayList (java.util.ArrayList)21 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)20 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)18 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)18 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)16 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)15 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)14 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)11 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)10 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)10 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)10 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)9 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)8 Whitespace (org.ballerinalang.model.Whitespace)7 BLangObject (org.wso2.ballerinalang.compiler.tree.BLangObject)7 BLangRecordLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral)7 Name (org.wso2.ballerinalang.compiler.util.Name)7 HashMap (java.util.HashMap)6 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)6