Homework 3
This commit is contained in:
parent
bf60a078d7
commit
0afc86ceeb
129 changed files with 3163 additions and 4316 deletions
|
@ -160,7 +160,15 @@ public class AstOneLine {
|
|||
@Override
|
||||
public String var(Var ast, Void arg) {
|
||||
{
|
||||
return ast.name;
|
||||
if (ast.sym != null) {
|
||||
String symName = ast.sym.toString();
|
||||
if (ast.name == null || ast.name.equals(symName))
|
||||
return symName;
|
||||
|
||||
// Return something strange to warn about the mismatch here:
|
||||
return String.format("(%s!=%s)", symName, ast.name);
|
||||
} else
|
||||
return ast.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
package cd.util.debug;
|
||||
|
||||
import static java.util.Collections.sort;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import cd.ir.Ast.ClassDecl;
|
||||
import cd.ir.Ast.MethodDecl;
|
||||
|
||||
class DumpUtils {
|
||||
|
||||
static final Comparator<ClassDecl> classComparator = new Comparator<ClassDecl>() {
|
||||
public int compare(ClassDecl left, ClassDecl right) {
|
||||
return left.name.compareTo(right.name);
|
||||
}
|
||||
};
|
||||
|
||||
static final Comparator<MethodDecl> methodComparator = new Comparator<MethodDecl>() {
|
||||
public int compare(MethodDecl left, MethodDecl right) {
|
||||
return left.name.compareTo(right.name);
|
||||
}
|
||||
};
|
||||
|
||||
static List<String> sortedStrings(Set<?> set) {
|
||||
List<String> strings = new ArrayList<String>();
|
||||
for(Object element : set)
|
||||
strings.add(element.toString());
|
||||
sort(strings);
|
||||
return strings;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue