nac3core/toplevel: added personality symbol config
This commit is contained in:
parent
dd998c8afc
commit
693ac7d336
|
@ -308,6 +308,14 @@ pub fn gen_func<'ctx>(
|
||||||
let fn_val =
|
let fn_val =
|
||||||
module.get_function(symbol).unwrap_or_else(|| module.add_function(symbol, fn_type, None));
|
module.get_function(symbol).unwrap_or_else(|| module.add_function(symbol, fn_type, None));
|
||||||
|
|
||||||
|
if let Some(personality) = &top_level_ctx.personality_symbol {
|
||||||
|
let personality = module.get_function(&personality).unwrap_or_else(|| {
|
||||||
|
let ty = context.i32_type().fn_type(&[], true);
|
||||||
|
module.add_function(&personality, ty, None)
|
||||||
|
});
|
||||||
|
fn_val.set_personality_function(personality);
|
||||||
|
}
|
||||||
|
|
||||||
let init_bb = context.append_basic_block(fn_val, "init");
|
let init_bb = context.append_basic_block(fn_val, "init");
|
||||||
builder.position_at_end(init_bb);
|
builder.position_at_end(init_bb);
|
||||||
let body_bb = context.append_basic_block(fn_val, "body");
|
let body_bb = context.append_basic_block(fn_val, "body");
|
||||||
|
|
|
@ -115,6 +115,7 @@ fn test_primitives() {
|
||||||
let top_level = Arc::new(TopLevelContext {
|
let top_level = Arc::new(TopLevelContext {
|
||||||
definitions: Arc::new(RwLock::new(std::mem::take(&mut *top_level.definitions.write()))),
|
definitions: Arc::new(RwLock::new(std::mem::take(&mut *top_level.definitions.write()))),
|
||||||
unifiers: Arc::new(RwLock::new(vec![(unifier.get_shared_unifier(), primitives)])),
|
unifiers: Arc::new(RwLock::new(vec![(unifier.get_shared_unifier(), primitives)])),
|
||||||
|
personality_symbol: None
|
||||||
});
|
});
|
||||||
|
|
||||||
let unifier = (unifier.get_shared_unifier(), primitives);
|
let unifier = (unifier.get_shared_unifier(), primitives);
|
||||||
|
@ -302,6 +303,7 @@ fn test_simple_call() {
|
||||||
let top_level = Arc::new(TopLevelContext {
|
let top_level = Arc::new(TopLevelContext {
|
||||||
definitions: Arc::new(RwLock::new(std::mem::take(&mut *top_level.definitions.write()))),
|
definitions: Arc::new(RwLock::new(std::mem::take(&mut *top_level.definitions.write()))),
|
||||||
unifiers: Arc::new(RwLock::new(vec![(unifier.get_shared_unifier(), primitives)])),
|
unifiers: Arc::new(RwLock::new(vec![(unifier.get_shared_unifier(), primitives)])),
|
||||||
|
personality_symbol: None
|
||||||
});
|
});
|
||||||
|
|
||||||
let unifier = (unifier.get_shared_unifier(), primitives);
|
let unifier = (unifier.get_shared_unifier(), primitives);
|
||||||
|
|
|
@ -132,6 +132,7 @@ impl TopLevelComposer {
|
||||||
self.unifier.get_shared_unifier(),
|
self.unifier.get_shared_unifier(),
|
||||||
self.primitives_ty,
|
self.primitives_ty,
|
||||||
)])),
|
)])),
|
||||||
|
personality_symbol: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,4 +84,5 @@ pub enum TopLevelDef {
|
||||||
pub struct TopLevelContext {
|
pub struct TopLevelContext {
|
||||||
pub definitions: Arc<RwLock<Vec<Arc<RwLock<TopLevelDef>>>>>,
|
pub definitions: Arc<RwLock<Vec<Arc<RwLock<TopLevelDef>>>>>,
|
||||||
pub unifiers: Arc<RwLock<Vec<(SharedUnifier, PrimitiveStore)>>>,
|
pub unifiers: Arc<RwLock<Vec<(SharedUnifier, PrimitiveStore)>>>,
|
||||||
|
pub personality_symbol: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,7 @@ impl TestEnvironment {
|
||||||
top_level: TopLevelContext {
|
top_level: TopLevelContext {
|
||||||
definitions: Default::default(),
|
definitions: Default::default(),
|
||||||
unifiers: Default::default(),
|
unifiers: Default::default(),
|
||||||
|
personality_symbol: None,
|
||||||
},
|
},
|
||||||
unifier,
|
unifier,
|
||||||
function_data: FunctionData {
|
function_data: FunctionData {
|
||||||
|
@ -277,6 +278,7 @@ impl TestEnvironment {
|
||||||
let top_level = TopLevelContext {
|
let top_level = TopLevelContext {
|
||||||
definitions: Arc::new(top_level_defs.into()),
|
definitions: Arc::new(top_level_defs.into()),
|
||||||
unifiers: Default::default(),
|
unifiers: Default::default(),
|
||||||
|
personality_symbol: None
|
||||||
};
|
};
|
||||||
|
|
||||||
let resolver = Arc::new(Box::new(Resolver {
|
let resolver = Arc::new(Box::new(Resolver {
|
||||||
|
|
Loading…
Reference in New Issue