Skip to content

Commit ea7e810

Browse files
committed
Many fine tuning changes, add more tests
1 parent 457ca70 commit ea7e810

51 files changed

Lines changed: 1984 additions & 176 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/workspace.xml

Lines changed: 102 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/ko/carbonel/compiler/codegen/DeCompiler.java

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
import ko.carbonel.compiler.intermediate.tinyRust.ts.ClassEntry;
77
import ko.carbonel.compiler.intermediate.tinyRust.ts.MethodEntry;
88
import ko.carbonel.compiler.intermediate.tinyRust.ts.VariableEntry;
9+
import ko.carbonel.compiler.runner.TermFont;
910

1011
import java.util.List;
1112
import java.util.stream.Collectors;
1213

14+
/**
15+
* Re-Generate the original source code from the TinyRustSymbolTable (ST and AST)
16+
* Known issues:
17+
* - Brace Exp does not generate braces, Example ast/33.rs
18+
* > Possible solution: Generate braces for all chaining expressions
19+
*/
1320
public class DeCompiler {
1421
private DeCompiler() {
1522
throw new IllegalStateException("Utility class");
@@ -18,76 +25,74 @@ private DeCompiler() {
1825
public static String decompile(TinyRustSymbolTable tinyRustSymbolTable) {
1926
TinyRustSymbolTable temp = new TinyRustSymbolTable();
2027
String classes = tinyRustSymbolTable.classEntries.stream()
21-
.filter(it->temp.classEntries.stream().noneMatch(primitive->primitive.name.lexeme().equals(it.name.lexeme())))
28+
.filter(it -> temp.classEntries.stream().noneMatch(primitive -> primitive.name.lexeme().equals(it.name.lexeme())))
2229
.map(DeCompiler::decompileClass).collect(Collectors.joining("\n"));
2330
String main = decompileMain(tinyRustSymbolTable.main);
2431
return classes + "\n" + main;
2532
}
2633

2734
private static String decompileMain(MethodEntry main) {
2835
String out = "";
29-
out += "fn " + main.name.lexeme() + "(";
36+
out += TermFont.code_reserved("fn") + " " + TermFont.code_attr_m(main.name.lexeme()) + "(";
3037
out += main.parameters.stream().map(DeCompiler::decompileArgument).collect(Collectors.joining(", "));
3138
out += ")";
32-
out += decompileStatement(main.block, main.variables);
39+
out += decompileStatement(main.block, main.variables, 1);
3340
return out;
3441
}
3542

36-
3743
private static String decompileMethod(MethodEntry method) {
38-
String out = "";
39-
if (method.name.lexeme().equals(MethodEntry.CONSTRUCTOR)){
40-
out += method.name.lexeme() + "(";
44+
String out = "\t";
45+
if (method.name.lexeme().equals(MethodEntry.CONSTRUCTOR)) {
46+
out += TermFont.code_attr_m(method.name.lexeme()) + "(";
4147
out += method.parameters.stream().map(DeCompiler::decompileArgument).collect(Collectors.joining(", "));
42-
out += ")";
43-
}else{
44-
if (method.isStatic) out += "static ";
45-
out += "fn " + method.name.lexeme() + "(";
48+
out += ") ";
49+
} else {
50+
if (method.isStatic) out += TermFont.code_reserved("static") + " ";
51+
out += TermFont.code_reserved("fn") + " " + TermFont.code_attr_m(method.name.lexeme()) + "(";
4652
out += method.parameters.stream().map(DeCompiler::decompileArgument).collect(Collectors.joining(", "));
47-
out += ") -> " + method.returnType.type.lexeme();
53+
out += ") -> " + TermFont.code_type(method.returnType.type.lexeme()) + " ";
4854
}
49-
out += decompileStatement(method.block, method.variables);
55+
out += decompileStatement(method.block, method.variables, 2);
5056
return out;
5157
}
5258

53-
private static String decompileStatement(BlockStatementEntry statementEntry, List<VariableEntry> vars) {
59+
private static String decompileStatement(BlockStatementEntry statementEntry, List<VariableEntry> vars, int depth) {
5460
String out = "";
61+
String indent = "\t".repeat(depth);
62+
String indent1 = "\t".repeat(depth - 1);
5563
out += "{\n";
56-
out += vars.stream().map(DeCompiler::decompileVariable).collect(Collectors.joining("\n"));
57-
out += "\n";
58-
out += statementEntry.statements.stream().map(DeCompiler::decompileStatement).collect(Collectors.joining("\n"));
59-
out += "\n}";
64+
out += vars.isEmpty() ? "" : vars.stream().map(DeCompiler::decompileVariable).collect(Collectors.joining("\n" + indent, indent, "\n"));
65+
out += indent + statementEntry.statements.stream().map(it -> decompileStatement(it, depth + 1)).collect(Collectors.joining("\n" + indent));
66+
out += "\n" + indent1 + "}";
6067
return out;
6168
}
6269

63-
private static String decompileVariable(VariableEntry variableEntry) {
64-
return (variableEntry.type.isArray ? "Array " : "") + variableEntry.type.type.lexeme()+ ": " + variableEntry.name.lexeme() + ";";
65-
}
66-
67-
private static String decompileStatement(StatementEntry statementEntry) {
70+
private static String decompileStatement(StatementEntry statementEntry, int depth) {
6871
String out = "";
72+
String indent = "\t".repeat(depth);
73+
String indent1 = "\t".repeat(depth - 1);
6974
if (statementEntry instanceof EmptyStatementEntry) {
7075
out += ";";
7176
} else if (statementEntry instanceof ExpressionStatementEntry exp) {
7277
out += "(" + decompileExpression(exp.expression) + ");";
7378
} else if (statementEntry instanceof BlockStatementEntry blk) {
7479
out += "{\n";
75-
out += blk.statements.stream().map(DeCompiler::decompileStatement).collect(Collectors.joining("\n"));
76-
out += "\n}";
80+
out += indent + blk.statements.stream().map(it -> decompileStatement(it, depth + 1)).collect(Collectors.joining("\n" + indent));
81+
out += "\n" + indent1 + "}";
7782
} else if (statementEntry instanceof IfStatementEntry iF) {
78-
out += "if (" + decompileExpression(iF.ifCondition) + ")\n";
79-
out += decompileStatement(iF.ifBody);
83+
out += TermFont.code_reserved("if") + " (" + decompileExpression(iF.ifCondition) + ") ";
84+
out += decompileStatement(iF.ifBody, depth);
8085
if (iF.elseBody != null) {
81-
out += " else\n";
82-
out += decompileStatement(iF.elseBody);
86+
out += " " + TermFont.code_reserved("else") + " ";
87+
out += decompileStatement(iF.elseBody, depth);
8388
}
8489
} else if (statementEntry instanceof WhileStatementEntry whl) {
85-
out += "while (" + decompileExpression(whl.whileCondition) + ")\n";
86-
out += decompileStatement(whl.whileBody);
90+
out += TermFont.code_reserved("while") + " (" + decompileExpression(whl.whileCondition) + ") ";
91+
out += decompileStatement(whl.whileBody, depth);
8792
} else if (statementEntry instanceof ReturnStatementEntry ret) {
88-
out += "return " + decompileExpression(ret.returnExpression) + ";";
93+
out += TermFont.code_reserved("return") + " " + decompileExpression(ret.returnExpression) + ";";
8994
} else if (statementEntry instanceof AssignStatementEntry as) {
90-
out += decompileExpression(as.lhs()) + "=" + decompileExpression(as.rhs()) + ";";
95+
out += decompileExpression(as.lhs()) + " " + TermFont.code_operator("=") + " " + decompileExpression(as.rhs()) + ";";
9196
} else throw new RuntimeException("Unknown statement type " + statementEntry.getClass().getName());
9297
return out;
9398
}
@@ -97,49 +102,53 @@ private static String decompileExpression(ExpressionEntry expression) {
97102
if (expression instanceof UnaryExpressionEntry un) {
98103
out += un.operator.lexeme() + decompileExpression(un.expression);
99104
} else if (expression instanceof LiteralExpressionEntry lit) {
100-
out += lit.literal.lexeme();
105+
out += TermFont.code_literal(lit.literal.lexeme());
101106
} else if (expression instanceof BinaryExpressionEntry bin) {
102-
out += "(" + decompileExpression(bin.left) + " " + bin.operator.lexeme() + " " + decompileExpression(bin.right) + ")";
107+
out += "(" + decompileExpression(bin.left) + " " + TermFont.code_operator(bin.operator.lexeme()) + " " + decompileExpression(bin.right) + ")";
103108
} else if (expression instanceof MethodCallExpressionEntry call) {
104-
out += call.methodName.lexeme() + "(";
109+
out += TermFont.code_attr_m(call.methodName.lexeme()) + "(";
105110
out += call.arguments.stream().map(DeCompiler::decompileExpression).collect(Collectors.joining(", "));
106111
out += ")";
107112
} else if (expression instanceof NewClassExpressionEntry newExp) {
108-
out += "new " + newExp.className.lexeme() + "(";
113+
out += TermFont.code_reserved("new") + " " + TermFont.code_type(newExp.className.lexeme()) + "(";
109114
out += newExp.constructorArguments.stream().map(DeCompiler::decompileExpression).collect(Collectors.joining(", "));
110115
out += ")";
111116
} else if (expression instanceof ArrayAccessExpressionEntry array) {
112117
out += decompileExpression(array.array) + "[" + decompileExpression(array.index) + "]";
113118
} else if (expression instanceof FieldAccessEntry field) {
114-
out += field.fieldName.lexeme();
119+
out += TermFont.code_attr_f(field.fieldName.lexeme());
115120
} else if (expression instanceof ChainedExpressionEntry chain) {
116121
out += decompileExpression(chain.base) + "." + decompileExpression(chain.chain);
117122
} else if (expression instanceof NewArrayExpressionEntry array) {
118-
out += "new " + array.type.lexeme() + "[" + decompileExpression(array.size) + "]";
123+
out += TermFont.code_reserved("new") + " " + TermFont.code_type(array.type.lexeme()) + "[" + decompileExpression(array.size) + "]";
119124
} else if (expression instanceof ClassRefEntry cls) {
120-
out += cls.name.lexeme();
125+
out += TermFont.code_type(cls.name.lexeme());
121126
} else throw new RuntimeException("Unknown expression type " + expression.getClass().getName());
122127
return out;
123128
}
124129

125130
private static String decompileClass(ClassEntry clazz) {
126-
String out = "class " + clazz.name.lexeme();
127-
if (clazz.superClass != null) out += " : " + clazz.superClass.type.lexeme();
131+
String out = TermFont.code_reserved("class") + " " + clazz.name.lexeme();
132+
if (clazz.superClass != null) out += " : " + TermFont.code_type(clazz.superClass.type.lexeme());
128133
out += " {\n";
129-
out += clazz.fields.stream().map(DeCompiler::decompileField).collect(Collectors.joining("\n"));
134+
out += clazz.fields.stream().map(DeCompiler::decompileField).collect(Collectors.joining("\n")) + "\n";
130135
out += clazz.methods.stream().map(DeCompiler::decompileMethod).collect(Collectors.joining("\n"));
131136
out += "\n}\n";
132137
return out;
133138
}
134139

135140
private static String decompileField(VariableEntry variableEntry) {
136-
String out = "";
137-
if (variableEntry.isPublic) out += "pub ";
138-
out += (variableEntry.type.isArray ? "Array " : "") + variableEntry.type.type.lexeme() + ": " + variableEntry.name.lexeme();
141+
String out = "\t";
142+
if (variableEntry.isPublic) out += TermFont.code_reserved("pub") + " ";
143+
out += (variableEntry.type.isArray ? TermFont.code_reserved("Array") + " " : "") + (TermFont.code_type(variableEntry.type.type.lexeme()) + ": " + TermFont.code_attr_f(variableEntry.name.lexeme()));
139144
return out + ";";
140145
}
141146

147+
private static String decompileVariable(VariableEntry variableEntry) {
148+
return (variableEntry.type.isArray ? TermFont.code_reserved("Array") + " " : "") + (TermFont.code_type(variableEntry.type.type.lexeme()) + ": " + TermFont.code_attr_f(variableEntry.name.lexeme())) + ";";
149+
}
150+
142151
private static String decompileArgument(VariableEntry variableEntry) {
143-
return (variableEntry.type.isArray ? "Array " : "") + (variableEntry.type.type.lexeme() + ": " + variableEntry.name.lexeme());
152+
return (variableEntry.type.isArray ? TermFont.code_reserved("Array") + " " : "") + (TermFont.code_type(variableEntry.type.type.lexeme()) + ": " + TermFont.code_attr_f(variableEntry.name.lexeme()));
144153
}
145154
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package ko.carbonel.compiler.exception.semantic;
2+
3+
import ko.carbonel.compiler.stream.reader.FileLocation;
4+
5+
public class PrivateVarAccessError extends ExpressionError {
6+
public PrivateVarAccessError(FileLocation start, FileLocation end, String message) {
7+
super(start, end, message);
8+
}
9+
}

src/main/java/ko/carbonel/compiler/generated/AttrTinyRustParser.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,16 @@ private List<TinyRustLexerToken> matchToken_Stmt_star(){
12071207
private List<TinyRustLexerToken> matchToken_Stmt(){
12081208
enter("matchToken_Stmt");
12091209
List<TinyRustLexerToken> result = null;
1210-
if (peek(TinyRustTokenType.IF)){
1210+
if (peek(TinyRustTokenType.OPN_BRACE)){
1211+
st.newBlock();
1212+
TinyRustLexerToken v_1 = match(TinyRustTokenType.OPN_BRACE);
1213+
List<TinyRustLexerToken> v_2 = matchToken_Method_factored();
1214+
} else if (peek(TinyRustTokenType.RETURN)){
1215+
st.newReturn();
1216+
TinyRustLexerToken v_1 = match(TinyRustTokenType.RETURN);
1217+
List<TinyRustLexerToken> v_2 = matchToken_Stmt_factored();
1218+
st.endReturn();
1219+
} else if (peek(TinyRustTokenType.IF)){
12111220
st.newIf();
12121221
TinyRustLexerToken v_1 = match(TinyRustTokenType.IF);
12131222
TinyRustLexerToken v_2 = match(TinyRustTokenType.OPN_PAREN);
@@ -1217,17 +1226,20 @@ private List<TinyRustLexerToken> matchToken_Stmt(){
12171226
List<TinyRustLexerToken> v_6 = matchToken_Stmt();
12181227
List<TinyRustLexerToken> v_7 = matchToken_Stmt_factored_factored_factored();
12191228
st.ifEnd();
1229+
} else if (peek(TinyRustTokenType.ATTR_ID, TinyRustTokenType.SELF)){
1230+
st.newAssign();
1231+
List<TinyRustLexerToken> v_1 = matchToken_Assign();
1232+
TinyRustLexerToken v_2 = match(TinyRustTokenType.SEMI_COLON);
12201233
} else if (peek(TinyRustTokenType.OPN_PAREN)){
12211234
st.newExpr();
12221235
TinyRustLexerToken v_1 = match(TinyRustTokenType.OPN_PAREN);
12231236
List<TinyRustLexerToken> v_2 = matchToken_ExpOr();
12241237
TinyRustLexerToken v_3 = match(TinyRustTokenType.CLS_PAREN);
12251238
TinyRustLexerToken v_4 = match(TinyRustTokenType.SEMI_COLON);
12261239
st.endExpr();
1227-
} else if (peek(TinyRustTokenType.OPN_BRACE)){
1228-
st.newBlock();
1229-
TinyRustLexerToken v_1 = match(TinyRustTokenType.OPN_BRACE);
1230-
List<TinyRustLexerToken> v_2 = matchToken_Method_factored();
1240+
} else if (peek(TinyRustTokenType.SEMI_COLON)){
1241+
st.newEmpty();
1242+
TinyRustLexerToken v_1 = match(TinyRustTokenType.SEMI_COLON);
12311243
} else if (peek(TinyRustTokenType.WHILE)){
12321244
st.newWhile();
12331245
TinyRustLexerToken v_1 = match(TinyRustTokenType.WHILE);
@@ -1237,18 +1249,6 @@ private List<TinyRustLexerToken> matchToken_Stmt(){
12371249
st.whileBody();
12381250
List<TinyRustLexerToken> v_6 = matchToken_Stmt();
12391251
st.endWhile();
1240-
} else if (peek(TinyRustTokenType.SEMI_COLON)){
1241-
st.newEmpty();
1242-
TinyRustLexerToken v_1 = match(TinyRustTokenType.SEMI_COLON);
1243-
} else if (peek(TinyRustTokenType.ATTR_ID, TinyRustTokenType.SELF)){
1244-
st.newAssign();
1245-
List<TinyRustLexerToken> v_1 = matchToken_Assign();
1246-
TinyRustLexerToken v_2 = match(TinyRustTokenType.SEMI_COLON);
1247-
} else if (peek(TinyRustTokenType.RETURN)){
1248-
st.newReturn();
1249-
TinyRustLexerToken v_1 = match(TinyRustTokenType.RETURN);
1250-
List<TinyRustLexerToken> v_2 = matchToken_Stmt_factored();
1251-
st.endReturn();
12521252
} else {
12531253
handleUnexpectedToken("Stmt", Set.of(TinyRustTokenType.ATTR_ID, TinyRustTokenType.IF, TinyRustTokenType.OPN_BRACE, TinyRustTokenType.OPN_PAREN, TinyRustTokenType.RETURN, TinyRustTokenType.SELF, TinyRustTokenType.SEMI_COLON, TinyRustTokenType.WHILE));
12541254
}

src/main/java/ko/carbonel/compiler/intermediate/tinyRust/TinyRustSymbolTable.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import ko.carbonel.compiler.intermediate.SymbolTable;
55
import ko.carbonel.compiler.intermediate.tinyRust.ast.expression.*;
66
import ko.carbonel.compiler.intermediate.tinyRust.ast.statement.*;
7-
import ko.carbonel.compiler.intermediate.tinyRust.ts.ClassEntry;
8-
import ko.carbonel.compiler.intermediate.tinyRust.ts.IOClassEntry;
9-
import ko.carbonel.compiler.intermediate.tinyRust.ts.MethodEntry;
10-
import ko.carbonel.compiler.intermediate.tinyRust.ts.TypeEntry;
7+
import ko.carbonel.compiler.intermediate.tinyRust.ts.*;
118
import ko.carbonel.compiler.stream.lexer.tinyRust.model.TinyRustLexerToken;
129
import ko.carbonel.compiler.stream.lexer.tinyRust.model.TinyRustTokenType;
1310
import ko.carbonel.json.SerializeClass;
@@ -96,8 +93,9 @@ public void setMainActive() {
9693
activeMethod = main;
9794
}
9895

99-
public Optional<ClassEntry> resolveClass(String lexeme) {
100-
return classEntries.stream().filter(c -> c.name.lexeme().equals(lexeme)).findFirst();
96+
public Optional<ClassEntry> resolveClass(TinyRustLexerToken tok) {
97+
if (tok.type().equals(TinyRustTokenType.NULL)) return resolveClass(new TinyRustLexerToken(TinyRustTokenType.VOID, VOID));
98+
return classEntries.stream().filter(c -> c.name.lexeme().equals(tok.lexeme())).findFirst();
10199
}
102100

103101
@Override
@@ -385,8 +383,9 @@ private void populatePredefined() {
385383
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.INT, I32), false, true));
386384
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.BOOL, BOOL), false, true));
387385
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.CHR, CHAR), false, true));
388-
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.STR, STR), false, true));
386+
classEntries.add(new StrClassEntry(this));
389387
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.CLASS_ID, OBJECT), true, false));
388+
classEntries.add(new ClassEntry(this, new TinyRustLexerToken(TinyRustTokenType.VOID, VOID), false, false));
390389
populateStdlib();
391390
}
392391

src/main/java/ko/carbonel/compiler/intermediate/tinyRust/ast/expression/BinaryExpressionEntry.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,22 @@ public TypeEntry getType(Scope scope, boolean isImmediateChainedScope) {
6565
}
6666
if (!lExprType.equals(rExprType))
6767
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator types mismatch, %s and %s given".formatted(lExprType, rExprType));
68-
if (operator.type().equals(TinyRustTokenType.PLUS)
69-
&& !lExprType.equals(TypeEntry.I32)
70-
&& !lExprType.equals(TypeEntry.STR)
71-
) {
72-
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator + works on integers and strings only, %s given".formatted(lExprType));
68+
if (operator.type().equals(TinyRustTokenType.PLUS)) {
69+
if (!lExprType.equals(TypeEntry.I32) && !lExprType.equals(TypeEntry.STR)) {
70+
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator + works on integers and strings only, %s given".formatted(lExprType));
71+
}
72+
return lExprType;
73+
} else {
74+
if (type != null && !lExprType.equals(type)) {
75+
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator %s works on %s only, %s given".formatted(operator.type(), type, lExprType));
76+
}
77+
return switch (operator.type()) {
78+
case MINUS, DIVIDE, MOD, TIMES -> TypeEntry.ofClass(TinyRustSymbolTable.I32, operator.location());
79+
case EQ, NEQ, GEQ, LEQ, GT, LT, AND, OR -> TypeEntry.ofClass(TinyRustSymbolTable.BOOL, operator.location());
80+
default ->
81+
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator %s not supported".formatted(operator.type()));
82+
};
7383
}
74-
if (type != null && !lExprType.equals(type)) {
75-
throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator %s works on %s only, %s given".formatted(operator.type(), type, lExprType));
76-
}
77-
return switch (operator.type()) {
78-
case MINUS, DIVIDE, MOD, TIMES -> TypeEntry.ofClass(TinyRustSymbolTable.I32, operator.location());
79-
case EQ, NEQ, GEQ, LEQ, GT, LT, AND, OR -> TypeEntry.ofClass(TinyRustSymbolTable.BOOL, operator.location());
80-
case PLUS -> lExprType;
81-
default -> throw new ExpressionError(operator.location(), "Type mismatch: Binary Operator %s not supported".formatted(operator.type()));
82-
};
8384
}
8485

