1/******************************** -*- C -*- **************************** 2 * 3 * Byte code compiler inlines 4 * 5 * 6 ***********************************************************************/ 7 8/*********************************************************************** 9 * 10 * Copyright 2000, 2001, 2002, 2006 Free Software Foundation, Inc. 11 * Written by Steve Byrne. 12 * 13 * This file is part of GNU Smalltalk. 14 * 15 * GNU Smalltalk is free software; you can redistribute it and/or modify it 16 * under the terms of the GNU General Public License as published by the Free 17 * Software Foundation; either version 2, or (at your option) any later 18 * version. 19 * 20 * Linking GNU Smalltalk statically or dynamically with other modules is 21 * making a combined work based on GNU Smalltalk. Thus, the terms and 22 * conditions of the GNU General Public License cover the whole 23 * combination. 24 * 25 * In addition, as a special exception, the Free Software Foundation 26 * give you permission to combine GNU Smalltalk with free software 27 * programs or libraries that are released under the GNU LGPL and with 28 * independent programs running under the GNU Smalltalk virtual machine. 29 * 30 * You may copy and distribute such a system following the terms of the 31 * GNU GPL for GNU Smalltalk and the licenses of the other code 32 * concerned, provided that you include the source code of that other 33 * code when and as the GNU GPL requires distribution of source code. 34 * 35 * Note that people who make modified versions of GNU Smalltalk are not 36 * obligated to grant this special exception for their modified 37 * versions; it is their choice whether to do so. The GNU General 38 * Public License gives permission to release a modified version without 39 * this exception; this exception also makes it possible to release a 40 * modified version which carries forward this exception. 41 * 42 * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT 43 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 44 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 45 * more details. 46 * 47 * You should have received a copy of the GNU General Public License along with 48 * GNU Smalltalk; see the file COPYING. If not, write to the Free Software 49 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 50 * 51 ***********************************************************************/ 52 53 54 55/* Returns the bytecodes of the CompiledMethod or CompiledBlock, 56 METHODOOP */ 57#define GET_METHOD_BYTECODES(methodOOP) \ 58 ( ((gst_compiled_method)OOP_TO_OBJ(methodOOP))->bytecodes ) 59 60/* Returns the number of literals in the CompiledMethod or CompiledBlock, 61 METHODOOP */ 62#define NUM_METHOD_LITERALS(methodOOP) \ 63 NUM_WORDS (OOP_TO_OBJ(((gst_compiled_method)OOP_TO_OBJ(methodOOP))->literals)) 64 65/* Returns the literals of the CompiledMethod or CompiledBlock, 66 METHODOOP */ 67#define GET_METHOD_LITERALS(methodOOP) \ 68 ( OOP_TO_OBJ(((gst_compiled_method)OOP_TO_OBJ(methodOOP))->literals)->data ) 69 70/* Returns the header of the CompiledMethod, METHODOOP */ 71#define GET_METHOD_HEADER(methodOOP) \ 72 (((gst_compiled_method)OOP_TO_OBJ(methodOOP))->header) 73 74/* Returns the class in which the CompiledMethod or CompiledBlock, 75 METHODOOP, was defined */ 76#define GET_METHOD_CLASS(methodOOP) \ 77 (((gst_method_info)OOP_TO_OBJ(get_method_info(methodOOP)))->class) 78 79/* Returns the selector under which the CompiledMethod or CompiledBlock, 80 METHODOOP, was defined */ 81#define GET_METHOD_SELECTOR(methodOOP) \ 82 (((gst_method_info)OOP_TO_OBJ(get_method_info(methodOOP)))->selector) 83 84/* Returns the header of the CompiledBlock, BLOCKOOP */ 85#define GET_BLOCK_HEADER(blockOOP) \ 86 (((gst_compiled_block)OOP_TO_OBJ(blockOOP))->header) 87 88/* Returns the method for the CompiledBlock, BLOCKOOP */ 89#define GET_BLOCK_METHOD(blockOOP) \ 90 (((gst_compiled_block)OOP_TO_OBJ(blockOOP))->method) 91 92/* Returns the number of arguments of the CompiledMethod or CompiledBlock 93 pointed to by METHODOOP */ 94#define GET_METHOD_NUM_ARGS(methodOOP) \ 95 (GET_METHOD_HEADER (methodOOP).numArgs) 96 97/* Returns the method descriptor of OOP (either the CompiledMethod's 98 descriptor or the descriptor of the home method if a 99 CompiledBlock). */ 100static inline OOP get_method_info (OOP oop); 101 102OOP 103get_method_info (OOP oop) 104{ 105 gst_object obj; 106 obj = OOP_TO_OBJ (oop); 107 if UNCOMMON (obj->objClass == _gst_compiled_block_class) 108 { 109 oop = ((gst_compiled_block) obj)->method; 110 obj = OOP_TO_OBJ (oop); 111 } 112 113 return ((gst_compiled_method) obj)->descriptor; 114} 115 116