本文整理汇总了C++中CVariable::setObjectRef方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariable::setObjectRef方法的具体用法?C++ CVariable::setObjectRef怎么用?C++ CVariable::setObjectRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariable
的用法示例。
在下文中一共展示了CVariable::setObjectRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setStaticFieldFunctionObject
/***************************************************************************
* setStaticFieldFunctionObject
***************************************************************************/
bool CCilVm::setStaticFieldFunctionObject( const RID rid,
const RID ridMethod )
{
assert( TypeFromToken( ridMethod ) == MDT_METHODDEF );
//Create function object and store it to static field
CVmObject newobject;
RID ridObj = getFunctionObjectRID();
newobject.setRID( ridObj );
newobject.setObjectName( getMetaData().getObjectNameRID( ridObj ) );
newobject.setPrototypeObject( &getPrototypeObject( ridObj ) );
newobject.setConstructorProperty( ridMethod );
newobject.setCallProperty( ridMethod );
getObjectPool().push_back( newobject );
CVariable var;
var.setObjectRef( &getObjectPool().back() );
METHOD_DEF& method = getMetaData().getMethod( ridMethod );
int32_t iLength = method.iNumArgments;
assert( iLength >= 0 );
CVariable varInt( iLength, OPERAND_FLAG_DONTENUM );
var.refObject->setProperty( STRING_INTERNAL_LENGTH,
varInt );
//Store the ObjectRef to a static field
setStaticField( rid, var );
return true;
}
示例2: call
/***************************************************************************
* call method
***************************************************************************/
void CErrorObject::call( CCilVm* const pVm,
const int32_t iNumArguments,
CVariable* pArguments )
{
CVariable obj;
CVmObject* pObj = pVm->createObject( pVm->getErrorObjectRID() );
obj.setObjectRef( pObj );
//Set prototype: String prototype object
obj.refObject->setPrototypeObject(
&pVm->getPrototypeObject( pVm->getErrorObjectRID() ) );
if( iNumArguments > 2 )
{
pArguments ++;
CVariable& var = *pArguments;
var.setFlag( OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_NUMBER, var ) ;
pArguments ++;
var = *pArguments;
var.convertToString( pVm );
var.setFlag( OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_MESSAGE, var );
} else if( iNumArguments > 1 )
{
pArguments ++;
CVariable& var = *pArguments;
var.convertToString( pVm );
var.setFlag( OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_MESSAGE, var );
CVariable varError( ERROR_PROPERTY_NUMBER_DEFAULT,
OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_NUMBER, varError );
}
else
{
CVariable varString( L"",
OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
CVariable varError( ERROR_PROPERTY_NUMBER_DEFAULT,
OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_MESSAGE, varString );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_NUMBER, varError );
}
CVariable var( L"",
OPERAND_FLAG( OPERAND_FLAG_DONTENUM | OPERAND_FLAG_DONTDELETE ) );
obj.refObject->setProperty( NAME_BUILTIN_ERROR_PROPERTY_NAME, var );
//Push the ObjectRef to a eval stack
pVm->pushEvalStackVariable( obj );
return;
}
示例3: InitializeVm
/***************************************************************************
* Create a prototype object
***************************************************************************/
bool CSystemObject::InitializeVm( CCilVm& vm )
{
int32_t iIndex = IndexFromBuiltinRid( vm.getSystemObjectRID() );
RID ridObjectName = vm.getMetaData().getBuiltinObjectTable()[ iIndex ].getObjectName();
assert( ridObjectName != RID_NOTDEFINED );
RID rid = vm.createPrototypeObject( vm.getSystemObjectRID(),
ridObjectName,
vm.getObjectRID() );
assert( rid == vm.getSystemObjectRID() );
VMOBJECTREF objref = vm.createObject( vm.getObjectRID() );
CVariable var;
var.setObjectRef( objref );
//Set true as an object value..
CVariable varBool( true );
objref->setValue( varBool );
//Create ExitCode property
CVariable varExitCode( 0 );
objref->setProperty( NAME_BUILTIN_SYSTEM_PROPERTY_EXITCODE, varExitCode );
//Create Environment property
//Add properties of prototype object here
vm.getPrototypeObject( vm.getSystemObjectRID() ).setProperty( NAME_BUILTIN_SYSTEM_PROPERTY_ENVIRONMENT,
var );
//---------------------------------------------------------------------------
// Bind System functions
//---------------------------------------------------------------------------
for( int32_t i = 0; i<sizeof( initParams ) / sizeof( initParams[ 0 ] ); ++i )
{
int32_t iParams;
iParams = (int32_t)RidFromToken( initParams[ i ].ridParam );
if( isBuiltinRid( initParams[ i ].ridParam ) )
{
iParams = RidFromToken( -iParams ) - 1;
}
//-----------------------------------------------------------------------
//Register methods
//-----------------------------------------------------------------------
bool b = vm.bindBuiltinMethod(
wstring( initParams[ i ].pStrSymbol ),
initParams[ i ].pMethod,
iParams );
if( !b )
return false;
}
return true;
}
示例4: LoadarrayLiteral
/***************************************************************************
* Load array literal onto the stack
***************************************************************************/
void CSystemObject::LoadarrayLiteral( CCilVm* const pVm,
const int32_t iNumArguments,
CVariable* pArguments )
{
assert( pVm != NULL );
//Array parameter can be null
assert( iNumArguments >= 1 );
//Skip this pointer
pArguments++;
//Create object object
CVmObject* pObj = pVm->createObject( pVm->getArrayObjectRID() );
CVariable var;
var.setObjectRef( pObj );
wchar_t strBuffer[ 22 ]; //22=max value width of longlong
int32_t i = 0;
for( ; i < iNumArguments - 1; ++i )
{
//Argument: 1) value of the property
swprintf( strBuffer, 22, L"%d", i );
var.refObject->setProperty( strBuffer, *pArguments );
pArguments++;
}
//Set prototype: Array prototype object
var.refObject->setPrototypeObject(
&pVm->getPrototypeObject( pVm->getArrayObjectRID() ) );
//Update 'length' property
CVariable varInt( 0 );
var.refObject->setProperty( STRING_INTERNAL_LENGTH, varInt );
//-2 means, 'prototype' & 'length'
CVariable varLength( (int32_t)var.refObject->getPropertyMap().size() - 2,
OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) );
var.refObject->setProperty( STRING_INTERNAL_LENGTH, varLength );
//Push the ObjectRef to a eval stack
pVm->pushEvalStackVariable( var );
return;
}
示例5: LoadobjectLiteral
/***************************************************************************
* Load object literal onto the stack
***************************************************************************/
void CSystemObject::LoadobjectLiteral( CCilVm* const pVm,
const int32_t iNumArguments,
CVariable* pArguments )
{
assert( pVm != NULL );
assert( iNumArguments >= 2 );
assert( iNumArguments % 2 == 1 );
//Skip this pointer
pArguments++;
int32_t i = iNumArguments;
i--;
CMetaData& Metadata = pVm->getMetaData();
//Create object object
CVmObject newobject;
RID ridObject = pVm->getObjectRID();
newobject.setRID( ridObject );
newobject.setObjectName( pVm->getMetaData().getObjectNameRID( ridObject ) );
newobject.setPrototypeObject( &pVm->getPrototypeObject( ridObject ) );
pVm->getObjectPool().push_back( newobject );
CVariable var;
var.setObjectRef( &pVm->getObjectPool().back() );
for( ; i > 0; i -= 2 )
{
//Argument: 1) value of the property
// 2) string RID of the property
RID ridString = pArguments->iValue;
assert( TypeFromToken( ridString ) == MDT_STRING );
pArguments++;
wstring& str = Metadata.getStringConstant( ridString );
var.refObject->setProperty( str, *pArguments );
pArguments++;
}
//Push the ObjectRef to a eval stack
pVm->pushEvalStackVariable( var );
return;
}