WhileStatement While 循环分支
1. 结构声明
- TS Declaration
- JSON Schema
class WhileStatement extends LogicItem {
test: LogicItem;
body: Array<LogicItem>;
}
{
"type": "object",
"properties": {
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"test": {
"$ref": "#/definitions/LogicItem"
},
"body": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
}
},
"required": [
"test",
"body"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "WhileStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"operator": ">",
"right": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
},
"body": [
{
"concept": "CallFunction",
"calleeNamespace": "nasl.util",
"calleeName": "RemoveAt",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
},
{
"concept": "Argument",
"keyword": "index",
"expression": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
}
]
}
]
}
concept: WhileStatement
test:
concept: BinaryExpression
left:
concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: list
property:
concept: Identifier
namespace: ""
name: length
operator: ">"
right:
concept: NumericLiteral
value: "0"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
body:
- concept: CallFunction
calleeNamespace: nasl.util
calleeName: RemoveAt
typeArguments: []
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: list
- concept: Argument
keyword: index
expression:
concept: NumericLiteral
value: "0"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}