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