Slide 45
Slide 45 text
45
const ast = {
properties: [
{},
{ test: 2, consequent: 3, alternate: 0 },
{ name: "condition" },
{ body: [4] },
{ expression: 5 }
],
nodes: [ // ノードを type, child, next, parentのみを持つようにして形状を統一
{ type: "", child: 0, next: 0, parent: 0 },
{ type: "IfStatement", child: 2, next: 0, parent: 0 },
{ type: "Identifier", child: 0, next: 3, parent: 1 },
{ type: "BlockStatement", child: 4, next: 0, parent: 1 },
{ type: "ExpressionStatement", child: 5, next: 0, parent: 3 },
{ type: "CallExpression", child: 0, next: 0, parent: 4 }
]};
プロパティの分離