Skip to content

Commit 0e38d4c

Browse files
committed
removed todos
1 parent 76ed8a4 commit 0e38d4c

File tree

5 files changed

+4
-31
lines changed

5 files changed

+4
-31
lines changed

lib/src/codegen/ir.rs

-13
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ impl ConstantPool {
256256
result.extend_from_slice(&self.add(Constant::Utf8(r#type)).to_be_bytes());
257257
}
258258
Constant::FieldRef(FieldRef { class, field }) => {
259-
//TODO: Maybe this should be moved Prio2
260259
result.push(9);
261260
result.extend_from_slice(
262261
&self
@@ -574,18 +573,6 @@ fn generate_class(class: &Class, dir: &mut DIR) -> IRClass {
574573
ir_class
575574
}
576575

577-
// @Cleanup this function is never used
578-
/// If this method is used the caller has to still set a NameAndType constant and a FieldRef
579-
/// constant, which is technically optional if the field is not used but we're lazy
580-
fn generate_field(field: &FieldDecl, constant_pool: &mut ConstantPool) -> IRFieldDecl {
581-
let name_index = constant_pool.add(Constant::Utf8(field.name.clone()));
582-
let type_index = constant_pool.add(Constant::Utf8(format!(
583-
"(){}",
584-
field.field_type.clone().to_ir_string()
585-
)));
586-
IRFieldDecl::new(type_index, name_index)
587-
}
588-
589576
/// Generates a Vector of instructions for a given method
590577
fn generate_method(
591578
method: &MethodDecl,

lib/src/codegen/stack.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ impl StackMapTable {
8282
constant_pool: &mut ConstantPool,
8383
) {
8484
while instruction_idx < code.len() {
85-
// FIXME: When are locals added and how can we detect that from the instructions alone?
8685
match code.get(instruction_idx).unwrap() {
8786
Instruction::invokespecial(idx) => {
8887
bytes_idx += 3;
8988
if let Some(Constant::MethodRef(m)) = constant_pool.get(*idx) {
90-
// FIXME: Somehow figure out how many parameters are popped when calling the given function
9189
let pop_amount = 1;
9290
let l = current_stack.operands.len();
9391
current_stack.operands.splice(l - pop_amount..l, []);
@@ -124,7 +122,7 @@ impl StackMapTable {
124122
bytes_idx += 1;
125123
current_stack.operands.push(VerificationType::NULL)
126124
}
127-
Instruction::new(_) => todo!(), // requires special treatment, I think, see documentation VerificationType::UNINITIALIZED
125+
Instruction::new(_) => unimplemented!(),
128126
Instruction::aload_0 => {
129127
bytes_idx += 1;
130128
current_stack.operands.push(VerificationType::OBJECT(
@@ -477,8 +475,7 @@ pub(crate) enum VerificationType {
477475
INTEGER,
478476
NULL,
479477
UNINITIALIZED_THIS,
480-
OBJECT(u16), // index in constant pool
481-
UNINITIALIZED(u16), // offset (see docs for specific infos)
478+
OBJECT(u16), // index in constant pool
482479
}
483480

484481
impl VerificationType {
@@ -494,7 +491,6 @@ impl VerificationType {
494491
v.extend_from_slice(&cp_idx.to_be_bytes());
495492
v
496493
}
497-
VerificationType::UNINITIALIZED(offset) => todo!(),
498494
}
499495
}
500496
}

lib/src/parser/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn parse_class(pair: Pair<Rule>) -> Class {
5252
methods,
5353
}
5454
}
55-
_ => todo!(),
55+
_ => unreachable!(),
5656
}
5757
}
5858
fn next_id(inners: &mut Pairs<Rule>) -> String {
@@ -182,7 +182,7 @@ fn parse_Stmt(pair: Pair<Rule>) -> Vec<Stmt> {
182182
pair.as_str()
183183
);
184184
match pair.as_rule() {
185-
Rule::Stmt => parse_Stmt(pair.into_inner().next().unwrap()), //@Notice this may be very wrong !!
185+
Rule::Stmt => parse_Stmt(pair.into_inner().next().unwrap()),
186186
Rule::WhileStmt => {
187187
let mut inners = pair.into_inner();
188188
let Expr = parse_expr(inners.next().unwrap());

lib/src/tests/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ fn normalize_str(s: std::string::String) -> std::string::String {
6161

6262
pub fn parser_test(ast: &Class, name: &str) {
6363
// Call parser with java code
64-
// TODO: Can only be done, once we have a parsing method that returns a Class
6564
let parse_res = parser::parse_programm(
6665
&read_to_string(File::open(format!("lib/testcases/{name}.java")).unwrap()).unwrap(),
6766
)
@@ -71,7 +70,6 @@ pub fn parser_test(ast: &Class, name: &str) {
7170
}
7271

7372
pub fn typechecker_test(ast: &Class, tast: &Class) {
74-
// TODO: Errors are just ignored for now, oops
7573
let mut tc = TypeChecker::new(vec![ast.clone()]).unwrap();
7674
let typed_classes = tc.check_and_type_program().unwrap();
7775
assert_eq!(typed_classes[0], *tast);

lib/src/types.rs

-8
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ pub enum Stmt {
9090
pub enum StmtExpr {
9191
Assign(Expr, Expr), // first the name of the variable, then the value it is being assigned to
9292
New(Type, Vec<Expr>), // first the class type, that should be instantiated, then the list of arguments for the constructor
93-
// FIXME: This needs to be changed to represent more how the JVM handles method calls. We need a class(at least name) and a method name with the typed arguments inside it, also the return type
94-
// #2 = Methodref #3.#17 // MethodTest.y:(I)I
95-
// #3 = Class #18 // MethodTest
96-
// #17 = NameAndType #19:#20 // y:(I)I
97-
// #18 = Utf8 MethodTest
98-
// #19 = Utf8 y
99-
// #20 = Utf8 (I)I
10093
MethodCall(Expr, String, Vec<Expr>), // first the object to which the method belongs (e.g. Expr::This), then the name of the method and lastly the list of arguments for the method call
10194
TypedStmtExpr(Box<StmtExpr>, Type),
10295
}
@@ -272,7 +265,6 @@ impl Type {
272265
Type::Bool => "Z",
273266
Type::String => "Ljava/lang/String;",
274267
Type::Void => "V",
275-
// FIXME: Either the class has the formatting `L<class>;' or we have to add it here.
276268
Type::Class(name) => name,
277269
_ => panic!("Invalid type: {}", self),
278270
}

0 commit comments

Comments
 (0)