Annotation of gforth/vmgen-ex/mini.h, revision 1.5

1.1       anton       1: /* support functions for vmgen example
                      2: 
                      3:   Copyright (C) 2001 Free Software Foundation, Inc.
                      4: 
                      5:   This file is part of Gforth.
                      6: 
                      7:   Gforth is free software; you can redistribute it and/or
                      8:   modify it under the terms of the GNU General Public License
                      9:   as published by the Free Software Foundation; either version 2
                     10:   of the License, or (at your option) any later version.
                     11: 
                     12:   This program is distributed in the hope that it will be useful,
                     13:   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15:   GNU General Public License for more details.
                     16: 
                     17:   You should have received a copy of the GNU General Public License
                     18:   along with this program; if not, write to the Free Software
                     19:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
                     20: */
                     21: 
                     22: #include <stdio.h>
                     23: 
1.4       anton      24: #ifdef __GNUC__
1.1       anton      25: typedef void *Label;
                     26: typedef void *Inst; /* for direct threading, the same as Label */
1.4       anton      27: #else
                     28: typedef long Label;
                     29: typedef long Inst;
                     30: #endif
1.1       anton      31: typedef long Cell;
                     32: 
                     33: extern Inst *vm_prim;
                     34: extern int locals;
                     35: extern Cell peeptable;
                     36: extern int vm_debug;
                     37: extern FILE *yyin;
                     38: extern int yylineno;
                     39: extern char *program_name;
                     40: extern FILE *vm_out;
                     41: extern Inst *vmcodep;
                     42: extern Inst *last_compiled;
1.2       anton      43: extern Inst *vmcode_end;
1.5     ! anton      44: extern int use_super;
1.1       anton      45: 
                     46: /* generic vmgen support functions (e.g., wrappers) */
                     47: void gen_inst(Inst **vmcodepp, Inst i);
                     48: void init_peeptable(void);
                     49: void vm_disassemble(Inst *ip, Inst *endp, Inst prim[]);
                     50: void vm_count_block(Inst *ip);
                     51: struct block_count *block_insert(Inst *ip);
1.2       anton      52: void vm_print_profile(FILE *file);
1.3       anton      53: #define VM_IS_INST(inst, n) ((inst) == vm_prim[n])
1.1       anton      54: 
                     55: /* mini type-specific support functions */
                     56: void genarg_i(Inst **vmcodepp, Cell i);
                     57: void printarg_i(Cell i);
                     58: void genarg_target(Inst **vmcodepp, Inst *target);
                     59: void printarg_target(Inst *target);
                     60: void printarg_a(char *a);
1.2       anton      61: void printarg_Cell(Cell i);
1.1       anton      62: 
                     63: /* engine functions (type not fixed) */
                     64: Cell engine(Inst *ip0, Cell *sp, char *fp);
                     65: Cell engine_debug(Inst *ip0, Cell *sp, char *fp);
                     66: 
                     67: /* other generic functions */
                     68: int yyparse(void);
                     69: 
                     70: /* mini-specific functions */
                     71: void insert_func(char *name, Inst *start, int locals, int nonparams);
                     72: Inst *func_addr(char *name);
                     73: Cell func_calladjust(char *name);
                     74: void insert_local(char *name);
                     75: Cell var_offset(char *name);
                     76: void gen_main_end(void);
                     77: 
                     78: /* stack pointer change for a function with n nonparams */
                     79: #define adjust(n)  ((n) * -sizeof(Cell))

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>