use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method resolveAnnotationAttributeTypes.
@Deprecated
private void resolveAnnotationAttributeTypes(List<BLangAnnotation> annotations, SymbolEnv pkgEnv) {
annotations.forEach(annotation -> {
annotation.attributes.forEach(attribute -> {
SymbolEnv annotationEnv = SymbolEnv.createAnnotationEnv(annotation, annotation.symbol.scope, pkgEnv);
BType actualType = this.symResolver.resolveTypeNode(attribute.typeNode, annotationEnv);
attribute.symbol.type = actualType;
});
});
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
public void visit(BLangAnnotation annotationNode) {
BSymbol annotationSymbol = Symbols.createAnnotationSymbol(Flags.asMask(annotationNode.flagSet), names.fromIdNode(annotationNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
annotationSymbol.type = new BAnnotationType((BAnnotationSymbol) annotationSymbol);
annotationNode.attachmentPoints.forEach(point -> ((BAnnotationSymbol) annotationSymbol).attachmentPoints.add(point));
annotationNode.symbol = annotationSymbol;
defineSymbol(annotationNode.pos, annotationSymbol);
SymbolEnv annotationEnv = SymbolEnv.createAnnotationEnv(annotationNode, annotationSymbol.scope, env);
annotationNode.attributes.forEach(att -> this.defineNode(att, annotationEnv));
if (annotationNode.typeNode != null) {
BType structType = this.symResolver.resolveTypeNode(annotationNode.typeNode, annotationEnv);
((BAnnotationSymbol) annotationSymbol).attachedType = structType.tsymbol;
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method defineStructFields.
private void defineStructFields(List<BLangStruct> structNodes, SymbolEnv pkgEnv) {
structNodes.forEach(struct -> {
// Create struct type
SymbolEnv structEnv = SymbolEnv.createPkgLevelSymbolEnv(struct, struct.symbol.scope, pkgEnv);
BStructType structType = (BStructType) struct.symbol.type;
structType.fields = struct.fields.stream().peek(field -> defineNode(field, structEnv)).map(field -> new BStructField(names.fromIdNode(field.name), field.symbol)).collect(Collectors.toList());
});
// define init function
structNodes.forEach(struct -> {
SymbolEnv structEnv = SymbolEnv.createPkgLevelSymbolEnv(struct, struct.symbol.scope, pkgEnv);
defineStructInitFunction(struct, structEnv);
});
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method definePackageInitFunctions.
private void definePackageInitFunctions(BLangPackage pkgNode, SymbolEnv env) {
BLangFunction initFunction = pkgNode.initFunction;
// Add package level namespace declarations to the init function
pkgNode.xmlnsList.forEach(xmlns -> {
initFunction.body.addStatement(createNamespaceDeclrStatement(xmlns));
});
// Add global variables to the init function
pkgNode.globalVars.stream().filter(f -> f.expr != null).forEachOrdered(v -> initFunction.body.addStatement(createAssignmentStmt(v)));
addInitReturnStatement(initFunction.body);
defineNode(pkgNode.initFunction, env);
pkgNode.symbol.initFunctionSymbol = pkgNode.initFunction.symbol;
addInitReturnStatement(pkgNode.startFunction.body);
defineNode(pkgNode.startFunction, env);
pkgNode.symbol.startFunctionSymbol = pkgNode.startFunction.symbol;
addInitReturnStatement(pkgNode.stopFunction.body);
defineNode(pkgNode.stopFunction, env);
pkgNode.symbol.stopFunctionSymbol = pkgNode.stopFunction.symbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangEnum enumNode) {
BTypeSymbol enumSymbol = Symbols.createEnumSymbol(Flags.asMask(enumNode.flagSet), names.fromIdNode(enumNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
enumNode.symbol = enumSymbol;
defineSymbol(enumNode.pos, enumSymbol);
BEnumType enumType = new BEnumType(enumSymbol, null);
enumSymbol.type = enumType;
SymbolEnv enumEnv = SymbolEnv.createPkgLevelSymbolEnv(enumNode, enumSymbol.scope, this.env);
for (int i = 0; i < enumNode.enumerators.size(); i++) {
BLangEnumerator enumerator = enumNode.enumerators.get(i);
BVarSymbol enumeratorSymbol = new BVarSymbol(Flags.PUBLIC, names.fromIdNode(enumerator.name), enumSymbol.pkgID, enumType, enumSymbol);
enumeratorSymbol.docTag = DocTag.FIELD;
enumerator.symbol = enumeratorSymbol;
if (symResolver.checkForUniqueSymbol(enumerator.pos, enumEnv, enumeratorSymbol, enumeratorSymbol.tag)) {
enumEnv.scope.define(enumeratorSymbol.name, enumeratorSymbol);
}
}
}
Aggregations