2019-02-05 02:44:07 +02:00
[ I n t e r : : ] I n t e r in M e m o r y .
To s t o r e b y t e c o d e - l i k e i n t e r m e d i a t e code in m e m o r y .
@ h B y t e c o d e d e f i n i t i o n .
@ d i n t e r _ t u n s i g n e d int
@ d s i g n e d _ i n t e r _ t int
@ h C h u n k s .
@ d I S T _ S I Z E 100
@ d S Y M B O L _ B A S E _ V A L 0x40000000
@ d P R E F R A M E _ S K I P _ A M O U N T 0
@ d P R E F R A M E _ V E R I F I C A T I O N _ C O U N T 1
@ d P R E F R A M E _ O R I G I N 2
@ d P R E F R A M E _ C O M M E N T 3
@ d P R E F R A M E _ P A C K A G E 4
2019-07-09 12:32:05 +03:00
@ d P R E F R A M E _ P A R E N T 5
@ d P R E F R A M E _ C H I L D 6
@ d P R E F R A M E _ P R E V I O U S 7
@ d P R E F R A M E _ N E X T 8
@ d P R E F R A M E _ L I S T 9
@ d P R E F R A M E _ S I Z E 10
2019-02-05 02:44:07 +02:00
=
t y p e def s t r u c t i n t e r _ r e p o s i t o r y {
int r e f ;
s t r u c t i n t e r _ r e p o s i t o r y _ s e g m e n t * f i r s t _ r e p o _ s e g m e n t ;
int size ;
int c a p a c i t y ;
s t r u c t i n t e r _ r e s o u r c e _ h o l d e r * s t o r e d _ r e s o u r c e s ;
s t r u c t filename * o r i g i n _ f i l e ;
2019-07-08 13:21:00 +03:00
s t r u c t i n t e r _ f r a m e _ l i s t g l o b a l _ m a t e r i a l ;
s t r u c t i n t e r _ f r a m e _ l i s t r e s i d u e ;
2019-02-05 02:44:07 +02:00
s t r u c t i n t e r _ r e p o s i t o r y * m a i n _ r e p o ;
s t r u c t i n t e r _ p a c k a g e * m a i n _ p a c k a g e ;
M E M O R Y _ M A N A G E M E N T
} i n t e r _ r e p o s i t o r y ;
t y p e def s t r u c t i n t e r _ r e s o u r c e _ h o l d e r {
s t r u c t i n t e r _ s y m b o l s _ t a b l e * s t o r e d _ s y m b o l s _ t a b l e ;
s t r u c t i n t e r _ f r a m e _ l i s t s t o r e d _ f r a m e _ l i s t ;
s t r u c t i n t e r _ p a c k a g e * s t o r e d _ p a c k a g e ;
s t r u c t t e x t _ s t r e a m * s t o r e d _ t e x t _ s t r e a m ;
void * s t o r e d _ r e f ;
} i n t e r _ r e s o u r c e _ h o l d e r ;
t y p e def s t r u c t i n t e r _ f r a m e _ l i s t {
int s t o r a g e _ u s e d ;
int s t o r a g e _ c a p a c i t y ;
s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y * s p a r e _ s t o r a g e ;
s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y * f i r s t _ i n _ i f l ;
s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y * l a s t _ i n _ i f l ;
} i n t e r _ f r a m e _ l i s t ;
t y p e def s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y {
s t r u c t i n t e r _ f r a m e l i s t e d _ f r a m e ;
s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y * n e x t _ i n _ i f l ;
s t r u c t i n t e r _ f r a m e _ l i s t _ e n t r y * p r e v _ i n _ i f l ;
} i n t e r _ f r a m e _ l i s t _ e n t r y ;
t y p e def s t r u c t i n t e r _ r e p o s i t o r y _ s e g m e n t {
s t r u c t i n t e r _ r e p o s i t o r y * o w n i n g _ r e p o ;
int size ;
int c a p a c i t y ;
i n t e r _ t * b y t e c o d e ;
s t r u c t i n t e r _ r e p o s i t o r y _ s e g m e n t * n e x t _ r e p o _ s e g m e n t ;
M E M O R Y _ M A N A G E M E N T
} i n t e r _ r e p o s i t o r y _ s e g m e n t ;
@ =
i n t e r _ r e p o s i t o r y * I n t e r : : create ( int r e f , int c a p a c i t y ) {
i n t e r _ r e p o s i t o r y * I = CREATE ( i n t e r _ r e p o s i t o r y ) ;
I - > r e f = r e f ;
I - > f i r s t _ r e p o _ s e g m e n t = I n t e r : : c r e a t e _ s e g m e n t ( c a p a c i t y , I ) ;
I - > size = 1 ;
I - > c a p a c i t y = 0 ;
I - > s t o r e d _ r e s o u r c e s = NULL ;
I - > o r i g i n _ f i l e = NULL ;
I n t e r : : c r e a t e _ s y m b o l s _ t a b l e ( I ) ;
2019-07-08 13:21:00 +03:00
I - > g l o b a l _ m a t e r i a l . s p a r e _ s t o r a g e = NULL ;
I - > g l o b a l _ m a t e r i a l . s t o r a g e _ u s e d = 0 ;
I - > g l o b a l _ m a t e r i a l . s t o r a g e _ c a p a c i t y = 0 ;
I - > r e s i d u e . s p a r e _ s t o r a g e = NULL ;
I - > r e s i d u e . s t o r a g e _ u s e d = 0 ;
I - > r e s i d u e . s t o r a g e _ c a p a c i t y = 0 ;
2019-02-05 02:44:07 +02:00
I - > m a i n _ r e p o = NULL ;
I - > m a i n _ p a c k a g e = NULL ;
return I ;
}
i n t e r _ r e p o s i t o r y _ s e g m e n t * I n t e r : : c r e a t e _ s e g m e n t ( int c a p a c i t y , i n t e r _ r e p o s i t o r y * owner ) {
i n t e r _ r e p o s i t o r y _ s e g m e n t * IS = CREATE ( i n t e r _ r e p o s i t o r y _ s e g m e n t ) ;
I S - > o w n i n g _ r e p o = owner ;
I S - > size = 0 ;
I S - > c a p a c i t y = c a p a c i t y ;
I S - > b y t e c o d e = ( i n t e r _ t * )
M e m o r y : : I 7 _ c a l l o c ( c a p a c i t y , s i z e o f ( i n t e r _ t ) , I N T E R _ B Y T E C O D E _ M R E A S O N ) ;
L O G I F ( I N T E R _ M E M O R Y , "Created repository %d segment %d with capacity %d\n" ,
o w n e r - > a l l o c a t i o n _ i d , I S - > a l l o c a t i o n _ i d , I S - > c a p a c i t y ) ;
return IS ;
}
int I n t e r : : e n l a r g e _ s i z e ( int n , int a t _ l e a s t ) {
int n e x t _ s i z e = 2 * n ;
if ( n e x t _ s i z e < 128 ) n e x t _ s i z e = 128 ;
while ( n + a t _ l e a s t > n e x t _ s i z e ) n e x t _ s i z e = 2 * n e x t _ s i z e ;
return n e x t _ s i z e ;
}
i n t e r _ f r a m e I n t e r : : f i n d _ r o o m ( i n t e r _ r e p o s i t o r y * I , int n , i n t e r _ e r r o r _ l o c a t i o n * e l o c , i n t e r _ p a c k a g e * owner ) {
if ( I = = NULL ) i n t e r n a l _ e r r o r ( "no repository" ) ;
i n t e r _ r e p o s i t o r y _ s e g m e n t * IS = I - > f i r s t _ r e p o _ s e g m e n t ;
while ( I S - > n e x t _ r e p o _ s e g m e n t ) IS = I S - > n e x t _ r e p o _ s e g m e n t ;
i n t e r _ f r a m e F = I n t e r : : f i n d _ r o o m _ i n _ s e g m e n t ( IS , n ) ;
F . r e p o _ s e g m e n t - > b y t e c o d e [ F . index + P R E F R A M E _ O R I G I N ] = I n t e r : : s t o r e _ o r i g i n ( I , e l o c ) ;
I n t e r : : Frame : : a t t a c h _ p a c k a g e ( F , I n t e r : : P a c k a g e s : : t o _ P I D ( owner ) ) ;
return F ;
}
void I n t e r : : d u m p _ s e g m e n t s ( O U T P U T _ S T R E A M , i n t e r _ r e p o s i t o r y * I ) {
for ( i n t e r _ r e p o s i t o r y _ s e g m e n t * J = I - > f i r s t _ r e p o _ s e g m e n t ; J ; J = J - > n e x t _ r e p o _ s e g m e n t ) {
WRITE ( "%08x: size %d capacity %d: " , ( l o n g int ) J , J - > size , J - > c a p a c i t y ) ;
for ( int i = 0 ; i < J - > size ; i + + ) {
WRITE ( "%08x " , J - > b y t e c o d e [ i ] ) ;
}
WRITE ( "\n" ) ;
}
}
void I n t e r : : c h e c k _ s e g m e n t s ( i n t e r _ r e p o s i t o r y * I ) {
for ( i n t e r _ r e p o s i t o r y _ s e g m e n t * J = I - > f i r s t _ r e p o _ s e g m e n t ; J ; J = J - > n e x t _ r e p o _ s e g m e n t ) {
if ( ( J - > size > 0 ) && (J->bytecode[0] == 0)) {
W R I T E _ T O ( S T D E R R , "Repository segment %d is corrupt\n" , J - > a l l o c a t i o n _ i d ) ;
i n t e r n a l _ e r r o r ( "segment corrupt" ) ;
}
}
}
i n t e r _ f r a m e I n t e r : : f i n d _ r o o m _ i n _ s e g m e n t ( i n t e r _ r e p o s i t o r y _ s e g m e n t * IS , int n ) {
if ( ( I S - > size < 0 ) | | ( I S - > size > I S - > c a p a c i t y ) ) i n t e r n a l _ e r r o r ( "bad segment" ) ;
if ( I S - > n e x t _ r e p o _ s e g m e n t ! = NULL ) i n t e r n a l _ e r r o r ( "nonfinal segment" ) ;
if ( I S - > size + n + P R E F R A M E _ S I Z E > I S - > c a p a c i t y ) {
int n e x t _ s i z e = I n t e r : : e n l a r g e _ s i z e ( I S - > c a p a c i t y , n + P R E F R A M E _ S I Z E ) ;
I S - > c a p a c i t y = I S - > size ;
I S - > n e x t _ r e p o _ s e g m e n t = I n t e r : : c r e a t e _ s e g m e n t ( n e x t _ s i z e , I S - > o w n i n g _ r e p o ) ;
IS = I S - > n e x t _ r e p o _ s e g m e n t ;
I n t e r : : c h e c k _ s e g m e n t s ( I S - > o w n i n g _ r e p o ) ;
}
int at = I S - > size ;
I S - > b y t e c o d e [ at + P R E F R A M E _ S K I P _ A M O U N T ] = ( i n t e r _ t ) ( n + P R E F R A M E _ S I Z E ) ;
I S - > b y t e c o d e [ at + P R E F R A M E _ V E R I F I C A T I O N _ C O U N T ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ O R I G I N ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ C O M M E N T ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ P A C K A G E ] = 0 ;
2019-07-09 12:32:05 +03:00
I S - > b y t e c o d e [ at + P R E F R A M E _ P A R E N T ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ C H I L D ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ P R E V I O U S ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ N E X T ] = 0 ;
I S - > b y t e c o d e [ at + P R E F R A M E _ L I S T ] = 0 ;
2019-02-05 02:44:07 +02:00
for ( int i = 0 ; i < n ; i + + ) I S - > b y t e c o d e [ at + P R E F R A M E _ S I Z E + i ] = 0 ;
I S - > size + = n + P R E F R A M E _ S I Z E ;
i n t e r _ f r a m e F = I n t e r : : Frame : : a r o u n d ( IS , at ) ;
return F ;
}
i n t e r _ t I n t e r : : c r e a t e _ r e s o u r c e ( i n t e r _ r e p o s i t o r y * I ) {
if ( I = = NULL ) i n t e r n a l _ e r r o r ( "no repository" ) ;
if ( I - > size > = I - > c a p a c i t y ) {
int n e w _ s i z e = 128 ;
while ( n e w _ s i z e < 2 * I - > c a p a c i t y ) n e w _ s i z e = 2 * n e w _ s i z e ;
L O G I F ( I N T E R _ M E M O R Y , "Giving repository %d frame list of size %d (up from %d)\n" ,
I - > a l l o c a t i o n _ i d , n e w _ s i z e , I - > c a p a c i t y ) ;
i n t e r _ r e s o u r c e _ h o l d e r * s t o r a g e = ( i n t e r _ r e s o u r c e _ h o l d e r * ) M e m o r y : : I 7 _ c a l l o c ( n e w _ s i z e , s i z e o f ( i n t e r _ r e s o u r c e _ h o l d e r ) , I N T E R _ L I N K S _ M R E A S O N ) ;
i n t e r _ r e s o u r c e _ h o l d e r * old = I - > s t o r e d _ r e s o u r c e s ;
for ( int i = 0 ; i < I - > c a p a c i t y ; i + + ) s t o r a g e [ i ] = old [ i ] ;
if ( I - > c a p a c i t y > 0 )
M e m o r y : : I 7 _ f r e e ( old , I N T E R _ L I N K S _ M R E A S O N , I - > c a p a c i t y ) ;
I - > s t o r e d _ r e s o u r c e s = s t o r a g e ;
I - > c a p a c i t y = n e w _ s i z e ;
}
int n = I - > size + + ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ s y m b o l s _ t a b l e = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ r e f = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ p a c k a g e = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ t e x t _ s t r e a m = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ f r a m e _ l i s t . s p a r e _ s t o r a g e = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ f r a m e _ l i s t . s t o r a g e _ u s e d = 0 ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ f r a m e _ l i s t . s t o r a g e _ c a p a c i t y = 0 ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ f r a m e _ l i s t . f i r s t _ i n _ i f l = NULL ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ f r a m e _ l i s t . l a s t _ i n _ i f l = NULL ;
return ( i n t e r _ t ) n ;
}
i n t e r _ t I n t e r : : c r e a t e _ s y m b o l s _ t a b l e ( i n t e r _ r e p o s i t o r y * I ) {
i n t e r _ t n = I n t e r : : c r e a t e _ r e s o u r c e ( I ) ;
if ( I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ s y m b o l s _ t a b l e = = NULL ) {
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ s y m b o l s _ t a b l e = I n t e r : : S y m b o l s T a b l e s : : new ( ) ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ s y m b o l s _ t a b l e - > n _ i n d e x = ( int ) n ;
}
return n ;
}
i n t e r _ s y m b o l s _ t a b l e * I n t e r : : g e t _ g l o b a l _ s y m b o l s ( i n t e r _ r e p o s i t o r y * I ) {
return I n t e r : : g e t _ s y m b o l s _ t a b l e ( I , 1 ) ;
}
i n t e r _ s y m b o l s _ t a b l e * I n t e r : : g e t _ s y m b o l s _ t a b l e ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t n ) {
if ( n > = ( i n t e r _ t ) I - > size ) return NULL ;
if ( n = = 0 ) return NULL ;
return I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ s y m b o l s _ t a b l e ;
}
i n t e r _ t I n t e r : : c r e a t e _ p a c k a g e ( i n t e r _ r e p o s i t o r y * I , i n t e r _ p a c k a g e * p a r ) {
i n t e r _ t n = I n t e r : : c r e a t e _ r e s o u r c e ( I ) ;
if ( I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ p a c k a g e = = NULL ) {
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ p a c k a g e = I n t e r : : P a c k a g e s : : new ( p a r , I , n ) ;
}
return n ;
}
i n t e r _ p a c k a g e * I n t e r : : g e t _ p a c k a g e ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t n ) {
if ( n > = ( i n t e r _ t ) I - > size ) return NULL ;
if ( n = = 0 ) return NULL ;
return I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ p a c k a g e ;
}
i n t e r _ t I n t e r : : c r e a t e _ t e x t ( i n t e r _ r e p o s i t o r y * I ) {
i n t e r _ t n = I n t e r : : c r e a t e _ r e s o u r c e ( I ) ;
if ( I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ t e x t _ s t r e a m = = NULL ) {
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ t e x t _ s t r e a m = S t r : : new ( ) ;
}
return n ;
}
t e x t _ s t r e a m * I n t e r : : g e t _ t e x t ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t n ) {
if ( n > = ( i n t e r _ t ) I - > size ) return NULL ;
return I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ t e x t _ s t r e a m ;
}
i n t e r _ t I n t e r : : c r e a t e _ r e f ( i n t e r _ r e p o s i t o r y * I ) {
i n t e r _ t n = I n t e r : : c r e a t e _ r e s o u r c e ( I ) ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ r e f = NULL ;
return n ;
}
void * I n t e r : : g e t _ r e f ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t n ) {
if ( n > = ( i n t e r _ t ) I - > size ) return NULL ;
return I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ r e f ;
}
void I n t e r : : s e t _ r e f ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t n , void * r e f ) {
if ( n > = ( i n t e r _ t ) I - > size ) return ;
I - > s t o r e d _ r e s o u r c e s [ n ] . s t o r e d _ r e f = r e f ;
}
i n t e r _ t I n t e r : : c r e a t e _ f r a m e _ l i s t ( i n t e r _ r e p o s i t o r y * I ) {
return I n t e r : : c r e a t e _ r e s o u r c e ( I ) ;
}
@
@ d L O O P _ T H R O U G H _ I N T E R _ F R A M E _ L I S T ( F , i f l )
for ( i n t e r _ f r a m e _ l i s t _ e n t r y * F # # _ e n t r y = i f l - > f i r s t _ i n _ i f l ; F # # _ e n t r y ; F # # _ e n t r y = F # # _ e n t r y - > n e x t _ i n _ i f l )
2019-06-10 10:30:20 +03:00
if ( ( I n t e r : : Frame : : v a l i d ( ( ( F = F # # _ e n t r y - > l i s t e d _ f r a m e ) , &F))) &&
( I n t e r : : Frame : : i n c l u d e d ( ( ( F = F # # _ e n t r y - > l i s t e d _ f r a m e ) , &F))))
2019-02-05 02:44:07 +02:00
@ d L O O P _ T H R O U G H _ I N T E R _ F R A M E _ L I S T _ F R O M ( F , i f l , entry )
for ( i n t e r _ f r a m e _ l i s t _ e n t r y * F # # _ e n t r y = entry ; F # # _ e n t r y ; F # # _ e n t r y = F # # _ e n t r y - > n e x t _ i n _ i f l )
2019-06-10 10:30:20 +03:00
if ( ( I n t e r : : Frame : : v a l i d ( ( ( F = F # # _ e n t r y - > l i s t e d _ f r a m e ) , &F))) &&
( I n t e r : : Frame : : i n c l u d e d ( ( ( F = F # # _ e n t r y - > l i s t e d _ f r a m e ) , &F))))
2019-02-05 02:44:07 +02:00
=
i n t e r _ f r a m e _ l i s t * I n t e r : : f i n d _ f r a m e _ l i s t ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t N ) {
if ( I = = NULL ) return NULL ;
int n = ( int ) N ;
if ( n > = I - > size ) return NULL ;
return &(I->stored_resources[n].stored_frame_list);
}
i n t e r _ f r a m e I n t e r : : t o p _ o f _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | | ( F L - > f i r s t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
i n t e r _ f r a m e I n t e r : : s e c o n d _ i n _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | | ( F L - > f i r s t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
i n t e r _ f r a m e I n t e r : : t h i r d _ i n _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | | ( F L - > f i r s t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
i n t e r _ f r a m e I n t e r : : f o u r t h _ i n _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | | ( F L - > f i r s t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
i n t e r _ f r a m e I n t e r : : f i f t h _ i n _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | | ( F L - > f i r s t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | | ( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
i n t e r _ f r a m e I n t e r : : s i x t h _ i n _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L ) {
if ( ( F L = = NULL ) | |
( F L - > f i r s t _ i n _ i f l = = NULL ) | |
( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | |
( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | |
( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | |
( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) | |
( F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l = = NULL ) ) return I n t e r : : Frame : : a r o u n d ( NULL , - 1 ) ;
return F L - > f i r s t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > n e x t _ i n _ i f l - > l i s t e d _ f r a m e ;
}
void I n t e r : : a d d _ t o _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * F L , i n t e r _ f r a m e F , i n t e r _ r e a d i n g _ s t a t e * at ) {
if ( ( at ) && (at->in_frame_list != FL)) internal_error("bookmark mismatched to list");
if ( I n t e r : : Frame : : v a l i d ( &F) == FALSE) internal_error("linked imvalid frame");
if ( F L = = NULL ) i n t e r n a l _ e r r o r ( "bad frame list" ) ;
if ( F L - > s t o r a g e _ u s e d > = F L - > s t o r a g e _ c a p a c i t y ) {
int n e w _ s i z e = 128 ;
while ( n e w _ s i z e < 2 * F L - > s t o r a g e _ c a p a c i t y ) n e w _ s i z e = 2 * n e w _ s i z e ;
i n t e r _ f r a m e _ l i s t _ e n t r y * s t o r a g e = ( i n t e r _ f r a m e _ l i s t _ e n t r y * ) M e m o r y : : I 7 _ c a l l o c ( n e w _ s i z e , s i z e o f ( i n t e r _ f r a m e _ l i s t _ e n t r y ) , I N T E R _ L I N K S _ M R E A S O N ) ;
F L - > s p a r e _ s t o r a g e = s t o r a g e ;
F L - > s t o r a g e _ u s e d = 0 ;
F L - > s t o r a g e _ c a p a c i t y = n e w _ s i z e ;
}
i n t e r _ f r a m e _ l i s t _ e n t r y * entry = &(FL->spare_storage[FL->storage_used ++]);
e n t r y - > l i s t e d _ f r a m e = F ;
e n t r y - > n e x t _ i n _ i f l = NULL ;
e n t r y - > p r e v _ i n _ i f l = NULL ;
if ( ( at = = NULL ) | | ( a t - > p o s = = NULL ) | | ( a t - > p o s = = F L - > l a s t _ i n _ i f l ) | | ( a t - > p i n n e d _ t o _ e n d ) ) {
e n t r y - > p r e v _ i n _ i f l = F L - > l a s t _ i n _ i f l ;
if ( F L - > l a s t _ i n _ i f l ) F L - > l a s t _ i n _ i f l - > n e x t _ i n _ i f l = entry ;
F L - > l a s t _ i n _ i f l = entry ;
if ( F L - > f i r s t _ i n _ i f l = = NULL ) F L - > f i r s t _ i n _ i f l = entry ;
} else {
2019-07-08 13:21:00 +03:00
/* t h e n e w o n e c a n ' t b e t h e f i r s t */
2019-02-05 02:44:07 +02:00
i n t e r _ f r a m e _ l i s t _ e n t r y * a f t e r = a t - > p o s - > n e x t _ i n _ i f l ;
a t - > p o s - > n e x t _ i n _ i f l = entry ;
e n t r y - > p r e v _ i n _ i f l = a t - > p o s ;
e n t r y - > n e x t _ i n _ i f l = a f t e r ;
2019-07-08 13:21:00 +03:00
if ( a f t e r = = NULL )
F L - > l a s t _ i n _ i f l = entry ;
else
a f t e r - > p r e v _ i n _ i f l = entry ;
2019-02-05 02:44:07 +02:00
}
if ( at ) a t - > p o s = entry ;
}
int I n t e r : : s i z e _ o f _ f r a m e _ l i s t ( i n t e r _ f r a m e _ l i s t * i f l ) {
int c = 0 ;
i n t e r _ f r a m e F ;
L O O P _ T H R O U G H _ I N T E R _ F R A M E _ L I S T ( F , i f l ) c + + ;
return c ;
}
i n t e r _ t I n t e r : : s t o r e _ o r i g i n ( i n t e r _ r e p o s i t o r y * I , i n t e r _ e r r o r _ l o c a t i o n * e l o c ) {
if ( e l o c ) {
if ( e l o c - > e r r o r _ i n t e r b ) {
I - > o r i g i n _ f i l e = e l o c - > e r r o r _ i n t e r b ;
return ( i n t e r _ t ) ( 0x10000000 + e l o c - > e r r o r _ o f f s e t ) ;
}
if ( e l o c - > e r r o r _ t f p ) {
I - > o r i g i n _ f i l e = e l o c - > e r r o r _ t f p - > t e x t _ f i l e _ f i l e n a m e ;
return ( i n t e r _ t ) ( e l o c - > e r r o r _ t f p - > l i n e _ c o u n t ) ;
}
}
return 0 ;
}
t y p e def s t r u c t i n t e r _ e r r o r _ s t a s h {
s t r u c t i n t e r _ e r r o r _ l o c a t i o n s t a s h e d _ e l o c ;
s t r u c t t e x t _ f i l e _ p o s i t i o n s t a s h e d _ t f p ;
M E M O R Y _ M A N A G E M E N T
} i n t e r _ e r r o r _ s t a s h ;
i n t e r _ e r r o r _ l o c a t i o n * I n t e r : : r e t r i e v e _ o r i g i n ( i n t e r _ r e p o s i t o r y * I , i n t e r _ t C ) {
if ( ( I ) && (I->origin_file)) {
i n t e r _ e r r o r _ s t a s h * s t a s h = CREATE ( i n t e r _ e r r o r _ s t a s h ) ;
s t a s h - > s t a s h e d _ t f p = T e x t F i l e s : : n o w h e r e ( ) ;
if ( C < 0x10000000 ) {
t e x t _ f i l e _ p o s i t i o n * t f p = &(stash->stashed_tfp);
t f p - > t e x t _ f i l e _ f i l e n a m e = I - > o r i g i n _ f i l e ;
t f p - > l i n e _ c o u n t = ( int ) C ;
s t a s h - > s t a s h e d _ e l o c = I n t e r : : E r r o r s : : f i l e _ l o c a t i o n ( NULL , t f p ) ;
} else {
s t a s h - > s t a s h e d _ e l o c = I n t e r : : E r r o r s : : i n t e r b _ l o c a t i o n ( I - > o r i g i n _ f i l e , ( s i z e _ t ) ( C - 0x10000000 ) ) ;
}
return &(stash->stashed_eloc);
}
return NULL ;
}