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.7% of users enabled 2FA.

Commit 8e4268ab authored by Eduardo Souza's avatar Eduardo Souza
Browse files

Adding explicit environment and store.

parent 4228dc95
......@@ -348,8 +348,8 @@ impl Exp for VarExp {
let current_block = vm.blocks_map.get_mut(&vm.curr_block).unwrap();
old_bindings.push(current_block.form_args.remove(name.name.as_str()));
current_block.form_args.insert(name.name.clone(), start_exp);
old_bindings.push(current_block.scoped_vars.remove(name.name.as_str()));
current_block.scoped_vars.insert(name.name.clone(), start_exp);
}
let body_value = match self.body_exp.code_gen_mu(vm, fun_ver) {
......@@ -363,11 +363,11 @@ impl Exp for VarExp {
let (name, _) = var;
let current_block = vm.blocks_map.get_mut(&vm.curr_block).unwrap();
current_block.form_args.remove(name.name.as_str());
current_block.scoped_vars.remove(name.name.as_str());
match old_bindings_iter.next() {
Some(Some(value)) => {
current_block.form_args.insert(name.name.clone(), value);
current_block.scoped_vars.insert(name.name.clone(), value);
}
_ => (),
}
......@@ -516,8 +516,10 @@ impl Exp for ForExp {
let current_block = vm.blocks_map.get_mut(&vm.curr_block).unwrap();
let current_block_args = (&current_block.args).clone();
let current_block_form_args = (&current_block.form_args).clone();
let current_block_scoped_vars = (&current_block.scoped_vars).clone();
let mut args_preloop = current_block_args.clone();
let mut form_args_preloop = current_block_form_args.clone();
let mut scoped_vars_preloop = current_block_scoped_vars.clone();
let mut args = vec![];
for (_, arg) in &current_block_form_args {
......@@ -525,12 +527,11 @@ impl Exp for ForExp {
}
args.push(start_exp);
println!("{:?}", current_block.block);
let branch_preloop = create_branch1_instr(vm.vm.next_id(), fun_ver, args, &preloop_block);
current_block.instr.push(branch_preloop);
form_args_preloop.insert(phi_node_name.clone(), phi_node.clone());
scoped_vars_preloop.insert(phi_node_name.clone(), phi_node.clone());
args_preloop.push(phi_node.clone_value());
vm.blocks_map.insert(
......@@ -540,21 +541,24 @@ impl Exp for ForExp {
instr: vec![],
args: args_preloop.clone(),
form_args: form_args_preloop.clone(),
scoped_vars : scoped_vars_preloop.clone(),
},
);
vm.curr_block = preloop_block_id;
let current_block = vm.blocks_map.get_mut(&vm.curr_block).unwrap();
let old_value = current_block.form_args.remove(self.var.name());
let old_value = current_block.scoped_vars.remove(self.var.name());
current_block
.form_args
.scoped_vars
.insert(self.var.name().clone(), phi_node.clone());
// build end loop check
let end_exp = match self.end_exp.code_gen_mu(vm, fun_ver) {
Ok(r) => r,
e @ Err(_) => return e,
Err(err) => {
return Err(err)
},
};
let name = format!("const_{}", 0);
......@@ -602,6 +606,7 @@ impl Exp for ForExp {
instr: vec![],
args: args_preloop.clone(),
form_args: form_args_preloop.clone(),
scoped_vars : scoped_vars_preloop.clone()
},
);
......@@ -620,6 +625,7 @@ impl Exp for ForExp {
instr: vec![],
args: current_block_args.clone(),
form_args: current_block_form_args.clone(),
scoped_vars: current_block_scoped_vars.clone()
},
);
......@@ -687,7 +693,7 @@ impl Exp for ForExp {
let preloop_block = vm.blocks_map.get_mut(&preloop_block_id).unwrap();
match old_value {
Some(v) => {
preloop_block.form_args.insert(self.var.name.clone(), v);
preloop_block.scoped_vars.insert(self.var.name.clone(), v);
}
None => (),
}
......@@ -890,6 +896,7 @@ impl Exp for ConditionalExp {
instr: vec![],
args: current_block_args.clone(),
form_args: current_block_form_args.clone(),
scoped_vars: current_block_form_args.clone()
},
);
......@@ -919,6 +926,7 @@ impl Exp for ConditionalExp {
instr: vec![],
args: current_block_args.clone(),
form_args: current_block_form_args.clone(),
scoped_vars: current_block_form_args.clone()
},
);
......@@ -963,6 +971,7 @@ impl Exp for ConditionalExp {
instr: vec![],
args: args_if_cont.clone(),
form_args: form_args_if_cont.clone(),
scoped_vars: form_args_if_cont.clone()
},
);
......@@ -1021,7 +1030,6 @@ fn create_branch1_instr(
form_args: Vec<P<TreeNode>>,
dest: &Block,
) -> P<TreeNode> {
println!("{:?}", form_args);
fun_ver.new_inst(Instruction {
hdr: MuEntityHeader::unnamed(id),
value: None,
......@@ -1115,7 +1123,7 @@ impl Exp for BinaryExp {
let variable = match context.named_values.get(var_name.as_str()) {
Some(vl) => *vl,
None => return Err(String::from("Uknown variable name")),
None => return Err(String::from("Unknown variable name")),
};
LLVMBuildStore(context.builder, rhs, variable);
......@@ -1138,7 +1146,9 @@ impl Exp for BinaryExp {
let rhs = match self.rhs.code_gen_mu(mu_vm, function_version) {
Ok(r) => r,
e @ Err(_) => return e,
Err(err) => {
return Err(err)
},
};
let var = function_version.new_ssa(
......@@ -1176,7 +1186,7 @@ impl Exp for BinaryExp {
let current_block = mu_vm.blocks_map.get_mut(&mu_vm.curr_block).unwrap();
let var_name = &*lhs.name();
current_block
.form_args
.scoped_vars
.insert(var_name.clone(), rhs.clone());
return Ok(rhs);
}
......@@ -1249,7 +1259,7 @@ impl Exp for Var {
);
Ok(var)
}
None => Err(String::from("Unknown variable name.")),
None => unimplemented!()
}
}
......@@ -1260,7 +1270,7 @@ impl Exp for Var {
) -> Result<P<TreeNode>, String> {
let current_block = mu_vm.blocks_map.get_mut(&mu_vm.curr_block).unwrap();
let r = current_block.form_args.get(self.name.as_str());
let r = current_block.scoped_vars.get(self.name.as_str());
match r {
Some(v) => {
// let mem_loc = v.clone();
......@@ -1269,7 +1279,7 @@ impl Exp for Var {
// current_block.instr.push(inst);
Ok(v.clone())
}
None => Err(String::from("Unknown variable name.")),
None => unimplemented!(),
}
}
}
......
......@@ -34,7 +34,7 @@ fn main() {
} else {
unsafe {
values =
mu_generator::code_gen(filename, nodes, USE_AOT_MU_LLVM, true, USE_ALLOCA, USE_NEW);
mu_generator::code_gen(filename, nodes, USE_AOT_MU_LLVM, false, USE_ALLOCA, USE_NEW);
}
}
......
......@@ -119,6 +119,7 @@ pub struct Mu_Block {
pub instr: Vec<P<TreeNode>>,
pub args: Vec<P<Value>>,
pub form_args: LinkedHashMap<String, P<TreeNode>>,
pub scoped_vars : LinkedHashMap<String, P<TreeNode>>,
}
pub unsafe fn code_gen(
......@@ -294,8 +295,6 @@ impl Mu_code_gen for Function {
let mut blk_entry = Block::new(MuEntityHeader::named(mu_vm.vm.next_id(), Mu("blk_entry")));
&mu_vm.vm.set_name(blk_entry.as_entity());
println!("{:?}", args);
let blk_entry_id = blk_entry.hdr.id();
mu_vm.curr_block = blk_entry_id;
mu_vm.blocks_map.insert(
......@@ -304,7 +303,8 @@ impl Mu_code_gen for Function {
block: blk_entry,
instr: alloca_instr,
args,
form_args,
form_args : form_args.clone(),
scoped_vars : form_args.clone()
},
);
......@@ -363,8 +363,6 @@ pub fn create_mu_load(
);
mu_vm.vm.set_name(var_loaded.as_entity());
println!("at load : {:?}", mem_loc);
let new_load_instr = func_version.new_inst(Instruction {
hdr: MuEntityHeader::unnamed(mu_vm.vm.next_id()),
value: Some(vec![var_loaded.clone_value()]),
......
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