Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Created April 7, 2015 21:16
Show Gist options
  • Save aslushnikov/9ca6fb227e2f142e866d to your computer and use it in GitHub Desktop.
Save aslushnikov/9ca6fb227e2f142e866d to your computer and use it in GitHub Desktop.
V8 AST example 4
var a = 10, b = 20, c = a + b;
{
"type": "FunctionLiteral",
"position": 0,
"declarations": [
{
"type": "VariableDeclaration",
"position": 0,
"proxy": {
"type": "VariableProxy",
"position": 4
}
},
{
"type": "VariableDeclaration",
"position": 0,
"proxy": {
"type": "VariableProxy",
"position": 12
}
},
{
"type": "VariableDeclaration",
"position": 0,
"proxy": {
"type": "VariableProxy",
"position": 20
}
}
],
"body": [
{
"type": "Block",
"position": 0,
"statements": [
{
"type": "ExpressionStatement",
"position": -1,
"expression": {
"type": "CallRuntime",
"position": 6,
"arguments": [
{
"type": "Literal",
"position": 6
},
{
"type": "Literal",
"position": 6
},
{
"type": "Literal",
"position": 8
}
]
}
},
{
"type": "ExpressionStatement",
"position": -1,
"expression": {
"type": "CallRuntime",
"position": 14,
"arguments": [
{
"type": "Literal",
"position": 14
},
{
"type": "Literal",
"position": 14
},
{
"type": "Literal",
"position": 16
}
]
}
},
{
"type": "ExpressionStatement",
"position": -1,
"expression": {
"type": "CallRuntime",
"position": 22,
"arguments": [
{
"type": "Literal",
"position": 22
},
{
"type": "Literal",
"position": 22
},
{
"type": "BinaryOperation",
"position": 26,
"left": {
"type": "VariableProxy",
"position": 24
},
"right": {
"type": "VariableProxy",
"position": 28
}
}
]
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment