~ubuntu-branches/ubuntu/wily/gargoyle-free/wily-proposed

« back to all changes in this revision

Viewing changes to terps/alan2/stack.c

  • Committer: Package Import Robot
  • Author(s): Sylvain Beucler
  • Date: 2013-07-28 13:38:56 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130728133856-4k6uc864wzsnrx04
Tags: 2011.1a-1
* New upstream release
* Alan 2 interpreter is now Free Software, include it
* Update fonts package names in dependencies (Closes: #715160)
* Bump Standards-Version to 3.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*----------------------------------------------------------------------*\
 
2
 
 
3
  STACK.C
 
4
 
 
5
  Stack Handling for Alan interpreter
 
6
 
 
7
\*----------------------------------------------------------------------*/
 
8
 
 
9
 
 
10
#include "types.h"
 
11
#include "main.h"
 
12
 
 
13
#include "stack.h"
 
14
 
 
15
 
 
16
/* PRIVATE DATA */
 
17
 
 
18
#define STACKSIZE 100
 
19
 
 
20
/* The AMACHINE STACK */
 
21
static Aptr stack[STACKSIZE];
 
22
static int stackp = 0;
 
23
 
 
24
 
 
25
#ifdef _PROTOTYPES_
 
26
void push(Aptr i)
 
27
#else
 
28
void push(i)
 
29
     Aptr i;
 
30
#endif
 
31
{
 
32
  if (stackp == STACKSIZE)
 
33
    syserr("Out of stack space.");
 
34
  stack[stackp++] = i;
 
35
}
 
36
 
 
37
 
 
38
#ifdef _PROTOTYPES_
 
39
Aptr pop(void)
 
40
#else
 
41
Aptr pop()
 
42
#endif
 
43
{
 
44
  if (stackp == 0)
 
45
    syserr("Stack underflow.");
 
46
  return(stack[--stackp]);
 
47
}
 
48
 
 
49
 
 
50
#ifdef _PROTOTYPES_
 
51
Aptr top(void)
 
52
#else
 
53
Aptr top()
 
54
#endif
 
55
{
 
56
  return(stack[stackp-1]);
 
57
}