Add GCC/Linux support.
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_jitcraft_function_h_
19 #define _include_jitcraft_function_h_
33 class Function : public Object
35 Barriered<Code> code_;
36 Barriered<Type> type_;
37 Barriered<String> name_;
41 static Function *New(Zone *zone, Handle<Code> code, Handle<Type> type, Handle<String> name,
42 const SourcePosition &pos);
50 String *name() const {
53 const SourcePosition &pos() {
57 return type()->parameters()->length();
59 Type *argType(size_t index) {
60 return type()->parameterAt(index);
63 // Begin GC Descriptor.
64 static inline size_t offsetOfCode() {
65 return OFFSETOF(Function, code_);
67 static inline size_t offsetOfType() {
68 return OFFSETOF(Function, type_);
70 static inline size_t offsetOfName() {
71 return OFFSETOF(Function, name_);
75 static inline Function *cast(Object *obj) {
76 assert(!obj || obj->is(MapKind_Function));
77 return reinterpret_cast<Function *>(obj);
81 // A Native is a function with a very specialized calling convention, intended
82 // for earlier ISourcePawnEngine API compatibility.
83 class Native : public Object
85 Barriered<Type> type_;
86 Barriered<String> name_;
90 static Native *New(Zone *zone, Handle<Type> type, Handle<String> name);
101 void bind(void *function) {
102 function_ = function;
105 // Begin GC Descriptor.
106 static inline size_t offsetOfType() {
107 return OFFSETOF(Native, type_);
109 static inline size_t offsetOfName() {
110 return OFFSETOF(Native, name_);
112 // End GC Descriptor.
114 static inline Native *cast(Object *obj) {
115 assert(!obj || obj->is(MapKind_Native));
116 return reinterpret_cast<Native *>(obj);
122 #endif // _include_jitcraft_function_h_