use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
// Visitor methods
public void visit(BLangPackage pkgNode) {
if (pkgNode.completedPhases.contains(CompilerPhase.TYPE_CHECK)) {
return;
}
SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgNode.symbol);
// Visit all the imported packages
pkgNode.imports.forEach(importNode -> analyzeDef(importNode, pkgEnv));
// Then visit each top-level element sorted using the compilation unit
pkgNode.topLevelNodes.forEach(topLevelNode -> analyzeDef((BLangNode) topLevelNode, pkgEnv));
analyzeDef(pkgNode.initFunction, pkgEnv);
analyzeDef(pkgNode.startFunction, pkgEnv);
analyzeDef(pkgNode.stopFunction, pkgEnv);
pkgNode.completedPhases.add(CompilerPhase.TYPE_CHECK);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangImportPackage importPkgNode) {
BPackageSymbol pkgSymbol = importPkgNode.symbol;
SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgSymbol);
if (pkgEnv == null) {
return;
}
analyzeDef(pkgEnv.node, pkgEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangForeach foreach) {
typeChecker.checkExpr(foreach.collection, env);
foreach.varTypes = types.checkForeachTypes(foreach.collection, foreach.varRefs.size());
SymbolEnv blockEnv = SymbolEnv.createBlockEnv(foreach.body, env);
handleForeachVariables(foreach, foreach.varTypes, blockEnv);
analyzeStmt(foreach.body, blockEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
@Override
public void visit(BLangTransformer transformerNode) {
SymbolEnv transformerEnv = SymbolEnv.createTransformerEnv(transformerNode, transformerNode.symbol.scope, env);
transformerNode.annAttachments.forEach(annotationAttachment -> {
annotationAttachment.attachmentPoint = new BLangAnnotationAttachmentPoint(BLangAnnotationAttachmentPoint.AttachmentPoint.TRANSFORMER);
this.analyzeDef(annotationAttachment, transformerEnv);
});
transformerNode.docAttachments.forEach(doc -> analyzeDef(doc, transformerEnv));
validateTransformerMappingType(transformerNode.source);
validateTransformerMappingType(transformerNode.retParams.get(0));
analyzeStmt(transformerNode.body, transformerEnv);
// TODO: update this accordingly once the unsafe conversion are supported
int returnCount = transformerNode.retParams.size();
if (returnCount == 0) {
dlog.error(transformerNode.pos, DiagnosticCode.TRANSFORMER_MUST_HAVE_OUTPUT);
} else if (returnCount > 1) {
dlog.error(transformerNode.pos, DiagnosticCode.TOO_MANY_OUTPUTS_FOR_TRANSFORMER, 1, returnCount);
}
this.processWorkers(transformerNode, transformerEnv);
}
use of org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv in project ballerina by ballerina-lang.
the class TypeChecker method checkExpr.
public List<BType> checkExpr(BLangExpression expr, SymbolEnv env, List<BType> expTypes, DiagnosticCode diagCode) {
// TODO Check the possibility of using a try/finally here
SymbolEnv prevEnv = this.env;
List<BType> preExpTypes = this.expTypes;
DiagnosticCode preDiagCode = this.diagCode;
this.env = env;
this.diagCode = diagCode;
this.expTypes = expTypes;
expr.accept(this);
setExprType(expr, expTypes);
this.env = prevEnv;
this.expTypes = preExpTypes;
this.diagCode = preDiagCode;
return resultTypes;
}
Aggregations