@@ -4,21 +4,17 @@ use std::{
44} ;
55
66use oxc:: allocator:: { self , Allocator } ;
7- use oxc:: { semantic:: SymbolId , span:: Atom } ;
8- use oxc_syntax:: operator:: LogicalOperator ;
97
108use crate :: {
119 TreeShakeConfig ,
1210 dep:: { CustomDepTrait , Dep , DepTrait , LazyDep , OnceDep } ,
1311 entity:: Entity ,
14- mangling:: { AlwaysMangableDep , MangleAtom , MangleConstraint , ManglingDep } ,
12+ mangling:: { AlwaysMangableDep , MangleConstraint , ManglingDep } ,
1513 scope:: CfScopeId ,
16- utils:: { CalleeInstanceId , F64WithEq } ,
14+ utils:: CalleeInstanceId ,
1715 value:: {
18- ArgumentsValue , BuiltinFnImplementation , ImplementedBuiltinFnValue , LiteralValue ,
19- ObjectProperty , ObjectPrototype , ObjectValue , PureBuiltinFnValue , literal:: string:: ToAtomRef ,
20- logical_result:: LogicalResultValue , never:: NeverValue , primitive:: PrimitiveValue ,
21- react_element:: ReactElementValue , union:: UnionValues , unknown:: UnknownValue ,
16+ ArgumentsValue , LiteralValue , PureBuiltinFnValue , logical_result:: LogicalResultValue ,
17+ never:: NeverValue , primitive:: PrimitiveValue , union:: UnionValues , unknown:: UnknownValue ,
2218 } ,
2319} ;
2420
@@ -188,63 +184,6 @@ impl<'a> Factory<'a> {
188184 CalleeInstanceId :: from_usize ( id)
189185 }
190186
191- pub fn builtin_object (
192- & self ,
193- prototype : ObjectPrototype < ' a > ,
194- consumable : bool ,
195- ) -> & ' a mut ObjectValue < ' a > {
196- self . alloc ( ObjectValue {
197- consumable,
198- consumed : Cell :: new ( false ) ,
199- consumed_as_prototype : Cell :: new ( false ) ,
200- cf_scope : self . root_cf_scope . unwrap ( ) ,
201- keyed : allocator:: HashMap :: new_in ( self . allocator ) . into ( ) ,
202- unknown : ObjectProperty :: new_in ( self . allocator ) . into ( ) ,
203- rest : Default :: default ( ) ,
204- prototype : Cell :: new ( prototype) ,
205- mangling_group : Cell :: new ( None ) ,
206- } )
207- }
208-
209- pub fn arguments (
210- & self ,
211- elements : & ' a [ Entity < ' a > ] ,
212- rest : Option < Entity < ' a > > ,
213- ) -> ArgumentsValue < ' a > {
214- ArgumentsValue { elements, rest }
215- }
216-
217- pub fn implemented_builtin_fn < F : BuiltinFnImplementation < ' a > + ' a > (
218- & self ,
219- name : & ' static str ,
220- implementation : F ,
221- ) -> Entity < ' a > {
222- self
223- . alloc ( ImplementedBuiltinFnValue {
224- name,
225- implementation,
226- statics : None ,
227- consumed : Cell :: new ( true ) ,
228- } )
229- . into ( )
230- }
231-
232- pub fn implemented_builtin_fn_with_statics < F : BuiltinFnImplementation < ' a > + ' a > (
233- & self ,
234- name : & ' static str ,
235- implementation : F ,
236- statics : & ' a ObjectValue < ' a > ,
237- ) -> Entity < ' a > {
238- self
239- . alloc ( ImplementedBuiltinFnValue {
240- name,
241- implementation,
242- statics : Some ( statics) ,
243- consumed : Cell :: new ( true ) ,
244- } )
245- . into ( )
246- }
247-
248187 pub fn dep_no_once ( & self , dep : impl CustomDepTrait < ' a > + ' a ) -> Dep < ' a > {
249188 Dep ( self . alloc ( dep) )
250189 }
@@ -276,71 +215,6 @@ impl<'a> Factory<'a> {
276215 }
277216 }
278217
279- pub fn mangable_string ( & self , value : impl ToAtomRef < ' a > , atom : MangleAtom ) -> Entity < ' a > {
280- self . string ( value, Some ( atom) )
281- }
282-
283- pub fn unmangable_string ( & self , value : impl ToAtomRef < ' a > ) -> Entity < ' a > {
284- self . string ( value, None )
285- }
286-
287- pub fn string ( & self , value : impl ToAtomRef < ' a > , atom : Option < MangleAtom > ) -> Entity < ' a > {
288- if atom. is_some ( ) {
289- self . alloc ( LiteralValue :: String ( value. to_atom_ref ( self . allocator ) , atom) ) . into ( )
290- } else {
291- value. to_atom_ref ( self . allocator ) . into ( )
292- }
293- }
294-
295- pub fn number ( & self , value : impl Into < F64WithEq > ) -> Entity < ' a > {
296- self . alloc ( LiteralValue :: Number ( value. into ( ) ) ) . into ( )
297- }
298- pub fn big_int ( & self , value : & ' a Atom < ' a > ) -> Entity < ' a > {
299- self . alloc ( LiteralValue :: BigInt ( value) ) . into ( )
300- }
301-
302- pub fn boolean ( & self , value : bool ) -> Entity < ' a > {
303- if value { self . r#true } else { self . r#false }
304- }
305- pub fn boolean_maybe_unknown ( & self , value : Option < bool > ) -> Entity < ' a > {
306- if let Some ( value) = value { self . boolean ( value) } else { self . unknown_boolean }
307- }
308-
309- pub fn symbol ( & self , id : SymbolId , str_rep : & ' a Atom < ' a > ) -> Entity < ' a > {
310- self . alloc ( LiteralValue :: Symbol ( id, str_rep) ) . into ( )
311- }
312-
313- /// Only used when (maybe_left, maybe_right) == (true, true)
314- pub fn logical_result (
315- & self ,
316- left : Entity < ' a > ,
317- right : Entity < ' a > ,
318- operator : LogicalOperator ,
319- ) -> Entity < ' a > {
320- let value = self . union ( ( left, right) ) ;
321- let result = match operator {
322- LogicalOperator :: Or => match right. test_truthy ( ) {
323- Some ( true ) => true ,
324- _ => return value,
325- } ,
326- LogicalOperator :: And => match right. test_truthy ( ) {
327- Some ( false ) => false ,
328- _ => return value,
329- } ,
330- LogicalOperator :: Coalesce => match right. test_nullish ( ) {
331- Some ( false ) => false ,
332- _ => return value,
333- } ,
334- } ;
335- self
336- . alloc ( LogicalResultValue {
337- value,
338- is_coalesce : operator == LogicalOperator :: Coalesce ,
339- result,
340- } )
341- . into ( )
342- }
343-
344218 pub fn try_union < V : UnionValues < ' a > + Debug + ' a > ( & self , values : V ) -> Option < Entity < ' a > > {
345219 match values. len ( ) {
346220 0 => None ,
@@ -381,17 +255,6 @@ impl<'a> Factory<'a> {
381255 LazyDep ( self . alloc ( RefCell :: new ( Some ( deps) ) ) )
382256 }
383257
384- pub fn react_element ( & self , tag : Entity < ' a > , props : Entity < ' a > ) -> Entity < ' a > {
385- self
386- . alloc ( ReactElementValue {
387- consumed : Cell :: new ( false ) ,
388- tag,
389- props,
390- deps : RefCell :: new ( self . vec ( ) ) ,
391- } )
392- . into ( )
393- }
394-
395258 pub fn mangable (
396259 & self ,
397260 val : Entity < ' a > ,
0 commit comments