(strandsContext, typeInfo, dependsOn)
| 291 | } |
| 292 | |
| 293 | export function primitiveConstructorNode(strandsContext, typeInfo, dependsOn) { |
| 294 | const cfg = strandsContext.cfg; |
| 295 | dependsOn = (Array.isArray(dependsOn) ? dependsOn : [dependsOn]) |
| 296 | .flat(Infinity) |
| 297 | .map(a => { |
| 298 | if ( |
| 299 | a.isStrandsNode && |
| 300 | a.typeInfo().baseType === BaseType.INT && |
| 301 | // TODO: handle ivec inputs instead of just int scalars |
| 302 | a.typeInfo().dimension === 1 |
| 303 | ) { |
| 304 | return castToFloat(strandsContext, a); |
| 305 | } else { |
| 306 | return a; |
| 307 | } |
| 308 | }); |
| 309 | const { mappedDependencies, inferredTypeInfo } = mapPrimitiveDepsToIDs(strandsContext, typeInfo, dependsOn); |
| 310 | |
| 311 | const finalType = { |
| 312 | // We might have inferred a non numeric type. Currently this is |
| 313 | // just used for booleans. Maybe this needs to be something more robust |
| 314 | // if we ever want to support inference of e.g. int vectors? |
| 315 | baseType: inferredTypeInfo.baseType === BaseType.BOOL |
| 316 | ? BaseType.BOOL |
| 317 | : typeInfo.baseType, |
| 318 | dimension: inferredTypeInfo.dimension |
| 319 | }; |
| 320 | |
| 321 | const id = constructTypeFromIDs(strandsContext, finalType, mappedDependencies); |
| 322 | if (typeInfo.baseType !== BaseType.DEFER) { |
| 323 | CFG.recordInBasicBlock(cfg, cfg.currentBlock, id); |
| 324 | } |
| 325 | |
| 326 | return { id, dimension: finalType.dimension, components: mappedDependencies }; |
| 327 | } |
| 328 | |
| 329 | export function castToFloat(strandsContext, dep) { |
| 330 | const { id, dimension } = functionCallNode( |
no test coverage detected