-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wip] Nova versão da geração de código #8
base: master
Are you sure you want to change the base?
Conversation
GChicha
commented
Nov 24, 2018
•
edited by theosirian
Loading
edited by theosirian
- Decl
- Single
- Global
- Local
- Array
- Global
- Declaration
- Initiallization
- Local
- Declaration
- Initialization
- Global
- Function
- Params
- Single
- Array
- Params
- Single
- Expr
- Variable
- Single
- Array
- Add
- Sub
- Div
- Mul
- Mod
- Ternary
- Variable
- Stmt
- Attr
- Stop
- Skip
- Read
- Write
- Call
- If
- While
- For
Já propaguei os tipos e as localizções de todos elementos da AST, por enquanto eles não estão utilizados. Acredito que se substituirmos as chamadas unwrap por algo que emita erros já é suficiente. |
Acho que tá legal para entregar, a unica coisa que não está funcionando (talvez não seja dificil corrigir) é a passagem de array por parametro, o resto, read write e todos os outros controless de fluxo estão funcionando. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saco de vacilo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments.
Op(Box<Expr>, Opcode, Box<Expr>), | ||
Right(Opcode, Box<Expr>), | ||
Ternary(Box<Expr>, Box<Expr>, Box<Expr>), | ||
Number(u64, Location), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap Expr with a Location like:
enum Expr {
...
}
pub type Expr = (Expr, Location)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, after reading the rest of the files, you can do that with almost all the AST types.
src/gen/context.rs
Outdated
pub module: *mut LLVMModule, | ||
pub context: *mut LLVMContext, | ||
pub builder: *mut LLVMBuilder, | ||
pub actual_function: Option<(*mut LLVMValue, *mut LLVMBasicBlock)>, // (function, entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual
is not atual
, that would be current
.
impl Emit<*mut LLVMType> for Type { | ||
unsafe fn emit( | ||
self: &Self, | ||
context: &mut Context, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destructure Context like so:
Context {
mut symbol_table,
module,
context,
actual_function,
builder,
}: &mut Context
Add mutables as needed.