Added RootScopes for AST roots.
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> objects_;
41 unsigned maxStackDepth_;
45 static Code *New(Zone *zone, ByteArray *bytecode, FixedArray *locals,
46 FixedArray *objects, unsigned maxStackDepth, Module *module);
52 return bytecode_->raw();
55 return bytecode_->length();
57 Type *localType(size_t index) {
58 return Type::cast(locals_->at(index));
61 return locals_->length();
63 unsigned maxStackDepth() {
64 return maxStackDepth_;
66 Map *map(size_t index) {
67 return Map::cast(objects_->at(index));
69 Object *object(size_t index) {
70 return objects_->at(index);
73 static Code *cast(Object *obj) {
74 assert(!obj || obj->is(MapKind_Code));
75 return reinterpret_cast<Code *>(obj);
81 #endif // _include_jc_code_h_