Skip to content

Commit 6c56824

Browse files
committed
Move curried types to constants
1 parent 9467509 commit 6c56824

File tree

16 files changed

+47
-57
lines changed

16 files changed

+47
-57
lines changed

packages/@glimmer-workspace/integration-tests/lib/modes/jit/register.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import type {
66
TemplateFactory,
77
} from '@glimmer/interfaces';
88
import type { CurriedValue } from '@glimmer/runtime';
9+
import { CURRIED_COMPONENT } from '@glimmer/constants';
910
import {
1011
getInternalComponentManager,
1112
setComponentTemplate,
1213
setInternalHelperManager,
1314
setInternalModifierManager,
1415
} from '@glimmer/manager';
1516
import { curry, templateOnlyComponent } from '@glimmer/runtime';
16-
import { CurriedTypes } from '@glimmer/vm';
1717

1818
import type { ComponentKind, ComponentTypes } from '../../components';
1919
import type { UserHelper } from '../../helpers';
@@ -168,11 +168,5 @@ export function componentHelper(
168168

169169
if (definition === null) return null;
170170

171-
return curry(
172-
CurriedTypes.Component,
173-
constants.resolvedComponent(definition, name),
174-
{},
175-
null,
176-
true
177-
);
171+
return curry(CURRIED_COMPONENT, constants.resolvedComponent(definition, name), {}, null, true);
178172
}

packages/@glimmer/compiler/lib/passes/1-normalization/keywords/append.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { CURRIED_COMPONENT, CURRIED_HELPER } from '@glimmer/constants';
12
import { ASTv2, generateSyntaxError, src } from '@glimmer/syntax';
2-
import { CurriedTypes } from '@glimmer/vm';
33

44
import type { NormalizationState } from '../context';
55

