1 /**************************************************************************** 2 * Copyright (C) 2008 by Matteo Franchin * 3 * * 4 * This file is part of Box. * 5 * * 6 * Box is free software: you can redistribute it and/or modify it * 7 * under the terms of the GNU Lesser General Public License as published * 8 * by the Free Software Foundation, either version 3 of the License, or * 9 * (at your option) any later version. * 10 * * 11 * Box 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 Lesser General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU Lesser General Public * 17 * License along with Box. If not, see <http://www.gnu.org/licenses/>. * 18 ****************************************************************************/ 19 20 /** 21 * @file vmsymstuff.h 22 * @brief Wrappings of 'vmsym.c' for defining and referencing symbols. 23 * 24 * Some words. 25 */ 26 27 #ifndef _VMSYMSTUFF_H 28 # define _VMSYMSTUFF_H 29 30 typedef enum { 31 BOXVMSYMTYPE_COND_JMP=1, 32 BOXVMSYMTYPE_PROC_HEAD=2, 33 BOXVMSYMTYPE_LABEL=3, 34 BOXVMSYMTYPE_PROC=4 35 } BoxVMSymType; 36 37 typedef struct { 38 BoxInt sheet_id, position; 39 int conditional; 40 } VMSymLabel; 41 42 43 /** This function creates an undefined label. A label is a number which 44 * refers to a position in the assembled code. 45 */ 46 BoxVMSymID BoxVMSym_New_Label(BoxVM *vmp); 47 48 /** Same as VM_Sym_New_Label, but sheet_id is the current active sheet and 49 * position is the current position in that sheet. 50 */ 51 BoxTask BoxVMSym_New_Label_Here(BoxVM *vmp, BoxVMSymID *label_sym_num); 52 53 /** Specify the position of a undefined label. */ 54 BoxTask BoxVMSym_Def_Label(BoxVM *vmp, BoxUInt label_sym_num, 55 BoxInt sheet_id, BoxInt position); 56 57 /** Same as VM_Sym_Def_Label, but sheet_id is the current active sheet and 58 * position is the current position in that sheet. 59 */ 60 BoxTask BoxVMSym_Def_Label_Here(BoxVM *vmp, BoxVMSymID label_sym_id); 61 62 BoxTask BoxVMSym_Jc(BoxVM *vm, BoxVMSymID sym_id); 63 64 BoxTask BoxVMSym_Jmp(BoxVM *vm, BoxVMSymID sym_id); 65 66 /** Called to signal that a label is not needed anymore. */ 67 BoxTask BoxVMSym_Release_Label(BoxVM *vmp, BoxUInt sym_num); 68 69 BoxTask BoxVMSym_Assemble_Proc_Head(BoxVM *vm, BoxVMSymID *sym_id); 70 71 BoxTask BoxVMSym_Def_Proc_Head(BoxVM *vmp, BoxVMSymID sym_id, 72 BoxInt *num_var, BoxInt *num_reg); 73 74 75 /* Temporary, very ugly stuff... */ 76 77 BoxBool 78 BoxVMSym_Proc_Is_Implemented(BoxVM *vm, BoxVMSymID sym_id, 79 const char **c_name); 80 81 BoxBool 82 BoxVMSym_Define_Proc(BoxVM *vm, BoxVMSymID sym_id, BoxCCallOld fn_ptr); 83 84 BoxBool 85 BoxVMSym_Reference_Proc(BoxVM *vm, BoxCallable *cb); 86 87 #endif 88 89