@lcap/nasl 2.18.0-beta.4 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/concepts/MatchExpression__.d.ts +97 -0
- package/out/concepts/MatchExpression__.js +281 -0
- package/out/concepts/MatchExpression__.js.map +1 -0
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/server/naslServer.js +27 -31
- package/out/server/naslServer.js.map +1 -1
- package/out/templator/sql-parser/index.d.ts +1 -0
- package/out/templator/sql-parser/index.js +228 -0
- package/out/templator/sql-parser/index.js.map +1 -0
- package/out/templator/sql-parser/parser.js +26664 -0
- package/out/templator/sql-parser/parser.js.map +1 -0
- package/package.json +2 -2
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/Param__.ts +1 -1
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/dist/Anchor__.js +179 -0
- package/src/concepts/dist/Assignment__.js +301 -0
- package/src/concepts/dist/CallFunction__.js +473 -0
- package/src/concepts/dist/CallInterface__.js +533 -0
- package/src/concepts/dist/CallLogic__.js +864 -0
- package/src/concepts/dist/ForEachStatement__.js +426 -0
- package/src/concepts/dist/MatchCase__.js +587 -0
- package/src/concepts/dist/MemberExpression__.js +348 -0
- package/src/concepts/dist/Param__.js +537 -0
- package/src/concepts/dist/Return__.js +493 -0
- package/src/generator/dist/genBundleFiles.js +414 -0
- package/src/server/dist/formatTsUtils.js +683 -0
- package/src/server/dist/naslServer.js +3396 -0
- package/src/server/naslServer.ts +28 -31
- package/src/service/storage/dist/init.js +541 -0
- package/ts-worker/dist/webpack.config.dev.js +104 -0
- package/ts-worker/lib/dist/tsserver.dev.js +22953 -0
- package/ts-worker/sources/lib/dist/tsserver.dev.js +22912 -0
- package/dist/bundle.js +0 -3962
- package/dist/bundle.js.LICENSE.txt +0 -16
- package/out/generator/release.d.ts +0 -1
- package/out/generator/release.js +0 -51
- package/out/generator/release.js.map +0 -1
package/src/concepts/Param__.ts
CHANGED
package/src/concepts/Return__.ts
CHANGED
|
@@ -292,7 +292,7 @@ export class Return extends BaseNode {
|
|
|
292
292
|
return code;
|
|
293
293
|
}
|
|
294
294
|
isEnum() {
|
|
295
|
-
return this.typeAnnotation?.typeNamespace
|
|
295
|
+
return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
|
|
296
296
|
}
|
|
297
297
|
@withSourceMap()
|
|
298
298
|
toEmbeddedTSInProcess(state?: TranslatorState): string {
|
|
@@ -291,7 +291,7 @@ export class Variable extends BaseNode {
|
|
|
291
291
|
return code;
|
|
292
292
|
}
|
|
293
293
|
isEnum() {
|
|
294
|
-
return this.typeAnnotation?.typeNamespace
|
|
294
|
+
return this.typeAnnotation?.typeNamespace?.endsWith('.enums');
|
|
295
295
|
}
|
|
296
296
|
getNamespace() {
|
|
297
297
|
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.reference2TypeAnnotationList = void 0;
|
|
4
|
+
var Structure__1 = require("../../Structure__");
|
|
5
|
+
var TypeAnnotation__1 = require("../../TypeAnnotation__");
|
|
6
|
+
function reference2TypeAnnotationList(list, namespace) {
|
|
7
|
+
if (list === void 0) { list = []; }
|
|
8
|
+
return list.map(function (item) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (item instanceof Structure__1["default"] && ((_a = item.typeParams) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
11
|
+
return TypeAnnotation__1["default"].createReference(item.name, {
|
|
12
|
+
typeKind: 'generic',
|
|
13
|
+
typeNamespace: namespace,
|
|
14
|
+
typeArguments: item.typeParams.map(function (typeParam) { return new TypeAnnotation__1["default"]({ name: typeParam.name }); })
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return TypeAnnotation__1["default"].createReference(item.name, {
|
|
19
|
+
typeNamespace: namespace
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.reference2TypeAnnotationList = reference2TypeAnnotationList;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
exports.__esModule = true;
|
|
33
|
+
exports.Anchor = void 0;
|
|
34
|
+
var translator_1 = require("../translator");
|
|
35
|
+
var decorators_1 = require("../decorators");
|
|
36
|
+
var utils = require("../utils");
|
|
37
|
+
var classMap_1 = require("../common/classMap");
|
|
38
|
+
var LogicItem__1 = require("./LogicItem__");
|
|
39
|
+
/**
|
|
40
|
+
* 锚点参数
|
|
41
|
+
*/
|
|
42
|
+
var Anchor = /** @class */ (function (_super) {
|
|
43
|
+
__extends(Anchor, _super);
|
|
44
|
+
/**
|
|
45
|
+
* @param source 需要合并的部分参数
|
|
46
|
+
*/
|
|
47
|
+
function Anchor(source) {
|
|
48
|
+
var _this = this;
|
|
49
|
+
source = Object.assign({}, Anchor_1.getDefaultOptions(), source);
|
|
50
|
+
_this = _super.call(this, source) || this;
|
|
51
|
+
/**
|
|
52
|
+
* 产品概念
|
|
53
|
+
*/
|
|
54
|
+
_this.concept = 'Anchor';
|
|
55
|
+
/**
|
|
56
|
+
* 参数值
|
|
57
|
+
*/
|
|
58
|
+
_this.expression = undefined;
|
|
59
|
+
_super.prototype.subConstructor.call(_this, source);
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
Anchor_1 = Anchor;
|
|
63
|
+
Anchor.from = function (source, parentNode, parentKey) {
|
|
64
|
+
return _super.from.call(this, source, parentNode, parentKey);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 设置参数值
|
|
68
|
+
*/
|
|
69
|
+
Anchor.prototype.setExpression = function (expression) {
|
|
70
|
+
expression._delete();
|
|
71
|
+
var relationOptions = { parentNode: this, parentKey: 'expression' };
|
|
72
|
+
Object.assign(expression, relationOptions);
|
|
73
|
+
var object = {
|
|
74
|
+
expression: expression
|
|
75
|
+
};
|
|
76
|
+
this.update(__assign({}, object));
|
|
77
|
+
};
|
|
78
|
+
Anchor.prototype.removeExpression = function (options) {
|
|
79
|
+
var expression;
|
|
80
|
+
if (typeof options === 'string') {
|
|
81
|
+
expression = this.expression;
|
|
82
|
+
if (!expression) {
|
|
83
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
expression = options;
|
|
88
|
+
}
|
|
89
|
+
return expression["delete"]();
|
|
90
|
+
};
|
|
91
|
+
Anchor.prototype.__removeLogicItem = function (logicItem) {
|
|
92
|
+
var parentKey = logicItem.parentKey;
|
|
93
|
+
var params = {
|
|
94
|
+
parentNode: this,
|
|
95
|
+
parentKey: parentKey,
|
|
96
|
+
index: -1,
|
|
97
|
+
object: null,
|
|
98
|
+
oldObject: logicItem
|
|
99
|
+
};
|
|
100
|
+
if (parentKey) {
|
|
101
|
+
params.parentKey = parentKey;
|
|
102
|
+
if (Array.isArray(this[parentKey])) {
|
|
103
|
+
var index = this[parentKey].indexOf(logicItem);
|
|
104
|
+
~index && this[parentKey].splice(index, 1);
|
|
105
|
+
params.index = index;
|
|
106
|
+
}
|
|
107
|
+
else if (this[parentKey] === logicItem) {
|
|
108
|
+
params.index = 0;
|
|
109
|
+
this[parentKey] = undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return params;
|
|
113
|
+
};
|
|
114
|
+
//================================================================================
|
|
115
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
116
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
117
|
+
//================================================================================
|
|
118
|
+
Anchor.prototype.toVue = function (options) {
|
|
119
|
+
return this.expression ? this.expression.toVue(options) : '';
|
|
120
|
+
};
|
|
121
|
+
Anchor.prototype.toUI = function (state) {
|
|
122
|
+
var code = '';
|
|
123
|
+
if (this.expression) {
|
|
124
|
+
code += this.expression.toUI(translator_1.shiftState(state, code));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
code += '';
|
|
128
|
+
}
|
|
129
|
+
return code;
|
|
130
|
+
};
|
|
131
|
+
Anchor.prototype.toJS = function (state) {
|
|
132
|
+
var code = '';
|
|
133
|
+
if (this.expression) {
|
|
134
|
+
code += this.expression.toJS(translator_1.shiftState(state, code));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
code += '';
|
|
138
|
+
}
|
|
139
|
+
return code;
|
|
140
|
+
};
|
|
141
|
+
Anchor.prototype.toBrief = function () {
|
|
142
|
+
var expr = utils.toBriefExpr(this.expression);
|
|
143
|
+
return "<span style=\"color: #AAAAAA\">\u951A\u70B9 = </span><span style=\"color: #FFFFFF\">" + expr + "</span>";
|
|
144
|
+
};
|
|
145
|
+
Anchor.prototype.toEmbeddedTS = function (state, isHaveKeyWord) {
|
|
146
|
+
var code = '';
|
|
147
|
+
if (isHaveKeyWord) {
|
|
148
|
+
code += "_anchor: ";
|
|
149
|
+
}
|
|
150
|
+
if (this.expression) {
|
|
151
|
+
code += this.expression.toEmbeddedTS(translator_1.shiftState(state, code), false);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
code += 'undefined';
|
|
155
|
+
}
|
|
156
|
+
return code;
|
|
157
|
+
};
|
|
158
|
+
var Anchor_1;
|
|
159
|
+
__decorate([
|
|
160
|
+
decorators_1.property()
|
|
161
|
+
], Anchor.prototype, "concept");
|
|
162
|
+
__decorate([
|
|
163
|
+
decorators_1.property('LogicItem')
|
|
164
|
+
], Anchor.prototype, "expression");
|
|
165
|
+
__decorate([
|
|
166
|
+
translator_1.withSourceMap()
|
|
167
|
+
], Anchor.prototype, "toEmbeddedTS");
|
|
168
|
+
Anchor = Anchor_1 = __decorate([
|
|
169
|
+
decorators_1.concept('锚点参数')
|
|
170
|
+
], Anchor);
|
|
171
|
+
return Anchor;
|
|
172
|
+
}(LogicItem__1["default"]));
|
|
173
|
+
exports.Anchor = Anchor;
|
|
174
|
+
classMap_1["default"].Anchor = Anchor;
|
|
175
|
+
exports["default"] = Anchor;
|
|
176
|
+
//================================================================================
|
|
177
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
178
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
179
|
+
//================================================================================
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
};
|
|
32
|
+
exports.__esModule = true;
|
|
33
|
+
exports.Assignment = void 0;
|
|
34
|
+
var translator_1 = require("../translator");
|
|
35
|
+
var Identifier__1 = require("./Identifier__");
|
|
36
|
+
var BatchAssignment__1 = require("./BatchAssignment__");
|
|
37
|
+
var SelectMembers__1 = require("./SelectMembers__");
|
|
38
|
+
var AssignmentLine__1 = require("./AssignmentLine__");
|
|
39
|
+
var decorators_1 = require("../decorators");
|
|
40
|
+
var classMap_1 = require("../common/classMap");
|
|
41
|
+
var LogicItem__1 = require("./LogicItem__");
|
|
42
|
+
/**
|
|
43
|
+
* 赋值语句
|
|
44
|
+
*/
|
|
45
|
+
var Assignment = /** @class */ (function (_super) {
|
|
46
|
+
__extends(Assignment, _super);
|
|
47
|
+
/**
|
|
48
|
+
* @param source 需要合并的部分参数
|
|
49
|
+
*/
|
|
50
|
+
function Assignment(source) {
|
|
51
|
+
var _this = this;
|
|
52
|
+
source = Object.assign({}, Assignment_1.getDefaultOptions(), source);
|
|
53
|
+
_this = _super.call(this, source) || this;
|
|
54
|
+
/**
|
|
55
|
+
* 产品概念
|
|
56
|
+
*/
|
|
57
|
+
_this.concept = 'Assignment';
|
|
58
|
+
/**
|
|
59
|
+
* 赋值语句标题
|
|
60
|
+
*/
|
|
61
|
+
_this.label = '赋值';
|
|
62
|
+
/**
|
|
63
|
+
* 左边项
|
|
64
|
+
*/
|
|
65
|
+
_this.left = undefined;
|
|
66
|
+
/**
|
|
67
|
+
* 右边项
|
|
68
|
+
*/
|
|
69
|
+
_this.right = undefined;
|
|
70
|
+
_super.prototype.subConstructor.call(_this, source);
|
|
71
|
+
return _this;
|
|
72
|
+
}
|
|
73
|
+
Assignment_1 = Assignment;
|
|
74
|
+
Assignment.from = function (source, parentNode, parentKey) {
|
|
75
|
+
return _super.from.call(this, source, parentNode, parentKey);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 设置左边项
|
|
79
|
+
*/
|
|
80
|
+
Assignment.prototype.setLeft = function (left) {
|
|
81
|
+
left._delete();
|
|
82
|
+
var relationOptions = { parentNode: this, parentKey: 'left' };
|
|
83
|
+
Object.assign(left, relationOptions);
|
|
84
|
+
var object = {
|
|
85
|
+
left: left
|
|
86
|
+
};
|
|
87
|
+
this.update(__assign({}, object));
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 设置右边项
|
|
91
|
+
*/
|
|
92
|
+
Assignment.prototype.setRight = function (right) {
|
|
93
|
+
right._delete();
|
|
94
|
+
var relationOptions = { parentNode: this, parentKey: 'right' };
|
|
95
|
+
Object.assign(right, relationOptions);
|
|
96
|
+
var object = {
|
|
97
|
+
right: right
|
|
98
|
+
};
|
|
99
|
+
this.update(__assign({}, object));
|
|
100
|
+
};
|
|
101
|
+
Assignment.prototype.removeLeft = function (options) {
|
|
102
|
+
var left;
|
|
103
|
+
if (typeof options === 'string') {
|
|
104
|
+
left = this.left;
|
|
105
|
+
if (!left) {
|
|
106
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
left = options;
|
|
111
|
+
}
|
|
112
|
+
return left["delete"]();
|
|
113
|
+
};
|
|
114
|
+
Assignment.prototype.removeRight = function (options) {
|
|
115
|
+
var right;
|
|
116
|
+
if (typeof options === 'string') {
|
|
117
|
+
right = this.right;
|
|
118
|
+
if (!right) {
|
|
119
|
+
throw new Error('找不到逻辑项 ' + options);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
right = options;
|
|
124
|
+
}
|
|
125
|
+
return right["delete"]();
|
|
126
|
+
};
|
|
127
|
+
Assignment.prototype.__removeLogicItem = function (logicItem) {
|
|
128
|
+
var parentKey = logicItem.parentKey;
|
|
129
|
+
var params = {
|
|
130
|
+
parentNode: this,
|
|
131
|
+
parentKey: parentKey,
|
|
132
|
+
index: -1,
|
|
133
|
+
object: null,
|
|
134
|
+
oldObject: logicItem
|
|
135
|
+
};
|
|
136
|
+
if (parentKey) {
|
|
137
|
+
params.parentKey = parentKey;
|
|
138
|
+
if (Array.isArray(this[parentKey])) {
|
|
139
|
+
var index = this[parentKey].indexOf(logicItem);
|
|
140
|
+
~index && this[parentKey].splice(index, 1);
|
|
141
|
+
params.index = index;
|
|
142
|
+
}
|
|
143
|
+
else if (this[parentKey] === logicItem) {
|
|
144
|
+
params.index = 0;
|
|
145
|
+
this[parentKey] = undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return params;
|
|
149
|
+
};
|
|
150
|
+
//================================================================================
|
|
151
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
152
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
153
|
+
//================================================================================
|
|
154
|
+
Assignment.getDefaultOptions = function () {
|
|
155
|
+
return {
|
|
156
|
+
left: {
|
|
157
|
+
concept: 'Identifier',
|
|
158
|
+
name: ''
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
Assignment.prototype.replaceBatchAssignment = function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
var _a = this, parentKey = _a.parentKey, parentNode = _a.parentNode, logic = _a.logic;
|
|
165
|
+
var index;
|
|
166
|
+
var leftMembers = [];
|
|
167
|
+
// 左边变量变换
|
|
168
|
+
var leftObject = Object.assign({}, this.left);
|
|
169
|
+
if (leftObject.concept === 'MemberExpression') {
|
|
170
|
+
while (leftObject.object) {
|
|
171
|
+
leftMembers.unshift(leftObject);
|
|
172
|
+
leftObject = Object.assign({}, leftObject.object);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// 右边变量变换
|
|
176
|
+
var rightMembers = [];
|
|
177
|
+
var rightObject = Object.assign({}, this.right);
|
|
178
|
+
if (rightObject.concept === 'MemberExpression') {
|
|
179
|
+
while (rightObject.object) {
|
|
180
|
+
rightMembers.unshift(rightObject);
|
|
181
|
+
rightObject = Object.assign({}, rightObject.object);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// 自动连线
|
|
185
|
+
var leftIndex = leftMembers.length ? [0, leftMembers.length - 1] : [0];
|
|
186
|
+
var rightIndex = rightMembers.length ? [0, rightMembers.length - 1] : [0];
|
|
187
|
+
// 切换成批量赋值
|
|
188
|
+
var leftSelect = new SelectMembers__1["default"]({
|
|
189
|
+
expression: leftObject,
|
|
190
|
+
members: leftMembers
|
|
191
|
+
});
|
|
192
|
+
var rightSelect = new SelectMembers__1["default"]({
|
|
193
|
+
expression: rightObject,
|
|
194
|
+
members: rightMembers
|
|
195
|
+
});
|
|
196
|
+
var assignmentLine = new AssignmentLine__1["default"]({
|
|
197
|
+
leftIndex: leftIndex,
|
|
198
|
+
rightIndex: rightIndex
|
|
199
|
+
});
|
|
200
|
+
var batchObject = this.right ? {
|
|
201
|
+
left: leftSelect,
|
|
202
|
+
rights: [rightSelect],
|
|
203
|
+
assignmentLines: [assignmentLine]
|
|
204
|
+
} : {
|
|
205
|
+
left: leftSelect,
|
|
206
|
+
rights: [],
|
|
207
|
+
assignmentLines: []
|
|
208
|
+
};
|
|
209
|
+
var batchAssignment = new BatchAssignment__1["default"](__assign(__assign({}, batchObject), { offsetX: this.offsetX, offsetY: this.offsetY }));
|
|
210
|
+
this.app.emit('collect:start', {
|
|
211
|
+
actionMsg: '普通赋值切换批量赋值'
|
|
212
|
+
});
|
|
213
|
+
if (parentNode.concept === 'Logic') {
|
|
214
|
+
if (parentKey === 'body') {
|
|
215
|
+
index = logic.body.findIndex(function (item) { return item === _this; });
|
|
216
|
+
logic.insertItemInBodyAt(batchAssignment, index);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
index = logic.playground.findIndex(function (item) { return item === _this; });
|
|
220
|
+
logic.insertItemInPlaygroundAt(batchAssignment, index);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
index = parentNode[parentKey].findIndex(function (item) { return item === _this; });
|
|
225
|
+
var firstUpperText = parentKey[0].toUpperCase() + parentKey.slice(1, parentKey.length);
|
|
226
|
+
if (parentNode["insertItemIn" + firstUpperText + "At"])
|
|
227
|
+
parentNode["insertItemIn" + firstUpperText + "At"](batchAssignment, index);
|
|
228
|
+
else
|
|
229
|
+
parentNode.insertItemAt(batchAssignment, index);
|
|
230
|
+
}
|
|
231
|
+
this["delete"]();
|
|
232
|
+
this.app.emit('collect:end');
|
|
233
|
+
return batchAssignment;
|
|
234
|
+
};
|
|
235
|
+
Assignment.prototype.toVue = function (options) {
|
|
236
|
+
var code = '';
|
|
237
|
+
code += this.left ? this.left.toVue(options) : '';
|
|
238
|
+
code += ' = ';
|
|
239
|
+
code += this.right ? this.right.toVue(options) : '';
|
|
240
|
+
code += ';';
|
|
241
|
+
return code;
|
|
242
|
+
};
|
|
243
|
+
Assignment.prototype.toUI = function (state) {
|
|
244
|
+
var code = '';
|
|
245
|
+
code += this.left ? this.left.toUI(translator_1.shiftState(state, code, { inline: true })) : '';
|
|
246
|
+
code += ' = ';
|
|
247
|
+
code += this.right ? this.right.toUI(translator_1.shiftState(state, code, { inline: true })) : '';
|
|
248
|
+
code += ';';
|
|
249
|
+
return code;
|
|
250
|
+
};
|
|
251
|
+
Assignment.prototype.toJS = function (state) {
|
|
252
|
+
var code = '';
|
|
253
|
+
code += this.left ? this.left.toJS(translator_1.shiftState(state, code, { inline: true })) : '';
|
|
254
|
+
if (this.right) {
|
|
255
|
+
code += ' = ';
|
|
256
|
+
code += this.right.toJS(translator_1.shiftState(state, code, {
|
|
257
|
+
inline: true
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
return code;
|
|
261
|
+
};
|
|
262
|
+
Assignment.prototype.toEmbeddedTS = function (state) {
|
|
263
|
+
var code = 'nasl.core.assign(';
|
|
264
|
+
code += this.left ? this.left.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true })) : '__LEFT__';
|
|
265
|
+
code += ',';
|
|
266
|
+
// 因为右侧枚举要赋值就得new 一下;
|
|
267
|
+
if (this.right && this.right instanceof Identifier__1["default"] && this.right.namespace && this.right.namespace.endsWith('enums')) {
|
|
268
|
+
code += 'new ';
|
|
269
|
+
}
|
|
270
|
+
code += (this.right && this.right.toEmbeddedTS) ? this.right.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true })) : '__RIGHT__';
|
|
271
|
+
code += ');';
|
|
272
|
+
return code;
|
|
273
|
+
};
|
|
274
|
+
var Assignment_1;
|
|
275
|
+
__decorate([
|
|
276
|
+
decorators_1.property()
|
|
277
|
+
], Assignment.prototype, "concept");
|
|
278
|
+
__decorate([
|
|
279
|
+
decorators_1.property()
|
|
280
|
+
], Assignment.prototype, "label");
|
|
281
|
+
__decorate([
|
|
282
|
+
decorators_1.property('LogicItem')
|
|
283
|
+
], Assignment.prototype, "left");
|
|
284
|
+
__decorate([
|
|
285
|
+
decorators_1.property('LogicItem')
|
|
286
|
+
], Assignment.prototype, "right");
|
|
287
|
+
__decorate([
|
|
288
|
+
translator_1.withSourceMap()
|
|
289
|
+
], Assignment.prototype, "toEmbeddedTS");
|
|
290
|
+
Assignment = Assignment_1 = __decorate([
|
|
291
|
+
decorators_1.concept('赋值语句')
|
|
292
|
+
], Assignment);
|
|
293
|
+
return Assignment;
|
|
294
|
+
}(LogicItem__1["default"]));
|
|
295
|
+
exports.Assignment = Assignment;
|
|
296
|
+
classMap_1["default"].Assignment = Assignment;
|
|
297
|
+
exports["default"] = Assignment;
|
|
298
|
+
//================================================================================
|
|
299
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
300
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
301
|
+
//================================================================================
|