Grackle: handle complicated nested computed objects (#1348)

Previously, Grackle could compile a single computed property like `array[x]`. But it couldn't handle:

- Nested properties like `array[x][y]`
- Nested objects like `obj[x][y]`
- Arrays nested in objects, like `{x: [1,2,3]}`
- Objects in arrays like `[{a: 1}]`

It was quite difficult to find a way to handle this, which is why I started the EP Debugger project. The debugger helped me understand the VM much better and figure out a better way to handle these cases (the two new instructions AddrOfMember and CopyLen). Now Grackle can compile those cases!
This commit is contained in:
Adam Chalmers
2024-02-06 22:44:30 +11:00
committed by GitHub
parent a4d3263b88
commit 379c30824e
12 changed files with 370 additions and 245 deletions

View File

@ -498,7 +498,7 @@
}
],
"asset": {
"generator": "kittycad.io",
"generator": "zoo.dev",
"version": "2.0"
},
"buffers": [
@ -882,7 +882,7 @@
"loops": [
[
14,
-1
1
]
]
},
@ -1953,12 +1953,17 @@
{
"type": "plane",
"plane": {
"normal": [
-1,
"xAxis": [
0,
1,
0
],
"point": [
"yAxis": [
0,
0,
-1
],
"origin": [
0,
-0.0127,
0.050800000000000005
@ -1968,12 +1973,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
1,
0,
-1,
-0
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.039310000000000005,
-0.0254,
0.050800000000000005
@ -1983,12 +1993,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
0.81915,
-0.5735800000000001,
-0.81915,
0
],
"point": [
"yAxis": [
0,
0,
1
],
"origin": [
0.11489,
-0.050800000000000005,
0.050800000000000005
@ -1998,12 +2013,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
1,
0,
-1,
-0
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.19623,
-0.0762,
0.050800000000000005
@ -2013,12 +2033,17 @@
{
"type": "plane",
"plane": {
"normal": [
1,
"xAxis": [
0,
-0
1,
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.2413,
-0.06985000000000001,
0.050800000000000005
@ -2028,12 +2053,17 @@
{
"type": "plane",
"plane": {
"normal": [
0,
"xAxis": [
1,
-0
0,
0
],
"point": [
"yAxis": [
0,
-0,
-1
],
"origin": [
0.19823,
-0.0635,
0.050800000000000005
@ -2043,12 +2073,17 @@
{
"type": "plane",
"plane": {
"normal": [
0.5735800000000001,
"xAxis": [
0.81915,
-0.5735800000000001,
0
],
"point": [
"yAxis": [
0,
0,
-1
],
"origin": [
0.10982,
-0.03175,
0.050800000000000005
@ -2058,12 +2093,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
0.90631,
0.4226200000000001,
-0.90631,
-0
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.10533,
0.01905,
0.050800000000000005
@ -2073,12 +2113,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
1,
0,
-1,
-0
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.19374,
0.0381,
0.050800000000000005
@ -2088,12 +2133,17 @@
{
"type": "plane",
"plane": {
"normal": [
1,
"xAxis": [
0,
-0
1,
0
],
"point": [
"yAxis": [
-0,
0,
1
],
"origin": [
0.2413,
0.04445,
0.050800000000000005
@ -2103,12 +2153,17 @@
{
"type": "plane",
"plane": {
"normal": [
0,
"xAxis": [
1,
-0
0,
0
],
"point": [
"yAxis": [
0,
-0,
-1
],
"origin": [
0.19234,
0.050800000000000005,
0.050800000000000005
@ -2118,12 +2173,17 @@
{
"type": "plane",
"plane": {
"normal": [
-0.4226200000000001,
"xAxis": [
0.90631,
0.4226200000000001,
0
],
"point": [
"yAxis": [
0,
0,
-1
],
"origin": [
0.11614,
0.0381,
0.050800000000000005
@ -2133,12 +2193,17 @@
{
"type": "plane",
"plane": {
"normal": [
0,
"xAxis": [
1,
-0
0,
0
],
"point": [
"yAxis": [
0,
-0,
-1
],
"origin": [
0.04445,
0.0254,
0.050800000000000005
@ -2148,12 +2213,17 @@
{
"type": "plane",
"plane": {
"normal": [
-1,
"xAxis": [
0,
1,
0
],
"point": [
"yAxis": [
0,
0,
-1
],
"origin": [
0,
0.0127,
0.050800000000000005
@ -2163,12 +2233,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
1,
0,
0,
1
0
],
"point": [
"yAxis": [
0,
1,
0
],
"origin": [
0,
0,
0
@ -2178,12 +2253,17 @@
{
"type": "plane",
"plane": {
"normal": [
"xAxis": [
1,
0,
0,
1
-0
],
"point": [
"yAxis": [
-0,
1,
0
],
"origin": [
0,
0,
0.1016
@ -2191,7 +2271,7 @@
}
}
],
"curves": [
"curves3D": [
{
"type": "line",
"line": {

View File

@ -1,7 +1,7 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION((('kittycad.io export')), '2;1');
FILE_NAME('dump.step', '1970-01-01T00:00:00.0+00:00', ('Author unknown'), ('Organization unknown'), 'kittycad.io beta', 'kittycad.io', 'Authorization unknown');
FILE_DESCRIPTION((('zoo.dev export')), '2;1');
FILE_NAME('dump.step', '1970-01-01T00:00:00.0+00:00', ('Author unknown'), ('Organization unknown'), 'zoo.dev beta', 'zoo.dev', 'Authorization unknown');
FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));
ENDSEC;
DATA;
@ -384,23 +384,23 @@ DATA;
#368 = ORIENTED_EDGE('NONE', *, *, #269, .T.);
#369 = EDGE_LOOP('NONE', (#355, #356, #357, #358, #359, #360, #361, #362, #363, #364, #365, #366, #367, #368));
#370 = CARTESIAN_POINT('NONE', (0, -0.0127, 0.0508));
#371 = DIRECTION('NONE', (-1, 0, -0));
#371 = DIRECTION('NONE', (-1, -0, 0));
#372 = AXIS2_PLACEMENT_3D('NONE', #370, #371, $);
#373 = PLANE('NONE', #372);
#374 = CARTESIAN_POINT('NONE', (0.039306734695977924, -0.025399999999999995, 0.0508));
#375 = DIRECTION('NONE', (0, -1, -0));
#375 = DIRECTION('NONE', (0, -1, 0));
#376 = AXIS2_PLACEMENT_3D('NONE', #374, #375, $);
#377 = PLANE('NONE', #376);
#378 = CARTESIAN_POINT('NONE', (0.11488842876320533, -0.05079999999999996, 0.05079999999999999));
#379 = DIRECTION('NONE', (-0.5735764363510459, -0.819152044288992, 0));
#379 = DIRECTION('NONE', (-0.5735764363510459, -0.8191520442889919, 0));
#380 = AXIS2_PLACEMENT_3D('NONE', #378, #379, $);
#381 = PLANE('NONE', #380);
#382 = CARTESIAN_POINT('NONE', (0.19623169406722757, -0.07619999999999999, 0.0508));
#383 = DIRECTION('NONE', (0, -1, -0));
#383 = DIRECTION('NONE', (0, -1, 0));
#384 = AXIS2_PLACEMENT_3D('NONE', #382, #383, $);
#385 = PLANE('NONE', #384);
#386 = CARTESIAN_POINT('NONE', (0.2413, -0.06985, 0.0508));
#387 = DIRECTION('NONE', (1, 0, -0));
#387 = DIRECTION('NONE', (1, -0, 0));
#388 = AXIS2_PLACEMENT_3D('NONE', #386, #387, $);
#389 = PLANE('NONE', #388);
#390 = CARTESIAN_POINT('NONE', (0.19823384137660915, -0.0635, 0.0508));
@ -408,19 +408,19 @@ DATA;
#392 = AXIS2_PLACEMENT_3D('NONE', #390, #391, $);
#393 = PLANE('NONE', #392);
#394 = CARTESIAN_POINT('NONE', (0.10982398353915601, -0.03174999999999997, 0.0508));
#395 = DIRECTION('NONE', (0.573576436351046, 0.8191520442889918, -0));
#395 = DIRECTION('NONE', (0.5735764363510459, 0.8191520442889917, -0));
#396 = AXIS2_PLACEMENT_3D('NONE', #394, #395, $);
#397 = PLANE('NONE', #396);
#398 = CARTESIAN_POINT('NONE', (0.105333141160801, 0.019049999999999987, 0.0508));
#399 = DIRECTION('NONE', (0.4226182617406993, -0.90630778703665, -0));
#399 = DIRECTION('NONE', (0.4226182617406993, -0.90630778703665, 0));
#400 = AXIS2_PLACEMENT_3D('NONE', #398, #399, $);
#401 = PLANE('NONE', #400);
#402 = CARTESIAN_POINT('NONE', (0.19374299899825406, 0.0381, 0.0508));
#403 = DIRECTION('NONE', (0, -1, -0));
#403 = DIRECTION('NONE', (0, -1, 0));
#404 = AXIS2_PLACEMENT_3D('NONE', #402, #403, $);
#405 = PLANE('NONE', #404);
#406 = CARTESIAN_POINT('NONE', (0.2413, 0.044449999999999996, 0.0508));
#407 = DIRECTION('NONE', (1, 0, -0));
#407 = DIRECTION('NONE', (1, -0, 0));
#408 = AXIS2_PLACEMENT_3D('NONE', #406, #407, $);
#409 = PLANE('NONE', #408);
#410 = CARTESIAN_POINT('NONE', (0.19233523789047138, 0.0508, 0.0508));
@ -436,7 +436,7 @@ DATA;
#420 = AXIS2_PLACEMENT_3D('NONE', #418, #419, $);
#421 = PLANE('NONE', #420);
#422 = CARTESIAN_POINT('NONE', (0, 0.0127, 0.0508));
#423 = DIRECTION('NONE', (-1, 0, -0));
#423 = DIRECTION('NONE', (-1, -0, 0));
#424 = AXIS2_PLACEMENT_3D('NONE', #422, #423, $);
#425 = PLANE('NONE', #424);
#426 = CARTESIAN_POINT('NONE', (0, 0, -0));
@ -475,7 +475,7 @@ DATA;
#459 = ADVANCED_FACE('NONE', (#458), #421, .T.);
#460 = FACE_OUTER_BOUND('NONE', #339, .T.);
#461 = ADVANCED_FACE('NONE', (#460), #425, .T.);
#462 = FACE_OUTER_BOUND('NONE', #354, .T.);
#462 = FACE_OUTER_BOUND('NONE', #354, .F.);
#463 = ADVANCED_FACE('NONE', (#462), #429, .F.);
#464 = FACE_OUTER_BOUND('NONE', #369, .T.);
#465 = ADVANCED_FACE('NONE', (#464), #433, .T.);

View File

@ -100,15 +100,15 @@ endfacet
facet normal 0.57357645 0 0.819152
outer loop
vertex 3.4311862 -0 -0.625
vertex 2.5385938 -0 0
vertex 2.5385938 -4 0
vertex 3.4311862 -4 -0.625
endloop
endfacet
facet normal 0.57357645 -0 0.819152
facet normal 0.5735763 0 0.8191522
outer loop
vertex 3.4311862 -4 -0.625
vertex 4.323779 -0 -1.25
vertex 3.4311862 -0 -0.625
vertex 2.5385938 -4 0
vertex 3.4311862 -4 -0.625
endloop
endfacet
facet normal 0.57357645 -0 0.819152
@ -118,11 +118,11 @@ facet normal 0.57357645 -0 0.819152
vertex 4.323779 -0 -1.25
endloop
endfacet
facet normal 0.5735763 0 0.8191522
facet normal 0.57357645 -0 0.819152
outer loop
vertex 2.5385938 -4 0
vertex 3.4311862 -0 -0.625
vertex 3.4311862 -4 -0.625
vertex 4.323779 -0 -1.25
vertex 2.5385938 -0 0
endloop
endfacet
facet normal 0.42261824 0 -0.9063078
@ -142,29 +142,29 @@ endfacet
facet normal 0.42261824 0 -0.9063078
outer loop
vertex 3.342784 -0 0.375
vertex 4.146974 -0 0.75
vertex 4.146974 -4 0.75
vertex 3.342784 -4 0.375
vertex 2.5385938 -0 0
endloop
endfacet
facet normal 0.42261833 0 -0.90630776
outer loop
vertex 4.146974 -0 0.75
vertex 5.755354 -0 1.5
vertex 5.755354 -4 1.5
vertex 4.146974 -4 0.75
endloop
endfacet
facet normal 0.42261824 0 -0.9063078
outer loop
vertex 3.342784 -4 0.375
vertex 2.5385938 -0 0
vertex 4.146974 -4 0.75
vertex 3.342784 -0 0.375
vertex 4.146974 -0 0.75
endloop
endfacet
facet normal 0.42261833 0 -0.90630776
outer loop
vertex 5.755354 -4 1.5
vertex 4.146974 -4 0.75
vertex 4.146974 -0 0.75
vertex 5.755354 -0 1.5
endloop
endfacet
facet normal 0 0 -1
@ -258,6 +258,13 @@ facet normal 0 1 -0
vertex 3.5 -0 1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 4.146974 -0 0.75
vertex 3.342784 -0 0.375
vertex 3.5 -0 1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 3.4311862 -0 -0.625
@ -265,11 +272,53 @@ facet normal 0 1 0
vertex 3.0950184 -0 -1
endloop
endfacet
facet normal 0 0.99999994 0
outer loop
vertex 4.146974 -0 0.75
vertex 5.644507 -0 2
vertex 5.755354 -0 1.5
endloop
endfacet
facet normal -0 1 0
outer loop
vertex 0 -0 1
vertex 3.5 -0 1
vertex 2.5385938 -0 0
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 3.342784 -0 0.375
vertex 3.5 -0 1
vertex 0 -0 1
vertex 2.5385938 -0 0
vertex 0 -0 0
endloop
endfacet
facet normal -0 1 0
outer loop
vertex 5.644507 -0 2
vertex 9.5 -0 2
vertex 5.755354 -0 1.5
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 9.5 -0 2
vertex 9.5 -0 1.5
vertex 5.755354 -0 1.5
endloop
endfacet
facet normal 0 1 -0
outer loop
vertex 4.146974 -0 0.75
vertex 3.5 -0 1
vertex 5.644507 -0 2
endloop
endfacet
facet normal 0 0.99999994 0
outer loop
vertex 2.5385938 -0 0
vertex 3.4311862 -0 -0.625
vertex 3.0950184 -0 -1
endloop
endfacet
facet normal 0 0.99999994 0
@ -281,86 +330,37 @@ facet normal 0 0.99999994 0
endfacet
facet normal 0 1 0
outer loop
vertex 0 -0 -1
vertex 2.5385938 -0 0
vertex 3.0950184 -0 -1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 0 -0 -1
vertex 0 -0 0
vertex 2.5385938 -0 0
endloop
endfacet
facet normal 0 0.99999994 -0
outer loop
vertex 9.5 -0 -3
vertex 6.108964 -0 -2.5
vertex 9.5 -0 -2.5
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 9.5 -0 -3
vertex 5.9513144 -0 -3
vertex 6.108964 -0 -2.5
endloop
endfacet
facet normal 0 1 -0
outer loop
vertex 5.9513144 -0 -3
vertex 4.323779 -0 -1.25
endloop
endfacet
facet normal 0 0.99999994 0
outer loop
vertex 9.5 -0 -2.5
vertex 9.5 -0 -3
vertex 6.108964 -0 -2.5
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 5.644507 -0 2
vertex 5.755354 -0 1.5
vertex 4.146974 -0 0.75
vertex 6.108964 -0 -2.5
vertex 9.5 -0 -3
vertex 5.9513144 -0 -3
endloop
endfacet
facet normal 0 0.99999994 -0
facet normal 0 1 0
outer loop
vertex 2.5385938 -0 0
vertex 3.0950184 -0 -1
vertex 2.5385938 -0 0
vertex 3.4311862 -0 -0.625
endloop
endfacet
facet normal 0 1 -0
outer loop
vertex 4.146974 -0 0.75
vertex 3.5 -0 1
vertex 5.644507 -0 2
endloop
endfacet
facet normal 0 1 -0
outer loop
vertex 9.5 -0 1.5
vertex 5.755354 -0 1.5
vertex 9.5 -0 2
endloop
endfacet
facet normal 0 1 -0
outer loop
vertex 5.755354 -0 1.5
vertex 5.644507 -0 2
vertex 9.5 -0 2
vertex 0 -0 -1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 2.5385938 -0 0
vertex 0 -0 -1
vertex 0 -0 0
vertex 0 -0 1
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 3.5 -0 1
vertex 2.5385938 -0 0
vertex 0 -0 1
endloop
endfacet
facet normal -0 -1 0