Some in-progress work
This commit is contained in:
parent
a01b6c874e
commit
2ad65a1c5d
@ -12,12 +12,12 @@ mod LLVMWrap {
|
|||||||
use self::llvm_sys::prelude::*;
|
use self::llvm_sys::prelude::*;
|
||||||
use self::llvm_sys::core;
|
use self::llvm_sys::core;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
pub fn ContextCreate() -> LLVMContextRef {
|
pub fn create_context() -> LLVMContextRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
core::LLVMContextCreate()
|
core::LLVMContextCreate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn ModuleCreateWithName(name: &str) -> LLVMModuleRef {
|
pub fn module_create_with_name(name: &str) -> LLVMModuleRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let n = name.as_ptr() as *const _;
|
let n = name.as_ptr() as *const _;
|
||||||
core::LLVMModuleCreateWithName(n)
|
core::LLVMModuleCreateWithName(n)
|
||||||
@ -32,8 +32,8 @@ mod LLVMWrap {
|
|||||||
|
|
||||||
pub fn compile_ast(ast: AST) {
|
pub fn compile_ast(ast: AST) {
|
||||||
println!("Compiling!");
|
println!("Compiling!");
|
||||||
let context = LLVMWrap::ContextCreate();
|
let context = LLVMWrap::create_context();
|
||||||
let module = LLVMWrap::ModuleCreateWithName("schala");
|
let module = LLVMWrap::module_create_with_name("schala");
|
||||||
let builder = LLVMWrap::CreateBuilderInContext(context);
|
let builder = LLVMWrap::CreateBuilderInContext(context);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
||||||
@ -63,7 +63,6 @@ trait CodeGen {
|
|||||||
fn codegen(&self, LLVMContextRef) -> LLVMValueRef;
|
fn codegen(&self, LLVMContextRef) -> LLVMValueRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl CodeGen for ASTNode {
|
impl CodeGen for ASTNode {
|
||||||
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
||||||
use self::ASTNode::*;
|
use self::ASTNode::*;
|
||||||
@ -78,6 +77,9 @@ impl CodeGen for Expression {
|
|||||||
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
fn codegen(&self, context: LLVMContextRef) -> LLVMValueRef {
|
||||||
use self::Expression::*;
|
use self::Expression::*;
|
||||||
match self {
|
match self {
|
||||||
|
&BinExp(ref op, ref left, ref right) => {
|
||||||
|
unimplemented!()
|
||||||
|
},
|
||||||
&Number(ref n) => {
|
&Number(ref n) => {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user