use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addXMLNSDeclaration.
public void addXMLNSDeclaration(DiagnosticPos pos, Set<Whitespace> ws, String namespaceUri, String prefix, boolean isTopLevel) {
BLangXMLNS xmlns = (BLangXMLNS) TreeBuilder.createXMLNSNode();
BLangIdentifier prefixIdentifer = (BLangIdentifier) TreeBuilder.createIdentifierNode();
prefixIdentifer.pos = pos;
prefixIdentifer.value = prefix;
addLiteralValue(pos, removeNthFromStart(ws, 1), TypeTags.STRING, namespaceUri);
xmlns.namespaceURI = (BLangLiteral) exprNodeStack.pop();
xmlns.prefix = prefixIdentifer;
xmlns.pos = pos;
xmlns.addWS(ws);
if (isTopLevel) {
this.compUnit.addTopLevelNode(xmlns);
return;
}
BLangXMLNSStatement xmlnsStmt = (BLangXMLNSStatement) TreeBuilder.createXMLNSDeclrStatementNode();
xmlnsStmt.xmlnsDecl = xmlns;
xmlnsStmt.pos = pos;
addStmtToCurrentBlock(xmlnsStmt);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method getDataForSecret.
private Map<String, String> getDataForSecret(List<BLangExpression> data) throws KubernetesPluginException {
Map<String, String> dataMap = new HashMap<>();
for (BLangExpression bLangExpression : data) {
Path dataFilePath = Paths.get(((BLangLiteral) bLangExpression).getValue().toString());
String key = String.valueOf(dataFilePath.getFileName());
String content = Base64.encodeBase64String(KubernetesUtils.readFileContent(dataFilePath));
dataMap.put(key, content);
}
return dataMap;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project kubernetes by ballerinax.
the class KubernetesAnnotationProcessor method getDataForConfigMap.
private Map<String, String> getDataForConfigMap(List<BLangExpression> data) throws KubernetesPluginException {
Map<String, String> dataMap = new HashMap<>();
for (BLangExpression bLangExpression : data) {
Path dataFilePath = Paths.get(((BLangLiteral) bLangExpression).getValue().toString());
String key = String.valueOf(dataFilePath.getFileName());
String content = new String(KubernetesUtils.readFileContent(dataFilePath), StandardCharsets.UTF_8);
dataMap.put(key, content);
}
return dataMap;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class TypeChecker method visit.
// Expressions
public void visit(BLangLiteral literalExpr) {
BType literalType = symTable.getTypeFromTag(literalExpr.typeTag);
resultTypes = types.checkTypes(literalExpr, Lists.of(literalType), expTypes);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
@Override
public void visit(BLangArrayLiteral arrayLiteral) {
BType etype;
if (arrayLiteral.type.tag == TypeTags.ANY) {
etype = arrayLiteral.type;
} else {
etype = ((BArrayType) arrayLiteral.type).eType;
}
// Emit create array instruction
int opcode = getOpcode(etype.tag, InstructionCodes.INEWARRAY);
Operand arrayVarRegIndex = calcAndGetExprRegIndex(arrayLiteral);
Operand typeCPIndex = getTypeCPIndex(arrayLiteral.type);
emit(opcode, arrayVarRegIndex, typeCPIndex);
// Emit instructions populate initial array values;
for (int i = 0; i < arrayLiteral.exprs.size(); i++) {
BLangExpression argExpr = arrayLiteral.exprs.get(i);
genNode(argExpr, this.env);
BLangLiteral indexLiteral = new BLangLiteral();
indexLiteral.pos = arrayLiteral.pos;
indexLiteral.value = (long) i;
indexLiteral.type = symTable.intType;
genNode(indexLiteral, this.env);
opcode = getOpcode(argExpr.type.tag, InstructionCodes.IASTORE);
emit(opcode, arrayVarRegIndex, indexLiteral.regIndex, argExpr.regIndex);
}
}
Aggregations