mirror of
https://github.com/siemens-mobile-hacks/vbcc.git
synced 2026-11-25 22:27:36 +00:00
93 lines
1.8 KiB
C
Executable file
93 lines
1.8 KiB
C
Executable file
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdarg.h>
|
|
|
|
#include "supp.h"
|
|
|
|
extern FILE *infile;
|
|
#define MAXLEN 1024
|
|
extern char tkname[MAXLEN];
|
|
extern int label;
|
|
extern int nesting;
|
|
extern int local_offset,parm_offset,framesize;
|
|
|
|
#define REAL DOUBLE
|
|
#define FUNCTION FUNKT
|
|
|
|
#define YYERROR_VERBOSE 1
|
|
|
|
enum nodeflags {
|
|
NVARIABLE,NNUMBER,NADD,NMUL,NSUB,NDIV,NINDEX,
|
|
NEQUALS,NLT,NGT,NLEQ,NGEQ,NNEQ,NAND,NOR,
|
|
NI2R,NR2I,NASSGN,NCALL,NARG
|
|
};
|
|
|
|
extern char *nodename[];
|
|
|
|
typedef struct Typ type;
|
|
|
|
typedef struct obj operand;
|
|
|
|
typedef struct var {
|
|
int nesting;
|
|
char *name;
|
|
struct Typ *type;
|
|
struct var *next;
|
|
int offset;
|
|
struct Var *vbccvar;
|
|
} var;
|
|
|
|
#define MAXNESTING 128
|
|
extern var *first_var[128];
|
|
|
|
typedef struct {
|
|
int flags;
|
|
char *name;
|
|
} *stype;
|
|
|
|
typedef struct mnode {
|
|
enum nodeflags flags;
|
|
struct mnode *left,*right;
|
|
type *type;
|
|
var *var;
|
|
int ivalue;
|
|
double rvalue;
|
|
} mnode;
|
|
|
|
void enter_block(void);
|
|
void leave_block(void);
|
|
void enter_func(char *,type *);
|
|
void leave_func(void);
|
|
var *find_var(char *,int);
|
|
var *add_var(char *,type *);
|
|
var *new_temp(int);
|
|
char *add_string(char *);
|
|
void error(int,...);
|
|
void *getmem(size_t);
|
|
mnode *number_node(void);
|
|
mnode *var_node(void);
|
|
mnode *conv_tree(mnode *,int);
|
|
mnode *binary_node(enum nodeflags,mnode *,mnode *);
|
|
void print_tree(mnode *);
|
|
void simplify_tree(mnode *);
|
|
void free_tree(mnode *);
|
|
type *new_type(int);
|
|
type *new_array(type *,mnode *);
|
|
void return_statement(mnode *);
|
|
void while_statement(mnode *);
|
|
void while_end(void);
|
|
void if_statement(mnode *);
|
|
void if_end(void);
|
|
void if_else(void);
|
|
void assign_statement(mnode *,mnode *);
|
|
void push_int(int);
|
|
int pop_int(void);
|
|
void push_name(char *);
|
|
char *pop_name(void);
|
|
operand *gen_tree(mnode *);
|
|
void gen_cond(mnode *,int,int);
|
|
void gen_label(int);
|
|
int push_arg(mnode *);
|
|
void gen_global(char *,int);
|