Files
modeling-app/src/wasm-lib/kcl/tests/cube/program_memory.snap
Adam Chalmers 9e57034873 AST: Allow KCL fn params to have defaults and labels (#4676)
Pure refactor, should not change any behaviour.

Previously, optional parameters in KCL function calls always set the parameter to KclNone. 

As of this PR, they can be set to KCL literals in addition to KCL none. However the parser does not actually ever use this (that'll be in a follow-up PR).

Also adds a `labeled: bool` to all parameters, which is always true. But it lays the groundwork for the unlabeled first parameter in a follow-up PR.
2024-12-06 03:04:40 +00:00

973 lines
32 KiB
Plaintext

---
source: kcl/src/simulation_tests.rs
description: Program memory after executing cube.kcl
snapshot_kind: text
---
{
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
},
"cube": {
"type": "Function",
"expression": {
"body": {
"body": [
{
"declarations": [
{
"end": 42,
"id": {
"end": 29,
"name": "l",
"start": 28,
"type": "Identifier"
},
"init": {
"end": 42,
"left": {
"end": 38,
"name": "length",
"start": 32,
"type": "Identifier",
"type": "Identifier"
},
"operator": "/",
"right": {
"end": 42,
"raw": "2",
"start": 41,
"type": "Literal",
"type": "Literal",
"value": 2.0
},
"start": 32,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
"start": 28,
"type": "VariableDeclarator"
}
],
"end": 42,
"kind": "const",
"start": 28,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 58,
"id": {
"end": 46,
"name": "x",
"start": 45,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 58,
"object": {
"end": 55,
"name": "center",
"start": 49,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 57,
"raw": "0",
"start": 56,
"type": "Literal",
"type": "Literal",
"value": 0.0
},
"start": 49,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 45,
"type": "VariableDeclarator"
}
],
"end": 58,
"kind": "const",
"start": 45,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 74,
"id": {
"end": 62,
"name": "y",
"start": 61,
"type": "Identifier"
},
"init": {
"computed": false,
"end": 74,
"object": {
"end": 71,
"name": "center",
"start": 65,
"type": "Identifier",
"type": "Identifier"
},
"property": {
"end": 73,
"raw": "1",
"start": 72,
"type": "Literal",
"type": "Literal",
"value": 1.0
},
"start": 65,
"type": "MemberExpression",
"type": "MemberExpression"
},
"start": 61,
"type": "VariableDeclarator"
}
],
"end": 74,
"kind": "const",
"start": 61,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 98,
"id": {
"end": 79,
"name": "p0",
"start": 77,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 89,
"left": {
"argument": {
"end": 85,
"name": "l",
"start": 84,
"type": "Identifier",
"type": "Identifier"
},
"end": 85,
"operator": "-",
"start": 83,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
"operator": "+",
"right": {
"end": 89,
"name": "x",
"start": 88,
"type": "Identifier",
"type": "Identifier"
},
"start": 83,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"end": 97,
"left": {
"argument": {
"end": 93,
"name": "l",
"start": 92,
"type": "Identifier",
"type": "Identifier"
},
"end": 93,
"operator": "-",
"start": 91,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
"operator": "+",
"right": {
"end": 97,
"name": "y",
"start": 96,
"type": "Identifier",
"type": "Identifier"
},
"start": 91,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 98,
"start": 82,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 77,
"type": "VariableDeclarator"
}
],
"end": 98,
"kind": "const",
"start": 77,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 121,
"id": {
"end": 103,
"name": "p1",
"start": 101,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 113,
"left": {
"argument": {
"end": 109,
"name": "l",
"start": 108,
"type": "Identifier",
"type": "Identifier"
},
"end": 109,
"operator": "-",
"start": 107,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
"operator": "+",
"right": {
"end": 113,
"name": "x",
"start": 112,
"type": "Identifier",
"type": "Identifier"
},
"start": 107,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"end": 120,
"left": {
"end": 116,
"name": "l",
"start": 115,
"type": "Identifier",
"type": "Identifier"
},
"operator": "+",
"right": {
"end": 120,
"name": "y",
"start": 119,
"type": "Identifier",
"type": "Identifier"
},
"start": 115,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 121,
"start": 106,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 101,
"type": "VariableDeclarator"
}
],
"end": 121,
"kind": "const",
"start": 101,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 143,
"id": {
"end": 126,
"name": "p2",
"start": 124,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 135,
"left": {
"end": 131,
"name": "l",
"start": 130,
"type": "Identifier",
"type": "Identifier"
},
"operator": "+",
"right": {
"end": 135,
"name": "x",
"start": 134,
"type": "Identifier",
"type": "Identifier"
},
"start": 130,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"end": 142,
"left": {
"end": 138,
"name": "l",
"start": 137,
"type": "Identifier",
"type": "Identifier"
},
"operator": "+",
"right": {
"end": 142,
"name": "y",
"start": 141,
"type": "Identifier",
"type": "Identifier"
},
"start": 137,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 143,
"start": 129,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 124,
"type": "VariableDeclarator"
}
],
"end": 143,
"kind": "const",
"start": 124,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"declarations": [
{
"end": 166,
"id": {
"end": 148,
"name": "p3",
"start": 146,
"type": "Identifier"
},
"init": {
"elements": [
{
"end": 157,
"left": {
"end": 153,
"name": "l",
"start": 152,
"type": "Identifier",
"type": "Identifier"
},
"operator": "+",
"right": {
"end": 157,
"name": "x",
"start": 156,
"type": "Identifier",
"type": "Identifier"
},
"start": 152,
"type": "BinaryExpression",
"type": "BinaryExpression"
},
{
"end": 165,
"left": {
"argument": {
"end": 161,
"name": "l",
"start": 160,
"type": "Identifier",
"type": "Identifier"
},
"end": 161,
"operator": "-",
"start": 159,
"type": "UnaryExpression",
"type": "UnaryExpression"
},
"operator": "+",
"right": {
"end": 165,
"name": "y",
"start": 164,
"type": "Identifier",
"type": "Identifier"
},
"start": 159,
"type": "BinaryExpression",
"type": "BinaryExpression"
}
],
"end": 166,
"start": 151,
"type": "ArrayExpression",
"type": "ArrayExpression"
},
"start": 146,
"type": "VariableDeclarator"
}
],
"end": 166,
"kind": "const",
"start": 146,
"type": "VariableDeclaration",
"type": "VariableDeclaration"
},
{
"argument": {
"body": [
{
"arguments": [
{
"end": 193,
"name": "p0",
"start": 191,
"type": "Identifier",
"type": "Identifier"
}
],
"callee": {
"end": 190,
"name": "startSketchAt",
"start": 177,
"type": "Identifier"
},
"end": 194,
"start": 177,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 211,
"name": "p1",
"start": 209,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 214,
"start": 213,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 208,
"name": "lineTo",
"start": 202,
"type": "Identifier"
},
"end": 215,
"start": 202,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 232,
"name": "p2",
"start": 230,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 235,
"start": 234,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 229,
"name": "lineTo",
"start": 223,
"type": "Identifier"
},
"end": 236,
"start": 223,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 253,
"name": "p3",
"start": 251,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 256,
"start": 255,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 250,
"name": "lineTo",
"start": 244,
"type": "Identifier"
},
"end": 257,
"start": 244,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 274,
"name": "p0",
"start": 272,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 277,
"start": 276,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 271,
"name": "lineTo",
"start": 265,
"type": "Identifier"
},
"end": 278,
"start": 265,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 293,
"start": 292,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 291,
"name": "close",
"start": 286,
"type": "Identifier"
},
"end": 294,
"start": 286,
"type": "CallExpression",
"type": "CallExpression"
},
{
"arguments": [
{
"end": 316,
"name": "length",
"start": 310,
"type": "Identifier",
"type": "Identifier"
},
{
"end": 319,
"start": 318,
"type": "PipeSubstitution",
"type": "PipeSubstitution"
}
],
"callee": {
"end": 309,
"name": "extrude",
"start": 302,
"type": "Identifier"
},
"end": 320,
"start": 302,
"type": "CallExpression",
"type": "CallExpression"
}
],
"end": 320,
"start": 177,
"type": "PipeExpression",
"type": "PipeExpression"
},
"end": 320,
"start": 170,
"type": "ReturnStatement",
"type": "ReturnStatement"
}
],
"end": 322,
"nonCodeMeta": {
"nonCodeNodes": {
"6": [
{
"end": 170,
"start": 166,
"type": "NonCodeNode",
"value": {
"type": "newLine"
}
}
]
},
"startNodes": []
},
"start": 24
},
"end": 322,
"params": [
{
"type": "Parameter",
"identifier": {
"end": 14,
"name": "length",
"start": 8,
"type": "Identifier"
}
},
{
"type": "Parameter",
"identifier": {
"end": 22,
"name": "center",
"start": 16,
"type": "Identifier"
}
}
],
"start": 7,
"type": "FunctionExpression"
},
"memory": {
"environments": [
{
"bindings": {
"HALF_TURN": {
"type": "Number",
"value": 180.0,
"__meta": []
},
"QUARTER_TURN": {
"type": "Number",
"value": 90.0,
"__meta": []
},
"THREE_QUARTER_TURN": {
"type": "Number",
"value": 270.0,
"__meta": []
},
"ZERO": {
"type": "Number",
"value": 0.0,
"__meta": []
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
},
"__meta": [
{
"sourceRange": [
7,
322,
0
]
}
]
},
"myCube": {
"type": "Solid",
"type": "Solid",
"id": "[uuid]",
"value": [
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
202,
215,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
223,
236,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
244,
257,
0
],
"tag": null,
"type": "extrudePlane"
},
{
"faceId": "[uuid]",
"id": "[uuid]",
"sourceRange": [
265,
278,
0
],
"tag": null,
"type": "extrudePlane"
}
],
"sketch": {
"type": "Sketch",
"id": "[uuid]",
"paths": [
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
202,
215,
0
]
},
"from": [
-20.0,
-20.0
],
"tag": null,
"to": [
-20.0,
20.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
223,
236,
0
]
},
"from": [
-20.0,
20.0
],
"tag": null,
"to": [
20.0,
20.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
244,
257,
0
]
},
"from": [
20.0,
20.0
],
"tag": null,
"to": [
20.0,
-20.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
265,
278,
0
]
},
"from": [
20.0,
-20.0
],
"tag": null,
"to": [
-20.0,
-20.0
],
"type": "ToPoint"
},
{
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
286,
294,
0
]
},
"from": [
-20.0,
-20.0
],
"tag": null,
"to": [
-20.0,
-20.0
],
"type": "ToPoint"
}
],
"on": {
"type": "plane",
"id": "[uuid]",
"value": "XY",
"origin": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"xAxis": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"yAxis": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"zAxis": {
"x": 0.0,
"y": 0.0,
"z": 1.0
},
"__meta": []
},
"start": {
"from": [
-20.0,
-20.0
],
"to": [
-20.0,
-20.0
],
"tag": null,
"__geoMeta": {
"id": "[uuid]",
"sourceRange": [
177,
194,
0
]
}
},
"__meta": [
{
"sourceRange": [
177,
194,
0
]
}
]
},
"height": 40.0,
"startCapId": "[uuid]",
"endCapId": "[uuid]",
"__meta": [
{
"sourceRange": [
177,
194,
0
]
}
]
}
},
"parent": null
}
],
"currentEnv": 0,
"return": null
}