use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class BLangPackageBuilder method endServiceDef.
public void endServiceDef(DiagnosticPos pos, Set<Whitespace> ws, String serviceName, boolean constrained) {
BLangService serviceNode = (BLangService) serviceNodeStack.pop();
serviceNode.setName(createIdentifier(serviceName));
if (constrained) {
final BLangNameReference epName = nameReferenceStack.pop();
serviceNode.setServiceTypeStruct(createUserDefinedType(pos, epName.ws, (BLangIdentifier) epName.pkgAlias, (BLangIdentifier) epName.name));
}
serviceNode.pos = pos;
serviceNode.addWS(ws);
this.compUnit.addTopLevelNode(serviceNode);
endEndpointDeclarationScope();
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class PackageLoader method loadAndDefinePackage.
public BLangPackage loadAndDefinePackage(BLangIdentifier orgName, List<BLangIdentifier> pkgNameComps, BLangIdentifier version) {
// TODO This method is only used by the composer. Can we refactor the composer code?
List<Name> nameComps = pkgNameComps.stream().map(identifier -> names.fromIdNode(identifier)).collect(Collectors.toList());
PackageID pkgID = new PackageID(names.fromIdNode(orgName), nameComps, names.fromIdNode(version));
return loadAndDefinePackage(pkgID);
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier 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.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class SymbolEnter method createAssignmentStmt.
private StatementNode createAssignmentStmt(BLangVariable variable, BVarSymbol varSym, BVarSymbol fieldVar) {
// Create LHS reference variable
BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = variable.pos;
varRef.variableName = (BLangIdentifier) createIdentifier(fieldVar.name.getValue());
varRef.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
// Create RHS variable reference
BLangSimpleVarRef exprVar = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
exprVar.pos = variable.pos;
exprVar.variableName = (BLangIdentifier) createIdentifier(varSym.name.getValue());
exprVar.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
// Create assignment statement
BLangAssignment assignmentStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignmentStmt.expr = exprVar;
assignmentStmt.pos = variable.pos;
assignmentStmt.addVariable(varRef);
return assignmentStmt;
}
use of org.wso2.ballerinalang.compiler.tree.BLangIdentifier in project ballerina by ballerina-lang.
the class SymbolEnter method createAssignmentStmt.
private StatementNode createAssignmentStmt(BLangVariable variable) {
BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = variable.pos;
varRef.variableName = variable.name;
varRef.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
BLangAssignment assignmentStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignmentStmt.expr = variable.expr;
assignmentStmt.pos = variable.pos;
assignmentStmt.addVariable(varRef);
return assignmentStmt;
}
Aggregations