本文整理汇总了C++中Literals类的典型用法代码示例。如果您正苦于以下问题:C++ Literals类的具体用法?C++ Literals怎么用?C++ Literals使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Literals类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fetchMember
void fetchMember (CodeContainer& code, Literals& literals, char localType,
const std::string& name, const std::string& id, bool global)
{
int index = literals.addString (name);
opPushInt (code, index);
index = literals.addString (id);
opPushInt (code, index);
switch (localType)
{
case 'f':
opFetchMemberFloat (code, global);
break;
case 's':
opFetchMemberShort (code, global);
break;
case 'l':
opFetchMemberLong (code, global);
break;
default:
assert (0);
}
}
示例2: assignToMember
void assignToMember (CodeContainer& code, Literals& literals, char localType,
const std::string& name, const std::string& id, const CodeContainer& value,
char valueType, bool global)
{
int index = literals.addString (name);
opPushInt (code, index);
index = literals.addString (id);
opPushInt (code, index);
std::copy (value.begin(), value.end(), std::back_inserter (code));
if (localType!=valueType)
{
if (localType=='f' && (valueType=='l' || valueType=='s'))
{
opIntToFloat (code);
}
else if ((localType=='l' || localType=='s') && valueType=='f')
{
opFloatToInt (code);
}
}
switch (localType)
{
case 'f':
opStoreMemberFloat (code, global);
break;
case 's':
opStoreMemberShort (code, global);
break;
case 'l':
opStoreMemberLong (code, global);
break;
default:
assert (0);
}
}
示例3: report
void report (CodeContainer& code, Literals& literals, const std::string& message)
{
int index = literals.addString (message);
opPushInt (code, index);
opReport (code);
}
示例4: fetchGlobal
void fetchGlobal (CodeContainer& code, Literals& literals, char localType,
const std::string& name)
{
int index = literals.addString (name);
opPushInt (code, index);
switch (localType)
{
case 'f':
opFetchGlobalFloat (code);
break;
case 's':
opFetchGlobalShort (code);
break;
case 'l':
opFetchGlobalLong (code);
break;
default:
assert (0);
}
}
示例5: message
void message (CodeContainer& code, Literals& literals, const std::string& message,
int buttons)
{
assert (buttons==0);
int index = literals.addString (message);
opPushInt (code, index);
opMessageBox (code, buttons);
}
示例6: disable
void disable (CodeContainer& code, Literals& literals, const std::string& id)
{
if (id.empty())
{
opDisable (code);
}
else
{
int index = literals.addString (id);
opPushInt (code, index);
opDisableExplicit (code);
}
}
示例7: message
void message (CodeContainer& code, Literals& literals, const std::string& message,
int buttons)
{
assert (buttons>=0);
if (buttons>=256)
throw std::runtime_error ("A message box can't have more than 255 buttons");
int index = literals.addString (message);
opPushInt (code, index);
opMessageBox (code, buttons);
}
示例8: generateInstructionCode
void Extensions::generateInstructionCode (int keyword,
std::vector<Interpreter::Type_Code>& code, Literals& literals, const std::string& id,
int optionalArguments) const
{
assert (optionalArguments>=0);
std::map<int, Instruction>::const_iterator iter = mInstructions.find (keyword);
if (iter==mInstructions.end())
throw std::logic_error ("unknown custom instruction keyword");
if (optionalArguments && iter->second.mSegment!=3)
throw std::logic_error ("instructions with optional arguments must be placed into segment 3");
if (!id.empty())
{
if (iter->second.mCodeExplicit==-1)
throw std::logic_error ("explicit references not supported");
int index = literals.addString (id);
Generator::pushInt (code, literals, index);
}
switch (iter->second.mSegment)
{
case 3:
if (optionalArguments>=256)
throw std::logic_error ("number of optional arguments is too large for segment 3");
code.push_back (Generator::segment3 (
id.empty() ? iter->second.mCode : iter->second.mCodeExplicit,
optionalArguments));
break;
case 5:
code.push_back (Generator::segment5 (
id.empty() ? iter->second.mCode : iter->second.mCodeExplicit));
break;
default:
throw std::logic_error ("unsupported code segment");
}
}
示例9: pushString
void pushString (CodeContainer& code, Literals& literals, const std::string& value)
{
int index = literals.addString (value);
opPushInt (code, index);
}
示例10: pushFloat
void pushFloat (CodeContainer& code, Literals& literals, float value)
{
int index = literals.addFloat (value);
opPushInt (code, index);
opFetchFloatLiteral (code);
}
示例11: pushInt
void pushInt (CodeContainer& code, Literals& literals, int value)
{
int index = literals.addInteger (value);
opPushInt (code, index);
opFetchIntLiteral (code);
}