Skip to content

Commit

Permalink
fix(predefined, typo, test): 修正forEach返回类型、一个typo、删去过时API的导入
Browse files Browse the repository at this point in the history
forEach返回类型本来被F定义为Number了,不知道哪次merge又给merge没了,这里补上。

顺便把replce改对,有一些丢人。

InterpreterTester引入了ANTLR4的过时API。每次运行都要给个警告,很烦,奇怪的是他也没有用。直接删了。

没啥内容,所以一起commit了。
  • Loading branch information
sinofp committed Jun 5, 2020
1 parent fb8270e commit c35bd12
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/check/TypeCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void exitCallExpression(CallExpression ctx) {
if (containsGeneric(retType)) {
GenericType gType = (GenericType) getInnermostElementType(retType);
Type corriType = genericHelper.get(gType);
ctx.evalType = replceGenericType(retType, corriType);
ctx.evalType = replaceGenericType(retType, corriType);
} else {
ctx.evalType = retType;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/symboltable/PredefinedScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public PredefinedScope(Scope enclosingScope) {

//todo
define(mkproc(this, "filter", "List<TypeA>", mkprmtr("List<TypeA>", "self"), mkprmtr("Proc")));
define(mkproc(this, "forEach", "?", mkprmtr("List<TypeA>", "self"), mkprmtr("Proc")));
define(mkproc(this, "forEach", "Number", mkprmtr("List<TypeA>", "self"), mkprmtr("Proc")));
define(mkproc(this, "reduce", "Number", mkprmtr("Proc"), mkprmtr("List<TypeA>"), mkprmtr("TypeA")));

define(builtin(this, new BuiltInImRead(), new SimpleType("Image")));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/util/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static symboltable.Type matchGenericType(symboltable.Type argType, symbol
return null;
}

public static symboltable.Type replceGenericType(symboltable.Type typeWithGenetic, symboltable.Type coreType) {
public static symboltable.Type replaceGenericType(symboltable.Type typeWithGenetic, symboltable.Type coreType) {
assert containsGeneric(typeWithGenetic) && !containsGeneric(coreType);
String typeStr = typeWithGenetic.toString();
int l = typeStr.indexOf("Type");
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/InterpreterTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
import check.TypeCheck;
import grammar.CLParserLexer;
import grammar.CLParserParser;
import interpreter.Value;
import ir.IR;
import ir.NoOperationIR;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
Expand Down

0 comments on commit c35bd12

Please sign in to comment.