本文整理汇总了C++中CVariable类的典型用法代码示例。如果您正苦于以下问题:C++ CVariable类的具体用法?C++ CVariable怎么用?C++ CVariable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/***************************************************************************
* 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: iterator
void CConfiguration::LoadFromFile(const CString& FileName)
{
CStringList configuration, sub_strings;
CStringListIterator iterator(&configuration);
configuration.LoadFromFile(FileName);
//
for (int i = 0; i < configuration.GetCount(); i++)
{
ParseStr(configuration[i],"=;",sub_strings);
CVariable variable = VarNamed(sub_strings[0]);
if (variable.GetType()==VARIABLE_TYPE_CHAR)
{
CStringList sub_strings2;
ParseStr(sub_strings[1],"''",sub_strings2);
variable.SetString(sub_strings2[1]);
}
else if (variable.GetType()==VARIABLE_TYPE_STRING)
{
CStringList sub_strings2;
ParseStr(sub_strings[1],"\"\"",sub_strings2);
variable.SetString(sub_strings2[1]);
}
sub_strings.Clear();
}
}
示例3: VarIndex
int CConfiguration::VarIndex(const CString& Name) const
{
for (size_t i = 0; i < m_Variables.size(); i++)
{
CVariable *variable = m_Variables[i];
if (variable->GetName()==Name) return i;
}
return INVALID_INDEX;
}
示例4: Visit
void CAddressGenerationVisitor::Visit(CVariable &AStmt)
{
if (AStmt.GetSymbol()->GetGlobal()) {
Asm.Add(PUSH, "$" + AStmt.GetName());
} else {
Asm.Add(LEA, mem(AStmt.GetSymbol()->GetOffset(), EBP), EAX);
Asm.Add(PUSH, EAX);
}
}
示例5: OPERAND_FLAG
/***************************************************************************
* 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;
}
示例6: IndexFromBuiltinRid
/***************************************************************************
* 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;
}
示例7: assert
/***************************************************************************
* Convert var and store to type constraint var
* Src is on the top of eval stack
***************************************************************************/
void CCilVm::storeAsRestrictedType( CVariable& varDest )
{
assert( varDest.getFlag() & OPERAND_FLAG_STRICT );
switch( varDest.iOperandType )
{
case OPERAND_UNDEFINED:
case OPERAND_NULL:
case OPERAND_NAN:
//Throw TypeError
ThrowExceptionFromVm( &wstring( ERRORSTRING_TYPEERROR_STORESTATICFIELD ),
&wstring( NAME_BUILTIN_ERROR_OBJECT ),
ERROR_TYPEERROR_STORESTATICFIELD );
break;
case OPERAND_INT:
varDest.iValue = getEvalStackFirstEntry().toInt();
break;
case OPERAND_INT64:
varDest.i64Value = getEvalStackFirstEntry().toInt64();
break;
case OPERAND_FLOAT:
varDest.fValue = getEvalStackFirstEntry().toFloat();
break;
case OPERAND_DOUBLE:
varDest.dValue = getEvalStackFirstEntry().toDouble();
break;
case OPERAND_BOOLEAN:
varDest.bValue = getEvalStackFirstEntry().toBoolean();
break;
case OPERAND_STRING:
varDest.pString = getEvalStackFirstEntry().toString( this );
break;
case OPERAND_OBJECTREF:
{
//Try object conversion
CObjectTypeInfo& info = getMetaData().getObject( varDest.GetConstraintRid() );
RID ridCtor = info.getConstructor();
CVariable vars[ 2 ];
vars[ 0 ] = varDest;
vars[ 1 ] = getEvalStackFirstEntry();
CVariable* pVar = invokeMethod( ridCtor, 2, vars );
delete( pVar );
}
break;
case OPERAND_UNSIGNEDINT:
case OPERAND_UNSIGNEDINT64:
case OPERAND_SYSTEM_DELETION:
default:
Debug_Fatal( "Unhandled type constraint");
break;
}
}
示例8: sizeof
void CTeslaAPIVariables::Serialize (CArchive& ar) {
CaImAPICollection<CVariable>::Serialize (ar);
uvar32_64 n, size;
if (ar.IsLoading ()) {
ar.Read (&size, sizeof (uvar32_64));
CVariable *var = new CVariable (m_pTesla, "", "");
for (n = 0; n < size; ++n) {
var->Serialize (ar);
Add (*var);
}
delete var;
}
}
示例9: fopen
void CConfiguration::SaveToFile(const CString& FileName)
{
FILE *stream = fopen(FileName.GetCString(),"wt");
for (size_t i = 0; i < m_Variables.size(); i++)
{
CVariable *variable = m_Variables[i];
CString string = variable->GetName()+"=";
if ((variable->GetType()==VARIABLE_TYPE_STRING)||
(variable->GetType()==VARIABLE_TYPE_CHAR))
{ string+="\""+variable->GetString()+"\""; }
else
{ string+=variable->GetString(); }
string.Append(';').AppendEOL();
fwrite(string.GetCString(),string.GetLength(),1,stream);
}
fclose(stream);
}
示例10: assert
/***************************************************************************
* 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;
}
示例11: assert
bool CArrayObject::CilPredicater( const CVariable& elem1,
const CVariable& elem2 )
{
assert( g_ridPredicater != RID_NULL );
assert( g_pVm != NULL );
//Invoke predicater
CVariable vars[ 3 ];
vars[ 1 ] = elem1;
vars[ 2 ] = elem2;
CVariable* pResult = g_pVm->invokeMethod( g_ridPredicater,
3,
vars );
bool bReturn = (pResult->toInt() < 0);
delete( pResult );
return bReturn;
}
示例12: sizeof
void ParaEngine::CVariable::Clone(const CVariable& value)
{
ChangeType(value.GetType());
m_strVal = value.m_strVal;
memcpy(m_vector4, value.m_vector4, sizeof(float) * 4);
if (value.m_pAnimated)
{
// TODO: copy animated data.
PE_ASSERT(false);
}
}
示例13: setNewImpactScheme
/*
* Set a new mapping scheme of property impact
*/
void CHarvestSource::setNewImpactScheme()
{
H_AUTO(CHarvestSource_setNewImpactScheme);
// Set mapping scheme of property impact
if ( _IsInNewbieMode )
{
// Force "low dangers" for 1 newbie extractor
_IImpactMappingScheme = (uint16)LowDangerMappings[RandomGenerator.rand( 1 )];
}
else
{
// Normal dangers
if ( ForageForceImpactScheme.get() == -1 )
_IImpactMappingScheme = (uint16)RandomGenerator.rand( 5 );
else
_IImpactMappingScheme = (uint16)ForageForceImpactScheme.get();
}
sendMessageToExtractors( "FORAGE_SOURCE_IMPACT_MODE", (sint32)_IImpactMappingScheme );
#ifdef NL_DEBUG
nldebug( "FG: map scheme: %u", _IImpactMappingScheme );
#endif
}
示例14: saveToFile
// ----------------------------------------------------------------------------
void CMissionQueueManager::saveToFile()
{
H_AUTO(CMissionQueueManagerSaveToFile);
if( _InitOk )
{
string sFilename = MissionQueueFile.get();
// save file via Backup Service (BS)
try
{
static CPersistentDataRecordRyzomStore pdr;
pdr.clear();
store(pdr);
CBackupMsgSaveFile msg( sFilename, CBackupMsgSaveFile::SaveFile, Bsi );
{
std::string s;
pdr.toString(s);
msg.DataMsg.serialBuffer((uint8*)&s[0], (uint)s.size());
}
Bsi.sendFile( msg );
}
catch(const Exception &)
{
nlwarning("(EGS)<CMissionQueueManager::saveToFile> : Can't serial file %s (connection with BS service down ?)",sFilename.c_str());
return;
}
}
}
示例15: getline
/**
* updateShardOpenFromFile()
* Update ShardOpen from a file.
* Read a line of text in the file, converts it to int (atoi), then casts into bool for ShardOpen.
*/
void updateShardOpenFromFile(const std::string& filename)
{
CIFile f;
if (!f.open(filename))
{
nlwarning("Failed to update ShardOpen from file '%s', couldn't open file", filename.c_str());
return;
}
try
{
char readBuffer[256];
f.getline(readBuffer, 256);
sint state;
NLMISC::fromString(std::string(readBuffer), state);
setShardOpenState((TShardOpenState)state);
nlinfo("Updated ShardOpen state to '%u' from file '%s'", ShardOpen.get(), filename.c_str());
}
catch (const Exception& e)
{
nlwarning("Failed to update ShardOpen from file '%s', exception raised while getline() '%s'", filename.c_str(), e.what());
}
}