src/Functions.h
changeset 263 ba85a47ee414
parent 195 c1ba166f3fc4
     1.1 --- a/src/Functions.h	Mon Jun 10 00:46:29 2013 +0100
     1.2 +++ b/src/Functions.h	Mon Jun 10 01:04:43 2013 +0100
     1.3 @@ -1,113 +1,113 @@
     1.4 -/*
     1.5 - * Copyright (C) 2012 David Anderson
     1.6 - *
     1.7 - * This file is part of SourcePawn.
     1.8 - *
     1.9 - * SourcePawn is free software: you can redistribute it and/or modify it under
    1.10 - * the terms of the GNU General Public License as published by the Free
    1.11 - * Software Foundation, either version 3 of the License, or (at your option)
    1.12 - * any later version.
    1.13 - * 
    1.14 - * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    1.15 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.16 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License along with
    1.19 - * SourcePawn. If not, see http://www.gnu.org/licenses/.
    1.20 - */
    1.21 -#ifndef _include_jitcraft_function_h_
    1.22 -#define _include_jitcraft_function_h_
    1.23 -
    1.24 -#include "Heap.h"
    1.25 -#include "Barriers.h"
    1.26 -#include "Types.h"
    1.27 -#include "Opcodes.h"
    1.28 -
    1.29 -namespace ke {
    1.30 -
    1.31 -class Code;
    1.32 -class Module;
    1.33 -class String;
    1.34 -
    1.35 -class Function : public Object
    1.36 -{
    1.37 -    Barriered<Code> code_;
    1.38 -    Barriered<FunctionType> type_;
    1.39 -    Barriered<String> name_;
    1.40 -    SourcePosition pos_;
    1.41 -
    1.42 - public:
    1.43 -    static Function *New(Zone *zone, Handle<Code> code, Handle<FunctionType> type, Handle<String> name,
    1.44 -                         const SourcePosition &pos);
    1.45 -
    1.46 -    Code *code() const {
    1.47 -        return code_;
    1.48 -    }
    1.49 -    FunctionType *type() const {
    1.50 -        return type_;
    1.51 -    }
    1.52 -    String *name() const {
    1.53 -        return name_;
    1.54 -    }
    1.55 -    const SourcePosition &pos() {
    1.56 -        return pos_;
    1.57 -    }
    1.58 -    unsigned nargs() {
    1.59 -        return type()->parameters()->length();
    1.60 -    }
    1.61 -    Type *argType(size_t index) {
    1.62 -        return type()->parameterAt(index);
    1.63 -    }
    1.64 -
    1.65 -    // Begin GC Descriptor.
    1.66 -    static inline size_t offsetOfCode() {
    1.67 -        return OFFSETOF(Function, code_);
    1.68 -    }
    1.69 -    static inline size_t offsetOfType() {
    1.70 -        return OFFSETOF(Function, type_);
    1.71 -    }
    1.72 -    static inline size_t offsetOfName() {
    1.73 -        return OFFSETOF(Function, name_);
    1.74 -    }
    1.75 -    // End GC Descriptor.
    1.76 -
    1.77 -    static inline Function *cast(Object *obj) {
    1.78 -        assert(!obj || obj->is(MapKind_Function));
    1.79 -        return reinterpret_cast<Function *>(obj);
    1.80 -    }
    1.81 -};
    1.82 -
    1.83 -// A Native is a function with a very specialized calling convention, intended
    1.84 -// for earlier ISourcePawnEngine API compatibility.
    1.85 -class Native : public Object
    1.86 -{
    1.87 -    Barriered<FunctionType> type_;
    1.88 -
    1.89 -    // Index into the Zone's native table.
    1.90 -    size_t index_;
    1.91 -
    1.92 -  public:
    1.93 -    static Native *New(Zone *zone, Handle<FunctionType> type, size_t index);
    1.94 -
    1.95 -    FunctionType *type() {
    1.96 -        return type_;
    1.97 -    }
    1.98 -    size_t index() const {
    1.99 -        return index_;
   1.100 -    }
   1.101 -
   1.102 -    // Begin GC Descriptor.
   1.103 -    static inline size_t offsetOfType() {
   1.104 -        return OFFSETOF(Native, type_);
   1.105 -    }
   1.106 -    // End GC Descriptor.
   1.107 -
   1.108 -    static inline Native *cast(Object *obj) {
   1.109 -        assert(!obj || obj->is(MapKind_Native));
   1.110 -        return reinterpret_cast<Native *>(obj);
   1.111 -    }
   1.112 -};
   1.113 -
   1.114 -}
   1.115 -
   1.116 -#endif // _include_jitcraft_function_h_
   1.117 +/*
   1.118 + * Copyright (C) 2012 David Anderson
   1.119 + *
   1.120 + * This file is part of SourcePawn.
   1.121 + *
   1.122 + * SourcePawn is free software: you can redistribute it and/or modify it under
   1.123 + * the terms of the GNU General Public License as published by the Free
   1.124 + * Software Foundation, either version 3 of the License, or (at your option)
   1.125 + * any later version.
   1.126 + * 
   1.127 + * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
   1.128 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   1.129 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   1.130 + *
   1.131 + * You should have received a copy of the GNU General Public License along with
   1.132 + * SourcePawn. If not, see http://www.gnu.org/licenses/.
   1.133 + */
   1.134 +#ifndef _include_jitcraft_function_h_
   1.135 +#define _include_jitcraft_function_h_
   1.136 +
   1.137 +#include "Heap.h"
   1.138 +#include "Barriers.h"
   1.139 +#include "Types.h"
   1.140 +#include "Opcodes.h"
   1.141 +
   1.142 +namespace ke {
   1.143 +
   1.144 +class Code;
   1.145 +class Module;
   1.146 +class String;
   1.147 +
   1.148 +class Function : public Object
   1.149 +{
   1.150 +    Barriered<Code> code_;
   1.151 +    Barriered<FunctionType> type_;
   1.152 +    Barriered<String> name_;
   1.153 +    SourcePosition pos_;
   1.154 +
   1.155 + public:
   1.156 +    static Function *New(Zone *zone, Handle<Code> code, Handle<FunctionType> type, Handle<String> name,
   1.157 +                         const SourcePosition &pos);
   1.158 +
   1.159 +    Code *code() const {
   1.160 +        return code_;
   1.161 +    }
   1.162 +    FunctionType *type() const {
   1.163 +        return type_;
   1.164 +    }
   1.165 +    String *name() const {
   1.166 +        return name_;
   1.167 +    }
   1.168 +    const SourcePosition &pos() {
   1.169 +        return pos_;
   1.170 +    }
   1.171 +    unsigned nargs() {
   1.172 +        return type()->parameters()->length();
   1.173 +    }
   1.174 +    Type *argType(size_t index) {
   1.175 +        return type()->parameterAt(index);
   1.176 +    }
   1.177 +
   1.178 +    // Begin GC Descriptor.
   1.179 +    static inline size_t offsetOfCode() {
   1.180 +        return OFFSETOF(Function, code_);
   1.181 +    }
   1.182 +    static inline size_t offsetOfType() {
   1.183 +        return OFFSETOF(Function, type_);
   1.184 +    }
   1.185 +    static inline size_t offsetOfName() {
   1.186 +        return OFFSETOF(Function, name_);
   1.187 +    }
   1.188 +    // End GC Descriptor.
   1.189 +
   1.190 +    static inline Function *cast(Object *obj) {
   1.191 +        assert(!obj || obj->is(MapKind_Function));
   1.192 +        return reinterpret_cast<Function *>(obj);
   1.193 +    }
   1.194 +};
   1.195 +
   1.196 +// A Native is a function with a very specialized calling convention, intended
   1.197 +// for earlier ISourcePawnEngine API compatibility.
   1.198 +class Native : public Object
   1.199 +{
   1.200 +    Barriered<FunctionType> type_;
   1.201 +
   1.202 +    // Index into the Zone's native table.
   1.203 +    size_t index_;
   1.204 +
   1.205 +  public:
   1.206 +    static Native *New(Zone *zone, Handle<FunctionType> type, size_t index);
   1.207 +
   1.208 +    FunctionType *type() {
   1.209 +        return type_;
   1.210 +    }
   1.211 +    size_t index() const {
   1.212 +        return index_;
   1.213 +    }
   1.214 +
   1.215 +    // Begin GC Descriptor.
   1.216 +    static inline size_t offsetOfType() {
   1.217 +        return OFFSETOF(Native, type_);
   1.218 +    }
   1.219 +    // End GC Descriptor.
   1.220 +
   1.221 +    static inline Native *cast(Object *obj) {
   1.222 +        assert(!obj || obj->is(MapKind_Native));
   1.223 +        return reinterpret_cast<Native *>(obj);
   1.224 +    }
   1.225 +};
   1.226 +
   1.227 +}
   1.228 +
   1.229 +#endif // _include_jitcraft_function_h_