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