@@ -8,12 +8,6 @@ import { TupleExpression } from '../slang-nodes/TupleExpression.js';
88import { TupleValues } from '../slang-nodes/TupleValues.js' ;
99import { TupleValue } from '../slang-nodes/TupleValue.js' ;
1010
11- const objectConfig = {
12- writable : true ,
13- enumerable : true ,
14- configurable : true
15- } ;
16-
1711export function createHugFunction (
1812 huggableOperators : string [ ]
1913) : ( node : Expression ) => Expression {
@@ -26,42 +20,39 @@ export function createHugFunction(
2620 ) {
2721 const { loc } = node ;
2822
29- return Object . create ( Expression . prototype , {
30- kind : { value : NonterminalKind . Expression , ...objectConfig } ,
31- loc : { value : { ...loc } , ...objectConfig } ,
32- comments : { value : [ ] , ...objectConfig } ,
33- variant : {
34- value : Object . create ( TupleExpression . prototype , {
35- kind : { value : NonterminalKind . TupleExpression , ...objectConfig } ,
36- loc : { value : { ...loc } , ...objectConfig } ,
37- comments : { value : [ ] , ...objectConfig } ,
38- items : {
39- value : Object . create ( TupleValues . prototype , {
40- kind : { value : NonterminalKind . TupleValues , ...objectConfig } ,
41- loc : { value : { ...loc } , ...objectConfig } ,
42- comments : { value : [ ] , ...objectConfig } ,
43- items : {
44- value : [
45- Object . create ( TupleValue . prototype , {
46- kind : {
47- value : NonterminalKind . TupleValue ,
48- ...objectConfig
49- } ,
50- loc : { value : { ...loc } , ...objectConfig } ,
51- comments : { value : [ ] , ...objectConfig } ,
52- expression : { value : node , ...objectConfig }
53- } ) as TupleValue
54- ] ,
55- ...objectConfig
56- } ,
57- separators : { value : [ ] , ...objectConfig }
58- } ) as TupleValues ,
59- ...objectConfig
60- }
61- } ) as TupleExpression ,
62- ...objectConfig
63- }
64- } ) as Expression ;
23+ return Object . assign ( Object . create ( Expression . prototype ) as Expression , {
24+ kind : NonterminalKind . Expression ,
25+ loc : { ...loc } ,
26+ comments : [ ] ,
27+ variant : Object . assign (
28+ Object . create ( TupleExpression . prototype ) as TupleExpression ,
29+ {
30+ kind : NonterminalKind . TupleExpression ,
31+ loc : { ...loc } ,
32+ comments : [ ] ,
33+ items : Object . assign (
34+ Object . create ( TupleValues . prototype ) as TupleValues ,
35+ {
36+ kind : NonterminalKind . TupleValues ,
37+ loc : { ...loc } ,
38+ comments : [ ] ,
39+ items : [
40+ Object . assign (
41+ Object . create ( TupleValue . prototype ) as TupleValue ,
42+ {
43+ kind : NonterminalKind . TupleValue ,
44+ loc : { ...loc } ,
45+ comments : [ ] ,
46+ expression : node
47+ }
48+ )
49+ ] ,
50+ separators : [ ]
51+ }
52+ )
53+ }
54+ )
55+ } ) ;
6556 }
6657
6758 return node ;
0 commit comments