diff -r 000000000000 -r c455ebb9a5dc jitcraft/Code.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jitcraft/Code.h Mon Jun 25 02:57:28 2012 -0700 @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2012 David Anderson + * + * This file is part of JITCraft. + * + * JITCraft is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * JITCraft. If not, see http://www.gnu.org/licenses/. + */ +#ifndef _include_jc_code_h_ +#define _include_jc_code_h_ + +#include "Opcodes.h" + +namespace jc { + +class Module; +class Type; + +class Code +{ + bytecode *start_; + unsigned length_; + Type **locals_; + unsigned nlocals_; + unsigned maxStackDepth_; + Module *module_; + Type **args_; + unsigned nargs_; + + public: + Code(Module *module, bytecode *start, unsigned length, + Type **args, unsigned nargs, + Type **locals, unsigned nlocals, + unsigned maxStackDepth) + : start_(start), + length_(length), + locals_(locals), + nlocals_(nlocals), + maxStackDepth_(maxStackDepth), + module_(module), + args_(args), + nargs_(nargs) + { + } + + Module *module() const { + return module_; + } + bytecode *start() const { + return start_; + } + unsigned length() const { + return length_; + } + Type *localType(size_t index) const { + assert(index < nlocals()); + return locals_[index]; + } + Type *argType(size_t index) const { + assert(index < nlocals()); + return args_[index]; + } + unsigned nlocals() const { + return nlocals_; + } + unsigned nargs() const { + return nargs_; + } + unsigned maxStackDepth() const { + return maxStackDepth_; + } +}; + +} + +#endif // _include_jc_code_h_