added what can be typed

This commit is contained in:
ahmad 2024-05-09 21:19:58 +02:00
parent 5a5b467407
commit a38ea3ad02
2 changed files with 13 additions and 25 deletions

View File

@ -14,7 +14,7 @@ import java.io.IOException;
* Decaf language Compiler
*/
public class Compiler {
/*
public static void main(String[] args) {
generateAST("""
public class ClassWithConstructorWithParameters {
@ -33,7 +33,7 @@ public class Compiler {
}
}
""");
}
} */
public static Class generateAST(String fromSource) {
CharStream input = CharStreams.fromString(fromSource);
@ -83,7 +83,7 @@ public class Compiler {
CodeGenUtils.writeClassfile(bytes, classname);
}
// public static void main(String[] args) {
// generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/ClassWithConstructor.java", "ClassWithConstructor");
// }
public static void main(String[] args) {
generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/ClassCanBeTyped.java", "ClassCanBeTyped");
}
}

View File

@ -6,46 +6,34 @@ public class ClassCanBeTyped {
public ClassCanBeTyped() {
this.x = 10;
int i;
for (i = 0; i < (x+1); i = i + 1) {
for (i = 0; i < (x + 1); i = i + 1) {
int j;
for (j = 0; j < this.x; j += 1) {
this.x = this.x * this.x;
break;
}
}
do{
do {
this.y = this.y + 1;
}while (this.y < 10)
} while (this.y < 10)
if(this.x > 10) {
this.x = 10;
} else {
this.x = 20;
}
int k;
k = 0;
for ( k = 0; k < 10; k = k+1) {
if(k == 5) {
for (k = 0; k < 10; k = k + 1) {
if (k == 5) {
return;
}
}
}
public ClassCanBeTyped(int x, int y, char z) {
this.x = x;
this.y = y;
this.z = z;
}
public int getY() {
return this.y;
}
public int getX() {
return this.x;
}
public char getZ() {
return this.z;
public int getX(char z) {
return x;
}