add variable cloning
This commit is contained in:
parent
1f020ecdb2
commit
e258f6208d
3 changed files with 11 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -99,7 +99,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "granite"
|
name = "granite"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "granite"
|
name = "granite"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -280,6 +280,14 @@ fn execute(program: Program) {
|
||||||
println!("Missing variable on int check.");
|
println!("Missing variable on int check.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
} else if statement.operator == "%" {
|
||||||
|
if vars.contains_key(&statement.arguments[0]) {
|
||||||
|
let value = vars.get(&statement.arguments[0]).unwrap();
|
||||||
|
vars.insert(statement.arguments[1].clone(), value.clone());
|
||||||
|
} else {
|
||||||
|
println!("Missing variable on clone.");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
} else if statement.operator == "$" {
|
} else if statement.operator == "$" {
|
||||||
vars.remove(&statement.arguments[0]);
|
vars.remove(&statement.arguments[0]);
|
||||||
}
|
}
|
||||||
|
@ -392,6 +400,7 @@ fn operator_to_arglength(operator: char) -> Option<i32> {
|
||||||
'0' => Some(1),
|
'0' => Some(1),
|
||||||
'&' => Some(2),
|
'&' => Some(2),
|
||||||
'$' => Some(1),
|
'$' => Some(1),
|
||||||
|
'%' => Some(2),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue