Search in sources :

Example 6 with BLangObject

use of org.wso2.ballerinalang.compiler.tree.BLangObject 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 7 with BLangObject

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

the class BLangPackageBuilder method addFieldToObject.

void addFieldToObject(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean exprAvailable, int annotCount, boolean isPrivate) {
    Set<Whitespace> wsForSemiColon = removeNthFromLast(ws, 0);
    BLangObject objectNode = (BLangObject) this.objectStack.peek();
    objectNode.addWS(wsForSemiColon);
    BLangVariable field = addVar(pos, ws, identifier, exprAvailable, annotCount);
    if (!isPrivate) {
        field.flagSet.add(Flag.PUBLIC);
    }
}
Also used : BLangObject(org.wso2.ballerinalang.compiler.tree.BLangObject) Whitespace(org.ballerinalang.model.Whitespace) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 8 with BLangObject

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

the class TreeVisitor method visit.

@Override
public void visit(BLangObject objectNode) {
    BSymbol objectSymbol = objectNode.symbol;
    SymbolEnv objectEnv = SymbolEnv.createPkgLevelSymbolEnv(objectNode, objectSymbol.scope, symbolEnv);
    blockOwnerStack.push(objectNode);
    this.cursorPositionResolver = ObjectTypeScopeResolver.class;
    objectNode.fields.forEach(field -> acceptNode(field, objectEnv));
    // TODO: visit annotation and doc attachments
    objectNode.functions.forEach(f -> acceptNode(f, objectEnv));
    blockOwnerStack.pop();
    this.cursorPositionResolver = TopLevelNodeScopeResolver.class;
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 9 with BLangObject

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

the class SymbolEnter method visit.

@Override
public void visit(BLangObject objectNode) {
    BSymbol objectSymbol = Symbols.createObjectSymbol(Flags.asMask(objectNode.flagSet), names.fromIdNode(objectNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
    objectNode.symbol = objectSymbol;
    // Create struct type
    objectNode.symbol.type = new BStructType((BTypeSymbol) objectNode.symbol);
    defineSymbol(objectNode.pos, objectSymbol);
}
Also used : BStructType(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) BTypeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol)

Example 10 with BLangObject

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

the class TaintAnalyzer method visit.

public void visit(BLangObject objectNode) {
    BSymbol objectSymbol = objectNode.symbol;
    SymbolEnv objectEnv = SymbolEnv.createPkgLevelSymbolEnv(objectNode, objectSymbol.scope, env);
    objectNode.fields.forEach(field -> analyzeNode(field, objectEnv));
    analyzeNode(objectNode.initFunction, objectEnv);
    objectNode.functions.forEach(f -> analyzeNode(f, objectEnv));
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Aggregations

BLangObject (org.wso2.ballerinalang.compiler.tree.BLangObject)8 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)6 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)6 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)6 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)6 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)5 List (java.util.List)3 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)3 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)3 BTypeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol)3 Name (org.wso2.ballerinalang.compiler.util.Name)3 ArrayList (java.util.ArrayList)2 EnumSet (java.util.EnumSet)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 XMLConstants (javax.xml.XMLConstants)2 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)2 TreeBuilder (org.ballerinalang.model.TreeBuilder)2 DocTag (org.ballerinalang.model.elements.DocTag)2 Flag (org.ballerinalang.model.elements.Flag)2