@geastack/compiler 1.0.22 → 1.0.24

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.
Files changed (38) hide show
  1. package/dist/ir/borrow-effects.js +55 -1
  2. package/dist/ir/dense-loops.d.ts +16 -2
  3. package/dist/ir/dense-loops.js +66 -21
  4. package/dist/ir/facts.d.ts +6 -29
  5. package/dist/ir/facts.js +46 -1
  6. package/dist/ir/floats.d.ts +46 -0
  7. package/dist/ir/floats.js +196 -0
  8. package/dist/ir/hoist.d.ts +11 -2
  9. package/dist/ir/hoist.js +17 -2
  10. package/dist/ir/integer-storage.d.ts +8 -0
  11. package/dist/ir/integer-storage.js +15 -4
  12. package/dist/ir/integers.d.ts +40 -0
  13. package/dist/ir/integers.js +137 -4
  14. package/dist/ir/numeric-intrinsics.d.ts +1 -1
  15. package/dist/ir/numeric-intrinsics.js +3 -2
  16. package/dist/representation/derive.js +30 -1
  17. package/dist/semantics/frontend.js +5 -1
  18. package/dist/semantics/normalize/asserted-argument-arms.d.ts +38 -0
  19. package/dist/semantics/normalize/asserted-argument-arms.js +182 -0
  20. package/dist/semantics/normalize/structural.d.ts +2 -1
  21. package/dist/semantics/normalize/structural.js +10 -3
  22. package/dist/targets/cpp/emit-arrays.d.ts +2 -1
  23. package/dist/targets/cpp/emit-arrays.js +7 -3
  24. package/dist/targets/cpp/emit-bindings.js +4 -2
  25. package/dist/targets/cpp/emit-callable.js +13 -0
  26. package/dist/targets/cpp/emit-carrier-members.d.ts +3 -1
  27. package/dist/targets/cpp/emit-carrier-members.js +18 -2
  28. package/dist/targets/cpp/emit-context.d.ts +13 -0
  29. package/dist/targets/cpp/emit-context.js +18 -2
  30. package/dist/targets/cpp/emit-properties.js +16 -3
  31. package/dist/targets/cpp/emit.js +36 -4
  32. package/dist/targets/cpp/host/emit-host-invoke.js +10 -1
  33. package/dist/targets/cpp/host/host-members.js +43 -30
  34. package/dist/targets/cpp/translation-unit.js +15 -3
  35. package/dist/targets/cpp/types.d.ts +2 -0
  36. package/dist/targets/cpp/types.js +2 -0
  37. package/package.json +9 -9
  38. package/src/targets/cpp/runtime/gea_runtime.h +80 -4
@@ -0,0 +1,182 @@
1
+ import ts from 'typescript';
2
+ import { forEachReachableStatement } from './reachability.js';
3
+ export const emptyAssertedArgumentArmCensus = { armsOf: () => null };
4
+ const presentMembersOf = (type) => (type.isUnion() ? type.types : [type]).filter((member) => (member.flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Null)) === 0);
5
+ const containsTypeParameter = (checker, type, depth = 0) => {
6
+ if (depth > 4)
7
+ return true;
8
+ if (type.flags & ts.TypeFlags.TypeParameter)
9
+ return true;
10
+ if (type.isUnionOrIntersection())
11
+ return type.types.some((member) => containsTypeParameter(checker, member, depth + 1));
12
+ if ((type.flags & ts.TypeFlags.Object) !== 0 && (type.objectFlags & ts.ObjectFlags.Reference) !== 0)
13
+ return checker.getTypeArguments(type).some((argument) => containsTypeParameter(checker, argument, depth + 1));
14
+ return false;
15
+ };
16
+ const unwrapParens = (node) => (ts.isParenthesizedExpression(node) ? unwrapParens(node.expression) : node);
17
+ /**
18
+ * A plain record: an object type with no call or construct signature that is
19
+ * not a class instance, an array, or a tuple. A class arm is nominal, so a
20
+ * record beside it would be a second layout the class's methods never see.
21
+ */
22
+ const isPlainRecord = (checker, type) => (type.flags & ts.TypeFlags.Object) !== 0 &&
23
+ ((type.getSymbol()?.flags ?? 0) & ts.SymbolFlags.Class) === 0 &&
24
+ type.getCallSignatures().length === 0 &&
25
+ type.getConstructSignatures().length === 0 &&
26
+ !checker.isArrayType(type) &&
27
+ !checker.isTupleType(type);
28
+ /** Whether a narrowing condition reads `node` -- the walk `record-stand-in-arms.ts` states. */
29
+ const narrows = (node) => {
30
+ let current = node;
31
+ for (;;) {
32
+ const parent = current.parent;
33
+ if (!parent)
34
+ return false;
35
+ if (ts.isParenthesizedExpression(parent) ||
36
+ ts.isTypeOfExpression(parent) ||
37
+ ts.isNonNullExpression(parent) ||
38
+ (ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.ExclamationToken) ||
39
+ (ts.isPropertyAccessExpression(parent) && parent.expression === current) ||
40
+ (ts.isElementAccessExpression(parent) && parent.expression === current)) {
41
+ current = parent;
42
+ continue;
43
+ }
44
+ if (ts.isBinaryExpression(parent)) {
45
+ switch (parent.operatorToken.kind) {
46
+ case ts.SyntaxKind.AmpersandAmpersandToken:
47
+ case ts.SyntaxKind.BarBarToken:
48
+ case ts.SyntaxKind.QuestionQuestionToken:
49
+ case ts.SyntaxKind.EqualsEqualsEqualsToken:
50
+ case ts.SyntaxKind.ExclamationEqualsEqualsToken:
51
+ case ts.SyntaxKind.EqualsEqualsToken:
52
+ case ts.SyntaxKind.ExclamationEqualsToken:
53
+ case ts.SyntaxKind.InstanceOfKeyword:
54
+ case ts.SyntaxKind.InKeyword:
55
+ current = parent;
56
+ continue;
57
+ default:
58
+ return false;
59
+ }
60
+ }
61
+ if (ts.isIfStatement(parent) || ts.isWhileStatement(parent) || ts.isDoStatement(parent))
62
+ return parent.expression === current;
63
+ if (ts.isForStatement(parent))
64
+ return parent.condition === current;
65
+ if (ts.isConditionalExpression(parent))
66
+ return parent.condition === current;
67
+ if (ts.isSwitchStatement(parent))
68
+ return parent.expression === current;
69
+ if (ts.isCaseClause(parent))
70
+ return parent.expression === current;
71
+ return false;
72
+ }
73
+ };
74
+ export const censusAssertedArgumentArms = (checker, files, reachable) => {
75
+ /** The seed one call argument states, when it is `record as unknown as Union` landing where the union is the parameter. */
76
+ const seedOf = (argument) => {
77
+ const outer = unwrapParens(argument);
78
+ if (!ts.isAsExpression(outer) && !ts.isTypeAssertionExpression(outer))
79
+ return null;
80
+ const inner = unwrapParens(outer.expression);
81
+ if (!ts.isAsExpression(inner) && !ts.isTypeAssertionExpression(inner))
82
+ return null;
83
+ if ((checker.getTypeFromTypeNode(inner.type).flags & ts.TypeFlags.Unknown) === 0)
84
+ return null;
85
+ const union = checker.getTypeFromTypeNode(outer.type);
86
+ const record = checker.getTypeAtLocation(unwrapParens(inner.expression));
87
+ if (!union.isUnion() || containsTypeParameter(checker, union) || containsTypeParameter(checker, record))
88
+ return null;
89
+ const homes = presentMembersOf(union);
90
+ if (homes.length < 2 || !homes.every((home) => isPlainRecord(checker, home)))
91
+ return null;
92
+ if (!isPlainRecord(checker, record) || homes.includes(record) || checker.isTypeAssignableTo(record, union))
93
+ return null;
94
+ return { union, record };
95
+ };
96
+ const seeds = [];
97
+ for (const file of files) {
98
+ if (file.isDeclarationFile)
99
+ continue;
100
+ const visit = (node) => {
101
+ if (reachable.memberIsPruned(node))
102
+ return;
103
+ if (ts.isCallExpression(node) || ts.isNewExpression(node)) {
104
+ const argumentsList = node.arguments ?? [];
105
+ const signature = checker.getResolvedSignature(node);
106
+ argumentsList.forEach((argument, index) => {
107
+ if (argumentsList.slice(0, index + 1).some(ts.isSpreadElement))
108
+ return;
109
+ const seed = seedOf(argument);
110
+ const parameter = signature?.getParameters()[index];
111
+ if (!seed || !parameter || checker.getTypeOfSymbol(parameter) !== seed.union)
112
+ return;
113
+ seeds.push(seed);
114
+ });
115
+ }
116
+ ts.forEachChild(node, visit);
117
+ };
118
+ forEachReachableStatement(reachable, file, visit);
119
+ }
120
+ if (seeds.length === 0)
121
+ return emptyAssertedArgumentArmCensus;
122
+ const records = new Map();
123
+ for (const seed of seeds) {
124
+ const held = records.get(seed.union);
125
+ if (!held)
126
+ records.set(seed.union, [seed.record]);
127
+ else if (!held.includes(seed.record))
128
+ held.push(seed.record);
129
+ }
130
+ /**
131
+ * Whether a narrowing test on a value of `union` can tell its arms apart.
132
+ * Truthiness and nullishness of the value itself cannot -- every arm is an
133
+ * object -- and neither can a member every arm states with a non-unit type.
134
+ */
135
+ const discriminates = (use, union) => {
136
+ const parent = use.parent;
137
+ if (!parent)
138
+ return true;
139
+ if (ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) {
140
+ const key = ts.isPropertyAccessExpression(parent)
141
+ ? parent.name.text
142
+ : ts.isStringLiteralLike(parent.argumentExpression)
143
+ ? parent.argumentExpression.text
144
+ : null;
145
+ if (key === null)
146
+ return true;
147
+ return [...presentMembersOf(union), ...(records.get(union) ?? [])].some((arm) => {
148
+ const property = arm.getProperty(key);
149
+ return !property || (checker.getTypeOfSymbol(property).flags & ts.TypeFlags.Unit) !== 0;
150
+ });
151
+ }
152
+ if (ts.isBinaryExpression(parent)) {
153
+ const operator = parent.operatorToken.kind;
154
+ return operator === ts.SyntaxKind.InstanceOfKeyword || operator === ts.SyntaxKind.InKeyword;
155
+ }
156
+ return ts.isTypeOfExpression(parent);
157
+ };
158
+ const withdrawn = new Set();
159
+ for (const file of files) {
160
+ if (file.isDeclarationFile)
161
+ continue;
162
+ const visit = (node) => {
163
+ if (reachable.memberIsPruned(node) || ts.isTypeNode(node))
164
+ return;
165
+ if ((ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && narrows(node)) {
166
+ const type = checker.getTypeAtLocation(node);
167
+ if (records.has(type) && discriminates(node, type))
168
+ withdrawn.add(type);
169
+ }
170
+ ts.forEachChild(node, visit);
171
+ };
172
+ forEachReachableStatement(reachable, file, visit);
173
+ }
174
+ for (const union of withdrawn)
175
+ records.delete(union);
176
+ if (process.env['GEA_BINDING_DEBUG'])
177
+ for (const seed of seeds)
178
+ console.error(`[ASSERTED-ARGUMENT-ARM] ${checker.typeToString(seed.record)} into ${checker.typeToString(seed.union)}${withdrawn.has(seed.union) ? ' :: withdrawn' : ''}`);
179
+ if (records.size === 0)
180
+ return emptyAssertedArgumentArmCensus;
181
+ return { armsOf: (union) => records.get(union) ?? null };
182
+ };
@@ -4,6 +4,7 @@ import type { ValueFlowIndex } from './flow/model.js';
4
4
  import { type SloppyAbsenceCensus } from './sloppy-absence.js';
5
5
  import { type SuppressedWriteArmCensus } from './suppressed-write-arms.js';
6
6
  import { type RecordStandInArmCensus } from './record-stand-in-arms.js';
7
+ import { type AssertedArgumentArmCensus } from './asserted-argument-arms.js';
7
8
  import { type RecordLinkFamilyCensus } from './record-link-families.js';
8
9
  import { type DeclaredMemberCensus } from './structural-declarations.js';
9
10
  import type { DeclarationId, StructuralTypeId } from '../../identity/ids.js';
@@ -203,7 +204,7 @@ export interface StructuralMapper {
203
204
  */
204
205
  readonly classCopies: () => ReadonlyMap<DeclarationId, readonly ClassCopyKey[]>;
205
206
  }
206
- export declare const createStructuralMapper: (checker: ts.TypeChecker, identities: IdentityTable, table: StructuralTypeTable, instantiations?: InstantiationCensus, specializations?: SpecializationCensus, parameters?: ParameterBindingCensus, absent?: AbsentGlobalCensus, collections?: CollectionBindingCensus, bags?: ObjectBagCensus, flow?: ValueFlowIndex, families?: InterfaceFamilyCensus, moduleRecords?: CommonJsModuleRecordCensus, declaredMembers?: DeclaredMemberCensus, isIntrinsicDescriptorCall?: (call: ts.CallExpression) => boolean, standIns?: RecordStandInArmCensus, linkFamilies?: RecordLinkFamilyCensus, sloppyAbsence?: SloppyAbsenceCensus, suppressedWrites?: SuppressedWriteArmCensus) => StructuralMapper;
207
+ export declare const createStructuralMapper: (checker: ts.TypeChecker, identities: IdentityTable, table: StructuralTypeTable, instantiations?: InstantiationCensus, specializations?: SpecializationCensus, parameters?: ParameterBindingCensus, absent?: AbsentGlobalCensus, collections?: CollectionBindingCensus, bags?: ObjectBagCensus, flow?: ValueFlowIndex, families?: InterfaceFamilyCensus, moduleRecords?: CommonJsModuleRecordCensus, declaredMembers?: DeclaredMemberCensus, isIntrinsicDescriptorCall?: (call: ts.CallExpression) => boolean, standIns?: RecordStandInArmCensus, linkFamilies?: RecordLinkFamilyCensus, sloppyAbsence?: SloppyAbsenceCensus, suppressedWrites?: SuppressedWriteArmCensus, assertedArguments?: AssertedArgumentArmCensus) => StructuralMapper;
207
208
  /**
208
209
  * `JSON.stringify(value)` from the default lib over a value that may have no
209
210
  * JSON form, so the call may return `undefined` although the lib declares
@@ -6,6 +6,7 @@ import { noSloppyAbsence, withAbsences } from './sloppy-absence.js';
6
6
  import { emptySuppressedWriteArmCensus } from './suppressed-write-arms.js';
7
7
  import { recordStorageFamilies } from './record-storage-families.js';
8
8
  import { emptyRecordStandInArmCensus } from './record-stand-in-arms.js';
9
+ import { emptyAssertedArgumentArmCensus } from './asserted-argument-arms.js';
9
10
  import { emptyRecordLinkFamilyCensus } from './record-link-families.js';
10
11
  import { bivariantSlotArrayAliasTypeOf, bivariantSlotBindingTypeOf, bivariantSlotElementTypeOf, bivariantSlotParameterTypeOf, bivariantSlotReadTypeOf } from './bivariant-slot-parameter.js';
11
12
  import { emptyDeclaredMemberCensus } from './structural-declarations.js';
@@ -100,7 +101,7 @@ const nativeErrorNames = new Set([
100
101
  'TypeError',
101
102
  'URIError'
102
103
  ]);
103
- export const createStructuralMapper = (checker, identities, table, instantiations = emptyInstantiationCensus, specializations = emptySpecializationCensus, parameters = emptyParameterBindingCensus, absent = emptyAbsentGlobalCensus, collections = emptyCollectionBindingCensus, bags = emptyObjectBagCensus, flow, families = emptyInterfaceFamilyCensus, moduleRecords = emptyCommonJsModuleRecordCensus, declaredMembers = emptyDeclaredMemberCensus, isIntrinsicDescriptorCall = () => false, standIns = emptyRecordStandInArmCensus, linkFamilies = emptyRecordLinkFamilyCensus, sloppyAbsence = noSloppyAbsence, suppressedWrites = emptySuppressedWriteArmCensus) => {
104
+ export const createStructuralMapper = (checker, identities, table, instantiations = emptyInstantiationCensus, specializations = emptySpecializationCensus, parameters = emptyParameterBindingCensus, absent = emptyAbsentGlobalCensus, collections = emptyCollectionBindingCensus, bags = emptyObjectBagCensus, flow, families = emptyInterfaceFamilyCensus, moduleRecords = emptyCommonJsModuleRecordCensus, declaredMembers = emptyDeclaredMemberCensus, isIntrinsicDescriptorCall = () => false, standIns = emptyRecordStandInArmCensus, linkFamilies = emptyRecordLinkFamilyCensus, sloppyAbsence = noSloppyAbsence, suppressedWrites = emptySuppressedWriteArmCensus, assertedArguments = emptyAssertedArgumentArmCensus) => {
104
105
  const storageTypeOf = recordStorageFamilies(checker, flow, parameters);
105
106
  // One disagreement list for the WHOLE mapper, for the same reason the caches
106
107
  // below are shared: two rules answering for one node is a fact about the rule
@@ -133,13 +134,13 @@ export const createStructuralMapper = (checker, identities, table, instantiation
133
134
  const cached = views.get(key);
134
135
  if (cached)
135
136
  return cached;
136
- const built = buildMapper(checker, identities.forSpecialization(path), table, instantiations, specializations, path, bindingPath, mapperFor, parameters, absent, collections, bags, flow, storageTypeOf, families, moduleRecords, declaredMembers, isIntrinsicDescriptorCall, standIns, linkFamilies, aliasRecurrence, instantiatedMembersFor(bindingPath), viewIndependentKeyOf, sharedCompleted, classCopyKeys, disagreements, sloppyAbsence, suppressedWrites);
137
+ const built = buildMapper(checker, identities.forSpecialization(path), table, instantiations, specializations, path, bindingPath, mapperFor, parameters, absent, collections, bags, flow, storageTypeOf, families, moduleRecords, declaredMembers, isIntrinsicDescriptorCall, standIns, linkFamilies, aliasRecurrence, instantiatedMembersFor(bindingPath), viewIndependentKeyOf, sharedCompleted, classCopyKeys, disagreements, sloppyAbsence, suppressedWrites, assertedArguments);
137
138
  views.set(key, built);
138
139
  return built;
139
140
  };
140
141
  return mapperFor(rootSpecialization);
141
142
  };
142
- const buildMapper = (checker, identities, table, instantiations, specializations, path, bindingPath, mapperFor, programParameters, absent, collections, bags, flow, storageTypeOf, families, moduleRecords, declaredMembers, isIntrinsicDescriptorCall, standIns, linkFamilies, aliasRecurrence, instantiatedMembers, viewIndependentKeyOf, sharedCompleted, classCopyKeys, disagreements, sloppyAbsence, suppressedWrites) => {
143
+ const buildMapper = (checker, identities, table, instantiations, specializations, path, bindingPath, mapperFor, programParameters, absent, collections, bags, flow, storageTypeOf, families, moduleRecords, declaredMembers, isIntrinsicDescriptorCall, standIns, linkFamilies, aliasRecurrence, instantiatedMembers, viewIndependentKeyOf, sharedCompleted, classCopyKeys, disagreements, sloppyAbsence, suppressedWrites, assertedArguments) => {
143
144
  const { boundByPath, bindingOf: censusBindingOf, substituteTypeParameter } = createTypeParameterSubstitution(identities, instantiations, specializations, bindingPath);
144
145
  // What a parameter holds is a fact about the COPY this view describes: a
145
146
  // generic body's copies are called with different carriers. Scoped once,
@@ -2246,6 +2247,12 @@ const buildMapper = (checker, identities, table, instantiations, specializations
2246
2247
  const standInArms = standInArmIdsOf(standIns.armsOf(type));
2247
2248
  if (standInArms)
2248
2249
  return remember(type, table.intern({ kind: 'union', members: [...present.map(typeOf), ...standInArms] }));
2250
+ // A record an argument hands this union through `as unknown as` is the
2251
+ // same object in the callee -- `asserted-argument-arms.ts` -- so it is
2252
+ // its own carrier's arm, never a stand-in copy of another shape.
2253
+ const assertedArms = assertedArguments.armsOf(type);
2254
+ if (assertedArms)
2255
+ return remember(type, table.intern({ kind: 'union', members: [...present.map(typeOf), ...assertedArms.map(typeOf)] }));
2249
2256
  // A union of pure INDEX-SIGNATURE objects is one table whose values are
2250
2257
  // the union. `Record<string, string> | Record<string, string[]>` (hono's
2251
2258
  // `_getQueryParam`, `utils/url.ts:255`) describes one object either way:
@@ -1,3 +1,4 @@
1
+ import type { HoistPlan } from '../../ir/hoist.js';
1
2
  import type { IrValueId } from '../../identity/ids.js';
2
3
  import type { AllocateArrayObjectOperation, IrBlockId, IrBody } from '../../ir/model.js';
3
4
  import { type Representation } from '../../representation/model.js';
@@ -68,7 +69,7 @@ export declare const emitFillLoop: (ctx: EmitContext, lines: string[], fill: Fil
68
69
  * until a `%` compute actually renders (`emit.ts`'s `emitBinaryOperation`),
69
70
  * which is why that one field, alone of this group, is on the whitelist.
70
71
  */
71
- export declare const admitDenseWindows: (ctx: EmitContext, prepass: EmitBodyPrepassFacts, body: IrBody) => void;
72
+ export declare const admitDenseWindows: (ctx: EmitContext, prepass: EmitBodyPrepassFacts, body: IrBody, hoists: HoistPlan) => void;
72
73
  /**
73
74
  * The preheader statements one loop's dense windows need: an element pointer
74
75
  * per array, and the one loop-invariant condition that makes indexing it sound.
@@ -924,8 +924,8 @@ const denseIntegerText = (ctx, operand) => ctx.integerValues.has(operand.value)
924
924
  * until a `%` compute actually renders (`emit.ts`'s `emitBinaryOperation`),
925
925
  * which is why that one field, alone of this group, is on the whitelist.
926
926
  */
927
- export const admitDenseWindows = (ctx, prepass, body) => {
928
- const plan = denseLoopsOf(body);
927
+ export const admitDenseWindows = (ctx, prepass, body, hoists) => {
928
+ const plan = denseLoopsOf(body, hoists);
929
929
  if (plan.arrays.length === 0)
930
930
  return;
931
931
  const admitted = admittedDenseLoopPlanOf(plan, ctx.integerValues, (declaration) => denseCellName(ctx, declaration) !== null);
@@ -1061,7 +1061,11 @@ export const emitDenseSetup = (ctx, lines, blockId) => {
1061
1061
  // this may dereference it.
1062
1062
  said.push(...holder.guard, ...shape, ...writable);
1063
1063
  for (const offset of array.bases) {
1064
- const base = offset === null ? '0' : operandText(ctx, offset);
1064
+ const base = offset === null
1065
+ ? '0'
1066
+ : offset.terms.length === 1 && !offset.terms[0].negated
1067
+ ? operandText(ctx, offset.terms[0].operand)
1068
+ : `(${offset.terms.map((term, at) => `${term.negated ? '-' : at === 0 ? '' : '+'} (${operandText(ctx, term.operand)})`).join(' ')})`;
1065
1069
  said.push(`gea::denseIndexWindow(${size}, ${seed}, ${base}, ${operandText(ctx, array.bound)}, ${step}, ${array.inclusive}, ${array.widened})`);
1066
1070
  }
1067
1071
  }
@@ -5,7 +5,7 @@ import { carrierDifference, shortCarrierText } from '../../representation/differ
5
5
  import { bindingReference, createCppEmitBlockedError, cppFormalName, cppFrameLocalName, cppFrameStructName, cppReceiverName, declareCell, defineValue, defineValueAlias, isCppEmitBlockedError, operandText } from './emit-context.js';
6
6
  import { alignedValueText, classFamilyLoadText, emptyArraySentinelText, movedValueText } from './emit-narrowing.js';
7
7
  import { stringAppendStatement } from './emit-tostring.js';
8
- import { cppAbiParameterType, cppBoxedType, cppNarrowedIntegerType, cppStringLiteral, cppTypeOf } from './types.js';
8
+ import { cppAbiParameterType, cppBoxedType, cppNarrowedFloatType, cppNarrowedIntegerType, cppStringLiteral, cppTypeOf } from './types.js';
9
9
  import { receiverBoundCallableText } from './emit-callable.js';
10
10
  import { structuralRecordViewText } from './emit-record-view.js';
11
11
  import { owningConversionInputText } from './owning-conversion-input.js';
@@ -582,7 +582,9 @@ export const emitBindingWrite = (ctx, lines, operation) => {
582
582
  ? 'gea::Value::Tag'
583
583
  : ctx.integerBindings.has(operation.declaration) && !cell.boxed
584
584
  ? cppNarrowedIntegerType
585
- : cppTypeOf(held ?? operation.value.representation);
585
+ : ctx.float32.bindings.has(operation.declaration) && !cell.boxed
586
+ ? cppNarrowedFloatType
587
+ : cppTypeOf(held ?? operation.value.representation);
586
588
  if (cell.boxed) {
587
589
  // The box itself, not its pointee, is what gets declared and allocated: a
588
590
  // shared cell is born already holding this first value, so every other
@@ -918,6 +918,19 @@ const emitCharCodeBufferPush = (ctx, lines, operation) => {
918
918
  return true;
919
919
  };
920
920
  export const emitCall = (ctx, lines, operation) => {
921
+ const minMax = ctx.numericCalls.get(operation);
922
+ if (minMax === 'min' || minMax === 'max') {
923
+ // An integer result (`ir/integers.ts`) is the smaller or larger integer;
924
+ // anything else is the host's own double answer, NaN and -0 included.
925
+ const integer = operation.result !== null && isIntegerStorageValue(ctx, operation.result.id);
926
+ const args = operation.arguments.map((argument) => integer ? `static_cast<long long>(${operandText(ctx, argument)})` : `static_cast<double>(${operandText(ctx, argument)})`);
927
+ const expression = integer ? `std::${minMax}<long long>(${args.join(', ')})` : `gea::host::Math::${minMax}Direct({${args.join(', ')}})`;
928
+ if (operation.result && !ctx.unreadValues.has(operation.result.id))
929
+ lines.push(`${defineValue(ctx, operation.result)} = ${expression};`);
930
+ else
931
+ lines.push(`${expression};`);
932
+ return;
933
+ }
921
934
  if (ctx.numericCalls.get(operation) === 'imul') {
922
935
  const args = operation.arguments.map((argument) => {
923
936
  const text = operandText(ctx, argument);
@@ -1,7 +1,7 @@
1
1
  import type { DefineOwnPropertyOperation, GetOperation, IrOperand, IrResult, SetOperation } from '../../ir/model.js';
2
2
  import type { IrValueId } from '../../identity/ids.js';
3
3
  import { type ReactiveRevisionOrigin, type EmitContext, type PrototypeMethodRead } from './emit-context.js';
4
- import type { Ownership, Representation } from '../../representation/model.js';
4
+ import type { Ownership, Representation, TypedArrayElementDomain } from '../../representation/model.js';
5
5
  import { type ConversionSite } from './emit-narrowing.js';
6
6
  import { type RecordIndexSidecar } from './records.js';
7
7
  /**
@@ -64,6 +64,8 @@ export declare const arrayAccessText: (ctx: EmitContext, receiver: IrOperand, ke
64
64
  * index, and the three block-shaped members `emit-buffers.ts` owns.
65
65
  */
66
66
  export declare const deferredTypedArrayMethodClaim: (staticKeyTexts: ReadonlyMap<IrValueId, string>, receiver: IrOperand, key: IrOperand) => PrototypeMethodRead | null;
67
+ /** The views whose every element is an integer, read and written in integer registers when the census holds the value as one. */
68
+ export declare const integerTypedArrayElements: ReadonlySet<TypedArrayElementDomain>;
67
69
  export declare const typedArrayAccessText: (ctx: EmitContext, receiver: IrOperand, key: IrOperand, result: IrResult | null) => string | null;
68
70
  /**
69
71
  * `absentCapableElementText` for the typed-array reader.
@@ -336,6 +336,16 @@ export const deferredTypedArrayMethodClaim = (staticKeyTexts, receiver, key) =>
336
336
  receiverElement: typedArrayElementSpelling(carrier)
337
337
  };
338
338
  };
339
+ /** The views whose every element is an integer, read and written in integer registers when the census holds the value as one. */
340
+ export const integerTypedArrayElements = new Set([
341
+ 'int8',
342
+ 'uint8',
343
+ 'uint8-clamped',
344
+ 'int16',
345
+ 'uint16',
346
+ 'int32',
347
+ 'uint32'
348
+ ]);
339
349
  export const typedArrayAccessText = (ctx, receiver, key, result) => {
340
350
  if (receiver.representation.kind !== 'typed-array')
341
351
  return null;
@@ -394,8 +404,14 @@ export const typedArrayAccessText = (ctx, receiver, key, result) => {
394
404
  const integerKey = isIntegerStorageValue(ctx, key.value);
395
405
  const reader = integerKey ? 'elementAtIndex' : 'elementAt';
396
406
  const keyText = operandText(ctx, key);
397
- return (absentCapableNumericElementText(receiverText, keyText, result, integerKey ? 'hasElementAtIndex' : 'hasElement', reader) ??
398
- `${receiverText}->${reader}(${keyText})`);
407
+ const absentCapable = absentCapableNumericElementText(receiverText, keyText, result, integerKey ? 'hasElementAtIndex' : 'hasElement', reader);
408
+ if (absentCapable !== null)
409
+ return absentCapable;
410
+ // An integer element read into a `long long` the integer census chose is
411
+ // that integer: no conversion to `double` and back.
412
+ if (integerKey && result !== null && integerTypedArrayElements.has(receiver.representation.element) && ctx.integerValues.has(result.id))
413
+ return `${receiverText}->elementIntegerAtIndex(${keyText})`;
414
+ return `${receiverText}->${reader}(${keyText})`;
399
415
  };
400
416
  /**
401
417
  * `absentCapableElementText` for the typed-array reader.
@@ -1650,6 +1650,12 @@ export interface EmitContext {
1650
1650
  readonly integerValues: ReadonlySet<IrValueId>;
1651
1651
  /** Settled the same way as `hoistedResults`. */
1652
1652
  readonly integerBindings: ReadonlySet<DeclarationId>;
1653
+ /** `ir/floats.ts`'s answer for this body. Settled the same way as `hoistedResults`. */
1654
+ readonly float32: {
1655
+ readonly values: ReadonlySet<IrValueId>;
1656
+ readonly bindings: ReadonlySet<DeclarationId>;
1657
+ readonly arithmetic: ReadonlySet<IrValueId>;
1658
+ };
1653
1659
  /** Finite typeof snapshots proved by the IR, confined to comparison-only uses. Settled the same way as `hoistedResults`. */
1654
1660
  readonly typeQueryValues: ReadonlySet<IrValueId>;
1655
1661
  /** Settled the same way as `hoistedResults`. */
@@ -1881,6 +1887,11 @@ export interface EmitBodyPrepassFacts {
1881
1887
  readonly numericCallOnly: Set<IrValueId>;
1882
1888
  readonly integerValues: Set<IrValueId>;
1883
1889
  readonly integerBindings: Set<DeclarationId>;
1890
+ readonly float32: {
1891
+ readonly values: Set<IrValueId>;
1892
+ readonly bindings: Set<DeclarationId>;
1893
+ readonly arithmetic: Set<IrValueId>;
1894
+ };
1884
1895
  readonly typeQueryValues: Set<IrValueId>;
1885
1896
  readonly typeQueryBindings: Set<DeclarationId>;
1886
1897
  readonly typeQueryComparisons: Map<ComputeOperation, TypeQueryComparison>;
@@ -1939,6 +1950,8 @@ export declare const createEmitContext: (abi: CallableAbi | null, owner: Functio
1939
1950
  * something this does not.
1940
1951
  */
1941
1952
  export declare const storageTypeOf: (ctx: EmitContext, value: IrValueId, representation: Representation) => string;
1953
+ /** Whether a value's rendered text is a `float` -- the float32 census's twin of `isIntegerStorageValue`. */
1954
+ export declare const isFloatStorageValue: (ctx: EmitContext, value: IrValueId) => boolean;
1942
1955
  /**
1943
1956
  * Whether a value's rendered text is a `long long`, from every storage that
1944
1957
  * can make it one: the value census (`integerValues`), the cell a read names
@@ -5,7 +5,7 @@ import { noInstantiationFacts } from '../../ir/instantiation.js';
5
5
  import { observesEveryCallableIdentity } from '../../ir/callable-identity-demand.js';
6
6
  import { hostCallName, hostMemberOf, statedHostIntrinsicLength } from './host/host-members.js';
7
7
  import { representationKey } from '../../representation/model.js';
8
- import { cppBodyName, cppConstructName, cppNarrowedIntegerType, cppStringLiteral, cppStringViewLiteral, cppTypeOf, cppUndefinedIn, unitFunctionName } from './types.js';
8
+ import { cppBodyName, cppConstructName, cppNarrowedFloatType, cppNarrowedIntegerType, cppStringLiteral, cppStringViewLiteral, cppTypeOf, cppUndefinedIn, unitFunctionName } from './types.js';
9
9
  import { hostBuiltinFunctionIdentityText, hostClassValueText, hostFunctionValueText, hostJsonMemberValueText, hostMemberValueText } from './host/emit-host-value.js';
10
10
  import { createConversionNodes } from '../../conversion/nodes.js';
11
11
  import { createCppConversionRegistry } from './conversions.js';
@@ -103,6 +103,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
103
103
  const numericCallOnly = new Set();
104
104
  const integerValues = new Set();
105
105
  const integerBindings = new Set();
106
+ const float32 = { values: new Set(), bindings: new Set(), arithmetic: new Set() };
106
107
  const typeQueryValues = new Set();
107
108
  const typeQueryBindings = new Set();
108
109
  const typeQueryComparisons = new Map();
@@ -244,6 +245,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
244
245
  numericCallOnly,
245
246
  integerValues,
246
247
  integerBindings,
248
+ float32,
247
249
  typeQueryValues,
248
250
  typeQueryBindings,
249
251
  typeQueryComparisons,
@@ -285,6 +287,7 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
285
287
  numericCallOnly,
286
288
  integerValues,
287
289
  integerBindings,
290
+ float32,
288
291
  typeQueryValues,
289
292
  typeQueryBindings,
290
293
  typeQueryComparisons,
@@ -335,7 +338,20 @@ conversions = null, nativeSelections = undefined, callableIdentityDemand = obser
335
338
  * An explicit spelling always wins: a caller that named the type knows
336
339
  * something this does not.
337
340
  */
338
- export const storageTypeOf = (ctx, value, representation) => ctx.typeQueryValues.has(value) ? 'gea::Value::Tag' : ctx.integerValues.has(value) ? cppNarrowedIntegerType : cppTypeOf(representation);
341
+ export const storageTypeOf = (ctx, value, representation) => ctx.typeQueryValues.has(value)
342
+ ? 'gea::Value::Tag'
343
+ : ctx.integerValues.has(value)
344
+ ? cppNarrowedIntegerType
345
+ : ctx.float32.values.has(value)
346
+ ? cppNarrowedFloatType
347
+ : cppTypeOf(representation);
348
+ /** Whether a value's rendered text is a `float` -- the float32 census's twin of `isIntegerStorageValue`. */
349
+ export const isFloatStorageValue = (ctx, value) => {
350
+ if (ctx.float32.values.has(value))
351
+ return true;
352
+ const declaration = ctx.bindingReadDeclarations.get(value);
353
+ return declaration !== undefined && ctx.float32.bindings.has(declaration) && !ctx.captures.isBoxed(declaration);
354
+ };
339
355
  /**
340
356
  * Whether a value's rendered text is a `long long`, from every storage that
341
357
  * can make it one: the value census (`integerValues`), the cell a read names
@@ -66,7 +66,7 @@ export const staticKeyTextOf = (ctx, key, contextDescription) => {
66
66
  throw createCppEmitBlockedError(`runtime-helper:computation:to-property-key:${contextDescription}`, `${contextDescription} has a key that was not produced by a "constant" operation in this body; this emitter has no dynamic-key path`);
67
67
  };
68
68
  import { dateMemberText } from './prototype/emit-prototype-date.js';
69
- import { arrayAccessText, presentElementText, keyedCollectionMemberText, iteratorMemberText, canonicalIndexLiteral, dictionaryPrototypeMemberRead, memberAccessOperator, positionalRecordArityText, promiseMemberText, keyedTableKeyText, emitRecordIndexSidecarStore, recordIndexSidecarReadText, reactiveRevisionText, scalarMemberText, stringMemberText, symbolMemberText, typedArrayAccessText } from './emit-carrier-members.js';
69
+ import { arrayAccessText, presentElementText, keyedCollectionMemberText, iteratorMemberText, canonicalIndexLiteral, dictionaryPrototypeMemberRead, memberAccessOperator, positionalRecordArityText, promiseMemberText, keyedTableKeyText, emitRecordIndexSidecarStore, recordIndexSidecarReadText, reactiveRevisionText, scalarMemberText, stringMemberText, symbolMemberText, typedArrayAccessText, integerTypedArrayElements } from './emit-carrier-members.js';
70
70
  import { arrayBufferAccessText, dataViewAccessText, sharedArrayBufferAccessText } from './emit-buffers.js';
71
71
  import { functionSourceReadClaimOf } from './function-source-reads.js';
72
72
  import { deferredCallableBuiltinReadClaimOf, recordWithIndexFieldClaimOf } from './property-read-claims.js';
@@ -411,6 +411,15 @@ const denseElementText = (ctx, operation) => {
411
411
  : arrayAccessText(ctx, operation.receiver, operation.key, operation.result);
412
412
  if (general === null || general === '')
413
413
  return null;
414
+ // A `float` result (`ir/floats.ts`) reads a float32 element as the `float`
415
+ // it is: both halves in `float`, so the fast half is a load and no
416
+ // conversion through `double` -- a software routine on a core whose FPU is
417
+ // single-precision only.
418
+ const receiver = operation.receiver.representation;
419
+ if (receiver.kind === 'typed-array' && receiver.element === 'float32' && ctx.float32.values.has(operation.result.id))
420
+ return `(${dense.flag} ? gea::TypedArray<float>::readInBounds(${dense.pointer}, ${dense.index}) : static_cast<float>(${general}))`;
421
+ if (receiver.kind === 'typed-array' && integerTypedArrayElements.has(receiver.element) && ctx.integerValues.has(operation.result.id))
422
+ return `(${dense.flag} ? gea::TypedArray<${cppScalarType(receiver.element)}>::readIntegerInBounds(${dense.pointer}, ${dense.index}) : static_cast<long long>(${general}))`;
414
423
  // The window's flag is a proof of presence, so the fast half is written in
415
424
  // the result's carrier the same way the general half's guarded arm is --
416
425
  // see `presentElementText`. Without it the two arms are a bare element and
@@ -1589,11 +1598,15 @@ const emitFieldStoreLines = (ctx, lines, operation, label) => {
1589
1598
  }
1590
1599
  const dense = denseCellText(ctx, operation);
1591
1600
  const value = operandText(ctx, operation.value);
1592
- const writer = isIntegerStorageValue(ctx, operation.key.value) ? 'setElementAtIndex' : 'setElement';
1601
+ const integerKey = isIntegerStorageValue(ctx, operation.key.value);
1602
+ // An integer value stores its low bits (or itself, rounded once, into a
1603
+ // float view) without the `double` modulo `setElementAtIndex` performs.
1604
+ const integerValue = isIntegerStorageValue(ctx, operation.value.value);
1605
+ const writer = integerKey ? (integerValue ? 'setElementIntegerAtIndex' : 'setElementAtIndex') : 'setElement';
1593
1606
  const general = `${typedArrayReceiver}->${writer}(${operandText(ctx, operation.key)}, ${value});`;
1594
1607
  lines.push(dense === null
1595
1608
  ? general
1596
- : `if (${dense.flag}) gea::TypedArray<${cppScalarType(operation.receiver.representation.element)}>::writeInBounds(${dense.pointer}, ${dense.index}, ${value}); else ${general}`);
1609
+ : `if (${dense.flag}) gea::TypedArray<${cppScalarType(operation.receiver.representation.element)}>::${integerValue ? 'writeIntegerInBounds' : 'writeInBounds'}(${dense.pointer}, ${dense.index}, ${value}); else ${general}`);
1597
1610
  finishTypedArrayStore();
1598
1611
  return;
1599
1612
  }
@@ -17,7 +17,7 @@ import { allOperationsOf } from '../../ir/model.js';
17
17
  import { operandsOfIrOperation, resultOfIrOperation } from '../../ir/queries.js';
18
18
  import { namesMoreThanOnce } from './evaluated-once.js';
19
19
  import { isOpenDocument, representationKey } from '../../representation/model.js';
20
- import { cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineValue, defineValueAlias, directCalleesOf, emptyCaptureIndex, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace } from './emit-context.js';
20
+ import { cppFormalName, cppReceiverName, createCppEmitBlockedError, createEmitContext, defineValue, defineValueAlias, directCalleesOf, emptyCaptureIndex, isFloatStorageValue, isIntegerStorageValue, isCppEmitBlockedError, operandText, storageTypeOf, cppThunkEntryText, sealFactFieldsForRender, suspendsInPlace } from './emit-context.js';
21
21
  import { hostMemberReadsOf } from './host/emit-host-properties.js';
22
22
  import { hostNamespaceReadsOf } from './host-namespace-reads.js';
23
23
  import { functionSourceReadsOf } from './function-source-reads.js';
@@ -833,6 +833,23 @@ const emitCompute = (ctx, lines, operation) => {
833
833
  throw createCppEmitBlockedError(`runtime-helper:computation:binary:${operation.operator}:${first.representation.kind}`, `binary "${operation.operator}" on a "${first.representation.kind}" carrier has no C++ spelling in this emitter`);
834
834
  }
835
835
  const name = defineValue(ctx, operation.result);
836
+ // `ir/floats.ts`: an operation every use of which rounds to float32 is the
837
+ // single-precision operation itself; every other operator promotes a `float`
838
+ // operand back to the double the Number is, or two of them would compute in
839
+ // single precision where ECMA-262 computes in double.
840
+ if (ctx.float32.arithmetic.has(operation.result.id) && spelling.kind === 'infix') {
841
+ // A narrowed integer operand is one `ir/floats.ts` bounded by 2^24, so it
842
+ // fits an int32: converting from that is one instruction, from a
843
+ // `long long` a library call on a 32-bit core.
844
+ const single = (operand) => isIntegerStorageValue(ctx, operand.value)
845
+ ? `static_cast<float>(static_cast<std::int32_t>(${operandText(ctx, operand)}))`
846
+ : `static_cast<float>(${operandText(ctx, operand)})`;
847
+ const computed = `(${single(first)} ${spelling.text} ${single(second)})`;
848
+ // A product is the half of a multiply-add GCC would fuse (`float32Product`).
849
+ lines.push(`${name} = ${spelling.text === '*' ? `gea::float32Product${computed}` : computed};`);
850
+ return;
851
+ }
852
+ const promotedText = (operand) => isFloatStorageValue(ctx, operand.value) ? `static_cast<double>(${operandText(ctx, operand)})` : operandText(ctx, operand);
836
853
  const integral = ctx.integerValues.has(first.value) && ctx.integerValues.has(second.value);
837
854
  // `/` is the one arithmetic operator whose C++ meaning CHANGES when both
838
855
  // operands are integers: `7 / 2` would become 3 rather than 3.5, so two
@@ -841,8 +858,8 @@ const emitCompute = (ctx, lines, operation) => {
841
858
  // remainder is the same answer without the fmod round trip, under its own
842
859
  // name rather than an overload (a mixed call would make a pair ambiguous).
843
860
  const widenForDivision = integral && operation.operator === '/';
844
- const left = widenForDivision ? `static_cast<double>(${operandText(ctx, first)})` : operandText(ctx, first);
845
- const right = widenForDivision ? `static_cast<double>(${operandText(ctx, second)})` : operandText(ctx, second);
861
+ const left = widenForDivision ? `static_cast<double>(${operandText(ctx, first)})` : promotedText(first);
862
+ const right = widenForDivision ? `static_cast<double>(${operandText(ctx, second)})` : promotedText(second);
846
863
  const bounded = integerBoundedComparison(ctx.integerValues, ctx.loopInvariantValues, operation, first, second, left, right);
847
864
  if (bounded !== null) {
848
865
  lines.push(`${name} = ${bounded};`);
@@ -2536,6 +2553,15 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2536
2553
  !ctx.captures.isBoxed(declaration) &&
2537
2554
  !capturedQueryCells.has(declaration));
2538
2555
  },
2556
+ float32Cell: (declaration) => {
2557
+ const placement = ctx.placements.get(declaration);
2558
+ return (placement?.storage.kind === 'local' &&
2559
+ placement.storage.owner === body.sourceOwner &&
2560
+ placement.representation?.kind === 'scalar' &&
2561
+ placement.representation.domain === 'number' &&
2562
+ !ctx.captures.isBoxed(declaration) &&
2563
+ !capturedQueryCells.has(declaration));
2564
+ },
2539
2565
  spellConstants: () => spellConstants(ctx, body),
2540
2566
  formalStorage: (settled) => {
2541
2567
  // The collectors below read these off the context, so they are published
@@ -2570,6 +2596,12 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2570
2596
  prepass.integerValues.add(value);
2571
2597
  for (const declaration of settled.integerBindings)
2572
2598
  prepass.integerBindings.add(declaration);
2599
+ for (const value of settled.float32.values)
2600
+ prepass.float32.values.add(value);
2601
+ for (const declaration of settled.float32.bindings)
2602
+ prepass.float32.bindings.add(declaration);
2603
+ for (const value of settled.float32.arithmetic)
2604
+ prepass.float32.arithmetic.add(value);
2573
2605
  for (const [value, form] of settled.remainderForms)
2574
2606
  prepass.remainderForms.set(value, form);
2575
2607
  for (const value of settled.roundingArithmetic)
@@ -2610,7 +2642,7 @@ virtualDispatch = new Map(), narrowedStorage = { reads: new Map(), integral: new
2610
2642
  collectDirectBindingSinks(prepass, body, hoists.relocated);
2611
2643
  // After the hoists, because a window's own bound is often the loop-invariant
2612
2644
  // read they relocate, and a relocated value is one this may name.
2613
- admitDenseWindows(ctx, prepass, body);
2645
+ admitDenseWindows(ctx, prepass, body, hoists);
2614
2646
  const isSingleBlock = body.blockOrder.length === 1;
2615
2647
  const orderLabels = isSingleBlock ? new Map() : blockLabelsOf(body.blockOrder);
2616
2648
  const owner = sectionOwnerOf(body);
@@ -1,7 +1,7 @@
1
1
  import { usesRealmStorage } from '../realm-storage.js';
2
2
  import { isOpenDocument, representationKey } from '../../../representation/model.js';
3
3
  import { hostMemberTemplateOf, isArrayConstantOf } from '../../../representation/host-templates.js';
4
- import { createCppEmitBlockedError, internSymbolKey, operandText, paddedArguments } from '../emit-context.js';
4
+ import { createCppEmitBlockedError, internSymbolKey, isFloatStorageValue, operandText, paddedArguments } from '../emit-context.js';
5
5
  import { consoleArgumentsText, toStringRefusal, toStringText, toStringTextOver } from '../emit-tostring.js';
6
6
  import { classToNumberText, classToPrimitiveOf, toNumberRefusal, toNumberText } from '../emit-tonumber.js';
7
7
  import { booleanTestText } from '../emit-presence.js';
@@ -1432,6 +1432,15 @@ export const hostCallText = (ctx, operation) => {
1432
1432
  !operation.arguments.every((argument) => argument.representation.kind === 'scalar' && argument.representation.domain === 'number')) {
1433
1433
  throw createCppEmitBlockedError(`host-invocation:${read.protocol}.${read.member}`, 'a deferred numeric host call disagrees with its fixed numeric argument frame');
1434
1434
  }
1435
+ // `Math.fround` of a value `ir/floats.ts` already holds in `float` is that
1436
+ // value: no double to round, and no software double conversion on a core
1437
+ // whose FPU is single-precision only.
1438
+ const only = operation.arguments[0];
1439
+ if (read.protocol === 'Math' &&
1440
+ read.member === 'fround' &&
1441
+ only !== undefined &&
1442
+ (isFloatStorageValue(ctx, only.value) || ctx.float32.arithmetic.has(only.value)))
1443
+ return `static_cast<float>(${operandText(ctx, only)})`;
1435
1444
  return fillHostTemplate(host.numericDirectCall.emit, receiverText, operation.arguments.map((argument) => `static_cast<double>(${operandText(ctx, argument)})`));
1436
1445
  }
1437
1446
  if (!host || host.kind !== 'method') {