@@ -2,10 +2,13 @@ use super::{
2
2
consumed_object, never:: NeverEntity , Entity , EntityFactory , EntityTrait , EnumeratedProperties ,
3
3
IteratedElements , ObjectEntity , ObjectPrototype , TypeofResult ,
4
4
} ;
5
- use crate :: { analyzer:: Analyzer , consumable:: Consumable } ;
5
+ use crate :: {
6
+ analyzer:: Analyzer ,
7
+ consumable:: { Consumable , ConsumableTrait } ,
8
+ } ;
6
9
use std:: fmt:: Debug ;
7
10
8
- pub trait BuiltinFnEntity < ' a > : Debug {
11
+ trait BuiltinFnEntity < ' a > : ConsumableTrait < ' a > {
9
12
#[ cfg( feature = "flame" ) ]
10
13
fn name ( & self ) -> & ' static str ;
11
14
fn object ( & self ) -> Option < & ' a ObjectEntity < ' a > > {
@@ -21,12 +24,6 @@ pub trait BuiltinFnEntity<'a>: Debug {
21
24
}
22
25
23
26
impl < ' a , T : BuiltinFnEntity < ' a > > EntityTrait < ' a > for T {
24
- fn consume ( & ' a self , analyzer : & mut Analyzer < ' a > ) {
25
- if let Some ( object) = self . object ( ) {
26
- object. consume ( analyzer) ;
27
- }
28
- }
29
-
30
27
fn unknown_mutate ( & ' a self , _analyzer : & mut Analyzer < ' a > , _dep : Consumable < ' a > ) {
31
28
// No effect
32
29
}
@@ -194,6 +191,16 @@ impl<'a, F: BuiltinFnImplementation<'a> + 'a> Debug for ImplementedBuiltinFnEnti
194
191
}
195
192
}
196
193
194
+ impl < ' a , F : BuiltinFnImplementation < ' a > + ' a > ConsumableTrait < ' a >
195
+ for ImplementedBuiltinFnEntity < ' a , F >
196
+ {
197
+ fn consume ( & self , analyzer : & mut Analyzer < ' a > ) {
198
+ if let Some ( object) = self . object ( ) {
199
+ object. consume ( analyzer) ;
200
+ }
201
+ }
202
+ }
203
+
197
204
impl < ' a , F : BuiltinFnImplementation < ' a > + ' a > BuiltinFnEntity < ' a >
198
205
for ImplementedBuiltinFnEntity < ' a , F >
199
206
{
@@ -238,6 +245,14 @@ pub struct PureBuiltinFnEntity<'a> {
238
245
return_value : fn ( & EntityFactory < ' a > ) -> Entity < ' a > ,
239
246
}
240
247
248
+ impl < ' a > ConsumableTrait < ' a > for PureBuiltinFnEntity < ' a > {
249
+ fn consume ( & self , analyzer : & mut Analyzer < ' a > ) {
250
+ if let Some ( object) = self . object ( ) {
251
+ object. consume ( analyzer) ;
252
+ }
253
+ }
254
+ }
255
+
241
256
impl < ' a > BuiltinFnEntity < ' a > for PureBuiltinFnEntity < ' a > {
242
257
#[ cfg( feature = "flame" ) ]
243
258
fn name ( & self ) -> & ' static str {
0 commit comments