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;
}
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);
}
Aggregations