🤔 Add a type inference engine, along with typed literals. #4
12
Cargo.toml
12
Cargo.toml
@@ -12,12 +12,12 @@ path = "src/lib.rs"
|
|||||||
clap = { version = "^3.0.14", features = ["derive"] }
|
clap = { version = "^3.0.14", features = ["derive"] }
|
||||||
codespan = "0.11.1"
|
codespan = "0.11.1"
|
||||||
codespan-reporting = "0.11.1"
|
codespan-reporting = "0.11.1"
|
||||||
cranelift-codegen = "0.94.0"
|
cranelift-codegen = "0.99.1"
|
||||||
cranelift-jit = "0.94.0"
|
cranelift-jit = "0.99.1"
|
||||||
cranelift-frontend = "0.94.0"
|
cranelift-frontend = "0.99.1"
|
||||||
cranelift-module = "0.94.0"
|
cranelift-module = "0.99.1"
|
||||||
cranelift-native = "0.94.0"
|
cranelift-native = "0.99.1"
|
||||||
cranelift-object = "0.94.0"
|
cranelift-object = "0.99.1"
|
||||||
internment = { version = "0.7.0", default-features = false, features = ["arc"] }
|
internment = { version = "0.7.0", default-features = false, features = ["arc"] }
|
||||||
lalrpop-util = "^0.20.0"
|
lalrpop-util = "^0.20.0"
|
||||||
lazy_static = "^1.4.0"
|
lazy_static = "^1.4.0"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ use crate::syntax::ConstantType;
|
|||||||
use cranelift_codegen::settings::Configurable;
|
use cranelift_codegen::settings::Configurable;
|
||||||
use cranelift_codegen::{isa, settings};
|
use cranelift_codegen::{isa, settings};
|
||||||
use cranelift_jit::{JITBuilder, JITModule};
|
use cranelift_jit::{JITBuilder, JITModule};
|
||||||
use cranelift_module::{default_libcall_names, DataContext, DataId, FuncId, Linkage, Module};
|
use cranelift_module::{default_libcall_names, DataDescription, DataId, FuncId, Linkage, Module};
|
||||||
use cranelift_object::{ObjectBuilder, ObjectModule};
|
use cranelift_object::{ObjectBuilder, ObjectModule};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
@@ -55,7 +55,7 @@ const EMPTY_DATUM: [u8; 8] = [0; 8];
|
|||||||
/// implementations.
|
/// implementations.
|
||||||
pub struct Backend<M: Module> {
|
pub struct Backend<M: Module> {
|
||||||
pub module: M,
|
pub module: M,
|
||||||
data_ctx: DataContext,
|
data_ctx: DataDescription,
|
||||||
runtime_functions: RuntimeFunctions,
|
runtime_functions: RuntimeFunctions,
|
||||||
defined_strings: HashMap<String, DataId>,
|
defined_strings: HashMap<String, DataId>,
|
||||||
defined_symbols: HashMap<String, (DataId, ConstantType)>,
|
defined_symbols: HashMap<String, (DataId, ConstantType)>,
|
||||||
@@ -85,7 +85,7 @@ impl Backend<JITModule> {
|
|||||||
|
|
||||||
Ok(Backend {
|
Ok(Backend {
|
||||||
module,
|
module,
|
||||||
data_ctx: DataContext::new(),
|
data_ctx: DataDescription::new(),
|
||||||
runtime_functions,
|
runtime_functions,
|
||||||
defined_strings: HashMap::new(),
|
defined_strings: HashMap::new(),
|
||||||
defined_symbols: HashMap::new(),
|
defined_symbols: HashMap::new(),
|
||||||
@@ -123,7 +123,7 @@ impl Backend<ObjectModule> {
|
|||||||
|
|
||||||
Ok(Backend {
|
Ok(Backend {
|
||||||
module,
|
module,
|
||||||
data_ctx: DataContext::new(),
|
data_ctx: DataDescription::new(),
|
||||||
runtime_functions,
|
runtime_functions,
|
||||||
defined_strings: HashMap::new(),
|
defined_strings: HashMap::new(),
|
||||||
defined_symbols: HashMap::new(),
|
defined_symbols: HashMap::new(),
|
||||||
@@ -154,7 +154,7 @@ impl<M: Module> Backend<M> {
|
|||||||
let global_id = self
|
let global_id = self
|
||||||
.module
|
.module
|
||||||
.declare_data(&name, Linkage::Local, false, false)?;
|
.declare_data(&name, Linkage::Local, false, false)?;
|
||||||
let mut data_context = DataContext::new();
|
let mut data_context = DataDescription::new();
|
||||||
data_context.set_align(8);
|
data_context.set_align(8);
|
||||||
data_context.define(s0.into_boxed_str().into_boxed_bytes());
|
data_context.define(s0.into_boxed_str().into_boxed_bytes());
|
||||||
self.module.define_data(global_id, &data_context)?;
|
self.module.define_data(global_id, &data_context)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user