use of org.wso2.ballerinalang.compiler.tree.BLangNode in project ballerina by ballerina-lang.
the class CodeGenerator method genNode.
// private methods
private <T extends BLangNode, U extends SymbolEnv> T genNode(T t, U u) {
SymbolEnv prevEnv = this.env;
this.env = u;
t.accept(this);
this.env = prevEnv;
return t;
}
use of org.wso2.ballerinalang.compiler.tree.BLangNode in project ballerina by ballerina-lang.
the class Desugar method rewrite.
@SuppressWarnings("unchecked")
private <E extends BLangStatement> E rewrite(E statement, SymbolEnv env) {
if (statement == null) {
return null;
}
BLangStatementLink link = new BLangStatementLink();
link.parent = currentLink;
currentLink = link;
BLangStatement stmt = (BLangStatement) rewrite((BLangNode) statement, env);
// Link Statements.
link.statement = stmt;
stmt.statementLink = link;
currentLink = link.parent;
return (E) stmt;
}
use of org.wso2.ballerinalang.compiler.tree.BLangNode in project ballerina by ballerina-lang.
the class Desugar method rewriteExpr.
@SuppressWarnings("unchecked")
private <E extends BLangExpression> E rewriteExpr(E node) {
if (node == null) {
return null;
}
if (node.desugared) {
return node;
}
BLangExpression expr = node;
if (node.impConversionExpr != null) {
expr = node.impConversionExpr;
node.impConversionExpr = null;
}
expr.accept(this);
BLangNode resultNode = this.result;
this.result = null;
resultNode.desugared = true;
return (E) resultNode;
}
use of org.wso2.ballerinalang.compiler.tree.BLangNode in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
// Visitor methods
public void visit(BLangPackage pkgNode) {
SymbolEnv pkgEnv = this.symTable.pkgEnvMap.get(pkgNode.symbol);
// Then visit each top-level element sorted using the compilation unit
String fileName = documentServiceContext.get(DocumentServiceKeys.FILE_NAME_KEY);
List<TopLevelNode> topLevelNodes = pkgNode.topLevelNodes.stream().filter(node -> node.getPosition().getSource().getCompilationUnitName().equals(fileName)).collect(Collectors.toList());
if (topLevelNodes.isEmpty()) {
this.setTerminateVisitor(true);
acceptNode(null, null);
} else {
cursorPositionResolver = PackageNodeScopeResolver.class;
topLevelNodes.forEach(topLevelNode -> {
cursorPositionResolver = TopLevelNodeScopeResolver.class;
this.blockOwnerStack.push(pkgNode);
acceptNode((BLangNode) topLevelNode, pkgEnv);
});
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangNode in project ballerina by ballerina-lang.
the class TreeVisitor method acceptNode.
// Private Methods
private void acceptNode(BLangNode node, SymbolEnv env) {
if (this.terminateVisitor) {
return;
}
SymbolEnv prevEnv = this.symbolEnv;
this.symbolEnv = env;
node.accept(this);
this.symbolEnv = prevEnv;
this.setPreviousNode(node);
}
Aggregations