BatchAssignment 批量赋值语句
1. 结构声明
- TS Declaration
- JSON Schema
class BatchAssignment extends LogicItem {
left: SelectMembers;
rights: Array<SelectMembers>;
assignmentLines: Array<AssignmentLine>;
autoConnection: boolean = true;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"left": {
"$ref": "#/definitions/SelectMembers"
},
"rights": {
"type": "array",
"items": {
"$ref": "#/definitions/SelectMembers"
}
},
"assignmentLines": {
"type": "array",
"items": {
"$ref": "#/definitions/AssignmentLine"
}
},
"autoConnection": {
"type": "boolean"
}
},
"required": [
"left",
"rights",
"assignmentLines",
"autoConnection"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "BatchAssignment",
"label": "批量赋值",
"left": {
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"members": [
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "accepted"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "executed"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "fullAccepted"
}
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "success"
}
}
]
},
"rights": [
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "52f1329c82414b9a8c320815cf703425",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "executedList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "aabee80d05b94a64ab797bae0f11aa85",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "successList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "a274f5173af049feaee53c1b968c17c1",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "acceptedList"
}
}
]
},
"members": []
},
{
"concept": "SelectMembers",
"hideMembers": false,
"expression": {
"uuid": "6ac10af536c446acbc7179b4f525d3d6",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "app.logics",
"calleeName": "computeRatio",
"handleError": false,
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "fullAcceptedList"
}
}
]
},
"members": []
}
],
"assignmentLines": [
{
"concept": "AssignmentLine",
"leftIndex": [
0,
2
],
"rightIndex": [
3
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
0
],
"rightIndex": [
2
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
3
],
"rightIndex": [
1
]
},
{
"concept": "AssignmentLine",
"leftIndex": [
0,
1
],
"rightIndex": [
0
]
}
],
"autoConnection": true
}
concept: BatchAssignment
label: 批量赋值
left:
concept: SelectMembers
hideMembers: false
expression:
concept: Identifier
namespace: ""
name: result
members:
- concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: result
property:
concept: Identifier
namespace: ""
name: accepted
- concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: result
property:
concept: Identifier
namespace: ""
name: executed
- concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: result
property:
concept: Identifier
namespace: ""
name: fullAccepted
- concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: result
property:
concept: Identifier
namespace: ""
name: success
rights:
- concept: SelectMembers
hideMembers: false
expression:
uuid: 52f1329c82414b9a8c320815cf703425
concept: CallLogic
label: 调用逻辑
calleeNamespace: app.logics
calleeName: computeRatio
handleError: false
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: executedList
members: []
- concept: SelectMembers
hideMembers: false
expression:
uuid: aabee80d05b94a64ab797bae0f11aa85
concept: CallLogic
label: 调用逻辑
calleeNamespace: app.logics
calleeName: computeRatio
handleError: false
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: successList
members: []
- concept: SelectMembers
hideMembers: false
expression:
uuid: a274f5173af049feaee53c1b968c17c1
concept: CallLogic
label: 调用逻辑
calleeNamespace: app.logics
calleeName: computeRatio
handleError: false
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: acceptedList
members: []
- concept: SelectMembers
hideMembers: false
expression:
uuid: 6ac10af536c446acbc7179b4f525d3d6
concept: CallLogic
label: 调用逻辑
calleeNamespace: app.logics
calleeName: computeRatio
handleError: false
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: fullAcceptedList
members: []
assignmentLines:
- concept: AssignmentLine
leftIndex:
- 0
- 2
rightIndex:
- 3
- concept: AssignmentLine
leftIndex:
- 0
- 0
rightIndex:
- 2
- concept: AssignmentLine
leftIndex:
- 0
- 3
rightIndex:
- 1
- concept: AssignmentLine
leftIndex:
- 0
- 1
rightIndex:
- 0
autoConnection: true
对应的代码如下:
- 文本化 NASL
{
result.fullAccepted = app::logics::computeRatio(fullAcceptedList);
result.accepted = app::logics::computeRatio(acceptedList);
result.success = app::logics::computeRatio(successList);
result.executed = app::logics::computeRatio(executedList);
}