Removed OBJECT_FIELD and READ and WRITE macros.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jc_code_h_
19 #define _include_jc_code_h_
25 #include "FixedArray.h"
32 // A code object contains the bytecode compiled from a function (or global
33 // script), as well as all information needed to interpret or JIT-compile
35 class Code : public Object
38 Unbarriered<ByteArray> bytecode_;
39 Unbarriered<FixedArray> locals_;
40 Unbarriered<FixedArray> args_;
41 Unbarriered<FixedArray> maps_;
42 unsigned maxStackDepth_;
46 static Code *New(Zone *zone, ByteArray *bytecode, FixedArray *locals, FixedArray *args,
47 FixedArray *maps, unsigned maxStackDepth, Module *module);
53 return bytecode_->raw();
56 return bytecode_->length();
58 Type *localType(size_t index) {
59 return Type::cast(locals_->at(index));
61 Type *argType(size_t index) {
62 return Type::cast(args_->at(index));
65 return locals_->length();
68 return args_->length();
70 unsigned maxStackDepth() {
71 return maxStackDepth_;
73 Map *map(size_t index) {
74 return Map::cast(maps_->at(index));
77 static Code *cast(Object *obj) {
78 assert(obj->is(MapKind_Code));
79 return reinterpret_cast<Code *>(obj);
85 #endif // _include_jc_code_h_