8586
@Override

src/main/java/ko/carbonel/compiler/intermediate/tinyRust/ast/expression/ClassRefEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void setName(TinyRustLexerToken name) {
2626
@Override
2727
public TypeEntry getType(Scope scope, boolean isImmediateChainedScope) {
2828
TinyRustSymbolTable symbolTable = (TinyRustSymbolTable) scope.getSymbolTable();
29-
ClassEntry classEntry = symbolTable.resolveClass(name.lexeme())
29+
ClassEntry classEntry = symbolTable.resolveClass(name)
3030
.orElseThrow(() -> new ClassNotFoundError(name));
3131
classEntry.setUsed(true);
3232
return TypeEntry.ofClass(classEntry.name.lexeme());

src/main/java/ko/carbonel/compiler/intermediate/tinyRust/ast/expression/NewArrayExpressionEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void setType(TinyRustLexerToken type) {
3131
@Override
3232
public TypeEntry getType(Scope scope, boolean isImmediateChainedScope) {
3333
TinyRustSymbolTable st = (TinyRustSymbolTable) scope.getSymbolTable();
34-
ClassEntry classEntry = st.resolveClass(type.lexeme())
34+
ClassEntry classEntry = st.resolveClass(type)
3535
.orElseThrow(() -> new RuntimeException("This should have been caught by the consolidation"));
3636
classEntry.setUsed(true);
3737
TypeEntry typeEntry = TypeEntry.arrayOf(type);

src/main/java/ko/carbonel/compiler/intermediate/tinyRust/ast/expression/NewClassExpressionEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void setConstructorArguments(List<ExpressionEntry> constructorArguments)
3636
@Override
3737
public TypeEntry getType(Scope scope, boolean isImmediateChainedScope) {
3838
TinyRustSymbolTable symbolTable = (TinyRustSymbolTable) scope.getSymbolTable();
39-
ClassEntry classEntry = symbolTable.resolveClass(className.lexeme())
39+
ClassEntry classEntry = symbolTable.resolveClass(className)
4040
.orElseThrow(() -> new ClassNotFoundError(className, "This should have been caught by the consolidation"));
4141
classEntry.setUsed(true);
4242
classEntry.constructor.setUsed(true);

0 commit comments

Comments
 (0)