WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.2% of users enabled 2FA.

Commit 2da94d67 authored by Kunshan Wang's avatar Kunshan Wang
Browse files

IRBuilder: Build functions (not versions yet).

parent c04159ca
......@@ -105,17 +105,6 @@ impl MuIRBuilder {
pub fn new_type_int(&mut self, id: MuID, len: c_int) {
self.bundle.types.insert(id, Box::new(NodeType::TypeInt { id: id, len: len }));
// let maybe_name = self.consume_name_of(id);
// let pty = P(MuType {
// hdr: MuEntityHeader {
// id: id,
// name: RwLock::new(maybe_name),
// },
// v: MuType_::Int(len as usize),
// });
//
// self.bundle.types.push(pty);
}
pub fn new_type_float(&mut self, id: MuID) {
......@@ -451,6 +440,7 @@ struct BundleLoader<'lb, 'lvm> {
built_types: IdPMap<MuType>,
built_sigs: IdPMap<MuFuncSig>,
built_values: IdPMap<Value>,
built_funcs: IdPMap<MuFunction>,
struct_id_tags: Vec<(MuID, MuName)>,
}
......@@ -467,6 +457,7 @@ fn load_bundle(b: &mut MuIRBuilder) {
built_types: Default::default(),
built_sigs: Default::default(),
built_values: Default::default(),
built_funcs: Default::default(),
struct_id_tags: Default::default(),
};
......@@ -480,7 +471,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
}
fn name_from_id(id: MuID, hint: &str) -> String {
format!("@uvm.unnamed{}{}", hint, id)
format!("@uvm.unnamed.{}{}", hint, id)
}
fn ensure_name(&mut self, id: MuID, hint: &str) {
......@@ -502,6 +493,14 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
_ => {}
}
}
for id in self.b.bundle.funcvers.keys() {
self.ensure_name(*id, "funcver");
}
for id in self.b.bundle.bbs.keys() {
self.ensure_name(*id, "funcver");
}
}
fn get_name(&self, id: MuID) -> String {
......@@ -542,6 +541,12 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
self.build_const(*id)
}
}
for id in self.b.bundle.funcs.keys() {
if !self.visited.contains(id) {
self.build_func(*id)
}
}
}
fn build_type(&mut self, id: MuID) {
......@@ -691,5 +696,27 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
self.built_values.insert(id, P(impl_val));
}
fn build_func(&mut self, id: MuID) {
self.visited.insert(id);
let fun = self.b.bundle.funcs.get(&id).unwrap();
trace!("Building function {} {:?}", id, fun);
let hdr = self.make_mu_entity_header(id);
let impl_sig = self.ensure_sig_rec(fun.sig);
let impl_fun = MuFunction {
hdr: hdr,
sig: impl_sig,
cur_ver: None,
all_vers: Default::default(),
};
trace!("Function built: {} {:?}", id, impl_fun);
self.built_funcs.insert(id, P(impl_fun));
}
}
......@@ -150,3 +150,44 @@ fn test_consts_loading() {
}
}
#[test]
#[allow(unused_variables)]
fn test_function_loading() {
let mut csp: CStringPool = Default::default();
unsafe {
simple_logger::init_with_level(log::LogLevel::Trace).ok();
info!("Starting micro VM...");
let mvm = mu_fastimpl_new();
let ctx = ((*mvm).new_context)(mvm);
let b = ((*ctx).new_ir_builder)(ctx);
let id1 = ((*b).gen_sym)(b, csp.get("@i32"));
let id2 = ((*b).gen_sym)(b, csp.get("@i64"));
let id3 = ((*b).gen_sym)(b, csp.get("@sig"));
let id4 = ((*b).gen_sym)(b, csp.get("@func"));
((*b).new_type_int)(b, id1, 32);
((*b).new_type_int)(b, id2, 64);
let mut ptys = vec![id1];
let mut rtys = vec![id2];
((*b).new_funcsig)(b, id3,
ptys.as_mut_ptr(), ptys.len(),
rtys.as_mut_ptr(), rtys.len());
((*b).new_func)(b, id4, id3);
((*b).load)(b);
((*ctx).close_context)(ctx);
info!("Finished.");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment