-
Notifications
You must be signed in to change notification settings - Fork 23
/
modifier_invocation.ts
61 lines (52 loc) · 1.87 KB
/
modifier_invocation.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
61
import { ASTNode } from "../../ast_node";
import { ModifierInvocationKind } from "../../constants";
import { ContractDefinition } from "../declaration/contract_definition";
import { ModifierDefinition } from "../declaration/modifier_definition";
import { Expression } from "../expression/expression";
import { Identifier } from "../expression/identifier";
import { IdentifierPath } from "./identifier_path";
export class ModifierInvocation extends ASTNode {
/**
* Kind of invoked target modifier:
* - base contract constrcutor (when appled via modifier syntax);
* - regular modifier definition.
*
* Is `undefined` when not provided in raw AST.
*/
kind?: ModifierInvocationKind;
/**
* An identifier of the referenced modifier declaration
*/
vModifierName: Identifier | IdentifierPath;
/**
* An array of arguments, that are passed for the modifier call
*/
vArguments: Expression[];
constructor(
id: number,
src: string,
modifierName: Identifier | IdentifierPath,
args: Expression[],
kind?: ModifierInvocationKind,
raw?: any
) {
super(id, src, raw);
this.kind = kind;
this.vModifierName = modifierName;
this.vArguments = args;
this.acceptChildren();
}
get children(): readonly ASTNode[] {
return this.pickNodes(this.vModifierName, this.vArguments);
}
/**
* Reference to the `ModifierDefinition` or `ContractDefinition`.
*
* There is a possibility that constructor of the current contract
* invokes a constructor of the super contract.
* The `ContractDefinition` of a super contract is the value in such case.
*/
get vModifier(): ModifierDefinition | ContractDefinition {
return this.vModifierName.vReferencedDeclaration as ModifierDefinition | ContractDefinition;
}
}