1 /****************************************************************************/
2 /*                                                                          */
3 /*  Module:         jamstack.h                                              */
4 /*                                                                          */
5 /*                  Copyright (C) Altera Corporation 1997                   */
6 /*                                                                          */
7 /*  Description:    Prototypes for stack management functions               */
8 /*                                                                          */
9 /*  Revisions:      1.1 added urj_jam_free_stack()                              */
10 /*                                                                          */
11 /****************************************************************************/
12 
13 #ifndef INC_JAMSTACK_H
14 #define INC_JAMSTACK_H
15 
16 #include <stdint.h>
17 
18 /****************************************************************************/
19 /*                                                                          */
20 /*  Type definitions                                                        */
21 /*                                                                          */
22 /****************************************************************************/
23 
24 /* types of stack records */
25 typedef enum
26 {
27     JAM_ILLEGAL_STACK_TYPE = 0,
28     JAM_STACK_FOR_NEXT,
29     JAM_STACK_PUSH_POP,
30     JAM_STACK_CALL_RETURN,
31     JAM_STACK_MAX
32 } JAME_STACK_RECORD_TYPE;
33 
34 /* stack record structure */
35 typedef struct
36 {
37     JAME_STACK_RECORD_TYPE type;
38     JAMS_SYMBOL_RECORD *iterator;       /* used only for FOR/NEXT */
39     int32_t for_position;       /* used only for FOR/NEXT */
40     int32_t stop_value;         /* used only for FOR/NEXT */
41     int32_t step_value;         /* used only for FOR/NEXT */
42     int32_t push_value;         /* used only for PUSH/POP */
43     int32_t return_position;    /* used only for CALL/RETURN */
44 } JAMS_STACK_RECORD;
45 
46 /****************************************************************************/
47 /*                                                                          */
48 /*  Global variables                                                        */
49 /*                                                                          */
50 /****************************************************************************/
51 
52 extern JAMS_STACK_RECORD *urj_jam_stack;
53 
54 /****************************************************************************/
55 /*                                                                          */
56 /*  Function prototypes                                                     */
57 /*                                                                          */
58 /****************************************************************************/
59 
60 JAM_RETURN_TYPE urj_jam_init_stack (void);
61 
62 void urj_jam_free_stack (void);
63 
64 JAM_RETURN_TYPE urj_jam_push_stack_record (JAMS_STACK_RECORD *stack_record);
65 
66 JAMS_STACK_RECORD *urj_jam_peek_stack_record (void);
67 
68 JAM_RETURN_TYPE urj_jam_pop_stack_record (void);
69 
70 JAM_RETURN_TYPE urj_jam_push_fornext_record
71     (JAMS_SYMBOL_RECORD *iterator,
72      int32_t for_position, int32_t stop_value, int32_t step_value);
73 
74 JAM_RETURN_TYPE urj_jam_push_pushpop_record (int32_t value);
75 
76 JAM_RETURN_TYPE urj_jam_push_callret_record (int32_t return_position);
77 
78 #endif /* INC_JAMSTACK_H */
79