use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.
the class CodeGenerator method getLocalVarAttributeInfo.
private LocalVariableInfo getLocalVarAttributeInfo(BVarSymbol varSymbol) {
int varNameCPIndex = addUTF8CPEntry(currentPkgInfo, varSymbol.name.value);
int varIndex = varSymbol.varIndex.value;
int sigCPIndex = addUTF8CPEntry(currentPkgInfo, varSymbol.type.getDesc());
return new LocalVariableInfo(varNameCPIndex, sigCPIndex, varIndex);
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.
the class CodeGenerator method getOperands.
private Operand[] getOperands(BLangLock lockNode) {
Operand[] operands = new Operand[(lockNode.lockVariables.size() * 2) + 1];
int i = 0;
operands[i++] = new Operand(lockNode.lockVariables.size());
for (BVarSymbol varSymbol : lockNode.lockVariables) {
int typeSigCPIndex = addUTF8CPEntry(currentPkgInfo, varSymbol.getType().getDesc());
TypeRefCPEntry typeRefCPEntry = new TypeRefCPEntry(typeSigCPIndex);
operands[i++] = getOperand(currentPkgInfo.addCPEntry(typeRefCPEntry));
operands[i++] = varSymbol.varIndex;
}
return operands;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createVariable.
static BLangVariable createVariable(DiagnosticPos pos, String name, BType type, BLangExpression expr, BVarSymbol varSymbol) {
final BLangVariable varNode = (BLangVariable) TreeBuilder.createVariableNode();
varNode.pos = pos;
varNode.name = createIdentifier(pos, name);
varNode.type = type;
varNode.expr = expr;
varNode.symbol = varSymbol;
return varNode;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol in project ballerina by ballerina-lang.
the class ASTBuilderUtil method generateArgExprs.
static List<BLangExpression> generateArgExprs(DiagnosticPos pos, List<BLangVariable> args, List<BVarSymbol> formalParams, SymbolResolver symResolver) {
List<BLangExpression> argsExpr = new ArrayList<>();
final List<BLangSimpleVarRef> variableRefList = createVariableRefList(pos, args);
for (int i = 0; i < variableRefList.size(); i++) {
BLangSimpleVarRef varRef = variableRefList.get(i);
BType target = formalParams.get(i).type;
BType source = varRef.symbol.type;
if (source != target) {
argsExpr.add(generateConversionExpr(varRef, target, symResolver));
continue;
}
argsExpr.add(varRef);
}
return argsExpr;
}
use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol 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