use of org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addEndpointType.
public void addEndpointType(DiagnosticPos pos, Set<Whitespace> ws) {
BLangNameReference nameReference = nameReferenceStack.pop();
BLangUserDefinedType constraintType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
constraintType.pos = pos;
constraintType.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
constraintType.typeName = (BLangIdentifier) nameReference.name;
constraintType.addWS(nameReference.ws);
addType(constraintType);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addConstraintType.
public void addConstraintType(DiagnosticPos pos, Set<Whitespace> ws, String typeName) {
BLangNameReference nameReference = nameReferenceStack.pop();
BLangUserDefinedType constraintType = (BLangUserDefinedType) TreeBuilder.createUserDefinedTypeNode();
constraintType.pos = pos;
constraintType.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
constraintType.typeName = (BLangIdentifier) nameReference.name;
constraintType.addWS(nameReference.ws);
Set<Whitespace> refTypeWS = removeNthFromLast(ws, 2);
BLangBuiltInRefTypeNode refType = (BLangBuiltInRefTypeNode) TreeBuilder.createBuiltInReferenceTypeNode();
refType.typeKind = TreeUtils.stringToTypeKind(typeName);
refType.pos = pos;
refType.addWS(refTypeWS);
BLangConstrainedType constrainedType = (BLangConstrainedType) TreeBuilder.createConstrainedTypeNode();
constrainedType.type = refType;
constrainedType.constraint = constraintType;
constrainedType.pos = pos;
constrainedType.addWS(ws);
addType(constrainedType);
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType 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.types.BLangUserDefinedType in project ballerina by ballerina-lang.
the class TypeChecker method getTypeAccessExpression.
private BLangTypeofExpr getTypeAccessExpression(BLangSimpleVarRef varRef) {
BLangUserDefinedType userDefinedType = new BLangUserDefinedType();
userDefinedType.pkgAlias = varRef.pkgAlias;
userDefinedType.typeName = varRef.variableName;
userDefinedType.pos = varRef.pos;
BLangTypeofExpr typeAccessExpr = (BLangTypeofExpr) TreeBuilder.createTypeAccessNode();
typeAccessExpr.typeNode = userDefinedType;
typeAccessExpr.resolvedType = symResolver.resolveTypeNode(userDefinedType, env);
typeAccessExpr.pos = varRef.pos;
typeAccessExpr.type = symTable.typeDesc;
return typeAccessExpr;
}
use of org.wso2.ballerinalang.compiler.tree.types.BLangUserDefinedType in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addUserDefineType.
public void addUserDefineType(Set<Whitespace> ws) {
BLangNameReference nameReference = nameReferenceStack.pop();
BLangUserDefinedType userDefinedType = createUserDefinedType(nameReference.pos, ws, (BLangIdentifier) nameReference.pkgAlias, (BLangIdentifier) nameReference.name);
userDefinedType.addWS(nameReference.ws);
addType(userDefinedType);
}
Aggregations