Search in sources :

Example 1 with BLangLocalXMLNS

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

the class CodeGenerator method visit.

@Override
public void visit(BLangLocalXMLNS xmlnsNode) {
    RegIndex lvIndex = getLVIndex(TypeTags.STRING);
    BLangExpression nsURIExpr = xmlnsNode.namespaceURI;
    nsURIExpr.regIndex = createLHSRegIndex(lvIndex);
    genNode(nsURIExpr, env);
    BXMLNSSymbol nsSymbol = (BXMLNSSymbol) xmlnsNode.symbol;
    nsSymbol.nsURIIndex = lvIndex;
}
Also used : BXMLNSSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 2 with BLangLocalXMLNS

use of org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS 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 3 with BLangLocalXMLNS

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

the class Desugar method visit.

@Override
public void visit(BLangXMLElementLiteral xmlElementLiteral) {
    xmlElementLiteral.startTagName = rewriteExpr(xmlElementLiteral.startTagName);
    xmlElementLiteral.endTagName = rewriteExpr(xmlElementLiteral.endTagName);
    xmlElementLiteral.modifiedChildren = rewriteExprs(xmlElementLiteral.modifiedChildren);
    xmlElementLiteral.attributes = rewriteExprs(xmlElementLiteral.attributes);
    // Separate the in-line namepsace declarations and attributes.
    Iterator<BLangXMLAttribute> attributesItr = xmlElementLiteral.attributes.iterator();
    while (attributesItr.hasNext()) {
        BLangXMLAttribute attribute = attributesItr.next();
        if (!attribute.isNamespaceDeclr) {
            continue;
        }
        // Create local namepace declaration for all in-line namespace declarations
        BLangLocalXMLNS xmlns = new BLangLocalXMLNS();
        xmlns.namespaceURI = attribute.value.concatExpr;
        xmlns.prefix = ((BLangXMLQName) attribute.name).localname;
        xmlns.symbol = (BXMLNSSymbol) attribute.symbol;
        xmlElementLiteral.inlineNamespaces.add(xmlns);
        attributesItr.remove();
    }
    result = xmlElementLiteral;
}
Also used : BLangXMLAttribute(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute) BLangLocalXMLNS(org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)

Aggregations

BLangLocalXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)2 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 BLangPackageXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangPackageXMLNS)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangXMLAttribute (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1