NewMap Map 构造器
1. 结构声明
- TS Declaration
- JSON Schema
class NewMap extends LogicItem {
keys: Array<LogicItem>;
values: Array<LogicItem>;
}
{
"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"
},
"keys": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
},
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/LogicItem"
}
}
},
"required": [
"keys",
"values"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "NewMap",
"keys": [
{
"concept": "NumericLiteral",
"value": "1",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "NumericLiteral",
"value": "2",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
},
{
"concept": "NumericLiteral",
"value": "3",
"typeAnnotation": {
"concept": "TypeAnnotation",
"typeKind": "primitive",
"typeNamespace": "nasl.core",
"typeName": "Long",
"inferred": false,
"ruleMap": {}
}
}
],
"values": [
{
"concept": "StringLiteral",
"value": "选项1"
},
{
"concept": "StringLiteral",
"value": "选项2"
},
{
"concept": "StringLiteral",
"value": "选项3"
}
]
}
concept: NewMap
keys:
- concept: NumericLiteral
value: "1"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
- concept: NumericLiteral
value: "2"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
- concept: NumericLiteral
value: "3"
typeAnnotation:
concept: TypeAnnotation
typeKind: primitive
typeNamespace: nasl.core
typeName: Long
inferred: false
ruleMap: {}
values:
- concept: StringLiteral
value: 选项1
- concept: StringLiteral
value: 选项2
- concept: StringLiteral
value: 选项3
对应的代码如下:
- 文本化 NASL
- Natural TS
[1 -> '选项1', 2 -> '选项2', 3 -> '选项3']
nasl.util.NewMap<__IDENTIFIER__>({ 1: '选项1', 2: '选项2', 3: '选项3' })