use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BOperatorSymbol 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.BOperatorSymbol in project ballerina by ballerina-lang.
the class SymbolTable method defineOperator.
private void defineOperator(Name name, List<BType> paramTypes, List<BType> retTypes, int opcode) {
BInvokableType opType = new BInvokableType(paramTypes, retTypes, null);
BOperatorSymbol symbol = new BOperatorSymbol(name, rootPkgSymbol.pkgID, opType, rootPkgSymbol, opcode);
rootScope.define(name, symbol);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BOperatorSymbol in project ballerina by ballerina-lang.
the class Symbols method createTypeofOperatorSymbol.
public static BOperatorSymbol createTypeofOperatorSymbol(BType exprType, Types types, SymbolTable symTable, Names names) {
List<BType> paramTypes = Lists.of(exprType);
List<BType> retTypes = Lists.of(symTable.typeDesc);
BInvokableType opType = new BInvokableType(paramTypes, retTypes, null);
if (types.isValueType(exprType)) {
return new BOperatorSymbol(names.fromString(OperatorKind.TYPEOF.value()), symTable.rootPkgSymbol.pkgID, opType, symTable.rootPkgSymbol, InstructionCodes.TYPELOAD);
} else {
return new BOperatorSymbol(names.fromString(OperatorKind.TYPEOF.value()), symTable.rootPkgSymbol.pkgID, opType, symTable.rootPkgSymbol, InstructionCodes.TYPEOF);
}
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BOperatorSymbol in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createIsAssignableExpr.
static BLangIsAssignableExpr createIsAssignableExpr(DiagnosticPos pos, BLangExpression lhsExpr, BType targetType, BType type, Names names) {
final BLangIsAssignableExpr assignableExpr = new BLangIsAssignableExpr();
assignableExpr.pos = pos;
assignableExpr.lhsExpr = lhsExpr;
assignableExpr.targetType = targetType;
assignableExpr.type = type;
assignableExpr.opSymbol = new BOperatorSymbol(names.fromString(assignableExpr.opKind.value()), null, targetType, null, InstructionCodes.IS_ASSIGNABLE);
return assignableExpr;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BOperatorSymbol in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createBinaryExpr.
static BLangBinaryExpr createBinaryExpr(DiagnosticPos pos, BLangExpression lhsExpr, BLangExpression rhsExpr, BType type, OperatorKind opKind, BOperatorSymbol symbol) {
final BLangBinaryExpr binaryExpr = (BLangBinaryExpr) TreeBuilder.createBinaryExpressionNode();
binaryExpr.pos = pos;
binaryExpr.lhsExpr = lhsExpr;
binaryExpr.rhsExpr = rhsExpr;
binaryExpr.type = type;
binaryExpr.opKind = opKind;
binaryExpr.opSymbol = symbol;
return binaryExpr;
}
Aggregations