12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- "use strict";
- const estraverse = require('estraverse');
- const Node_1 = require('./Node');
- class UnicodeArrayRotateFunctionCallNode extends Node_1.Node {
- constructor(astTree, unicodeArrayRotateFunctionName, unicodeArrayName, unicodeArrayRotateValue) {
- super();
- this.astTree = astTree;
- this.unicodeArrayRotateFunctionName = unicodeArrayRotateFunctionName;
- this.unicodeArrayName = unicodeArrayName;
- this.unicodeArrayRotateValue = unicodeArrayRotateValue;
- this.node = this.getNodeStructure();
- }
- appendNode() {
- estraverse.replace(this.astTree, {
- leave: (node, parent) => {
- switch (node.type) {
- case 'Program':
- node.body.unshift(this.getNode());
- break;
- default:
- break;
- }
- }
- });
- }
- getNodeStructure() {
- return {
- 'type': 'ExpressionStatement',
- 'expression': {
- 'type': 'CallExpression',
- 'callee': {
- 'type': 'Identifier',
- 'name': this.unicodeArrayRotateFunctionName
- },
- 'arguments': [
- {
- 'type': 'Identifier',
- 'name': this.unicodeArrayName
- },
- {
- 'type': 'Literal',
- 'value': this.unicodeArrayRotateValue,
- 'raw': `'${this.unicodeArrayRotateValue}'`
- },
- {
- 'type': 'Literal',
- 'value': true,
- 'raw': 'true'
- }
- ]
- }
- };
- }
- }
- exports.UnicodeArrayRotateFunctionCallNode = UnicodeArrayRotateFunctionCallNode;
|