src/Functions.cpp
author David Anderson <dvander@alliedmods.net>
Sun Nov 18 15:50:41 2012 -0800 (2012-11-18)
changeset 217 c22e983b3b6e
parent 195 c1ba166f3fc4
child 263 ba85a47ee414
permissions -rw-r--r--
Get preinc working again.
dvander@26
     1
/*
dvander@26
     2
 * Copyright (C) 2012 David Anderson
dvander@26
     3
 *
dvander@119
     4
 * This file is part of SourcePawn.
dvander@26
     5
 *
dvander@119
     6
 * SourcePawn is free software: you can redistribute it and/or modify it under
dvander@26
     7
 * the terms of the GNU General Public License as published by the Free
dvander@26
     8
 * Software Foundation, either version 3 of the License, or (at your option)
dvander@26
     9
 * any later version.
dvander@26
    10
 * 
dvander@119
    11
 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
dvander@26
    12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@26
    13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
dvander@26
    14
 *
dvander@26
    15
 * You should have received a copy of the GNU General Public License along with
dvander@119
    16
 * SourcePawn. If not, see http://www.gnu.org/licenses/.
dvander@26
    17
 */
dvander@26
    18
#include "Functions.h"
dvander@26
    19
#include "Modules.h"
dvander@26
    20
#include "Zone.h"
dvander@26
    21
#include "Heap-inl.h"
dvander@26
    22
dvander@59
    23
using namespace ke;
dvander@26
    24
dvander@26
    25
Function *
dvander@195
    26
Function::New(Zone *zone, Handle<Code> code, Handle<FunctionType> type, Handle<String> name,
dvander@64
    27
              const SourcePosition &pos)
dvander@26
    28
{
dvander@26
    29
    Function *fun = Function::cast(zone->allocate(MapKind_Function, sizeof(Function), Heap::Tenure_Old));
dvander@26
    30
    if (!fun)
dvander@26
    31
        return NULL;
dvander@26
    32
dvander@26
    33
    fun->code_ = code;
dvander@26
    34
    fun->pos_ = pos;
dvander@26
    35
    fun->type_ = type;
dvander@64
    36
    fun->name_ = name;
dvander@26
    37
    return fun;
dvander@26
    38
}
dvander@68
    39
dvander@68
    40
Native *
dvander@195
    41
Native::New(Zone *zone, Handle<FunctionType> type, size_t index)
dvander@68
    42
{
dvander@68
    43
    Native *fun = Native::cast(zone->allocate(MapKind_Native, sizeof(Native), Heap::Tenure_Old));
dvander@68
    44
    if (!fun)
dvander@68
    45
        return NULL;
dvander@68
    46
dvander@68
    47
    fun->type_ = type;
dvander@195
    48
    fun->index_ = index;
dvander@68
    49
    return fun;
dvander@68
    50
}