Implement functions

- Implement function declaration and call
- Change the precalculated variable stack positions to contain the
  offset from the end instead of the absolute position. This is
  important for passing fun args on the stack
- Add the ability to offset the stackframes. This is used to delete the
  stack where the fun args have been stored before the block executes
- Implement exit type for blocks in interpreter. This is used to get the
  return values and propagate them where needed
- Add recursive fibonacci examples
This commit is contained in:
2022-02-10 01:26:11 +01:00
parent f0c2bd8dde
commit aeedfb4ef2
8 changed files with 272 additions and 20 deletions

View File

@@ -41,6 +41,8 @@ impl SimpleAstOptimizer {
}
Statement::Print(expr) => Self::optimize_expr(expr),
Statement::Declaration(_, _, expr) => Self::optimize_expr(expr),
Statement::FunDeclare(_) => (),
Statement::Return(expr) => Self::optimize_expr(expr),
}
}
}