Skip to content

Commit

Permalink
fix review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
chiranSachintha committed Nov 14, 2022
1 parent d66a17c commit e084377
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ public TypedescValueImpl(Type describingType, MapValue[] closures) {

@Deprecated
public TypedescValueImpl(Type describingType, MapValue[] closures, MapValue annotations) {
this.type = new BTypedescType(describingType);
this.describingType = describingType;
this.closures = closures;
this(describingType, closures);
this.annotations = annotations;
}


/**
* Returns the {@code BType} of the value describe by this type descriptor.
* @return describing type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ public void visit(BLangLiteral astLiteralExpr) {

@Override
public void visit(BLangMapLiteral astMapLiteralExpr) {
visitTypedesc(astMapLiteralExpr.pos, astMapLiteralExpr.getBType(), Collections.emptyList(), null);
visitTypedesc(astMapLiteralExpr.pos, astMapLiteralExpr.getBType(), Collections.emptyList());
BIRVariableDcl tempVarDcl =
new BIRVariableDcl(astMapLiteralExpr.getBType(), this.env.nextLocalVarId(names),
VarScope.FUNCTION, VarKind.TEMP);
Expand Down Expand Up @@ -1951,7 +1951,7 @@ public void visit(BLangWaitExpr waitExpr) {

@Override
public void visit(BLangWaitForAllExpr.BLangWaitLiteral waitLiteral) {
visitTypedesc(waitLiteral.pos, waitLiteral.getBType(), Collections.emptyList(), null);
visitTypedesc(waitLiteral.pos, waitLiteral.getBType(), Collections.emptyList());
BIRBasicBlock thenBB = new BIRBasicBlock(this.env.nextBBId(names));
addToTrapStack(thenBB);
BIRVariableDcl tempVarDcl = new BIRVariableDcl(waitLiteral.getBType(),
Expand Down Expand Up @@ -2179,7 +2179,7 @@ public void visit(BLangTypedescExpr accessExpr) {
this.env.enclFunc.localVars.add(tempVarDcl);
BIROperand toVarRef = new BIROperand(tempVarDcl);
setScopeAndEmit(new BIRNonTerminator.NewTypeDesc(accessExpr.pos, toVarRef, accessExpr.resolvedType,
Collections.emptyList(), null));
Collections.emptyList()));
this.env.targetOperand = toVarRef;
}

Expand Down Expand Up @@ -2228,7 +2228,7 @@ public void visit(BLangTableConstructorExpr tableConstructorExpr) {
public void visit(BLangSimpleVarRef.BLangTypeLoad typeLoad) {
BType type = typeLoad.symbol.tag == SymTag.TYPE_DEF ?
((BTypeDefinitionSymbol) typeLoad.symbol).referenceType : typeLoad.symbol.type;
visitTypedesc(typeLoad.pos, type, Collections.emptyList(), null);
visitTypedesc(typeLoad.pos, type, Collections.emptyList());
}

private void visitTypedesc(Location pos, BType type, List<BIROperand> varDcls, BIROperand annotations) {
Expand All @@ -2240,6 +2240,15 @@ private void visitTypedesc(Location pos, BType type, List<BIROperand> varDcls, B
this.env.targetOperand = toVarRef;
}

private void visitTypedesc(Location pos, BType type, List<BIROperand> varDcls) {
BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.typeDesc, this.env.nextLocalVarId(names),
VarScope.FUNCTION, VarKind.TEMP);
this.env.enclFunc.localVars.add(tempVarDcl);
BIROperand toVarRef = new BIROperand(tempVarDcl);
setScopeAndEmit(new BIRNonTerminator.NewTypeDesc(pos, toVarRef, type, varDcls));
this.env.targetOperand = toVarRef;
}

@Override
public void visit(BLangBreak breakStmt) {
BIRLockDetailsHolder toUnlock = this.env.unlockVars.peek();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,18 @@ public BIROperand[] getRhsOperands() {
public static class NewTypeDesc extends BIRNonTerminator {
public final List<BIROperand> closureVars;
public BType type;
public final BIROperand annotations;
public BIROperand annotations;

public NewTypeDesc(Location pos, BIROperand lhsOp, BType type, List<BIROperand> closureVars,
BIROperand annotations) {
public NewTypeDesc(Location pos, BIROperand lhsOp, BType type, List<BIROperand> closureVars) {
super(pos, InstructionKind.NEW_TYPEDESC);
this.closureVars = closureVars;
this.lhsOp = lhsOp;
this.type = type;
}

public NewTypeDesc(Location pos, BIROperand lhsOp, BType type, List<BIROperand> closureVars,
BIROperand annotations) {
this(pos, lhsOp, type, closureVars);
this.annotations = annotations;
}

Expand Down

0 comments on commit e084377

Please sign in to comment.