Skip to content

Commit

Permalink
Smaller IR changes. (FuelLabs#828)
Browse files Browse the repository at this point in the history
* Introduce IrError and use it for most Results in the library.

* Handle IrErrors naively by converting to String.

* Remove the redundant Module name.

I put it there initially without thinking, and then just used the name
'script' for scripts, etc.  This just removes it altogether; touches a
lot of the test files.

* Move the aggregate naming management from IR back into core.

The IR doesn't care about struct field names nor enum variant names.
They need to be tracked by IRgen though, so instead of managing it in
the IR Context it can be all done in IRgen core.
  • Loading branch information
otrho authored Feb 23, 2022
1 parent 24c879c commit 89ce7fb
Show file tree
Hide file tree
Showing 55 changed files with 390 additions and 261 deletions.
4 changes: 2 additions & 2 deletions sway-core/src/asm_generation/from_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ impl<'ir> AsmBuilder<'ir> {
}
Some(span_md_idx) => match span_md_idx.to_span(self.context) {
Ok(span) => span,
Err(msg) => {
Err(ir_error) => {
errors.push(CompileError::InternalOwned(
msg,
ir_error.to_string(),
instr_val
.get_span(self.context)
.unwrap_or_else(Self::empty_span),
Expand Down
8 changes: 4 additions & 4 deletions sway-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,11 @@ pub(crate) fn compile_ast_to_ir_to_asm(

fn inline_function_calls(ir: &mut Context, functions: &[Function]) -> CompileResult<()> {
for function in functions {
if let Err(msg) = sway_ir::optimize::inline_all_function_calls(ir, function) {
if let Err(ir_error) = sway_ir::optimize::inline_all_function_calls(ir, function) {
return err(
Vec::new(),
vec![CompileError::InternalOwned(
msg,
ir_error.to_string(),
span::Span {
span: pest::Span::new("".into(), 0, 0).unwrap(),
path: None,
Expand All @@ -487,11 +487,11 @@ fn inline_function_calls(ir: &mut Context, functions: &[Function]) -> CompileRes

fn combine_constants(ir: &mut Context, functions: &[Function]) -> CompileResult<()> {
for function in functions {
if let Err(msg) = sway_ir::optimize::combine_constants(ir, function) {
if let Err(ir_error) = sway_ir::optimize::combine_constants(ir, function) {
return err(
Vec::new(),
vec![CompileError::InternalOwned(
msg,
ir_error.to_string(),
span::Span {
span: pest::Span::new("".into(), 0, 0).unwrap(),
path: None,
Expand Down
Loading

0 comments on commit 89ce7fb

Please sign in to comment.