use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class CodeGenerator method getIntLiteral.
private BLangLiteral getIntLiteral(long value) {
BLangLiteral literal = (BLangLiteral) TreeBuilder.createLiteralExpression();
literal.value = value;
literal.typeTag = TypeTags.INT;
literal.type = symTable.intType;
return literal;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class CodeGenerator method getStringLiteral.
private BLangLiteral getStringLiteral(String value) {
BLangLiteral literal = (BLangLiteral) TreeBuilder.createLiteralExpression();
literal.value = value;
literal.typeTag = TypeTags.STRING;
literal.type = symTable.stringType;
return literal;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class CodeGenerator method getDefaultValueAttributeInfo.
private DefaultValueAttributeInfo getDefaultValueAttributeInfo(BLangLiteral literalExpr) {
DefaultValue defaultValue = getDefaultValue(literalExpr);
UTF8CPEntry defaultValueAttribUTF8CPEntry = new UTF8CPEntry(AttributeInfo.Kind.DEFAULT_VALUE_ATTRIBUTE.toString());
int defaultValueAttribNameIndex = currentPkgInfo.addCPEntry(defaultValueAttribUTF8CPEntry);
return new DefaultValueAttributeInfo(defaultValueAttribNameIndex, defaultValue);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class CodeGenerator method addParameterDefaultValues.
private void addParameterDefaultValues(BLangInvokableNode invokableNode, CallableUnitInfo callableUnitInfo) {
int paramDefaultsAttrNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE.value());
ParamDefaultValueAttributeInfo paramDefaulValAttrInfo = new ParamDefaultValueAttributeInfo(paramDefaultsAttrNameIndex);
// Only named parameters can have default values.
for (BLangVariableDef param : invokableNode.defaultableParams) {
DefaultValue defaultVal = getDefaultValue((BLangLiteral) param.var.expr);
paramDefaulValAttrInfo.addParamDefaultValueInfo(defaultVal);
}
callableUnitInfo.addAttributeInfo(AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE, paramDefaulValAttrInfo);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral in project ballerina by ballerina-lang.
the class Desugar method createPatternMatchBinaryExpr.
private BLangExpression createPatternMatchBinaryExpr(DiagnosticPos pos, BVarSymbol varSymbol, BType patternType) {
if (patternType == symTable.nullType) {
BLangSimpleVarRef varRef = ASTBuilderUtil.createVariableRef(pos, varSymbol);
BLangLiteral bLangLiteral = ASTBuilderUtil.createLiteral(pos, symTable.nullType, null);
return ASTBuilderUtil.createBinaryExpr(pos, varRef, bLangLiteral, symTable.booleanType, OperatorKind.EQUAL, (BOperatorSymbol) symResolver.resolveBinaryOperator(OperatorKind.EQUAL, symTable.anyType, symTable.nullType));
} else {
return createIsAssignableExpression(pos, varSymbol, patternType);
}
}
Aggregations