testing in meeting
This commit is contained in:
parent
6585e67273
commit
5220a65a92
@ -6,6 +6,7 @@ import abstractSyntaxTree.Expression.LocalVarIdentifier;
|
|||||||
import abstractSyntaxTree.Expression.UnaryExpression;
|
import abstractSyntaxTree.Expression.UnaryExpression;
|
||||||
import abstractSyntaxTree.Program;
|
import abstractSyntaxTree.Program;
|
||||||
import abstractSyntaxTree.Statement.IStatement;
|
import abstractSyntaxTree.Statement.IStatement;
|
||||||
|
import abstractSyntaxTree.Statement.IfElseStatement;
|
||||||
import abstractSyntaxTree.Statement.LocalVarDecl;
|
import abstractSyntaxTree.Statement.LocalVarDecl;
|
||||||
import abstractSyntaxTree.Statement.ReturnStatement;
|
import abstractSyntaxTree.Statement.ReturnStatement;
|
||||||
import abstractSyntaxTree.StatementExpression.AssignStatementExpression;
|
import abstractSyntaxTree.StatementExpression.AssignStatementExpression;
|
||||||
@ -104,8 +105,12 @@ public class Compiler {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
//abstractSyntaxTree.classes.get(0).methodDecls.get(0).codeBlock.returnType = "char";
|
IfElseStatement c = (IfElseStatement) abstractSyntaxTree.classes.get(0).methodDecls.get(0).codeBlock.statements.get(2);
|
||||||
AssignStatementExpression a = (AssignStatementExpression) abstractSyntaxTree.classes.get(0).methodDecls.get(0).codeBlock.statements.get(2);
|
InstVarExpression d = (InstVarExpression) c.condition;
|
||||||
|
d.classRef = abstractSyntaxTree.classes.get(0);
|
||||||
|
|
||||||
|
|
||||||
|
AssignStatementExpression a = (AssignStatementExpression) abstractSyntaxTree.classes.get(0).methodDecls.get(0).codeBlock.statements.get(1);
|
||||||
InstVarExpression b = (InstVarExpression) a.left;
|
InstVarExpression b = (InstVarExpression) a.left;
|
||||||
b.classRef = abstractSyntaxTree.classes.get(0);
|
b.classRef = abstractSyntaxTree.classes.get(0);
|
||||||
abstractSyntaxTree.typeCheck();
|
abstractSyntaxTree.typeCheck();
|
||||||
|
@ -4,8 +4,12 @@ class Example {
|
|||||||
char c;
|
char c;
|
||||||
int m(int n){
|
int m(int n){
|
||||||
int localA;
|
int localA;
|
||||||
localA = 5;
|
this.b = true;
|
||||||
this.i = 3;
|
if(this.b){
|
||||||
|
localA = 7;
|
||||||
|
}else{
|
||||||
|
localA = 5;
|
||||||
|
}
|
||||||
return localA;
|
return localA;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class IfElseStatement extends AbstractType implements IStatement{
|
public class IfElseStatement extends AbstractType implements IStatement{
|
||||||
IExpression condition;
|
public IExpression condition;
|
||||||
IStatement ifStatement;
|
IStatement ifStatement;
|
||||||
IStatement elseStatement;
|
IStatement elseStatement;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ public class IfElseStatement extends AbstractType implements IStatement{
|
|||||||
|
|
||||||
TypeCheckResult conditionType = condition.typeCheck(methodContext, typeContext, localVars);
|
TypeCheckResult conditionType = condition.typeCheck(methodContext, typeContext, localVars);
|
||||||
|
|
||||||
if (!conditionType.type.equals("bool")) {
|
if (!conditionType.type.equals("boolean")) {
|
||||||
throw new IllegalArgumentException("should be boolean");
|
throw new IllegalArgumentException("should be boolean");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class IfStatement extends AbstractType implements IStatement{
|
public class IfStatement extends AbstractType implements IStatement{
|
||||||
IExpression condition;
|
public IExpression condition;
|
||||||
|
|
||||||
//Do we need a block statement here?
|
//Do we need a block statement here?
|
||||||
IStatement ifStatement;
|
IStatement ifStatement;
|
||||||
|
Loading…
Reference in New Issue
Block a user