Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Fix bugs in right hand side method call in IR translation, bug in TC
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolkabra committed May 16, 2019
1 parent 20a20e5 commit 00af981
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/kc875/ast/visit/IRTranslationVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,8 @@ public IRStmt visit(StmtDeclAssign node) {
List<IRStmt> declsInitIR = new ArrayList<>();
List<IRStmt> moveRetIR = new ArrayList<>();

if (node.getRhs() instanceof ExprFunctionCall) {
if (node.getRhs() instanceof ExprFunctionCall
|| node.getRhs() instanceof ExprMethodCall) {
for (int i = 0; i < decls.size(); ++i) {
TypeDecl di = decls.get(i);
// if di is an underscore, the _RETi is ignored, i.e., don't
Expand Down
18 changes: 13 additions & 5 deletions src/main/java/kc875/ast/visit/TypeCheckVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1020,23 +1020,31 @@ private void collectTauClass(ClassDefn c) {
ClassDecl decl = interfaceClasses.get(cName);
// Convert list of methods to a set since ordering doesn't
// matter for typechecking
// method name -> ([(param, paramtype), ...], output)
Map<String, Pair<List<Pair<String, TypeTTau>>, TypeT>> declMeths =
// method name -> ([paramtype, ...], output)
Map<String, Pair<List<TypeTTau>, TypeT>> declMeths =
decl.getMethodDecls().stream()
.collect(Collectors.toMap(
Func::getName,
(Func f) -> new Pair<>(
f.getParams(), f.getOutput()
f.getParams().stream()
.map(Pair::part2)
.collect(Collectors.toList()),
f.getOutput()
)
));
Map<String, Pair<List<Pair<String, TypeTTau>>, TypeT>> cMeths =
Map<String, Pair<List<TypeTTau>, TypeT>> cMeths =
c.getMethodDecls().stream()
.collect(Collectors.toMap(
Func::getName,
(Func f) -> new Pair<>(
f.getParams(), f.getOutput()
f.getParams().stream()
.map(Pair::part2)
.collect(Collectors.toList()),
f.getOutput()
)
));
System.out.println(declMeths);
System.out.println(cMeths);
if (!declMeths.equals(cMeths)) {
throw new SemanticError(
"Different methods in declaration and definition " +
Expand Down

0 comments on commit 00af981

Please sign in to comment.