diff -r c4b1341297e5 -r ba85a47ee414 src/Functions.h --- a/src/Functions.h Mon Jun 10 00:46:29 2013 +0100 +++ b/src/Functions.h Mon Jun 10 01:04:43 2013 +0100 @@ -1,113 +1,113 @@ -/* - * Copyright (C) 2012 David Anderson - * - * This file is part of SourcePawn. - * - * SourcePawn 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. - * - * SourcePawn 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 - * SourcePawn. If not, see http://www.gnu.org/licenses/. - */ -#ifndef _include_jitcraft_function_h_ -#define _include_jitcraft_function_h_ - -#include "Heap.h" -#include "Barriers.h" -#include "Types.h" -#include "Opcodes.h" - -namespace ke { - -class Code; -class Module; -class String; - -class Function : public Object -{ - Barriered code_; - Barriered type_; - Barriered name_; - SourcePosition pos_; - - public: - static Function *New(Zone *zone, Handle code, Handle type, Handle name, - const SourcePosition &pos); - - Code *code() const { - return code_; - } - FunctionType *type() const { - return type_; - } - String *name() const { - return name_; - } - const SourcePosition &pos() { - return pos_; - } - unsigned nargs() { - return type()->parameters()->length(); - } - Type *argType(size_t index) { - return type()->parameterAt(index); - } - - // Begin GC Descriptor. - static inline size_t offsetOfCode() { - return OFFSETOF(Function, code_); - } - static inline size_t offsetOfType() { - return OFFSETOF(Function, type_); - } - static inline size_t offsetOfName() { - return OFFSETOF(Function, name_); - } - // End GC Descriptor. - - static inline Function *cast(Object *obj) { - assert(!obj || obj->is(MapKind_Function)); - return reinterpret_cast(obj); - } -}; - -// A Native is a function with a very specialized calling convention, intended -// for earlier ISourcePawnEngine API compatibility. -class Native : public Object -{ - Barriered type_; - - // Index into the Zone's native table. - size_t index_; - - public: - static Native *New(Zone *zone, Handle type, size_t index); - - FunctionType *type() { - return type_; - } - size_t index() const { - return index_; - } - - // Begin GC Descriptor. - static inline size_t offsetOfType() { - return OFFSETOF(Native, type_); - } - // End GC Descriptor. - - static inline Native *cast(Object *obj) { - assert(!obj || obj->is(MapKind_Native)); - return reinterpret_cast(obj); - } -}; - -} - -#endif // _include_jitcraft_function_h_ +/* + * Copyright (C) 2012 David Anderson + * + * This file is part of SourcePawn. + * + * SourcePawn 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. + * + * SourcePawn 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 + * SourcePawn. If not, see http://www.gnu.org/licenses/. + */ +#ifndef _include_jitcraft_function_h_ +#define _include_jitcraft_function_h_ + +#include "Heap.h" +#include "Barriers.h" +#include "Types.h" +#include "Opcodes.h" + +namespace ke { + +class Code; +class Module; +class String; + +class Function : public Object +{ + Barriered code_; + Barriered type_; + Barriered name_; + SourcePosition pos_; + + public: + static Function *New(Zone *zone, Handle code, Handle type, Handle name, + const SourcePosition &pos); + + Code *code() const { + return code_; + } + FunctionType *type() const { + return type_; + } + String *name() const { + return name_; + } + const SourcePosition &pos() { + return pos_; + } + unsigned nargs() { + return type()->parameters()->length(); + } + Type *argType(size_t index) { + return type()->parameterAt(index); + } + + // Begin GC Descriptor. + static inline size_t offsetOfCode() { + return OFFSETOF(Function, code_); + } + static inline size_t offsetOfType() { + return OFFSETOF(Function, type_); + } + static inline size_t offsetOfName() { + return OFFSETOF(Function, name_); + } + // End GC Descriptor. + + static inline Function *cast(Object *obj) { + assert(!obj || obj->is(MapKind_Function)); + return reinterpret_cast(obj); + } +}; + +// A Native is a function with a very specialized calling convention, intended +// for earlier ISourcePawnEngine API compatibility. +class Native : public Object +{ + Barriered type_; + + // Index into the Zone's native table. + size_t index_; + + public: + static Native *New(Zone *zone, Handle type, size_t index); + + FunctionType *type() { + return type_; + } + size_t index() const { + return index_; + } + + // Begin GC Descriptor. + static inline size_t offsetOfType() { + return OFFSETOF(Native, type_); + } + // End GC Descriptor. + + static inline Native *cast(Object *obj) { + assert(!obj || obj->is(MapKind_Native)); + return reinterpret_cast(obj); + } +}; + +} + +#endif // _include_jitcraft_function_h_