use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TypeChecker method getBinaryAddExpr.
private BLangExpression getBinaryAddExpr(BLangExpression lExpr, BLangExpression rExpr, BSymbol opSymbol) {
BLangBinaryExpr binaryExpressionNode = (BLangBinaryExpr) TreeBuilder.createBinaryExpressionNode();
binaryExpressionNode.lhsExpr = lExpr;
binaryExpressionNode.rhsExpr = rExpr;
binaryExpressionNode.pos = rExpr.pos;
binaryExpressionNode.opKind = OperatorKind.ADD;
if (opSymbol != symTable.notFoundSymbol) {
binaryExpressionNode.type = opSymbol.type.getReturnTypes().get(0);
binaryExpressionNode.opSymbol = (BOperatorSymbol) opSymbol;
} else {
binaryExpressionNode.type = symTable.errType;
}
types.checkType(binaryExpressionNode, binaryExpressionNode.type, symTable.stringType);
return binaryExpressionNode;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class TypeChecker method getStringTemplateConcatExpr.
private BLangExpression getStringTemplateConcatExpr(List<BLangExpression> exprs) {
BLangExpression concatExpr = null;
for (BLangExpression expr : exprs) {
checkExpr((BLangExpression) expr, env);
if (concatExpr == null) {
concatExpr = expr;
continue;
}
BSymbol opSymbol = symResolver.resolveBinaryOperator(OperatorKind.ADD, symTable.stringType, expr.type);
if (opSymbol == symTable.notFoundSymbol && expr.type != symTable.errType) {
dlog.error(expr.pos, DiagnosticCode.INCOMPATIBLE_TYPES, symTable.stringType, expr.type);
}
concatExpr = getBinaryAddExpr(concatExpr, expr, opSymbol);
}
return concatExpr;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class Types method setImplicitCastExpr.
public void setImplicitCastExpr(BLangExpression expr, BType actualType, BType expType) {
BSymbol symbol = symResolver.resolveImplicitConversionOp(actualType, expType);
if (expType.tag == TypeTags.UNION && isValueType(actualType)) {
symbol = symResolver.resolveImplicitConversionOp(actualType, symTable.anyType);
}
if (symbol == symTable.notFoundSymbol) {
return;
}
BConversionOperatorSymbol conversionSym = (BConversionOperatorSymbol) symbol;
BLangTypeConversionExpr implicitConversionExpr = (BLangTypeConversionExpr) TreeBuilder.createTypeConversionNode();
implicitConversionExpr.pos = expr.pos;
implicitConversionExpr.expr = expr.impConversionExpr == null ? expr : expr.impConversionExpr;
implicitConversionExpr.type = expType;
implicitConversionExpr.targetType = expType;
implicitConversionExpr.conversionSymbol = conversionSym;
expr.impConversionExpr = implicitConversionExpr;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class Symbols method createTransformerSymbol.
public static BTransformerSymbol createTransformerSymbol(int flags, Name name, PackageID pkgID, BType type, boolean safe, BSymbol owner) {
BTransformerSymbol symbol = new BTransformerSymbol(name, pkgID, type, owner, safe);
symbol.kind = SymbolKind.TRANSFORMER;
symbol.scope = new Scope(symbol);
return symbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangTypeInit cIExpr) {
BSymbol structSymbol = cIExpr.type.tsymbol;
int pkgCPIndex = addPackageRefCPEntry(currentPkgInfo, structSymbol.pkgID);
int structNameCPIndex = addUTF8CPEntry(currentPkgInfo, structSymbol.name.value);
StructureRefCPEntry structureRefCPEntry = new StructureRefCPEntry(pkgCPIndex, structNameCPIndex);
Operand structCPIndex = getOperand(currentPkgInfo.addCPEntry(structureRefCPEntry));
// Emit an instruction to create a new struct.
RegIndex structRegIndex = calcAndGetExprRegIndex(cIExpr);
emit(InstructionCodes.NEWSTRUCT, structCPIndex, structRegIndex);
// Invoke the struct initializer here.
Operand[] operands = getFuncOperands(cIExpr.objectInitInvocation);
Operand[] callOperands = new Operand[operands.length + 1];
callOperands[0] = operands[0];
callOperands[1] = operands[1];
callOperands[2] = getOperand(operands[2].value + 1);
callOperands[3] = structRegIndex;
System.arraycopy(operands, 3, callOperands, 4, operands.length - 3);
emit(InstructionCodes.CALL, callOperands);
}
Aggregations