2016-02-09 23:52:57 -08:00
|
|
|
extern crate llvm_sys;
|
|
|
|
|
2016-12-21 01:42:37 -08:00
|
|
|
use self::llvm_sys::prelude::*;
|
|
|
|
use self::llvm_sys::core;
|
2016-02-10 03:25:37 -08:00
|
|
|
|
2016-02-11 10:49:45 -08:00
|
|
|
|
2016-02-15 23:41:00 -08:00
|
|
|
use parser::{ParseResult, AST, ASTNode, Prototype, Function, Expression};
|
2016-02-10 03:25:37 -08:00
|
|
|
|
2016-03-04 14:32:22 -08:00
|
|
|
pub fn compile_ast(ast: AST) {
|
|
|
|
println!("Compiling!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-12-21 01:42:37 -08:00
|
|
|
trait CodeGen {
|
|
|
|
fn codegen(&self, LLVMContextRef) -> LLVMValueRef;
|
2016-02-10 03:25:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-21 01:42:37 -08:00
|
|
|
impl CodeGen for ASTNode {
|
|
|
|
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
|
|
|
use self::ASTNode::*;
|
2016-02-11 10:49:45 -08:00
|
|
|
match self {
|
2016-12-21 01:42:37 -08:00
|
|
|
&ExprNode(ref expr) => expr.codegen(context),
|
|
|
|
&FuncNode(ref func) => unimplemented!(),
|
2016-02-11 10:49:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-21 01:42:37 -08:00
|
|
|
impl CodeGen for Expression {
|
|
|
|
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
|
|
|
use self::Expression::*;
|
2016-02-12 23:14:09 -08:00
|
|
|
match self {
|
2016-12-21 01:42:37 -08:00
|
|
|
&Number(ref n) => unimplemented!(),
|
|
|
|
_ => unimplemented!(),
|
2016-02-12 23:14:09 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|