Lines Matching refs:stack

5 /*    Adobe's code for emulating a CFF stack (body).                       */
59 CF2_Stack stack = NULL;
62 if ( !FT_NEW( stack ) )
65 stack->memory = memory;
66 stack->error = e;
69 /* allocate the stack buffer */
70 if ( FT_NEW_ARRAY( stack->buffer, stackSize ) )
72 FT_FREE( stack );
76 stack->stackSize = stackSize;
77 stack->top = stack->buffer; /* empty stack */
79 return stack;
84 cf2_stack_free( CF2_Stack stack )
86 if ( stack )
88 FT_Memory memory = stack->memory;
91 FT_FREE( stack->buffer );
94 FT_FREE( stack );
100 cf2_stack_count( CF2_Stack stack )
102 return (CF2_UInt)( stack->top - stack->buffer );
107 cf2_stack_pushInt( CF2_Stack stack,
110 if ( stack->top == stack->buffer + stack->stackSize )
112 CF2_SET_ERROR( stack->error, Stack_Overflow );
113 return; /* stack overflow */
116 stack->top->u.i = val;
117 stack->top->type = CF2_NumberInt;
118 stack->top++;
123 cf2_stack_pushFixed( CF2_Stack stack,
126 if ( stack->top == stack->buffer + stack->stackSize )
128 CF2_SET_ERROR( stack->error, Stack_Overflow );
129 return; /* stack overflow */
132 stack->top->u.r = val;
133 stack->top->type = CF2_NumberFixed;
134 stack->top++;
140 cf2_stack_popInt( CF2_Stack stack )
142 if ( stack->top == stack->buffer )
144 CF2_SET_ERROR( stack->error, Stack_Underflow );
147 if ( stack->top[-1].type != CF2_NumberInt )
149 CF2_SET_ERROR( stack->error, Syntax_Error );
153 stack->top--;
155 return stack->top->u.i;
162 cf2_stack_popFixed( CF2_Stack stack )
164 if ( stack->top == stack->buffer )
166 CF2_SET_ERROR( stack->error, Stack_Underflow );
170 stack->top--;
172 switch ( stack->top->type )
175 return cf2_intToFixed( stack->top->u.i );
177 return cf2_fracToFixed( stack->top->u.f );
179 return stack->top->u.r;
187 cf2_stack_getReal( CF2_Stack stack,
190 FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize );
192 if ( idx >= cf2_stack_count( stack ) )
194 CF2_SET_ERROR( stack->error, Stack_Overflow );
198 switch ( stack->buffer[idx].type )
201 return cf2_intToFixed( stack->buffer[idx].u.i );
203 return cf2_fracToFixed( stack->buffer[idx].u.f );
205 return stack->buffer[idx].u.r;
210 /* provide random access to stack */
212 cf2_stack_setReal( CF2_Stack stack,
216 if ( idx > cf2_stack_count( stack ) )
218 CF2_SET_ERROR( stack->error, Stack_Overflow );
222 stack->buffer[idx].u.r = val;
223 stack->buffer[idx].type = CF2_NumberFixed;
227 /* discard (pop) num values from stack */
229 cf2_stack_pop( CF2_Stack stack,
232 if ( num > cf2_stack_count( stack ) )
234 CF2_SET_ERROR( stack->error, Stack_Underflow );
237 stack->top -= num;
242 cf2_stack_roll( CF2_Stack stack,
255 if ( (CF2_UInt)count > cf2_stack_count( stack ) )
257 CF2_SET_ERROR( stack->error, Stack_Overflow );
277 /* stack indices before roll: 7 6 5 4 3 2 1 0 */
278 /* stack indices after roll: 1 0 7 6 5 4 3 2 */
305 last = stack->buffer[idx];
314 tmp = stack->buffer[idx];
315 stack->buffer[idx] = last;
322 cf2_stack_clear( CF2_Stack stack )
324 stack->top = stack->buffer;