Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Last active August 29, 2015 14:18
Show Gist options
  • Save aslushnikov/9e01c42b1cf85d8cdc73 to your computer and use it in GitHub Desktop.
Save aslushnikov/9e01c42b1cf85d8cdc73 to your computer and use it in GitHub Desktop.
V8 AST example 1
for (var i = 0; i < 10; ++i) {} var b = 0;
{
"type": "FunctionLiteral",
"position": 0,
"declarations": [
{
"type": "VariableDeclaration",
"position": 5,
"proxy": {
"type": "VariableProxy",
"position": 9
}
},
{
"type": "VariableDeclaration",
"position": 32,
"proxy": {
"type": "VariableProxy",
"position": 36
}
}
],
"body": [
{
"type": "ForStatement",
"position": 0,
"init": {
"type": "Block",
"position": 5,
"statements": [
{
"type": "ExpressionStatement",
"position": -1,
"expression": {
"type": "Assignment",
"position": 11,
"target": {
"type": "VariableProxy",
"position": -1
},
"value": {
"type": "Literal",
"position": 13
}
}
}
]
},
"cond": {
"type": "CompareOperation",
"position": 18,
"left": {
"type": "VariableProxy",
"position": 16
},
"right": {
"type": "Literal",
"position": 20
}
},
"next": {
"type": "ExpressionStatement",
"position": 22,
"expression": {
"type": "CountOperation",
"position": 26,
"expression": {
"type": "VariableProxy",
"position": 26
}
}
},
"body": {
"type": "Block",
"position": -1,
"statements": []
}
},
{
"type": "Block",
"position": 32,
"statements": [
{
"type": "ExpressionStatement",
"position": -1,
"expression": {
"type": "CallRuntime",
"position": 38,
"arguments": [
{
"type": "Literal",
"position": 38
},
{
"type": "Literal",
"position": 38
},
{
"type": "Literal",
"position": 40
}
]
}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment