Search in sources :

Example 66 with SymbolEnv

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

the class CodeGenerator method visit.

public void visit(BLangResource resourceNode) {
    ResourceInfo resourceInfo = currentServiceInfo.resourceInfoMap.get(resourceNode.name.getValue());
    currentCallableUnitInfo = resourceInfo;
    SymbolEnv resourceEnv = SymbolEnv.createResourceActionSymbolEnv(resourceNode, resourceNode.symbol.scope, this.env);
    visitInvokableNode(resourceNode, currentCallableUnitInfo, resourceEnv);
}
Also used : ResourceInfo(org.wso2.ballerinalang.programfile.ResourceInfo) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 67 with SymbolEnv

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

the class Desugar method visit.

@Override
public void visit(BLangResource resourceNode) {
    addReturnIfNotPresent(resourceNode);
    SymbolEnv resourceEnv = SymbolEnv.createResourceActionSymbolEnv(resourceNode, resourceNode.symbol.scope, env);
    // To preserve endpoint code gen order at resource
    Collections.reverse(resourceNode.endpoints);
    resourceNode.endpoints = rewrite(resourceNode.endpoints, resourceEnv);
    resourceNode.body = rewrite(resourceNode.body, resourceEnv);
    resourceNode.workers = rewrite(resourceNode.workers, resourceEnv);
    result = resourceNode;
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 68 with SymbolEnv

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

the class Desugar method visit.

@Override
public void visit(BLangService serviceNode) {
    SymbolEnv serviceEnv = SymbolEnv.createServiceEnv(serviceNode, serviceNode.symbol.scope, env);
    serviceNode.resources = rewrite(serviceNode.resources, serviceEnv);
    serviceNode.vars = rewrite(serviceNode.vars, serviceEnv);
    serviceNode.endpoints = rewrite(serviceNode.endpoints, serviceEnv);
    serviceNode.initFunction = rewrite(serviceNode.initFunction, serviceEnv);
    result = serviceNode;
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 69 with SymbolEnv

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

the class Desugar method visit.

@Override
public void visit(BLangFunction funcNode) {
    SymbolEnv fucEnv = SymbolEnv.createFunctionEnv(funcNode, funcNode.symbol.scope, env);
    if (!funcNode.interfaceFunction) {
        addReturnIfNotPresent(funcNode);
    }
    // To preserve endpoint code gen order.
    Collections.reverse(funcNode.endpoints);
    funcNode.endpoints = rewrite(funcNode.endpoints, fucEnv);
    funcNode.body = rewrite(funcNode.body, fucEnv);
    funcNode.workers = rewrite(funcNode.workers, fucEnv);
    // the struct variable as the first parameter
    if (funcNode.receiver != null) {
        BInvokableSymbol funcSymbol = funcNode.symbol;
        List<BVarSymbol> params = funcSymbol.params;
        params.add(0, funcNode.receiver.symbol);
        BInvokableType funcType = (BInvokableType) funcSymbol.type;
        funcType.paramTypes.add(0, funcNode.receiver.type);
    }
    result = funcNode;
}
Also used : BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)

Example 70 with SymbolEnv

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

the class Desugar method visit.

@Override
public void visit(BLangConnector connectorNode) {
    SymbolEnv conEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorNode.symbol.scope, env);
    connectorNode.params = rewrite(connectorNode.params, conEnv);
    connectorNode.actions = rewrite(connectorNode.actions, conEnv);
    connectorNode.varDefs = rewrite(connectorNode.varDefs, conEnv);
    connectorNode.endpoints = rewrite(connectorNode.endpoints, conEnv);
    connectorNode.initFunction = rewrite(connectorNode.initFunction, conEnv);
    connectorNode.initAction = rewrite(connectorNode.initAction, conEnv);
    result = connectorNode;
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Aggregations

SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)125 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)47 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)30 Name (org.wso2.ballerinalang.compiler.util.Name)26 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)25 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)25 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)24 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)22 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)20 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)20 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)20 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)19 Scope (org.wso2.ballerinalang.compiler.semantics.model.Scope)18 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)18 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)18 TopLevelNode (org.ballerinalang.model.tree.TopLevelNode)17 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)17 BLangAnnotation (org.wso2.ballerinalang.compiler.tree.BLangAnnotation)17 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)17 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)17