Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
34b33d7353
@ -1,4 +1,23 @@
|
|||||||
package abstractSyntaxTree.Class;
|
package abstractSyntaxTree.Class;
|
||||||
|
|
||||||
|
import TypeCheck.TypeCheckResult;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class FieldDecl implements IClass {
|
public class FieldDecl implements IClass {
|
||||||
|
private String type;
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
|
public TypeCheckResult typeCheck(List<FieldDecl> classFieldsIdentifier) throws Exception {
|
||||||
|
TypeCheckResult result = new TypeCheckResult();
|
||||||
|
if (classFieldsIdentifier.contains(this.identifier)){
|
||||||
|
throw new Exception("field already defined");
|
||||||
|
} else {
|
||||||
|
classFieldsIdentifier.add(this);
|
||||||
|
}
|
||||||
|
result.type = this.type;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package abstractSyntaxTree.Class;
|
package abstractSyntaxTree.Class;
|
||||||
|
|
||||||
public interface IClass {
|
import TypeCheck.TypeCheckResult;
|
||||||
// not type or type check
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IClass {
|
||||||
// visit method for code generation
|
// visit method for code generation
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
package abstractSyntaxTree.Class;
|
package abstractSyntaxTree.Class;
|
||||||
|
|
||||||
|
import TypeCheck.TypeCheckResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MethodDecl implements IClass {
|
public class MethodDecl implements IClass {
|
||||||
|
public TypeCheckResult typeCheck(List<MethodDecl> fieldsOrMethods) throws Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,14 @@ public class RefType extends AbstractType implements IDatatype {
|
|||||||
public TypeCheckResult typeCheck() throws Exception {
|
public TypeCheckResult typeCheck() throws Exception {
|
||||||
TypeCheckResult result = new TypeCheckResult();
|
TypeCheckResult result = new TypeCheckResult();
|
||||||
|
|
||||||
// for (FieldDecl fieldDecl : fieldDecls) {
|
for (FieldDecl fieldDecl : fieldDecls) {
|
||||||
// fieldDecl.typeCheck();
|
fieldDecl.typeCheck(fieldDecls);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// for (MethodDecl methodDecl : methodDecls) {
|
for (MethodDecl methodDecl : methodDecls) {
|
||||||
// methodDecl.typeCheck();
|
methodDecl.typeCheck(methodDecls);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
result.type = "class";
|
result.type = "class";
|
||||||
setTypeCheckResult(result);
|
setTypeCheckResult(result);
|
||||||
return result;
|
return result;
|
||||||
|
15
Source/abstractSyntaxTree/Program.java
Normal file
15
Source/abstractSyntaxTree/Program.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package abstractSyntaxTree;
|
||||||
|
|
||||||
|
import TypeCheck.TypeCheckResult;
|
||||||
|
import abstractSyntaxTree.Datatype.RefType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Program {
|
||||||
|
public List<RefType> classes;
|
||||||
|
|
||||||
|
public TypeCheckResult typeCheck() throws Exception{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user