AnonymousFunction 匿名函数
1. 结构声明
- TS Declaration
- JSON Schema
class AnonymousFunction extends LogicItem {
params: Array<Param>;
body: LogicItem;
typeAnnotation?: TypeAnnotation;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/Param"
}
},
"body": {
"$ref": "#/definitions/LogicItem"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
}
},
"required": [
"params",
"body"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "AnonymousFunction",
"params": [
{
"concept": "Param",
"name": "item",
"description": ""
}
],
"body": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "item"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "productReport"
}
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "executed"
}
},
"right": {
"concept": "NullLiteral"
},
"operator": "!="
}
}
concept: AnonymousFunction
params:
- concept: Param
name: item
description: ""
body:
concept: BinaryExpression
left:
concept: MemberExpression
object:
concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: item
property:
concept: Identifier
namespace: ""
name: productReport
property:
concept: Identifier
namespace: ""
name: executed
right:
concept: NullLiteral
operator: "!="
对应的代码如下:
- 文本化 NASL
{ item: String => item.productReport.executed != null }