Permalink
Browse files

LLVM: Use `tagua/llvm`.

  • Loading branch information...
Hywan committed Nov 1, 2016
1 parent ba75974 commit 6db179cc902d51ae5d01781991260f4efc6adc4b
Showing with 15 additions and 18 deletions.
  1. +1 −2 Cargo.toml
  2. +13 −13 source/language/compiler/vm.rs
  3. +1 −3 source/lib.rs
View
@@ -51,6 +51,5 @@ debug-assertions = true
codegen-units = 1
[dependencies]
-libc = "~0.2.7"
-llvm-sys = "~0.3.9"
+tagua-llvm = {git = "https://github.com/tagua-vm/llvm", rev = "master"}
tagua-parser = {git = "https://github.com/tagua-vm/parser", rev = "master"}
@@ -31,35 +31,35 @@
//! Transform an AST to VM intermediate representation.
+use llvm::native_type::VMRepresentation;
+use llvm;
use parser::ast;
-use super::super::super::vm::native_type::VMRepresentation;
-use super::super::super::vm;
/// Compile an AST to VM intermediate representation.
pub fn compile(ast: ast::Addition) {
- let context = vm::context::Context::new();
- let mut module = vm::module::Module::new("foobar", &context);
- let mut builder = vm::builder::Builder::new(&context);
- let function = vm::function::Function::new(
+ let context = llvm::context::Context::new();
+ let mut module = llvm::module::Module::new("foobar", &context);
+ let mut builder = llvm::builder::Builder::new(&context);
+ let function = llvm::function::Function::new(
&module,
"f",
&mut [],
- vm::native_type::int64_type(&context)
+ llvm::native_type::int64_type(&context)
);
let basic_block = function.new_basic_block("entry");
builder.move_to_end(basic_block);
let addition = builder.add(
- ast.a.t.to_vm_representation(&context),
- ast.b.t.to_vm_representation(&context),
+ 7u64.to_vm_representation(&context),
+ 42u64.to_vm_representation(&context),
"addition"
);
builder.return_value(addition);
- let engine_result = vm::engine::Engine::new(
+ let engine_result = llvm::engine::Engine::new(
&mut module,
- &vm::engine::Options {
- level : vm::engine::OptimizationLevel::NoOptimizations,
- code_model: vm::engine::CodeModel::Default
+ &llvm::engine::Options {
+ level : llvm::engine::OptimizationLevel::NoOptimizations,
+ code_model: llvm::engine::CodeModel::Default
}
);
View
@@ -40,10 +40,8 @@
//! This library is the fundation of the VM. It contains the language (with the lexer, parser and
//! compiler) and the virtual machine.
-extern crate libc;
-extern crate llvm_sys as llvm;
+extern crate tagua_llvm as llvm;
extern crate tagua_parser as parser;
pub mod language;
pub mod shared;
-pub mod vm;

0 comments on commit 6db179c

Please sign in to comment.