CallLogic 调用逻辑
1. 结构声明
- TS Declaration
- JSON Schema
class CallLogic extends LogicItem {
uuid?: uuid = createUUID();
calleeNamespace: string;
calleeName: string;
shortcut?: boolean;
handleError?: boolean;
typeArguments?: Array<TypeAnnotation>;
arguments: Array<Argument>;
validation?: BindAttribute;
isAdvancedSettingFolded?: boolean;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
},
"uuid": {
"$ref": "#/definitions/uuid"
},
"calleeNamespace": {
"type": "string"
},
"calleeName": {
"type": "string"
},
"shortcut": {
"type": "boolean"
},
"handleError": {
"type": "boolean"
},
"typeArguments": {
"type": "array",
"items": {
"$ref": "#/definitions/TypeAnnotation"
}
},
"arguments": {
"type": "array",
"items": {
"$ref": "#/definitions/Argument"
}
},
"validation": {
"$ref": "#/definitions/BindAttribute"
},
"isAdvancedSettingFolded": {
"type": "boolean"
}
},
"required": [
"calleeNamespace",
"calleeName",
"arguments"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"uuid": "43a14fc183ed4b1bab03a839ea7fce9f",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "elements.saveModal_1.logics",
"calleeName": "open",
"arguments": []
}
uuid: 43a14fc183ed4b1bab03a839ea7fce9f
concept: CallLogic
label: 调用逻辑
calleeNamespace: elements.saveModal_1.logics
calleeName: open
arguments: []
对应的代码如下:
- 文本化 NASL
- Natural TS
$refs::saveModal_1::open()
$refs.saveModal_1.open()
(2) 带 shortcut
AST 如下:
- JSON
- YAML
{
"uuid": "d5ab84861fa64b5f928b655182c9a19d",
"concept": "CallLogic",
"label": "输出日志",
"calleeNamespace": "nasl.logging",
"calleeName": "INFO",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "模板",
"expression": {
"concept": "StringInterpolation",
"expressions": [
{
"concept": "StringLiteral",
"value": "count: "
},
{
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "ListSum",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
}
]
},
{
"concept": "StringLiteral",
"value": ", length: "
},
{
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
}
]
}
}
]
}
uuid: d5ab84861fa64b5f928b655182c9a19d
concept: CallLogic
label: 输出日志
calleeNamespace: nasl.logging
calleeName: INFO
shortcut: true
arguments:
- concept: Argument
keyword: 模板
expression:
concept: StringInterpolation
expressions:
- concept: StringLiteral
value: "count: "
- concept: CallFunction
label: 内置函数
calleeNamespace: nasl.util
calleeName: ListSum
typeArguments: []
arguments:
- concept: Argument
keyword: list
expression:
concept: Identifier
namespace: ""
name: list
- concept: StringLiteral
value: ", length: "
- concept: MemberExpression
object:
concept: Identifier
namespace: ""
name: list
property:
concept: Identifier
namespace: ""
name: length
对应的代码如下:
- 文本化 NASL
- Natural TS
nasl::logging::INFO(s"count: \$\{nasl::util::ListSum(list)}, length: \$\{list.length}")
nasl.logging.INFO(\`count: \$\{nasl.util.ListSum(list)}, length: \$\{list.length}\`)