Search in sources :

Example 11 with BXMLNSSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol in project ballerina by ballerina-lang.

the class TypeChecker method visit.

public void visit(BLangXMLQName bLangXMLQName) {
    String prefix = bLangXMLQName.prefix.value;
    resultTypes = Lists.of(types.checkType(bLangXMLQName, symTable.stringType, expTypes.get(0)));
    if (env.node.getKind() == NodeKind.XML_ATTRIBUTE && prefix.isEmpty() && bLangXMLQName.localname.value.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
        ((BLangXMLAttribute) env.node).isNamespaceDeclr = true;
        return;
    }
    if (env.node.getKind() == NodeKind.XML_ATTRIBUTE && prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
        ((BLangXMLAttribute) env.node).isNamespaceDeclr = true;
        return;
    }
    if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
        dlog.error(bLangXMLQName.pos, DiagnosticCode.INVALID_NAMESPACE_PREFIX, prefix);
        bLangXMLQName.type = symTable.errType;
        return;
    }
    BSymbol xmlnsSymbol = symResolver.lookupSymbol(env, names.fromIdNode(bLangXMLQName.prefix), SymTag.XMLNS);
    if (prefix.isEmpty() && xmlnsSymbol == symTable.notFoundSymbol) {
        return;
    }
    if (!prefix.isEmpty() && xmlnsSymbol == symTable.notFoundSymbol) {
        dlog.error(bLangXMLQName.pos, DiagnosticCode.UNDEFINED_SYMBOL, prefix);
        bLangXMLQName.type = symTable.errType;
        return;
    }
    bLangXMLQName.namespaceURI = ((BXMLNSSymbol) xmlnsSymbol).namespaceURI;
    bLangXMLQName.nsSymbol = (BXMLNSSymbol) xmlnsSymbol;
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) BLangXMLQuotedString(org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)

Example 12 with BXMLNSSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol 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

BXMLNSSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLNSSymbol)7 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)4 BLangXMLQName (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQName)4 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)4 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)3 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)2 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)2 Operand (org.wso2.ballerinalang.programfile.Instruction.Operand)2 Stack (java.util.Stack)1 Name (org.ballerinalang.model.Name)1 BXMLAttributeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BXMLAttributeSymbol)1 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)1 BLangLocalXMLNS (org.wso2.ballerinalang.compiler.tree.BLangXMLNS.BLangLocalXMLNS)1 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)1 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)1 BLangFieldVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangFieldVarRef)1 BLangFunctionVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangFunctionVarRef)1 BLangLocalVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangLocalVarRef)1 BLangPackageVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef.BLangPackageVarRef)1 BLangXMLAttribute (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLAttribute)1