use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangConnector connectorNode) {
BConnectorSymbol conSymbol = Symbols.createConnectorSymbol(Flags.asMask(connectorNode.flagSet), names.fromIdNode(connectorNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
connectorNode.symbol = conSymbol;
defineSymbol(connectorNode.pos, conSymbol);
SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, conSymbol.scope, env);
connectorNode.endpoints.forEach(ep -> defineNode(ep, connectorEnv));
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method defineVarSymbol.
public BVarSymbol defineVarSymbol(DiagnosticPos pos, Set<Flag> flagSet, BType varType, Name varName, SymbolEnv env) {
// Create variable symbol
Scope enclScope = env.scope;
BVarSymbol varSymbol;
if (varType.tag == TypeTags.INVOKABLE) {
varSymbol = new BInvokableSymbol(SymTag.VARIABLE, Flags.asMask(flagSet), varName, env.enclPkg.symbol.pkgID, varType, enclScope.owner);
} else {
varSymbol = new BVarSymbol(Flags.asMask(flagSet), varName, env.enclPkg.symbol.pkgID, varType, enclScope.owner);
}
// Find duplicates
if (!symResolver.checkForUniqueSymbol(pos, env, varSymbol, SymTag.VARIABLE_NAME)) {
varSymbol.type = symTable.errType;
}
enclScope.define(varSymbol.name, varSymbol);
return varSymbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method defineTransformerMembers.
private void defineTransformerMembers(List<BLangTransformer> transformers, SymbolEnv pkgEnv) {
transformers.forEach(transformer -> {
SymbolEnv transformerEnv = SymbolEnv.createTransformerEnv(transformer, transformer.symbol.scope, pkgEnv);
defineInvokableSymbolParams(transformer, transformer.symbol, transformerEnv);
});
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method defineConnectorInitFunction.
private void defineConnectorInitFunction(BLangConnector connector, SymbolEnv conEnv) {
BLangFunction initFunction = createInitFunction(connector.pos, connector.getName().getValue(), Names.INIT_FUNCTION_SUFFIX);
// Add connector as a parameter to the init function
BLangVariable param = (BLangVariable) TreeBuilder.createVariableNode();
param.pos = connector.pos;
param.setName(this.createIdentifier(Names.CONNECTOR.getValue()));
BLangUserDefinedType connectorType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
connectorType.pos = connector.pos;
connectorType.typeName = connector.name;
connectorType.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
param.setTypeNode(connectorType);
initFunction.addParameter(param);
// Add connector level variables to the init function
connector.varDefs.stream().filter(f -> f.var.expr != null).forEachOrdered(v -> initFunction.body.addStatement(createAssignmentStmt(v.var)));
addInitReturnStatement(initFunction.body);
connector.initFunction = initFunction;
BLangAction initAction = createNativeInitAction(connector.pos);
connector.initAction = initAction;
defineNode(connector.initFunction, conEnv);
defineNode(connector.initAction, conEnv);
connector.symbol.initFunctionSymbol = connector.initFunction.symbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method defineNode.
public void defineNode(BLangNode node, SymbolEnv env) {
SymbolEnv prevEnv = this.env;
this.env = env;
node.accept(this);
this.env = prevEnv;
}
Aggregations