MCPcopy Index your code
hub / github.com/endbasic/endbasic / exec

Method exec

core/tests/testutils/callables/sum_doubles_fn.rs:53–83  ·  view source on GitHub ↗
(&self, scope: Scope<'_>)

Source from the content-addressed store, hash-verified

51 }
52
53 fn exec(&self, scope: Scope<'_>) -> CallResult<()> {
54 let mut total = 0.0;
55 let mut reg = 0;
56 loop {
57 let sep = match scope.get_type(reg) {
58 VarArgTag::Immediate(sep, etype) => {
59 reg += 1;
60 match etype {
61 ExprType::Double => total += scope.get_double(reg),
62 ExprType::Integer => total += f64::from(scope.get_integer(reg)),
63 _ => {
64 return Err(CallError::Argument(
65 "Only accepts numerical values".to_owned(),
66 ));
67 }
68 }
69 sep
70 }
71
72 _ => {
73 return Err(CallError::Argument("Only accepts numerical values".to_owned()));
74 }
75 };
76 reg += 1;
77
78 if sep == ArgSep::End {
79 break;
80 }
81 }
82 scope.return_double(total)
83 }
84}

Callers

nothing calls this directly

Calls 4

get_typeMethod · 0.80
get_doubleMethod · 0.80
get_integerMethod · 0.80
return_doubleMethod · 0.80

Tested by

no test coverage detected