use of org.wso2.ballerinalang.compiler.semantics.model.types.BType 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.types.BType in project ballerina by ballerina-lang.
the class SymbolEnter method validateFuncReceiver.
private boolean validateFuncReceiver(BLangFunction funcNode) {
if (funcNode.receiver == null) {
return true;
}
BType varType = symResolver.resolveTypeNode(funcNode.receiver.typeNode, env);
funcNode.receiver.type = varType;
if (varType.tag == TypeTags.ERROR) {
return true;
}
if (varType.tag != TypeTags.BOOLEAN && varType.tag != TypeTags.STRING && varType.tag != TypeTags.INT && varType.tag != TypeTags.FLOAT && varType.tag != TypeTags.BLOB && varType.tag != TypeTags.JSON && varType.tag != TypeTags.XML && varType.tag != TypeTags.MAP && varType.tag != TypeTags.TABLE && varType.tag != TypeTags.STREAM && varType.tag != TypeTags.FUTURE && varType.tag != TypeTags.STRUCT) {
dlog.error(funcNode.receiver.pos, DiagnosticCode.FUNC_DEFINED_ON_NOT_SUPPORTED_TYPE, funcNode.name.value, varType.toString());
return false;
}
if (!this.env.enclPkg.symbol.pkgID.equals(varType.tsymbol.pkgID)) {
dlog.error(funcNode.receiver.pos, DiagnosticCode.FUNC_DEFINED_ON_NON_LOCAL_TYPE, funcNode.name.value, varType.toString());
return false;
}
return true;
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolEnter method validateTransformerMappingTypes.
private void validateTransformerMappingTypes(BLangTransformer transformerNode) {
BType varType = symResolver.resolveTypeNode(transformerNode.source.typeNode, env);
transformerNode.source.type = varType;
transformerNode.retParams.forEach(returnParams -> {
BType targetType = symResolver.resolveTypeNode(returnParams.typeNode, env);
returnParams.type = targetType;
});
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType 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.types.BType 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;
}
}
Aggregations