extensions/bintools/CallMaker.cpp
author Scott Ehlert <ds@alliedmods.net>
Fri Jun 22 04:35:27 2007 +0000 (2007-06-22)
changeset 999 8d7e956f996d
parent 757 b799caa9a190
child 1226 478550a4d5ec
permissions -rw-r--r--
don't fix what isn't broken I guess :\ (Fixed reserved slots once and for all...)
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod BinTools Extension
     5  * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
     6  * ===============================================================
     7  *
     8  * This program is free software; you can redistribute it and/or
     9  * modify it under the terms of the GNU General Public License
    10  * as published by the Free Software Foundation; either version 2
    11  * of the License, or (at your option) any later version.
    12  * This program is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  * 
    17  * You should have received a copy of the GNU General Public License
    18  * along with this program; if not, write to the Free Software
    19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    20  *
    21  * Version: $Id$
    22  */
    23 
    24 #include "CallMaker.h"
    25 #include "CallWrapper.h"
    26 #include "jit_call.h"
    27 
    28 ICallWrapper *CallMaker::CreateCall(void *address,
    29 						 CallConvention cv,
    30 						 const PassInfo *retInfo,
    31 						 const PassInfo paramInfo[],
    32 						 unsigned int numParams)
    33 {
    34 	CallWrapper *pWrapper = new CallWrapper(cv, paramInfo, retInfo, numParams);
    35 	pWrapper->m_Addrs[ADDR_CALLEE] = address;
    36 
    37 	JIT_Compile(pWrapper, FuncAddr_Direct);
    38 
    39 	return pWrapper;
    40 }
    41 
    42 ICallWrapper *CallMaker::CreateVCall(unsigned int vtblIdx, 
    43 									 unsigned int vtblOffs, 
    44 									 unsigned int thisOffs, 
    45 									 const PassInfo *retInfo, 
    46 									 const PassInfo paramInfo[], 
    47 									 unsigned int numParams)
    48 {
    49 	CallWrapper *pWrapper = new CallWrapper(CallConv_ThisCall, paramInfo, retInfo, numParams);
    50 	pWrapper->m_VtInfo.thisOffs = thisOffs;
    51 	pWrapper->m_VtInfo.vtblIdx = vtblIdx;
    52 	pWrapper->m_VtInfo.vtblOffs = vtblOffs;
    53 
    54 	JIT_Compile(pWrapper, FuncAddr_VTable);
    55 
    56 	return pWrapper;
    57 }