123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import { injectable, inject } from 'inversify';
- import { ServiceIdentifiers } from '../../../container/ServiceIdentifiers';
- import { Expression } from 'estree';
- import { TStatement } from '../../../types/node/TStatement';
- import { IOptions } from '../../../interfaces/options/IOptions';
- import { initializable } from '../../../decorators/Initializable';
- import { AbstractCustomNode } from '../../AbstractCustomNode';
- import { Nodes } from '../../../node/Nodes';
- @injectable()
- export class ControlFlowStorageCallNode extends AbstractCustomNode {
- /**
- * @type {string}
- */
- @initializable()
- private controlFlowStorageKey: string;
- /**
- * @type {string}
- */
- @initializable()
- private controlFlowStorageName: string;
- /**
- * @type {Expression}
- */
- @initializable()
- private leftValue: Expression;
- /**
- * @type {ESTree.Expression}
- */
- @initializable()
- private rightValue: Expression;
- /**
- * @param options
- */
- constructor (
- @inject(ServiceIdentifiers.IOptions) options: IOptions
- ) {
- super(options);
- }
- /**
- * @param controlFlowStorageName
- * @param controlFlowStorageKey
- * @param leftValue
- * @param rightValue
- */
- public initialize (
- controlFlowStorageName: string,
- controlFlowStorageKey: string,
- leftValue: Expression,
- rightValue: Expression,
- ): void {
- this.controlFlowStorageName = controlFlowStorageName;
- this.controlFlowStorageKey = controlFlowStorageKey;
- this.leftValue = leftValue;
- this.rightValue = rightValue;
- }
- protected getNodeStructure (): TStatement[] {
- return [
- Nodes.getExpressionStatementNode(
- Nodes.getCallExpressionNode(
- Nodes.getMemberExpressionNode(
- Nodes.getIdentifierNode(this.controlFlowStorageName),
- Nodes.getIdentifierNode(this.controlFlowStorageKey)
- ),
- [
- this.leftValue,
- this.rightValue
- ]
- )
- )
- ];
- }
- }
|