File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed
Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change 1- package pgdp .minijava ;
1+ package pgdp .minijava . ast ;
22
3- import java .util .ArrayList ;
4- import java .util .Arrays ;
5- import java .util .Iterator ;
6- import java .util .NoSuchElementException ;
3+ import java .util .*;
74
85public class SyntaxTreeNode implements Iterable <SyntaxTreeNode >{
6+ // TODO: Replace generic class with FactoryPattern
7+ // -> move emitter logic to nodes
8+
99 private SyntaxTreeNode [] children ;
1010 private final String value ;
1111 private final Type type ;
@@ -42,6 +42,23 @@ public Type getType() {
4242 return type ;
4343 }
4444
45+ @ Override
46+ public boolean equals (Object o ) {
47+ if (this == o ) {
48+ return true ;
49+ }
50+ if (o == null || getClass () != o .getClass ()) {
51+ return false ;
52+ }
53+ SyntaxTreeNode that = (SyntaxTreeNode ) o ;
54+ return Arrays .equals (children , that .children ) && Objects .equals (value , that .value ) && type == that .type ;
55+ }
56+
57+ @ Override
58+ public int hashCode () {
59+ return Objects .hash (value , type );
60+ }
61+
4562 @ Override
4663 public String toString () {
4764 StringBuilder out = new StringBuilder ();
You can’t perform that action at this time.
0 commit comments