Skip to main content
Version: 3.4

IfStatement 条件分支

1. 结构声明

class IfStatement extends LogicItem {
test: LogicItem;
consequent: Array<LogicItem>;
alternate: Array<LogicItem>;
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "IfStatement",
"test": {
"concept": "BinaryExpression",
"left": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"right": {
"concept": "NumericLiteral",
"value": "0",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
"operator": "=="
},
"consequent": [
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"right": {
"concept": "NullLiteral"
}
}
],
"alternate": [
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "result"
},
"right": {
"concept": "BinaryExpression",
"left": {
"concept": "CallFunction",
"label": "内置函数",
"calleeNamespace": "nasl.util",
"calleeName": "ListSum",
"typeArguments": [],
"arguments": [
{
"concept": "Argument",
"keyword": "list",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "list"
}
}
]
},
"right": {
"concept": "MemberExpression",
"object": {
"concept": "Identifier",
"namespace": "",
"name": "list"
},
"property": {
"concept": "Identifier",
"namespace": "",
"name": "length"
}
},
"operator": "/"
}
}
]
}