mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-21 13:14:46 +00:00
compile fixes.
This commit is contained in:
parent
50df52ecfc
commit
02447f0996
|
|
@ -228,7 +228,7 @@ bool VDataTable::getValue( SimObject *pObject, const String &pFieldName, String
|
|||
case VDataTable::k_TypeExpression :
|
||||
{
|
||||
// Evaluate.
|
||||
pValue = Con::evaluate( fieldValue, false ).getStringValue();
|
||||
pValue = Con::evaluate( fieldValue, false ).getString();
|
||||
|
||||
} break;
|
||||
|
||||
|
|
|
|||
|
|
@ -2638,23 +2638,25 @@ DefineEngineStringlyVariadicMethod(afxMagicSpell, setTimeFactor, void, 3, 4, "(F
|
|||
"@ingroup AFX")
|
||||
{
|
||||
if (argc == 3)
|
||||
object->setTimeFactor(dAtof(argv[2]));
|
||||
object->setTimeFactor(argv[2].getFloat());
|
||||
else
|
||||
{
|
||||
F32 value = argv[3].getFloat();
|
||||
|
||||
if (dStricmp(argv[2], "overall") == 0)
|
||||
object->setTimeFactor(dAtof(argv[3]));
|
||||
else if (dStricmp(argv[2], "casting") == 0)
|
||||
object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, dAtof(argv[3]));
|
||||
object->setTimeFactor(afxMagicSpell::CASTING_PHRASE, value);
|
||||
else if (dStricmp(argv[2], "launch") == 0)
|
||||
object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, dAtof(argv[3]));
|
||||
object->setTimeFactor(afxMagicSpell::LAUNCH_PHRASE, value);
|
||||
else if (dStricmp(argv[2], "delivery") == 0)
|
||||
object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, dAtof(argv[3]));
|
||||
object->setTimeFactor(afxMagicSpell::DELIVERY_PHRASE, value);
|
||||
else if (dStricmp(argv[2], "impact") == 0)
|
||||
object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, dAtof(argv[3]));
|
||||
object->setTimeFactor(afxMagicSpell::IMPACT_PHRASE, value);
|
||||
else if (dStricmp(argv[2], "linger") == 0)
|
||||
object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, dAtof(argv[3]));
|
||||
object->setTimeFactor(afxMagicSpell::LINGER_PHRASE, value);
|
||||
else
|
||||
Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getStringValue());
|
||||
Con::errorf("afxMagicSpell::setTimeFactor() -- unknown spell phrase [%s].", argv[2].getString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -874,7 +874,7 @@ DefineEngineStringlyVariadicFunction(echoThru, const char*, 2, 0, "(string passt
|
|||
for (i = 2; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::printf("%s -- [%s]", ret, argv[1].getStringValue());
|
||||
Con::printf("%s -- [%s]", ret, argv[1].getString());
|
||||
ret[0] = 0;
|
||||
|
||||
return argv[1];
|
||||
|
|
@ -894,7 +894,7 @@ DefineEngineStringlyVariadicFunction(warnThru, const char*, 2, 0, "(string passt
|
|||
for(i = 2; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::warnf("%s -- [%s]", ret, argv[1].getStringValue());
|
||||
Con::warnf("%s -- [%s]", ret, argv[1].getString());
|
||||
ret[0] = 0;
|
||||
|
||||
return argv[1];
|
||||
|
|
@ -914,7 +914,7 @@ DefineEngineStringlyVariadicFunction(errorThru, const char*, 2, 0, "(string pass
|
|||
for(i = 2; i < argc; i++)
|
||||
dStrcat(ret, argv[i], len + 1);
|
||||
|
||||
Con::errorf("%s -- [%s]", ret, argv[1].getStringValue());
|
||||
Con::errorf("%s -- [%s]", ret, argv[1].getString());
|
||||
ret[0] = 0;
|
||||
|
||||
return argv[1];
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
#include "console/debugOutputConsumer.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "console/codeInterpreter.h"
|
||||
|
||||
#include "gfx/bitmap/gBitmap.h"
|
||||
#include "gfx/gFont.h"
|
||||
|
|
@ -229,9 +228,6 @@ void StandardMainLoop::init()
|
|||
ManagedSingleton< ThreadManager >::createSingleton();
|
||||
FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
|
||||
|
||||
// Initialize the TorqueScript interpreter.
|
||||
CodeInterpreter::init();
|
||||
|
||||
// Yell if we can't initialize the network.
|
||||
if(!Net::init())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -456,6 +456,8 @@ expr
|
|||
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, NULL); }
|
||||
| VAR '[' aidx_expr ']'
|
||||
{ $$ = (ExprNode*)VarNode::alloc( $1.lineNumber, $1.value, $3 ); }
|
||||
;
|
||||
/*
|
||||
| rwDEFINE '(' var_list_decl ')' '{' statement_list '}'
|
||||
{
|
||||
const U32 bufLen = 64;
|
||||
|
|
@ -471,7 +473,7 @@ expr
|
|||
|
||||
$$ = StrConstNode::alloc( $1.lineNumber, (UTF8*)fName, false );
|
||||
}
|
||||
;
|
||||
*/
|
||||
|
||||
slot_acc
|
||||
: expr '.' IDENT
|
||||
|
|
@ -551,9 +553,12 @@ funcall_expr
|
|||
{ $$ = FuncCallExprNode::alloc( $1.lineNumber, $3.value, $1.value, $5, false); }
|
||||
| expr '.' IDENT '(' expr_list_decl ')'
|
||||
{ $1->append($5); $$ = FuncCallExprNode::alloc( $1->dbgLineNumber, $3.value, NULL, $1, true); }
|
||||
;
|
||||
/*
|
||||
| expr '(' expr_list_decl ')'
|
||||
{ $$ = FuncPointerCallExprNode::alloc( $1->dbgLineNumber, $1, $3); }
|
||||
;
|
||||
*/
|
||||
|
||||
assert_expr
|
||||
: rwASSERT '(' expr ')'
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -565,7 +565,7 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
|||
return true;
|
||||
}
|
||||
|
||||
void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, ConsoleValue &returnValue, bool noCalls, S32 setFrame)
|
||||
ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
|
||||
{
|
||||
AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
|
||||
|
||||
|
|
@ -619,7 +619,7 @@ void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, Con
|
|||
if (!gStatementList)
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
return std::move(ConsoleValue());
|
||||
}
|
||||
|
||||
resetTables();
|
||||
|
|
@ -653,7 +653,7 @@ void CodeBlock::compileExec(StringTableEntry fileName, const char *inString, Con
|
|||
if (lastIp + 1 != codeSize)
|
||||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
||||
|
||||
exec(0, fileName, NULL, 0, 0, noCalls, NULL, returnValue, setFrame);
|
||||
return std::move(exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ void ExprEvalState::setStringVariable(const char *val)
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
U32 gExecCount = 0;
|
||||
void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace, U32 argc, ConsoleValue* argv, bool noCalls, StringTableEntry packageName, ConsoleValue& returnValue, S32 setFrame)
|
||||
ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace, U32 argc, ConsoleValue* argv, bool noCalls, StringTableEntry packageName, S32 setFrame)
|
||||
{
|
||||
#ifdef TORQUE_DEBUG
|
||||
U32 stackStart = STR.mStartStackSize;
|
||||
|
|
@ -432,6 +432,7 @@ void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace,
|
|||
U32 i;
|
||||
|
||||
U32 iterDepth = 0;
|
||||
ConsoleValue returnValue;
|
||||
|
||||
incRefCount();
|
||||
F64* curFloatTable;
|
||||
|
|
@ -1738,9 +1739,8 @@ void CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNamespace,
|
|||
{
|
||||
if (nsEntry->mFunctionOffset)
|
||||
{
|
||||
ConsoleValue ret;
|
||||
nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage, ret);
|
||||
STR.setStringValue(ret.getString());
|
||||
const char* ret = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage).getString();
|
||||
STR.setStringValue(ret);
|
||||
}
|
||||
else // no body
|
||||
STR.setStringValue("");
|
||||
|
|
@ -2128,6 +2128,10 @@ execFinished:
|
|||
AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec");
|
||||
AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec");
|
||||
#endif
|
||||
|
||||
if (returnValue.getType() == ConsoleValueType::cvNone)
|
||||
returnValue.setStringTableEntry(StringTable->EmptyString());
|
||||
return std::move(returnValue);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ char* ConsoleValue::convertToBuffer() const
|
|||
return offset;
|
||||
}
|
||||
|
||||
const char* ConsoleValue::getConsoleData() const
|
||||
{
|
||||
return Con::getData(type, ct->dataPtr, 0, ct->enumTable);
|
||||
}
|
||||
|
||||
ConsoleDocFragment* ConsoleDocFragment::smFirst;
|
||||
ExprEvalState gEvalState;
|
||||
StmtNode *gStatementList;
|
||||
|
|
|
|||
|
|
@ -158,25 +158,12 @@ class ConsoleValue
|
|||
|
||||
char* convertToBuffer() const;
|
||||
|
||||
TORQUE_FORCEINLINE bool isStringType() const
|
||||
{
|
||||
return type == ConsoleValueType::cvString || type == ConsoleValueType::cvSTEntry;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool isNumberType() const
|
||||
{
|
||||
return type == ConsoleValueType::cvFloat || type == ConsoleValueType::cvInteger;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool hasAllocatedData() const
|
||||
{
|
||||
return type == ConsoleValueType::cvString || type >= ConsoleValueType::cvConsoleValueType;
|
||||
return type == ConsoleValueType::cvString || isConsoleType();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE const char* getConsoleData() const
|
||||
{
|
||||
return Con::getData(type, ct->dataPtr, 0, ct->enumTable);
|
||||
}
|
||||
const char* getConsoleData() const;
|
||||
|
||||
TORQUE_FORCEINLINE void cleanupData()
|
||||
{
|
||||
|
|
@ -192,7 +179,7 @@ public:
|
|||
type = ConsoleValueType::cvNone;
|
||||
}
|
||||
|
||||
ConsoleValue(ConsoleValue&& ref)
|
||||
ConsoleValue(ConsoleValue&& ref) noexcept
|
||||
{
|
||||
cleanupData();
|
||||
type = ref.type;
|
||||
|
|
@ -209,7 +196,7 @@ public:
|
|||
f = ref.f;
|
||||
break;
|
||||
case cvSTEntry:
|
||||
TORQUE_CASE_FALLTHROUGH
|
||||
TORQUE_CASE_FALLTHROUGH;
|
||||
case cvString:
|
||||
s = ref.s;
|
||||
break;
|
||||
|
|
@ -229,6 +216,12 @@ public:
|
|||
cleanupData();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void reset()
|
||||
{
|
||||
cleanupData();
|
||||
type = ConsoleValueType::cvNone;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE F64 getFloat() const
|
||||
{
|
||||
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
||||
|
|
@ -263,6 +256,11 @@ public:
|
|||
return getConsoleData();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE operator const char* () const
|
||||
{
|
||||
return getString();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool getBool() const
|
||||
{
|
||||
AssertFatal(type == ConsoleValueType::cvNone, "Attempted to access ConsoleValue when it has no value!");
|
||||
|
|
@ -290,6 +288,11 @@ public:
|
|||
i = val;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setString(const char* val)
|
||||
{
|
||||
setString(val, dStrlen(val));
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setString(const char* val, S32 len)
|
||||
{
|
||||
cleanupData();
|
||||
|
|
@ -315,11 +318,11 @@ public:
|
|||
s = const_cast<char*>(val);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, EnumTable* enumTable)
|
||||
TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, const EnumTable* enumTable)
|
||||
{
|
||||
cleanupData();
|
||||
type = ConsoleValueType::cvSTEntry;
|
||||
ct = new ConsoleValueConsoleType{ dataPtr, enumTable };
|
||||
ct = new ConsoleValueConsoleType{ dataPtr, const_cast<EnumTable*>(enumTable) };
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE S32 getType() const
|
||||
|
|
@ -327,6 +330,21 @@ public:
|
|||
return type;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool isStringType() const
|
||||
{
|
||||
return type == ConsoleValueType::cvString || type == ConsoleValueType::cvSTEntry;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool isNumberType() const
|
||||
{
|
||||
return type == ConsoleValueType::cvFloat || type == ConsoleValueType::cvInteger;
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE bool isConsoleType() const
|
||||
{
|
||||
return type >= ConsoleValueType::cvConsoleValueType;
|
||||
}
|
||||
|
||||
static void init();
|
||||
static S32 getConstantBufferCount() { return (S32)ConversionBufferSize / StringSize; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -480,8 +480,6 @@ Dictionary::Entry::Entry(StringTableEntry in_name)
|
|||
|
||||
Dictionary::Entry::~Entry()
|
||||
{
|
||||
value.cleanup();
|
||||
|
||||
if (notify)
|
||||
delete notify;
|
||||
}
|
||||
|
|
@ -560,20 +558,13 @@ Dictionary::Entry* Dictionary::addVariable(const char *name,
|
|||
}
|
||||
|
||||
Entry *ent = add(StringTable->insert(name));
|
||||
|
||||
if (ent->value.type <= ConsoleValue::TypeInternalString &&
|
||||
ent->value.bufferLen > 0)
|
||||
dFree(ent->value.sval);
|
||||
|
||||
ent->value.type = type;
|
||||
ent->value.dataPtr = dataPtr;
|
||||
ent->mUsage = usage;
|
||||
|
||||
// Fetch enum table, if any.
|
||||
|
||||
ConsoleBaseType* conType = ConsoleBaseType::getType(type);
|
||||
AssertFatal(conType, "Dictionary::addVariable - invalid console type");
|
||||
ent->value.enumTable = conType->getEnumTable();
|
||||
ent->value.setConsoleData(type, dataPtr, conType->getEnumTable());
|
||||
|
||||
return ent;
|
||||
}
|
||||
|
|
@ -1303,9 +1294,11 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, ExprEvalSta
|
|||
switch (mType)
|
||||
{
|
||||
case StringCallbackType:
|
||||
{
|
||||
const char* str = cb.mStringCallbackFunc(state->thisObject, argc, argv);
|
||||
result.setString(str, dStrlen(str));
|
||||
break;
|
||||
}
|
||||
case IntCallbackType:
|
||||
result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -274,8 +274,6 @@ public:
|
|||
|
||||
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
||||
|
||||
|
||||
|
||||
class Dictionary
|
||||
{
|
||||
public:
|
||||
|
|
@ -307,7 +305,6 @@ public:
|
|||
mUsage = NULL;
|
||||
mIsConstant = false;
|
||||
mNext = NULL;
|
||||
value.init();
|
||||
}
|
||||
|
||||
Entry(StringTableEntry name);
|
||||
|
|
@ -317,7 +314,7 @@ public:
|
|||
|
||||
void reset() {
|
||||
name = NULL;
|
||||
value.cleanup();
|
||||
value.reset();
|
||||
if (notify)
|
||||
delete notify;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1187,8 +1187,7 @@ public:
|
|||
if (Con::isMainThread())
|
||||
{
|
||||
ConsoleStackFrameSaver sav; sav.save();
|
||||
CSTK.reserveValues(mArgc + sizeof...(ArgTs), mArgv);
|
||||
mArgv[ 0 ].value->setStackStringValue(mCallbackName);
|
||||
mArgv[ 0 ].setStringTableEntry(mCallbackName);
|
||||
|
||||
Helper::marshallEach(mArgc, mArgv, args...);
|
||||
|
||||
|
|
@ -1199,7 +1198,7 @@ public:
|
|||
SimConsoleThreadExecCallback cb;
|
||||
SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(mArgc + sizeof...(ArgTs), NULL, false, &cb);
|
||||
evt->populateArgs(mArgv);
|
||||
mArgv[ 0 ].value->setStackStringValue(mCallbackName);
|
||||
mArgv[ 0 ].setStringTableEntry(mCallbackName);
|
||||
|
||||
Helper::marshallEach(mArgc, mArgv, args...);
|
||||
|
||||
|
|
@ -1233,7 +1232,6 @@ public:
|
|||
if (Con::isMainThread())
|
||||
{
|
||||
ConsoleStackFrameSaver sav; sav.save();
|
||||
CSTK.reserveValues(mArgc+sizeof...(ArgTs), mArgv);
|
||||
mArgv[ 0 ].setString(simCB, dStrlen(simCB));
|
||||
|
||||
Helper::marshallEach(mArgc, mArgv, args...);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static void dumpVariable( Stream& stream,
|
|||
{
|
||||
// Skip variables defined in script.
|
||||
|
||||
if( entry->value.type < 0 )
|
||||
if( !entry->value.isConsoleType() )
|
||||
return;
|
||||
|
||||
// Skip internals... don't export them.
|
||||
|
|
@ -149,7 +149,7 @@ static void dumpVariable( Stream& stream,
|
|||
|
||||
// Skip variables for which we can't decipher their type.
|
||||
|
||||
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.type );
|
||||
ConsoleBaseType* type = ConsoleBaseType::getType( entry->value.getType() );
|
||||
if( !type )
|
||||
{
|
||||
Con::errorf( "Can't find type for variable '%s'", entry->name );
|
||||
|
|
|
|||
104
Engine/source/console/optimizer.cpp
Normal file
104
Engine/source/console/optimizer.cpp
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2013 GarageGames, LLC
|
||||
// Copyright (c) 2021 TGEMIT Authors & Contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "console/console.h"
|
||||
#include "console/codeBlock.h"
|
||||
|
||||
static bool isLiteralNumber(ExprNode* node)
|
||||
{
|
||||
ExprNodeName name = node->getExprNodeNameEnum();
|
||||
return name == NameFloatNode || name == NameIntNode;
|
||||
}
|
||||
|
||||
static F64 getFloatValue(ExprNode* node)
|
||||
{
|
||||
if (node->getExprNodeNameEnum() == NameFloatNode)
|
||||
return static_cast<FloatNode*>(node)->value;
|
||||
return (F64)static_cast<IntNode*>(node)->value;
|
||||
}
|
||||
|
||||
static S32 getIntValue(ExprNode* node)
|
||||
{
|
||||
if (node->getExprNodeNameEnum() == NameFloatNode)
|
||||
return (S32)static_cast<FloatNode*>(node)->value;
|
||||
return static_cast<IntNode*>(node)->value;
|
||||
}
|
||||
|
||||
bool FloatBinaryExprNode::optimize()
|
||||
{
|
||||
// Perform constant folding
|
||||
if (isLiteralNumber(right) && isLiteralNumber(left))
|
||||
{
|
||||
F64 rightValue = getFloatValue(right);
|
||||
F64 leftValue = getFloatValue(left);
|
||||
F64 result = 0.0;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case '+':
|
||||
result = leftValue + rightValue;
|
||||
break;
|
||||
case '-':
|
||||
result = leftValue - rightValue;
|
||||
break;
|
||||
case '*':
|
||||
result = leftValue * rightValue;
|
||||
break;
|
||||
case '/':
|
||||
if (rightValue != 0.0)
|
||||
result = leftValue / rightValue;
|
||||
break;
|
||||
}
|
||||
|
||||
optimizedNode = FloatNode::alloc(dbgLineNumber, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IntBinaryExprNode::optimize()
|
||||
{
|
||||
if (op == '%' && left->getExprNodeNameEnum() == NameVarNode && isLiteralNumber(right))
|
||||
{
|
||||
// %a % intconst
|
||||
S32 val = getIntValue(right);
|
||||
switch (val)
|
||||
{
|
||||
case 2:
|
||||
op = '&';
|
||||
optimizedNode = IntNode::alloc(dbgLineNumber, 1);
|
||||
return true;
|
||||
case 4:
|
||||
op = '&';
|
||||
optimizedNode = IntNode::alloc(dbgLineNumber, 3);
|
||||
return true;
|
||||
case 8:
|
||||
op = '&';
|
||||
optimizedNode = IntNode::alloc(dbgLineNumber, 7);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2962,7 +2962,7 @@ DefineEngineStringlyVariadicMethod( SimObject, call, const char*, 3, 0, "( strin
|
|||
"@param args Zero or more arguments for the method.\n"
|
||||
"@return The result of the method call." )
|
||||
{
|
||||
argv[1] = argv[2];
|
||||
argv[1].setString(argv[2], dStrlen(argv[2]));
|
||||
return Con::execute( object, argc - 1, argv + 1 );
|
||||
}
|
||||
|
||||
|
|
@ -3065,9 +3065,9 @@ DefineEngineStringlyVariadicMethod( SimObject,schedule, S32, 4, 0, "( float time
|
|||
"@param args The arguments with which to call the method.\n"
|
||||
"@return The numeric ID of the created schedule. Can be used to cancel the call.\n" )
|
||||
{
|
||||
U32 timeDelta = U32(dAtof(argv[2]));
|
||||
argv[2] = argv[3];
|
||||
argv[3] = argv[1];
|
||||
U32 timeDelta = U32(argv[2].getFloat());
|
||||
argv[2].setString(argv[3].getString());
|
||||
argv[3].setString(argv[1].getString());
|
||||
SimConsoleEvent *evt = new SimConsoleEvent(argc - 2, argv + 2, true);
|
||||
S32 ret = Sim::postEvent(object, evt, Sim::getCurrentTime() + timeDelta);
|
||||
// #ifdef DEBUG
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef 0
|
||||
#if 0
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
|
|
|
|||
|
|
@ -361,10 +361,8 @@ void GuiGameListMenuCtrl::onRenderSliderOption(Row* row, Point2I currentOffset)
|
|||
// calculate text to be at the center between the arrows
|
||||
GFont* font = profile->mFont;
|
||||
|
||||
ConsoleValue val;
|
||||
val.setFloatValue(row->mValue);
|
||||
|
||||
const char* stringVal = val.getStringValue();
|
||||
char stringVal[32];
|
||||
dSprintf(stringVal, 32, "%f", row->mValue);
|
||||
|
||||
S32 textWidth = font->getStrWidth(stringVal);
|
||||
S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ DefineEngineStringlyVariadicMethod(CustomShaderFeatureData, writeLine, void, 3,
|
|||
"@param args Zero or more arguments for the method.\n"
|
||||
"@return The result of the method call.")
|
||||
{
|
||||
object->writeLine(argv[2], argc - 3, argv + 3);
|
||||
object->writeLine(argv[2].getString(), argc - 3, argv + 3);
|
||||
}
|
||||
|
||||
DefineEngineMethod(CustomShaderFeatureData, hasFeature, bool, (String name), (""), "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue