Skip to content

Commit

Permalink
fix #159, simplify setType and stackType in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
CheShianHung committed Jan 22, 2018
1 parent b263206 commit 081e731
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
29 changes: 9 additions & 20 deletions src/java/boa/compiler/visitors/CodeGeneratingVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1872,31 +1872,20 @@ public void visit(final OutputType n) {
/** {@inheritDoc} */
@Override
public void visit(final StackType n) {
final ST st = stg.getInstanceOf("StackType");

n.env.setNeedsBoxing(true);

n.getValue().accept(this);
st.add("value", code.removeLast());

n.env.setNeedsBoxing(false);

code.add(st.render());
if(n.type != null)

This comment has been minimized.

Copy link
@psybers

psybers Jan 22, 2018

Member

This seems to indicate there is a problem in the typechecker, as there should be a n.type here.

code.add(n.type.toJavaType());
else{
final ST st = stg.getInstanceOf("StackType");
n.getValue().accept(this);
st.add("value", code.removeLast());
code.add(st.render());
}
}

/** {@inheritDoc} */
@Override
public void visit(final SetType n) {
final ST st = stg.getInstanceOf("SetType");

n.env.setNeedsBoxing(true);

n.getValue().accept(this);
st.add("value", code.removeLast());

n.env.setNeedsBoxing(false);

code.add(st.render());
code.add(n.type.toJavaType());
}

/** {@inheritDoc} */
Expand Down
2 changes: 0 additions & 2 deletions templates/BoaJava.stg
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ identifierMap ::= [

VarDecl(isstatic, type, id) ::= "<if(isstatic)>static <endif><type> ___<id>;<\n>"
ArrayType(type) ::= "<type>[]"
MapType(key, value) ::= "java.util.HashMap\<<key>, <value>>"
StackType(value) ::= "java.util.Stack\<<value>>"
SetType(value) ::= "java.util.LinkedHashSet\<<value>>"
Block(statements) ::= <<
{
<statements:{s | <s>}>}
Expand Down

0 comments on commit 081e731

Please sign in to comment.