super-three 0.177.0 → 0.179.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +77 -28
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -1,19 +1,134 @@
|
|
|
1
|
-
|
|
1
|
+
import { toFloatType } from './TranspilerUtils.js';
|
|
2
|
+
|
|
3
|
+
export class ASTNode {
|
|
2
4
|
|
|
3
5
|
constructor() {
|
|
4
6
|
|
|
5
|
-
this.
|
|
7
|
+
this.isASTNode = true;
|
|
8
|
+
|
|
9
|
+
this.linker = {
|
|
10
|
+
reference: null,
|
|
11
|
+
accesses: [],
|
|
12
|
+
assignments: []
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
this.parent = null;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get isNumericExpression() {
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get hasAssignment() {
|
|
26
|
+
|
|
27
|
+
if ( this.isAssignment === true ) {
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if ( this.parent === null ) {
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return this.parent.hasAssignment;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getType() {
|
|
44
|
+
|
|
45
|
+
return this.type || null;
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getParent( parents = [] ) {
|
|
50
|
+
|
|
51
|
+
if ( this.parent === null ) {
|
|
52
|
+
|
|
53
|
+
return parents;
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
parents.push( this.parent );
|
|
58
|
+
|
|
59
|
+
return this.parent.getParent( parents );
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
initialize() {
|
|
64
|
+
|
|
65
|
+
for ( const key in this ) {
|
|
66
|
+
|
|
67
|
+
if ( this[ key ] && this[ key ].isASTNode ) {
|
|
68
|
+
|
|
69
|
+
this[ key ].parent = this;
|
|
70
|
+
|
|
71
|
+
} else if ( Array.isArray( this[ key ] ) ) {
|
|
72
|
+
|
|
73
|
+
const array = this[ key ];
|
|
74
|
+
|
|
75
|
+
for ( const item of array ) {
|
|
76
|
+
|
|
77
|
+
if ( item && item.isASTNode ) {
|
|
78
|
+
|
|
79
|
+
item.parent = this;
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class Comment extends ASTNode {
|
|
94
|
+
|
|
95
|
+
constructor( comment ) {
|
|
96
|
+
|
|
97
|
+
super();
|
|
98
|
+
|
|
99
|
+
this.comment = comment;
|
|
100
|
+
|
|
101
|
+
this.isComment = true;
|
|
102
|
+
|
|
103
|
+
this.initialize();
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
export class Program extends ASTNode {
|
|
111
|
+
|
|
112
|
+
constructor( body = [] ) {
|
|
113
|
+
|
|
114
|
+
super();
|
|
115
|
+
|
|
116
|
+
this.body = body;
|
|
6
117
|
|
|
7
118
|
this.isProgram = true;
|
|
8
119
|
|
|
120
|
+
this.initialize();
|
|
121
|
+
|
|
9
122
|
}
|
|
10
123
|
|
|
11
124
|
}
|
|
12
125
|
|
|
13
|
-
export class VariableDeclaration {
|
|
126
|
+
export class VariableDeclaration extends ASTNode {
|
|
14
127
|
|
|
15
128
|
constructor( type, name, value = null, next = null, immutable = false ) {
|
|
16
129
|
|
|
130
|
+
super();
|
|
131
|
+
|
|
17
132
|
this.type = type;
|
|
18
133
|
this.name = name;
|
|
19
134
|
this.value = value;
|
|
@@ -23,40 +138,58 @@ export class VariableDeclaration {
|
|
|
23
138
|
|
|
24
139
|
this.isVariableDeclaration = true;
|
|
25
140
|
|
|
141
|
+
this.initialize();
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get isAssignment() {
|
|
146
|
+
|
|
147
|
+
return this.value !== null;
|
|
148
|
+
|
|
26
149
|
}
|
|
27
150
|
|
|
28
151
|
}
|
|
29
152
|
|
|
30
|
-
export class Uniform {
|
|
153
|
+
export class Uniform extends ASTNode {
|
|
31
154
|
|
|
32
155
|
constructor( type, name ) {
|
|
33
156
|
|
|
157
|
+
super();
|
|
158
|
+
|
|
34
159
|
this.type = type;
|
|
35
160
|
this.name = name;
|
|
36
161
|
|
|
37
162
|
this.isUniform = true;
|
|
38
163
|
|
|
164
|
+
this.initialize();
|
|
165
|
+
|
|
39
166
|
}
|
|
40
167
|
|
|
41
168
|
}
|
|
42
169
|
|
|
43
|
-
export class Varying {
|
|
170
|
+
export class Varying extends ASTNode {
|
|
44
171
|
|
|
45
172
|
constructor( type, name ) {
|
|
46
173
|
|
|
174
|
+
super();
|
|
175
|
+
|
|
47
176
|
this.type = type;
|
|
48
177
|
this.name = name;
|
|
49
178
|
|
|
50
179
|
this.isVarying = true;
|
|
51
180
|
|
|
181
|
+
this.initialize();
|
|
182
|
+
|
|
52
183
|
}
|
|
53
184
|
|
|
54
185
|
}
|
|
55
186
|
|
|
56
|
-
export class FunctionParameter {
|
|
187
|
+
export class FunctionParameter extends ASTNode {
|
|
57
188
|
|
|
58
189
|
constructor( type, name, qualifier = null, immutable = true ) {
|
|
59
190
|
|
|
191
|
+
super();
|
|
192
|
+
|
|
60
193
|
this.type = type;
|
|
61
194
|
this.name = name;
|
|
62
195
|
this.qualifier = qualifier;
|
|
@@ -64,217 +197,435 @@ export class FunctionParameter {
|
|
|
64
197
|
|
|
65
198
|
this.isFunctionParameter = true;
|
|
66
199
|
|
|
200
|
+
this.initialize();
|
|
201
|
+
|
|
67
202
|
}
|
|
68
203
|
|
|
69
204
|
}
|
|
70
205
|
|
|
71
|
-
export class FunctionDeclaration {
|
|
206
|
+
export class FunctionDeclaration extends ASTNode {
|
|
207
|
+
|
|
208
|
+
constructor( type, name, params = [], body = [] ) {
|
|
72
209
|
|
|
73
|
-
|
|
210
|
+
super();
|
|
74
211
|
|
|
75
212
|
this.type = type;
|
|
76
213
|
this.name = name;
|
|
77
214
|
this.params = params;
|
|
78
|
-
this.body =
|
|
215
|
+
this.body = body;
|
|
79
216
|
|
|
80
217
|
this.isFunctionDeclaration = true;
|
|
81
218
|
|
|
219
|
+
this.initialize();
|
|
220
|
+
|
|
82
221
|
}
|
|
83
222
|
|
|
84
223
|
}
|
|
85
224
|
|
|
86
|
-
export class Expression {
|
|
225
|
+
export class Expression extends ASTNode {
|
|
87
226
|
|
|
88
227
|
constructor( expression ) {
|
|
89
228
|
|
|
229
|
+
super();
|
|
230
|
+
|
|
90
231
|
this.expression = expression;
|
|
91
232
|
|
|
92
233
|
this.isExpression = true;
|
|
93
234
|
|
|
235
|
+
this.initialize();
|
|
236
|
+
|
|
94
237
|
}
|
|
95
238
|
|
|
96
239
|
}
|
|
97
240
|
|
|
98
|
-
export class Ternary {
|
|
241
|
+
export class Ternary extends ASTNode {
|
|
99
242
|
|
|
100
243
|
constructor( cond, left, right ) {
|
|
101
244
|
|
|
245
|
+
super();
|
|
246
|
+
|
|
102
247
|
this.cond = cond;
|
|
103
248
|
this.left = left;
|
|
104
249
|
this.right = right;
|
|
105
250
|
|
|
106
251
|
this.isTernary = true;
|
|
107
252
|
|
|
253
|
+
this.initialize();
|
|
254
|
+
|
|
108
255
|
}
|
|
109
256
|
|
|
110
257
|
}
|
|
111
258
|
|
|
112
|
-
export class Operator {
|
|
259
|
+
export class Operator extends ASTNode {
|
|
113
260
|
|
|
114
261
|
constructor( type, left, right ) {
|
|
115
262
|
|
|
263
|
+
super();
|
|
264
|
+
|
|
116
265
|
this.type = type;
|
|
117
266
|
this.left = left;
|
|
118
267
|
this.right = right;
|
|
119
268
|
|
|
120
269
|
this.isOperator = true;
|
|
121
270
|
|
|
271
|
+
this.initialize();
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
get isAssignment() {
|
|
276
|
+
|
|
277
|
+
return /^(=|\+=|-=|\*=|\/=|%=|<<=|>>=|>>>=|&=|\^=|\|=)$/.test( this.type );
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
get isNumericExpression() {
|
|
282
|
+
|
|
283
|
+
if ( this.left.isNumericExpression && this.right.isNumericExpression ) {
|
|
284
|
+
|
|
285
|
+
return true;
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return false;
|
|
290
|
+
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
getType() {
|
|
294
|
+
|
|
295
|
+
const leftType = this.left.getType();
|
|
296
|
+
const rightType = this.right.getType();
|
|
297
|
+
|
|
298
|
+
if ( leftType === rightType ) {
|
|
299
|
+
|
|
300
|
+
return leftType;
|
|
301
|
+
|
|
302
|
+
} else if ( toFloatType( leftType ) === toFloatType( rightType ) ) {
|
|
303
|
+
|
|
304
|
+
return toFloatType( leftType );
|
|
305
|
+
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return null;
|
|
309
|
+
|
|
122
310
|
}
|
|
123
311
|
|
|
124
312
|
}
|
|
125
313
|
|
|
126
314
|
|
|
127
|
-
export class Unary {
|
|
315
|
+
export class Unary extends ASTNode {
|
|
128
316
|
|
|
129
317
|
constructor( type, expression, after = false ) {
|
|
130
318
|
|
|
319
|
+
super();
|
|
320
|
+
|
|
131
321
|
this.type = type;
|
|
132
322
|
this.expression = expression;
|
|
133
323
|
this.after = after;
|
|
134
324
|
|
|
135
325
|
this.isUnary = true;
|
|
136
326
|
|
|
327
|
+
this.initialize();
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get isAssignment() {
|
|
332
|
+
|
|
333
|
+
return /^(\+\+|--)$/.test( this.type );
|
|
334
|
+
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
get isNumericExpression() {
|
|
338
|
+
|
|
339
|
+
if ( this.expression.isNumber ) {
|
|
340
|
+
|
|
341
|
+
return true;
|
|
342
|
+
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return false;
|
|
346
|
+
|
|
137
347
|
}
|
|
138
348
|
|
|
139
349
|
}
|
|
140
350
|
|
|
141
|
-
export class Number {
|
|
351
|
+
export class Number extends ASTNode {
|
|
142
352
|
|
|
143
353
|
constructor( value, type = 'float' ) {
|
|
144
354
|
|
|
355
|
+
super();
|
|
356
|
+
|
|
145
357
|
this.type = type;
|
|
146
358
|
this.value = value;
|
|
147
359
|
|
|
148
360
|
this.isNumber = true;
|
|
149
361
|
|
|
362
|
+
this.initialize();
|
|
363
|
+
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
get isNumericExpression() {
|
|
367
|
+
|
|
368
|
+
return true;
|
|
369
|
+
|
|
150
370
|
}
|
|
151
371
|
|
|
152
372
|
}
|
|
153
373
|
|
|
154
|
-
export class String {
|
|
374
|
+
export class String extends ASTNode {
|
|
155
375
|
|
|
156
376
|
constructor( value ) {
|
|
157
377
|
|
|
378
|
+
super();
|
|
379
|
+
|
|
158
380
|
this.value = value;
|
|
159
381
|
|
|
160
382
|
this.isString = true;
|
|
161
383
|
|
|
384
|
+
this.initialize();
|
|
385
|
+
|
|
162
386
|
}
|
|
163
387
|
|
|
164
388
|
}
|
|
165
389
|
|
|
166
390
|
|
|
167
|
-
export class Conditional {
|
|
391
|
+
export class Conditional extends ASTNode {
|
|
168
392
|
|
|
169
|
-
constructor( cond = null ) {
|
|
393
|
+
constructor( cond = null, body = [] ) {
|
|
170
394
|
|
|
171
|
-
|
|
395
|
+
super();
|
|
172
396
|
|
|
173
|
-
this.
|
|
397
|
+
this.cond = cond;
|
|
398
|
+
this.body = body;
|
|
174
399
|
this.elseConditional = null;
|
|
175
400
|
|
|
176
401
|
this.isConditional = true;
|
|
177
402
|
|
|
403
|
+
this.initialize();
|
|
404
|
+
|
|
178
405
|
}
|
|
179
406
|
|
|
180
407
|
}
|
|
181
408
|
|
|
182
|
-
export class FunctionCall {
|
|
409
|
+
export class FunctionCall extends ASTNode {
|
|
183
410
|
|
|
184
411
|
constructor( name, params = [] ) {
|
|
185
412
|
|
|
413
|
+
super();
|
|
414
|
+
|
|
186
415
|
this.name = name;
|
|
187
416
|
this.params = params;
|
|
188
417
|
|
|
189
418
|
this.isFunctionCall = true;
|
|
190
419
|
|
|
420
|
+
this.initialize();
|
|
421
|
+
|
|
191
422
|
}
|
|
192
423
|
|
|
193
424
|
}
|
|
194
425
|
|
|
195
|
-
export class Return {
|
|
426
|
+
export class Return extends ASTNode {
|
|
196
427
|
|
|
197
428
|
constructor( value ) {
|
|
198
429
|
|
|
430
|
+
super();
|
|
431
|
+
|
|
199
432
|
this.value = value;
|
|
200
433
|
|
|
201
434
|
this.isReturn = true;
|
|
202
435
|
|
|
436
|
+
this.initialize();
|
|
437
|
+
|
|
203
438
|
}
|
|
204
439
|
|
|
205
440
|
}
|
|
206
441
|
|
|
207
|
-
export class Discard {
|
|
442
|
+
export class Discard extends ASTNode {
|
|
208
443
|
|
|
209
444
|
constructor() {
|
|
210
445
|
|
|
446
|
+
super();
|
|
447
|
+
|
|
211
448
|
this.isDiscard = true;
|
|
212
449
|
|
|
450
|
+
this.initialize();
|
|
451
|
+
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export class Continue extends ASTNode {
|
|
457
|
+
|
|
458
|
+
constructor() {
|
|
459
|
+
|
|
460
|
+
super();
|
|
461
|
+
|
|
462
|
+
this.isContinue = true;
|
|
463
|
+
|
|
464
|
+
this.initialize();
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export class Break extends ASTNode {
|
|
471
|
+
|
|
472
|
+
constructor() {
|
|
473
|
+
|
|
474
|
+
super();
|
|
475
|
+
|
|
476
|
+
this.isBreak = true;
|
|
477
|
+
|
|
478
|
+
this.initialize();
|
|
479
|
+
|
|
213
480
|
}
|
|
214
481
|
|
|
215
482
|
}
|
|
216
483
|
|
|
217
|
-
export class Accessor {
|
|
484
|
+
export class Accessor extends ASTNode {
|
|
218
485
|
|
|
219
486
|
constructor( property ) {
|
|
220
487
|
|
|
488
|
+
super();
|
|
489
|
+
|
|
221
490
|
this.property = property;
|
|
222
491
|
|
|
223
492
|
this.isAccessor = true;
|
|
224
493
|
|
|
494
|
+
this.initialize();
|
|
495
|
+
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
getType() {
|
|
499
|
+
|
|
500
|
+
if ( this.linker.reference ) {
|
|
501
|
+
|
|
502
|
+
return this.linker.reference.getType();
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return super.getType();
|
|
507
|
+
|
|
225
508
|
}
|
|
226
509
|
|
|
227
510
|
}
|
|
228
511
|
|
|
229
|
-
export class StaticElement {
|
|
512
|
+
export class StaticElement extends ASTNode {
|
|
230
513
|
|
|
231
514
|
constructor( value ) {
|
|
232
515
|
|
|
516
|
+
super();
|
|
517
|
+
|
|
233
518
|
this.value = value;
|
|
234
519
|
|
|
235
520
|
this.isStaticElement = true;
|
|
236
521
|
|
|
522
|
+
this.initialize();
|
|
523
|
+
|
|
237
524
|
}
|
|
238
525
|
|
|
239
526
|
}
|
|
240
527
|
|
|
241
|
-
export class DynamicElement {
|
|
528
|
+
export class DynamicElement extends ASTNode {
|
|
242
529
|
|
|
243
530
|
constructor( value ) {
|
|
244
531
|
|
|
532
|
+
super();
|
|
533
|
+
|
|
245
534
|
this.value = value;
|
|
246
535
|
|
|
247
536
|
this.isDynamicElement = true;
|
|
248
537
|
|
|
538
|
+
this.initialize();
|
|
539
|
+
|
|
249
540
|
}
|
|
250
541
|
|
|
251
542
|
}
|
|
252
543
|
|
|
253
|
-
export class AccessorElements {
|
|
544
|
+
export class AccessorElements extends ASTNode {
|
|
254
545
|
|
|
255
546
|
constructor( object, elements = [] ) {
|
|
256
547
|
|
|
548
|
+
super();
|
|
549
|
+
|
|
257
550
|
this.object = object;
|
|
258
551
|
this.elements = elements;
|
|
259
552
|
|
|
260
553
|
this.isAccessorElements = true;
|
|
261
554
|
|
|
555
|
+
this.initialize();
|
|
556
|
+
|
|
262
557
|
}
|
|
263
558
|
|
|
264
559
|
}
|
|
265
560
|
|
|
266
|
-
export class For {
|
|
561
|
+
export class For extends ASTNode {
|
|
562
|
+
|
|
563
|
+
constructor( initialization, condition, afterthought, body = [] ) {
|
|
267
564
|
|
|
268
|
-
|
|
565
|
+
super();
|
|
269
566
|
|
|
270
567
|
this.initialization = initialization;
|
|
271
568
|
this.condition = condition;
|
|
272
569
|
this.afterthought = afterthought;
|
|
273
|
-
|
|
274
|
-
this.body = [];
|
|
570
|
+
this.body = body;
|
|
275
571
|
|
|
276
572
|
this.isFor = true;
|
|
277
573
|
|
|
574
|
+
this.initialize();
|
|
575
|
+
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export class While extends ASTNode {
|
|
581
|
+
|
|
582
|
+
constructor( condition, body = [] ) {
|
|
583
|
+
|
|
584
|
+
super();
|
|
585
|
+
|
|
586
|
+
this.condition = condition;
|
|
587
|
+
this.body = body;
|
|
588
|
+
|
|
589
|
+
this.isWhile = true;
|
|
590
|
+
|
|
591
|
+
this.initialize();
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
export class Switch extends ASTNode {
|
|
599
|
+
|
|
600
|
+
constructor( discriminant, cases ) {
|
|
601
|
+
|
|
602
|
+
super();
|
|
603
|
+
|
|
604
|
+
this.discriminant = discriminant;
|
|
605
|
+
this.cases = cases;
|
|
606
|
+
|
|
607
|
+
this.isSwitch = true;
|
|
608
|
+
|
|
609
|
+
this.initialize();
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export class SwitchCase extends ASTNode {
|
|
616
|
+
|
|
617
|
+
constructor( body, conditions = null ) {
|
|
618
|
+
|
|
619
|
+
super();
|
|
620
|
+
|
|
621
|
+
this.body = body;
|
|
622
|
+
this.conditions = conditions;
|
|
623
|
+
|
|
624
|
+
this.isDefault = conditions === null ? true : false;
|
|
625
|
+
this.isSwitchCase = true;
|
|
626
|
+
|
|
627
|
+
this.initialize();
|
|
628
|
+
|
|
278
629
|
}
|
|
279
630
|
|
|
280
631
|
}
|