dvander@26: /* dvander@26: * Copyright (C) 2012 David Anderson dvander@26: * dvander@119: * This file is part of SourcePawn. dvander@26: * dvander@119: * SourcePawn is free software: you can redistribute it and/or modify it under dvander@26: * the terms of the GNU General Public License as published by the Free dvander@26: * Software Foundation, either version 3 of the License, or (at your option) dvander@26: * any later version. dvander@26: * dvander@119: * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY dvander@26: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@26: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. dvander@26: * dvander@26: * You should have received a copy of the GNU General Public License along with dvander@119: * SourcePawn. If not, see http://www.gnu.org/licenses/. dvander@26: */ dvander@26: #include "Functions.h" dvander@26: #include "Modules.h" dvander@26: #include "Zone.h" dvander@26: #include "Heap-inl.h" dvander@26: dvander@59: using namespace ke; dvander@26: dvander@26: Function * dvander@195: Function::New(Zone *zone, Handle code, Handle type, Handle name, dvander@64: const SourcePosition &pos) dvander@26: { dvander@26: Function *fun = Function::cast(zone->allocate(MapKind_Function, sizeof(Function), Heap::Tenure_Old)); dvander@26: if (!fun) dvander@26: return NULL; dvander@26: dvander@26: fun->code_ = code; dvander@26: fun->pos_ = pos; dvander@26: fun->type_ = type; dvander@64: fun->name_ = name; dvander@26: return fun; dvander@26: } dvander@68: dvander@68: Native * dvander@195: Native::New(Zone *zone, Handle type, size_t index) dvander@68: { dvander@68: Native *fun = Native::cast(zone->allocate(MapKind_Native, sizeof(Native), Heap::Tenure_Old)); dvander@68: if (!fun) dvander@68: return NULL; dvander@68: dvander@68: fun->type_ = type; dvander@195: fun->index_ = index; dvander@68: return fun; dvander@68: }