Split ArrayType from Type.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of SourcePawn.
6 * SourcePawn 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 * SourcePawn 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 * SourcePawn. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_function_h_
19 #define _include_jitcraft_function_h_
32 class Function : public Object
34 Barriered<Code> code_;
35 Barriered<FunctionType> type_;
36 Barriered<String> name_;
40 static Function *New(Zone *zone, Handle<Code> code, Handle<FunctionType> type, Handle<String> name,
41 const SourcePosition &pos);
46 FunctionType *type() const {
49 String *name() const {
52 const SourcePosition &pos() {
56 return type()->parameters()->length();
58 Type *argType(size_t index) {
59 return type()->parameterAt(index);
62 // Begin GC Descriptor.
63 static inline size_t offsetOfCode() {
64 return OFFSETOF(Function, code_);
66 static inline size_t offsetOfType() {
67 return OFFSETOF(Function, type_);
69 static inline size_t offsetOfName() {
70 return OFFSETOF(Function, name_);
74 static inline Function *cast(Object *obj) {
75 assert(!obj || obj->is(MapKind_Function));
76 return reinterpret_cast<Function *>(obj);
80 // A Native is a function with a very specialized calling convention, intended
81 // for earlier ISourcePawnEngine API compatibility.
82 class Native : public Object
84 Barriered<FunctionType> type_;
86 // Index into the Zone's native table.
90 static Native *New(Zone *zone, Handle<FunctionType> type, size_t index);
92 FunctionType *type() {
95 size_t index() const {
99 // Begin GC Descriptor.
100 static inline size_t offsetOfType() {
101 return OFFSETOF(Native, type_);
103 // End GC Descriptor.
105 static inline Native *cast(Object *obj) {
106 assert(!obj || obj->is(MapKind_Native));
107 return reinterpret_cast<Native *>(obj);
113 #endif // _include_jitcraft_function_h_