Search in sources :

Example 1 with BLangPackageXMLNS

use of org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangPackageXMLNS in project ballerina by ballerina-lang.

the class Desugar method visit.

@Override
public void visit(BLangXMLNS xmlnsNode) {
    BLangXMLNS generatedXMLNSNode;
    xmlnsNode.namespaceURI = rewriteExpr(xmlnsNode.namespaceURI);
    BSymbol ownerSymbol = xmlnsNode.symbol.owner;
    // Local namespace declaration in a function/resource/action/worker
    if ((ownerSymbol.tag & SymTag.INVOKABLE) == SymTag.INVOKABLE) {
        generatedXMLNSNode = new BLangLocalXMLNS();
    } else {
        generatedXMLNSNode = new BLangPackageXMLNS();
    }
    generatedXMLNSNode.namespaceURI = xmlnsNode.namespaceURI;
    generatedXMLNSNode.prefix = xmlnsNode.prefix;
    generatedXMLNSNode.symbol = xmlnsNode.symbol;
    result = generatedXMLNSNode;
}
Also used : BLangPackageXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangPackageXMLNS) BLangXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS) BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) BLangLocalXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)

Example 2 with BLangPackageXMLNS

use of org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangPackageXMLNS in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

@Override
public void visit(BLangPackageXMLNS xmlnsNode) {
    BLangExpression nsURIExpr = xmlnsNode.namespaceURI;
    Operand pvIndex = getPVIndex(TypeTags.STRING);
    BXMLNSSymbol nsSymbol = (BXMLNSSymbol) xmlnsNode.symbol;
    genNode(nsURIExpr, env);
    nsSymbol.nsURIIndex = pvIndex;
    emit(InstructionCodes.SGSTORE, nsURIExpr.regIndex, pvIndex);
}
Also used : BXMLNSSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol) Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)1 BXMLNSSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol)1 BLangXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS)1 BLangLocalXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)1 BLangPackageXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangPackageXMLNS)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 Operand (org.wso2.ballerinalang.programfile.Instruction.Operand)1