use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TypeChecker method checkNamedTransformerInvocation.
private List<BType> checkNamedTransformerInvocation(BLangTypeConversionExpr conversionExpr, BType sourceType, BType targetType) {
List<BType> actualTypes = getListWithErrorTypes(expTypes.size());
BLangInvocation transformerInvocation = conversionExpr.transformerInvocation;
BSymbol transformerSymbol = symResolver.lookupSymbolInPackage(transformerInvocation.pos, env, names.fromIdNode(transformerInvocation.pkgAlias), names.fromIdNode(transformerInvocation.name), SymTag.TRANSFORMER);
if (transformerSymbol == symTable.notFoundSymbol) {
dlog.error(conversionExpr.pos, DiagnosticCode.UNDEFINED_TRANSFORMER, transformerInvocation.name);
} else {
conversionExpr.conversionSymbol = (BConversionOperatorSymbol) (transformerInvocation.symbol = transformerSymbol);
// Check the transformer invocation. Expected type for the transformer is the target type
// of the cast conversion operator, but not the lhs type.
List<BType> prevExpType = expTypes;
expTypes = Lists.of(targetType);
checkInvocationParamAndReturnType(transformerInvocation);
expTypes = prevExpType;
if (transformerInvocation.type != symTable.errType) {
BInvokableType transformerSymType = (BInvokableType) transformerSymbol.type;
transformerInvocation.types = transformerSymType.retTypes;
actualTypes = getActualTypesOfConversionExpr(conversionExpr, targetType, sourceType, conversionExpr.conversionSymbol);
}
}
return actualTypes;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class CompilerPluginRunner method isValidEndpoints.
private boolean isValidEndpoints(DefinitionID endpoint, CompilerPlugin plugin) {
PackageID pkdID = new PackageID(Names.ANON_ORG, names.fromString(endpoint.pkgName), Names.EMPTY);
BLangPackage pkgNode = this.packageCache.get(pkdID);
if (pkgNode == null) {
return false;
}
SymbolEnv pkgEnv = symTable.pkgEnvMap.get(pkgNode.symbol);
final BSymbol bSymbol = symResolver.lookupSymbol(pkgEnv, names.fromString(endpoint.name), SymTag.VARIABLE_NAME);
return bSymbol != symTable.notFoundSymbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangConnector connectorNode) {
BSymbol connectorSymbol = connectorNode.symbol;
SymbolEnv connectorEnv = SymbolEnv.createConnectorEnv(connectorNode, connectorSymbol.scope, env);
connectorNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.CONNECTOR);
this.analyzeDef(a, connectorEnv);
});
connectorNode.docAttachments.forEach(doc -> analyzeDef(doc, connectorEnv));
connectorNode.params.forEach(param -> this.analyzeDef(param, connectorEnv));
connectorNode.varDefs.forEach(varDef -> this.analyzeDef(varDef, connectorEnv));
connectorNode.endpoints.forEach(e -> analyzeDef(e, connectorEnv));
this.analyzeDef(connectorNode.initFunction, connectorEnv);
connectorNode.actions.forEach(action -> this.analyzeDef(action, connectorEnv));
this.analyzeDef(connectorNode.initAction, connectorEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangCompoundAssignment compoundAssignment) {
List<BType> expTypes = new ArrayList<>();
BLangExpression varRef = compoundAssignment.varRef;
if (varRef.getKind() != NodeKind.SIMPLE_VARIABLE_REF && varRef.getKind() != NodeKind.INDEX_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.FIELD_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.XML_ATTRIBUTE_ACCESS_EXPR) {
dlog.error(varRef.pos, DiagnosticCode.INVALID_VARIABLE_ASSIGNMENT, varRef);
expTypes.add(symTable.errType);
} else {
this.typeChecker.checkExpr(varRef, env).get(0);
expTypes.add(varRef.type);
}
this.typeChecker.checkExpr(compoundAssignment.expr, env).get(0);
if (expTypes.get(0) != symTable.errType && compoundAssignment.expr.type != symTable.errType) {
BSymbol opSymbol = this.symResolver.resolveBinaryOperator(compoundAssignment.opKind, expTypes.get(0), compoundAssignment.expr.type);
if (opSymbol == symTable.notFoundSymbol) {
dlog.error(compoundAssignment.pos, DiagnosticCode.BINARY_OP_INCOMPATIBLE_TYPES, compoundAssignment.opKind, expTypes.get(0), compoundAssignment.expr.type);
} else {
compoundAssignment.modifiedExpr = getBinaryExpr(varRef, compoundAssignment.expr, compoundAssignment.opKind, opSymbol);
this.types.checkTypes(compoundAssignment.modifiedExpr, Lists.of(compoundAssignment.modifiedExpr.type), expTypes);
}
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangAction actionNode) {
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, env);
actionNode.annAttachments.forEach(a -> {
a.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.ACTION);
this.analyzeDef(a, actionEnv);
});
actionNode.docAttachments.forEach(doc -> analyzeDef(doc, actionEnv));
if (Symbols.isNative(actionSymbol)) {
return;
}
actionNode.requiredParams.forEach(p -> this.analyzeDef(p, actionEnv));
actionNode.defaultableParams.forEach(p -> this.analyzeDef(p, actionEnv));
if (actionNode.restParam != null) {
this.analyzeDef(actionNode.restParam, actionEnv);
}
actionNode.endpoints.forEach(e -> analyzeDef(e, actionEnv));
analyzeStmt(actionNode.body, actionEnv);
this.processWorkers(actionNode, actionEnv);
}
Aggregations