| 79 | } |
| 80 | |
| 81 | int ScriptArgs::intAt(int i) const |
| 82 | { |
| 83 | struct Value* value = at(i); |
| 84 | // The Value carries the type from the prototype, so a mismatch here means |
| 85 | // the binding and its declaration disagree — a Checkpoint bug that used to |
| 86 | // read a pointer as an int and abort somewhere else entirely. |
| 87 | if (value->Typ == nullptr || value->Typ->Base != TypeInt) { |
| 88 | fail("argument %d is declared %s, read as int", i + 1, value->Typ != nullptr ? baseName(value->Typ->Base) : "untyped"); |
| 89 | } |
| 90 | return value->Val->Integer; |
| 91 | } |
| 92 | |
| 93 | void* ScriptArgs::ptrAt(int i, bool allowNull) const |
| 94 | { |