Implement copy

master
Raymon Zutekouw 2 years ago
parent 20869b55c1
commit aff0ed0034
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 19
      src/main.rs

@ -162,7 +162,24 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
Rule::copy => {
let variable_name = operand;
println!("Copy to variable '{}'", variable_name);
out.append("copy\n");
let source_address = state.mem_pointer.to_string();
to_bf(Rule::var, "__temp", state, out);
out.append("[");
to_bf(Rule::sub, "1", state, out);
to_bf(Rule::point, variable_name, state, out);
to_bf(Rule::add, "1", state, out);
to_bf(Rule::point, "__temp", state, out);
to_bf(Rule::add, "1", state, out);
to_bf(Rule::pointa, &source_address, state, out);
out.append("]");
to_bf(Rule::point, "__temp", state, out);
out.append("[");
to_bf(Rule::sub, "1", state, out);
to_bf(Rule::pointa, &source_address, state, out);
to_bf(Rule::add, "1", state, out);
to_bf(Rule::point, "__temp", state, out);
out.append("]");
to_bf(Rule::delvar, "__temp", state, out);
}
Rule::setz => {
println!("Set current variable to zero");

Loading…
Cancel
Save