Compare commits
2 Commits
9cda409dd3
...
f273c74693
Author | SHA1 | Date | |
---|---|---|---|
|
f273c74693 | ||
|
783bab8580 |
1
Source/.idea/Source.iml
generated
1
Source/.idea/Source.iml
generated
@ -7,5 +7,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="asm-9.7" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
9
Source/.idea/libraries/asm_9_7.xml
generated
Normal file
9
Source/.idea/libraries/asm_9_7.xml
generated
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="asm-9.7">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/../Lib/asm-9.7.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -9,27 +9,21 @@ import java.util.List;
|
|||||||
|
|
||||||
public class MethodDecl implements IClass {
|
public class MethodDecl implements IClass {
|
||||||
|
|
||||||
// name
|
public String classThatContainsMethod;
|
||||||
|
public String name;
|
||||||
|
public List<String> parameters;
|
||||||
|
public String returnType;
|
||||||
|
|
||||||
private HashMap<String, HashMap<String, HashMap<String, String>>> methodContext;
|
|
||||||
private HashMap<String, HashMap<String, String>> typeContext;
|
|
||||||
|
|
||||||
//TODO: Move this into the typeCheck
|
//TODO: Move this into the typeCheck
|
||||||
private HashMap<String, String> localVars; // (type, identifier) // add content here
|
private HashMap<String, String> localVars; // (type, identifier) // add content here
|
||||||
|
|
||||||
public MethodDecl(HashMap<String, HashMap<String, HashMap<String, String>>> methodContext, HashMap<String, HashMap<String, String>> typeContext){
|
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, String>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
|
||||||
this.methodContext = methodContext;
|
|
||||||
this.typeContext = typeContext;
|
|
||||||
}
|
|
||||||
public TypeCheckResult typeCheck(List<MethodDecl> fieldsOrMethods) throws Exception {
|
|
||||||
// write localvars
|
// write localvars
|
||||||
|
|
||||||
|
|
||||||
// jede methode als block statement aufrufen
|
// jede methode als block statement aufrufen
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void codeGen(ClassWriter cw) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class RefType extends AbstractType implements IClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MethodDecl methodDecl : methodDecls) {
|
for (MethodDecl methodDecl : methodDecls) {
|
||||||
methodDecl.typeCheck(methodDecls);
|
methodDecl.typeCheck(methodContext, typeContext, methodDecls);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.type = "class";
|
result.type = "class";
|
||||||
|
@ -2,10 +2,14 @@ package abstractSyntaxTree;
|
|||||||
|
|
||||||
import TypeCheck.TypeCheckResult;
|
import TypeCheck.TypeCheckResult;
|
||||||
import abstractSyntaxTree.Class.FieldDecl;
|
import abstractSyntaxTree.Class.FieldDecl;
|
||||||
|
import abstractSyntaxTree.Class.MethodDecl;
|
||||||
|
import abstractSyntaxTree.Datatype.RefType;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import abstractSyntaxTree.Class.RefType;
|
import abstractSyntaxTree.Class.RefType;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -17,13 +21,25 @@ public class Program {
|
|||||||
public List<RefType> classes;
|
public List<RefType> classes;
|
||||||
|
|
||||||
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
|
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
|
||||||
public HashMap<String, HashMap<String, HashMap<String, String>>> methodContext; // (class, (returntype, (identifier, parameter)))
|
public HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext; // (class, (returntype, (identifier, parameter)))
|
||||||
|
|
||||||
public TypeCheckResult typeCheck() throws Exception{
|
public TypeCheckResult typeCheck() throws Exception{
|
||||||
for(RefType oneClass : classes){
|
for(RefType oneClass : classes){
|
||||||
HashMap<String, String> classVars = new HashMap<>();
|
HashMap<String, String> classVars = new HashMap<>();
|
||||||
for (FieldDecl fielsDecl: oneClass.fieldDecls)
|
for (FieldDecl fieldDecl: oneClass.fieldDecls){
|
||||||
classVars.put(fielsDecl.type, fielsDecl.identifier);
|
classVars.put(fieldDecl.type, fieldDecl.identifier);
|
||||||
|
}
|
||||||
|
typeContext.put(oneClass.name, classVars);
|
||||||
|
|
||||||
|
HashMap<String, List<String>> methodIdentifierAndParameter = new HashMap<>();
|
||||||
|
HashMap<String, HashMap<String, List<String >>> returnTypeAndMethod = new HashMap<>();
|
||||||
|
for (MethodDecl methodDecl : oneClass.methodDecls){
|
||||||
|
methodIdentifierAndParameter.put(methodDecl.name, methodDecl.parameters);
|
||||||
|
returnTypeAndMethod.put(methodDecl.returnType, methodIdentifierAndParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
methodContext.put(oneClass.name, returnTypeAndMethod);
|
||||||
|
|
||||||
oneClass.typeCheck();
|
oneClass.typeCheck();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user