src/Functions.cpp
author David Anderson <dvander@alliedmods.net>
Mon Sep 17 00:10:01 2012 -0700 (2012-09-17)
changeset 194 b029d63565a2
parent 119 ac72cd783392
child 195 c1ba166f3fc4
permissions -rw-r--r--
Implement sizeof operator.
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@64
    26
Function::New(Zone *zone, Handle<Code> code, Handle<Type> 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@68
    41
Native::New(Zone *zone, Handle<Type> type, Handle<String> name)
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@68
    48
    fun->name_ = name;
dvander@68
    49
    fun->function_ = NULL;
dvander@68
    50
    return fun;
dvander@68
    51
}