Quick fix compilation errors in old AST code.
This commit is contained in:
parent
1150b03a29
commit
85e29367a8
@ -385,7 +385,7 @@ impl AssignStatement {
|
||||
get_or_init_mut_field_pointer_variable(builder, &field_symbol, field_type)
|
||||
.clone();
|
||||
let ir_set_field = IrSetField::new(
|
||||
&mut_field_pointer_variable,
|
||||
todo!(),
|
||||
self.value
|
||||
.to_ir_expression(builder, symbol_table, types_table)
|
||||
.expect("Attempt to convert non-value to value"),
|
||||
@ -395,7 +395,7 @@ impl AssignStatement {
|
||||
ExpressibleSymbol::Variable(variable_symbol) => {
|
||||
let vr_variable = builder.local_variables().get(&variable_symbol).unwrap();
|
||||
let ir_assign = IrAssign::new(
|
||||
vr_variable.clone(),
|
||||
todo!(),
|
||||
self.value
|
||||
.to_ir_operation(builder, symbol_table, types_table),
|
||||
);
|
||||
@ -432,7 +432,7 @@ impl AssignStatement {
|
||||
.clone();
|
||||
|
||||
let ir_set_field = IrSetField::new(
|
||||
&mut_field_pointer_variable,
|
||||
todo!(),
|
||||
self.value.lower_to_ir_expression(
|
||||
builder,
|
||||
nodes_to_symbols,
|
||||
@ -445,7 +445,7 @@ impl AssignStatement {
|
||||
ExpressibleSymbol::Variable(variable_symbol) => {
|
||||
let ir_variable = builder.local_variables().get(&variable_symbol).unwrap();
|
||||
let ir_assign = IrAssign::new(
|
||||
ir_variable.clone(),
|
||||
todo!(),
|
||||
self.value.lower_to_ir_operation(
|
||||
builder,
|
||||
nodes_to_symbols,
|
||||
|
||||
@ -603,17 +603,13 @@ impl BinaryExpression {
|
||||
types_table: &TypesTable,
|
||||
) -> IrExpression {
|
||||
let ir_operation = self.to_ir_operation(builder, symbol_table, types_table);
|
||||
let t_var = IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
self.type_info(),
|
||||
);
|
||||
let t_var = IrVariable::new(&builder.new_t_var(), todo!());
|
||||
let as_rc = Rc::new(RefCell::new(t_var));
|
||||
let ir_assign = IrAssign::new(as_rc.clone(), ir_operation);
|
||||
let ir_assign = IrAssign::new(todo!(), ir_operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
IrExpression::Variable(as_rc)
|
||||
IrExpression::Variable(todo!())
|
||||
}
|
||||
|
||||
pub fn lower_to_ir_expression(
|
||||
@ -628,16 +624,12 @@ impl BinaryExpression {
|
||||
|
||||
let type_info = nodes_to_types.get(&self.node_id).unwrap();
|
||||
|
||||
let t_var = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
type_info,
|
||||
)));
|
||||
let t_var = Rc::new(RefCell::new(todo!()));
|
||||
|
||||
let ir_assign = IrAssign::new(t_var.clone(), ir_operation);
|
||||
let ir_assign = IrAssign::new(todo!(), ir_operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
IrExpression::Variable(t_var)
|
||||
IrExpression::Variable(todo!())
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ impl Constructor {
|
||||
let offset = (parameters_count as isize).neg() + i as isize;
|
||||
let ir_parameter = Rc::new(IrParameter::new(
|
||||
parameter_symbol.declared_name(),
|
||||
parameter_type.clone(),
|
||||
todo!(),
|
||||
offset,
|
||||
));
|
||||
|
||||
@ -227,19 +227,14 @@ impl Constructor {
|
||||
let entry_block_id = ir_builder.new_block();
|
||||
|
||||
// first, allocate the object into a t var
|
||||
let alloc_assign_destination = IrVariable::new_vr(
|
||||
ir_builder.new_t_var().into(),
|
||||
ir_builder.current_block().id(),
|
||||
&TypeInfo::Class(class_symbol.clone()),
|
||||
);
|
||||
let alloc_assign_destination = todo!();
|
||||
let self_variable = Rc::new(RefCell::new(alloc_assign_destination));
|
||||
|
||||
// save self variable so statements can assign stuff to self's fields
|
||||
ir_builder
|
||||
.set_self_parameter_or_variable(IrParameterOrVariable::Variable(self_variable.clone()));
|
||||
ir_builder.set_self_parameter_or_variable(IrParameterOrVariable::Variable(todo!()));
|
||||
|
||||
let alloc_assign = IrAssign::new(
|
||||
self_variable.clone(),
|
||||
todo!(),
|
||||
IrOperation::Allocate(IrAllocate::new(class_symbol.declared_name_owned())),
|
||||
);
|
||||
ir_builder
|
||||
@ -255,19 +250,13 @@ impl Constructor {
|
||||
let field_type = types_table.field_types().get(&field_symbol).unwrap();
|
||||
// get a mut ref to the field
|
||||
let ir_get_field_ref_mut = IrGetFieldRefMut::new(
|
||||
IrParameterOrVariable::Variable(self_variable.clone()),
|
||||
IrParameterOrVariable::Variable(todo!()),
|
||||
field_symbol.field_index(),
|
||||
);
|
||||
let field_mut_ref_variable_name: Rc<str> = ir_builder.new_t_var().into();
|
||||
let field_mut_ref_variable = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
field_mut_ref_variable_name.clone(),
|
||||
ir_builder.current_block().id(),
|
||||
field_type,
|
||||
)));
|
||||
let field_mut_ref_assign = IrAssign::new(
|
||||
field_mut_ref_variable.clone(),
|
||||
IrOperation::GetFieldRefMut(ir_get_field_ref_mut),
|
||||
);
|
||||
let field_mut_ref_variable = Rc::new(RefCell::new(todo!()));
|
||||
let field_mut_ref_assign =
|
||||
IrAssign::new(todo!(), IrOperation::GetFieldRefMut(ir_get_field_ref_mut));
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(field_mut_ref_assign));
|
||||
@ -288,7 +277,7 @@ impl Constructor {
|
||||
.to_ir_expression(&mut ir_builder, symbol_table, types_table)
|
||||
.unwrap();
|
||||
let ir_set_field = IrSetField::new(
|
||||
&field_mut_ref_variable, // dumb that we clone it and then ref it
|
||||
todo!(), // dumb that we clone it and then ref it
|
||||
ir_expression,
|
||||
);
|
||||
ir_builder
|
||||
@ -303,9 +292,8 @@ impl Constructor {
|
||||
}
|
||||
|
||||
// return complete self object
|
||||
let ir_return_statement = IrStatement::Return(IrReturn::new(Some(IrExpression::Variable(
|
||||
self_variable.clone(),
|
||||
))));
|
||||
let ir_return_statement =
|
||||
IrStatement::Return(IrReturn::new(Some(IrExpression::Variable(todo!()))));
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(ir_return_statement);
|
||||
@ -316,12 +304,7 @@ impl Constructor {
|
||||
let constructor_symbol = symbol_table
|
||||
.get_constructor_symbol(self.scope_id.unwrap())
|
||||
.unwrap();
|
||||
IrFunction::new(
|
||||
fqn_parts_to_string(constructor_symbol.fqn_parts()),
|
||||
ir_parameters,
|
||||
&TypeInfo::Class(class_symbol.clone()),
|
||||
entry_block.clone(),
|
||||
)
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn lower_to_ir(
|
||||
@ -341,11 +324,7 @@ impl Constructor {
|
||||
let symbol = nodes_to_symbols.get(¶meter.node_id()).unwrap();
|
||||
let parameter_type = symbols_to_types.get(symbol).unwrap();
|
||||
let offset = base_offset + i as isize;
|
||||
let ir_parameter = Rc::new(IrParameter::new(
|
||||
symbol.declared_name(),
|
||||
parameter_type.clone(),
|
||||
offset,
|
||||
));
|
||||
let ir_parameter = Rc::new(IrParameter::new(symbol.declared_name(), todo!(), offset));
|
||||
|
||||
// save in builder
|
||||
ir_builder.push_parameter(symbol.unwrap_parameter_symbol(), ir_parameter.clone());
|
||||
@ -358,104 +337,101 @@ impl Constructor {
|
||||
let entry_block_id = ir_builder.new_block();
|
||||
|
||||
// PART 1: Make self object
|
||||
let self_variable = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
ir_builder.new_t_var().into(),
|
||||
ir_builder.current_block().id(),
|
||||
&TypeInfo::ParameterizedClass(class_symbol.clone(), Vec::new()), // todo: figure out the correct TypeInfo for this
|
||||
)));
|
||||
let self_variable = Rc::new(RefCell::new(todo!()));
|
||||
//
|
||||
// // save self variable in builder
|
||||
// ir_builder
|
||||
// .set_self_parameter_or_variable(IrParameterOrVariable::Variable(self_variable.clone()));
|
||||
//
|
||||
// // allocate the self object
|
||||
// let ir_assign = IrAssign::new(
|
||||
// self_variable.clone(),
|
||||
// IrOperation::Allocate(IrAllocate::new(class_symbol.declared_name_owned())),
|
||||
// );
|
||||
// ir_builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(ir_assign));
|
||||
//
|
||||
// // PART 2: Initialize fields that are initialized OUTSIDE the constructor
|
||||
// for field in fields {
|
||||
// if let Some(initializer) = field.initializer() {
|
||||
// let symbol = nodes_to_symbols.get(&field.node_id()).unwrap();
|
||||
// let field_type = symbols_to_types.get(symbol).unwrap();
|
||||
// let field_symbol = symbol.unwrap_field_symbol();
|
||||
//
|
||||
// // 1. Get a mut ref to the field
|
||||
// // mut t_var: Type = &mut self.x
|
||||
// let ir_get_field_ref_mut = IrGetFieldRefMut::new(
|
||||
// IrParameterOrVariable::Variable(self_variable.clone()),
|
||||
// field_symbol.field_index(),
|
||||
// );
|
||||
// let field_ref_mut_ir_variable = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
// ir_builder.new_t_var().into(),
|
||||
// ir_builder.current_block().id(),
|
||||
// field_type,
|
||||
// )));
|
||||
// let ir_assign = IrAssign::new(
|
||||
// field_ref_mut_ir_variable.clone(),
|
||||
// IrOperation::GetFieldRefMut(ir_get_field_ref_mut),
|
||||
// );
|
||||
// ir_builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(ir_assign));
|
||||
//
|
||||
// // save the mut ref for later uses if needed
|
||||
// ir_builder.field_mut_pointer_variables_mut().insert(
|
||||
// field.declared_name_owned(),
|
||||
// field_ref_mut_ir_variable.clone(),
|
||||
// );
|
||||
//
|
||||
// // 2. Evaluate initializer and save result to mut field ref
|
||||
// let ir_expression = initializer.lower_to_ir_expression(
|
||||
// &mut ir_builder,
|
||||
// nodes_to_symbols,
|
||||
// symbols_to_types,
|
||||
// nodes_to_types,
|
||||
// );
|
||||
// let ir_set_field = IrSetField::new(&field_ref_mut_ir_variable, ir_expression);
|
||||
// ir_builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::SetField(ir_set_field));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // PART 3. Constructor statements
|
||||
// for statement in &self.statements {
|
||||
// statement.lower_to_ir(
|
||||
// &mut ir_builder,
|
||||
// nodes_to_symbols,
|
||||
// symbols_to_types,
|
||||
// nodes_to_types,
|
||||
// false,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // PART 4. Return finished self object
|
||||
// let ir_return_statement = IrStatement::Return(IrReturn::new(Some(IrExpression::Variable(
|
||||
// self_variable.clone(),
|
||||
// ))));
|
||||
// ir_builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(ir_return_statement);
|
||||
//
|
||||
// // Finish up the builder and return IrFunction
|
||||
// ir_builder.finish_block();
|
||||
// let entry_block = ir_builder.get_block(entry_block_id);
|
||||
//
|
||||
// let constructor_symbol = nodes_to_symbols
|
||||
// .get(&self.node_id)
|
||||
// .unwrap()
|
||||
// .unwrap_constructor_symbol();
|
||||
|
||||
// save self variable in builder
|
||||
ir_builder
|
||||
.set_self_parameter_or_variable(IrParameterOrVariable::Variable(self_variable.clone()));
|
||||
|
||||
// allocate the self object
|
||||
let ir_assign = IrAssign::new(
|
||||
self_variable.clone(),
|
||||
IrOperation::Allocate(IrAllocate::new(class_symbol.declared_name_owned())),
|
||||
);
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
|
||||
// PART 2: Initialize fields that are initialized OUTSIDE the constructor
|
||||
for field in fields {
|
||||
if let Some(initializer) = field.initializer() {
|
||||
let symbol = nodes_to_symbols.get(&field.node_id()).unwrap();
|
||||
let field_type = symbols_to_types.get(symbol).unwrap();
|
||||
let field_symbol = symbol.unwrap_field_symbol();
|
||||
|
||||
// 1. Get a mut ref to the field
|
||||
// mut t_var: Type = &mut self.x
|
||||
let ir_get_field_ref_mut = IrGetFieldRefMut::new(
|
||||
IrParameterOrVariable::Variable(self_variable.clone()),
|
||||
field_symbol.field_index(),
|
||||
);
|
||||
let field_ref_mut_ir_variable = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
ir_builder.new_t_var().into(),
|
||||
ir_builder.current_block().id(),
|
||||
field_type,
|
||||
)));
|
||||
let ir_assign = IrAssign::new(
|
||||
field_ref_mut_ir_variable.clone(),
|
||||
IrOperation::GetFieldRefMut(ir_get_field_ref_mut),
|
||||
);
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
|
||||
// save the mut ref for later uses if needed
|
||||
ir_builder.field_mut_pointer_variables_mut().insert(
|
||||
field.declared_name_owned(),
|
||||
field_ref_mut_ir_variable.clone(),
|
||||
);
|
||||
|
||||
// 2. Evaluate initializer and save result to mut field ref
|
||||
let ir_expression = initializer.lower_to_ir_expression(
|
||||
&mut ir_builder,
|
||||
nodes_to_symbols,
|
||||
symbols_to_types,
|
||||
nodes_to_types,
|
||||
);
|
||||
let ir_set_field = IrSetField::new(&field_ref_mut_ir_variable, ir_expression);
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::SetField(ir_set_field));
|
||||
}
|
||||
}
|
||||
|
||||
// PART 3. Constructor statements
|
||||
for statement in &self.statements {
|
||||
statement.lower_to_ir(
|
||||
&mut ir_builder,
|
||||
nodes_to_symbols,
|
||||
symbols_to_types,
|
||||
nodes_to_types,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
// PART 4. Return finished self object
|
||||
let ir_return_statement = IrStatement::Return(IrReturn::new(Some(IrExpression::Variable(
|
||||
self_variable.clone(),
|
||||
))));
|
||||
ir_builder
|
||||
.current_block_mut()
|
||||
.add_statement(ir_return_statement);
|
||||
|
||||
// Finish up the builder and return IrFunction
|
||||
ir_builder.finish_block();
|
||||
let entry_block = ir_builder.get_block(entry_block_id);
|
||||
|
||||
let constructor_symbol = nodes_to_symbols
|
||||
.get(&self.node_id)
|
||||
.unwrap()
|
||||
.unwrap_constructor_symbol();
|
||||
|
||||
IrFunction::new(
|
||||
fqn_parts_to_string(constructor_symbol.fqn_parts()),
|
||||
ir_parameters,
|
||||
&TypeInfo::Class(class_symbol.clone()), // TODO
|
||||
entry_block.clone(),
|
||||
)
|
||||
// IrFunction::new(
|
||||
// fqn_parts_to_string(constructor_symbol.fqn_parts()),
|
||||
// ir_parameters,
|
||||
// &TypeInfo::Class(class_symbol.clone()), // TODO
|
||||
// entry_block.clone(),
|
||||
// )
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,17 +479,13 @@ impl Expression {
|
||||
.add_statement(IrStatement::Call(ir_call));
|
||||
None
|
||||
} else {
|
||||
let t_var = IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
call.return_type_info(symbol_table, types_table),
|
||||
);
|
||||
let t_var = todo!();
|
||||
let as_rc = Rc::new(RefCell::new(t_var));
|
||||
let assign = IrAssign::new(as_rc.clone(), IrOperation::Call(ir_call));
|
||||
let assign = IrAssign::new(todo!(), IrOperation::Call(ir_call));
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(assign));
|
||||
Some(IrExpression::Variable(as_rc))
|
||||
Some(IrExpression::Variable(todo!()))
|
||||
}
|
||||
}
|
||||
Expression::Identifier(identifier) => {
|
||||
|
||||
@ -419,11 +419,8 @@ impl Function {
|
||||
.get(¶meter_symbol)
|
||||
.unwrap();
|
||||
let stack_offset = (self.parameters.len() as isize).neg() + (i as isize);
|
||||
let ir_parameter = IrParameter::new(
|
||||
parameter_symbol.declared_name(),
|
||||
parameter_type_info.clone(),
|
||||
stack_offset,
|
||||
);
|
||||
let ir_parameter =
|
||||
IrParameter::new(parameter_symbol.declared_name(), todo!(), stack_offset);
|
||||
let as_rc = Rc::new(ir_parameter);
|
||||
builder.push_parameter(¶meter_symbol, as_rc.clone());
|
||||
}
|
||||
@ -435,7 +432,7 @@ impl Function {
|
||||
if class_context.is_some() {
|
||||
let parameter_0 = builder.parameters()[0].clone();
|
||||
// put it in the self parameter
|
||||
builder.set_self_parameter_or_variable(IrParameterOrVariable::Parameter(parameter_0));
|
||||
builder.set_self_parameter_or_variable(IrParameterOrVariable::Parameter(todo!()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,9 +485,10 @@ impl Function {
|
||||
let entry_block = builder.get_block(entry_block_id).clone();
|
||||
IrFunction::new(
|
||||
fqn_parts_to_string(function_symbol.fqn_parts()),
|
||||
builder.parameters().iter().map(|p| (*p).clone()).collect(),
|
||||
&Self::get_return_type_info(types_table, function_symbol),
|
||||
entry_block,
|
||||
todo!(),
|
||||
todo!(),
|
||||
todo!(),
|
||||
todo!(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -515,7 +513,7 @@ impl Function {
|
||||
let stack_offset = (function_symbol.parameters().len() as isize).neg() + (i as isize);
|
||||
let ir_parameter = Rc::new(IrParameter::new(
|
||||
parameter_symbol.declared_name(),
|
||||
parameter_type_info.clone(),
|
||||
todo!(),
|
||||
stack_offset,
|
||||
));
|
||||
builder.push_parameter(parameter_symbol, ir_parameter);
|
||||
@ -544,9 +542,10 @@ impl Function {
|
||||
let entry_block = builder.get_block(entry_block_id).clone();
|
||||
IrFunction::new(
|
||||
fqn_parts_to_string(function_symbol.fqn_parts()),
|
||||
builder.parameters().iter().map(|p| (*p).clone()).collect(),
|
||||
return_type_info,
|
||||
entry_block,
|
||||
todo!(),
|
||||
todo!(),
|
||||
todo!(),
|
||||
todo!(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -570,39 +570,21 @@ impl Identifier {
|
||||
}
|
||||
ExpressibleSymbol::Field(field_symbol) => {
|
||||
let field_type = symbols_to_types.get(symbol).unwrap();
|
||||
let read_destination = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
field_type,
|
||||
)));
|
||||
let ir_read_field = IrReadField::new(
|
||||
get_or_init_field_pointer_variable(builder, field_symbol, field_type).clone(),
|
||||
);
|
||||
let read_destination = Rc::new(RefCell::new(todo!()));
|
||||
let ir_read_field = IrReadField::new(todo!());
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(IrAssign::new(
|
||||
read_destination.clone(),
|
||||
todo!(),
|
||||
IrOperation::ReadField(ir_read_field),
|
||||
)));
|
||||
IrExpression::Variable(read_destination)
|
||||
IrExpression::Variable(todo!())
|
||||
}
|
||||
ExpressibleSymbol::Function(_function_symbol) => {
|
||||
todo!()
|
||||
}
|
||||
ExpressibleSymbol::Parameter(parameter_symbol) => IrExpression::Parameter(
|
||||
builder
|
||||
.parameters_map()
|
||||
.get(parameter_symbol)
|
||||
.unwrap()
|
||||
.clone(),
|
||||
),
|
||||
ExpressibleSymbol::Variable(variable_symbol) => IrExpression::Variable(
|
||||
builder
|
||||
.local_variables()
|
||||
.get(variable_symbol)
|
||||
.unwrap()
|
||||
.clone(),
|
||||
),
|
||||
ExpressibleSymbol::Parameter(parameter_symbol) => IrExpression::Parameter(todo!()),
|
||||
ExpressibleSymbol::Variable(variable_symbol) => IrExpression::Variable(todo!()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,22 +603,16 @@ impl Identifier {
|
||||
}
|
||||
ExpressibleSymbol::Field(field_symbol) => {
|
||||
let field_type = types_table.field_types().get(&field_symbol).unwrap();
|
||||
let read_destination = IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
field_type,
|
||||
);
|
||||
let read_destination = todo!();
|
||||
let read_destination_as_rc = Rc::new(RefCell::new(read_destination));
|
||||
let ir_read_field = IrReadField::new(
|
||||
get_or_init_field_pointer_variable(builder, &field_symbol, field_type).clone(),
|
||||
);
|
||||
let ir_read_field = IrReadField::new(todo!());
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(IrAssign::new(
|
||||
read_destination_as_rc.clone(),
|
||||
todo!(),
|
||||
IrOperation::ReadField(ir_read_field),
|
||||
)));
|
||||
IrExpression::Variable(read_destination_as_rc)
|
||||
IrExpression::Variable(todo!())
|
||||
}
|
||||
ExpressibleSymbol::Function(_) => {
|
||||
panic!("Cannot yet get ir-variable for FunctionSymbol")
|
||||
@ -644,11 +620,11 @@ impl Identifier {
|
||||
ExpressibleSymbol::Parameter(parameter_symbol) => {
|
||||
let parameters_map = builder.parameters_map();
|
||||
let ir_parameter = parameters_map.get(¶meter_symbol).unwrap();
|
||||
IrExpression::Parameter(ir_parameter.clone())
|
||||
IrExpression::Parameter(todo!())
|
||||
}
|
||||
ExpressibleSymbol::Variable(variable_symbol) => {
|
||||
let ir_variable = builder.local_variables().get(&variable_symbol).unwrap();
|
||||
IrExpression::Variable(ir_variable.clone())
|
||||
IrExpression::Variable(todo!())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,18 +21,14 @@ pub fn get_or_init_field_pointer_variable<'a>(
|
||||
.field_pointer_variables()
|
||||
.contains_key(field_symbol.declared_name())
|
||||
{
|
||||
let field_ref_variable = IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
field_type,
|
||||
);
|
||||
let field_ref_variable = todo!();
|
||||
let as_rc = Rc::new(RefCell::new(field_ref_variable));
|
||||
let to_insert = as_rc.clone();
|
||||
let self_parameter_or_variable = builder.self_parameter_or_variable().clone();
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(IrAssign::new(
|
||||
as_rc,
|
||||
todo!(),
|
||||
IrOperation::GetFieldRef(IrGetFieldRef::new(
|
||||
self_parameter_or_variable.clone(),
|
||||
field_symbol.field_index(),
|
||||
@ -57,18 +53,14 @@ pub fn get_or_init_mut_field_pointer_variable<'a>(
|
||||
.field_mut_pointer_variables()
|
||||
.contains_key(field_symbol.declared_name())
|
||||
{
|
||||
let mut_field_pointer_variable = IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
field_type,
|
||||
);
|
||||
let mut_field_pointer_variable = todo!();
|
||||
let as_rc = Rc::new(RefCell::new(mut_field_pointer_variable));
|
||||
let to_insert = as_rc.clone();
|
||||
let self_parameter_or_variable = builder.self_parameter_or_variable().clone();
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(IrAssign::new(
|
||||
as_rc,
|
||||
todo!(),
|
||||
IrOperation::GetFieldRefMut(IrGetFieldRefMut::new(
|
||||
self_parameter_or_variable.clone(),
|
||||
field_symbol.field_index(),
|
||||
|
||||
@ -254,11 +254,7 @@ impl LetStatement {
|
||||
}
|
||||
|
||||
fn make_vr_variable(&self, builder: &mut IrBuilder, destination_type: &TypeInfo) -> IrVariable {
|
||||
IrVariable::new_vr(
|
||||
self.declared_name().into(),
|
||||
builder.current_block().id(),
|
||||
destination_type,
|
||||
)
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn make_stack_variable(
|
||||
@ -267,12 +263,7 @@ impl LetStatement {
|
||||
destination_type: &TypeInfo,
|
||||
offset: isize,
|
||||
) -> IrVariable {
|
||||
IrVariable::new_stack_with_offset(
|
||||
self.declared_name().into(),
|
||||
builder.current_block().id(),
|
||||
destination_type,
|
||||
offset,
|
||||
)
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn get_destination_symbol(&self, symbol_table: &SymbolTable) -> Rc<VariableSymbol> {
|
||||
@ -301,7 +292,7 @@ impl LetStatement {
|
||||
let destination_vr_variable = self.make_vr_variable(builder, destination_type);
|
||||
|
||||
let as_rc = Rc::new(RefCell::new(destination_vr_variable));
|
||||
let ir_assign = IrAssign::new(as_rc.clone(), init_operation);
|
||||
let ir_assign = IrAssign::new(todo!(), init_operation);
|
||||
|
||||
builder
|
||||
.local_variables_mut()
|
||||
@ -330,7 +321,7 @@ impl LetStatement {
|
||||
let destination_stack_variable =
|
||||
self.make_stack_variable(builder, destination_type, destination_stack_offset);
|
||||
let as_rc = Rc::new(RefCell::new(destination_stack_variable));
|
||||
let ir_assign = IrAssign::new(as_rc.clone(), init_operation);
|
||||
let ir_assign = IrAssign::new(todo!(), init_operation);
|
||||
// do not need to save variable to builder as a new one is created for each repl function
|
||||
builder
|
||||
.current_block_mut()
|
||||
@ -354,11 +345,7 @@ impl LetStatement {
|
||||
|
||||
let destination_symbol = nodes_to_symbols.get(&self.node_id).unwrap();
|
||||
let destination_type_info = symbols_to_types.get(destination_symbol).unwrap();
|
||||
let vr_variable = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
self.declared_name().into(),
|
||||
builder.current_block().id(),
|
||||
destination_type_info,
|
||||
)));
|
||||
let vr_variable = Rc::new(RefCell::new(todo!()));
|
||||
|
||||
// save local variable to builder
|
||||
builder.local_variables_mut().insert(
|
||||
@ -366,7 +353,7 @@ impl LetStatement {
|
||||
vr_variable.clone(),
|
||||
);
|
||||
|
||||
let ir_assign = IrAssign::new(vr_variable, init_operation);
|
||||
let ir_assign = IrAssign::new(todo!(), init_operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
|
||||
@ -184,55 +184,47 @@ impl NegativeExpression {
|
||||
|
||||
match base_ir_expression {
|
||||
IrExpression::Parameter(ir_parameter) => {
|
||||
let destination = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
ir_parameter.type_info(),
|
||||
)));
|
||||
|
||||
let rhs = match ir_parameter.type_info() {
|
||||
TypeInfo::Integer => IrExpression::Int(-1),
|
||||
TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
IrExpression::Parameter(ir_parameter),
|
||||
rhs,
|
||||
IrBinaryOperator::Multiply,
|
||||
));
|
||||
|
||||
let ir_assign = IrAssign::new(destination.clone(), operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
|
||||
IrExpression::Variable(destination)
|
||||
let destination = Rc::new(RefCell::new(todo!()));
|
||||
todo!()
|
||||
// let rhs = match todo!() {
|
||||
// TypeInfo::Integer => IrExpression::Int(-1),
|
||||
// TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
// _ => panic!(),
|
||||
// };
|
||||
//
|
||||
// let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
// IrExpression::Parameter(ir_parameter),
|
||||
// rhs,
|
||||
// IrBinaryOperator::Multiply,
|
||||
// ));
|
||||
//
|
||||
// let ir_assign = IrAssign::new(destination.clone(), operation);
|
||||
// builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(ir_assign));
|
||||
//
|
||||
// IrExpression::Variable(destination)
|
||||
}
|
||||
IrExpression::Variable(ir_variable) => {
|
||||
let destination = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
ir_variable.borrow().type_info(),
|
||||
)));
|
||||
|
||||
let rhs = match ir_variable.borrow().type_info() {
|
||||
TypeInfo::Integer => IrExpression::Int(-1),
|
||||
TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
_ => panic!(),
|
||||
};
|
||||
|
||||
let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
IrExpression::Variable(ir_variable),
|
||||
rhs,
|
||||
IrBinaryOperator::Multiply,
|
||||
));
|
||||
|
||||
let ir_assign = IrAssign::new(destination.clone(), operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(ir_assign));
|
||||
IrExpression::Variable(destination)
|
||||
let destination = Rc::new(RefCell::new(todo!()));
|
||||
todo!()
|
||||
// let rhs = match ir_variable.borrow().type_info() {
|
||||
// TypeInfo::Integer => IrExpression::Int(-1),
|
||||
// TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
// _ => panic!(),
|
||||
// };
|
||||
//
|
||||
// let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
// IrExpression::Variable(ir_variable),
|
||||
// rhs,
|
||||
// IrBinaryOperator::Multiply,
|
||||
// ));
|
||||
//
|
||||
// let ir_assign = IrAssign::new(destination.clone(), operation);
|
||||
// builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(ir_assign));
|
||||
// IrExpression::Variable(destination)
|
||||
}
|
||||
IrExpression::Int(i) => IrExpression::Int(i * -1),
|
||||
IrExpression::Double(d) => IrExpression::Double(d * -1.0),
|
||||
@ -256,56 +248,48 @@ impl NegativeExpression {
|
||||
|
||||
match operand_as_ir {
|
||||
IrExpression::Parameter(parameter) => {
|
||||
let destination = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
parameter.type_info(),
|
||||
)));
|
||||
|
||||
let rhs = match parameter.type_info() {
|
||||
TypeInfo::Integer => IrExpression::Int(-1),
|
||||
TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
_ => panic!("Trying to multiply with a non-integer/double"),
|
||||
};
|
||||
|
||||
let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
IrExpression::Parameter(parameter),
|
||||
rhs,
|
||||
IrBinaryOperator::Multiply,
|
||||
));
|
||||
|
||||
let assign = IrAssign::new(destination.clone(), operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(assign));
|
||||
|
||||
IrExpression::Variable(destination)
|
||||
let destination = Rc::new(RefCell::new(todo!()));
|
||||
todo!()
|
||||
// let rhs = match todo!() {
|
||||
// TypeInfo::Integer => IrExpression::Int(-1),
|
||||
// TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
// _ => panic!("Trying to multiply with a non-integer/double"),
|
||||
// };
|
||||
//
|
||||
// let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
// IrExpression::Parameter(parameter),
|
||||
// rhs,
|
||||
// IrBinaryOperator::Multiply,
|
||||
// ));
|
||||
//
|
||||
// let assign = IrAssign::new(destination.clone(), operation);
|
||||
// builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(assign));
|
||||
//
|
||||
// IrExpression::Variable(destination)
|
||||
}
|
||||
IrExpression::Variable(variable) => {
|
||||
let destination = Rc::new(RefCell::new(IrVariable::new_vr(
|
||||
builder.new_t_var().into(),
|
||||
builder.current_block().id(),
|
||||
variable.borrow().type_info(),
|
||||
)));
|
||||
|
||||
let rhs = match variable.borrow().type_info() {
|
||||
TypeInfo::Integer => IrExpression::Int(-1),
|
||||
TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
_ => panic!("Trying to multiply with a non-integer/double"),
|
||||
};
|
||||
|
||||
let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
IrExpression::Variable(variable),
|
||||
rhs,
|
||||
IrBinaryOperator::Multiply,
|
||||
));
|
||||
|
||||
let assign = IrAssign::new(destination.clone(), operation);
|
||||
builder
|
||||
.current_block_mut()
|
||||
.add_statement(IrStatement::Assign(assign));
|
||||
|
||||
IrExpression::Variable(destination)
|
||||
let destination = Rc::new(RefCell::new(todo!()));
|
||||
todo!()
|
||||
// let rhs = match variable.borrow().type_info() {
|
||||
// TypeInfo::Integer => IrExpression::Int(-1),
|
||||
// TypeInfo::Double => IrExpression::Double(-1.0),
|
||||
// _ => panic!("Trying to multiply with a non-integer/double"),
|
||||
// };
|
||||
//
|
||||
// let operation = IrOperation::Binary(IrBinaryOperation::new(
|
||||
// IrExpression::Variable(variable),
|
||||
// rhs,
|
||||
// IrBinaryOperator::Multiply,
|
||||
// ));
|
||||
//
|
||||
// let assign = IrAssign::new(destination.clone(), operation);
|
||||
// builder
|
||||
// .current_block_mut()
|
||||
// .add_statement(IrStatement::Assign(assign));
|
||||
//
|
||||
// IrExpression::Variable(destination)
|
||||
}
|
||||
IrExpression::Int(i) => IrExpression::Int(i * -1),
|
||||
IrExpression::Double(d) => IrExpression::Double(d * -1.0),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user