2
* Copyright (C) 2006 Campanoni Simone
4
* iljit - This is a Just-in-time for the CIL language specified with the ECMA-335
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
* This file implements the stack used for the translation from CIL bytecode to IR language
28
#include <jitsystem.h>
29
#include <ir_method.h>
30
#include <metadata/metadata_types.h>
32
#define MAX_STACK_SIZE 128
37
* This struct contains the stack used to translate the CIL method into the IR equivalent method.
39
typedef struct t_stack{
40
ir_item_t *stack; /**< Stack */
41
JITUINT32 top; /**< Top of the stack */
42
JITUINT32 max_stack_size; /**< Max size of the stack */
43
void (*dupTop) (struct t_stack *_this); /**< Duplicate the top of the stack */
44
void (*push) (struct t_stack *_this, ir_item_t *var); /**< Push the element var to the top of the stack */
45
void (*pop) (struct t_stack *_this, ir_item_t *var); /**< Pop the element on the top of the stack and store it into the item element if it is not NULL */
46
void (*adjustSize) (struct t_stack *_this);
47
void (*cleanTop) (struct t_stack *_this); /**< Clean the top of the stack */
50
typedef struct _CILStack{
51
XanList *stackes; /**< List of stackes allocated */
53
t_stack * (*newStack) (struct _CILStack *cilStack);
54
t_stack * (*mergeStackes) (struct _CILStack *cilStack, t_stack *stack1, t_stack *stack2, void *ilMethod, void *labelInst);
55
t_stack * (*cloneStack) (struct _CILStack *cilStack, t_stack *stack); /**< Clone the stack */
56
void (*destroy) (struct _CILStack *cilStack);
59
typedef struct _CILStack * CILStack;
61
CILStack newCILStack();