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