You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+14-19Lines changed: 14 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,31 +109,26 @@ export class Var {
109
109
Similarly, the `run` method of each commandlet is expected to return a `Var` type which can subsequently be referenced by the user using the `ret` keyword in the execution of the next command.
110
110
111
111
# Parsing
112
-
Below is snippet of the `dump` commandlet showing how it parses it's two arguments. The first is the address which to dump and the second is the length. Note that the first argument is also used as the return value for this commandlet. Note also that the second argument is also converted from a `UInt64` to a `number` type, since this is what is reqired by the `hexdump` function called by `this.dump`. This is used in many commands where the parameter is likely to be a small number and therefore loss of precision is not a concern.
112
+
Below is snippet of the `dump` commandlet showing how it parses it's three arguments. The first is the address which to dump and the second is the length, and the fourth the width. Note that the first argument is also used as the return value for this commandlet. Note also that the second argument is also converted from a `UInt64` to a `number` type, since this is what is reqired by the `hexdump` function called by `this.dump`. This is used in many commands where the parameter is likely to be a small number and therefore loss of precision is not a concern.
113
113
```js
114
-
privaterunWithLength(tokens: Token[]): Var |null {
115
-
if (tokens.length!==2) returnnull;
116
-
117
-
const [a0, a1] = tokens;
118
-
const [t0, t1] = [a0 as Token, a1 as Token];
119
-
const [v0, v1] = [t0.toVar(), t1.toVar()];
120
-
121
-
if (v0 ===null) returnnull;
122
-
if (v1 ===null) returnnull;
114
+
publicrunSync(tokens: Token[]): Var {
115
+
constvars=this.transformOptional(
116
+
tokens,
117
+
[this.parseVar],
118
+
[this.parseVar, this.parseWidth],
119
+
);
120
+
if (vars ===null) returnthis.usage();
121
+
const [[v0], [v1, v2]] = vars as [[Var], [Var |null, number |null]];
0 commit comments