w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

stack.c
Go to the documentation of this file.
1 /* stack.c -- primitives for managing instruction stack and stream
2  * Copyright (C) 1996 Li-Da Lho, All right reserved.
3  */
4 #include "config.h"
5 #include "ttf.h"
6 #include "ttfutil.h"
7 
8 /* $Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
9 
10 #define stack (vm->Stack)
11 #define sp (vm->sp)
12 #define limit (vm->stklimit)
13 #define ins (vm->iStream)
14 #define ip (vm->ip)
15 
17 
18 /* Push LONG l onto the stack of vm */
19 inline void Push(VirtualMachine *vm, LONG l)
20 {
21  if (sp < limit)
22  {
23  stack[sp] = l;
24  sp += 1;
25  }
26  else
28 }
29 /* Pop LONG from the stack of vm and store in l */
30 inline LONG Pop(VirtualMachine *vm)
31 {
32  LONG l;
33 
34  if (sp > 0)
35  {
36  l = stack[sp];
37  sp -= 1;
38  return l;
39  }
40  else
41  {
43  return 0;
44  }
45 }
46 
47 /* read one byte from the instruction stream */
49 {
50  if (ip < vm->insLength+1)
51  return ins[ip++];
52  else
53  {
55  return 0;
56  }
57 }
58 /* read two bytes from the instruction stream */
60 {
61  SHORT n = 0;
62 
63  if (ip < vm->insLength + 2)
64  {
65  n = ins[ip++] << 8;
66  n |= ins[ip++];
67  return n;
68  }
69  else
70  {
72  return 0;
73  }
74 }
75 #if 0
76 /* Not used */
77 /* read four bytes from the instruction steam */
78 inline LONG GetLONG(VirtualMachine *vm)
79 {
80  LONG n = 0;
81 
82  if (ip < vm->insLength + 4)
83  {
84  n = ins[ip++] << 24;
85  n |= ins[ip++] << 16;
86  n |= ins[ip++] << 8;
87  n |= ins[ip++] ;
88  return n;
89  }
90  else
91  {
93  return 0;
94  }
95 }
96 #endif
#define n
Definition: t4ht.c:1290
signed short SHORT
Definition: sfnt.h:37
unsigned char BYTE
Definition: sfnt.h:34
long LONG
Definition: common.h:146
int Error_State
Definition: ttf.h:105
Definition: spc_misc.c:56
#define sp
Definition: stack.c:11
SHORT GetSHORT(VirtualMachine *vm)
Definition: stack.c:59
#define limit
Definition: stack.c:12
BYTE GetBYTE(VirtualMachine *vm)
Definition: stack.c:48
void Push(VirtualMachine *vm, LONG l)
Definition: stack.c:19
#define ip
Definition: stack.c:14
TTF_ERROR
Definition: stack.c:16
@ InstructionOverflow
Definition: stack.c:16
@ StackOverflow
Definition: stack.c:16
#define ins
Definition: stack.c:13
LONG Pop(VirtualMachine *vm)
Definition: stack.c:30