-
Notifications
You must be signed in to change notification settings - Fork 23
/
function_call_options.ts
60 lines (52 loc) · 1.49 KB
/
function_call_options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { ASTNode } from "../../ast_node";
import { Expression } from "./expression";
export class FunctionCallOptions extends Expression {
/**
* Function expression. For following example:
* ```
* foreign.buy{gas: 2000, value: 1 gwei}(1000);
* ```
* Will contain `foreign.buy` member access.
*/
vExpression: Expression;
/**
* Option name/value pairs, respecting order.
*/
vOptionsMap: Map<string, Expression>;
constructor(
id: number,
src: string,
typeString: string,
expression: Expression,
options: Map<string, Expression>,
raw?: any
) {
super(id, src, typeString, raw);
this.vExpression = expression;
this.vOptionsMap = options;
this.acceptChildren();
}
get children(): readonly ASTNode[] {
return this.pickNodes(this.vExpression, this.vOptions);
}
/**
* Specified option names, respecting order. For following example:
* ```
* foreign.buy{gas: 2000, value: 1 gwei}(1000);
* ```
* Will contain `["gas", "value"]`.
*/
get names(): Iterable<string> {
return this.vOptionsMap.keys();
}
/**
* Specified option values, respecting order. For following example:
* ```
* foreign.buy{gas: 2000, value: 1 gwei}(1000);
* ```
* Will contain `[2000, 1 gwei]` literal expressions.
*/
get vOptions(): Iterable<Expression> {
return this.vOptionsMap.values();
}
}