Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
34b33d7353
@ -1,4 +1,23 @@
|
||||
package abstractSyntaxTree.Class;
|
||||
|
||||
import TypeCheck.TypeCheckResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
||||
public interface IClass {
|
||||
// not type or type check
|
||||
import TypeCheck.TypeCheckResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IClass {
|
||||
// visit method for code generation
|
||||
}
|
||||
|
@ -1,4 +1,12 @@
|
||||
package abstractSyntaxTree.Class;
|
||||
|
||||
import TypeCheck.TypeCheckResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 {
|
||||
TypeCheckResult result = new TypeCheckResult();
|
||||
|
||||
// for (FieldDecl fieldDecl : fieldDecls) {
|
||||
// fieldDecl.typeCheck();
|
||||
// }
|
||||
//
|
||||
// for (MethodDecl methodDecl : methodDecls) {
|
||||
// methodDecl.typeCheck();
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
for (FieldDecl fieldDecl : fieldDecls) {
|
||||
fieldDecl.typeCheck(fieldDecls);
|
||||
}
|
||||
|
||||
for (MethodDecl methodDecl : methodDecls) {
|
||||
methodDecl.typeCheck(methodDecls);
|
||||
}
|
||||
|
||||
result.type = "class";
|
||||
setTypeCheckResult(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