Skip to content

Commit

Permalink
_forEachIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Oct 9, 2024
1 parent 8047f7c commit 86db383
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions libs/sqf/src/analyze/inspector/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl SciptScope {
pub fn cmd_generic_call_magic(
&mut self,
code_possibilities: &HashSet<GameValue>,
magic: &Vec<&str>,
magic: Vec<(&str, GameValue)>,
source: &Range<usize>,
database: &Database,
) -> HashSet<GameValue> {
Expand All @@ -192,11 +192,11 @@ impl SciptScope {
continue;
}
self.push();
for var in magic {
for (var, value) in magic.iter() {
self.var_assign(
var,
true,
HashSet::from([GameValue::Anything]),
HashSet::from([value.clone()]),
VarSource::Magic(source.clone()),
);
}
Expand Down Expand Up @@ -363,7 +363,7 @@ impl SciptScope {
) -> HashSet<GameValue> {
let mut return_value = cmd_set.clone();
// Check: `array select expression`
let _ = self.cmd_generic_call_magic(rhs, &vec!["_x"], source, database);
let _ = self.cmd_generic_call_magic(rhs, vec![("_x", GameValue::Anything)], source, database);
// if lhs is array, and rhs is bool/number then put array into return
if lhs.len() == 1
&& rhs
Expand Down
6 changes: 3 additions & 3 deletions libs/sqf/src/analyze/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,14 @@ impl SciptScope {
"then" => Some(self.cmd_b_then(&lhs_set, &rhs_set, database)),
"foreach" | "foreachreversed" => Some(self.cmd_generic_call_magic(
&lhs_set,
&vec!["_x", "_y", "_forEachIndex"],
vec![("_x", GameValue::Anything), ("_y", GameValue::Anything), ("_forEachIndex", GameValue::Number(None))],
source,
database,
)),
"count" => {
let _ = self.cmd_generic_call_magic(
&lhs_set,
&vec!["_x"],
vec![("_x", GameValue::Anything)],
source,
database,
);
Expand All @@ -350,7 +350,7 @@ impl SciptScope {
"findif" | "apply" => {
let _ = self.cmd_generic_call_magic(
&rhs_set,
&vec!["_x"],
vec![("_x", GameValue::Anything)],
source,
database,
);
Expand Down
3 changes: 3 additions & 0 deletions libs/sqf/tests/inspector/test_0.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
_forEachIndex + "A";
} forEach z;

0 comments on commit 86db383

Please sign in to comment.