@@ -103,7 +103,7 @@ export const APPEND_KEYWORDS = keywords('Append')
103103
},
104104
})
105105
.kw('component', {
106-
assert: assertCurryKeyword(CurriedTypes.Component),
106+
assert: assertCurryKeyword(CURRIED_COMPONENT),
107107

108108
translate(
109109
{ node, state }: { node: ASTv2.AppendContent; state: NormalizationState },
@@ -124,7 +124,7 @@ export const APPEND_KEYWORDS = keywords('Append')
124124
},
125125
})
126126
.kw('helper', {
127-
assert: assertCurryKeyword(CurriedTypes.Helper),
127+
assert: assertCurryKeyword(CURRIED_HELPER),
128128

129129
translate(
130130
{ node, state }: { node: ASTv2.AppendContent; state: NormalizationState },

packages/@glimmer/compiler/lib/passes/1-normalization/keywords/block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ASTv2 } from '@glimmer/syntax';
2+
import { CURRIED_COMPONENT } from '@glimmer/constants';
23
import { generateSyntaxError } from '@glimmer/syntax';
3-
import { CurriedTypes } from '@glimmer/vm';
44

55
import type { NormalizationState } from '../context';
66

@@ -362,7 +362,7 @@ export const BLOCK_KEYWORDS = keywords('Block')
362362
},
363363
})
364364
.kw('component', {
365-
assert: assertCurryKeyword(CurriedTypes.Component),
365+
assert: assertCurryKeyword(CURRIED_COMPONENT),
366366

367367
translate(
368368
{ node, state }: { node: ASTv2.InvokeBlock; state: NormalizationState },

packages/@glimmer/compiler/lib/passes/1-normalization/keywords/call.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CurriedTypes } from '@glimmer/vm';
1+
import { CURRIED_COMPONENT, CURRIED_HELPER, CURRIED_MODIFIER } from '@glimmer/constants';
22

33
import { keywords } from './impl';
44
import { curryKeyword } from './utils/curry';
@@ -14,6 +14,6 @@ export const CALL_KEYWORDS = keywords('Call')
1414
.kw('log', logKeyword)
1515
.kw('if', ifUnlessInlineKeyword('if'))
1616
.kw('unless', ifUnlessInlineKeyword('unless'))
17-
.kw('component', curryKeyword(CurriedTypes.Component))
18-
.kw('helper', curryKeyword(CurriedTypes.Helper))
19-
.kw('modifier', curryKeyword(CurriedTypes.Modifier));
17+
.kw('component', curryKeyword(CURRIED_COMPONENT))
18+
.kw('helper', curryKeyword(CURRIED_HELPER))
19+
.kw('modifier', curryKeyword(CURRIED_MODIFIER));

packages/@glimmer/compiler/lib/passes/1-normalization/keywords/utils/curry.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { CurriedType } from '@glimmer/interfaces';
2+
import { CURRIED_COMPONENT, CURRIED_HELPER, CURRIED_MODIFIER } from '@glimmer/constants';
23
import { ASTv2, generateSyntaxError } from '@glimmer/syntax';
3-
import { CurriedTypes } from '@glimmer/vm';
44

55
import type { NormalizationState } from '../../context';
66
import type { KeywordDelegate } from '../impl';
@@ -10,9 +10,9 @@ import * as mir from '../../../2-encoding/mir';
1010
import { VISIT_EXPRS } from '../../visitors/expressions';
1111

1212
const CurriedTypeToReadableType = {
13-
[CurriedTypes.Component]: 'component',
14-
[CurriedTypes.Helper]: 'helper',
15-
[CurriedTypes.Modifier]: 'modifier',
13+
[CURRIED_COMPONENT]: 'component',
14+
[CURRIED_HELPER]: 'helper',
15+
[CURRIED_MODIFIER]: 'modifier',
1616
} as const;
1717

1818
export function assertCurryKeyword(curriedType: CurriedType) {
@@ -24,7 +24,7 @@ export function assertCurryKeyword(curriedType: CurriedType) {
2424
args: ASTv2.Args;
2525
}> => {
2626
let readableType = CurriedTypeToReadableType[curriedType];
27-
let stringsAllowed = curriedType === CurriedTypes.Component;
27+
let stringsAllowed = curriedType === CURRIED_COMPONENT;
2828

2929
let { args } = node;
3030

packages/@glimmer/compiler/lib/passes/1-normalization/visitors/strict-mode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { HasSourceSpan } from '@glimmer/syntax';
2+
import { CURRIED_COMPONENT, CURRIED_HELPER } from '@glimmer/constants';
23
import { generateSyntaxError, loc } from '@glimmer/syntax';
3-
import { CurriedTypes } from '@glimmer/vm';
44

55
import type { Result } from '../../../shared/result';
66
import type * as mir from '../../2-encoding/mir';
@@ -363,9 +363,9 @@ export default class StrictModeValidationPass {
363363
Curry(expression: mir.Curry): Result<null> {
364364
let resolution: ResolutionType;
365365

366-
if (expression.curriedType === CurriedTypes.Component) {
366+
if (expression.curriedType === CURRIED_COMPONENT) {
367367
resolution = COMPONENT_RESOLUTION;
368-
} else if (expression.curriedType === CurriedTypes.Helper) {
368+
} else if (expression.curriedType === CURRIED_HELPER) {
369369
resolution = HELPER_RESOLUTION;
370370
} else {
371371
resolution = MODIFIER_RESOLUTION;

packages/@glimmer/compiler/lib/wire-format-debug.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import type {
55
SerializedTemplateBlock,
66
WireFormat,
77
} from '@glimmer/interfaces';
8+
import { CURRIED_COMPONENT, CURRIED_HELPER, CURRIED_MODIFIER } from '@glimmer/constants';
89
import { exhausted } from '@glimmer/debug-util';
910
import { dict } from '@glimmer/util';
10-
import { CurriedTypes } from '@glimmer/vm';
1111
import { SexpOpcodes as Op } from '@glimmer/wire-format';
1212

1313
import { inflateAttrName, inflateTagName } from './utils';
@@ -248,11 +248,11 @@ export default class WireFormatDebugger {
248248

249249
private formatCurryType(value: CurriedType) {
250250
switch (value) {
251-
case CurriedTypes.Component:
251+
case CURRIED_COMPONENT:
252252
return 'component';
253-
case CurriedTypes.Helper:
253+
case CURRIED_HELPER:
254254
return 'helper';
255-
case CurriedTypes.Modifier:
255+
case CURRIED_MODIFIER:
256256
return 'modifier';
257257
default:
258258
throw exhausted(value);

packages/@glimmer/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './lib/builder-constants';
2+
export * from './lib/curried';
23
export * from './lib/dom';
34
export * from './lib/immediate';
45
export * from './lib/syscall-ops';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { CurriedComponent, CurriedHelper, CurriedModifier } from '@glimmer/interfaces';
2+
3+
export const CURRIED_COMPONENT = 0 satisfies CurriedComponent;
4+
export const CURRIED_HELPER = 1 satisfies CurriedHelper;
5+
export const CURRIED_MODIFIER = 2 satisfies CurriedModifier;

packages/@glimmer/runtime/lib/compiled/opcodes/component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
} from '@glimmer/interfaces';
2727
import type { Reference } from '@glimmer/reference';
2828
import {
29+
CURRIED_COMPONENT,
2930
VM_BEGIN_COMPONENT_TRANSACTION_OP,
3031
VM_CAPTURE_ARGS_OP,
3132
VM_COMMIT_COMPONENT_TRANSACTION_OP,
@@ -70,7 +71,7 @@ import { registerDestructor } from '@glimmer/destroyable';
7071
import { managerHasCapability } from '@glimmer/manager';
7172
import { isConstRef, valueForRef } from '@glimmer/reference';
7273
import { assign, dict, EMPTY_STRING_ARRAY, enumerate } from '@glimmer/util';
73-
import { $t0, $t1, CurriedTypes, InternalComponentCapabilities } from '@glimmer/vm';
74+
import { $t0, $t1, InternalComponentCapabilities } from '@glimmer/vm';
7475

7576
import type { CurriedValue } from '../../curried-value';
7677
import type { UpdatingVM } from '../../vm';
@@ -270,7 +271,7 @@ APPEND_OPCODES.add(VM_PREPARE_ARGS_OP, (vm, { op1: register }) => {
270271

271272
let { definition } = instance;
272273

273-
if (isCurriedType(definition, CurriedTypes.Component)) {
274+
if (isCurriedType(definition, CURRIED_COMPONENT)) {
274275
assert(
275276
!definition.manager,
276277
"If the component definition was curried, we don't yet have a manager"

0 commit comments

Comments
 (0)