diff --git a/Engine/source/T3D/assets/SoundAsset.cpp b/Engine/source/T3D/assets/SoundAsset.cpp index 14cb00744..d00c0dbe2 100644 --- a/Engine/source/T3D/assets/SoundAsset.cpp +++ b/Engine/source/T3D/assets/SoundAsset.cpp @@ -40,6 +40,10 @@ #include "assets/assetPtr.h" #endif +#ifndef _SFXSOURCE_H_ +#include "sfx/sfxSource.h" +#endif + // Debug Profiling. #include "platform/profiler.h" #include "sfx/sfxTypes.h" @@ -159,7 +163,7 @@ void SoundAsset::initPersistFields() addField("maxDistance", TypeF32, Offset(mProfileDesc.mMaxDistance, SoundAsset), "Max distance for sound."); addField("coneInsideAngle", TypeS32, Offset(mProfileDesc.mConeInsideAngle, SoundAsset), "Cone inside angle."); addField("coneOutsideAngle", TypeS32, Offset(mProfileDesc.mConeOutsideAngle, SoundAsset), "Cone outside angle."); - addField("coneOutsideVolume", TypeS32, Offset(mProfileDesc.mConeOutsideVolume, SoundAsset), "Cone outside volume."); + addField("coneOutsideVolume", TypeF32, Offset(mProfileDesc.mConeOutsideVolume, SoundAsset), "Cone outside volume."); addField("rolloffFactor", TypeF32, Offset(mProfileDesc.mRolloffFactor, SoundAsset), "Rolloff factor."); addField("scatterDistance", TypePoint3F, Offset(mProfileDesc.mScatterDistance, SoundAsset), "Randomization to the spacial position of the sound."); addField("sourceGroup", TypeSFXSourceName, Offset(mProfileDesc.mSourceGroup, SoundAsset), "Group that sources playing with this description should be put into."); @@ -181,13 +185,7 @@ void SoundAsset::initializeAsset(void) if (mSoundFile == StringTable->EmptyString()) return; - //ResourceManager::get().getChangedSignal.notify(this, &SoundAsset::_onResourceChanged); - - //Ensure our path is expando'd if it isn't already mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath; - - mSoundPath = expandAssetFilePath(mSoundPath); - loadSound(); } @@ -208,7 +206,6 @@ void SoundAsset::onAssetRefresh(void) //Update mSoundPath = getOwned() ? expandAssetFilePath(mSoundFile) : mSoundPath; - loadSound(); } @@ -225,7 +222,7 @@ bool SoundAsset::loadSound() else {// = new SFXProfile(mProfileDesc, mSoundFile, mPreload); mSFXProfile.setDescription(&mProfileDesc); - mSFXProfile.setSoundFileName(mSoundFile); + mSFXProfile.setSoundFileName(mSoundPath); mSFXProfile.setPreload(mPreload); } @@ -254,11 +251,106 @@ void SoundAsset::setSoundFile(const char* pSoundFile) refreshAsset(); } +StringTableEntry SoundAsset::getAssetIdByFileName(StringTableEntry fileName) +{ + if (fileName == StringTable->EmptyString()) + return StringTable->EmptyString(); + + StringTableEntry materialAssetId = ""; + + AssetQuery query; + U32 foundCount = AssetDatabase.findAssetType(&query, "SoundAsset"); + if (foundCount != 0) + { + for (U32 i = 0; i < foundCount; i++) + { + SoundAsset* soundAsset = AssetDatabase.acquireAsset(query.mAssetList[i]); + if (soundAsset && soundAsset->getSoundPath() == fileName) + { + materialAssetId = soundAsset->getAssetId(); + AssetDatabase.releaseAsset(query.mAssetList[i]); + break; + } + AssetDatabase.releaseAsset(query.mAssetList[i]); + } + } + + return materialAssetId; +} + +U32 SoundAsset::getAssetById(StringTableEntry assetId, AssetPtr* materialAsset) +{ + (*materialAsset) = assetId; + + if (materialAsset->notNull()) + { + return (*materialAsset)->mLoadedState; + } + else + { + //Well that's bad, loading the fallback failed. + Con::warnf("MaterialAsset::getAssetById - Finding of asset with id %s failed with no fallback asset", assetId); + return AssetErrCode::Failed; + } +} + +U32 SoundAsset::getAssetByFileName(StringTableEntry fileName, AssetPtr* soundAsset) +{ + AssetQuery query; + U32 foundAssetcount = AssetDatabase.findAssetType(&query, "SoundAsset"); + if (foundAssetcount == 0) + { + //Well that's bad, loading the fallback failed. + Con::warnf("MaterialAsset::getAssetByMaterialName - Finding of asset associated with filename %s failed with no fallback asset", fileName); + return AssetErrCode::Failed; + } + else + { + for (U32 i = 0; i < foundAssetcount; i++) + { + SoundAsset* tSoundAsset = AssetDatabase.acquireAsset(query.mAssetList[i]); + if (tSoundAsset && tSoundAsset->getSoundPath() == fileName) + { + soundAsset->setAssetId(query.mAssetList[i]); + AssetDatabase.releaseAsset(query.mAssetList[i]); + return (*soundAsset)->mLoadedState; + } + AssetDatabase.releaseAsset(query.mAssetList[i]); //cleanup if that's not the one we needed + } + } + + //No good match + return AssetErrCode::Failed; +} + DefineEngineMethod(SoundAsset, getSoundPath, const char*, (), , "") { return object->getSoundPath(); } +DefineEngineMethod(SoundAsset, playSound, S32, (Point3F position), (Point3F::Zero), + "Gets the number of materials for this shape asset.\n" + "@return Material count.\n") +{ + if (object->getSfxProfile()) + { + MatrixF transform; + transform.setPosition(position); + SFXSource* source = SFX->playOnce(object->getSfxProfile(), &transform, NULL, -1); + return source->getId(); + } + else + return 0; +} + +#ifdef TORQUE_TOOLS +DefineEngineStaticMethod(SoundAsset, getAssetIdByFilename, const char*, (const char* filePath), (""), + "Queries the Asset Database to see if any asset exists that is associated with the provided file path.\n" + "@return The AssetId of the associated asset, if any.") +{ + return SoundAsset::getAssetIdByFileName(StringTable->insert(filePath)); +} +#endif IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetPtr); ConsoleDocClass(GuiInspectorTypeSoundAssetPtr, @@ -276,12 +368,63 @@ void GuiInspectorTypeSoundAssetPtr::consoleInit() GuiControl * GuiInspectorTypeSoundAssetPtr::constructEditControl() { - return nullptr; + // Create base filename edit controls + GuiControl* retCtrl = Parent::constructEditControl(); + if (retCtrl == NULL) + return retCtrl; + + // Change filespec + char szBuffer[512]; + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"SoundAsset\", \"AssetBrowser.changeAsset\", %s, \"\");", + getIdString()); + mBrowseButton->setField("Command", szBuffer); + + setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString()); + + // Create "Open in Editor" button + mEditButton = new GuiBitmapButtonCtrl(); + + dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.editAsset(%d.getText());", retCtrl->getId()); + mEditButton->setField("Command", szBuffer); + + char bitmapName[512] = "ToolsModule:SFXEmitter_image"; + mEditButton->setBitmap(StringTable->insert(bitmapName)); + + mEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile"); + mEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile"); + mEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000"); + mEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Test play this sound"); + + mEditButton->registerObject(); + addObject(mEditButton); + + return retCtrl; } bool GuiInspectorTypeSoundAssetPtr::updateRects() { - return false; + S32 dividerPos, dividerMargin; + mInspector->getDivider(dividerPos, dividerMargin); + Point2I fieldExtent = getExtent(); + Point2I fieldPos = getPosition(); + + mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y); + mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y); + + bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent); + if (mBrowseButton != NULL) + { + mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4); + resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent); + } + + if (mEditButton != NULL) + { + RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4); + resized |= mEditButton->resize(shapeEdRect.point, shapeEdRect.extent); + } + + return resized; } IMPLEMENT_CONOBJECT(GuiInspectorTypeSoundAssetId); diff --git a/Engine/source/T3D/assets/SoundAsset.h b/Engine/source/T3D/assets/SoundAsset.h index bbaeaef9d..321c461b4 100644 --- a/Engine/source/T3D/assets/SoundAsset.h +++ b/Engine/source/T3D/assets/SoundAsset.h @@ -122,6 +122,9 @@ public: bool isLoop() { return mProfileDesc.mIsLooping; } bool is3D() { return mProfileDesc.mIs3D; } + static StringTableEntry getAssetIdByFileName(StringTableEntry fileName); + static U32 getAssetById(StringTableEntry assetId, AssetPtr* materialAsset); + static U32 getAssetByFileName(StringTableEntry fileName, AssetPtr* matAsset); protected: virtual void initializeAsset(void); @@ -143,7 +146,7 @@ class GuiInspectorTypeSoundAssetPtr : public GuiInspectorTypeFileName typedef GuiInspectorTypeFileName Parent; public: - GuiBitmapButtonCtrl* mSoundButton; + GuiBitmapButtonCtrl* mEditButton; DECLARE_CONOBJECT(GuiInspectorTypeSoundAssetPtr); static void consoleInit(); @@ -168,14 +171,14 @@ public: /// Declares a sound asset /// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions /// -#define DECLARE_SOUNDASSET(className, name, profile) public: \ +#define DECLARE_SOUNDASSET(className, name) public: \ Resource m##name;\ StringTableEntry m##name##Name; \ StringTableEntry m##name##AssetId;\ AssetPtr m##name##Asset = NULL;\ - SFXProfile* m##name##Profile = &profile;\ + SFXProfile* m##name##Profile = NULL;\ public: \ - const StringTableEntry get##name##File() const { return m##name##Name); }\ + const StringTableEntry get##name##File() const { return m##name##Name; }\ void set##name##File(const FileName &_in) { m##name##Name = StringTable->insert(_in.c_str());}\ const AssetPtr & get##name##Asset() const { return m##name##Asset; }\ void set##name##Asset(const AssetPtr &_in) { m##name##Asset = _in;}\ @@ -206,7 +209,7 @@ public: \ }\ else\ {\ - StringTableEntry assetId = SoundAsset::getAssetIdByFilename(_in);\ + StringTableEntry assetId = SoundAsset::getAssetIdByFileName(_in);\ if (assetId != StringTable->EmptyString())\ {\ m##name##AssetId = assetId;\ @@ -232,9 +235,9 @@ public: \ m##name = NULL;\ }\ \ - if (m##name##Asset.notNull() && m##name##Asset->getStatus() != ShapeAsset::Ok)\ + if (m##name##Asset.notNull() && m##name##Asset->getStatus() != SoundAsset::Ok)\ {\ - Con::errorf("%s(%s)::_set%s() - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, ShapeAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\ + Con::errorf("%s(%s)::_set%s() - sound asset failure\"%s\" due to [%s]", macroText(className), getName(), macroText(name), _in, SoundAsset::getAssetErrstrn(m##name##Asset->getStatus()).c_str());\ return false; \ }\ else if (m##name)\ diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index 5dadee79c..380c9bcd6 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1382,32 +1382,32 @@ void AssetImporter::processImportAssets(AssetImportObject* assetItem) if (item->assetName != item->cleanAssetName) item->assetName = item->cleanAssetName; - //handle special pre-processing here for any types that need it - - //process the asset items - if (item->assetType == String("ImageAsset")) - { - processImageAsset(item); - } - else if (item->assetType == String("ShapeAsset")) - { - processShapeAsset(item); - } - /*else if (item->assetType == String("SoundAsset")) - SoundAsset::prepareAssetForImport(this, item);*/ - else if (item->assetType == String("MaterialAsset")) - { - processMaterialAsset(item); - } - /*else if (item->assetType == String("ShapeAnimationAsset")) - ShapeAnimationAsset::prepareAssetForImport(this, item);*/ - else - { - String processCommand = "process"; - processCommand += item->assetType; - if(isMethod(processCommand.c_str())) - Con::executef(this, processCommand.c_str(), item); - } + //process the asset items + if (item->assetType == String("ImageAsset")) + { + processImageAsset(item); + } + else if (item->assetType == String("ShapeAsset")) + { + processShapeAsset(item); + } + else if (item->assetType == String("SoundAsset")) + { + processSoundAsset(item); + } + else if (item->assetType == String("MaterialAsset")) + { + processMaterialAsset(item); + } + /*else if (item->assetType == String("ShapeAnimationAsset")) + ShapeAnimationAsset::prepareAssetForImport(this, item);*/ + else + { + String processCommand = "process"; + processCommand += item->assetType; + if(isMethod(processCommand.c_str())) + Con::executef(this, processCommand.c_str(), item); + } item->importStatus == AssetImportObject::Processed; @@ -1975,93 +1975,12 @@ void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 m void AssetImporter::processSoundAsset(AssetImportObject* assetItem) { - dSprintf(importLogBuffer, sizeof(importLogBuffer), "Preparing Image for Import: %s", assetItem->assetName.c_str()); + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Preparing Sound for Import: %s", assetItem->assetName.c_str()); activityLog.push_back(importLogBuffer); - if ((activeImportConfig->GenerateMaterialOnImport && assetItem->parentAssetItem == nullptr)/* || assetItem->parentAssetItem != nullptr*/) - { - //find our suffix match, if any - String noSuffixName = assetItem->assetName; - String suffixType; - String suffix = parseImageSuffixes(assetItem->assetName, &suffixType); - if (suffix.isNotEmpty()) - { - assetItem->imageSuffixType = suffixType; - S32 suffixPos = assetItem->assetName.find(suffix, 0, String::NoCase | String::Left); - noSuffixName = assetItem->assetName.substr(0, suffixPos); - } - - //We try to automatically populate materials under the naming convention: materialName: Rock, image maps: Rock_Albedo, Rock_Normal, etc - - AssetImportObject* materialAsset = findImportingAssetByName(noSuffixName); - if (materialAsset != nullptr && materialAsset->assetType != String("MaterialAsset")) - { - //We may have a situation where an asset matches the no-suffix name, but it's not a material asset. Ignore this - //asset item for now - - materialAsset = nullptr; - } - - //If we didn't find a matching material asset in our current items, we'll make one now - if (materialAsset == nullptr) - { - if (!assetItem->filePath.isEmpty()) - { - materialAsset = addImportingAsset("MaterialAsset", assetItem->filePath, nullptr, noSuffixName); - } - } - - //Not that, one way or another, we have the generated material asset, lets move on to associating our image with it - if (materialAsset != nullptr && materialAsset != assetItem->parentAssetItem) - { - if (assetItem->parentAssetItem != nullptr) - { - //If the image had an existing parent, it gets removed from that parent's child item list - assetItem->parentAssetItem->childAssetItems.remove(assetItem); - } - else - { - //If it didn't have one, we're going to pull it from the importingAssets list - importingAssets.remove(assetItem); - } - - //Now we can add it to the correct material asset - materialAsset->childAssetItems.push_back(assetItem); - assetItem->parentAssetItem = materialAsset; - - assetHeirarchyChanged = true; - } - - //Now to do some cleverness. If we're generating a material, we can parse like assets being imported(similar filenames) but different suffixes - //If we find these, we'll just populate into the original's material - - //if we need to append the diffuse suffix and indeed didn't find a suffix on the name, do that here - if (suffixType.isEmpty()) - { - if (activeImportConfig->UseDiffuseSuffixOnOriginImage) - { - String diffuseToken = StringUnit::getUnit(activeImportConfig->DiffuseTypeSuffixes, 0, ",;\t"); - assetItem->assetName = assetItem->assetName + diffuseToken; - assetItem->cleanAssetName = assetItem->assetName; - } - else - { - //We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix - //we'll give it a generic one - if ((materialAsset && materialAsset->assetName.compare(assetItem->assetName) == 0) || activeImportConfig->AlwaysAddImageSuffix) - { - assetItem->assetName = assetItem->assetName + activeImportConfig->AddedImageSuffix; - assetItem->cleanAssetName = assetItem->assetName; - } - } - - //Assume for abledo if it has no suffix matches - assetItem->imageSuffixType = "Albedo"; - } - } - assetItem->importStatus = AssetImportObject::Processed; } + // // Validation // @@ -2514,6 +2433,8 @@ void AssetImporter::importAssets(AssetImportObject* assetItem) if (!refreshSuccess) { + const char* importReturnVal = Con::executef(this, processCommand.c_str(), childItem).getString(); + assetPath = Torque::Path(importReturnVal); dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Failed to refresh reimporting asset %s.", item->assetName.c_str()); activityLog.push_back(importLogBuffer); } diff --git a/Engine/source/T3D/gameBase/gameConnection.cpp b/Engine/source/T3D/gameBase/gameConnection.cpp index 1477da406..09cfa13cf 100644 --- a/Engine/source/T3D/gameBase/gameConnection.cpp +++ b/Engine/source/T3D/gameBase/gameConnection.cpp @@ -331,7 +331,7 @@ DefineEngineStringlyVariadicMethod(GameConnection, setConnectArgs, void, 3, 17, "@see GameConnection::onConnect()\n\n") { - StringStackWrapper args(argc - 2, argv + 2); + ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2); object->setConnectArgs(args.count(), args); } @@ -373,7 +373,7 @@ void GameConnection::onConnectionEstablished(bool isInitiator) mMoveList->init(); const char *argv[MaxConnectArgs + 2]; argv[0] = "onConnect"; - argv[1] = NULL; // Filled in later + argv[1] = getIdString(); for(U32 i = 0; i < mConnectArgc; i++) argv[i + 2] = mConnectArgv[i]; // NOTE: Need to fallback to Con::execute() as IMPLEMENT_CALLBACK does not @@ -493,33 +493,32 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr *errorString = "CR_INVALID_ARGS"; return false; } - ConsoleValueRef connectArgv[MaxConnectArgs + 3]; - ConsoleValue connectArgvValue[MaxConnectArgs + 3]; - for(U32 i = 0; i < mConnectArgc+3; i++) - { - connectArgv[i].value = &connectArgvValue[i]; - connectArgvValue[i].init(); - } + char buffer[256]; + Net::addressToString(getNetAddress(), buffer); + + ConsoleValue connectArgv[MaxConnectArgs + 3]; for(U32 i = 0; i < mConnectArgc; i++) { char argString[256]; stream->readString(argString); mConnectArgv[i] = dStrdup(argString); - connectArgv[i + 3] = mConnectArgv[i]; + connectArgv[i + 3].setString(argString); } - connectArgvValue[0].setStackStringValue("onConnectRequest"); - connectArgvValue[1].setIntValue(0); - char buffer[256]; - Net::addressToString(getNetAddress(), buffer); - connectArgvValue[2].setStackStringValue(buffer); + + connectArgv[0].setStringTableEntry("onConnectRequest"); + connectArgv[1].setInt(0); + connectArgv[2].setString(buffer); // NOTE: Cannot convert over to IMPLEMENT_CALLBACK as it has variable args. - const char *ret = Con::execute(this, mConnectArgc + 3, connectArgv); - if(ret[0]) + ConsoleValue returnValue = Con::execute(this, mConnectArgc + 3, connectArgv); + + StringTableEntry returnStr = StringTable->insert(returnValue.getString()); + + if(returnStr[0]) { - *errorString = ret; + *errorString = returnStr; return false; } return true; @@ -1088,7 +1087,7 @@ bool GameConnection::readDemoStartBlock(BitStream *stream) void GameConnection::demoPlaybackComplete() { static const char* demoPlaybackArgv[1] = { "demoPlaybackComplete" }; - static StringStackConsoleWrapper demoPlaybackCmd(1, demoPlaybackArgv); + static StringArrayToConsoleValueWrapper demoPlaybackCmd(1, demoPlaybackArgv); Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(demoPlaybackCmd.argc, demoPlaybackCmd.argv, false)); Parent::demoPlaybackComplete(); diff --git a/Engine/source/T3D/sfx/sfxEmitter.cpp b/Engine/source/T3D/sfx/sfxEmitter.cpp index e48ca8fee..655e0071a 100644 --- a/Engine/source/T3D/sfx/sfxEmitter.cpp +++ b/Engine/source/T3D/sfx/sfxEmitter.cpp @@ -94,22 +94,23 @@ ColorI SFXEmitter::smRenderColorRangeSphere( 200, 0, 0, 90 ); SFXEmitter::SFXEmitter() : SceneObject(), mSource( NULL ), - mTrack( NULL ), mUseTrackDescriptionOnly( false ), - mLocalProfile( &mDescription ), mPlayOnAdd( true ) { mTypeMask |= MarkerObjectType; mNetFlags.set( Ghostable | ScopeAlways ); - + mDescription.mIs3D = true; mDescription.mIsLooping = true; mDescription.mIsStreaming = false; mDescription.mFadeInTime = -1.f; mDescription.mFadeOutTime = -1.f; - + + mLocalProfile.mFilename = StringTable->EmptyString(); mLocalProfile._registerSignals(); + INIT_SOUNDASSET(Sound); + mObjBox.minExtents.set( -1.f, -1.f, -1.f ); mObjBox.maxExtents.set( 1.f, 1.f, 1.f ); } @@ -174,15 +175,17 @@ void SFXEmitter::consoleInit() void SFXEmitter::initPersistFields() { addGroup( "Media" ); - - addField( "track", TypeSFXTrackName, Offset( mTrack, SFXEmitter), + + INITPERSISTFIELD_SOUNDASSET(Sound, SFXEmitter, ""); + + /*addField("track", TypeSFXTrackName, Offset(mTrack, SFXEmitter), "The track which the emitter should play.\n" "@note If assigned, this field will take precedence over a #fileName that may also be assigned to the " "emitter." ); addField( "fileName", TypeStringFilename, Offset( mLocalProfile.mFilename, SFXEmitter), "The sound file to play.\n" "Use @b either this property @b or #track. If both are assigned, #track takes precendence. The primary purpose of this " - "field is to avoid the need for the user to define SFXTrack datablocks for all sounds used in a level." ); + "field is to avoid the need for the user to define SFXTrack datablocks for all sounds used in a level." );*/ endGroup( "Media"); @@ -287,12 +290,13 @@ U32 SFXEmitter::packUpdate( NetConnection *con, U32 mask, BitStream *stream ) stream->writeAffineTransform( mObjToWorld ); // track - if( stream->writeFlag( mDirty.test( Track ) ) ) - sfxWrite( stream, mTrack ); + PACK_SOUNDASSET(con, Sound); + //if (stream->writeFlag(mDirty.test(Track))) + // sfxWrite( stream, mTrack ); // filename - if( stream->writeFlag( mDirty.test( Filename ) ) ) - stream->writeString( mLocalProfile.mFilename ); + //if( stream->writeFlag( mDirty.test( Filename ) ) ) + // stream->writeString( mLocalProfile.mFilename ); // volume if( stream->writeFlag( mDirty.test( Volume ) ) ) @@ -397,7 +401,8 @@ void SFXEmitter::unpackUpdate( NetConnection *conn, BitStream *stream ) } // track - if ( _readDirtyFlag( stream, Track ) ) + UNPACK_SOUNDASSET(conn, Sound); + /*if (_readDirtyFlag(stream, Track)) { String errorStr; if( !sfxReadAndResolve( stream, &mTrack, errorStr ) ) @@ -406,7 +411,7 @@ void SFXEmitter::unpackUpdate( NetConnection *conn, BitStream *stream ) // filename if ( _readDirtyFlag( stream, Filename ) ) - mLocalProfile.mFilename = stream->readSTString(); + mLocalProfile.mFilename = stream->readSTString();*/ // volume if ( _readDirtyFlag( stream, Volume ) ) @@ -586,8 +591,8 @@ void SFXEmitter::inspectPostApply() // Parent will call setScale so sync up scale with distance. F32 maxDistance = mDescription.mMaxDistance; - if( mUseTrackDescriptionOnly && mTrack ) - maxDistance = mTrack->getDescription()->mMaxDistance; + if( mUseTrackDescriptionOnly && mSoundAsset ) + maxDistance = mSoundAsset->getSfxDescription()->mMaxDistance; mObjScale.set( maxDistance, maxDistance, maxDistance ); @@ -608,8 +613,8 @@ bool SFXEmitter::onAdd() mDescription.validate(); // Read an old 'profile' field for backwards-compatibility. - - if( !mTrack ) + /* + if(mSoundAsset.isNull() || !mSoundAsset->getSfxProfile()) { static const char* sProfile = StringTable->insert( "profile" ); const char* profileName = getDataField( sProfile, NULL ); @@ -643,7 +648,7 @@ bool SFXEmitter::onAdd() // Remove the old 'channel' field. setDataField( sChannel, NULL, "" ); } - } + }*/ } else { @@ -683,6 +688,12 @@ void SFXEmitter::_update() // we can restore it. SFXStatus prevState = mSource ? mSource->getStatus() : SFXStatusNull; + if (mSoundAsset.notNull() ) + { + mLocalProfile = *mSoundAsset->getSfxProfile(); + mDescription = *mSoundAsset->getSfxDescription(); + } + // Make sure all the settings are valid. mDescription.validate(); @@ -695,12 +706,12 @@ void SFXEmitter::_update() SFX_DELETE( mSource ); // Do we have a track? - if( mTrack ) + if( mSoundAsset && mSoundAsset->getSfxProfile() ) { - mSource = SFX->createSource( mTrack, &transform, &velocity ); + mSource = SFX->createSource(mSoundAsset->getSfxProfile(), &transform, &velocity ); if( !mSource ) Con::errorf( "SFXEmitter::_update() - failed to create sound for track %i (%s)", - mTrack->getId(), mTrack->getName() ); + mSoundAsset->getSfxProfile()->getId(), mSoundAsset->getSfxProfile()->getName() ); // If we're supposed to play when the emitter is // added to the scene then also restart playback @@ -739,12 +750,12 @@ void SFXEmitter::_update() // is toggled on a local profile sound. It makes the // editor feel responsive and that things are working. if( gEditingMission && - !mTrack && + (mSoundAsset.isNull() || !mSoundAsset->getSfxProfile()) && mPlayOnAdd && mDirty.test( IsLooping ) ) prevState = SFXStatusPlaying; - bool useTrackDescriptionOnly = ( mUseTrackDescriptionOnly && mTrack ); + bool useTrackDescriptionOnly = ( mUseTrackDescriptionOnly && mSoundAsset.notNull() && mSoundAsset->getSfxProfile()); // The rest only applies if we have a source. if( mSource ) @@ -1087,8 +1098,8 @@ SFXStatus SFXEmitter::_getPlaybackStatus() const bool SFXEmitter::is3D() const { - if( mTrack != NULL ) - return mTrack->getDescription()->mIs3D; + if( mSoundAsset.notNull() && mSoundAsset->getSfxProfile() != NULL ) + return mSoundAsset->getSfxProfile()->getDescription()->mIs3D; else return mDescription.mIs3D; } @@ -1124,8 +1135,8 @@ void SFXEmitter::setScale( const VectorF &scale ) { F32 maxDistance; - if( mUseTrackDescriptionOnly && mTrack ) - maxDistance = mTrack->getDescription()->mMaxDistance; + if( mUseTrackDescriptionOnly && mSoundAsset.notNull() && mSoundAsset->getSfxProfile()) + maxDistance = mSoundAsset->getSfxProfile()->getDescription()->mMaxDistance; else { // Use the average of the three coords. diff --git a/Engine/source/T3D/sfx/sfxEmitter.h b/Engine/source/T3D/sfx/sfxEmitter.h index 226cf5ce5..aeecd13bf 100644 --- a/Engine/source/T3D/sfx/sfxEmitter.h +++ b/Engine/source/T3D/sfx/sfxEmitter.h @@ -36,6 +36,7 @@ #include "gfx/gfxStateBlock.h" #endif +#include "T3D/assets/SoundAsset.h" class SFXSource; class SFXTrack; @@ -103,13 +104,11 @@ class SFXEmitter : public SceneObject /// The current dirty flags. BitSet32 mDirty; + DECLARE_SOUNDASSET(SFXEmitter, Sound); + DECLARE_SOUNDASSET_NET_SETGET(SFXEmitter, Sound, DirtyUpdateMask); + /// The sound source for the emitter. SFXSource *mSource; - - /// The selected track or null if the local - /// profile should be used. - SFXTrack *mTrack; - /// Whether to leave sound setup exclusively to the assigned mTrack and not /// override part of the track's description with emitter properties. bool mUseTrackDescriptionOnly; diff --git a/Engine/source/Verve/Core/VDataTable.cpp b/Engine/source/Verve/Core/VDataTable.cpp index f338c5ac4..9bb4b92ff 100644 --- a/Engine/source/Verve/Core/VDataTable.cpp +++ b/Engine/source/Verve/Core/VDataTable.cpp @@ -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; diff --git a/Engine/source/afx/afxMagicSpell.cpp b/Engine/source/afx/afxMagicSpell.cpp index b45d7c131..9d05f0b80 100644 --- a/Engine/source/afx/afxMagicSpell.cpp +++ b/Engine/source/afx/afxMagicSpell.cpp @@ -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()); } } diff --git a/Engine/source/afx/afxSelectron.cpp b/Engine/source/afx/afxSelectron.cpp index 67cd32849..63157a4f1 100644 --- a/Engine/source/afx/afxSelectron.cpp +++ b/Engine/source/afx/afxSelectron.cpp @@ -1070,7 +1070,7 @@ afxSelectron::start_selectron(SceneObject* picked, U8 subcode, SimObject* extra) // CALL SCRIPT afxSelectronData::onPreactivate(%params, %extra) const char* result = Con::executef(datablock, "onPreactivate", Con::getIntArg(param_holder->getId()), - (extra) ? Con::getIntArg(extra->getId()) : ""); + (extra) ? Con::getIntArg(extra->getId()) : "").getString(); if (result && result[0] != '\0' && !dAtob(result)) { #if defined(TORQUE_DEBUG) diff --git a/Engine/source/afx/arcaneFX.cpp b/Engine/source/afx/arcaneFX.cpp index 385c056f6..5c7ea3460 100644 --- a/Engine/source/afx/arcaneFX.cpp +++ b/Engine/source/afx/arcaneFX.cpp @@ -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]; diff --git a/Engine/source/app/mainLoop.cpp b/Engine/source/app/mainLoop.cpp index 13a331075..97f25e4f3 100644 --- a/Engine/source/app/mainLoop.cpp +++ b/Engine/source/app/mainLoop.cpp @@ -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()) { @@ -637,6 +633,7 @@ bool StandardMainLoop::doMainLoop() ThreadPool::processMainThreadWorkItems(); Sampler::endFrame(); + ConsoleValue::resetConversionBuffer(); PROFILE_END_NAMED(MainLoop); } diff --git a/Engine/source/app/net/net.cpp b/Engine/source/app/net/net.cpp index 9f1def406..057a15b84 100644 --- a/Engine/source/app/net/net.cpp +++ b/Engine/source/app/net/net.cpp @@ -254,7 +254,7 @@ DefineEngineStringlyVariadicFunction( commandToServer, void, 2, RemoteCommandEve NetConnection *conn = NetConnection::getConnectionToServer(); if(!conn) return; - StringStackWrapper args(argc - 1, argv + 1); + ConsoleValueToStringArrayWrapper args(argc - 1, argv + 1); RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args); } @@ -292,7 +292,7 @@ DefineEngineStringlyVariadicFunction( commandToClient, void, 3, RemoteCommandEve NetConnection *conn; if(!Sim::findObject(argv[1], conn)) return; - StringStackWrapper args(argc - 2, argv + 2); + ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2); RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args); } diff --git a/Engine/source/app/net/tcpObject.cpp b/Engine/source/app/net/tcpObject.cpp index 07c8908eb..1b77e3bad 100644 --- a/Engine/source/app/net/tcpObject.cpp +++ b/Engine/source/app/net/tcpObject.cpp @@ -236,13 +236,13 @@ TCPObject::~TCPObject() } } -bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv) +bool TCPObject::processArguments(S32 argc, ConsoleValue *argv) { if(argc == 0) return true; else if(argc == 1) { - addToTable(NetSocket::fromHandle(dAtoi(argv[0]))); + addToTable(NetSocket::fromHandle(argv[0].getInt())); return true; } return false; diff --git a/Engine/source/app/net/tcpObject.h b/Engine/source/app/net/tcpObject.h index 9a8b5e40d..a869f48be 100644 --- a/Engine/source/app/net/tcpObject.h +++ b/Engine/source/app/net/tcpObject.h @@ -83,7 +83,7 @@ public: void disconnect(); State getState() { return mState; } - bool processArguments(S32 argc, ConsoleValueRef *argv); + bool processArguments(S32 argc, ConsoleValue *argv); void send(const U8 *buffer, U32 bufferLen); ///Send an entire file over tcp diff --git a/Engine/source/cinterface/cinterface.cpp b/Engine/source/cinterface/cinterface.cpp index e62db2c91..3cd717c13 100644 --- a/Engine/source/cinterface/cinterface.cpp +++ b/Engine/source/cinterface/cinterface.cpp @@ -55,7 +55,7 @@ bool CInterface::_isMethod(const char* className, const char* methodName) const if (mIsMethodCallback) return mIsMethodCallback(className, methodName); - return NULL; + return false; } const char* CInterface::_CallFunction(const char* nameSpace, const char* name, const char **argv, int argc, bool *result) const @@ -93,4 +93,4 @@ TORQUE_API void SetCallbacks(void* ptr, void* methodPtr, void* isMethodPtr, void CInterface::GetCInterface().SetCallMethodCallback(methodPtr); CInterface::GetCInterface().SetCallIsMethodCallback(isMethodPtr); CInterface::GetCInterface().SetMainCallback(mainPtr); -} \ No newline at end of file +} diff --git a/Engine/source/console/CMDgram.y b/Engine/source/console/CMDgram.y index 6cfbf3311..0b15c0e93 100644 --- a/Engine/source/console/CMDgram.y +++ b/Engine/source/console/CMDgram.y @@ -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 ')' diff --git a/Engine/source/console/CMDscan.cpp b/Engine/source/console/CMDscan.cpp index c30ac7bc9..43a864570 100644 --- a/Engine/source/console/CMDscan.cpp +++ b/Engine/source/console/CMDscan.cpp @@ -20,8 +20,8 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: -* $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $ -*/ + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.85 95/04/24 10:48:47 vern Exp $ + */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 @@ -60,8 +60,8 @@ #endif /* ! __cplusplus */ #ifdef __TURBOC__ -#pragma warn -rch -#pragma warn -use + #pragma warn -rch + #pragma warn -use #include #include #define YY_USE_CONST @@ -85,22 +85,22 @@ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned -* integer for use as an array index. If the signed char is negative, -* we want to instead treat it as an 8-bit unsigned char, hence the -* double cast. -*/ + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, -* but we do it the disgusting crufty way forced on us by the ()-less -* definition of BEGIN. -*/ + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ #define BEGIN yy_start = 1 + 2 * /* Translate the current start state into a value that can be later handed -* to BEGIN to return to the state. The YYSTATE alias is for lex -* compatibility. -*/ + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ #define YY_START ((yy_start - 1) / 2) #define YYSTATE YY_START @@ -125,18 +125,18 @@ extern FILE *yyin, *yyout; #define EOB_ACT_LAST_MATCH 2 /* The funky do-while in the following #define is used to turn the definition -* int a single C statement (which needs a semi-colon terminator). This -* avoids problems with code like: -* -* if ( condition_holds ) -* yyless( 5 ); -* else -* do_something_else(); -* -* Prior to using the do-while the compiler would get upset at the -* "else" because it interpreted the "if" statement as being all -* done when it reached the ';' after the yyless() call. -*/ + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ /* Return all but the first 'n' matched characters back to the input stream. */ @@ -153,75 +153,75 @@ extern FILE *yyin, *yyout; #define unput(c) yyunput( c, yytext_ptr ) /* The following is because we cannot portably get our hands on size_t -* (without autoconf's help, which isn't available because we want -* flex-generated scanners to compile on their own). -*/ + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ typedef unsigned int yy_size_t; struct yy_buffer_state -{ - FILE *yy_input_file; + { + FILE *yy_input_file; - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ #define YY_BUFFER_EOF_PENDING 2 -}; + }; static YY_BUFFER_STATE yy_current_buffer = 0; /* We provide macros for accessing buffer states in case in the -* future we want to put the buffer states in a more general -* "scanner state". -*/ + * future we want to put the buffer states in a more general + * "scanner state". + */ #define YY_CURRENT_BUFFER yy_current_buffer @@ -234,32 +234,32 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *)0; +static char *yy_c_buf_p = (char *) 0; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ - /* Flag which is used to allow yywrap()'s to do buffer switches - * instead of setting up a fresh yyin. A bit of a hack ... - */ +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ static int yy_did_buffer_switch_on_eof; -void yyrestart YY_PROTO((FILE *input_file)); +void yyrestart YY_PROTO(( FILE *input_file )); -void yy_switch_to_buffer YY_PROTO((YY_BUFFER_STATE new_buffer)); -void yy_load_buffer_state YY_PROTO((void)); -YY_BUFFER_STATE yy_create_buffer YY_PROTO((FILE *file, int size)); -void yy_delete_buffer YY_PROTO((YY_BUFFER_STATE b)); -void yy_init_buffer YY_PROTO((YY_BUFFER_STATE b, FILE *file)); -void yy_flush_buffer YY_PROTO((YY_BUFFER_STATE b)); +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) -YY_BUFFER_STATE yy_scan_buffer YY_PROTO((char *base, yy_size_t size)); -YY_BUFFER_STATE yy_scan_string YY_PROTO((yyconst char *str)); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO((yyconst char *bytes, int len)); +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); -static void *yy_flex_alloc YY_PROTO((yy_size_t)); -static void *yy_flex_realloc YY_PROTO((void *, yy_size_t)); -static void yy_flex_free YY_PROTO((void *)); +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); #define yy_new_buffer yy_create_buffer @@ -280,19 +280,19 @@ static void yy_flex_free YY_PROTO((void *)); #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *)0, *yyout = (FILE *)0; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext -static yy_state_type yy_get_previous_state YY_PROTO((void)); -static yy_state_type yy_try_NUL_trans YY_PROTO((yy_state_type current_state)); -static int yy_get_next_buffer YY_PROTO((void)); -static void yy_fatal_error YY_PROTO((yyconst char msg[])); +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); /* Done after the current pattern has been matched and before the -* corresponding action - sets up yytext. -*/ + * corresponding action - sets up yytext. + */ #define YY_DO_BEFORE_ACTION \ yytext_ptr = yy_bp; \ yyleng = (int) (yy_cp - yy_bp); \ @@ -303,241 +303,241 @@ static void yy_fatal_error YY_PROTO((yyconst char msg[])); #define YY_NUM_RULES 94 #define YY_END_OF_BUFFER 95 static yyconst short int yy_accept[224] = -{ 0, -0, 0, 95, 93, 1, 5, 4, 51, 93, 93, -58, 57, 93, 41, 42, 45, 43, 56, 44, 50, -46, 90, 90, 52, 53, 47, 61, 48, 38, 36, -88, 88, 88, 88, 39, 40, 59, 88, 88, 88, -88, 88, 88, 88, 88, 88, 88, 88, 88, 88, -88, 54, 49, 55, 60, 1, 0, 9, 0, 6, -0, 0, 17, 87, 25, 12, 26, 0, 7, 0, -23, 16, 21, 15, 22, 31, 91, 37, 3, 24, -0, 90, 0, 0, 14, 19, 11, 8, 10, 20, -88, 33, 88, 88, 27, 88, 88, 88, 88, 88, + { 0, + 0, 0, 95, 93, 1, 5, 4, 51, 93, 93, + 58, 57, 93, 41, 42, 45, 43, 56, 44, 50, + 46, 90, 90, 52, 53, 47, 61, 48, 38, 36, + 88, 88, 88, 88, 39, 40, 59, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 54, 49, 55, 60, 1, 0, 9, 0, 6, + 0, 0, 17, 87, 25, 12, 26, 0, 7, 0, + 23, 16, 21, 15, 22, 31, 91, 37, 3, 24, + 0, 90, 0, 0, 14, 19, 11, 8, 10, 20, + 88, 33, 88, 88, 27, 88, 88, 88, 88, 88, -88, 69, 88, 88, 88, 88, 70, 62, 88, 88, -63, 88, 88, 88, 88, 88, 88, 28, 13, 18, -92, 87, 0, 32, 3, 3, 91, 0, 91, 89, -29, 30, 35, 34, 88, 88, 88, 88, 88, 88, -88, 88, 73, 88, 88, 76, 88, 88, 88, 88, -88, 88, 92, 0, 3, 2, 88, 88, 79, 88, -88, 88, 66, 88, 88, 88, 88, 88, 88, 88, -88, 85, 88, 3, 0, 88, 64, 88, 88, 88, -86, 88, 88, 88, 88, 88, 88, 88, 68, 0, -67, 88, 88, 88, 88, 88, 88, 88, 65, 88, + 88, 69, 88, 88, 88, 88, 70, 62, 88, 88, + 63, 88, 88, 88, 88, 88, 88, 28, 13, 18, + 92, 87, 0, 32, 3, 3, 91, 0, 91, 89, + 29, 30, 35, 34, 88, 88, 88, 88, 88, 88, + 88, 88, 73, 88, 88, 76, 88, 88, 88, 88, + 88, 88, 92, 0, 3, 2, 88, 88, 79, 88, + 88, 88, 66, 88, 88, 88, 88, 88, 88, 88, + 88, 85, 88, 3, 0, 88, 64, 88, 88, 88, + 86, 88, 88, 88, 88, 88, 88, 88, 68, 0, + 67, 88, 88, 88, 88, 88, 88, 88, 65, 88, -81, 0, 88, 88, 82, 72, 88, 88, 83, 88, -80, 0, 74, 88, 71, 75, 88, 88, 0, 78, -84, 77, 0 -}; + 81, 0, 88, 88, 82, 72, 88, 88, 83, 88, + 80, 0, 74, 88, 71, 75, 88, 88, 0, 78, + 84, 77, 0 + } ; static yyconst int yy_ec[256] = -{ 0, -1, 1, 1, 1, 1, 1, 1, 1, 2, 3, -2, 2, 4, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 2, 5, 6, 1, 7, 8, 9, 10, 11, -12, 13, 14, 15, 16, 17, 18, 19, 20, 20, -20, 20, 20, 20, 20, 20, 20, 21, 22, 23, -24, 25, 26, 27, 28, 29, 30, 31, 32, 31, -33, 33, 33, 33, 33, 34, 33, 35, 33, 36, -33, 33, 37, 38, 33, 33, 33, 39, 33, 33, -40, 41, 42, 43, 33, 1, 44, 45, 46, 47, + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 6, 1, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 31, + 33, 33, 33, 33, 33, 34, 33, 35, 33, 36, + 33, 33, 37, 38, 33, 33, 33, 39, 33, 33, + 40, 41, 42, 43, 33, 1, 44, 45, 46, 47, -48, 49, 50, 51, 52, 33, 53, 54, 55, 56, -57, 58, 33, 59, 60, 61, 62, 33, 63, 39, -33, 33, 64, 65, 66, 67, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 48, 49, 50, 51, 52, 33, 53, 54, 55, 56, + 57, 58, 33, 59, 60, 61, 62, 33, 63, 39, + 33, 33, 64, 65, 66, 67, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1 -}; + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; static yyconst int yy_meta[68] = -{ 0, -1, 1, 2, 2, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 3, 4, 4, -5, 1, 1, 6, 1, 1, 1, 4, 4, 4, -4, 4, 7, 7, 7, 7, 7, 7, 7, 1, -1, 1, 1, 4, 4, 4, 4, 4, 4, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 1, 1, 1, 1 -}; + { 0, + 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 4, 4, + 5, 1, 1, 6, 1, 1, 1, 4, 4, 4, + 4, 4, 7, 7, 7, 7, 7, 7, 7, 1, + 1, 1, 1, 4, 4, 4, 4, 4, 4, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 1, 1, 1, 1 + } ; static yyconst short int yy_base[237] = -{ 0, -0, 0, 337, 338, 334, 338, 338, 61, 63, 51, -53, 65, 66, 338, 338, 311, 64, 338, 66, 60, -68, 76, 80, 313, 338, 60, 309, 77, 338, 338, -0, 298, 295, 302, 338, 338, 305, 268, 268, 54, -61, 272, 59, 38, 62, 266, 280, 275, 62, 263, -270, 338, 89, 338, 338, 318, 295, 338, 111, 338, -314, 100, 338, 296, 338, 338, 338, 112, 338, 312, -338, 338, 338, 290, 338, 338, 107, 338, 296, 338, -110, 114, 121, 0, 338, 289, 338, 338, 338, 288, -0, 0, 281, 281, 338, 249, 260, 247, 250, 244, + { 0, + 0, 0, 337, 338, 334, 338, 338, 61, 63, 51, + 53, 65, 66, 338, 338, 311, 64, 338, 66, 60, + 68, 76, 80, 313, 338, 60, 309, 77, 338, 338, + 0, 298, 295, 302, 338, 338, 305, 268, 268, 54, + 61, 272, 59, 38, 62, 266, 280, 275, 62, 263, + 270, 338, 89, 338, 338, 318, 295, 338, 111, 338, + 314, 100, 338, 296, 338, 338, 338, 112, 338, 312, + 338, 338, 338, 290, 338, 338, 107, 338, 296, 338, + 110, 114, 121, 0, 338, 289, 338, 338, 338, 288, + 0, 0, 281, 281, 338, 249, 260, 247, 250, 244, -255, 0, 243, 248, 242, 244, 0, 0, 244, 235, -0, 251, 235, 239, 242, 231, 240, 338, 338, 338, -270, 269, 268, 338, 0, 139, 119, 125, 128, 0, -338, 338, 0, 0, 240, 243, 238, 224, 240, 239, -234, 221, 232, 233, 230, 0, 224, 214, 225, 213, -225, 218, 250, 249, 146, 152, 210, 215, 0, 215, -221, 203, 0, 216, 219, 201, 201, 216, 200, 204, -211, 0, 208, 155, 237, 193, 0, 197, 198, 197, -0, 204, 197, 190, 197, 190, 197, 193, 0, 225, -0, 180, 184, 179, 177, 153, 158, 151, 0, 134, + 255, 0, 243, 248, 242, 244, 0, 0, 244, 235, + 0, 251, 235, 239, 242, 231, 240, 338, 338, 338, + 270, 269, 268, 338, 0, 139, 119, 125, 128, 0, + 338, 338, 0, 0, 240, 243, 238, 224, 240, 239, + 234, 221, 232, 233, 230, 0, 224, 214, 225, 213, + 225, 218, 250, 249, 146, 152, 210, 215, 0, 215, + 221, 203, 0, 216, 219, 201, 201, 216, 200, 204, + 211, 0, 208, 155, 237, 193, 0, 197, 198, 197, + 0, 204, 197, 190, 197, 190, 197, 193, 0, 225, + 0, 180, 184, 179, 177, 153, 158, 151, 0, 134, -187, 157, 143, 144, 0, 176, 123, 126, 0, 112, -338, 160, 0, 115, 338, 0, 88, 76, 162, 0, -0, 0, 338, 170, 174, 181, 185, 189, 193, 200, -119, 204, 211, 218, 225, 232 -}; + 187, 157, 143, 144, 0, 176, 123, 126, 0, 112, + 338, 160, 0, 115, 338, 0, 88, 76, 162, 0, + 0, 0, 338, 170, 174, 181, 185, 189, 193, 200, + 119, 204, 211, 218, 225, 232 + } ; static yyconst short int yy_def[237] = -{ 0, -223, 1, 223, 223, 223, 223, 223, 223, 224, 225, -225, 223, 226, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -227, 227, 227, 227, 223, 223, 223, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 227, 227, 227, -227, 223, 223, 223, 223, 223, 223, 223, 224, 223, -224, 228, 223, 229, 223, 223, 223, 226, 223, 226, -223, 223, 223, 223, 223, 223, 223, 223, 230, 223, -223, 223, 223, 231, 223, 223, 223, 223, 223, 223, -227, 227, 227, 227, 223, 227, 227, 227, 227, 227, + { 0, + 223, 1, 223, 223, 223, 223, 223, 223, 224, 225, + 225, 223, 226, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 227, 227, 227, 227, 223, 223, 223, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 223, 223, 223, 223, 223, 223, 223, 224, 223, + 224, 228, 223, 229, 223, 223, 223, 226, 223, 226, + 223, 223, 223, 223, 223, 223, 223, 223, 230, 223, + 223, 223, 223, 231, 223, 223, 223, 223, 223, 223, + 227, 227, 227, 227, 223, 227, 227, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 223, 223, 223, -232, 229, 229, 223, 230, 233, 223, 223, 223, 231, -223, 223, 227, 227, 227, 227, 227, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 227, 227, 227, -227, 227, 232, 232, 234, 223, 227, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 227, 227, 227, -227, 227, 227, 234, 223, 227, 227, 227, 227, 227, -227, 227, 227, 227, 227, 227, 227, 227, 227, 223, -227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 223, 223, 223, + 232, 229, 229, 223, 230, 233, 223, 223, 223, 231, + 223, 223, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 232, 232, 234, 223, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 234, 223, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 223, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, -227, 235, 227, 227, 227, 227, 227, 227, 227, 227, -223, 236, 227, 227, 223, 227, 227, 227, 236, 227, -227, 227, 0, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223 -}; + 227, 235, 227, 227, 227, 227, 227, 227, 227, 227, + 223, 236, 227, 227, 223, 227, 227, 227, 236, 227, + 227, 227, 0, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223 + } ; static yyconst short int yy_nxt[406] = -{ 0, -4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -24, 25, 26, 27, 28, 29, 30, 31, 31, 31, -31, 31, 31, 31, 32, 31, 33, 34, 31, 35, -4, 36, 37, 38, 39, 40, 41, 42, 43, 31, -31, 44, 31, 31, 31, 45, 46, 47, 48, 49, -50, 31, 51, 52, 53, 54, 55, 57, 60, 62, -62, 62, 62, 66, 63, 69, 65, 72, 77, 77, -78, 74, 86, 87, 58, 79, 107, 73, 67, 75, -76, 80, 81, 108, 82, 82, 81, 98, 82, 82, + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 31, 31, + 31, 31, 31, 31, 32, 31, 33, 34, 31, 35, + 4, 36, 37, 38, 39, 40, 41, 42, 43, 31, + 31, 44, 31, 31, 31, 45, 46, 47, 48, 49, + 50, 31, 51, 52, 53, 54, 55, 57, 60, 62, + 62, 62, 62, 66, 63, 69, 65, 72, 77, 77, + 78, 74, 86, 87, 58, 79, 107, 73, 67, 75, + 76, 80, 81, 108, 82, 82, 81, 98, 82, 82, -89, 90, 104, 61, 100, 109, 70, 83, 101, 110, -99, 83, 118, 114, 84, 105, 60, 102, 62, 62, -106, 69, 130, 83, 115, 77, 77, 83, 127, 127, -81, 222, 82, 82, 128, 221, 128, 127, 127, 129, -129, 156, 156, 129, 129, 83, 129, 129, 156, 156, -83, 61, 70, 119, 156, 156, 125, 156, 156, 156, -156, 83, 156, 156, 156, 156, 83, 220, 218, 175, -59, 217, 59, 59, 59, 59, 59, 64, 216, 64, -64, 68, 215, 68, 68, 68, 68, 68, 91, 214, -213, 91, 121, 211, 210, 121, 122, 122, 209, 122, + 89, 90, 104, 61, 100, 109, 70, 83, 101, 110, + 99, 83, 118, 114, 84, 105, 60, 102, 62, 62, + 106, 69, 130, 83, 115, 77, 77, 83, 127, 127, + 81, 222, 82, 82, 128, 221, 128, 127, 127, 129, + 129, 156, 156, 129, 129, 83, 129, 129, 156, 156, + 83, 61, 70, 119, 156, 156, 125, 156, 156, 156, + 156, 83, 156, 156, 156, 156, 83, 220, 218, 175, + 59, 217, 59, 59, 59, 59, 59, 64, 216, 64, + 64, 68, 215, 68, 68, 68, 68, 68, 91, 214, + 213, 91, 121, 211, 210, 121, 122, 122, 209, 122, -125, 208, 125, 125, 125, 125, 125, 153, 153, 207, -153, 155, 155, 155, 155, 155, 155, 155, 174, 174, -174, 174, 174, 174, 174, 212, 212, 206, 212, 212, -212, 212, 219, 219, 219, 219, 219, 219, 219, 205, -204, 203, 202, 201, 200, 199, 198, 197, 196, 195, -194, 193, 192, 191, 190, 189, 188, 187, 186, 185, -184, 183, 182, 181, 180, 179, 178, 177, 176, 154, -154, 173, 172, 171, 170, 169, 168, 167, 166, 165, -164, 163, 162, 161, 160, 159, 158, 157, 123, 123, -154, 152, 151, 150, 149, 148, 147, 146, 145, 144, + 125, 208, 125, 125, 125, 125, 125, 153, 153, 207, + 153, 155, 155, 155, 155, 155, 155, 155, 174, 174, + 174, 174, 174, 174, 174, 212, 212, 206, 212, 212, + 212, 212, 219, 219, 219, 219, 219, 219, 219, 205, + 204, 203, 202, 201, 200, 199, 198, 197, 196, 195, + 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, + 184, 183, 182, 181, 180, 179, 178, 177, 176, 154, + 154, 173, 172, 171, 170, 169, 168, 167, 166, 165, + 164, 163, 162, 161, 160, 159, 158, 157, 123, 123, + 154, 152, 151, 150, 149, 148, 147, 146, 145, 144, -143, 142, 141, 140, 139, 138, 137, 136, 135, 134, -133, 132, 131, 126, 124, 68, 123, 59, 120, 56, -117, 116, 113, 112, 111, 103, 97, 96, 95, 94, -93, 92, 88, 85, 71, 56, 223, 3, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, + 133, 132, 131, 126, 124, 68, 123, 59, 120, 56, + 117, 116, 113, 112, 111, 103, 97, 96, 95, 94, + 93, 92, 88, 85, 71, 56, 223, 3, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223 -}; + 223, 223, 223, 223, 223 + } ; static yyconst short int yy_chk[406] = -{ 0, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 8, 9, 10, -10, 11, 11, 12, 10, 13, 11, 17, 20, 20, -21, 19, 26, 26, 8, 21, 44, 17, 12, 19, -19, 21, 22, 44, 22, 22, 23, 40, 23, 23, + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 8, 9, 10, + 10, 11, 11, 12, 10, 13, 11, 17, 20, 20, + 21, 19, 26, 26, 8, 21, 44, 17, 12, 19, + 19, 21, 22, 44, 22, 22, 23, 40, 23, 23, -28, 28, 43, 9, 41, 45, 13, 22, 41, 45, -40, 23, 53, 49, 22, 43, 59, 41, 62, 62, -43, 68, 231, 22, 49, 77, 77, 23, 81, 81, -82, 218, 82, 82, 83, 217, 83, 127, 127, 83, -83, 126, 126, 128, 128, 82, 129, 129, 155, 155, -127, 59, 68, 53, 156, 156, 126, 174, 174, 202, -202, 82, 212, 212, 219, 219, 127, 214, 210, 156, -224, 208, 224, 224, 224, 224, 224, 225, 207, 225, -225, 226, 206, 226, 226, 226, 226, 226, 227, 204, -203, 227, 228, 201, 200, 228, 229, 229, 198, 229, + 28, 28, 43, 9, 41, 45, 13, 22, 41, 45, + 40, 23, 53, 49, 22, 43, 59, 41, 62, 62, + 43, 68, 231, 22, 49, 77, 77, 23, 81, 81, + 82, 218, 82, 82, 83, 217, 83, 127, 127, 83, + 83, 126, 126, 128, 128, 82, 129, 129, 155, 155, + 127, 59, 68, 53, 156, 156, 126, 174, 174, 202, + 202, 82, 212, 212, 219, 219, 127, 214, 210, 156, + 224, 208, 224, 224, 224, 224, 224, 225, 207, 225, + 225, 226, 206, 226, 226, 226, 226, 226, 227, 204, + 203, 227, 228, 201, 200, 228, 229, 229, 198, 229, -230, 197, 230, 230, 230, 230, 230, 232, 232, 196, -232, 233, 233, 233, 233, 233, 233, 233, 234, 234, -234, 234, 234, 234, 234, 235, 235, 195, 235, 235, -235, 235, 236, 236, 236, 236, 236, 236, 236, 194, -193, 192, 190, 188, 187, 186, 185, 184, 183, 182, -180, 179, 178, 176, 175, 173, 171, 170, 169, 168, -167, 166, 165, 164, 162, 161, 160, 158, 157, 154, -153, 152, 151, 150, 149, 148, 147, 145, 144, 143, -142, 141, 140, 139, 138, 137, 136, 135, 123, 122, -121, 117, 116, 115, 114, 113, 112, 110, 109, 106, + 230, 197, 230, 230, 230, 230, 230, 232, 232, 196, + 232, 233, 233, 233, 233, 233, 233, 233, 234, 234, + 234, 234, 234, 234, 234, 235, 235, 195, 235, 235, + 235, 235, 236, 236, 236, 236, 236, 236, 236, 194, + 193, 192, 190, 188, 187, 186, 185, 184, 183, 182, + 180, 179, 178, 176, 175, 173, 171, 170, 169, 168, + 167, 166, 165, 164, 162, 161, 160, 158, 157, 154, + 153, 152, 151, 150, 149, 148, 147, 145, 144, 143, + 142, 141, 140, 139, 138, 137, 136, 135, 123, 122, + 121, 117, 116, 115, 114, 113, 112, 110, 109, 106, -105, 104, 103, 101, 100, 99, 98, 97, 96, 94, -93, 90, 86, 79, 74, 70, 64, 61, 57, 56, -51, 50, 48, 47, 46, 42, 39, 38, 37, 34, -33, 32, 27, 24, 16, 5, 3, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 105, 104, 103, 101, 100, 99, 98, 97, 96, 94, + 93, 90, 86, 79, 74, 70, 64, 61, 57, 56, + 51, 50, 48, 47, 46, 42, 39, 38, 37, 34, + 33, 32, 27, 24, 16, 5, 3, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, + 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, -223, 223, 223, 223, 223 -}; + 223, 223, 223, 223, 223 + } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; /* The intent behind this definition is that it'll catch -* any uses of REJECT which flex missed. -*/ + * any uses of REJECT which flex missed. + */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 @@ -568,7 +568,7 @@ struct Token // Can't have ctors in structs used in unions, so we have this. template< typename T > -inline Token< T > MakeToken(T value, U32 lineNumber) +inline Token< T > MakeToken( T value, U32 lineNumber ) { Token< T > result; result.value = value; @@ -634,30 +634,30 @@ void CMDrestart(FILE *in); #line 635 "CMDscan.cpp" /* Macros after this point can all be overridden by user definitions in -* section 1. -*/ + * section 1. + */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap YY_PROTO((void)); +extern "C" int yywrap YY_PROTO(( void )); #else -extern int yywrap YY_PROTO((void)); +extern int yywrap YY_PROTO(( void )); #endif #endif #ifndef YY_NO_UNPUT -static void yyunput YY_PROTO((int c, char *buf_ptr)); +static void yyunput YY_PROTO(( int c, char *buf_ptr )); #endif #ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO((char *, yyconst char *, int)); +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput YY_PROTO((void)); +static int yyinput YY_PROTO(( void )); #else -static int input YY_PROTO((void)); +static int input YY_PROTO(( void )); #endif #endif @@ -666,13 +666,13 @@ static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; #ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO((int new_state)); +static void yy_push_state YY_PROTO(( int new_state )); #endif #ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO((void)); +static void yy_pop_state YY_PROTO(( void )); #endif #ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO((void)); +static int yy_top_state YY_PROTO(( void )); #endif #else @@ -690,9 +690,9 @@ YY_MALLOC_DECL #endif #else /* Just try to get by without declaring the routines. This will fail -* miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) -* or sizeof(void*) != sizeof(int). -*/ + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ #endif #endif @@ -705,14 +705,14 @@ YY_MALLOC_DECL #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, -* we now use fwrite(). -*/ + * we now use fwrite(). + */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, -* is returned in "result". -*/ + * is returned in "result". + */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( yy_current_buffer->yy_is_interactive ) \ @@ -733,9 +733,9 @@ YY_MALLOC_DECL #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - -* we don't want an extra ';' after the "return" because that will cause -* some compilers to complain about unreachable statements. -*/ + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif @@ -751,15 +751,15 @@ YY_MALLOC_DECL #endif /* Default declaration of generated scanner - a define so the user can -* easily add parameters. -*/ + * easily add parameters. + */ #ifndef YY_DECL #define YY_DECL int yylex YY_PROTO(( void )) #endif /* Code executed at the beginning of each rule, after yytext and yyleng -* have been set up. -*/ + * have been set up. + */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif @@ -773,894 +773,895 @@ YY_MALLOC_DECL YY_USER_ACTION YY_DECL -{ - register yy_state_type yy_current_state; -register char *yy_cp, *yy_bp; -register int yy_act; + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; #line 105 "CMDscan.l" -; + ; #line 785 "CMDscan.cpp" -if (yy_init) -{ - yy_init = 0; + if ( yy_init ) + { + yy_init = 0; #ifdef YY_USER_INIT - YY_USER_INIT; + YY_USER_INIT; #endif - if (!yy_start) - yy_start = 1; /* first start state */ + if ( ! yy_start ) + yy_start = 1; /* first start state */ - if (!yyin) - yyin = stdin; + if ( ! yyin ) + yyin = stdin; - if (!yyout) - yyout = stdout; + if ( ! yyout ) + yyout = stdout; - if (!yy_current_buffer) - yy_current_buffer = - yy_create_buffer(yyin, YY_BUF_SIZE); + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); - yy_load_buffer_state(); -} + yy_load_buffer_state(); + } -while (1) /* loops until end-of-file is reached */ -{ - yy_cp = yy_c_buf_p; + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; - /* Support of yytext. */ - *yy_cp = yy_hold_char; + /* Support of yytext. */ + *yy_cp = yy_hold_char; - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; - yy_current_state = yy_start; + yy_current_state = yy_start; yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if (yy_accept[yy_current_state]) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 224) - yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - ++yy_cp; - } while (yy_base[yy_current_state] != 338); + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 224 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 338 ); yy_find_action: - yy_act = yy_accept[yy_current_state]; - if (yy_act == 0) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } - YY_DO_BEFORE_ACTION; + YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ - switch (yy_act) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; - case 1: - YY_RULE_SETUP +case 1: +YY_RULE_SETUP #line 107 "CMDscan.l" - {} - YY_BREAK - case 2: - YY_RULE_SETUP +{ } + YY_BREAK +case 2: +YY_RULE_SETUP #line 108 "CMDscan.l" - { return(Sc_ScanDocBlock()); } - YY_BREAK - case 3: - YY_RULE_SETUP +{ return(Sc_ScanDocBlock()); } + YY_BREAK +case 3: +YY_RULE_SETUP #line 109 "CMDscan.l" - ; - YY_BREAK - case 4: - YY_RULE_SETUP +; + YY_BREAK +case 4: +YY_RULE_SETUP #line 110 "CMDscan.l" - ; - YY_BREAK - case 5: - YY_RULE_SETUP +; + YY_BREAK +case 5: +YY_RULE_SETUP #line 111 "CMDscan.l" - { lineIndex++; } - YY_BREAK - case 6: - YY_RULE_SETUP +{lineIndex++;} + YY_BREAK +case 6: +YY_RULE_SETUP #line 112 "CMDscan.l" - { return(Sc_ScanString(STRATOM)); } - YY_BREAK - case 7: - YY_RULE_SETUP +{ return(Sc_ScanString(STRATOM)); } + YY_BREAK +case 7: +YY_RULE_SETUP #line 113 "CMDscan.l" - { return(Sc_ScanString(TAGATOM)); } - YY_BREAK - case 8: - YY_RULE_SETUP +{ return(Sc_ScanString(TAGATOM)); } + YY_BREAK +case 8: +YY_RULE_SETUP #line 114 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opEQ, lineIndex); return opEQ; } - YY_BREAK - case 9: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opEQ, lineIndex ); return opEQ; } + YY_BREAK +case 9: +YY_RULE_SETUP #line 115 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opNE, lineIndex); return opNE; } - YY_BREAK - case 10: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opNE, lineIndex ); return opNE; } + YY_BREAK +case 10: +YY_RULE_SETUP #line 116 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opGE, lineIndex); return opGE; } - YY_BREAK - case 11: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opGE, lineIndex ); return opGE; } + YY_BREAK +case 11: +YY_RULE_SETUP #line 117 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opLE, lineIndex); return opLE; } - YY_BREAK - case 12: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opLE, lineIndex ); return opLE; } + YY_BREAK +case 12: +YY_RULE_SETUP #line 118 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opAND, lineIndex); return opAND; } - YY_BREAK - case 13: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opAND, lineIndex ); return opAND; } + YY_BREAK +case 13: +YY_RULE_SETUP #line 119 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opOR, lineIndex); return opOR; } - YY_BREAK - case 14: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opOR, lineIndex ); return opOR; } + YY_BREAK +case 14: +YY_RULE_SETUP #line 120 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opCOLONCOLON, lineIndex); return opCOLONCOLON; } - YY_BREAK - case 15: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opCOLONCOLON, lineIndex ); return opCOLONCOLON; } + YY_BREAK +case 15: +YY_RULE_SETUP #line 121 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opMINUSMINUS, lineIndex); return opMINUSMINUS; } - YY_BREAK - case 16: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opMINUSMINUS, lineIndex ); return opMINUSMINUS; } + YY_BREAK +case 16: +YY_RULE_SETUP #line 122 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opPLUSPLUS, lineIndex); return opPLUSPLUS; } - YY_BREAK - case 17: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opPLUSPLUS, lineIndex ); return opPLUSPLUS; } + YY_BREAK +case 17: +YY_RULE_SETUP #line 123 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSTREQ, lineIndex); return opSTREQ; } - YY_BREAK - case 18: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSTREQ, lineIndex ); return opSTREQ; } + YY_BREAK +case 18: +YY_RULE_SETUP #line 124 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSTRNE, lineIndex); return opSTRNE; } - YY_BREAK - case 19: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSTRNE, lineIndex ); return opSTRNE; } + YY_BREAK +case 19: +YY_RULE_SETUP #line 125 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSHL, lineIndex); return opSHL; } - YY_BREAK - case 20: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSHL, lineIndex ); return opSHL; } + YY_BREAK +case 20: +YY_RULE_SETUP #line 126 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSHR, lineIndex); return opSHR; } - YY_BREAK - case 21: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSHR, lineIndex ); return opSHR; } + YY_BREAK +case 21: +YY_RULE_SETUP #line 127 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opPLASN, lineIndex); return opPLASN; } - YY_BREAK - case 22: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opPLASN, lineIndex ); return opPLASN; } + YY_BREAK +case 22: +YY_RULE_SETUP #line 128 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opMIASN, lineIndex); return opMIASN; } - YY_BREAK - case 23: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opMIASN, lineIndex ); return opMIASN; } + YY_BREAK +case 23: +YY_RULE_SETUP #line 129 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opMLASN, lineIndex); return opMLASN; } - YY_BREAK - case 24: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opMLASN, lineIndex ); return opMLASN; } + YY_BREAK +case 24: +YY_RULE_SETUP #line 130 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opDVASN, lineIndex); return opDVASN; } - YY_BREAK - case 25: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opDVASN, lineIndex ); return opDVASN; } + YY_BREAK +case 25: +YY_RULE_SETUP #line 131 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opMODASN, lineIndex); return opMODASN; } - YY_BREAK - case 26: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opMODASN, lineIndex ); return opMODASN; } + YY_BREAK +case 26: +YY_RULE_SETUP #line 132 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opANDASN, lineIndex); return opANDASN; } - YY_BREAK - case 27: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opANDASN, lineIndex ); return opANDASN; } + YY_BREAK +case 27: +YY_RULE_SETUP #line 133 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opXORASN, lineIndex); return opXORASN; } - YY_BREAK - case 28: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opXORASN, lineIndex ); return opXORASN; } + YY_BREAK +case 28: +YY_RULE_SETUP #line 134 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opORASN, lineIndex); return opORASN; } - YY_BREAK - case 29: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opORASN, lineIndex ); return opORASN; } + YY_BREAK +case 29: +YY_RULE_SETUP #line 135 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSLASN, lineIndex); return opSLASN; } - YY_BREAK - case 30: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSLASN, lineIndex ); return opSLASN; } + YY_BREAK +case 30: +YY_RULE_SETUP #line 136 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opSRASN, lineIndex); return opSRASN; } - YY_BREAK - case 31: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opSRASN, lineIndex ); return opSRASN; } + YY_BREAK +case 31: +YY_RULE_SETUP #line 137 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opINTNAME, lineIndex); return opINTNAME; } - YY_BREAK - case 32: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opINTNAME, lineIndex ); return opINTNAME; } + YY_BREAK +case 32: +YY_RULE_SETUP #line 138 "CMDscan.l" - { CMDlval.i = MakeToken< int >(opINTNAMER, lineIndex); return opINTNAMER; } - YY_BREAK - case 33: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( opINTNAMER, lineIndex ); return opINTNAMER; } + YY_BREAK +case 33: +YY_RULE_SETUP #line 139 "CMDscan.l" - { CMDlval.i = MakeToken< int >('\n', lineIndex); return '@'; } - YY_BREAK - case 34: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( '\n', lineIndex ); return '@'; } + YY_BREAK +case 34: +YY_RULE_SETUP #line 140 "CMDscan.l" - { CMDlval.i = MakeToken< int >('\t', lineIndex); return '@'; } - YY_BREAK - case 35: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( '\t', lineIndex ); return '@'; } + YY_BREAK +case 35: +YY_RULE_SETUP #line 141 "CMDscan.l" - { CMDlval.i = MakeToken< int >(' ', lineIndex); return '@'; } - YY_BREAK - case 36: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( ' ', lineIndex ); return '@'; } + YY_BREAK +case 36: +YY_RULE_SETUP #line 142 "CMDscan.l" - { CMDlval.i = MakeToken< int >(0, lineIndex); return '@'; } - YY_BREAK - case 37: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( 0, lineIndex ); return '@'; } + YY_BREAK +case 37: +YY_RULE_SETUP #line 143 "CMDscan.l" - { /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */ - int c = 0, l; - for (; ; ) +{ /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */ + int c = 0, l; + for ( ; ; ) { l = c; c = yyinput(); // Is this an open comment? - if (c == EOF) + if ( c == EOF ) { - CMDerror("unexpected end of file found in comment"); + CMDerror( "unexpected end of file found in comment" ); break; } // Increment line numbers. - else if (c == '\n') + else if ( c == '\n' ) lineIndex++; // Did we find the end of the comment? - else if (l == '*' && c == '/') + else if ( l == '*' && c == '/' ) break; } - } - YY_BREAK - case 38: + } + YY_BREAK +case 38: #line 167 "CMDscan.l" - case 39: +case 39: #line 168 "CMDscan.l" - case 40: +case 40: #line 169 "CMDscan.l" - case 41: +case 41: #line 170 "CMDscan.l" - case 42: +case 42: #line 171 "CMDscan.l" - case 43: +case 43: #line 172 "CMDscan.l" - case 44: +case 44: #line 173 "CMDscan.l" - case 45: +case 45: #line 174 "CMDscan.l" - case 46: +case 46: #line 175 "CMDscan.l" - case 47: +case 47: #line 176 "CMDscan.l" - case 48: +case 48: #line 177 "CMDscan.l" - case 49: +case 49: #line 178 "CMDscan.l" - case 50: +case 50: #line 179 "CMDscan.l" - case 51: +case 51: #line 180 "CMDscan.l" - case 52: +case 52: #line 181 "CMDscan.l" - case 53: +case 53: #line 182 "CMDscan.l" - case 54: +case 54: #line 183 "CMDscan.l" - case 55: +case 55: #line 184 "CMDscan.l" - case 56: +case 56: #line 185 "CMDscan.l" - case 57: +case 57: #line 186 "CMDscan.l" - case 58: +case 58: #line 187 "CMDscan.l" - case 59: +case 59: #line 188 "CMDscan.l" - case 60: +case 60: #line 189 "CMDscan.l" - case 61: - YY_RULE_SETUP +case 61: +YY_RULE_SETUP #line 189 "CMDscan.l" - { CMDlval.i = MakeToken< int >(CMDtext[0], lineIndex); return CMDtext[0]; } - YY_BREAK - case 62: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( CMDtext[ 0 ], lineIndex ); return CMDtext[ 0 ]; } + YY_BREAK +case 62: +YY_RULE_SETUP #line 190 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwIN, lineIndex); return(rwIN); } - YY_BREAK - case 63: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwIN, lineIndex ); return(rwIN); } + YY_BREAK +case 63: +YY_RULE_SETUP #line 191 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwCASEOR, lineIndex); return(rwCASEOR); } - YY_BREAK - case 64: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwCASEOR, lineIndex ); return(rwCASEOR); } + YY_BREAK +case 64: +YY_RULE_SETUP #line 192 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwBREAK, lineIndex); return(rwBREAK); } - YY_BREAK - case 65: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwBREAK, lineIndex ); return(rwBREAK); } + YY_BREAK +case 65: +YY_RULE_SETUP #line 193 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwRETURN, lineIndex); return(rwRETURN); } - YY_BREAK - case 66: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwRETURN, lineIndex ); return(rwRETURN); } + YY_BREAK +case 66: +YY_RULE_SETUP #line 194 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwELSE, lineIndex); return(rwELSE); } - YY_BREAK - case 67: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwELSE, lineIndex ); return(rwELSE); } + YY_BREAK +case 67: +YY_RULE_SETUP #line 195 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwASSERT, lineIndex); return(rwASSERT); } - YY_BREAK - case 68: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwASSERT, lineIndex ); return(rwASSERT); } + YY_BREAK +case 68: +YY_RULE_SETUP #line 196 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwWHILE, lineIndex); return(rwWHILE); } - YY_BREAK - case 69: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwWHILE, lineIndex ); return(rwWHILE); } + YY_BREAK +case 69: +YY_RULE_SETUP #line 197 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDO, lineIndex); return(rwDO); } - YY_BREAK - case 70: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDO, lineIndex ); return(rwDO); } + YY_BREAK +case 70: +YY_RULE_SETUP #line 198 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwIF, lineIndex); return(rwIF); } - YY_BREAK - case 71: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwIF, lineIndex ); return(rwIF); } + YY_BREAK +case 71: +YY_RULE_SETUP #line 199 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwFOREACHSTR, lineIndex); return(rwFOREACHSTR); } - YY_BREAK - case 72: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwFOREACHSTR, lineIndex ); return(rwFOREACHSTR); } + YY_BREAK +case 72: +YY_RULE_SETUP #line 200 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwFOREACH, lineIndex); return(rwFOREACH); } - YY_BREAK - case 73: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwFOREACH, lineIndex ); return(rwFOREACH); } + YY_BREAK +case 73: +YY_RULE_SETUP #line 201 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwFOR, lineIndex); return(rwFOR); } - YY_BREAK - case 74: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwFOR, lineIndex ); return(rwFOR); } + YY_BREAK +case 74: +YY_RULE_SETUP #line 202 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwCONTINUE, lineIndex); return(rwCONTINUE); } - YY_BREAK - case 75: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwCONTINUE, lineIndex ); return(rwCONTINUE); } + YY_BREAK +case 75: +YY_RULE_SETUP #line 203 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDEFINE, lineIndex); return(rwDEFINE); } - YY_BREAK - case 76: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDEFINE, lineIndex ); return(rwDEFINE); } + YY_BREAK +case 76: +YY_RULE_SETUP #line 204 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDECLARE, lineIndex); return(rwDECLARE); } - YY_BREAK - case 77: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDECLARE, lineIndex ); return(rwDECLARE); } + YY_BREAK +case 77: +YY_RULE_SETUP #line 205 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDECLARESINGLETON, lineIndex); return(rwDECLARESINGLETON); } - YY_BREAK - case 78: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDECLARESINGLETON, lineIndex ); return(rwDECLARESINGLETON); } + YY_BREAK +case 78: +YY_RULE_SETUP #line 206 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDATABLOCK, lineIndex); return(rwDATABLOCK); } - YY_BREAK - case 79: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDATABLOCK, lineIndex ); return(rwDATABLOCK); } + YY_BREAK +case 79: +YY_RULE_SETUP #line 207 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwCASE, lineIndex); return(rwCASE); } - YY_BREAK - case 80: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwCASE, lineIndex ); return(rwCASE); } + YY_BREAK +case 80: +YY_RULE_SETUP #line 208 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwSWITCHSTR, lineIndex); return(rwSWITCHSTR); } - YY_BREAK - case 81: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwSWITCHSTR, lineIndex ); return(rwSWITCHSTR); } + YY_BREAK +case 81: +YY_RULE_SETUP #line 209 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwSWITCH, lineIndex); return(rwSWITCH); } - YY_BREAK - case 82: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwSWITCH, lineIndex ); return(rwSWITCH); } + YY_BREAK +case 82: +YY_RULE_SETUP #line 210 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwDEFAULT, lineIndex); return(rwDEFAULT); } - YY_BREAK - case 83: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwDEFAULT, lineIndex ); return(rwDEFAULT); } + YY_BREAK +case 83: +YY_RULE_SETUP #line 211 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwPACKAGE, lineIndex); return(rwPACKAGE); } - YY_BREAK - case 84: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwPACKAGE, lineIndex ); return(rwPACKAGE); } + YY_BREAK +case 84: +YY_RULE_SETUP #line 212 "CMDscan.l" - { CMDlval.i = MakeToken< int >(rwNAMESPACE, lineIndex); return(rwNAMESPACE); } - YY_BREAK - case 85: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( rwNAMESPACE, lineIndex ); return(rwNAMESPACE); } + YY_BREAK +case 85: +YY_RULE_SETUP #line 213 "CMDscan.l" - { CMDlval.i = MakeToken< int >(1, lineIndex); return INTCONST; } - YY_BREAK - case 86: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( 1, lineIndex ); return INTCONST; } + YY_BREAK +case 86: +YY_RULE_SETUP #line 214 "CMDscan.l" - { CMDlval.i = MakeToken< int >(0, lineIndex); return INTCONST; } - YY_BREAK - case 87: - YY_RULE_SETUP +{ CMDlval.i = MakeToken< int >( 0, lineIndex ); return INTCONST; } + YY_BREAK +case 87: +YY_RULE_SETUP #line 215 "CMDscan.l" - { return(Sc_ScanVar()); } - YY_BREAK - case 88: - YY_RULE_SETUP +{ return(Sc_ScanVar()); } + YY_BREAK +case 88: +YY_RULE_SETUP #line 216 "CMDscan.l" - { return Sc_ScanIdent(); } - YY_BREAK - case 89: - YY_RULE_SETUP +{ return Sc_ScanIdent(); } + YY_BREAK +case 89: +YY_RULE_SETUP #line 217 "CMDscan.l" - return(Sc_ScanHex()); - YY_BREAK - case 90: - YY_RULE_SETUP +return(Sc_ScanHex()); + YY_BREAK +case 90: +YY_RULE_SETUP #line 218 "CMDscan.l" - { CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >(dAtoi(CMDtext), lineIndex); return INTCONST; } - YY_BREAK - case 91: - YY_RULE_SETUP +{ CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), lineIndex ); return INTCONST; } + YY_BREAK +case 91: +YY_RULE_SETUP #line 219 "CMDscan.l" - return Sc_ScanNum(); - YY_BREAK - case 92: - YY_RULE_SETUP +return Sc_ScanNum(); + YY_BREAK +case 92: +YY_RULE_SETUP #line 220 "CMDscan.l" - return(ILLEGAL_TOKEN); - YY_BREAK - case 93: - YY_RULE_SETUP +return(ILLEGAL_TOKEN); + YY_BREAK +case 93: +YY_RULE_SETUP #line 221 "CMDscan.l" - return(ILLEGAL_TOKEN); - YY_BREAK - case 94: - YY_RULE_SETUP +return(ILLEGAL_TOKEN); + YY_BREAK +case 94: +YY_RULE_SETUP #line 222 "CMDscan.l" - ECHO; - YY_BREAK +ECHO; + YY_BREAK #line 1291 "CMDscan.cpp" - case YY_STATE_EOF(INITIAL): - yyterminate(); +case YY_STATE_EOF(INITIAL): + yyterminate(); - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int)(yy_cp - yytext_ptr) - 1; + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; - if (yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if (yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars]) - { /* This was really a NUL. */ - yy_state_type yy_next_state; + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state(); - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ - yy_next_state = yy_try_NUL_trans(yy_current_state); + yy_next_state = yy_try_NUL_trans( yy_current_state ); - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_bp = yytext_ptr + YY_MORE_ADJ; - if (yy_next_state) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } - else switch (yy_get_next_buffer()) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; - if (yywrap()) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } - else - { - if (!yy_did_buffer_switch_on_eof) - YY_NEW_FILE; - } - break; - } + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state(); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state(); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found"); - } /* end of action switch */ -} /* end of scanning one token */ -} /* end of yylex */ + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ - /* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ - static int yy_get_next_buffer() -{ - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; - if (yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1]) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed"); + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); - if (yy_current_buffer->yy_fill_buffer == 0) - { /* Don't try to fill the buffer, so this is an EOF. */ - if (yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1) - { - /* We matched a singled characater, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a singled characater, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } - /* Try to read more data. */ + /* Try to read more data. */ - /* First move last chars to start of buffer. */ - number_to_move = (int)(yy_c_buf_p - yytext_ptr) - 1; + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - for (i = 0; i < number_to_move; ++i) - *(dest++) = *(source++); + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); - if (yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_n_chars = 0; + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_n_chars = 0; - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; - while (num_to_read <= 0) - { /* Not enough room in the buffer - grow it. */ + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ #ifdef YY_USES_REJECT - YY_FATAL_ERROR( - "input buffer overflow, can't enlarge buffer because scanner uses REJECT"); + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; - int yy_c_buf_p_offset = - (int)(yy_c_buf_p - b->yy_ch_buf); + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); - if (b->yy_is_our_buffer) - { - int new_size = b->yy_buf_size * 2; + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; - if (new_size <= 0) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc((void *)b->yy_ch_buf, - b->yy_buf_size + 2); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; - if (!b->yy_ch_buf) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow"); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; #endif - } + } - if (num_to_read > YY_READ_BUF_SIZE) - num_to_read = YY_READ_BUF_SIZE; + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; - /* Read in more data. */ - YY_INPUT((&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read); - } + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + } - if (yy_n_chars == 0) - { - if (number_to_move == YY_MORE_ADJ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin); - } + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } - else - ret_val = EOB_ACT_CONTINUE_SCAN; + else + ret_val = EOB_ACT_CONTINUE_SCAN; - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - return ret_val; -} + return ret_val; + } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state() -{ - register yy_state_type yy_current_state; - register char *yy_cp; + { + register yy_state_type yy_current_state; + register char *yy_cp; - yy_current_state = yy_start; + yy_current_state = yy_start; - for (yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if (yy_accept[yy_current_state]) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 224) - yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - } + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 224 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } - return yy_current_state; -} + return yy_current_state; + } /* yy_try_NUL_trans - try to make a transition on the NUL character -* -* synopsis -* next_state = yy_try_NUL_trans( current_state ); -*/ + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ #ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans(yy_state_type yy_current_state) +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) #else -static yy_state_type yy_try_NUL_trans(yy_current_state) +static yy_state_type yy_try_NUL_trans( yy_current_state ) yy_state_type yy_current_state; #endif -{ - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; - register YY_CHAR yy_c = 1; - if (yy_accept[yy_current_state]) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while (yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state) - { - yy_current_state = (int)yy_def[yy_current_state]; - if (yy_current_state >= 224) - yy_c = yy_meta[(unsigned int)yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int)yy_c]; - yy_is_jam = (yy_current_state == 223); + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 224 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 223); - return yy_is_jam ? 0 : yy_current_state; -} + return yy_is_jam ? 0 : yy_current_state; + } #ifndef YY_NO_UNPUT #ifdef YY_USE_PROTOS -static void yyunput(int c, register char *yy_bp) +static void yyunput( int c, register char *yy_bp ) #else -static void yyunput(c, yy_bp) +static void yyunput( c, yy_bp ) int c; register char *yy_bp; #endif -{ - register char *yy_cp = yy_c_buf_p; + { + register char *yy_cp = yy_c_buf_p; - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; - if (yy_cp < yy_current_buffer->yy_ch_buf + 2) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; - while (source > yy_current_buffer->yy_ch_buf) - *--dest = *--source; + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; - yy_cp += (int)(dest - source); - yy_bp += (int)(dest - source); - yy_n_chars = yy_current_buffer->yy_buf_size; + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_n_chars = yy_current_buffer->yy_buf_size; - if (yy_cp < yy_current_buffer->yy_ch_buf + 2) - YY_FATAL_ERROR("flex scanner push-back overflow"); - } + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } - *--yy_cp = (char)c; + *--yy_cp = (char) c; - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; -} + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } #endif /* ifndef YY_NO_UNPUT */ @@ -1669,384 +1670,384 @@ static int yyinput() #else static int input() #endif -{ - int c; + { + int c; - *yy_c_buf_p = yy_hold_char; + *yy_c_buf_p = yy_hold_char; - if (*yy_c_buf_p == YY_END_OF_BUFFER_CHAR) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if (yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars]) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; - else - { /* need more input */ - yytext_ptr = yy_c_buf_p; - ++yy_c_buf_p; + else + { /* need more input */ + yytext_ptr = yy_c_buf_p; + ++yy_c_buf_p; - switch (yy_get_next_buffer()) - { - case EOB_ACT_END_OF_FILE: - { - if (yywrap()) - { - yy_c_buf_p = - yytext_ptr + YY_MORE_ADJ; - return EOF; - } + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + { + yy_c_buf_p = + yytext_ptr + YY_MORE_ADJ; + return EOF; + } - if (!yy_did_buffer_switch_on_eof) - YY_NEW_FILE; + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus - return yyinput(); + return yyinput(); #else - return input(); + return input(); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - break; + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + break; - case EOB_ACT_LAST_MATCH: + case EOB_ACT_LAST_MATCH: #ifdef __cplusplus - YY_FATAL_ERROR( - "unexpected last match in yyinput()"); + YY_FATAL_ERROR( + "unexpected last match in yyinput()" ); #else - YY_FATAL_ERROR( - "unexpected last match in input()"); + YY_FATAL_ERROR( + "unexpected last match in input()" ); #endif - } - } - } + } + } + } - c = *(unsigned char *)yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; - return c; -} + return c; + } #ifdef YY_USE_PROTOS -void yyrestart(FILE *input_file) +void yyrestart( FILE *input_file ) #else -void yyrestart(input_file) +void yyrestart( input_file ) FILE *input_file; #endif -{ - if (!yy_current_buffer) - yy_current_buffer = yy_create_buffer(yyin, YY_BUF_SIZE); + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - yy_init_buffer(yy_current_buffer, input_file); - yy_load_buffer_state(); -} + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } #ifdef YY_USE_PROTOS -void yy_switch_to_buffer(YY_BUFFER_STATE new_buffer) +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) #else -void yy_switch_to_buffer(new_buffer) +void yy_switch_to_buffer( new_buffer ) YY_BUFFER_STATE new_buffer; #endif -{ - if (yy_current_buffer == new_buffer) - return; + { + if ( yy_current_buffer == new_buffer ) + return; - if (yy_current_buffer) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } - yy_current_buffer = new_buffer; - yy_load_buffer_state(); + yy_current_buffer = new_buffer; + yy_load_buffer_state(); - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; -} + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } #ifdef YY_USE_PROTOS -void yy_load_buffer_state(void) +void yy_load_buffer_state( void ) #else void yy_load_buffer_state() #endif -{ - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; -} + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer(FILE *file, int size) +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) #else -YY_BUFFER_STATE yy_create_buffer(file, size) +YY_BUFFER_STATE yy_create_buffer( file, size ) FILE *file; int size; #endif -{ - YY_BUFFER_STATE b; + { + YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE)yy_flex_alloc(sizeof(struct yy_buffer_state)); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_buf_size = size; + b->yy_buf_size = size; - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *)yy_flex_alloc(b->yy_buf_size + 2); - if (!b->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_create_buffer()"); + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b->yy_is_our_buffer = 1; + b->yy_is_our_buffer = 1; - yy_init_buffer(b, file); + yy_init_buffer( b, file ); - return b; -} + return b; + } #ifdef YY_USE_PROTOS -void yy_delete_buffer(YY_BUFFER_STATE b) +void yy_delete_buffer( YY_BUFFER_STATE b ) #else -void yy_delete_buffer(b) +void yy_delete_buffer( b ) YY_BUFFER_STATE b; #endif -{ - if (!b) - return; + { + if ( ! b ) + return; - if (b == yy_current_buffer) - yy_current_buffer = (YY_BUFFER_STATE)0; + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; - if (b->yy_is_our_buffer) - yy_flex_free((void *)b->yy_ch_buf); + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); - yy_flex_free((void *)b); -} + yy_flex_free( (void *) b ); + } #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO((int)); +extern int isatty YY_PROTO(( int )); #endif #endif #ifdef YY_USE_PROTOS -void yy_init_buffer(YY_BUFFER_STATE b, FILE *file) +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) #else -void yy_init_buffer(b, file) +void yy_init_buffer( b, file ) YY_BUFFER_STATE b; FILE *file; #endif -{ - yy_flush_buffer(b); + { + yy_flush_buffer( b ); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_input_file = file; + b->yy_fill_buffer = 1; #if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; + b->yy_is_interactive = 1; #else #if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; + b->yy_is_interactive = 0; #else - b->yy_is_interactive = file ? (isatty(fileno(file)) > 0) : 0; + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif -} + } #ifdef YY_USE_PROTOS -void yy_flush_buffer(YY_BUFFER_STATE b) +void yy_flush_buffer( YY_BUFFER_STATE b ) #else -void yy_flush_buffer(b) +void yy_flush_buffer( b ) YY_BUFFER_STATE b; #endif -{ - b->yy_n_chars = 0; + { + b->yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; - if (b == yy_current_buffer) - yy_load_buffer_state(); -} + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } #ifndef YY_NO_SCAN_BUFFER #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size) +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) #else -YY_BUFFER_STATE yy_scan_buffer(base, size) +YY_BUFFER_STATE yy_scan_buffer( base, size ) char *base; yy_size_t size; #endif -{ - YY_BUFFER_STATE b; + { + YY_BUFFER_STATE b; - if (size < 2 || - base[size - 2] != YY_END_OF_BUFFER_CHAR || - base[size - 1] != YY_END_OF_BUFFER_CHAR) - /* They forgot to leave room for the EOB's. */ - return 0; + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; - b = (YY_BUFFER_STATE)yy_flex_alloc(sizeof(struct yy_buffer_state)); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in yy_scan_buffer()"); + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer(b); + yy_switch_to_buffer( b ); - return b; -} + return b; + } #endif #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string(yyconst char *str) +YY_BUFFER_STATE yy_scan_string( yyconst char *str ) #else -YY_BUFFER_STATE yy_scan_string(str) +YY_BUFFER_STATE yy_scan_string( str ) yyconst char *str; #endif -{ - int len; - for (len = 0; str[len]; ++len) - ; + { + int len; + for ( len = 0; str[len]; ++len ) + ; - return yy_scan_bytes(str, len); -} + return yy_scan_bytes( str, len ); + } #endif #ifndef YY_NO_SCAN_BYTES #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes(yyconst char *bytes, int len) +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) #else -YY_BUFFER_STATE yy_scan_bytes(bytes, len) +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) yyconst char *bytes; int len; #endif -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *)yy_flex_alloc(n); - if (!buf) - YY_FATAL_ERROR("out of dynamic memory in yy_scan_bytes()"); + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for (i = 0; i < len; ++i) - buf[i] = bytes[i]; + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; - buf[len] = buf[len + 1] = YY_END_OF_BUFFER_CHAR; + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer(buf, n); - if (!b) - YY_FATAL_ERROR("bad buffer in yy_scan_bytes()"); + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; - return b; -} + return b; + } #endif #ifndef YY_NO_PUSH_STATE #ifdef YY_USE_PROTOS -static void yy_push_state(int new_state) +static void yy_push_state( int new_state ) #else -static void yy_push_state(new_state) +static void yy_push_state( new_state ) int new_state; #endif -{ - if (yy_start_stack_ptr >= yy_start_stack_depth) - { - yy_size_t new_size; + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof(int); + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); - if (!yy_start_stack) - yy_start_stack = (int *)yy_flex_alloc(new_size); + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); - else - yy_start_stack = (int *)yy_flex_realloc( - (void *)yy_start_stack, new_size); + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); - if (!yy_start_stack) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack"); - } + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } - yy_start_stack[yy_start_stack_ptr++] = YY_START; + yy_start_stack[yy_start_stack_ptr++] = YY_START; - BEGIN(new_state); -} + BEGIN(new_state); + } #endif #ifndef YY_NO_POP_STATE static void yy_pop_state() -{ - if (--yy_start_stack_ptr < 0) - YY_FATAL_ERROR("start-condition stack underflow"); + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); - BEGIN(yy_start_stack[yy_start_stack_ptr]); -} + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } #endif #ifndef YY_NO_TOP_STATE static int yy_top_state() -{ - return yy_start_stack[yy_start_stack_ptr - 1]; -} + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } #endif #ifndef YY_EXIT_FAILURE @@ -2054,15 +2055,15 @@ static int yy_top_state() #endif #ifdef YY_USE_PROTOS -static void yy_fatal_error(yyconst char msg[]) +static void yy_fatal_error( yyconst char msg[] ) #else -static void yy_fatal_error(msg) +static void yy_fatal_error( msg ) char msg[]; #endif -{ - (void)fprintf(stderr, "%s\n", msg); - exit(YY_EXIT_FAILURE); -} + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } @@ -2086,65 +2087,65 @@ char msg[]; #ifndef yytext_ptr #ifdef YY_USE_PROTOS -static void yy_flex_strncpy(char *s1, yyconst char *s2, int n) +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) #else -static void yy_flex_strncpy(s1, s2, n) +static void yy_flex_strncpy( s1, s2, n ) char *s1; yyconst char *s2; int n; #endif -{ - register int i; - for (i = 0; i < n; ++i) - s1[i] = s2[i]; -} + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } #endif #ifdef YY_USE_PROTOS -static void *yy_flex_alloc(yy_size_t size) +static void *yy_flex_alloc( yy_size_t size ) #else -static void *yy_flex_alloc(size) +static void *yy_flex_alloc( size ) yy_size_t size; #endif -{ - return (void *)malloc(size); -} + { + return (void *) malloc( size ); + } #ifdef YY_USE_PROTOS -static void *yy_flex_realloc(void *ptr, yy_size_t size) +static void *yy_flex_realloc( void *ptr, yy_size_t size ) #else -static void *yy_flex_realloc(ptr, size) +static void *yy_flex_realloc( ptr, size ) void *ptr; yy_size_t size; #endif -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *)realloc((char *)ptr, size); -} + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } #ifdef YY_USE_PROTOS -static void yy_flex_free(void *ptr) +static void yy_flex_free( void *ptr ) #else -static void yy_flex_free(ptr) +static void yy_flex_free( ptr ) void *ptr; #endif -{ - free(ptr); -} + { + free( ptr ); + } #if YY_MAIN int main() -{ - yylex(); - return 0; -} + { + yylex(); + return 0; + } #endif #line 222 "CMDscan.l" @@ -2172,59 +2173,59 @@ void CMDerror(char *format, ...) const int BUFMAX = 1024; char tempBuf[BUFMAX]; va_list args; - va_start(args, format); + va_start( args, format ); #ifdef TORQUE_OS_WIN - _vsnprintf(tempBuf, BUFMAX, format, args); + _vsnprintf( tempBuf, BUFMAX, format, args ); #else - vsnprintf(tempBuf, BUFMAX, format, args); + vsnprintf( tempBuf, BUFMAX, format, args ); #endif - va_end(args); + va_end(args); - if (fileName) + if(fileName) { Con::errorf(ConsoleLogEntry::Script, "%s Line: %d - %s", fileName, lineIndex, tempBuf); #ifndef NO_ADVANCED_ERROR_REPORT // dhc - lineIndex is bogus. let's try to add some sanity back in. - int i, j, n; + int i,j,n; char c; int linediv = 1; // first, walk the buffer, trying to detect line ending type. // this is imperfect, if inconsistant line endings exist... - for (i = 0; iBUFMAX >> 2) break; // at least get a little data + c = scanBuffer[scanIndex-i]; + if ((c=='\r' || c=='\n') && i>BUFMAX>>2) break; // at least get a little data n++; i++; } // find next lineending - while (n>1) // cap at half-buf-size forward + while (n>1) // cap at half-buf-size forward { - c = scanBuffer[scanIndex + j]; - if (c == 0) break; - if ((c == '\r' || c == '\n') && j>BUFMAX >> 2) break; // at least get a little data + c = scanBuffer[scanIndex+j]; + if (c==0) break; + if ((c=='\r' || c=='\n') && j>BUFMAX>>2) break; // at least get a little data n++; j++; } if (i) i--; // chop off extra linefeed. if (j) j--; // chop off extra linefeed. - // build our little text block - if (i) dStrncpy(tempBuf, scanBuffer + scanIndex - i, i); - dStrncpy(tempBuf + i, "##", 2); // bracketing. - tempBuf[i + 2] = scanBuffer[scanIndex]; // copy the halt character. - dStrncpy(tempBuf + i + 3, "##", 2); // bracketing. - if (j) dStrncpy(tempBuf + i + 5, scanBuffer + scanIndex + 1, j); // +1 to go past current char. - tempBuf[i + j + 5] = 0; // null terminate - for (n = 0; n>> Advanced script error report. Line %d.", lineIndex); Con::warnf(ConsoleLogEntry::Script, ">>> Some error context, with ## on sides of error halt:"); @@ -2241,7 +2242,7 @@ void CMDerror(char *format, ...) Con::setVariable("$ScriptError", tempBuf); // We also need to mark that we came up with a new error. - static S32 sScriptErrorHash = 1000; + static S32 sScriptErrorHash=1000; Con::setIntVariable("$ScriptErrorHash", sScriptErrorHash++); } else @@ -2259,7 +2260,7 @@ void CMDSetScanBuffer(const char *sb, const char *fn) int CMDgetc() { int ret = scanBuffer[scanIndex]; - if (ret) + if(ret) scanIndex++; else ret = -1; @@ -2277,13 +2278,13 @@ static int Sc_ScanVar() CMDtext[CMDleng] = 0; // Make it a stringtable string! - CMDlval.s = MakeToken< StringTableEntry >(StringTable->insert(CMDtext), lineIndex); + CMDlval.s = MakeToken< StringTableEntry >( StringTable->insert(CMDtext), lineIndex ); return(VAR); } static int charConv(int in) { - switch (in) + switch(in) { case 'r': return '\r'; @@ -2298,11 +2299,11 @@ static int charConv(int in) static int getHexDigit(char c) { - if (c >= '0' && c <= '9') + if(c >= '0' && c <= '9') return c - '0'; - if (c >= 'A' && c <= 'F') + if(c >= 'A' && c <= 'F') return c - 'A' + 10; - if (c >= 'a' && c <= 'f') + if(c >= 'a' && c <= 'f') return c - 'a' + 10; return -1; } @@ -2310,41 +2311,41 @@ static int getHexDigit(char c) static int Sc_ScanDocBlock() { S32 len = dStrlen(CMDtext); - char* text = (char *)consoleAlloc(len + 1); + char* text = (char *) consoleAlloc(len + 1); S32 line = lineIndex; - for (S32 i = 0, j = 0; j <= len; j++) + for( S32 i = 0, j = 0; j <= len; j++ ) { - if ((j <= (len - 2)) && (CMDtext[j] == '/') && (CMDtext[j + 1] == '/') && (CMDtext[j + 2] == '/')) + if( ( j <= (len - 2) ) && ( CMDtext[j] == '/' ) && ( CMDtext[j + 1] == '/' ) && ( CMDtext[j + 2] == '/' ) ) { j += 2; continue; } - if (CMDtext[j] == '\r') + if( CMDtext[j] == '\r' ) continue; - if (CMDtext[j] == '\n') + if( CMDtext[j] == '\n' ) lineIndex++; text[i++] = CMDtext[j]; } - CMDlval.str = MakeToken< char* >(text, line); + CMDlval.str = MakeToken< char* >( text, line ); return(DOCBLOCK); } static int Sc_ScanString(int ret) { CMDtext[CMDleng - 1] = 0; - if (!collapseEscape(CMDtext + 1)) + if(!collapseEscape(CMDtext+1)) return -1; - dsize_t bufferLen = dStrlen(CMDtext); - char* buffer = (char*)consoleAlloc(bufferLen); - dStrcpy(buffer, CMDtext + 1, bufferLen); + dsize_t bufferLen = dStrlen( CMDtext ); + char* buffer = ( char* ) consoleAlloc( bufferLen ); + dStrcpy( buffer, CMDtext + 1, bufferLen ); - CMDlval.str = MakeToken< char* >(buffer, lineIndex); + CMDlval.str = MakeToken< char* >( buffer, lineIndex ); return ret; } @@ -2354,96 +2355,96 @@ static int Sc_ScanIdent() CMDtext[CMDleng] = 0; - if ((type = ConsoleBaseType::getTypeByName(CMDtext)) != NULL) + if((type = ConsoleBaseType::getTypeByName(CMDtext)) != NULL) { /* It's a type */ - CMDlval.i = MakeToken< int >(type->getTypeID(), lineIndex); + CMDlval.i = MakeToken< int >( type->getTypeID(), lineIndex ); return TYPEIDENT; } /* It's an identifier */ - CMDlval.s = MakeToken< StringTableEntry >(StringTable->insert(CMDtext), lineIndex); + CMDlval.s = MakeToken< StringTableEntry >( StringTable->insert(CMDtext), lineIndex ); return IDENT; } void expandEscape(char *dest, const char *src) { U8 c; - while ((c = (U8)*src++) != 0) + while((c = (U8) *src++) != 0) { - if (c == '\"') + if(c == '\"') { *dest++ = '\\'; *dest++ = '\"'; } - else if (c == '\\') + else if(c == '\\') { *dest++ = '\\'; *dest++ = '\\'; } - else if (c == '\r') + else if(c == '\r') { *dest++ = '\\'; *dest++ = 'r'; } - else if (c == '\n') + else if(c == '\n') { *dest++ = '\\'; *dest++ = 'n'; } - else if (c == '\t') + else if(c == '\t') { *dest++ = '\\'; *dest++ = 't'; } - else if (c == '\'') + else if(c == '\'') { *dest++ = '\\'; *dest++ = '\''; } - else if ((c >= 1 && c <= 7) || - (c >= 11 && c <= 12) || - (c >= 14 && c <= 15)) + else if((c >= 1 && c <= 7) || + (c >= 11 && c <= 12) || + (c >= 14 && c <= 15)) { - /* Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */ - static U8 expandRemap[15] = { 0x0, - 0x0, - 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x6, - 0x0, - 0x0, - 0x0, - 0x7, - 0x8, - 0x0, - 0x9 }; + /* Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */ + static U8 expandRemap[15] = { 0x0, + 0x0, + 0x1, + 0x2, + 0x3, + 0x4, + 0x5, + 0x6, + 0x0, + 0x0, + 0x0, + 0x7, + 0x8, + 0x0, + 0x9 }; *dest++ = '\\'; *dest++ = 'c'; - if (c == 15) + if(c == 15) *dest++ = 'r'; - else if (c == 16) + else if(c == 16) *dest++ = 'p'; - else if (c == 17) + else if(c == 17) *dest++ = 'o'; else *dest++ = expandRemap[c] + '0'; } - else if (c < 32) + else if(c < 32) { *dest++ = '\\'; *dest++ = 'x'; S32 dig1 = c >> 4; S32 dig2 = c & 0xf; - if (dig1 < 10) + if(dig1 < 10) dig1 += '0'; else dig1 += 'A' - 10; - if (dig2 < 10) + if(dig2 < 10) dig2 += '0'; else dig2 += 'A' - 10; @@ -2459,56 +2460,56 @@ void expandEscape(char *dest, const char *src) bool collapseEscape(char *buf) { S32 len = dStrlen(buf) + 1; - for (S32 i = 0; i < len;) + for(S32 i = 0; i < len;) { - if (buf[i] == '\\') + if(buf[i] == '\\') { - if (buf[i + 1] == 'x') + if(buf[i+1] == 'x') { - S32 dig1 = getHexDigit(buf[i + 2]); - if (dig1 == -1) + S32 dig1 = getHexDigit(buf[i+2]); + if(dig1 == -1) return false; - S32 dig2 = getHexDigit(buf[i + 3]); - if (dig2 == -1) + S32 dig2 = getHexDigit(buf[i+3]); + if(dig2 == -1) return false; buf[i] = dig1 * 16 + dig2; dMemmove(buf + i + 1, buf + i + 4, len - i - 3); len -= 3; i++; } - else if (buf[i + 1] == 'c') + else if(buf[i+1] == 'c') { /* Remap around: \b = 0x8, \t = 0x9, \n = 0xa, \r = 0xd */ static U8 collapseRemap[10] = { 0x1, - 0x2, - 0x3, - 0x4, - 0x5, - 0x6, - 0x7, - 0xb, - 0xc, - 0xe }; + 0x2, + 0x3, + 0x4, + 0x5, + 0x6, + 0x7, + 0xb, + 0xc, + 0xe }; - if (buf[i + 2] == 'r') - buf[i] = 15; - else if (buf[i + 2] == 'p') + if(buf[i+2] == 'r') + buf[i] = 15; + else if(buf[i+2] == 'p') buf[i] = 16; - else if (buf[i + 2] == 'o') + else if(buf[i+2] == 'o') buf[i] = 17; else { - int dig1 = buf[i + 2] - '0'; - if (dig1 < 0 || dig1 > 9) - return false; - buf[i] = collapseRemap[dig1]; + int dig1 = buf[i+2] - '0'; + if(dig1 < 0 || dig1 > 9) + return false; + buf[i] = collapseRemap[dig1]; } // Make sure we don't put 0x1 at the beginning of the string. if ((buf[i] == 0x1) && (i == 0)) { buf[i] = 0x2; - buf[i + 1] = 0x1; + buf[i+1] = 0x1; dMemmove(buf + i + 2, buf + i + 3, len - i - 1); len -= 1; } @@ -2521,7 +2522,7 @@ bool collapseEscape(char *buf) } else { - buf[i] = charConv(buf[i + 1]); + buf[i] = charConv(buf[i+1]); dMemmove(buf + i + 1, buf + i + 2, len - i - 1); len--; i++; @@ -2536,7 +2537,7 @@ bool collapseEscape(char *buf) static int Sc_ScanNum() { CMDtext[CMDleng] = 0; - CMDlval.f = MakeToken< double >(dAtof(CMDtext), lineIndex); + CMDlval.f = MakeToken< double >( dAtof(CMDtext), lineIndex ); return(FLTCONST); } @@ -2544,7 +2545,7 @@ static int Sc_ScanHex() { S32 val = 0; dSscanf(CMDtext, "%x", &val); - CMDlval.i = MakeToken< int >(val, lineIndex); + CMDlval.i = MakeToken< int >( val, lineIndex ); return INTCONST; } diff --git a/Engine/source/console/CMDscan.l b/Engine/source/console/CMDscan.l index e9069fe15..ccf933bd7 100644 --- a/Engine/source/console/CMDscan.l +++ b/Engine/source/console/CMDscan.l @@ -213,6 +213,7 @@ HEXDIGIT [a-fA-F0-9] "true" { CMDlval.i = MakeToken< int >( 1, lineIndex ); return INTCONST; } "false" { CMDlval.i = MakeToken< int >( 0, lineIndex ); return INTCONST; } {VAR} { return(Sc_ScanVar()); } + {ID} { return Sc_ScanIdent(); } 0[xX]{HEXDIGIT}+ return(Sc_ScanHex()); {INTEGER} { CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), lineIndex ); return INTCONST; } diff --git a/Engine/source/console/ICallMethod.h b/Engine/source/console/ICallMethod.h index fdda77fa7..0c0d50299 100644 --- a/Engine/source/console/ICallMethod.h +++ b/Engine/source/console/ICallMethod.h @@ -27,7 +27,7 @@ class ICallMethod { public: virtual const char* callMethod( S32 argc, const char* methodName, ... ) = 0; - virtual const char* callMethodArgList( U32 argc, ConsoleValueRef argv[], bool callThis = true ) = 0; + virtual const char* callMethodArgList( U32 argc, ConsoleValue argv[], bool callThis = true ) = 0; }; -#endif \ No newline at end of file +#endif diff --git a/Engine/source/console/SimXMLDocument.cpp b/Engine/source/console/SimXMLDocument.cpp index 5c1f8feef..9f0bd4ff4 100644 --- a/Engine/source/console/SimXMLDocument.cpp +++ b/Engine/source/console/SimXMLDocument.cpp @@ -159,7 +159,7 @@ SimXMLDocument::~SimXMLDocument() // ----------------------------------------------------------------------------- // Included for completeness. // ----------------------------------------------------------------------------- -bool SimXMLDocument::processArguments(S32 argc, ConsoleValueRef *argv) +bool SimXMLDocument::processArguments(S32 argc, ConsoleValue *argv) { return argc == 0; } diff --git a/Engine/source/console/SimXMLDocument.h b/Engine/source/console/SimXMLDocument.h index 3ba32bb9b..2a12a50ba 100644 --- a/Engine/source/console/SimXMLDocument.h +++ b/Engine/source/console/SimXMLDocument.h @@ -56,7 +56,7 @@ class SimXMLDocument: public SimObject // tie in to the script language. The .cc file has more in depth // comments on these. //----------------------------------------------------------------------- - bool processArguments(S32 argc, ConsoleValueRef *argv); + bool processArguments(S32 argc, ConsoleValue *argv); bool onAdd(); void onRemove(); static void initPersistFields(); diff --git a/Engine/source/console/ast.h b/Engine/source/console/ast.h index f81971413..558446534 100644 --- a/Engine/source/console/ast.h +++ b/Engine/source/console/ast.h @@ -39,8 +39,15 @@ enum TypeReq TypeReqNone, TypeReqUInt, TypeReqFloat, - TypeReqString, - TypeReqVar + TypeReqString +}; + +enum ExprNodeName +{ + NameExprNode, + NameFloatNode, + NameIntNode, + NameVarNode }; /// Representation of a node for the scripting language parser. @@ -52,7 +59,7 @@ enum TypeReq /// each representing a different language construct. struct StmtNode { - StmtNode *mNext; ///< Next entry in parse tree. + StmtNode* next; ///< Next entry in parse tree. StmtNode(); virtual ~StmtNode() {} @@ -61,8 +68,8 @@ struct StmtNode /// @{ /// - void append(StmtNode *next); - StmtNode *getNext() const { return mNext; } + void append(StmtNode* next); + StmtNode* getNext() const { return next; } /// @} @@ -79,93 +86,95 @@ struct StmtNode /// @name Breaking /// @{ - void addBreakLine(CodeStream &codeStream); + void addBreakLine(CodeStream& codeStream); /// @} /// @name Compilation /// @{ - virtual U32 compileStmt(CodeStream &codeStream, U32 ip) = 0; + virtual U32 compileStmt(CodeStream& codeStream, U32 ip) = 0; virtual void setPackage(StringTableEntry packageName); /// @} }; /// Helper macro #ifndef DEBUG_AST_NODES -# define DBG_STMT_TYPE(s) virtual String dbgStmtType() const { return String(#s); } +# define DBG_STMT_TYPE(s) virtual const char* dbgStmtType() const { return "#s"; } #else # define DBG_STMT_TYPE(s) #endif struct BreakStmtNode : StmtNode { - static BreakStmtNode *alloc(S32 lineNumber); + static BreakStmtNode* alloc(S32 lineNumber); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(BreakStmtNode); }; struct ContinueStmtNode : StmtNode { - static ContinueStmtNode *alloc(S32 lineNumber); + static ContinueStmtNode* alloc(S32 lineNumber); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(ContinueStmtNode); }; /// A mathematical expression. struct ExprNode : StmtNode { + ExprNode* optimizedNode; - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); - virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type) = 0; + virtual U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) = 0; virtual TypeReq getPreferredType() = 0; + virtual ExprNodeName getExprNodeNameEnum() const { return NameExprNode; } }; struct ReturnStmtNode : StmtNode { - ExprNode *expr; + ExprNode* expr; - static ReturnStmtNode *alloc(S32 lineNumber, ExprNode *expr); + static ReturnStmtNode* alloc(S32 lineNumber, ExprNode* expr); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(ReturnStmtNode); }; struct IfStmtNode : StmtNode { - ExprNode *testExpr; - StmtNode *ifBlock, *elseBlock; + ExprNode* testExpr; + StmtNode* ifBlock, * elseBlock; U32 endifOffset; U32 elseOffset; bool integer; bool propagate; - static IfStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagateThrough); - void propagateSwitchExpr(ExprNode *left, bool string); - ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string); + static IfStmtNode* alloc(S32 lineNumber, ExprNode* testExpr, StmtNode* ifBlock, StmtNode* elseBlock, bool propagateThrough); + void propagateSwitchExpr(ExprNode* left, bool string); + ExprNode* getSwitchOR(ExprNode* left, ExprNode* list, bool string); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(IfStmtNode); }; struct LoopStmtNode : StmtNode { - ExprNode *testExpr; - ExprNode *initExpr; - ExprNode *endLoopExpr; - StmtNode *loopBlock; + ExprNode* testExpr; + ExprNode* initExpr; + ExprNode* endLoopExpr; + StmtNode* loopBlock; bool isDoLoop; U32 breakOffset; U32 continueOffset; U32 loopBlockStartOffset; bool integer; - static LoopStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *initExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop); + static LoopStmtNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* initExpr, ExprNode* endLoopExpr, StmtNode* loopBlock, bool isDoLoop); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(LoopStmtNode); }; @@ -189,35 +198,38 @@ struct IterStmtNode : StmtNode static IterStmtNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); }; /// A binary mathematical expression (ie, left op right). struct BinaryExprNode : ExprNode { S32 op; - ExprNode *left; - ExprNode *right; + ExprNode* left; + ExprNode* right; }; struct FloatBinaryExprNode : BinaryExprNode { - static FloatBinaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right); + static FloatBinaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right); + + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); + + bool optimize(); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(FloatBinaryExprNode); }; struct ConditionalExprNode : ExprNode { - ExprNode *testExpr; - ExprNode *trueExpr; - ExprNode *falseExpr; + ExprNode* testExpr; + ExprNode* trueExpr; + ExprNode* falseExpr; bool integer; - static ConditionalExprNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr); + static ConditionalExprNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* trueExpr, ExprNode* falseExpr); - virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + virtual U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); virtual TypeReq getPreferredType(); DBG_STMT_TYPE(ConditionalExprNode); }; @@ -227,11 +239,13 @@ struct IntBinaryExprNode : BinaryExprNode TypeReq subType; U32 operand; - static IntBinaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right); + static IntBinaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right); void getSubTypeOperand(); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + bool optimize(); + + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(IntBinaryExprNode); }; @@ -239,9 +253,9 @@ struct IntBinaryExprNode : BinaryExprNode struct StreqExprNode : BinaryExprNode { bool eq; - static StreqExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, bool eq); + static StreqExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, bool eq); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(StreqExprNode); }; @@ -249,19 +263,19 @@ struct StreqExprNode : BinaryExprNode struct StrcatExprNode : BinaryExprNode { S32 appendChar; - static StrcatExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar); + static StrcatExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, S32 appendChar); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(StrcatExprNode); }; struct CommaCatExprNode : BinaryExprNode { - static CommaCatExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right); + static CommaCatExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(CommaCatExprNode); }; @@ -269,12 +283,12 @@ struct CommaCatExprNode : BinaryExprNode struct IntUnaryExprNode : ExprNode { S32 op; - ExprNode *expr; + ExprNode* expr; bool integer; - static IntUnaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *expr); + static IntUnaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* expr); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(IntUnaryExprNode); }; @@ -282,11 +296,11 @@ struct IntUnaryExprNode : ExprNode struct FloatUnaryExprNode : ExprNode { S32 op; - ExprNode *expr; + ExprNode* expr; - static FloatUnaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *expr); + static FloatUnaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* expr); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(FloatUnaryExprNode); }; @@ -294,12 +308,13 @@ struct FloatUnaryExprNode : ExprNode struct VarNode : ExprNode { StringTableEntry varName; - ExprNode *arrayIndex; + ExprNode* arrayIndex; - static VarNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex); + static VarNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); + virtual ExprNodeName getExprNodeNameEnum() const { return NameVarNode; } DBG_STMT_TYPE(VarNode); }; @@ -308,10 +323,11 @@ struct IntNode : ExprNode S32 value; U32 index; // if it's converted to float/string - static IntNode *alloc(S32 lineNumber, S32 value); + static IntNode* alloc(S32 lineNumber, S32 value); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); + virtual ExprNodeName getExprNodeNameEnum() const { return NameIntNode; } DBG_STMT_TYPE(IntNode); }; @@ -320,24 +336,25 @@ struct FloatNode : ExprNode F64 value; U32 index; - static FloatNode *alloc(S32 lineNumber, F64 value); + static FloatNode* alloc(S32 lineNumber, F64 value); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); + virtual ExprNodeName getExprNodeNameEnum() const { return NameFloatNode; } DBG_STMT_TYPE(FloatNode); }; struct StrConstNode : ExprNode { - char *str; + char* str; F64 fVal; U32 index; bool tag; bool doc; // Specifies that this string is a documentation block. - static StrConstNode *alloc(S32 lineNumber, char *str, bool tag, bool doc = false); + static StrConstNode* alloc(S32 lineNumber, char* str, bool tag, bool doc = false); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(StrConstNode); }; @@ -348,9 +365,9 @@ struct ConstantNode : ExprNode F64 fVal; U32 index; - static ConstantNode *alloc(S32 lineNumber, StringTableEntry value); + static ConstantNode* alloc(S32 lineNumber, StringTableEntry value); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(ConstantNode); }; @@ -358,13 +375,13 @@ struct ConstantNode : ExprNode struct AssignExprNode : ExprNode { StringTableEntry varName; - ExprNode *expr; - ExprNode *arrayIndex; + ExprNode* expr; + ExprNode* arrayIndex; TypeReq subType; - static AssignExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr); + static AssignExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(AssignExprNode); }; @@ -373,22 +390,22 @@ struct AssignDecl { S32 lineNumber; S32 token; - ExprNode *expr; + ExprNode* expr; bool integer; }; struct AssignOpExprNode : ExprNode { StringTableEntry varName; - ExprNode *expr; - ExprNode *arrayIndex; + ExprNode* expr; + ExprNode* arrayIndex; S32 op; U32 operand; TypeReq subType; - static AssignOpExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op); + static AssignOpExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr, S32 op); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(AssignOpExprNode); }; @@ -396,22 +413,22 @@ struct AssignOpExprNode : ExprNode struct TTagSetStmtNode : StmtNode { StringTableEntry tag; - ExprNode *valueExpr; - ExprNode *stringExpr; + ExprNode* valueExpr; + ExprNode* stringExpr; - static TTagSetStmtNode *alloc(S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr); + static TTagSetStmtNode* alloc(S32 lineNumber, StringTableEntry tag, ExprNode* valueExpr, ExprNode* stringExpr); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); DBG_STMT_TYPE(TTagSetStmtNode); }; struct TTagDerefNode : ExprNode { - ExprNode *expr; + ExprNode* expr; - static TTagDerefNode *alloc(S32 lineNumber, ExprNode *expr); + static TTagDerefNode* alloc(S32 lineNumber, ExprNode* expr); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(TTagDerefNode); }; @@ -420,9 +437,9 @@ struct TTagExprNode : ExprNode { StringTableEntry tag; - static TTagExprNode *alloc(S32 lineNumber, StringTableEntry tag); + static TTagExprNode* alloc(S32 lineNumber, StringTableEntry tag); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(TTagExprNode); }; @@ -431,42 +448,31 @@ struct FuncCallExprNode : ExprNode { StringTableEntry funcName; StringTableEntry nameSpace; - ExprNode *args; + ExprNode* args; U32 callType; enum { FunctionCall, + StaticCall, MethodCall, ParentCall }; - static FuncCallExprNode *alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot); + static FuncCallExprNode* alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode* args, bool dot); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(FuncCallExprNode); }; -struct FuncPointerCallExprNode : ExprNode -{ - ExprNode *funcPointer; - ExprNode *args; - - static FuncPointerCallExprNode *alloc(S32 lineNumber, ExprNode *stmt, ExprNode *args); - - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); - TypeReq getPreferredType(); - DBG_STMT_TYPE(FuncPointerCallExprNode); -}; - struct AssertCallExprNode : ExprNode { - ExprNode *testExpr; - const char *message; + ExprNode* testExpr; + const char* message; U32 messageIndex; - static AssertCallExprNode *alloc(S32 lineNumber, ExprNode *testExpr, const char *message); + static AssertCallExprNode* alloc(S32 lineNumber, ExprNode* testExpr, const char* message); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(AssertCallExprNode); }; @@ -474,19 +480,19 @@ struct AssertCallExprNode : ExprNode struct SlotDecl { S32 lineNumber; - ExprNode *object; + ExprNode* object; StringTableEntry slotName; - ExprNode *array; + ExprNode* array; }; struct SlotAccessNode : ExprNode { - ExprNode *objectExpr, *arrayExpr; + ExprNode* objectExpr, * arrayExpr; StringTableEntry slotName; - static SlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName); + static SlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(SlotAccessNode); }; @@ -494,101 +500,99 @@ struct SlotAccessNode : ExprNode struct InternalSlotDecl { S32 lineNumber; - ExprNode *object; - ExprNode *slotExpr; + ExprNode* object; + ExprNode* slotExpr; bool recurse; }; struct InternalSlotAccessNode : ExprNode { - ExprNode *objectExpr, *slotExpr; + ExprNode* objectExpr, * slotExpr; bool recurse; - static InternalSlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse); + static InternalSlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* slotExpr, bool recurse); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(InternalSlotAccessNode); }; struct SlotAssignNode : ExprNode { - ExprNode *objectExpr, *arrayExpr; + ExprNode* objectExpr, * arrayExpr; StringTableEntry slotName; - ExprNode *valueExpr; + ExprNode* valueExpr; U32 typeID; - static SlotAssignNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID = -1); + static SlotAssignNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName, ExprNode* valueExpr, U32 typeID = -1); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(SlotAssignNode); }; struct SlotAssignOpNode : ExprNode { - ExprNode *objectExpr, *arrayExpr; + ExprNode* objectExpr, * arrayExpr; StringTableEntry slotName; S32 op; - ExprNode *valueExpr; + ExprNode* valueExpr; U32 operand; TypeReq subType; - static SlotAssignOpNode *alloc(S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr); + static SlotAssignOpNode* alloc(S32 lineNumber, ExprNode* objectExpr, StringTableEntry slotName, ExprNode* arrayExpr, S32 op, ExprNode* valueExpr); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); TypeReq getPreferredType(); DBG_STMT_TYPE(SlotAssignOpNode); }; struct ObjectDeclNode : ExprNode { - ExprNode *classNameExpr; + ExprNode* classNameExpr; StringTableEntry parentObject; - ExprNode *objectNameExpr; - ExprNode *argList; - SlotAssignNode *slotDecls; - ObjectDeclNode *subObjects; + ExprNode* objectNameExpr; + ExprNode* argList; + SlotAssignNode* slotDecls; + ObjectDeclNode* subObjects; bool isDatablock; U32 failOffset; bool isClassNameInternal; bool isSingleton; - static ObjectDeclNode *alloc(S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton); + static ObjectDeclNode* alloc(S32 lineNumber, ExprNode* classNameExpr, ExprNode* objectNameExpr, ExprNode* argList, StringTableEntry parentObject, SlotAssignNode* slotDecls, ObjectDeclNode* subObjects, bool isDatablock, bool classNameInternal, bool isSingleton); U32 precompileSubObject(bool); - U32 compile(CodeStream &codeStream, U32 ip, TypeReq type); - U32 compileSubObject(CodeStream &codeStream, U32 ip, bool); + U32 compile(CodeStream& codeStream, U32 ip, TypeReq type); + U32 compileSubObject(CodeStream& codeStream, U32 ip, bool); TypeReq getPreferredType(); DBG_STMT_TYPE(ObjectDeclNode); }; struct ObjectBlockDecl { - SlotAssignNode *slots; - ObjectDeclNode *decls; + SlotAssignNode* slots; + ObjectDeclNode* decls; }; struct FunctionDeclStmtNode : StmtNode { StringTableEntry fnName; - VarNode *args; - StmtNode *stmts; + VarNode* args; + StmtNode* stmts; StringTableEntry nameSpace; StringTableEntry package; U32 endOffset; U32 argc; - static FunctionDeclStmtNode *alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts); + static FunctionDeclStmtNode* alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode* args, StmtNode* stmts); - U32 compileStmt(CodeStream &codeStream, U32 ip); + U32 compileStmt(CodeStream& codeStream, U32 ip); void setPackage(StringTableEntry packageName); DBG_STMT_TYPE(FunctionDeclStmtNode); }; -extern StmtNode *gStatementList; -extern StmtNode *gAnonFunctionList; -extern U32 gAnonFunctionID; +extern StmtNode* gStatementList; extern ExprEvalState gEvalState; #endif diff --git a/Engine/source/console/astAlloc.cpp b/Engine/source/console/astAlloc.cpp index 521b6dbcc..50d02bcaa 100644 --- a/Engine/source/console/astAlloc.cpp +++ b/Engine/source/console/astAlloc.cpp @@ -1,5 +1,5 @@ //----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC +// Copyright (c) 2013 GarageGames, LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to @@ -20,7 +20,6 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -#include "platform/platform.h" #include "console/console.h" #include "console/compiler.h" #include "console/consoleInternal.h" @@ -38,25 +37,25 @@ using namespace Compiler; //------------------------------------------------------------ -BreakStmtNode *BreakStmtNode::alloc(S32 lineNumber) +BreakStmtNode* BreakStmtNode::alloc(S32 lineNumber) { - BreakStmtNode *ret = (BreakStmtNode *)consoleAlloc(sizeof(BreakStmtNode)); + BreakStmtNode* ret = (BreakStmtNode*)consoleAlloc(sizeof(BreakStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; return ret; } -ContinueStmtNode *ContinueStmtNode::alloc(S32 lineNumber) +ContinueStmtNode* ContinueStmtNode::alloc(S32 lineNumber) { - ContinueStmtNode *ret = (ContinueStmtNode *)consoleAlloc(sizeof(ContinueStmtNode)); + ContinueStmtNode* ret = (ContinueStmtNode*)consoleAlloc(sizeof(ContinueStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; return ret; } -ReturnStmtNode *ReturnStmtNode::alloc(S32 lineNumber, ExprNode *expr) +ReturnStmtNode* ReturnStmtNode::alloc(S32 lineNumber, ExprNode* expr) { - ReturnStmtNode *ret = (ReturnStmtNode *)consoleAlloc(sizeof(ReturnStmtNode)); + ReturnStmtNode* ret = (ReturnStmtNode*)consoleAlloc(sizeof(ReturnStmtNode)); constructInPlace(ret); ret->expr = expr; ret->dbgLineNumber = lineNumber; @@ -64,9 +63,9 @@ ReturnStmtNode *ReturnStmtNode::alloc(S32 lineNumber, ExprNode *expr) return ret; } -IfStmtNode *IfStmtNode::alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagate) +IfStmtNode* IfStmtNode::alloc(S32 lineNumber, ExprNode* testExpr, StmtNode* ifBlock, StmtNode* elseBlock, bool propagate) { - IfStmtNode *ret = (IfStmtNode *)consoleAlloc(sizeof(IfStmtNode)); + IfStmtNode* ret = (IfStmtNode*)consoleAlloc(sizeof(IfStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; @@ -78,9 +77,9 @@ IfStmtNode *IfStmtNode::alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBl return ret; } -LoopStmtNode *LoopStmtNode::alloc(S32 lineNumber, ExprNode *initExpr, ExprNode *testExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop) +LoopStmtNode* LoopStmtNode::alloc(S32 lineNumber, ExprNode* initExpr, ExprNode* testExpr, ExprNode* endLoopExpr, StmtNode* loopBlock, bool isDoLoop) { - LoopStmtNode *ret = (LoopStmtNode *)consoleAlloc(sizeof(LoopStmtNode)); + LoopStmtNode* ret = (LoopStmtNode*)consoleAlloc(sizeof(LoopStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; ret->testExpr = testExpr; @@ -111,11 +110,12 @@ IterStmtNode* IterStmtNode::alloc(S32 lineNumber, StringTableEntry varName, Expr return ret; } -FloatBinaryExprNode *FloatBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right) +FloatBinaryExprNode* FloatBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right) { - FloatBinaryExprNode *ret = (FloatBinaryExprNode *)consoleAlloc(sizeof(FloatBinaryExprNode)); + FloatBinaryExprNode* ret = (FloatBinaryExprNode*)consoleAlloc(sizeof(FloatBinaryExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->op = op; ret->left = left; @@ -124,11 +124,12 @@ FloatBinaryExprNode *FloatBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode return ret; } -IntBinaryExprNode *IntBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right) +IntBinaryExprNode* IntBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right) { - IntBinaryExprNode *ret = (IntBinaryExprNode *)consoleAlloc(sizeof(IntBinaryExprNode)); + IntBinaryExprNode* ret = (IntBinaryExprNode*)consoleAlloc(sizeof(IntBinaryExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->op = op; ret->left = left; @@ -137,11 +138,12 @@ IntBinaryExprNode *IntBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *le return ret; } -StreqExprNode *StreqExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right, bool eq) +StreqExprNode* StreqExprNode::alloc(S32 lineNumber, ExprNode* left, ExprNode* right, bool eq) { - StreqExprNode *ret = (StreqExprNode *)consoleAlloc(sizeof(StreqExprNode)); + StreqExprNode* ret = (StreqExprNode*)consoleAlloc(sizeof(StreqExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->left = left; ret->right = right; ret->eq = eq; @@ -149,11 +151,12 @@ StreqExprNode *StreqExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *ri return ret; } -StrcatExprNode *StrcatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar) +StrcatExprNode* StrcatExprNode::alloc(S32 lineNumber, ExprNode* left, ExprNode* right, int appendChar) { - StrcatExprNode *ret = (StrcatExprNode *)consoleAlloc(sizeof(StrcatExprNode)); + StrcatExprNode* ret = (StrcatExprNode*)consoleAlloc(sizeof(StrcatExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->left = left; ret->right = right; ret->appendChar = appendChar; @@ -161,61 +164,67 @@ StrcatExprNode *StrcatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode * return ret; } -CommaCatExprNode *CommaCatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right) +CommaCatExprNode* CommaCatExprNode::alloc(S32 lineNumber, ExprNode* left, ExprNode* right) { - CommaCatExprNode *ret = (CommaCatExprNode *)consoleAlloc(sizeof(CommaCatExprNode)); + CommaCatExprNode* ret = (CommaCatExprNode*)consoleAlloc(sizeof(CommaCatExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->left = left; ret->right = right; return ret; } -IntUnaryExprNode *IntUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *expr) +IntUnaryExprNode* IntUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode* expr) { - IntUnaryExprNode *ret = (IntUnaryExprNode *)consoleAlloc(sizeof(IntUnaryExprNode)); + IntUnaryExprNode* ret = (IntUnaryExprNode*)consoleAlloc(sizeof(IntUnaryExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->op = op; ret->expr = expr; return ret; } -FloatUnaryExprNode *FloatUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *expr) +FloatUnaryExprNode* FloatUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode* expr) { - FloatUnaryExprNode *ret = (FloatUnaryExprNode *)consoleAlloc(sizeof(FloatUnaryExprNode)); + FloatUnaryExprNode* ret = (FloatUnaryExprNode*)consoleAlloc(sizeof(FloatUnaryExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->op = op; ret->expr = expr; return ret; } -VarNode *VarNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex) +VarNode* VarNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex) { - VarNode *ret = (VarNode *)consoleAlloc(sizeof(VarNode)); + VarNode* ret = (VarNode*)consoleAlloc(sizeof(VarNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->varName = varName; ret->arrayIndex = arrayIndex; return ret; } -IntNode *IntNode::alloc(S32 lineNumber, S32 value) +IntNode* IntNode::alloc(S32 lineNumber, S32 value) { - IntNode *ret = (IntNode *)consoleAlloc(sizeof(IntNode)); + IntNode* ret = (IntNode*)consoleAlloc(sizeof(IntNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->value = value; return ret; } -ConditionalExprNode *ConditionalExprNode::alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr) +ConditionalExprNode* ConditionalExprNode::alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* trueExpr, ExprNode* falseExpr) { - ConditionalExprNode *ret = (ConditionalExprNode *)consoleAlloc(sizeof(ConditionalExprNode)); + ConditionalExprNode* ret = (ConditionalExprNode*)consoleAlloc(sizeof(ConditionalExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->testExpr = testExpr; ret->trueExpr = trueExpr; ret->falseExpr = falseExpr; @@ -223,44 +232,50 @@ ConditionalExprNode *ConditionalExprNode::alloc(S32 lineNumber, ExprNode *testEx return ret; } -FloatNode *FloatNode::alloc(S32 lineNumber, F64 value) +FloatNode* FloatNode::alloc(S32 lineNumber, F64 value) { - FloatNode *ret = (FloatNode *)consoleAlloc(sizeof(FloatNode)); + FloatNode* ret = (FloatNode*)consoleAlloc(sizeof(FloatNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->value = value; return ret; } -StrConstNode *StrConstNode::alloc(S32 lineNumber, char *str, bool tag, bool doc) +StrConstNode* StrConstNode::alloc(S32 lineNumber, char* str, bool tag, bool doc) { - StrConstNode *ret = (StrConstNode *)consoleAlloc(sizeof(StrConstNode)); + StrConstNode* ret = (StrConstNode*)consoleAlloc(sizeof(StrConstNode)); constructInPlace(ret); + S32 len = dStrlen(str); + ret->dbgLineNumber = lineNumber; - dsize_t retStrLen = dStrlen(str) + 1; - ret->str = (char *)consoleAlloc(retStrLen); + ret->optimizedNode = NULL; + ret->str = (char*)consoleAlloc(len + 1); ret->tag = tag; ret->doc = doc; - dStrcpy(ret->str, str, retStrLen); + dStrcpy(ret->str, str, len + 1); + ret->str[len] = '\0'; return ret; } -ConstantNode *ConstantNode::alloc(S32 lineNumber, StringTableEntry value) +ConstantNode* ConstantNode::alloc(S32 lineNumber, StringTableEntry value) { - ConstantNode *ret = (ConstantNode *)consoleAlloc(sizeof(ConstantNode)); + ConstantNode* ret = (ConstantNode*)consoleAlloc(sizeof(ConstantNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->value = value; return ret; } -AssignExprNode *AssignExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr) +AssignExprNode* AssignExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr) { - AssignExprNode *ret = (AssignExprNode *)consoleAlloc(sizeof(AssignExprNode)); + AssignExprNode* ret = (AssignExprNode*)consoleAlloc(sizeof(AssignExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->varName = varName; ret->expr = expr; ret->arrayIndex = arrayIndex; @@ -268,11 +283,12 @@ AssignExprNode *AssignExprNode::alloc(S32 lineNumber, StringTableEntry varName, return ret; } -AssignOpExprNode *AssignOpExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op) +AssignOpExprNode* AssignOpExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr, S32 op) { - AssignOpExprNode *ret = (AssignOpExprNode *)consoleAlloc(sizeof(AssignOpExprNode)); + AssignOpExprNode* ret = (AssignOpExprNode*)consoleAlloc(sizeof(AssignOpExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->varName = varName; ret->expr = expr; ret->arrayIndex = arrayIndex; @@ -280,9 +296,9 @@ AssignOpExprNode *AssignOpExprNode::alloc(S32 lineNumber, StringTableEntry varNa return ret; } -TTagSetStmtNode *TTagSetStmtNode::alloc(S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr) +TTagSetStmtNode* TTagSetStmtNode::alloc(S32 lineNumber, StringTableEntry tag, ExprNode* valueExpr, ExprNode* stringExpr) { - TTagSetStmtNode *ret = (TTagSetStmtNode *)consoleAlloc(sizeof(TTagSetStmtNode)); + TTagSetStmtNode* ret = (TTagSetStmtNode*)consoleAlloc(sizeof(TTagSetStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; ret->tag = tag; @@ -291,59 +307,54 @@ TTagSetStmtNode *TTagSetStmtNode::alloc(S32 lineNumber, StringTableEntry tag, Ex return ret; } -TTagDerefNode *TTagDerefNode::alloc(S32 lineNumber, ExprNode *expr) +TTagDerefNode* TTagDerefNode::alloc(S32 lineNumber, ExprNode* expr) { - TTagDerefNode *ret = (TTagDerefNode *)consoleAlloc(sizeof(TTagDerefNode)); + TTagDerefNode* ret = (TTagDerefNode*)consoleAlloc(sizeof(TTagDerefNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->expr = expr; return ret; } -TTagExprNode *TTagExprNode::alloc(S32 lineNumber, StringTableEntry tag) +TTagExprNode* TTagExprNode::alloc(S32 lineNumber, StringTableEntry tag) { - TTagExprNode *ret = (TTagExprNode *)consoleAlloc(sizeof(TTagExprNode)); + TTagExprNode* ret = (TTagExprNode*)consoleAlloc(sizeof(TTagExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->tag = tag; return ret; } -FuncCallExprNode *FuncCallExprNode::alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot) +FuncCallExprNode* FuncCallExprNode::alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode* args, bool dot) { - FuncCallExprNode *ret = (FuncCallExprNode *)consoleAlloc(sizeof(FuncCallExprNode)); + FuncCallExprNode* ret = (FuncCallExprNode*)consoleAlloc(sizeof(FuncCallExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->funcName = funcName; ret->nameSpace = nameSpace; ret->args = args; if (dot) ret->callType = MethodCall; - else + else if (nameSpace != NULL) { - if (nameSpace && !dStricmp(nameSpace, "Parent")) + if (dStricmp(nameSpace, "Parent") == 0) ret->callType = ParentCall; else - ret->callType = FunctionCall; + ret->callType = StaticCall; } + else + ret->callType = FunctionCall; return ret; } -FuncPointerCallExprNode *FuncPointerCallExprNode::alloc(S32 lineNumber, ExprNode *funcPointer, ExprNode *args) +AssertCallExprNode* AssertCallExprNode::alloc(S32 lineNumber, ExprNode* testExpr, const char* message) { - FuncPointerCallExprNode *ret = (FuncPointerCallExprNode *)consoleAlloc(sizeof(FuncPointerCallExprNode)); - constructInPlace(ret); - ret->dbgLineNumber = lineNumber; - ret->funcPointer = funcPointer; - ret->args = args; - return ret; -} +#ifdef TORQUE_ENABLE_SCRIPTASSERTS -AssertCallExprNode *AssertCallExprNode::alloc(S32 lineNumber, ExprNode *testExpr, const char *message) -{ -#ifdef TORQUE_ENABLE_SCRIPTASSERTS - - AssertCallExprNode *ret = (AssertCallExprNode *)consoleAlloc(sizeof(FuncCallExprNode)); + AssertCallExprNode* ret = (AssertCallExprNode*)consoleAlloc(sizeof(FuncCallExprNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; ret->testExpr = testExpr; @@ -357,10 +368,11 @@ AssertCallExprNode *AssertCallExprNode::alloc(S32 lineNumber, ExprNode *testExpr #endif } -SlotAccessNode *SlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName) +SlotAccessNode* SlotAccessNode::alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName) { - SlotAccessNode *ret = (SlotAccessNode *)consoleAlloc(sizeof(SlotAccessNode)); + SlotAccessNode* ret = (SlotAccessNode*)consoleAlloc(sizeof(SlotAccessNode)); constructInPlace(ret); + ret->optimizedNode = NULL; ret->dbgLineNumber = lineNumber; ret->objectExpr = objectExpr; ret->arrayExpr = arrayExpr; @@ -368,22 +380,24 @@ SlotAccessNode *SlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, Expr return ret; } -InternalSlotAccessNode *InternalSlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse) +InternalSlotAccessNode* InternalSlotAccessNode::alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* slotExpr, bool recurse) { - InternalSlotAccessNode *ret = (InternalSlotAccessNode *)consoleAlloc(sizeof(InternalSlotAccessNode)); + InternalSlotAccessNode* ret = (InternalSlotAccessNode*)consoleAlloc(sizeof(InternalSlotAccessNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->objectExpr = objectExpr; ret->slotExpr = slotExpr; ret->recurse = recurse; return ret; } -SlotAssignNode *SlotAssignNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID /* = -1 */) +SlotAssignNode* SlotAssignNode::alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName, ExprNode* valueExpr, U32 typeID /* = -1 */) { - SlotAssignNode *ret = (SlotAssignNode *)consoleAlloc(sizeof(SlotAssignNode)); + SlotAssignNode* ret = (SlotAssignNode*)consoleAlloc(sizeof(SlotAssignNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->objectExpr = objectExpr; ret->arrayExpr = arrayExpr; ret->slotName = slotName; @@ -392,11 +406,12 @@ SlotAssignNode *SlotAssignNode::alloc(S32 lineNumber, ExprNode *objectExpr, Expr return ret; } -SlotAssignOpNode *SlotAssignOpNode::alloc(S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr) +SlotAssignOpNode* SlotAssignOpNode::alloc(S32 lineNumber, ExprNode* objectExpr, StringTableEntry slotName, ExprNode* arrayExpr, S32 op, ExprNode* valueExpr) { - SlotAssignOpNode *ret = (SlotAssignOpNode *)consoleAlloc(sizeof(SlotAssignOpNode)); + SlotAssignOpNode* ret = (SlotAssignOpNode*)consoleAlloc(sizeof(SlotAssignOpNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->objectExpr = objectExpr; ret->arrayExpr = arrayExpr; ret->slotName = slotName; @@ -405,11 +420,12 @@ SlotAssignOpNode *SlotAssignOpNode::alloc(S32 lineNumber, ExprNode *objectExpr, return ret; } -ObjectDeclNode *ObjectDeclNode::alloc(S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton) +ObjectDeclNode* ObjectDeclNode::alloc(S32 lineNumber, ExprNode* classNameExpr, ExprNode* objectNameExpr, ExprNode* argList, StringTableEntry parentObject, SlotAssignNode* slotDecls, ObjectDeclNode* subObjects, bool isDatablock, bool classNameInternal, bool isSingleton) { - ObjectDeclNode *ret = (ObjectDeclNode *)consoleAlloc(sizeof(ObjectDeclNode)); + ObjectDeclNode* ret = (ObjectDeclNode*)consoleAlloc(sizeof(ObjectDeclNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; + ret->optimizedNode = NULL; ret->classNameExpr = classNameExpr; ret->objectNameExpr = objectNameExpr; ret->argList = argList; @@ -422,13 +438,13 @@ ObjectDeclNode *ObjectDeclNode::alloc(S32 lineNumber, ExprNode *classNameExpr, E if (parentObject) ret->parentObject = parentObject; else - ret->parentObject = StringTable->EmptyString(); + ret->parentObject = StringTable->insert(""); return ret; } -FunctionDeclStmtNode *FunctionDeclStmtNode::alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts) +FunctionDeclStmtNode* FunctionDeclStmtNode::alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode* args, StmtNode* stmts) { - FunctionDeclStmtNode *ret = (FunctionDeclStmtNode *)consoleAlloc(sizeof(FunctionDeclStmtNode)); + FunctionDeclStmtNode* ret = (FunctionDeclStmtNode*)consoleAlloc(sizeof(FunctionDeclStmtNode)); constructInPlace(ret); ret->dbgLineNumber = lineNumber; ret->fnName = fnName; diff --git a/Engine/source/console/astNodes.cpp b/Engine/source/console/astNodes.cpp index 51bde9d61..091f6cf1c 100644 --- a/Engine/source/console/astNodes.cpp +++ b/Engine/source/console/astNodes.cpp @@ -44,94 +44,80 @@ struct Token namespace Compiler { - U32 compileBlock(StmtNode *block, CodeStream &codeStream, U32 ip) + U32 compileBlock(StmtNode* block, CodeStream& codeStream, U32 ip) { - for (StmtNode *walk = block; walk; walk = walk->getNext()) + for (StmtNode* walk = block; walk; walk = walk->getNext()) + { ip = walk->compileStmt(codeStream, ip); + } return codeStream.tell(); } - - inline bool isSimpleVarLookup(ExprNode *arrayExpr, StringTableEntry &varName) - { - if (arrayExpr == nullptr) - { - varName = StringTable->insert(""); - return false; - } - - // No double arrays allowed for optimization. - VarNode *var = dynamic_cast(arrayExpr); - if (var && !var->arrayIndex) - { - StringTableEntry arrayVar = StringTable->insert(var->varName); - precompileIdent(arrayVar); - varName = arrayVar; - return true; - } - return false; - } - - // Do not allow 'recursive' %this optimizations. It can lead to weird bytecode - // generation since we can only optimize one expression at a time. - static bool OnlyOneThisOptimization = false; - - inline bool isThisVar(ExprNode *objectExpr) - { - // If we are currently optimizing a this var, don't allow extra optimization. - if (objectExpr == nullptr || OnlyOneThisOptimization) - return false; - - VarNode *thisVar = dynamic_cast(objectExpr); - if (thisVar && thisVar->varName == StringTable->insert("%this")) - return true; - return false; - } - - inline void optimizeThisPointer(CodeStream &codeStream, ExprNode *arrayExpr, U32 &ip, StringTableEntry slotName) - { - OnlyOneThisOptimization = true; - - // Is the array a simple variable? If so, we can optimize that. - StringTableEntry varName = nullptr; - bool simple = false; - - if (arrayExpr) - { - simple = isSimpleVarLookup(arrayExpr, varName); - if (!simple) - { - // Less optimized array setting. - codeStream.emit(OP_ADVANCE_STR); - ip = arrayExpr->compile(codeStream, ip, TypeReqString); - } - } - - codeStream.emit(OP_SETCURFIELD_THIS); - codeStream.emitSTE(slotName); - - if (arrayExpr) - { - if (simple) - { - codeStream.emit(OP_SETCURFIELD_ARRAY_VAR); - codeStream.emitSTE(varName); - } - else - { - codeStream.emit(OP_SETCURFIELD_ARRAY); - codeStream.emit(OP_TERMINATE_REWIND_STR); - } - } - - OnlyOneThisOptimization = false; - } } using namespace Compiler; +class FuncVars +{ + struct Var + { + S32 reg; + TypeReq currentType; + StringTableEntry name; + bool isConstant; + }; + +public: + S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false) + { + std::unordered_map::iterator found = vars.find(var); + if (found != vars.end()) + { + AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber)); + return found->second.reg; + } + + S32 id = counter++; + vars[var] = { id, currentType, var, isConstant }; + variableNameMap[id] = var; + + return id; + } + + S32 lookup(StringTableEntry var, S32 lineNumber) + { + std::unordered_map::iterator found = vars.find(var); + AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber)); + return found->second.reg; + } + + TypeReq lookupType(StringTableEntry var, S32 lineNumber) + { + std::unordered_map::iterator found = vars.find(var); + + AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber)); + return found->second.currentType; + } + + inline S32 count() { return counter; } + + std::unordered_map variableNameMap; + +private: + std::unordered_map vars; + S32 counter = 0; +}; + +FuncVars* gFuncVars = NULL; + +inline FuncVars* getFuncVars(S32 lineNumber) +{ + AssertISV(gFuncVars, avar("Attemping to use local variable in global scope. File: %s Line: %d", CodeBlock::smCurrentParser->getCurrentFile(), lineNumber)); + return gFuncVars; +} + //----------------------------------------------------------------------------- -void StmtNode::addBreakLine(CodeStream &code) +void StmtNode::addBreakLine(CodeStream& code) { code.addBreakLine(dbgLineNumber, code.tell()); } @@ -140,21 +126,20 @@ void StmtNode::addBreakLine(CodeStream &code) StmtNode::StmtNode() { - mNext = NULL; + next = NULL; dbgFileName = CodeBlock::smCurrentParser->getCurrentFile(); - dbgLineNumber = 0; } void StmtNode::setPackage(StringTableEntry) { } -void StmtNode::append(StmtNode *next) +void StmtNode::append(StmtNode* next) { - StmtNode *walk = this; - while (walk->mNext) - walk = walk->mNext; - walk->mNext = next; + StmtNode* walk = this; + while (walk->next) + walk = walk->next; + walk->next = next; } @@ -169,78 +154,7 @@ void FunctionDeclStmtNode::setPackage(StringTableEntry packageName) // //------------------------------------------------------------ -static U32 conversionOp(TypeReq src, TypeReq dst) -{ - if (src == TypeReqString) - { - switch (dst) - { - case TypeReqUInt: - return OP_STR_TO_UINT; - case TypeReqFloat: - return OP_STR_TO_FLT; - case TypeReqNone: - return OP_STR_TO_NONE; - case TypeReqVar: - return OP_SAVEVAR_STR; - default: - break; - } - } - else if (src == TypeReqFloat) - { - switch (dst) - { - case TypeReqUInt: - return OP_FLT_TO_UINT; - case TypeReqString: - return OP_FLT_TO_STR; - case TypeReqNone: - return OP_FLT_TO_NONE; - case TypeReqVar: - return OP_SAVEVAR_FLT; - default: - break; - } - } - else if (src == TypeReqUInt) - { - switch (dst) - { - case TypeReqFloat: - return OP_UINT_TO_FLT; - case TypeReqString: - return OP_UINT_TO_STR; - case TypeReqNone: - return OP_UINT_TO_NONE; - case TypeReqVar: - return OP_SAVEVAR_UINT; - default: - break; - } - } - else if (src == TypeReqVar) - { - switch (dst) - { - case TypeReqUInt: - return OP_LOADVAR_UINT; - case TypeReqFloat: - return OP_LOADVAR_FLT; - case TypeReqString: - return OP_LOADVAR_STR; - case TypeReqNone: - return OP_COPYVAR_TO_NONE; - default: - break; - } - } - return OP_INVALID; -} - -//------------------------------------------------------------ - -U32 BreakStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 BreakStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { if (codeStream.inLoop()) { @@ -257,7 +171,7 @@ U32 BreakStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 ContinueStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 ContinueStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { if (codeStream.inLoop()) { @@ -274,7 +188,7 @@ U32 ContinueStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 ExprNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 ExprNode::compileStmt(CodeStream& codeStream, U32 ip) { addBreakLine(codeStream); return compile(codeStream, ip, TypeReqNone); @@ -282,7 +196,7 @@ U32 ExprNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 ReturnStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 ReturnStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { addBreakLine(codeStream); if (!expr) @@ -295,15 +209,15 @@ U32 ReturnStmtNode::compileStmt(CodeStream &codeStream, U32 ip) // Return the correct type switch (walkType) { - case TypeReqUInt: - codeStream.emit(OP_RETURN_UINT); - break; - case TypeReqFloat: - codeStream.emit(OP_RETURN_FLT); - break; - default: - codeStream.emit(OP_RETURN); - break; + case TypeReqUInt: + codeStream.emit(OP_RETURN_UINT); + break; + case TypeReqFloat: + codeStream.emit(OP_RETURN_FLT); + break; + default: + codeStream.emit(OP_RETURN); + break; } } return codeStream.tell(); @@ -311,10 +225,10 @@ U32 ReturnStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -ExprNode *IfStmtNode::getSwitchOR(ExprNode *left, ExprNode *list, bool string) +ExprNode* IfStmtNode::getSwitchOR(ExprNode* left, ExprNode* list, bool string) { - ExprNode *nextExpr = (ExprNode *)list->getNext(); - ExprNode *test; + ExprNode* nextExpr = (ExprNode*)list->getNext(); + ExprNode* test; if (string) test = StreqExprNode::alloc(left->dbgLineNumber, left, list, true); else @@ -324,14 +238,14 @@ ExprNode *IfStmtNode::getSwitchOR(ExprNode *left, ExprNode *list, bool string) return IntBinaryExprNode::alloc(test->dbgLineNumber, opOR, test, getSwitchOR(left, nextExpr, string)); } -void IfStmtNode::propagateSwitchExpr(ExprNode *left, bool string) +void IfStmtNode::propagateSwitchExpr(ExprNode* left, bool string) { testExpr = getSwitchOR(left, testExpr, string); if (propagate && elseBlock) - ((IfStmtNode *)elseBlock)->propagateSwitchExpr(left, string); + ((IfStmtNode*)elseBlock)->propagateSwitchExpr(left, string); } -U32 IfStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { U32 endifIp, elseIp; addBreakLine(codeStream); @@ -373,7 +287,7 @@ U32 IfStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 LoopStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 LoopStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { if (testExpr->getPreferredType() == TypeReqUInt) { @@ -446,7 +360,7 @@ U32 LoopStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 IterStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 IterStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { // Instruction sequence: // @@ -464,11 +378,18 @@ U32 IterStmtNode::compileStmt(CodeStream &codeStream, U32 ip) codeStream.pushFixScope(true); + bool isGlobal = varName[0] == '$'; + TypeReq varType = isStringIter ? TypeReqString : TypeReqUInt; + const U32 startIp = ip; containerExpr->compile(codeStream, startIp, TypeReqString); codeStream.emit(isStringIter ? OP_ITER_BEGIN_STR : OP_ITER_BEGIN); - codeStream.emitSTE(varName); + codeStream.emit(isGlobal); + if (isGlobal) + codeStream.emitSTE(varName); + else + codeStream.emit(getFuncVars(dbgLineNumber)->assign(varName, varType, dbgLineNumber)); const U32 finalFix = codeStream.emit(0); const U32 continueIp = codeStream.emit(OP_ITER); codeStream.emitFix(CodeStream::FIXTYPE_BREAK); @@ -491,7 +412,7 @@ U32 IterStmtNode::compileStmt(CodeStream &codeStream, U32 ip) //------------------------------------------------------------ -U32 ConditionalExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 ConditionalExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // code is testExpr // JMPIFNOT falseStart @@ -528,29 +449,33 @@ TypeReq ConditionalExprNode::getPreferredType() //------------------------------------------------------------ -U32 FloatBinaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 FloatBinaryExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { + if (optimize()) + { + ip = optimizedNode->compile(codeStream, ip, type); + return codeStream.tell(); + } + ip = right->compile(codeStream, ip, TypeReqFloat); ip = left->compile(codeStream, ip, TypeReqFloat); U32 operand = OP_INVALID; switch (op) { - case '+': - operand = OP_ADD; - break; - case '-': - operand = OP_SUB; - break; - case '/': - operand = OP_DIV; - break; - case '*': - operand = OP_MUL; - break; + case '+': + operand = OP_ADD; + break; + case '-': + operand = OP_SUB; + break; + case '/': + operand = OP_DIV; + break; + case '*': + operand = OP_MUL; + break; } codeStream.emit(operand); - if (type != TypeReqFloat) - codeStream.emit(conversionOp(TypeReqFloat, type)); return codeStream.tell(); } @@ -566,59 +491,62 @@ void IntBinaryExprNode::getSubTypeOperand() subType = TypeReqUInt; switch (op) { - case '^': - operand = OP_XOR; - break; - case '%': - operand = OP_MOD; - break; - case '&': - operand = OP_BITAND; - break; - case '|': - operand = OP_BITOR; - break; - case '<': - operand = OP_CMPLT; - subType = TypeReqFloat; - break; - case '>': - operand = OP_CMPGR; - subType = TypeReqFloat; - break; - case opGE: - operand = OP_CMPGE; - subType = TypeReqFloat; - break; - case opLE: - operand = OP_CMPLE; - subType = TypeReqFloat; - break; - case opEQ: - operand = OP_CMPEQ; - subType = TypeReqFloat; - break; - case opNE: - operand = OP_CMPNE; - subType = TypeReqFloat; - break; - case opOR: - operand = OP_OR; - break; - case opAND: - operand = OP_AND; - break; - case opSHR: - operand = OP_SHR; - break; - case opSHL: - operand = OP_SHL; - break; + case '^': + operand = OP_XOR; + break; + case '%': + operand = OP_MOD; + break; + case '&': + operand = OP_BITAND; + break; + case '|': + operand = OP_BITOR; + break; + case '<': + operand = OP_CMPLT; + subType = TypeReqFloat; + break; + case '>': + operand = OP_CMPGR; + subType = TypeReqFloat; + break; + case opGE: + operand = OP_CMPGE; + subType = TypeReqFloat; + break; + case opLE: + operand = OP_CMPLE; + subType = TypeReqFloat; + break; + case opEQ: + operand = OP_CMPEQ; + subType = TypeReqFloat; + break; + case opNE: + operand = OP_CMPNE; + subType = TypeReqFloat; + break; + case opOR: + operand = OP_OR; + break; + case opAND: + operand = OP_AND; + break; + case opSHR: + operand = OP_SHR; + break; + case opSHL: + operand = OP_SHL; + break; } } -U32 IntBinaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 IntBinaryExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { + if (optimize()) + right = optimizedNode; + getSubTypeOperand(); if (operand == OP_OR || operand == OP_AND) @@ -635,8 +563,6 @@ U32 IntBinaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) ip = left->compile(codeStream, ip, subType); codeStream.emit(operand); } - if (type != TypeReqUInt) - codeStream.emit(conversionOp(TypeReqUInt, type)); return codeStream.tell(); } @@ -647,7 +573,7 @@ TypeReq IntBinaryExprNode::getPreferredType() //------------------------------------------------------------ -U32 StreqExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 StreqExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // eval str left // OP_ADVANCE_STR_NUL @@ -656,13 +582,10 @@ U32 StreqExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) // optional conversion ip = left->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_ADVANCE_STR_NUL); ip = right->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_COMPARE_STR); if (!eq) codeStream.emit(OP_NOT); - if (type != TypeReqUInt) - codeStream.emit(conversionOp(TypeReqUInt, type)); return codeStream.tell(); } @@ -673,22 +596,16 @@ TypeReq StreqExprNode::getPreferredType() //------------------------------------------------------------ -U32 StrcatExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 StrcatExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { ip = left->compile(codeStream, ip, TypeReqString); - if (!appendChar) - codeStream.emit(OP_ADVANCE_STR); - else + if (appendChar) { codeStream.emit(OP_ADVANCE_STR_APPENDCHAR); codeStream.emit(appendChar); } ip = right->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_REWIND_STR); - if (type == TypeReqUInt) - codeStream.emit(OP_STR_TO_UINT); - else if (type == TypeReqFloat) - codeStream.emit(OP_STR_TO_FLT); return codeStream.tell(); } @@ -699,10 +616,11 @@ TypeReq StrcatExprNode::getPreferredType() //------------------------------------------------------------ -U32 CommaCatExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 CommaCatExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { ip = left->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_ADVANCE_STR_COMMA); + codeStream.emit(OP_ADVANCE_STR_APPENDCHAR); + codeStream.emit('_'); ip = right->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_REWIND_STR); @@ -711,10 +629,7 @@ U32 CommaCatExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) // But we're paranoid, so accept (but whine) if we get an oddity... if (type == TypeReqUInt || type == TypeReqFloat) Con::warnf(ConsoleLogEntry::General, "%s (%d): converting comma string to a number... probably wrong.", dbgFileName, dbgLineNumber); - if (type == TypeReqUInt) - codeStream.emit(OP_STR_TO_UINT); - else if (type == TypeReqFloat) - codeStream.emit(OP_STR_TO_FLT); + return codeStream.tell(); } @@ -725,7 +640,7 @@ TypeReq CommaCatExprNode::getPreferredType() //------------------------------------------------------------ -U32 IntUnaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 IntUnaryExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { integer = true; TypeReq prefType = expr->getPreferredType(); @@ -737,8 +652,7 @@ U32 IntUnaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) codeStream.emit(integer ? OP_NOT : OP_NOTF); else if (op == '~') codeStream.emit(OP_ONESCOMPLEMENT); - if (type != TypeReqUInt) - codeStream.emit(conversionOp(TypeReqUInt, type)); + return codeStream.tell(); } @@ -749,12 +663,11 @@ TypeReq IntUnaryExprNode::getPreferredType() //------------------------------------------------------------ -U32 FloatUnaryExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 FloatUnaryExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { ip = expr->compile(codeStream, ip, TypeReqFloat); codeStream.emit(OP_NEG); - if (type != TypeReqFloat) - codeStream.emit(conversionOp(TypeReqFloat, type)); + return codeStream.tell(); } @@ -765,22 +678,16 @@ TypeReq FloatUnaryExprNode::getPreferredType() //------------------------------------------------------------ -U32 VarNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 VarNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { - // if this has an arrayIndex and we are not short circuiting from a constant. - // if we are a var node - // OP_SETCURVAR_ARRAY_VARLOOKUP - // varName - // varNodeVarName - - // else - // OP_LOADIMMED_IDENT - // varName - // OP_ADVANCE_STR - // evaluate arrayIndex TypeReqString - // OP_REWIND_STR - // OP_SETCURVAR_ARRAY - // OP_LOADVAR (type) + // if this has an arrayIndex... + // OP_LOADIMMED_IDENT + // varName + // OP_ADVANCE_STR + // evaluate arrayIndex TypeReqString + // OP_REWIND_STR + // OP_SETCURVAR_ARRAY + // OP_LOADVAR (type) // else // OP_SETCURVAR @@ -790,56 +697,25 @@ U32 VarNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) if (type == TypeReqNone) return codeStream.tell(); - bool shortCircuit = false; - if (arrayIndex) - { - // If we have a constant, shortcircuit the array logic. - - IntNode *intNode = dynamic_cast(arrayIndex); - StrConstNode *strNode = dynamic_cast(arrayIndex); - if (intNode) - { - varName = StringTable->insert(avar("%s%d", varName, intNode->value)); - shortCircuit = true; - } - else if (strNode) - { - varName = StringTable->insert(avar("%s%s", varName, strNode->str)); - shortCircuit = true; - } - } - precompileIdent(varName); - if (arrayIndex && !shortCircuit) + bool oldVariables = arrayIndex || varName[0] == '$'; + + if (oldVariables) { - // Ok, lets try to optimize %var[%someothervar] as this is - // a common case for array usage. - StringTableEntry varNodeVarName; - if (isSimpleVarLookup(arrayIndex, varNodeVarName)) + codeStream.emit(arrayIndex ? OP_LOADIMMED_IDENT : OP_SETCURVAR); + codeStream.emitSTE(varName); + + if (arrayIndex) { - codeStream.emit(OP_SETCURVAR_ARRAY_VARLOOKUP); - codeStream.emitSTE(varName); - codeStream.emitSTE(varNodeVarName); - } - else - { - codeStream.emit(OP_LOADIMMED_IDENT); - codeStream.emitSTE(varName); - codeStream.emit(OP_ADVANCE_STR); + //codeStream.emit(OP_ADVANCE_STR); ip = arrayIndex->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_REWIND_STR); codeStream.emit(OP_SETCURVAR_ARRAY); + codeStream.emit(OP_POP_STK); } - } - else - { - codeStream.emit(OP_SETCURVAR); - codeStream.emitSTE(varName); - } - - switch (type) - { + switch (type) + { case TypeReqUInt: codeStream.emit(OP_LOADVAR_UINT); break; @@ -849,25 +725,36 @@ U32 VarNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) case TypeReqString: codeStream.emit(OP_LOADVAR_STR); break; - case TypeReqVar: - codeStream.emit(OP_LOADVAR_VAR); - break; case TypeReqNone: break; default: break; + } } + else + { + switch (type) + { + case TypeReqUInt: codeStream.emit(OP_LOAD_LOCAL_VAR_UINT); break; + case TypeReqFloat: codeStream.emit(OP_LOAD_LOCAL_VAR_FLT); break; + default: codeStream.emit(OP_LOAD_LOCAL_VAR_STR); + } + + codeStream.emit(getFuncVars(dbgLineNumber)->lookup(varName, dbgLineNumber)); + } + return codeStream.tell(); } TypeReq VarNode::getPreferredType() { - return TypeReqNone; // no preferred type + bool oldVariables = arrayIndex || varName[0] == '$'; + return oldVariables ? TypeReqNone : getFuncVars(dbgLineNumber)->lookupType(varName, dbgLineNumber); } //------------------------------------------------------------ -U32 IntNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 IntNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { if (type == TypeReqString) index = getCurrentStringTable()->addIntString(value); @@ -876,20 +763,20 @@ U32 IntNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) switch (type) { - case TypeReqUInt: - codeStream.emit(OP_LOADIMMED_UINT); - codeStream.emit(value); - break; - case TypeReqString: - codeStream.emit(OP_LOADIMMED_STR); - codeStream.emit(index); - break; - case TypeReqFloat: - codeStream.emit(OP_LOADIMMED_FLT); - codeStream.emit(index); - break; - case TypeReqNone: - break; + case TypeReqUInt: + codeStream.emit(OP_LOADIMMED_UINT); + codeStream.emit(value); + break; + case TypeReqString: + codeStream.emit(OP_LOADIMMED_STR); + codeStream.emit(index); + break; + case TypeReqFloat: + codeStream.emit(OP_LOADIMMED_FLT); + codeStream.emit(index); + break; + case TypeReqNone: + break; } return codeStream.tell(); } @@ -901,7 +788,7 @@ TypeReq IntNode::getPreferredType() //------------------------------------------------------------ -U32 FloatNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 FloatNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { if (type == TypeReqString) index = getCurrentStringTable()->addFloatString(value); @@ -910,20 +797,20 @@ U32 FloatNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) switch (type) { - case TypeReqUInt: - codeStream.emit(OP_LOADIMMED_UINT); - codeStream.emit(U32(value)); - break; - case TypeReqString: - codeStream.emit(OP_LOADIMMED_STR); - codeStream.emit(index); - break; - case TypeReqFloat: - codeStream.emit(OP_LOADIMMED_FLT); - codeStream.emit(index); - break; - case TypeReqNone: - break; + case TypeReqUInt: + codeStream.emit(OP_LOADIMMED_UINT); + codeStream.emit(U32(value)); + break; + case TypeReqString: + codeStream.emit(OP_LOADIMMED_STR); + codeStream.emit(index); + break; + case TypeReqFloat: + codeStream.emit(OP_LOADIMMED_FLT); + codeStream.emit(index); + break; + case TypeReqNone: + break; } return codeStream.tell(); } @@ -935,7 +822,7 @@ TypeReq FloatNode::getPreferredType() //------------------------------------------------------------ -U32 StrConstNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 StrConstNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // Early out for documentation block. if (doc) @@ -966,20 +853,20 @@ U32 StrConstNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) // Otherwise, deal with it normally as a string literal case. switch (type) { - case TypeReqString: - codeStream.emit(tag ? OP_TAG_TO_STR : OP_LOADIMMED_STR); - codeStream.emit(index); - break; - case TypeReqUInt: - codeStream.emit(OP_LOADIMMED_UINT); - codeStream.emit(U32(fVal)); - break; - case TypeReqFloat: - codeStream.emit(OP_LOADIMMED_FLT); - codeStream.emit(index); - break; - case TypeReqNone: - break; + case TypeReqString: + codeStream.emit(tag ? OP_TAG_TO_STR : OP_LOADIMMED_STR); + codeStream.emit(index); + break; + case TypeReqUInt: + codeStream.emit(OP_LOADIMMED_UINT); + codeStream.emit(U32(fVal)); + break; + case TypeReqFloat: + codeStream.emit(OP_LOADIMMED_FLT); + codeStream.emit(index); + break; + case TypeReqNone: + break; } return codeStream.tell(); } @@ -991,7 +878,7 @@ TypeReq StrConstNode::getPreferredType() //------------------------------------------------------------ -U32 ConstantNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 ConstantNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { if (type == TypeReqString) { @@ -1006,20 +893,20 @@ U32 ConstantNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) switch (type) { - case TypeReqString: - codeStream.emit(OP_LOADIMMED_IDENT); - codeStream.emitSTE(value); - break; - case TypeReqUInt: - codeStream.emit(OP_LOADIMMED_UINT); - codeStream.emit(U32(fVal)); - break; - case TypeReqFloat: - codeStream.emit(OP_LOADIMMED_FLT); - codeStream.emit(index); - break; - case TypeReqNone: - break; + case TypeReqString: + codeStream.emit(OP_LOADIMMED_IDENT); + codeStream.emitSTE(value); + break; + case TypeReqUInt: + codeStream.emit(OP_LOADIMMED_UINT); + codeStream.emit(U32(fVal)); + break; + case TypeReqFloat: + codeStream.emit(OP_LOADIMMED_FLT); + codeStream.emit(index); + break; + case TypeReqNone: + break; } return ip; } @@ -1031,49 +918,23 @@ TypeReq ConstantNode::getPreferredType() //------------------------------------------------------------ -U32 AssignExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 AssignExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { subType = expr->getPreferredType(); if (subType == TypeReqNone) subType = type; if (subType == TypeReqNone) - { - // What we need to do in this case is turn it into a VarNode reference. - // Unfortunately other nodes such as field access (SlotAccessNode) - // cannot be optimized in the same manner as all fields are exposed - // and set as strings. - if (dynamic_cast(expr) != NULL) - { - subType = TypeReqVar; - } - else - { - subType = TypeReqString; - } - } + subType = TypeReqString; - //if we are an array index and we are gonna short circuit - // eval expr - // compute new varName - // OP_SETCURVAR_CREATE - // varName - // OP_SAVEVAR - - //else if it's an array expr and we don't short circuit, the formula is: + // if it's an array expr, the formula is: // eval expr // (push and pop if it's TypeReqString) OP_ADVANCE_STR - // if array lookup is varnode - // OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP - // varName - // varNodeVarName - // else - // OP_LOADIMMED_IDENT - // varName - // OP_ADVANCE_STR - // eval array - // OP_REWIND_STR - // OP_SETCURVAR_ARRAY_CREATE - // endif + // OP_LOADIMMED_IDENT + // varName + // OP_ADVANCE_STR + // eval array + // OP_REWIND_STR + // OP_SETCURVAR_ARRAY_CREATE // OP_TERMINATE_REWIND_STR // OP_SAVEVAR @@ -1083,81 +944,54 @@ U32 AssignExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) // varname // OP_SAVEVAR - ip = expr->compile(codeStream, ip, subType); - - bool shortCircuit = false; - if (arrayIndex) - { - // If we have a constant, shortcircuit the array logic. - - IntNode *intNode = dynamic_cast(arrayIndex); - StrConstNode *strNode = dynamic_cast(arrayIndex); - if (intNode) - { - varName = StringTable->insert(avar("%s%d", varName, intNode->value)); - shortCircuit = true; - } - else if (strNode) - { - varName = StringTable->insert(avar("%s%s", varName, strNode->str)); - shortCircuit = true; - } - } - precompileIdent(varName); - if (arrayIndex && !shortCircuit) - { - if (subType == TypeReqString) - codeStream.emit(OP_ADVANCE_STR); + ip = expr->compile(codeStream, ip, subType); - // Ok, lets try to optimize %var[%someothervar] as this is - // a common case for array usage. - StringTableEntry varNodeVarName; - if (isSimpleVarLookup(arrayIndex, varNodeVarName)) - { - codeStream.emit(OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP); - codeStream.emitSTE(varName); - codeStream.emitSTE(varNodeVarName); - } - else + bool oldVariables = arrayIndex || varName[0] == '$'; + + if (oldVariables) + { + if (arrayIndex) { + //if (subType == TypeReqString) + // codeStream.emit(OP_ADVANCE_STR); + codeStream.emit(OP_LOADIMMED_IDENT); codeStream.emitSTE(varName); - codeStream.emit(OP_ADVANCE_STR); + //codeStream.emit(OP_ADVANCE_STR); ip = arrayIndex->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_REWIND_STR); codeStream.emit(OP_SETCURVAR_ARRAY_CREATE); + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); + } + else + { + codeStream.emit(OP_SETCURVAR_CREATE); + codeStream.emitSTE(varName); + } + switch (subType) + { + case TypeReqString: codeStream.emit(OP_SAVEVAR_STR); break; + case TypeReqUInt: codeStream.emit(OP_SAVEVAR_UINT); break; + case TypeReqFloat: codeStream.emit(OP_SAVEVAR_FLT); break; } - - if (subType == TypeReqString) - codeStream.emit(OP_TERMINATE_REWIND_STR); } else { - codeStream.emit(OP_SETCURVAR_CREATE); - codeStream.emitSTE(varName); + switch (subType) + { + case TypeReqUInt: codeStream.emit(OP_SAVE_LOCAL_VAR_UINT); break; + case TypeReqFloat: codeStream.emit(OP_SAVE_LOCAL_VAR_FLT); break; + default: codeStream.emit(OP_SAVE_LOCAL_VAR_STR); + } + codeStream.emit(getFuncVars(dbgLineNumber)->assign(varName, subType == TypeReqNone ? TypeReqString : subType, dbgLineNumber)); } - switch (subType) - { - case TypeReqString: - codeStream.emit(OP_SAVEVAR_STR); - break; - case TypeReqUInt: - codeStream.emit(OP_SAVEVAR_UINT); - break; - case TypeReqFloat: - codeStream.emit(OP_SAVEVAR_FLT); - break; - case TypeReqVar: - codeStream.emit(OP_SAVEVAR_VAR); - break; - case TypeReqNone: - break; - } - if (type != subType) - codeStream.emit(conversionOp(subType, type)); + + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); return ip; } @@ -1168,181 +1002,136 @@ TypeReq AssignExprNode::getPreferredType() //------------------------------------------------------------ -static void getAssignOpTypeOp(S32 op, TypeReq &type, U32 &operand) +static void getAssignOpTypeOp(S32 op, TypeReq& type, U32& operand) { switch (op) { - case '+': - case opPLUSPLUS: - type = TypeReqFloat; - operand = OP_ADD; - break; - case '-': - case opMINUSMINUS: - type = TypeReqFloat; - operand = OP_SUB; - break; - case '*': - type = TypeReqFloat; - operand = OP_MUL; - break; - case '/': - type = TypeReqFloat; - operand = OP_DIV; - break; - case '%': - type = TypeReqUInt; - operand = OP_MOD; - break; - case '&': - type = TypeReqUInt; - operand = OP_BITAND; - break; - case '^': - type = TypeReqUInt; - operand = OP_XOR; - break; - case '|': - type = TypeReqUInt; - operand = OP_BITOR; - break; - case opSHL: - type = TypeReqUInt; - operand = OP_SHL; - break; - case opSHR: - type = TypeReqUInt; - operand = OP_SHR; - break; + case opPLUSPLUS: + TORQUE_CASE_FALLTHROUGH; + case '+': + type = TypeReqFloat; + operand = OP_ADD; + break; + case opMINUSMINUS: + TORQUE_CASE_FALLTHROUGH; + case '-': + type = TypeReqFloat; + operand = OP_SUB; + break; + case '*': + type = TypeReqFloat; + operand = OP_MUL; + break; + case '/': + type = TypeReqFloat; + operand = OP_DIV; + break; + case '%': + type = TypeReqUInt; + operand = OP_MOD; + break; + case '&': + type = TypeReqUInt; + operand = OP_BITAND; + break; + case '^': + type = TypeReqUInt; + operand = OP_XOR; + break; + case '|': + type = TypeReqUInt; + operand = OP_BITOR; + break; + case opSHL: + type = TypeReqUInt; + operand = OP_SHL; + break; + case opSHR: + type = TypeReqUInt; + operand = OP_SHR; + break; + default: + AssertFatal(false, "Invalid opcode on operation expression"); } } -U32 AssignOpExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 AssignOpExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // goes like this... - // - // IF no array index && (op == OPPLUSPLUS or op == OPMINUSMINUS) - // if op == OPPLUSPLUS - // OP_INC - // varName - // else if op == OPMINUSMINUS - // OP_DEC - // varName - // else - // OP_INVALID - // endif - // ELSE - // eval expr as float or int - // if there's an arrayIndex and we don't short circuit - // if arrayIndex is a var node - // OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP - // varName - // varNodeVarName - // else - // OP_LOADIMMED_IDENT - // varName - // OP_ADVANCE_STR - // eval arrayIndex stringwise - // OP_REWIND_STR - // OP_SETCURVAR_ARRAY_CREATE - // endif - // else - // OP_SETCURVAR_CREATE - // varName - // endif - // OP_LOADVAR_FLT or UINT - // operand - // OP_SAVEVAR_FLT or UINT - // ENDIF - // - // if subtype != type - // convert type - // endif + // eval expr as float or int + // if there's an arrayIndex + + // OP_LOADIMMED_IDENT + // varName + // OP_ADVANCE_STR + // eval arrayIndex stringwise + // OP_REWIND_STR + // OP_SETCURVAR_ARRAY_CREATE + + // else + // OP_SETCURVAR_CREATE + // varName + + // OP_LOADVAR_FLT or UINT + // operand + // OP_SAVEVAR_FLT or UINT // conversion OP if necessary. getAssignOpTypeOp(op, subType, operand); + precompileIdent(varName); - // ++ or -- optimization support for non indexed variables. - if ((!arrayIndex) && (op == opPLUSPLUS || op == opMINUSMINUS)) + bool oldVariables = arrayIndex || varName[0] == '$'; + + if (op == opPLUSPLUS && !oldVariables && type == TypeReqNone) { - precompileIdent(varName); + const S32 varIdx = getFuncVars(dbgLineNumber)->assign(varName, TypeReqFloat, dbgLineNumber); - if (op == opPLUSPLUS) - { - codeStream.emit(OP_INC); - codeStream.emitSTE(varName); - } - else if (op == opMINUSMINUS) - { - codeStream.emit(OP_DEC); - codeStream.emitSTE(varName); - } - else - { - // This should NEVER happen. This is just for sanity. - AssertISV(false, "Tried to use ++ or -- but something weird happened."); - codeStream.emit(OP_INVALID); - } + codeStream.emit(OP_INC); + codeStream.emit(varIdx); } else { ip = expr->compile(codeStream, ip, subType); - bool shortCircuit = false; - if (arrayIndex) + if (oldVariables) { - // If we have a constant, shortcircuit the array logic. - - IntNode *intNode = dynamic_cast(arrayIndex); - StrConstNode *strNode = dynamic_cast(arrayIndex); - if (intNode) + if (!arrayIndex) { - varName = StringTable->insert(avar("%s%d", varName, intNode->value)); - shortCircuit = true; - } - else if (strNode) - { - varName = StringTable->insert(avar("%s%s", varName, strNode->str)); - shortCircuit = true; - } - } - - precompileIdent(varName); - - if (!arrayIndex || shortCircuit) - { - codeStream.emit(OP_SETCURVAR_CREATE); - codeStream.emitSTE(varName); - } - else - { - // Ok, lets try to optimize %var[%someothervar] as this is - // a common case for array usage. - StringTableEntry varNodeVarName; - if (isSimpleVarLookup(arrayIndex, varNodeVarName)) - { - codeStream.emit(OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP); + codeStream.emit(OP_SETCURVAR_CREATE); codeStream.emitSTE(varName); - codeStream.emitSTE(varNodeVarName); } else { codeStream.emit(OP_LOADIMMED_IDENT); codeStream.emitSTE(varName); - codeStream.emit(OP_ADVANCE_STR); + //codeStream.emit(OP_ADVANCE_STR); ip = arrayIndex->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_REWIND_STR); codeStream.emit(OP_SETCURVAR_ARRAY_CREATE); + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); } + codeStream.emit((subType == TypeReqFloat) ? OP_LOADVAR_FLT : OP_LOADVAR_UINT); + codeStream.emit(operand); + codeStream.emit((subType == TypeReqFloat) ? OP_SAVEVAR_FLT : OP_SAVEVAR_UINT); } - codeStream.emit((subType == TypeReqFloat) ? OP_LOADVAR_FLT : OP_LOADVAR_UINT); - codeStream.emit(operand); - codeStream.emit((subType == TypeReqFloat) ? OP_SAVEVAR_FLT : OP_SAVEVAR_UINT); + else + { + const bool isFloat = subType == TypeReqFloat; + const S32 varIdx = getFuncVars(dbgLineNumber)->assign(varName, subType == TypeReqNone ? TypeReqString : subType, dbgLineNumber); + + codeStream.emit(isFloat ? OP_LOAD_LOCAL_VAR_FLT : OP_LOAD_LOCAL_VAR_UINT); + codeStream.emit(varIdx); + codeStream.emit(operand); + codeStream.emit(isFloat ? OP_SAVE_LOCAL_VAR_FLT : OP_SAVE_LOCAL_VAR_UINT); + codeStream.emit(varIdx); + } + + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); } - if (subType != type) - codeStream.emit(conversionOp(subType, type)); return codeStream.tell(); } @@ -1385,7 +1174,7 @@ TypeReq TTagExprNode::getPreferredType() //------------------------------------------------------------ -U32 FuncCallExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 FuncCallExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // OP_PUSH_FRAME // arg OP_PUSH arg OP_PUSH arg OP_PUSH @@ -1399,72 +1188,31 @@ U32 FuncCallExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) precompileIdent(funcName); precompileIdent(nameSpace); + S32 count = 0; + for (ExprNode* walk = args; walk; walk = static_cast(walk->getNext())) + count++; + codeStream.emit(OP_PUSH_FRAME); + codeStream.emit(count); - bool isThisCall = false; - - ExprNode *walk = args; - - // Try to optimize the this pointer call if it is a variable - // that we are loading. - if (callType == MethodCall) - { - // We cannot optimize array indices because it can have quite - // a bit of code to figure out the array index. - VarNode *var = dynamic_cast(args); - if (var && !var->arrayIndex) - { - precompileIdent(var->varName); - - // Are we a %this call? - isThisCall = (var->varName == StringTable->insert("%this")); - - codeStream.emit(OP_PUSH_THIS); - codeStream.emitSTE(var->varName); - - // inc args since we took care of first arg. - walk = (ExprNode*)walk ->getNext(); - } - } - - for (; walk; walk = (ExprNode *)walk->getNext()) + for (ExprNode* walk = args; walk; walk = static_cast(walk->getNext())) { TypeReq walkType = walk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; + if (walkType == TypeReqNone) + walkType = TypeReqString; + ip = walk->compile(codeStream, ip, walkType); - switch (walk->getPreferredType()) - { - case TypeReqFloat: - codeStream.emit(OP_PUSH_FLT); - break; - case TypeReqUInt: - codeStream.emit(OP_PUSH_UINT); - break; - default: - codeStream.emit(OP_PUSH); - break; - } + codeStream.emit(OP_PUSH); } - if (isThisCall) - { - codeStream.emit(OP_CALLFUNC_THIS); - codeStream.emitSTE(funcName); - } - else - { - if (callType == MethodCall || callType == ParentCall) - codeStream.emit(OP_CALLFUNC); - else - codeStream.emit(OP_CALLFUNC_RESOLVE); + codeStream.emit(OP_CALLFUNC); + codeStream.emitSTE(funcName); + codeStream.emitSTE(nameSpace); + codeStream.emit(callType); - codeStream.emitSTE(funcName); - codeStream.emitSTE(nameSpace); - codeStream.emit(callType); - } + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); - if (type != TypeReqString) - codeStream.emit(conversionOp(TypeReqString, type)); return codeStream.tell(); } @@ -1475,51 +1223,7 @@ TypeReq FuncCallExprNode::getPreferredType() //------------------------------------------------------------ -U32 FuncPointerCallExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) -{ - // OP_PUSH_FRAME - // arg OP_PUSH arg OP_PUSH arg OP_PUSH - // eval all the args, then call the function. - - // eval fn pointer - // OP_CALLFUNC_POINTER - - codeStream.emit(OP_PUSH_FRAME); - for (ExprNode *walk = args; walk; walk = (ExprNode *)walk->getNext()) - { - TypeReq walkType = walk->getPreferredType(); - if (walkType == TypeReqNone) walkType = TypeReqString; - ip = walk->compile(codeStream, ip, walkType); - switch (walk->getPreferredType()) - { - case TypeReqFloat: - codeStream.emit(OP_PUSH_FLT); - break; - case TypeReqUInt: - codeStream.emit(OP_PUSH_UINT); - break; - default: - codeStream.emit(OP_PUSH); - break; - } - } - - ip = funcPointer->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_CALLFUNC_POINTER); - - if (type != TypeReqString) - codeStream.emit(conversionOp(TypeReqString, type)); - return codeStream.tell(); -} - -TypeReq FuncPointerCallExprNode::getPreferredType() -{ - return TypeReqString; -} - -//------------------------------------------------------------ - -U32 AssertCallExprNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 AssertCallExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { #ifdef TORQUE_ENABLE_SCRIPTASSERTS @@ -1541,59 +1245,44 @@ TypeReq AssertCallExprNode::getPreferredType() //------------------------------------------------------------ -U32 SlotAccessNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 SlotAccessNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { if (type == TypeReqNone) return ip; precompileIdent(slotName); - // check if object is %this. If we are, we can do additional optimizations. - if (isThisVar(objectExpr)) + if (arrayExpr) { - optimizeThisPointer(codeStream, arrayExpr, ip, slotName); + ip = arrayExpr->compile(codeStream, ip, TypeReqString); } - else + ip = objectExpr->compile(codeStream, ip, TypeReqString); + codeStream.emit(OP_SETCUROBJECT); + + codeStream.emit(OP_SETCURFIELD); + codeStream.emitSTE(slotName); + + codeStream.emit(OP_POP_STK); + + if (arrayExpr) { - if (arrayExpr) - { - // eval array - // OP_ADVANCE_STR - // evaluate object expression sub (OP_SETCURFIELD) - // OP_TERMINATE_REWIND_STR - // OP_SETCURFIELDARRAY - // total add of 4 + array precomp - - ip = arrayExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_ADVANCE_STR); - } - ip = objectExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_SETCUROBJECT); - - codeStream.emit(OP_SETCURFIELD); - - codeStream.emitSTE(slotName); - - if (arrayExpr) - { - codeStream.emit(OP_TERMINATE_REWIND_STR); - codeStream.emit(OP_SETCURFIELD_ARRAY); - } + codeStream.emit(OP_SETCURFIELD_ARRAY); + codeStream.emit(OP_POP_STK); } switch (type) { - case TypeReqUInt: - codeStream.emit(OP_LOADFIELD_UINT); - break; - case TypeReqFloat: - codeStream.emit(OP_LOADFIELD_FLT); - break; - case TypeReqString: - codeStream.emit(OP_LOADFIELD_STR); - break; - case TypeReqNone: - break; + case TypeReqUInt: + codeStream.emit(OP_LOADFIELD_UINT); + break; + case TypeReqFloat: + codeStream.emit(OP_LOADFIELD_FLT); + break; + case TypeReqString: + codeStream.emit(OP_LOADFIELD_STR); + break; + case TypeReqNone: + break; } return codeStream.tell(); } @@ -1605,7 +1294,7 @@ TypeReq SlotAccessNode::getPreferredType() //----------------------------------------------------------------------------- -U32 InternalSlotAccessNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 InternalSlotAccessNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { if (type == TypeReqNone) return ip; @@ -1613,12 +1302,13 @@ U32 InternalSlotAccessNode::compile(CodeStream &codeStream, U32 ip, TypeReq type ip = objectExpr->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_SETCUROBJECT); + // we pop the stack as we will override the current object with the internal object + codeStream.emit(OP_POP_STK); + ip = slotExpr->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_SETCUROBJECT_INTERNAL); codeStream.emit(recurse); - if (type != TypeReqUInt) - codeStream.emit(conversionOp(TypeReqUInt, type)); return codeStream.tell(); } @@ -1629,69 +1319,36 @@ TypeReq InternalSlotAccessNode::getPreferredType() //----------------------------------------------------------------------------- -U32 SlotAssignNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 SlotAssignNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { - // first eval the expression TypeReqString - - // if it's an array: - - // if OP_ADVANCE_STR 1 - // eval array - - // OP_ADVANCE_STR 1 - // evaluate object expr - // OP_SETCUROBJECT 1 - // OP_SETCURFIELD 1 - // fieldName 1 - // OP_TERMINATE_REWIND_STR 1 - - // OP_SETCURFIELDARRAY 1 - // OP_TERMINATE_REWIND_STR 1 - - // else - // OP_ADVANCE_STR - // evaluate object expr - // OP_SETCUROBJECT - // OP_SETCURFIELD - // fieldName - // OP_TERMINATE_REWIND_STR - - // OP_SAVEFIELD - // convert to return type if necessary. - precompileIdent(slotName); ip = valueExpr->compile(codeStream, ip, TypeReqString); - - if (isThisVar(objectExpr)) + if (arrayExpr) { - optimizeThisPointer(codeStream, arrayExpr, ip, slotName); + ip = arrayExpr->compile(codeStream, ip, TypeReqString); + } + if (objectExpr) + { + ip = objectExpr->compile(codeStream, ip, TypeReqString); + codeStream.emit(OP_SETCUROBJECT); } else + codeStream.emit(OP_SETCUROBJECT_NEW); + codeStream.emit(OP_SETCURFIELD); + codeStream.emitSTE(slotName); + + if (objectExpr) { - codeStream.emit(OP_ADVANCE_STR); - if (arrayExpr) - { - ip = arrayExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_ADVANCE_STR); - } - if (objectExpr) - { - ip = objectExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_SETCUROBJECT); - } - else - codeStream.emit(OP_SETCUROBJECT_NEW); - codeStream.emit(OP_SETCURFIELD); - codeStream.emitSTE(slotName); + // Don't pop unless we are assigning a field to an object + // (For initializer fields, we don't wanna pop) + codeStream.emit(OP_POP_STK); + } - if (arrayExpr) - { - codeStream.emit(OP_TERMINATE_REWIND_STR); - codeStream.emit(OP_SETCURFIELD_ARRAY); - } - - codeStream.emit(OP_TERMINATE_REWIND_STR); + if (arrayExpr) + { + codeStream.emit(OP_SETCURFIELD_ARRAY); + codeStream.emit(OP_POP_STK); } codeStream.emit(OP_SAVEFIELD_STR); @@ -1702,8 +1359,9 @@ U32 SlotAssignNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) codeStream.emit(typeID); } - if (type != TypeReqString) - codeStream.emit(conversionOp(TypeReqString, type)); + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); + return codeStream.tell(); } @@ -1714,7 +1372,7 @@ TypeReq SlotAssignNode::getPreferredType() //------------------------------------------------------------ -U32 SlotAssignOpNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 SlotAssignOpNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // first eval the expression as its type @@ -1743,34 +1401,28 @@ U32 SlotAssignOpNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) precompileIdent(slotName); ip = valueExpr->compile(codeStream, ip, subType); - - if (isThisVar(objectExpr)) + if (arrayExpr) { - optimizeThisPointer(codeStream, arrayExpr, ip, slotName); + ip = arrayExpr->compile(codeStream, ip, TypeReqString); } - else - { - if (arrayExpr) - { - ip = arrayExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_ADVANCE_STR); - } - ip = objectExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_SETCUROBJECT); - codeStream.emit(OP_SETCURFIELD); - codeStream.emitSTE(slotName); + ip = objectExpr->compile(codeStream, ip, TypeReqString); + codeStream.emit(OP_SETCUROBJECT); + codeStream.emit(OP_SETCURFIELD); + codeStream.emitSTE(slotName); - if (arrayExpr) - { - codeStream.emit(OP_TERMINATE_REWIND_STR); - codeStream.emit(OP_SETCURFIELD_ARRAY); - } + codeStream.emit(OP_POP_STK); + + if (arrayExpr) + { + codeStream.emit(OP_SETCURFIELD_ARRAY); + if (subType == TypeReqNone) + codeStream.emit(OP_POP_STK); } codeStream.emit((subType == TypeReqFloat) ? OP_LOADFIELD_FLT : OP_LOADFIELD_UINT); codeStream.emit(operand); codeStream.emit((subType == TypeReqFloat) ? OP_SAVEFIELD_FLT : OP_SAVEFIELD_UINT); - if (subType != type) - codeStream.emit(conversionOp(subType, type)); + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); return codeStream.tell(); } @@ -1782,7 +1434,7 @@ TypeReq SlotAssignOpNode::getPreferredType() //------------------------------------------------------------ -U32 ObjectDeclNode::compileSubObject(CodeStream &codeStream, U32 ip, bool root) +U32 ObjectDeclNode::compileSubObject(CodeStream& codeStream, U32 ip, bool root) { // goes @@ -1808,30 +1460,24 @@ U32 ObjectDeclNode::compileSubObject(CodeStream &codeStream, U32 ip, bool root) // To fix the stack issue [7/9/2007 Black] // OP_FINISH_OBJECT <-- fail point jumps to this opcode + S32 count = 2; // 2 OP_PUSH's + for (ExprNode* exprWalk = argList; exprWalk; exprWalk = (ExprNode*)exprWalk->getNext()) + count++; + codeStream.emit(OP_PUSH_FRAME); + codeStream.emit(count); ip = classNameExpr->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_PUSH); ip = objectNameExpr->compile(codeStream, ip, TypeReqString); codeStream.emit(OP_PUSH); - for (ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *)exprWalk->getNext()) + for (ExprNode* exprWalk = argList; exprWalk; exprWalk = (ExprNode*)exprWalk->getNext()) { TypeReq walkType = exprWalk->getPreferredType(); if (walkType == TypeReqNone) walkType = TypeReqString; ip = exprWalk->compile(codeStream, ip, walkType); - switch (exprWalk->getPreferredType()) - { - case TypeReqFloat: - codeStream.emit(OP_PUSH_FLT); - break; - case TypeReqUInt: - codeStream.emit(OP_PUSH_UINT); - break; - default: - codeStream.emit(OP_PUSH); - break; - } + codeStream.emit(OP_PUSH); } codeStream.emit(OP_CREATE_OBJECT); codeStream.emitSTE(parentObject); @@ -1841,11 +1487,11 @@ U32 ObjectDeclNode::compileSubObject(CodeStream &codeStream, U32 ip, bool root) codeStream.emit(isSingleton); codeStream.emit(dbgLineNumber); const U32 failIp = codeStream.emit(0); - for (SlotAssignNode *slotWalk = slotDecls; slotWalk; slotWalk = (SlotAssignNode *)slotWalk->getNext()) + for (SlotAssignNode* slotWalk = slotDecls; slotWalk; slotWalk = (SlotAssignNode*)slotWalk->getNext()) ip = slotWalk->compile(codeStream, ip, TypeReqNone); codeStream.emit(OP_ADD_OBJECT); codeStream.emit(root); - for (ObjectDeclNode *objectWalk = subObjects; objectWalk; objectWalk = (ObjectDeclNode *)objectWalk->getNext()) + for (ObjectDeclNode* objectWalk = subObjects; objectWalk; objectWalk = (ObjectDeclNode*)objectWalk->getNext()) ip = objectWalk->compileSubObject(codeStream, ip, false); codeStream.emit(OP_END_OBJECT); codeStream.emit(root || isDatablock); @@ -1857,7 +1503,7 @@ U32 ObjectDeclNode::compileSubObject(CodeStream &codeStream, U32 ip, bool root) return codeStream.tell(); } -U32 ObjectDeclNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) +U32 ObjectDeclNode::compile(CodeStream& codeStream, U32 ip, TypeReq type) { // root object decl does: @@ -1869,8 +1515,10 @@ U32 ObjectDeclNode::compile(CodeStream &codeStream, U32 ip, TypeReq type) codeStream.emit(OP_LOADIMMED_UINT); codeStream.emit(0); ip = compileSubObject(codeStream, ip, true); - if (type != TypeReqUInt) - codeStream.emit(conversionOp(TypeReqUInt, type)); + + if (type == TypeReqNone) + codeStream.emit(OP_POP_STK); + return codeStream.tell(); } @@ -1881,7 +1529,7 @@ TypeReq ObjectDeclNode::getPreferredType() //------------------------------------------------------------ -U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip) +U32 FunctionDeclStmtNode::compileStmt(CodeStream& codeStream, U32 ip) { // OP_FUNC_DECL // func name @@ -1896,10 +1544,14 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip) setCurrentStringTable(&getFunctionStringTable()); setCurrentFloatTable(&getFunctionFloatTable()); + FuncVars vars; + gFuncVars = &vars; + argc = 0; - for (VarNode *walk = args; walk; walk = (VarNode *)((StmtNode*)walk)->getNext()) + for (VarNode* walk = args; walk; walk = (VarNode*)((StmtNode*)walk)->getNext()) { precompileIdent(walk->varName); + getFuncVars(dbgLineNumber)->assign(walk->varName, TypeReqNone, dbgLineNumber); argc++; } @@ -1919,9 +1571,11 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip) codeStream.emit(U32(bool(stmts != NULL) ? 1 : 0) + U32(dbgLineNumber << 1)); const U32 endIp = codeStream.emit(0); codeStream.emit(argc); - for (VarNode *walk = args; walk; walk = (VarNode *)((StmtNode*)walk)->getNext()) + const U32 localNumVarsIP = codeStream.emit(0); + for (VarNode* walk = args; walk; walk = (VarNode*)((StmtNode*)walk)->getNext()) { - codeStream.emitSTE(walk->varName); + StringTableEntry name = walk->varName; + codeStream.emit(getFuncVars(dbgLineNumber)->lookup(name, dbgLineNumber)); } CodeBlock::smInFunction = true; ip = compileBlock(stmts, codeStream, ip); @@ -1933,10 +1587,22 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip) CodeBlock::smInFunction = false; codeStream.emit(OP_RETURN_VOID); + codeStream.patch(localNumVarsIP, getFuncVars(dbgLineNumber)->count()); codeStream.patch(endIp, codeStream.tell()); setCurrentStringTable(&getGlobalStringTable()); setCurrentFloatTable(&getGlobalFloatTable()); + // map local variables to registers for this function. + // Note we have to map these in order because the table itself is ordered by the register id. + CompilerLocalVariableToRegisterMappingTable* tbl = &getFunctionVariableMappingTable(); + for (size_t i = 0; i < gFuncVars->variableNameMap.size(); ++i) + { + StringTableEntry varName = gFuncVars->variableNameMap[i]; + tbl->add(fnName, nameSpace, varName); + } + + gFuncVars = NULL; + return ip; } diff --git a/Engine/source/console/cmdgram.cpp b/Engine/source/console/cmdgram.cpp index b5051786b..aab109792 100644 --- a/Engine/source/console/cmdgram.cpp +++ b/Engine/source/console/cmdgram.cpp @@ -1,6 +1,6 @@ /* A Bison parser, made from cmdgram.y with Bison version GNU Bison version 1.24 -*/ + */ #define YYBISON 1 /* Identify Bison output. */ @@ -129,13 +129,13 @@ struct Token #line 44 "cmdgram.y" -/* Reserved Word Definitions */ + /* Reserved Word Definitions */ #line 55 "cmdgram.y" -/* Constants and Identifier Definitions */ + /* Constants and Identifier Definitions */ #line 69 "cmdgram.y" -/* Operator Definitions */ + /* Operator Definitions */ #line 82 "cmdgram.y" typedef union { @@ -158,16 +158,16 @@ typedef union { #ifndef YYLTYPE typedef -struct yyltype -{ - int timestamp; - int first_line; - int first_column; - int last_line; - int last_column; - char *text; -} -yyltype; + struct yyltype + { + int timestamp; + int first_line; + int first_column; + int last_line; + int last_column; + char *text; + } + yyltype; #define YYLTYPE yyltype #endif @@ -182,165 +182,164 @@ yyltype; -#define YYFINAL 391 +#define YYFINAL 380 #define YYFLAG -32768 #define YYNTBASE 100 #define YYTRANSLATE(x) ((unsigned)(x) <= 329 ? yytranslate[x] : 140) -static const char yytranslate[] = { 0, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 64, 2, 2, 2, 54, 53, 2, 55, -56, 46, 44, 57, 45, 51, 47, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 58, 59, 48, -50, 49, 96, 65, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -92, 2, 99, 62, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 60, 52, 61, 63, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 2, 2, 2, 1, 2, 3, 4, 5, -6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -36, 37, 38, 39, 40, 41, 42, 43, 66, 67, -68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -78, 79, 80, 81, 82, 83, 84, 85, 86, 87, -88, 89, 90, 91, 93, 94, 95, 97, 98 +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 64, 2, 2, 2, 54, 53, 2, 55, + 56, 46, 44, 57, 45, 51, 47, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 58, 59, 48, + 50, 49, 96, 65, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 92, 2, 99, 62, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 60, 52, 61, 63, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 93, 94, 95, 97, 98 }; #if YYDEBUG != 0 -static const short yyprhs[] = { 0, -0, 2, 3, 6, 8, 10, 12, 19, 21, 24, -25, 28, 30, 32, 34, 36, 38, 40, 43, 46, -49, 53, 56, 61, 68, 70, 79, 90, 91, 93, -95, 99, 110, 121, 129, 142, 152, 163, 171, 172, -175, 176, 178, 179, 182, 183, 185, 187, 190, 193, -197, 201, 203, 211, 219, 224, 232, 238, 240, 244, -250, 258, 264, 271, 281, 290, 299, 307, 316, 324, -332, 339, 347, 355, 357, 359, 363, 367, 371, 375, -379, 383, 387, 391, 395, 398, 401, 403, 409, 413, -417, 421, 425, 429, 433, 437, 441, 445, 449, 453, -457, 461, 464, 467, 469, 471, 473, 475, 477, 479, -481, 483, 485, 490, 498, 502, 509, 513, 517, 519, -523, 525, 527, 530, 533, 536, 539, 542, 545, 548, -551, 554, 557, 559, 561, 563, 567, 574, 577, 583, -586, 590, 596, 601, 608, 615, 620, 625, 632, 633, -635, 637, 641, 642, 644, 646, 649, 654, 660, 665, -673, 682, 684 +static const short yyprhs[] = { 0, + 0, 2, 3, 6, 8, 10, 12, 19, 21, 24, + 25, 28, 30, 32, 34, 36, 38, 40, 43, 46, + 49, 53, 56, 61, 68, 70, 79, 90, 91, 93, + 95, 99, 110, 121, 129, 142, 152, 163, 171, 172, + 175, 176, 178, 179, 182, 183, 185, 187, 190, 193, + 197, 201, 203, 211, 219, 224, 232, 238, 240, 244, + 250, 258, 264, 271, 281, 290, 299, 307, 316, 324, + 332, 339, 347, 355, 357, 359, 363, 367, 371, 375, + 379, 383, 387, 391, 395, 398, 401, 403, 409, 413, + 417, 421, 425, 429, 433, 437, 441, 445, 449, 453, + 457, 461, 464, 467, 469, 471, 473, 475, 477, 479, + 481, 483, 485, 490, 494, 501, 505, 509, 511, 515, + 517, 519, 522, 525, 528, 531, 534, 537, 540, 543, + 546, 549, 551, 553, 555, 559, 566, 569, 575, 578, + 582, 588, 593, 600, 607, 612, 619, 620, 622, 624, + 628, 629, 631, 633, 636, 641, 647, 652, 660, 669, + 671 }; -static const short yyrhs[] = { 101, -0, 0, 101, 102, 0, 106, 0, 107, 0, 103, -0, 29, 38, 60, 104, 61, 59, 0, 107, 0, -104, 107, 0, 0, 105, 106, 0, 121, 0, 122, -0, 123, 0, 124, 0, 110, 0, 118, 0, 7, -59, 0, 9, 59, 0, 13, 59, 0, 13, 126, -59, 0, 125, 59, 0, 36, 50, 126, 59, 0, -36, 50, 126, 57, 126, 59, 0, 40, 0, 3, -38, 55, 108, 56, 60, 105, 61, 0, 3, 38, -91, 38, 55, 108, 56, 60, 105, 61, 0, 0, -109, 0, 37, 0, 109, 57, 37, 0, 24, 129, -55, 126, 112, 56, 60, 136, 61, 59, 0, 5, -129, 55, 113, 112, 114, 56, 60, 115, 61, 0, -5, 129, 55, 113, 112, 114, 56, 0, 5, 129, -55, 92, 113, 99, 112, 114, 56, 60, 115, 61, -0, 5, 129, 55, 92, 113, 99, 112, 114, 56, -0, 6, 129, 55, 113, 112, 114, 56, 60, 115, -61, 0, 6, 129, 55, 113, 112, 114, 56, 0, -0, 58, 38, 0, 0, 126, 0, 0, 57, 135, -0, 0, 137, 0, 116, 0, 137, 116, 0, 111, -59, 0, 116, 111, 59, 0, 60, 105, 61, 0, -106, 0, 25, 55, 126, 56, 60, 119, 61, 0, -27, 55, 126, 56, 60, 119, 61, 0, 26, 120, -58, 105, 0, 26, 120, 58, 105, 19, 58, 105, -0, 26, 120, 58, 105, 119, 0, 126, 0, 120, -28, 126, 0, 11, 55, 126, 56, 117, 0, 11, -55, 126, 56, 117, 8, 117, 0, 14, 55, 126, -56, 117, 0, 15, 117, 14, 55, 126, 56, 0, -20, 55, 126, 59, 126, 59, 126, 56, 117, 0, -20, 55, 126, 59, 126, 59, 56, 117, 0, 20, -55, 126, 59, 59, 126, 56, 117, 0, 20, 55, -126, 59, 59, 56, 117, 0, 20, 55, 59, 126, -59, 126, 56, 117, 0, 20, 55, 59, 126, 59, -56, 117, 0, 20, 55, 59, 59, 126, 56, 117, -0, 20, 55, 59, 59, 56, 117, 0, 21, 55, -37, 23, 126, 56, 117, 0, 22, 55, 37, 23, -126, 56, 117, 0, 131, 0, 131, 0, 55, 126, -56, 0, 126, 62, 126, 0, 126, 54, 126, 0, -126, 53, 126, 0, 126, 52, 126, 0, 126, 44, -126, 0, 126, 45, 126, 0, 126, 46, 126, 0, -126, 47, 126, 0, 45, 126, 0, 46, 126, 0, -36, 0, 126, 96, 126, 58, 126, 0, 126, 48, -126, 0, 126, 49, 126, 0, 126, 86, 126, 0, -126, 87, 126, 0, 126, 84, 126, 0, 126, 85, -126, 0, 126, 89, 126, 0, 126, 71, 126, 0, -126, 72, 126, 0, 126, 88, 126, 0, 126, 90, -126, 0, 126, 97, 126, 0, 126, 65, 126, 0, -64, 126, 0, 63, 126, 0, 42, 0, 43, 0, -35, 0, 7, 0, 127, 0, 128, 0, 38, 0, -41, 0, 37, 0, 37, 92, 139, 99, 0, 3, -55, 108, 56, 60, 105, 61, 0, 126, 51, 38, -0, 126, 51, 38, 92, 139, 99, 0, 126, 66, -129, 0, 126, 67, 129, 0, 38, 0, 55, 126, -56, 0, 69, 0, 68, 0, 73, 126, 0, 74, -126, 0, 75, 126, 0, 76, 126, 0, 77, 126, -0, 78, 126, 0, 79, 126, 0, 80, 126, 0, -81, 126, 0, 82, 126, 0, 132, 0, 133, 0, -111, 0, 37, 50, 126, 0, 37, 92, 139, 99, -50, 126, 0, 37, 130, 0, 37, 92, 139, 99, -130, 0, 127, 130, 0, 127, 50, 126, 0, 127, -50, 60, 135, 61, 0, 38, 55, 134, 56, 0, -38, 91, 38, 55, 134, 56, 0, 126, 51, 38, -55, 134, 56, 0, 126, 55, 134, 56, 0, 32, -55, 126, 56, 0, 32, 55, 126, 57, 41, 56, -0, 0, 135, 0, 126, 0, 135, 57, 126, 0, -0, 137, 0, 138, 0, 137, 138, 0, 38, 50, -126, 59, 0, 39, 38, 50, 126, 59, 0, 24, -50, 126, 59, 0, 38, 92, 139, 99, 50, 126, -59, 0, 39, 38, 92, 139, 99, 50, 126, 59, -0, 126, 0, 139, 57, 126, 0 +static const short yyrhs[] = { 101, + 0, 0, 101, 102, 0, 106, 0, 107, 0, 103, + 0, 29, 38, 60, 104, 61, 59, 0, 107, 0, + 104, 107, 0, 0, 105, 106, 0, 121, 0, 122, + 0, 123, 0, 124, 0, 110, 0, 118, 0, 7, + 59, 0, 9, 59, 0, 13, 59, 0, 13, 126, + 59, 0, 125, 59, 0, 36, 50, 126, 59, 0, + 36, 50, 126, 57, 126, 59, 0, 40, 0, 3, + 38, 55, 108, 56, 60, 105, 61, 0, 3, 38, + 91, 38, 55, 108, 56, 60, 105, 61, 0, 0, + 109, 0, 37, 0, 109, 57, 37, 0, 24, 129, + 55, 126, 112, 56, 60, 136, 61, 59, 0, 5, + 129, 55, 113, 112, 114, 56, 60, 115, 61, 0, + 5, 129, 55, 113, 112, 114, 56, 0, 5, 129, + 55, 92, 113, 99, 112, 114, 56, 60, 115, 61, + 0, 5, 129, 55, 92, 113, 99, 112, 114, 56, + 0, 6, 129, 55, 113, 112, 114, 56, 60, 115, + 61, 0, 6, 129, 55, 113, 112, 114, 56, 0, + 0, 58, 38, 0, 0, 126, 0, 0, 57, 135, + 0, 0, 137, 0, 116, 0, 137, 116, 0, 111, + 59, 0, 116, 111, 59, 0, 60, 105, 61, 0, + 106, 0, 25, 55, 126, 56, 60, 119, 61, 0, + 27, 55, 126, 56, 60, 119, 61, 0, 26, 120, + 58, 105, 0, 26, 120, 58, 105, 19, 58, 105, + 0, 26, 120, 58, 105, 119, 0, 126, 0, 120, + 28, 126, 0, 11, 55, 126, 56, 117, 0, 11, + 55, 126, 56, 117, 8, 117, 0, 14, 55, 126, + 56, 117, 0, 15, 117, 14, 55, 126, 56, 0, + 20, 55, 126, 59, 126, 59, 126, 56, 117, 0, + 20, 55, 126, 59, 126, 59, 56, 117, 0, 20, + 55, 126, 59, 59, 126, 56, 117, 0, 20, 55, + 126, 59, 59, 56, 117, 0, 20, 55, 59, 126, + 59, 126, 56, 117, 0, 20, 55, 59, 126, 59, + 56, 117, 0, 20, 55, 59, 59, 126, 56, 117, + 0, 20, 55, 59, 59, 56, 117, 0, 21, 55, + 37, 23, 126, 56, 117, 0, 22, 55, 37, 23, + 126, 56, 117, 0, 131, 0, 131, 0, 55, 126, + 56, 0, 126, 62, 126, 0, 126, 54, 126, 0, + 126, 53, 126, 0, 126, 52, 126, 0, 126, 44, + 126, 0, 126, 45, 126, 0, 126, 46, 126, 0, + 126, 47, 126, 0, 45, 126, 0, 46, 126, 0, + 36, 0, 126, 96, 126, 58, 126, 0, 126, 48, + 126, 0, 126, 49, 126, 0, 126, 86, 126, 0, + 126, 87, 126, 0, 126, 84, 126, 0, 126, 85, + 126, 0, 126, 89, 126, 0, 126, 71, 126, 0, + 126, 72, 126, 0, 126, 88, 126, 0, 126, 90, + 126, 0, 126, 97, 126, 0, 126, 65, 126, 0, + 64, 126, 0, 63, 126, 0, 42, 0, 43, 0, + 35, 0, 7, 0, 127, 0, 128, 0, 38, 0, + 41, 0, 37, 0, 37, 92, 139, 99, 0, 126, + 51, 38, 0, 126, 51, 38, 92, 139, 99, 0, + 126, 66, 129, 0, 126, 67, 129, 0, 38, 0, + 55, 126, 56, 0, 69, 0, 68, 0, 73, 126, + 0, 74, 126, 0, 75, 126, 0, 76, 126, 0, + 77, 126, 0, 78, 126, 0, 79, 126, 0, 80, + 126, 0, 81, 126, 0, 82, 126, 0, 132, 0, + 133, 0, 111, 0, 37, 50, 126, 0, 37, 92, + 139, 99, 50, 126, 0, 37, 130, 0, 37, 92, + 139, 99, 130, 0, 127, 130, 0, 127, 50, 126, + 0, 127, 50, 60, 135, 61, 0, 38, 55, 134, + 56, 0, 38, 91, 38, 55, 134, 56, 0, 126, + 51, 38, 55, 134, 56, 0, 32, 55, 126, 56, + 0, 32, 55, 126, 57, 41, 56, 0, 0, 135, + 0, 126, 0, 135, 57, 126, 0, 0, 137, 0, + 138, 0, 137, 138, 0, 38, 50, 126, 59, 0, + 39, 38, 50, 126, 59, 0, 24, 50, 126, 59, + 0, 38, 92, 139, 99, 50, 126, 59, 0, 39, + 38, 92, 139, 99, 50, 126, 59, 0, 126, 0, + 139, 57, 126, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, -161, 166, 168, 173, 175, 177, 182, 187, 189, 194, -196, 201, 202, 203, 204, 205, 206, 207, 209, 211, -213, 215, 217, 219, 221, 226, 228, 233, 235, 240, -242, 247, 252, 254, 256, 258, 260, 262, 267, 269, -274, 276, 281, 283, 288, 290, 292, 294, 299, 301, -306, 308, 313, 315, 320, 322, 324, 329, 331, 336, -338, 343, 345, 350, 352, 354, 356, 358, 360, 362, -364, 369, 371, 376, 381, 383, 385, 387, 389, 391, -393, 395, 397, 399, 401, 403, 405, 407, 409, 411, -413, 415, 417, 419, 421, 423, 425, 427, 429, 431, -433, 435, 437, 439, 441, 443, 445, 447, 449, 451, -453, 455, 457, 459, 477, 479, 484, 486, 491, 493, -498, 500, 502, 504, 506, 508, 510, 512, 514, 516, -518, 520, 525, 527, 529, 531, 533, 535, 537, 539, -541, 543, 548, 550, 552, 554, 559, 561, 566, 568, -573, 575, 580, 582, 587, 589, 594, 596, 598, 600, -602, 607, 609 + 161, 166, 168, 173, 175, 177, 182, 187, 189, 194, + 196, 201, 202, 203, 204, 205, 206, 207, 209, 211, + 213, 215, 217, 219, 221, 226, 228, 233, 235, 240, + 242, 247, 252, 254, 256, 258, 260, 262, 267, 269, + 274, 276, 281, 283, 288, 290, 292, 294, 299, 301, + 306, 308, 313, 315, 320, 322, 324, 329, 331, 336, + 338, 343, 345, 350, 352, 354, 356, 358, 360, 362, + 364, 369, 371, 376, 381, 383, 385, 387, 389, 391, + 393, 395, 397, 399, 401, 403, 405, 407, 409, 411, + 413, 415, 417, 419, 421, 423, 425, 427, 429, 431, + 433, 435, 437, 439, 441, 443, 445, 447, 449, 451, + 453, 455, 457, 479, 481, 486, 488, 493, 495, 500, + 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, + 522, 527, 529, 531, 533, 535, 537, 539, 541, 543, + 545, 550, 552, 554, 564, 566, 571, 573, 578, 580, + 585, 587, 592, 594, 599, 601, 603, 605, 607, 612, + 614 }; -static const char * const yytname[] = { "$","error","$undefined.","rwDEFINE", +static const char * const yytname[] = { "$","error","$undefined.","rwDEFINE", "rwENDDEF","rwDECLARE","rwDECLARESINGLETON","rwBREAK","rwELSE","rwCONTINUE", "rwGLOBAL","rwIF","rwNIL","rwRETURN","rwWHILE","rwDO","rwENDIF","rwENDWHILE", "rwENDFOR","rwDEFAULT","rwFOR","rwFOREACH","rwFOREACHSTR","rwIN","rwDATABLOCK", @@ -363,805 +362,747 @@ static const char * const yytname[] = { "$","error","$undefined.","rwDEFINE", }; #endif -static const short yyr1[] = { 0, -100, 101, 101, 102, 102, 102, 103, 104, 104, 105, -105, 106, 106, 106, 106, 106, 106, 106, 106, 106, -106, 106, 106, 106, 106, 107, 107, 108, 108, 109, -109, 110, 111, 111, 111, 111, 111, 111, 112, 112, -113, 113, 114, 114, 115, 115, 115, 115, 116, 116, -117, 117, 118, 118, 119, 119, 119, 120, 120, 121, -121, 122, 122, 123, 123, 123, 123, 123, 123, 123, -123, 124, 124, 125, 126, 126, 126, 126, 126, 126, -126, 126, 126, 126, 126, 126, 126, 126, 126, 126, -126, 126, 126, 126, 126, 126, 126, 126, 126, 126, -126, 126, 126, 126, 126, 126, 126, 126, 126, 126, -126, 126, 126, 126, 127, 127, 128, 128, 129, 129, -130, 130, 130, 130, 130, 130, 130, 130, 130, 130, -130, 130, 131, 131, 131, 131, 131, 131, 131, 131, -131, 131, 132, 132, 132, 132, 133, 133, 134, 134, -135, 135, 136, 136, 137, 137, 138, 138, 138, 138, -138, 139, 139 +static const short yyr1[] = { 0, + 100, 101, 101, 102, 102, 102, 103, 104, 104, 105, + 105, 106, 106, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 106, 106, 106, 107, 107, 108, 108, 109, + 109, 110, 111, 111, 111, 111, 111, 111, 112, 112, + 113, 113, 114, 114, 115, 115, 115, 115, 116, 116, + 117, 117, 118, 118, 119, 119, 119, 120, 120, 121, + 121, 122, 122, 123, 123, 123, 123, 123, 123, 123, + 123, 124, 124, 125, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 127, 127, 128, 128, 129, 129, 130, + 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, + 130, 131, 131, 131, 131, 131, 131, 131, 131, 131, + 131, 132, 132, 132, 133, 133, 134, 134, 135, 135, + 136, 136, 137, 137, 138, 138, 138, 138, 138, 139, + 139 }; -static const short yyr2[] = { 0, -1, 0, 2, 1, 1, 1, 6, 1, 2, 0, -2, 1, 1, 1, 1, 1, 1, 2, 2, 2, -3, 2, 4, 6, 1, 8, 10, 0, 1, 1, -3, 10, 10, 7, 12, 9, 10, 7, 0, 2, -0, 1, 0, 2, 0, 1, 1, 2, 2, 3, -3, 1, 7, 7, 4, 7, 5, 1, 3, 5, -7, 5, 6, 9, 8, 8, 7, 8, 7, 7, -6, 7, 7, 1, 1, 3, 3, 3, 3, 3, -3, 3, 3, 3, 2, 2, 1, 5, 3, 3, -3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -3, 2, 2, 1, 1, 1, 1, 1, 1, 1, -1, 1, 4, 7, 3, 6, 3, 3, 1, 3, -1, 1, 2, 2, 2, 2, 2, 2, 2, 2, -2, 2, 1, 1, 1, 3, 6, 2, 5, 2, -3, 5, 4, 6, 6, 4, 4, 6, 0, 1, -1, 3, 0, 1, 1, 2, 4, 5, 4, 7, -8, 1, 3 +static const short yyr2[] = { 0, + 1, 0, 2, 1, 1, 1, 6, 1, 2, 0, + 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 3, 2, 4, 6, 1, 8, 10, 0, 1, 1, + 3, 10, 10, 7, 12, 9, 10, 7, 0, 2, + 0, 1, 0, 2, 0, 1, 1, 2, 2, 3, + 3, 1, 7, 7, 4, 7, 5, 1, 3, 5, + 7, 5, 6, 9, 8, 8, 7, 8, 7, 7, + 6, 7, 7, 1, 1, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 2, 2, 1, 5, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 3, 6, 3, 3, 1, 3, 1, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 1, 1, 1, 3, 6, 2, 5, 2, 3, + 5, 4, 6, 6, 4, 6, 0, 1, 1, 3, + 0, 1, 1, 2, 4, 5, 4, 7, 8, 1, + 3 }; -static const short yydefact[] = { 2, -1, 0, 0, 0, 107, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 106, 87, -112, 110, 25, 111, 104, 105, 0, 0, 0, 0, -0, 3, 6, 4, 5, 16, 135, 17, 12, 13, -14, 15, 0, 0, 108, 109, 75, 133, 134, 0, -28, 119, 0, 0, 0, 18, 19, 0, 0, 107, -87, 20, 0, 75, 0, 10, 52, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 122, 121, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 138, 149, 0, 85, 86, 0, 103, 102, 22, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -149, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 140, 28, 0, -30, 0, 29, 0, 41, 41, 0, 21, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 136, 123, 124, 125, 126, 127, 128, 129, 130, -131, 132, 162, 0, 151, 0, 150, 0, 76, 81, -82, 83, 84, 89, 90, 115, 80, 79, 78, 0, -77, 101, 117, 118, 96, 97, 93, 94, 91, 92, -98, 95, 99, 0, 100, 0, 141, 0, 0, 0, -0, 120, 41, 39, 42, 39, 0, 0, 51, 11, -0, 0, 0, 0, 0, 0, 39, 0, 0, 0, -0, 8, 147, 0, 0, 23, 0, 113, 143, 0, -149, 149, 0, 146, 0, 0, 0, 28, 10, 31, -0, 0, 43, 43, 60, 62, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 9, 0, -0, 163, 0, 139, 152, 0, 0, 0, 88, 142, -10, 0, 0, 39, 40, 0, 0, 0, 0, 63, -71, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 7, 148, 24, 137, 144, 145, 116, -0, 0, 114, 43, 44, 34, 38, 61, 70, 69, -0, 67, 0, 0, 0, 72, 73, 153, 0, 58, -53, 54, 26, 10, 0, 45, 45, 68, 66, 65, -0, 0, 0, 0, 0, 154, 155, 0, 10, 0, -36, 0, 0, 47, 46, 0, 64, 0, 0, 0, -0, 0, 156, 59, 55, 27, 45, 49, 33, 0, -48, 37, 0, 0, 0, 0, 0, 32, 0, 57, -0, 50, 159, 157, 0, 0, 0, 10, 35, 0, -158, 0, 56, 0, 0, 160, 0, 161, 0, 0, -0 +static const short yydefact[] = { 2, + 1, 0, 0, 0, 107, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 106, 87, + 112, 110, 25, 111, 104, 105, 0, 0, 0, 0, + 0, 3, 6, 4, 5, 16, 134, 17, 12, 13, + 14, 15, 0, 0, 108, 109, 75, 132, 133, 0, + 118, 0, 0, 0, 18, 19, 0, 107, 87, 20, + 0, 75, 0, 10, 52, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 121, 120, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 137, + 147, 0, 85, 86, 0, 103, 102, 22, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 139, 28, 0, 0, 41, 41, + 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 135, 122, 123, 124, 125, + 126, 127, 128, 129, 130, 131, 160, 0, 149, 0, + 148, 0, 76, 81, 82, 83, 84, 89, 90, 114, + 80, 79, 78, 77, 101, 116, 117, 96, 97, 93, + 94, 91, 92, 98, 95, 99, 0, 100, 0, 140, + 30, 0, 29, 0, 119, 41, 39, 42, 39, 0, + 0, 51, 11, 0, 0, 0, 0, 0, 0, 39, + 0, 0, 0, 8, 145, 0, 0, 23, 0, 113, + 142, 0, 147, 147, 0, 0, 0, 0, 0, 28, + 0, 0, 43, 43, 60, 62, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 161, 0, 138, 150, 0, 0, 0, 88, 141, + 10, 31, 0, 39, 40, 0, 0, 0, 0, 63, + 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 7, 146, 24, 136, 143, 144, 115, + 0, 0, 43, 44, 34, 38, 61, 70, 69, 0, + 67, 0, 0, 0, 72, 73, 151, 0, 58, 53, + 54, 26, 10, 0, 45, 45, 68, 66, 65, 0, + 0, 0, 0, 0, 152, 153, 0, 10, 0, 36, + 0, 0, 47, 46, 0, 64, 0, 0, 0, 0, + 0, 154, 59, 55, 27, 45, 49, 33, 0, 48, + 37, 0, 0, 0, 0, 0, 32, 0, 57, 0, + 50, 157, 155, 0, 0, 0, 10, 35, 0, 156, + 0, 56, 0, 0, 158, 0, 159, 0, 0, 0 }; -static const short yydefgoto[] = { 389, -1, 32, 33, 221, 140, 67, 35, 132, 133, 36, -37, 243, 204, 277, 343, 344, 68, 38, 292, 319, -39, 40, 41, 42, 43, 44, 45, 46, 54, 92, -64, 48, 49, 166, 167, 335, 345, 337, 164 +static const short yydefgoto[] = { 378, + 1, 32, 33, 213, 134, 65, 35, 192, 193, 36, + 37, 233, 197, 267, 332, 333, 66, 38, 282, 308, + 39, 40, 41, 42, 43, 44, 45, 46, 53, 90, + 62, 48, 49, 160, 161, 324, 334, 326, 158 }; -static const short yypact[] = { -32768, -213, -7, 55, 55, -37, -25, -18, 490, -13, 422, -5, 14, 41, 55, 47, 49, 9, 51,-32768, 57, -566, -23,-32768,-32768,-32768,-32768, 1187, 1187, 1187, 1187, -1187,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768,-32768, -5, 2650, 3021,-32768, 35,-32768,-32768, -12, -62,-32768, 1187, 67, 68,-32768,-32768, 1187, 69,-32768, --32768,-32768, 1300,-32768, 1187,-32768,-32768, 103, 835, 88, -89, 77, 1187, 1187, 73, 1187, 1187, 1187,-32768,-32768, -1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, 1187, -1187,-32768, 1187, 96, 219, 219, 1354, 219, 219,-32768, -1187, 1187, 1187, 1187, 1187, 1187, 97, 1187, 1187, 1187, -1187, 1187, 1187, 55, 55, 1187, 1187, 1187, 1187, 1187, -1187, 1187, 1187, 1187, 1187, 1187, 879,-32768, 62, 98, --32768, 81, 91, 1408, 21, 1187, 1462,-32768, 1516, 556, -95, 923, 1570, 123, 131, 1187, 1624, 1678, 152, 1192, -1246, 2650, 2650, 2650, 2650, 2650, 2650, 2650, 2650, 2650, -2650, 2650, 2650, -38, 2650, 100, 104, 111,-32768, 145, -145, 219, 219, 3015, 3015, -40, 2845, 2939, 219, 112, -2892, 143,-32768,-32768, 277, 277, 2986, 2986, 3015, 3015, -2798, 2751, 143, 1732, 143, 1187, 2650, 113, 116, 107, -135,-32768, 1187, 119, 2650, 119, 422, 422,-32768,-32768, -1187, 967, 1786, 1011, 1187, 1187, 1840, 122, 126, 157, -13,-32768,-32768, 162, 1187,-32768, 1187, 3041,-32768, 1187, -1187, 1187, 1187,-32768, 1187, 44, 144, 62,-32768,-32768, -106, 170, 156, 156, 209,-32768, 1894, 422, 1948, 1055, -1099, 2002, 2056, 2110, 165, 197, 197, 166,-32768, 173, -2164, 2650, 1187,-32768, 2650, 174, 175, -28, 2704,-32768, --32768, 176, 656, 119,-32768, 1187, 180, 183, 422,-32768, --32768, 422, 422, 2218, 422, 2272, 1143, 422, 422, 181, -1187, 182, 185,-32768,-32768,-32768, 2650,-32768,-32768,-32768, -701, 184,-32768, 156, 104, 192, 200,-32768,-32768,-32768, -422,-32768, 422, 422, 2326,-32768,-32768, 76, 12, 2650, --32768,-32768,-32768,-32768, 201, 92, 92,-32768,-32768,-32768, -422, 211, -20, 224, 202, 76,-32768, 1187,-32768, 746, -204, 206, 205, 39, 92, 208,-32768, 1187, 1187, 1187, --17, 212,-32768, 2650, 138,-32768, 92,-32768,-32768, 216, -39,-32768, 2380, 2434, -21, 1187, 1187,-32768, 221,-32768, -222,-32768,-32768,-32768, 217, 2488, -8,-32768,-32768, 1187, --32768, 230, 791, 2542, 1187,-32768, 2596,-32768, 289, 290, --32768 +static const short yypact[] = {-32768, + 396, -30, -7, -7, -5, 29, -39, 166, -29, 488, + -26, 37, 40, -7, 46, 74, 97, 82,-32768, 94, + -36, -28,-32768,-32768,-32768,-32768, 1001, 1001, 1001, 1001, + 1001,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, 92, 2464, 2726,-32768, 105,-32768,-32768, -27, +-32768, 1001, 110, 111,-32768,-32768, 1001,-32768,-32768,-32768, + 1114,-32768, 1001,-32768,-32768, 156, 707, 137, 139, 123, + 1001, 1001, 120, 1001, 1001, 1001,-32768,-32768, 1001, 1001, + 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001,-32768, + 1001, 143, 27, 27, 1168, 27, 27,-32768, 1001, 1001, + 1001, 1001, 1001, 1001, 144, 1001, 1001, 1001, 1001, 1001, + -7, -7, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, + 1001, 1001, 1001, 749,-32768, 146, 147, 1222, 44, 1001, + 1276,-32768, 1330, 548, 129, 791, 1384, 163, 167, 1001, + 1438, 1492, 186, 1006, 1060, 2464, 2464, 2464, 2464, 2464, + 2464, 2464, 2464, 2464, 2464, 2464, 2464, -47, 2464, 135, + 136, 140,-32768, 713, 713, 27, 27, 2721, 2721, -33, + 2605, 2663, 27, 2634, 2785,-32768,-32768, 291, 291, 2692, + 2692, 2721, 2721, 2576, 2547, 2785, 1546, 2785, 1001, 2464, +-32768, 138, 153, 141,-32768, 1001, 134, 2464, 134, 488, + 488,-32768,-32768, 1001, 318, 1600, 833, 1001, 1001, 1654, + 154, 155, 14,-32768,-32768, 172, 1001,-32768, 1001, 2746, +-32768, 1001, 1001, 1001, 1001, 1001, 48, 157, 160, 146, + 117, 185, 169, 169, 216,-32768, 1708, 488, 1762, 875, + 917, 1816, 1870, 1924, 171, 207, 207, 175,-32768, 180, + 1978, 2464, 1001,-32768, 2464, 183, 184, -46, 2518,-32768, +-32768,-32768, 189, 134,-32768, 1001, 193, 194, 488,-32768, +-32768, 488, 488, 2032, 488, 2086, 959, 488, 488, 181, + 1001, 190, 196,-32768,-32768,-32768, 2464,-32768,-32768,-32768, + 593, 182, 169, 136, 195, 199,-32768,-32768,-32768, 488, +-32768, 488, 488, 2140,-32768,-32768, 59, -3, 2464,-32768, +-32768,-32768,-32768, 198, 214, 214,-32768,-32768,-32768, 488, + 210, -35, 228, 206, 59,-32768, 1001,-32768, 638, 213, + 211, 215, 98, 214, 220,-32768, 1001, 1001, 1001, -32, + 223,-32768, 2464, 443,-32768, 214,-32768,-32768, 224, 98, +-32768, 2194, 2248, -38, 1001, 1001,-32768, 217,-32768, 225, +-32768,-32768,-32768, 234, 2302, -37,-32768,-32768, 1001,-32768, + 235, 683, 2356, 1001,-32768, 2410,-32768, 287, 288,-32768 }; -static const short yypgoto[] = { -32768, --32768,-32768,-32768,-32768, -236, 0, -132, -118,-32768,-32768, --306, -192, -113, -231, -262, -54, -202,-32768, -247,-32768, --32768,-32768,-32768,-32768,-32768, 288,-32768,-32768, 4, -43, --1,-32768,-32768, -104, -184,-32768, -26, -295, -229 +static const short yypgoto[] = {-32768, +-32768,-32768,-32768,-32768, -255, 0, -139, 63,-32768,-32768, + -128, -187, -125, -221, -281, -45, 31,-32768, -244,-32768, +-32768,-32768,-32768,-32768,-32768, 39,-32768,-32768, 20, -43, + -1,-32768,-32768, -107, -182,-32768, -13, -304, -189 }; -#define YYLAST 3123 +#define YYLAST 2857 -static const short yytable[] = { 47, -34, 128, 273, 268, 245, 246, 180, 55, 47, 293, -198, 236, 278, 244, 232, 220, 222, 72, 227, 342, -342, 56, 206, 59, 255, 3, 4, 60, 227, 349, -50, 93, 366, 57, 301, 227, 58, 360, 342, 338, -353, 65, 129, 3, 4, 281, 75, 51, 227, 353, -342, 233, 18, 100, 360, 19, 61, 21, 22, 69, -228, 24, 25, 26, 346, 27, 28, 94, 70, 339, -300, 350, 325, 258, 367, 29, 308, 375, 130, 309, -310, 304, 312, 30, 31, 316, 317, 340, 259, 241, -382, 305, 52, -74, 371, 71, 3, 4, 131, 332, -230, 73, 355, 74, 270, 76, 77, 370, 328, 53, -329, 330, 203, 333, 334, 332, 141, 183, 184, 272, -365, 135, 136, 51, 144, 145, 266, 267, 347, 333, -334, 146, 149, 168, 176, 199, 200, 377, 47, 210, -59, 383, 3, 4, 5, 215, 6, 201, 7, 211, -8, 9, 10, 216, 220, 229, 369, 11, 12, 13, -230, 14, 15, 291, 16, 231, 239, 234, 237, 18, -238, 240, 19, 20, 21, 22, 242, 23, 24, 25, -26, 256, 27, 28, 264, 257, 101, 102, 103, 104, -103, 104, 29, 107, 50, 107, 110, 111, 110, 111, -30, 31, 260, 271, 274, 47, 47, 275, 114, 115, -114, 115, 276, 116, 117, 2, 279, 3, 4, 5, -290, 6, 291, 7, 294, 8, 9, 10, 295, 298, -299, 302, 11, 12, 13, 306, 14, 15, 307, 16, -318, 17, 321, 324, 18, 322, 47, 19, 20, 21, -22, 326, 23, 24, 25, 26, 341, 27, 28, 327, -348, 351, 352, 357, 358, 359, 380, 29, 362, 107, -368, 47, 210, 111, 372, 30, 31, 47, 378, 385, -47, 47, 379, 47, 114, 115, 47, 47, 390, 391, -361, 336, 0, 0, 0, 63, 0, 0, 0, 47, -210, 0, 0, 0, 0, 0, 0, 0, 0, 47, -0, 47, 47, 0, 95, 96, 97, 98, 99, 0, -101, 102, 103, 104, 0, 0, 0, 107, 0, 47, -110, 111, 0, 0, 0, 0, 0, 0, 47, 210, -134, 0, 114, 115, 0, 137, 0, 0, 0, 0, -0, 0, 139, 47, 210, 0, 143, 0, 0, 0, -147, 148, 0, 150, 151, 152, 0, 0, 153, 154, -155, 156, 157, 158, 159, 160, 161, 162, 163, 0, -165, 47, 210, 0, 0, 0, 0, 0, 170, 171, -172, 173, 174, 175, 0, 177, 178, 179, 165, 181, -182, 0, 0, 185, 186, 187, 188, 189, 190, 191, -192, 193, 194, 195, 197, 0, 0, 0, 0, 0, -0, 0, 205, 205, 59, 0, 3, 4, 5, 213, -6, 0, 7, 217, 8, 9, 10, 0, 0, 0, -0, 11, 12, 13, 0, 14, 15, 0, 16, 0, -0, 0, 0, 18, 0, 0, 19, 20, 21, 22, -0, 23, 24, 25, 26, 0, 27, 28, 0, 0, -0, 0, 0, 0, 0, 0, 29, 0, 0, 0, -0, 66, 0, 165, 30, 31, 0, 0, 0, 0, -205, 0, 59, 0, 3, 4, 60, 0, 247, 249, -0, 252, 253, 254, 0, 0, 0, 0, 0, 0, -0, 0, 261, 0, 262, 0, 0, 265, 165, 165, -163, 18, 269, 0, 19, 61, 21, 22, 0, 0, -24, 25, 26, 0, 27, 28, 0, 284, 286, 0, -0, 0, 0, 0, 29, 0, 0, 0, 62, 0, -297, 0, 30, 31, 0, 0, 0, 0, 59, 0, -3, 4, 5, 165, 6, 0, 7, 0, 8, 9, -10, 0, 0, 0, 315, 11, 12, 13, 320, 14, -15, 0, 16, 0, 0, 0, 0, 18, 0, 0, -19, 20, 21, 22, 0, 23, 24, 25, 26, 0, -27, 28, 0, 0, 0, 0, 0, 0, 0, 0, -29, 0, 0, 0, 0, 78, 209, 0, 30, 31, -0, 0, 0, 0, 0, 354, 0, 0, 0, 0, -0, 0, 0, 79, 80, 363, 364, 163, 81, 82, -83, 84, 85, 86, 87, 88, 89, 90, 0, 0, -0, 0, 0, 376, 163, 0, 0, 91, 59, 0, -3, 4, 5, 0, 6, 0, 7, 384, 8, 9, -10, 0, 387, 0, 0, 11, 12, 13, 0, 14, -15, 0, 16, 0, 0, 0, 0, 18, 0, 0, -19, 20, 21, 22, 0, 23, 24, 25, 26, 0, -27, 28, 0, 59, 0, 3, 4, 5, 0, 6, -29, 7, 0, 8, 9, 10, 303, 0, 30, 31, -11, 12, 13, 0, 14, 15, 0, 16, 0, 0, -0, 0, 18, 0, 0, 19, 20, 21, 22, 0, -23, 24, 25, 26, 0, 27, 28, 0, 59, 0, -3, 4, 5, 0, 6, 29, 7, 0, 8, 9, -10, 323, 0, 30, 31, 11, 12, 13, 0, 14, -15, 0, 16, 0, 0, 0, 0, 18, 0, 0, -19, 20, 21, 22, 0, 23, 24, 25, 26, 0, -27, 28, 0, 59, 0, 3, 4, 5, 0, 6, -29, 7, 0, 8, 9, 10, 356, 0, 30, 31, -11, 12, 13, 0, 14, 15, 0, 16, 0, 0, -0, 0, 18, 0, 0, 19, 20, 21, 22, 0, -23, 24, 25, 26, 0, 27, 28, 59, 0, 3, -4, 60, 0, 0, 0, 29, 0, 0, 0, 0, -0, 0, 0, 30, 31, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 18, 0, 0, 19, -61, 21, 22, 0, 0, 24, 25, 26, 0, 27, -28, 59, 0, 3, 4, 60, 0, 0, 0, 29, -0, 0, 0, 142, 0, 0, 0, 30, 31, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, 0, 0, 19, 61, 21, 22, 0, 0, 24, -25, 26, 0, 27, 28, 59, 0, 3, 4, 60, -0, 0, 0, 29, 0, 0, 0, 0, 196, 0, -0, 30, 31, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 18, 0, 0, 19, 61, 21, -22, 0, 0, 24, 25, 26, 0, 27, 28, 59, -0, 3, 4, 60, 0, 0, 0, 29, 0, 0, -0, 212, 0, 0, 0, 30, 31, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 18, 0, -0, 19, 61, 21, 22, 0, 0, 24, 25, 26, -0, 27, 28, 59, 0, 3, 4, 60, 0, 0, -0, 29, 248, 0, 0, 0, 0, 0, 0, 30, -31, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 18, 0, 0, 19, 61, 21, 22, 0, -0, 24, 25, 26, 0, 27, 28, 59, 0, 3, -4, 60, 0, 0, 0, 29, 0, 0, 0, 251, -0, 0, 0, 30, 31, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 18, 0, 0, 19, -61, 21, 22, 0, 0, 24, 25, 26, 0, 27, -28, 59, 0, 3, 4, 60, 0, 0, 0, 29, -283, 0, 0, 0, 0, 0, 0, 30, 31, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -18, 0, 0, 19, 61, 21, 22, 0, 0, 24, -25, 26, 0, 27, 28, 59, 0, 3, 4, 60, -0, 0, 0, 29, 285, 0, 0, 0, 0, 0, -0, 30, 31, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 18, 0, 0, 19, 61, 21, -22, 0, 0, 24, 25, 26, 0, 27, 28, 59, -0, 3, 4, 60, 0, 0, 0, 29, 314, 0, -0, 0, 0, 0, 0, 30, 31, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 18, 0, -0, 19, 61, 21, 22, 0, 0, 24, 25, 26, -0, 27, 28, 0, 0, 101, 102, 103, 104, 105, -106, 29, 107, 108, 109, 110, 111, 223, 224, 30, -31, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 0, 225, 0, 226, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 0, 0, 0, 138, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 169, -0, 0, 0, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 0, 0, 0, 0, 0, 125, -126, 101, 102, 103, 104, 105, 106, 0, 107, 108, -109, 110, 111, 202, 0, 0, 0, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 122, 123, 124, 0, 0, -0, 0, 0, 125, 126, 101, 102, 103, 104, 105, -106, 0, 107, 108, 109, 110, 111, 207, 0, 0, -0, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 208, 0, 0, 0, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 0, 0, 0, 214, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 218, -0, 0, 0, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 0, 0, 0, 0, 0, 125, -126, 101, 102, 103, 104, 105, 106, 0, 107, 108, -109, 110, 111, 219, 0, 0, 0, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 122, 123, 124, 0, 0, -0, 0, 0, 125, 126, 101, 102, 103, 104, 105, -106, 0, 107, 108, 109, 110, 111, 0, 0, 235, -0, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 0, 0, 0, 250, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 0, 0, 242, 0, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 280, -0, 0, 0, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 0, 0, 0, 0, 0, 125, -126, 101, 102, 103, 104, 105, 106, 0, 107, 108, -109, 110, 111, 282, 0, 0, 0, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 122, 123, 124, 0, 0, -0, 0, 0, 125, 126, 101, 102, 103, 104, 105, -106, 0, 107, 108, 109, 110, 111, 0, 0, 0, -287, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 288, 0, 0, 0, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 289, 0, 0, 0, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 0, -0, 0, 296, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 0, 0, 0, 0, 0, 125, -126, 101, 102, 103, 104, 105, 106, 0, 107, 108, -109, 110, 111, 311, 0, 0, 0, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 122, 123, 124, 0, 0, -0, 0, 0, 125, 126, 101, 102, 103, 104, 105, -106, 0, 107, 108, 109, 110, 111, 313, 0, 0, -0, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 331, 0, 0, 0, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 0, 0, 0, 373, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 0, -0, 0, 374, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 0, 0, 0, 0, 0, 125, -126, 101, 102, 103, 104, 105, 106, 0, 107, 108, -109, 110, 111, 0, 0, 0, 381, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 122, 123, 124, 0, 0, -0, 0, 0, 125, 126, 101, 102, 103, 104, 105, -106, 0, 107, 108, 109, 110, 111, 0, 0, 0, -386, 0, 0, 112, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 122, -123, 124, 0, 0, 0, 0, 0, 125, 126, 101, -102, 103, 104, 105, 106, 0, 107, 108, 109, 110, -111, 0, 0, 0, 388, 0, 0, 112, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 118, -119, 120, 121, 122, 123, 124, 0, 0, 0, 0, -0, 125, 126, 101, 102, 103, 104, 105, 106, 0, -107, 108, 109, 110, 111, 0, 0, 0, 0, 0, -0, 112, 0, 0, 113, 114, 115, 0, 0, 0, -116, 117, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 118, 119, 120, 121, 122, 123, 124, -0, 0, 0, 0, 0, 125, 126, 101, 102, 103, -104, 105, 106, 0, 107, 108, 109, 110, 111, 0, -0, 0, 0, 0, 0, 112, 0, 0, 113, 114, -115, 0, 0, 0, 116, 117, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 118, 119, 120, -121, 122, 123, 124, 101, 102, 103, 104, 105, 106, -126, 107, 108, 109, 110, 111, 0, 0, 0, 0, -0, 0, 112, 0, 0, 113, 114, 115, 0, 0, -0, 116, 117, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 118, 119, 120, 121, 122, 0, -124, 101, 102, 103, 104, 105, 106, 126, 107, 108, -109, 110, 111, 0, 0, 0, 0, 0, 0, 112, -0, 0, 113, 114, 115, 0, 0, 0, 116, 117, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 118, 119, 120, 121, 0, 0, 124, 101, 102, -103, 104, 105, 106, 126, 107, 0, 109, 110, 111, -0, 0, 0, 0, 0, 0, 112, 0, 0, 113, -114, 115, 0, 0, 0, 116, 117, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 118, 119, -120, 121, 0, 0, 124, 101, 102, 103, 104, 105, -106, 126, 107, 0, 109, 110, 111, 0, 0, 0, -0, 0, 0, 0, 0, 0, 113, 114, 115, 0, -0, 0, 116, 117, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 118, 119, 120, 121, 0, -0, 124, 101, 102, 103, 104, 105, 106, 126, 107, -0, 0, 110, 111, 0, 0, 0, 0, 0, 0, -0, 0, 0, 113, 114, 115, 0, 0, 0, 116, -117, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 118, 119, 120, 121, 0, 0, 124, 101, -102, 103, 104, 105, 106, 126, 107, 0, 0, 110, -111, 0, 0, 0, 0, 0, 0, 0, 0, 0, -113, 114, 115, 0, 0, 0, 116, 117, 101, 102, -103, 104, 0, 0, 0, 107, 0, 0, 110, 111, -127, 120, 121, 0, 0, 124, 0, 0, 0, 113, -114, 115, 126, 0, 0, 116, 117, 0, 79, 80, -263, 0, 0, 81, 82, 83, 84, 85, 86, 87, -88, 89, 90, 0, 124, 0, 0, 0, 79, 80, -0, 126, 0, 81, 82, 83, 84, 85, 86, 87, -88, 89, 90 +static const short yytable[] = { 47, + 34, 125, 283, 214, 199, 291, 227, 50, 47, 219, + 219, 234, 268, 76, 338, 57, 2, 355, 219, 219, + 342, 224, 245, 54, 327, 63, 91, 126, 67, 342, + 51, 77, 78, 70, 335, 258, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 61, 52, 3, 4, + 58, 220, 290, 55, 328, 89, 339, 329, 225, 356, + 364, 371, 92, 127, 360, 93, 94, 95, 96, 97, + 231, 314, 344, 249, 248, 18, 293, 105, 19, 59, + 21, 22, 321, 294, 24, 25, 26, 56, 27, 28, + 128, 68, 111, 112, 69, 131, 322, 323, 29, 359, + 71, 133, 3, 4, 222, 137, 30, 31, 260, 141, + 142, 372, 144, 145, 146, 256, 257, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 72, 159, + 176, 177, 47, 203, 73, 196, 74, 164, 165, 166, + 167, 168, 169, 75, 171, 172, 173, 174, 175, 354, + 98, 178, 179, 180, 181, 182, 183, 184, 185, 186, + 187, 188, 190, -74, 129, 130, 366, 198, 198, 135, + 3, 4, 58, 138, 206, 139, 254, 140, 210, 143, + 162, 170, 191, 204, 194, 208, 331, 331, 2, 209, + 221, 232, 222, 228, 223, 230, 262, 18, 47, 47, + 19, 59, 21, 22, 349, 331, 24, 25, 26, 229, + 27, 28, 250, 246, 247, 264, 261, 331, 3, 4, + 29, 349, 265, 269, 60, 266, 280, 159, 30, 31, + 235, 236, 281, 284, 198, 285, 47, 321, 288, 289, + 307, 313, 237, 239, 292, 242, 243, 244, 295, 296, + 310, 322, 323, 330, 315, 251, 311, 252, 316, 337, + 255, 159, 159, 157, 259, 340, 341, 47, 271, 347, + 47, 47, 346, 47, 367, 348, 47, 47, 274, 276, + 351, 357, 361, 369, 374, 368, 379, 380, 350, 47, + 203, 287, 263, 325, 0, 0, 0, 0, 47, 297, + 47, 47, 298, 299, 159, 301, 0, 0, 305, 306, + 0, 0, 0, 0, 0, 304, 0, 0, 47, 309, + 0, 0, 3, 4, 58, 0, 0, 47, 203, 0, + 317, 0, 318, 319, 99, 100, 101, 102, 0, 0, + 0, 105, 47, 203, 108, 0, 0, 0, 0, 18, + 336, 0, 19, 59, 21, 22, 111, 112, 24, 25, + 26, 0, 27, 28, 0, 343, 0, 0, 0, 0, + 47, 203, 29, 238, 0, 352, 353, 157, 0, 0, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 365, 157, 0, 0, 0, 2, 0, + 3, 4, 5, 0, 6, 0, 7, 373, 8, 9, + 10, 0, 376, 0, 0, 11, 12, 13, 0, 14, + 15, 0, 16, 0, 17, 0, 0, 18, 0, 0, + 19, 20, 21, 22, 0, 23, 24, 25, 26, 0, + 27, 28, 0, 0, 0, 0, 0, 3, 4, 5, + 29, 6, 0, 7, 0, 8, 9, 10, 30, 31, + 0, 358, 11, 12, 13, 0, 14, 15, 281, 16, + 0, 0, 0, 0, 18, 0, 0, 19, 20, 21, + 22, 0, 23, 24, 25, 26, 0, 27, 28, 0, + 0, 0, 3, 4, 5, 0, 6, 29, 7, 0, + 8, 9, 10, 0, 0, 30, 31, 11, 12, 13, + 0, 14, 15, 0, 16, 0, 0, 0, 0, 18, + 0, 0, 19, 20, 21, 22, 0, 23, 24, 25, + 26, 0, 27, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 29, 0, 0, 0, 0, 64, 0, 0, + 30, 31, 3, 4, 5, 0, 6, 0, 7, 0, + 8, 9, 10, 0, 0, 0, 0, 11, 12, 13, + 0, 14, 15, 0, 16, 0, 0, 0, 0, 18, + 0, 0, 19, 20, 21, 22, 0, 23, 24, 25, + 26, 0, 27, 28, 0, 0, 0, 3, 4, 5, + 0, 6, 29, 7, 0, 8, 9, 10, 202, 0, + 30, 31, 11, 12, 13, 0, 14, 15, 0, 16, + 0, 0, 0, 0, 18, 0, 0, 19, 20, 21, + 22, 0, 23, 24, 25, 26, 0, 27, 28, 0, + 0, 0, 3, 4, 5, 0, 6, 29, 7, 0, + 8, 9, 10, 312, 0, 30, 31, 11, 12, 13, + 0, 14, 15, 0, 16, 0, 0, 0, 0, 18, + 0, 0, 19, 20, 21, 22, 0, 23, 24, 25, + 26, 0, 27, 28, 0, 0, 0, 3, 4, 5, + 0, 6, 29, 7, 0, 8, 9, 10, 345, 0, + 30, 31, 11, 12, 13, 0, 14, 15, 0, 16, + 0, 3, 4, 58, 18, 0, 0, 19, 20, 21, + 22, 0, 23, 24, 25, 26, 0, 27, 28, 0, + 0, 0, 0, 0, 0, 0, 0, 29, 18, 0, + 0, 19, 59, 21, 22, 30, 31, 24, 25, 26, + 0, 27, 28, 3, 4, 58, 0, 0, 101, 102, + 0, 29, 0, 105, 0, 136, 108, 0, 0, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 111, 112, + 18, 0, 0, 19, 59, 21, 22, 0, 0, 24, + 25, 26, 0, 27, 28, 3, 4, 58, 0, 0, + 0, 0, 0, 29, 0, 0, 0, 0, 189, 0, + 0, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 0, 19, 59, 21, 22, 0, + 0, 24, 25, 26, 0, 27, 28, 3, 4, 58, + 0, 0, 0, 0, 0, 29, 0, 0, 0, 205, + 0, 0, 0, 30, 31, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 18, 0, 0, 19, 59, 21, + 22, 0, 0, 24, 25, 26, 0, 27, 28, 3, + 4, 58, 0, 0, 0, 0, 0, 29, 0, 0, + 0, 241, 0, 0, 0, 30, 31, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 19, + 59, 21, 22, 0, 0, 24, 25, 26, 0, 27, + 28, 3, 4, 58, 0, 0, 0, 0, 0, 29, + 273, 0, 0, 0, 0, 0, 0, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, + 0, 19, 59, 21, 22, 0, 0, 24, 25, 26, + 0, 27, 28, 3, 4, 58, 0, 0, 0, 0, + 0, 29, 275, 0, 0, 0, 0, 0, 0, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 18, 0, 0, 19, 59, 21, 22, 0, 0, 24, + 25, 26, 0, 27, 28, 3, 4, 58, 0, 0, + 0, 0, 0, 29, 303, 0, 0, 0, 0, 0, + 0, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 18, 0, 0, 19, 59, 21, 22, 0, + 0, 24, 25, 26, 0, 27, 28, 0, 0, 99, + 100, 101, 102, 103, 104, 29, 105, 106, 107, 108, + 0, 215, 216, 30, 31, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 0, 217, 0, 218, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 0, + 0, 0, 132, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 163, 0, 0, 0, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 115, 116, 117, 118, 119, 120, 121, 0, 0, + 0, 0, 0, 122, 123, 99, 100, 101, 102, 103, + 104, 0, 105, 106, 107, 108, 0, 195, 0, 0, + 0, 0, 0, 109, 0, 0, 110, 111, 112, 0, + 0, 0, 113, 114, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 0, 0, 0, 122, 123, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 0, 200, 0, 0, 0, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 201, 0, 0, 0, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 0, + 0, 0, 207, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 211, 0, 0, 0, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 115, 116, 117, 118, 119, 120, 121, 0, 0, + 0, 0, 0, 122, 123, 99, 100, 101, 102, 103, + 104, 0, 105, 106, 107, 108, 0, 212, 0, 0, + 0, 0, 0, 109, 0, 0, 110, 111, 112, 0, + 0, 0, 113, 114, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 0, 0, 0, 122, 123, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 0, 0, 0, 226, 0, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 0, 0, 0, 240, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 0, + 0, 232, 0, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 270, 0, 0, 0, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 115, 116, 117, 118, 119, 120, 121, 0, 0, + 0, 0, 0, 122, 123, 99, 100, 101, 102, 103, + 104, 0, 105, 106, 107, 108, 0, 272, 0, 0, + 0, 0, 0, 109, 0, 0, 110, 111, 112, 0, + 0, 0, 113, 114, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 0, 0, 0, 122, 123, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 0, 0, 0, 0, 277, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 278, 0, 0, 0, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 279, + 0, 0, 0, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 0, 0, 0, 286, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 115, 116, 117, 118, 119, 120, 121, 0, 0, + 0, 0, 0, 122, 123, 99, 100, 101, 102, 103, + 104, 0, 105, 106, 107, 108, 0, 300, 0, 0, + 0, 0, 0, 109, 0, 0, 110, 111, 112, 0, + 0, 0, 113, 114, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 0, 0, 0, 122, 123, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 0, 302, 0, 0, 0, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 320, 0, 0, 0, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 0, + 0, 0, 362, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 0, 0, 0, 363, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 115, 116, 117, 118, 119, 120, 121, 0, 0, + 0, 0, 0, 122, 123, 99, 100, 101, 102, 103, + 104, 0, 105, 106, 107, 108, 0, 0, 0, 0, + 370, 0, 0, 109, 0, 0, 110, 111, 112, 0, + 0, 0, 113, 114, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 115, 116, 117, 118, 119, + 120, 121, 0, 0, 0, 0, 0, 122, 123, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 0, 0, 0, 0, 375, 0, 0, 109, 0, 0, + 110, 111, 112, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, + 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, + 0, 122, 123, 99, 100, 101, 102, 103, 104, 0, + 105, 106, 107, 108, 0, 0, 0, 0, 377, 0, + 0, 109, 0, 0, 110, 111, 112, 0, 0, 0, + 113, 114, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 115, 116, 117, 118, 119, 120, 121, + 0, 0, 0, 0, 0, 122, 123, 99, 100, 101, + 102, 103, 104, 0, 105, 106, 107, 108, 0, 0, + 0, 0, 0, 0, 0, 109, 0, 0, 110, 111, + 112, 0, 0, 0, 113, 114, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 115, 116, 117, + 118, 119, 120, 121, 0, 0, 0, 0, 0, 122, + 123, 99, 100, 101, 102, 103, 104, 0, 105, 106, + 107, 108, 0, 0, 0, 0, 0, 0, 0, 109, + 0, 0, 110, 111, 112, 0, 0, 0, 113, 114, + 99, 100, 101, 102, 103, 104, 0, 105, 106, 107, + 108, 115, 116, 117, 118, 119, 120, 121, 109, 0, + 0, 110, 111, 112, 123, 0, 0, 113, 114, 99, + 100, 101, 102, 103, 104, 0, 105, 106, 107, 108, + 115, 116, 117, 118, 119, 0, 121, 109, 0, 0, + 110, 111, 112, 123, 0, 0, 113, 114, 99, 100, + 101, 102, 103, 104, 0, 105, 0, 107, 108, 115, + 116, 117, 118, 0, 0, 121, 109, 0, 0, 110, + 111, 112, 123, 0, 0, 113, 114, 99, 100, 101, + 102, 103, 104, 0, 105, 0, 107, 108, 115, 116, + 117, 118, 0, 0, 121, 0, 0, 0, 110, 111, + 112, 123, 0, 0, 113, 114, 99, 100, 101, 102, + 103, 104, 0, 105, 0, 0, 108, 115, 116, 117, + 118, 0, 0, 121, 0, 0, 0, 110, 111, 112, + 123, 0, 0, 113, 114, 99, 100, 101, 102, 103, + 104, 0, 105, 0, 0, 108, 115, 116, 117, 118, + 0, 0, 121, 0, 0, 0, 110, 111, 112, 123, + 0, 0, 113, 114, 99, 100, 101, 102, 0, 0, + 0, 105, 0, 0, 108, 124, 0, 117, 118, 0, + 0, 121, 0, 0, 0, 110, 111, 112, 123, 0, + 0, 113, 114, 77, 78, 253, 0, 0, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 0, 0, + 121, 0, 0, 77, 78, 0, 0, 123, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 99, 100, + 101, 102, 0, 0, 0, 105, 0, 0, 108, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 111, 112, 0, 0, 0, 113, 114 }; -static const short yycheck[] = { 1, -1, 45, 239, 233, 207, 208, 111, 4, 10, 257, -129, 196, 244, 206, 55, 3, 149, 14, 57, 326, -327, 59, 136, 3, 217, 5, 6, 7, 57, 50, -38, 55, 50, 59, 271, 57, 55, 344, 345, 28, -336, 55, 55, 5, 6, 248, 38, 55, 57, 345, -357, 92, 32, 59, 361, 35, 36, 37, 38, 55, -99, 41, 42, 43, 327, 45, 46, 91, 55, 58, -99, 92, 304, 61, 92, 55, 279, 99, 91, 282, -283, 274, 285, 63, 64, 288, 289, 324, 221, 203, -99, 276, 38, 59, 357, 55, 5, 6, 37, 24, -57, 55, 339, 55, 61, 55, 50, 355, 311, 55, -313, 314, 92, 38, 39, 24, 14, 114, 115, 238, -350, 55, 55, 55, 37, 37, 231, 232, 331, 38, -39, 55, 60, 38, 38, 38, 56, 367, 140, 140, -3, 378, 5, 6, 7, 23, 9, 57, 11, 55, -13, 14, 15, 23, 3, 56, 19, 20, 21, 22, -57, 24, 25, 26, 27, 55, 60, 56, 56, 32, -55, 37, 35, 36, 37, 38, 58, 40, 41, 42, -43, 60, 45, 46, 228, 60, 44, 45, 46, 47, -46, 47, 55, 51, 38, 51, 54, 55, 54, 55, -63, 64, 41, 60, 99, 207, 208, 38, 66, 67, -66, 67, 57, 71, 72, 3, 8, 5, 6, 7, -56, 9, 26, 11, 59, 13, 14, 15, 56, 56, -56, 56, 20, 21, 22, 56, 24, 25, 56, 27, -60, 29, 61, 60, 32, 61, 248, 35, 36, 37, -38, 60, 40, 41, 42, 43, 56, 45, 46, 60, -50, 38, 61, 60, 59, 61, 50, 55, 61, 51, -59, 273, 273, 55, 59, 63, 64, 279, 58, 50, -282, 283, 61, 285, 66, 67, 288, 289, 0, 0, -345, 318, -1, -1, -1, 8, -1, -1, -1, 301, -301, -1, -1, -1, -1, -1, -1, -1, -1, 311, --1, 313, 314, -1, 27, 28, 29, 30, 31, -1, -44, 45, 46, 47, -1, -1, -1, 51, -1, 331, -54, 55, -1, -1, -1, -1, -1, -1, 340, 340, -53, -1, 66, 67, -1, 58, -1, -1, -1, -1, --1, -1, 65, 355, 355, -1, 69, -1, -1, -1, -73, 74, -1, 76, 77, 78, -1, -1, 81, 82, -83, 84, 85, 86, 87, 88, 89, 90, 91, -1, -93, 383, 383, -1, -1, -1, -1, -1, 101, 102, -103, 104, 105, 106, -1, 108, 109, 110, 111, 112, -113, -1, -1, 116, 117, 118, 119, 120, 121, 122, -123, 124, 125, 126, 127, -1, -1, -1, -1, -1, --1, -1, 135, 136, 3, -1, 5, 6, 7, 142, -9, -1, 11, 146, 13, 14, 15, -1, -1, -1, --1, 20, 21, 22, -1, 24, 25, -1, 27, -1, --1, -1, -1, 32, -1, -1, 35, 36, 37, 38, --1, 40, 41, 42, 43, -1, 45, 46, -1, -1, --1, -1, -1, -1, -1, -1, 55, -1, -1, -1, --1, 60, -1, 196, 63, 64, -1, -1, -1, -1, -203, -1, 3, -1, 5, 6, 7, -1, 211, 212, --1, 214, 215, 216, -1, -1, -1, -1, -1, -1, --1, -1, 225, -1, 227, -1, -1, 230, 231, 232, -233, 32, 235, -1, 35, 36, 37, 38, -1, -1, -41, 42, 43, -1, 45, 46, -1, 250, 251, -1, --1, -1, -1, -1, 55, -1, -1, -1, 59, -1, -263, -1, 63, 64, -1, -1, -1, -1, 3, -1, -5, 6, 7, 276, 9, -1, 11, -1, 13, 14, -15, -1, -1, -1, 287, 20, 21, 22, 291, 24, -25, -1, 27, -1, -1, -1, -1, 32, -1, -1, -35, 36, 37, 38, -1, 40, 41, 42, 43, -1, -45, 46, -1, -1, -1, -1, -1, -1, -1, -1, -55, -1, -1, -1, -1, 50, 61, -1, 63, 64, --1, -1, -1, -1, -1, 338, -1, -1, -1, -1, --1, -1, -1, 68, 69, 348, 349, 350, 73, 74, -75, 76, 77, 78, 79, 80, 81, 82, -1, -1, --1, -1, -1, 366, 367, -1, -1, 92, 3, -1, -5, 6, 7, -1, 9, -1, 11, 380, 13, 14, -15, -1, 385, -1, -1, 20, 21, 22, -1, 24, -25, -1, 27, -1, -1, -1, -1, 32, -1, -1, -35, 36, 37, 38, -1, 40, 41, 42, 43, -1, -45, 46, -1, 3, -1, 5, 6, 7, -1, 9, -55, 11, -1, 13, 14, 15, 61, -1, 63, 64, -20, 21, 22, -1, 24, 25, -1, 27, -1, -1, --1, -1, 32, -1, -1, 35, 36, 37, 38, -1, -40, 41, 42, 43, -1, 45, 46, -1, 3, -1, -5, 6, 7, -1, 9, 55, 11, -1, 13, 14, -15, 61, -1, 63, 64, 20, 21, 22, -1, 24, -25, -1, 27, -1, -1, -1, -1, 32, -1, -1, -35, 36, 37, 38, -1, 40, 41, 42, 43, -1, -45, 46, -1, 3, -1, 5, 6, 7, -1, 9, -55, 11, -1, 13, 14, 15, 61, -1, 63, 64, -20, 21, 22, -1, 24, 25, -1, 27, -1, -1, --1, -1, 32, -1, -1, 35, 36, 37, 38, -1, -40, 41, 42, 43, -1, 45, 46, 3, -1, 5, -6, 7, -1, -1, -1, 55, -1, -1, -1, -1, --1, -1, -1, 63, 64, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, 32, -1, -1, 35, -36, 37, 38, -1, -1, 41, 42, 43, -1, 45, -46, 3, -1, 5, 6, 7, -1, -1, -1, 55, --1, -1, -1, 59, -1, -1, -1, 63, 64, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -32, -1, -1, 35, 36, 37, 38, -1, -1, 41, -42, 43, -1, 45, 46, 3, -1, 5, 6, 7, --1, -1, -1, 55, -1, -1, -1, -1, 60, -1, --1, 63, 64, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, 32, -1, -1, 35, 36, 37, -38, -1, -1, 41, 42, 43, -1, 45, 46, 3, --1, 5, 6, 7, -1, -1, -1, 55, -1, -1, --1, 59, -1, -1, -1, 63, 64, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, 32, -1, --1, 35, 36, 37, 38, -1, -1, 41, 42, 43, --1, 45, 46, 3, -1, 5, 6, 7, -1, -1, --1, 55, 56, -1, -1, -1, -1, -1, -1, 63, -64, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, 32, -1, -1, 35, 36, 37, 38, -1, --1, 41, 42, 43, -1, 45, 46, 3, -1, 5, -6, 7, -1, -1, -1, 55, -1, -1, -1, 59, --1, -1, -1, 63, 64, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, 32, -1, -1, 35, -36, 37, 38, -1, -1, 41, 42, 43, -1, 45, -46, 3, -1, 5, 6, 7, -1, -1, -1, 55, -56, -1, -1, -1, -1, -1, -1, 63, 64, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -32, -1, -1, 35, 36, 37, 38, -1, -1, 41, -42, 43, -1, 45, 46, 3, -1, 5, 6, 7, --1, -1, -1, 55, 56, -1, -1, -1, -1, -1, --1, 63, 64, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, 32, -1, -1, 35, 36, 37, -38, -1, -1, 41, 42, 43, -1, 45, 46, 3, --1, 5, 6, 7, -1, -1, -1, 55, 56, -1, --1, -1, -1, -1, -1, 63, 64, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, 32, -1, --1, 35, 36, 37, 38, -1, -1, 41, 42, 43, --1, 45, 46, -1, -1, 44, 45, 46, 47, 48, -49, 55, 51, 52, 53, 54, 55, 56, 57, 63, -64, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, -1, 57, -1, 59, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, -1, -1, -1, 59, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, 56, --1, -1, -1, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, -1, -1, -1, -1, -1, 96, -97, 44, 45, 46, 47, 48, 49, -1, 51, 52, -53, 54, 55, 56, -1, -1, -1, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, 88, 89, 90, -1, -1, --1, -1, -1, 96, 97, 44, 45, 46, 47, 48, -49, -1, 51, 52, 53, 54, 55, 56, -1, -1, --1, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, 56, -1, -1, -1, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, -1, -1, -1, 59, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, 56, --1, -1, -1, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, -1, -1, -1, -1, -1, 96, -97, 44, 45, 46, 47, 48, 49, -1, 51, 52, -53, 54, 55, 56, -1, -1, -1, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, 88, 89, 90, -1, -1, --1, -1, -1, 96, 97, 44, 45, 46, 47, 48, -49, -1, 51, 52, 53, 54, 55, -1, -1, 58, --1, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, -1, -1, -1, 59, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, -1, -1, 58, -1, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, 56, --1, -1, -1, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, -1, -1, -1, -1, -1, 96, -97, 44, 45, 46, 47, 48, 49, -1, 51, 52, -53, 54, 55, 56, -1, -1, -1, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, 88, 89, 90, -1, -1, --1, -1, -1, 96, 97, 44, 45, 46, 47, 48, -49, -1, 51, 52, 53, 54, 55, -1, -1, -1, -59, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, 56, -1, -1, -1, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, 56, -1, -1, -1, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, -1, --1, -1, 59, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, -1, -1, -1, -1, -1, 96, -97, 44, 45, 46, 47, 48, 49, -1, 51, 52, -53, 54, 55, 56, -1, -1, -1, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, 88, 89, 90, -1, -1, --1, -1, -1, 96, 97, 44, 45, 46, 47, 48, -49, -1, 51, 52, 53, 54, 55, 56, -1, -1, --1, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, 56, -1, -1, -1, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, -1, -1, -1, 59, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, -1, --1, -1, 59, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, -1, -1, -1, -1, -1, 96, -97, 44, 45, 46, 47, 48, 49, -1, 51, 52, -53, 54, 55, -1, -1, -1, 59, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, 88, 89, 90, -1, -1, --1, -1, -1, 96, 97, 44, 45, 46, 47, 48, -49, -1, 51, 52, 53, 54, 55, -1, -1, -1, -59, -1, -1, 62, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, 88, -89, 90, -1, -1, -1, -1, -1, 96, 97, 44, -45, 46, 47, 48, 49, -1, 51, 52, 53, 54, -55, -1, -1, -1, 59, -1, -1, 62, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, -1, 84, -85, 86, 87, 88, 89, 90, -1, -1, -1, -1, --1, 96, 97, 44, 45, 46, 47, 48, 49, -1, -51, 52, 53, 54, 55, -1, -1, -1, -1, -1, --1, 62, -1, -1, 65, 66, 67, -1, -1, -1, -71, 72, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, 84, 85, 86, 87, 88, 89, 90, --1, -1, -1, -1, -1, 96, 97, 44, 45, 46, -47, 48, 49, -1, 51, 52, 53, 54, 55, -1, --1, -1, -1, -1, -1, 62, -1, -1, 65, 66, -67, -1, -1, -1, 71, 72, -1, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, 84, 85, 86, -87, 88, 89, 90, 44, 45, 46, 47, 48, 49, -97, 51, 52, 53, 54, 55, -1, -1, -1, -1, --1, -1, 62, -1, -1, 65, 66, 67, -1, -1, --1, 71, 72, -1, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, 84, 85, 86, 87, 88, -1, -90, 44, 45, 46, 47, 48, 49, 97, 51, 52, -53, 54, 55, -1, -1, -1, -1, -1, -1, 62, --1, -1, 65, 66, 67, -1, -1, -1, 71, 72, --1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, 84, 85, 86, 87, -1, -1, 90, 44, 45, -46, 47, 48, 49, 97, 51, -1, 53, 54, 55, --1, -1, -1, -1, -1, -1, 62, -1, -1, 65, -66, 67, -1, -1, -1, 71, 72, -1, -1, -1, --1, -1, -1, -1, -1, -1, -1, -1, 84, 85, -86, 87, -1, -1, 90, 44, 45, 46, 47, 48, -49, 97, 51, -1, 53, 54, 55, -1, -1, -1, --1, -1, -1, -1, -1, -1, 65, 66, 67, -1, --1, -1, 71, 72, -1, -1, -1, -1, -1, -1, --1, -1, -1, -1, -1, 84, 85, 86, 87, -1, --1, 90, 44, 45, 46, 47, 48, 49, 97, 51, --1, -1, 54, 55, -1, -1, -1, -1, -1, -1, --1, -1, -1, 65, 66, 67, -1, -1, -1, 71, -72, -1, -1, -1, -1, -1, -1, -1, -1, -1, --1, -1, 84, 85, 86, 87, -1, -1, 90, 44, -45, 46, 47, 48, 49, 97, 51, -1, -1, 54, -55, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 66, 67, -1, -1, -1, 71, 72, 44, 45, -46, 47, -1, -1, -1, 51, -1, -1, 54, 55, -50, 86, 87, -1, -1, 90, -1, -1, -1, 65, -66, 67, 97, -1, -1, 71, 72, -1, 68, 69, -50, -1, -1, 73, 74, 75, 76, 77, 78, 79, -80, 81, 82, -1, 90, -1, -1, -1, 68, 69, --1, 97, -1, 73, 74, 75, 76, 77, 78, 79, -80, 81, 82 +static const short yycheck[] = { 1, + 1, 45, 247, 143, 130, 261, 189, 38, 10, 57, + 57, 199, 234, 50, 50, 55, 3, 50, 57, 57, + 325, 55, 210, 4, 28, 55, 55, 55, 55, 334, + 38, 68, 69, 14, 316, 225, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 8, 55, 5, 6, + 7, 99, 99, 59, 58, 92, 92, 313, 92, 92, + 99, 99, 91, 91, 346, 27, 28, 29, 30, 31, + 196, 293, 328, 213, 61, 32, 264, 51, 35, 36, + 37, 38, 24, 266, 41, 42, 43, 59, 45, 46, + 52, 55, 66, 67, 55, 57, 38, 39, 55, 344, + 55, 63, 5, 6, 57, 67, 63, 64, 61, 71, + 72, 367, 74, 75, 76, 223, 224, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 55, 91, + 111, 112, 134, 134, 38, 92, 55, 99, 100, 101, + 102, 103, 104, 50, 106, 107, 108, 109, 110, 339, + 59, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 123, 124, 59, 55, 55, 356, 129, 130, 14, + 5, 6, 7, 37, 136, 37, 220, 55, 140, 60, + 38, 38, 37, 55, 38, 23, 315, 316, 3, 23, + 56, 58, 57, 56, 55, 55, 37, 32, 200, 201, + 35, 36, 37, 38, 333, 334, 41, 42, 43, 57, + 45, 46, 41, 60, 60, 99, 60, 346, 5, 6, + 55, 350, 38, 8, 59, 57, 56, 189, 63, 64, + 200, 201, 26, 59, 196, 56, 238, 24, 56, 56, + 60, 60, 204, 205, 56, 207, 208, 209, 56, 56, + 61, 38, 39, 56, 60, 217, 61, 219, 60, 50, + 222, 223, 224, 225, 226, 38, 61, 269, 238, 59, + 272, 273, 60, 275, 58, 61, 278, 279, 240, 241, + 61, 59, 59, 50, 50, 61, 0, 0, 334, 291, + 291, 253, 230, 307, -1, -1, -1, -1, 300, 269, + 302, 303, 272, 273, 266, 275, -1, -1, 278, 279, + -1, -1, -1, -1, -1, 277, -1, -1, 320, 281, + -1, -1, 5, 6, 7, -1, -1, 329, 329, -1, + 300, -1, 302, 303, 44, 45, 46, 47, -1, -1, + -1, 51, 344, 344, 54, -1, -1, -1, -1, 32, + 320, -1, 35, 36, 37, 38, 66, 67, 41, 42, + 43, -1, 45, 46, -1, 327, -1, -1, -1, -1, + 372, 372, 55, 56, -1, 337, 338, 339, -1, -1, + 63, 64, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 355, 356, -1, -1, -1, 3, -1, + 5, 6, 7, -1, 9, -1, 11, 369, 13, 14, + 15, -1, 374, -1, -1, 20, 21, 22, -1, 24, + 25, -1, 27, -1, 29, -1, -1, 32, -1, -1, + 35, 36, 37, 38, -1, 40, 41, 42, 43, -1, + 45, 46, -1, -1, -1, -1, -1, 5, 6, 7, + 55, 9, -1, 11, -1, 13, 14, 15, 63, 64, + -1, 19, 20, 21, 22, -1, 24, 25, 26, 27, + -1, -1, -1, -1, 32, -1, -1, 35, 36, 37, + 38, -1, 40, 41, 42, 43, -1, 45, 46, -1, + -1, -1, 5, 6, 7, -1, 9, 55, 11, -1, + 13, 14, 15, -1, -1, 63, 64, 20, 21, 22, + -1, 24, 25, -1, 27, -1, -1, -1, -1, 32, + -1, -1, 35, 36, 37, 38, -1, 40, 41, 42, + 43, -1, 45, 46, -1, -1, -1, -1, -1, -1, + -1, -1, 55, -1, -1, -1, -1, 60, -1, -1, + 63, 64, 5, 6, 7, -1, 9, -1, 11, -1, + 13, 14, 15, -1, -1, -1, -1, 20, 21, 22, + -1, 24, 25, -1, 27, -1, -1, -1, -1, 32, + -1, -1, 35, 36, 37, 38, -1, 40, 41, 42, + 43, -1, 45, 46, -1, -1, -1, 5, 6, 7, + -1, 9, 55, 11, -1, 13, 14, 15, 61, -1, + 63, 64, 20, 21, 22, -1, 24, 25, -1, 27, + -1, -1, -1, -1, 32, -1, -1, 35, 36, 37, + 38, -1, 40, 41, 42, 43, -1, 45, 46, -1, + -1, -1, 5, 6, 7, -1, 9, 55, 11, -1, + 13, 14, 15, 61, -1, 63, 64, 20, 21, 22, + -1, 24, 25, -1, 27, -1, -1, -1, -1, 32, + -1, -1, 35, 36, 37, 38, -1, 40, 41, 42, + 43, -1, 45, 46, -1, -1, -1, 5, 6, 7, + -1, 9, 55, 11, -1, 13, 14, 15, 61, -1, + 63, 64, 20, 21, 22, -1, 24, 25, -1, 27, + -1, 5, 6, 7, 32, -1, -1, 35, 36, 37, + 38, -1, 40, 41, 42, 43, -1, 45, 46, -1, + -1, -1, -1, -1, -1, -1, -1, 55, 32, -1, + -1, 35, 36, 37, 38, 63, 64, 41, 42, 43, + -1, 45, 46, 5, 6, 7, -1, -1, 46, 47, + -1, 55, -1, 51, -1, 59, 54, -1, -1, 63, + 64, -1, -1, -1, -1, -1, -1, -1, 66, 67, + 32, -1, -1, 35, 36, 37, 38, -1, -1, 41, + 42, 43, -1, 45, 46, 5, 6, 7, -1, -1, + -1, -1, -1, 55, -1, -1, -1, -1, 60, -1, + -1, 63, 64, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 32, -1, -1, 35, 36, 37, 38, -1, + -1, 41, 42, 43, -1, 45, 46, 5, 6, 7, + -1, -1, -1, -1, -1, 55, -1, -1, -1, 59, + -1, -1, -1, 63, 64, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 32, -1, -1, 35, 36, 37, + 38, -1, -1, 41, 42, 43, -1, 45, 46, 5, + 6, 7, -1, -1, -1, -1, -1, 55, -1, -1, + -1, 59, -1, -1, -1, 63, 64, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, -1, -1, 35, + 36, 37, 38, -1, -1, 41, 42, 43, -1, 45, + 46, 5, 6, 7, -1, -1, -1, -1, -1, 55, + 56, -1, -1, -1, -1, -1, -1, 63, 64, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, + -1, 35, 36, 37, 38, -1, -1, 41, 42, 43, + -1, 45, 46, 5, 6, 7, -1, -1, -1, -1, + -1, 55, 56, -1, -1, -1, -1, -1, -1, 63, + 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 32, -1, -1, 35, 36, 37, 38, -1, -1, 41, + 42, 43, -1, 45, 46, 5, 6, 7, -1, -1, + -1, -1, -1, 55, 56, -1, -1, -1, -1, -1, + -1, 63, 64, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 32, -1, -1, 35, 36, 37, 38, -1, + -1, 41, 42, 43, -1, 45, 46, -1, -1, 44, + 45, 46, 47, 48, 49, 55, 51, 52, 53, 54, + -1, 56, 57, 63, 64, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, -1, 57, -1, 59, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, -1, + -1, -1, 59, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, 56, -1, -1, -1, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, 96, 97, 44, 45, 46, 47, 48, + 49, -1, 51, 52, 53, 54, -1, 56, -1, -1, + -1, -1, -1, 62, -1, -1, 65, 66, 67, -1, + -1, -1, 71, 72, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, 86, 87, 88, + 89, 90, -1, -1, -1, -1, -1, 96, 97, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + -1, 56, -1, -1, -1, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, 56, -1, -1, -1, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, -1, + -1, -1, 59, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, 56, -1, -1, -1, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, 96, 97, 44, 45, 46, 47, 48, + 49, -1, 51, 52, 53, 54, -1, 56, -1, -1, + -1, -1, -1, 62, -1, -1, 65, 66, 67, -1, + -1, -1, 71, 72, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, 86, 87, 88, + 89, 90, -1, -1, -1, -1, -1, 96, 97, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + -1, -1, -1, 58, -1, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, -1, -1, -1, 59, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, -1, + -1, 58, -1, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, 56, -1, -1, -1, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, 96, 97, 44, 45, 46, 47, 48, + 49, -1, 51, 52, 53, 54, -1, 56, -1, -1, + -1, -1, -1, 62, -1, -1, 65, 66, 67, -1, + -1, -1, 71, 72, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, 86, 87, 88, + 89, 90, -1, -1, -1, -1, -1, 96, 97, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + -1, -1, -1, -1, 59, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, 56, -1, -1, -1, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, 56, + -1, -1, -1, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, -1, -1, -1, 59, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, 96, 97, 44, 45, 46, 47, 48, + 49, -1, 51, 52, 53, 54, -1, 56, -1, -1, + -1, -1, -1, 62, -1, -1, 65, 66, 67, -1, + -1, -1, 71, 72, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, 86, 87, 88, + 89, 90, -1, -1, -1, -1, -1, 96, 97, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + -1, 56, -1, -1, -1, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, 56, -1, -1, -1, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, -1, + -1, -1, 59, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, -1, -1, -1, 59, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 84, 85, 86, 87, 88, 89, 90, -1, -1, + -1, -1, -1, 96, 97, 44, 45, 46, 47, 48, + 49, -1, 51, 52, 53, 54, -1, -1, -1, -1, + 59, -1, -1, 62, -1, -1, 65, 66, 67, -1, + -1, -1, 71, 72, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 84, 85, 86, 87, 88, + 89, 90, -1, -1, -1, -1, -1, 96, 97, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + -1, -1, -1, -1, 59, -1, -1, 62, -1, -1, + 65, 66, 67, -1, -1, -1, 71, 72, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, + 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, + -1, 96, 97, 44, 45, 46, 47, 48, 49, -1, + 51, 52, 53, 54, -1, -1, -1, -1, 59, -1, + -1, 62, -1, -1, 65, 66, 67, -1, -1, -1, + 71, 72, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 84, 85, 86, 87, 88, 89, 90, + -1, -1, -1, -1, -1, 96, 97, 44, 45, 46, + 47, 48, 49, -1, 51, 52, 53, 54, -1, -1, + -1, -1, -1, -1, -1, 62, -1, -1, 65, 66, + 67, -1, -1, -1, 71, 72, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 84, 85, 86, + 87, 88, 89, 90, -1, -1, -1, -1, -1, 96, + 97, 44, 45, 46, 47, 48, 49, -1, 51, 52, + 53, 54, -1, -1, -1, -1, -1, -1, -1, 62, + -1, -1, 65, 66, 67, -1, -1, -1, 71, 72, + 44, 45, 46, 47, 48, 49, -1, 51, 52, 53, + 54, 84, 85, 86, 87, 88, 89, 90, 62, -1, + -1, 65, 66, 67, 97, -1, -1, 71, 72, 44, + 45, 46, 47, 48, 49, -1, 51, 52, 53, 54, + 84, 85, 86, 87, 88, -1, 90, 62, -1, -1, + 65, 66, 67, 97, -1, -1, 71, 72, 44, 45, + 46, 47, 48, 49, -1, 51, -1, 53, 54, 84, + 85, 86, 87, -1, -1, 90, 62, -1, -1, 65, + 66, 67, 97, -1, -1, 71, 72, 44, 45, 46, + 47, 48, 49, -1, 51, -1, 53, 54, 84, 85, + 86, 87, -1, -1, 90, -1, -1, -1, 65, 66, + 67, 97, -1, -1, 71, 72, 44, 45, 46, 47, + 48, 49, -1, 51, -1, -1, 54, 84, 85, 86, + 87, -1, -1, 90, -1, -1, -1, 65, 66, 67, + 97, -1, -1, 71, 72, 44, 45, 46, 47, 48, + 49, -1, 51, -1, -1, 54, 84, 85, 86, 87, + -1, -1, 90, -1, -1, -1, 65, 66, 67, 97, + -1, -1, 71, 72, 44, 45, 46, 47, -1, -1, + -1, 51, -1, -1, 54, 50, -1, 86, 87, -1, + -1, 90, -1, -1, -1, 65, 66, 67, 97, -1, + -1, 71, 72, 68, 69, 50, -1, -1, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, + 90, -1, -1, 68, 69, -1, -1, 97, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 44, 45, + 46, 47, -1, -1, -1, 51, -1, -1, 54, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 66, 67, -1, -1, -1, 71, 72 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "bison.simple" /* Skeleton output parser for bison, -Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* As a special exception, when this file is copied by Bison into a -Bison output file, you may use that output file without restriction. -This special exception was added by the Free Software Foundation -in version 1.24 of Bison. */ + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ #ifndef alloca #ifdef __GNUC__ @@ -1175,15 +1116,15 @@ in version 1.24 of Bison. */ #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) #include -#pragma alloca + #pragma alloca #else /* not MSDOS, __TURBOC__, or _AIX */ #ifdef __hpux #ifdef __cplusplus extern "C" { - void *alloca(unsigned int); +void *alloca (unsigned int); }; #else /* not __cplusplus */ -void *alloca(); +void *alloca (); #endif /* not __cplusplus */ #endif /* __hpux */ #endif /* not _AIX */ @@ -1193,13 +1134,13 @@ void *alloca(); #endif /* alloca not defined. */ /* This is the parser code that is written into each bison parser -when the %semantic_parser declaration is not specified in the grammar. -It was written by Richard Stallman by simplifying the hairy parser -used when %semantic_parser is specified. */ + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ /* Note: there must be only one dollar sign in this file. -It is replaced by the list of actions, each action -as one case of the switch. */ + It is replaced by the list of actions, each action + as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) @@ -1209,9 +1150,9 @@ as one case of the switch. */ #define YYABORT return(1) #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. -This remains here temporarily to ease the -transition to the new meaning of YYERROR, for GCC. -Once GCC version 2 has supplanted version 1, this can go. */ + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ @@ -1255,11 +1196,11 @@ while (0) int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ + /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ + /* symbol */ #endif int yynerrs; /* number of parse errors so far */ @@ -1267,18 +1208,18 @@ int yynerrs; /* number of parse errors so far */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ - /* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ #endif - /* YYINITDEPTH indicates the initial size of the parser's stacks */ +/* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif - /* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH @@ -1288,57 +1229,57 @@ int yydebug; /* nonzero means print parse trace */ #define YYMAXDEPTH 10000 #endif - /* Prevent warning if -Wstrict-prototypes. */ +/* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ -int yyparse(void); +int yyparse (void); #endif - + #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities -in available built-in functions on various systems. */ + in available built-in functions on various systems. */ static void -__yy_memcpy(from, to, count) -char *from; -char *to; -int count; +__yy_memcpy (from, to, count) + char *from; + char *to; + int count; { - register char *f = from; - register char *t = to; - register int i = count; + register char *f = from; + register char *t = to; + register int i = count; - while (i-- > 0) - *t++ = *f++; + while (i-- > 0) + *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities -in available built-in functions on various systems. */ + in available built-in functions on various systems. */ static void -__yy_memcpy(char *from, char *to, int count) +__yy_memcpy (char *from, char *to, int count) { - register char *f = from; - register char *t = to; - register int i = count; + register char *f = from; + register char *t = to; + register int i = count; - while (i-- > 0) - *t++ = *f++; + while (i-- > 0) + *t++ = *f++; } #endif #endif - + #line 192 "bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed -into yyparse. The argument should have type void *. -It should actually point to an object. -Grammar actions can access the variable by casting it -to the proper pointer type. */ + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ #ifdef YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; @@ -1349,78 +1290,78 @@ to the proper pointer type. */ int yyparse(YYPARSE_PARAM) -YYPARSE_PARAM_DECL + YYPARSE_PARAM_DECL { - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif - int yystacksize = YYINITDEPTH; + int yystacksize = YYINITDEPTH; #ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; + int yychar; + YYSTYPE yylval; + int yynerrs; #ifdef YYLSP_NEEDED - YYLTYPE yylloc; + YYLTYPE yylloc; #endif #endif - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ - int yylen; + int yylen; #if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); + if (yydebug) + fprintf(stderr, "Starting parse\n"); #endif - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ - yyssp = yyss - 1; - yyvsp = yyvs; + yyssp = yyss - 1; + yyvsp = yyvs; #ifdef YYLSP_NEEDED - yylsp = yyls; + yylsp = yyls; #endif - /* Push a new state, which is found in yystate . */ - /* In all cases, when you get here, the value and location stacks +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: - *++yyssp = yystate; + *++yyssp = yystate; - if (yyssp >= yyss + yystacksize - 1) - { + if (yyssp >= yyss + yystacksize - 1) + { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; @@ -1434,20 +1375,20 @@ yynewstate: #ifdef yyoverflow /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ + the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ + but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", - &yyss1, size * sizeof(*yyssp), - &yyvs1, size * sizeof(*yyvsp), - &yyls1, size * sizeof(*yylsp), - &yystacksize); + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); #else yyoverflow("parser stack overflow", - &yyss1, size * sizeof(*yyssp), - &yyvs1, size * sizeof(*yyvsp), - &yystacksize); + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; @@ -1457,20 +1398,20 @@ yynewstate: #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } + { + yyerror("parser stack overflow"); + return 2; + } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *)alloca(yystacksize * sizeof(*yyssp)); - __yy_memcpy((char *)yyss1, (char *)yyss, size * sizeof(*yyssp)); - yyvs = (YYSTYPE *)alloca(yystacksize * sizeof(*yyvsp)); - __yy_memcpy((char *)yyvs1, (char *)yyvs, size * sizeof(*yyvsp)); + yystacksize = YYMAXDEPTH; + yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); + yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); #ifdef YYLSP_NEEDED - yyls = (YYLTYPE *)alloca(yystacksize * sizeof(*yylsp)); - __yy_memcpy((char *)yyls1, (char *)yyls, size * sizeof(*yylsp)); + yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); #endif #endif /* no yyoverflow */ @@ -1482,995 +1423,972 @@ yynewstate: #if YYDEBUG != 0 if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); + fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } + YYABORT; + } #if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); #endif - goto yybackup; -yybackup: + goto yybackup; + yybackup: - /* Do appropriate processing given the current state. */ - /* Read a lookahead token if we need one and don't already have one. */ - /* yyresume: */ +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ - if (yychar == YYEMPTY) - { + if (yychar == YYEMPTY) + { #if YYDEBUG != 0 if (yydebug) - fprintf(stderr, "Reading a token: "); + fprintf(stderr, "Reading a token: "); #endif yychar = YYLEX; - } + } - /* Convert token to internal form (in yychar1) for indexing tables with */ + /* Convert token to internal form (in yychar1) for indexing tables with */ - if (yychar <= 0) /* This means end of input. */ - { + if (yychar <= 0) /* This means end of input. */ + { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) - fprintf(stderr, "Now at end of input.\n"); + fprintf(stderr, "Now at end of input.\n"); #endif - } - else - { + } + else + { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) - { - fprintf(stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ #ifdef YYPRINT - YYPRINT(stderr, yychar, yylval); + YYPRINT (stderr, yychar, yylval); #endif - fprintf(stderr, ")\n"); - } + fprintf (stderr, ")\n"); + } #endif - } + } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; - yyn = yytable[yyn]; + yyn = yytable[yyn]; - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ - if (yyn < 0) - { + if (yyn < 0) + { if (yyn == YYFLAG) - goto yyerrlab; + goto yyerrlab; yyn = -yyn; goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; + } + else if (yyn == 0) + goto yyerrlab; - if (yyn == YYFINAL) - YYACCEPT; + if (yyn == YYFINAL) + YYACCEPT; - /* Shift the lookahead token. */ + /* Shift the lookahead token. */ #if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; - *++yyvsp = yylval; + *++yyvsp = yylval; #ifdef YYLSP_NEEDED - *++yylsp = yylloc; + *++yylsp = yylloc; #endif - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; - yystate = yyn; - goto yynewstate; + yystate = yyn; + goto yynewstate; - /* Do the default action for the current state. */ +/* Do the default action for the current state. */ yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; - /* Do a reduction. yyn is the number of a rule to reduce with. */ +/* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1 - yylen]; /* implement default value of the action */ + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 - if (yydebug) - { + if (yydebug) + { int i; - fprintf(stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf(stderr, "%s ", yytname[yyrhs[i]]); - fprintf(stderr, " -> %s\n", yytname[yyr1[yyn]]); - } + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } #endif - switch (yyn) { + switch (yyn) { - case 1: +case 1: #line 162 "cmdgram.y" - {; - break; } - case 2: +{ ; + break;} +case 2: #line 167 "cmdgram.y" - { yyval.stmt = nil; ; - break; } - case 3: +{ yyval.stmt = nil; ; + break;} +case 3: #line 169 "cmdgram.y" - { if (!gStatementList) { gStatementList = yyvsp[0].stmt; } - else { gStatementList->append(yyvsp[0].stmt); }; - break; } - case 4: +{ if(!gStatementList) { gStatementList = yyvsp[0].stmt; } else { gStatementList->append(yyvsp[0].stmt); } ; + break;} +case 4: #line 174 "cmdgram.y" - { yyval.stmt = yyvsp[0].stmt; ; - break; } - case 5: +{ yyval.stmt = yyvsp[0].stmt; ; + break;} +case 5: #line 176 "cmdgram.y" - { yyval.stmt = yyvsp[0].stmt; ; - break; } - case 6: +{ yyval.stmt = yyvsp[0].stmt; ; + break;} +case 6: #line 178 "cmdgram.y" - { yyval.stmt = yyvsp[0].stmt; ; - break; } - case 7: +{ yyval.stmt = yyvsp[0].stmt; ; + break;} +case 7: #line 183 "cmdgram.y" - { yyval.stmt = yyvsp[-2].stmt; for (StmtNode *walk = (yyvsp[-2].stmt); walk; walk = walk->getNext()) walk->setPackage(yyvsp[-4].s.value); ; - break; } - case 8: +{ yyval.stmt = yyvsp[-2].stmt; for(StmtNode *walk = (yyvsp[-2].stmt);walk;walk = walk->getNext() ) walk->setPackage(yyvsp[-4].s.value); ; + break;} +case 8: #line 188 "cmdgram.y" - { yyval.stmt = yyvsp[0].stmt; ; - break; } - case 9: +{ yyval.stmt = yyvsp[0].stmt; ; + break;} +case 9: #line 190 "cmdgram.y" - { yyval.stmt = yyvsp[-1].stmt; (yyvsp[-1].stmt)->append(yyvsp[0].stmt); ; - break; } - case 10: +{ yyval.stmt = yyvsp[-1].stmt; (yyvsp[-1].stmt)->append(yyvsp[0].stmt); ; + break;} +case 10: #line 195 "cmdgram.y" - { yyval.stmt = nil; ; - break; } - case 11: +{ yyval.stmt = nil; ; + break;} +case 11: #line 197 "cmdgram.y" - { if (!yyvsp[-1].stmt) { yyval.stmt = yyvsp[0].stmt; } - else { (yyvsp[-1].stmt)->append(yyvsp[0].stmt); yyval.stmt = yyvsp[-1].stmt; }; - break; } - case 18: +{ if(!yyvsp[-1].stmt) { yyval.stmt = yyvsp[0].stmt; } else { (yyvsp[-1].stmt)->append(yyvsp[0].stmt); yyval.stmt = yyvsp[-1].stmt; } ; + break;} +case 18: #line 208 "cmdgram.y" - { yyval.stmt = BreakStmtNode::alloc(yyvsp[-1].i.lineNumber); ; - break; } - case 19: +{ yyval.stmt = BreakStmtNode::alloc( yyvsp[-1].i.lineNumber ); ; + break;} +case 19: #line 210 "cmdgram.y" - { yyval.stmt = ContinueStmtNode::alloc(yyvsp[-1].i.lineNumber); ; - break; } - case 20: +{ yyval.stmt = ContinueStmtNode::alloc( yyvsp[-1].i.lineNumber ); ; + break;} +case 20: #line 212 "cmdgram.y" - { yyval.stmt = ReturnStmtNode::alloc(yyvsp[-1].i.lineNumber, NULL); ; - break; } - case 21: +{ yyval.stmt = ReturnStmtNode::alloc( yyvsp[-1].i.lineNumber, NULL ); ; + break;} +case 21: #line 214 "cmdgram.y" - { yyval.stmt = ReturnStmtNode::alloc(yyvsp[-2].i.lineNumber, yyvsp[-1].expr); ; - break; } - case 22: +{ yyval.stmt = ReturnStmtNode::alloc( yyvsp[-2].i.lineNumber, yyvsp[-1].expr ); ; + break;} +case 22: #line 216 "cmdgram.y" - { yyval.stmt = yyvsp[-1].stmt; ; - break; } - case 23: +{ yyval.stmt = yyvsp[-1].stmt; ; + break;} +case 23: #line 218 "cmdgram.y" - { yyval.stmt = TTagSetStmtNode::alloc(yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, yyvsp[-1].expr, NULL); ; - break; } - case 24: +{ yyval.stmt = TTagSetStmtNode::alloc( yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, yyvsp[-1].expr, NULL ); ; + break;} +case 24: #line 220 "cmdgram.y" - { yyval.stmt = TTagSetStmtNode::alloc(yyvsp[-5].s.lineNumber, yyvsp[-5].s.value, yyvsp[-3].expr, yyvsp[-1].expr); ; - break; } - case 25: +{ yyval.stmt = TTagSetStmtNode::alloc( yyvsp[-5].s.lineNumber, yyvsp[-5].s.value, yyvsp[-3].expr, yyvsp[-1].expr ); ; + break;} +case 25: #line 222 "cmdgram.y" - { yyval.stmt = StrConstNode::alloc(yyvsp[0].str.lineNumber, yyvsp[0].str.value, false, true); ; - break; } - case 26: +{ yyval.stmt = StrConstNode::alloc( yyvsp[0].str.lineNumber, yyvsp[0].str.value, false, true ); ; + break;} +case 26: #line 227 "cmdgram.y" - { yyval.stmt = FunctionDeclStmtNode::alloc(yyvsp[-7].i.lineNumber, yyvsp[-6].s.value, NULL, yyvsp[-4].var, yyvsp[-1].stmt); ; - break; } - case 27: +{ yyval.stmt = FunctionDeclStmtNode::alloc( yyvsp[-7].i.lineNumber, yyvsp[-6].s.value, NULL, yyvsp[-4].var, yyvsp[-1].stmt ); ; + break;} +case 27: #line 229 "cmdgram.y" - { yyval.stmt = FunctionDeclStmtNode::alloc(yyvsp[-9].i.lineNumber, yyvsp[-6].s.value, yyvsp[-8].s.value, yyvsp[-4].var, yyvsp[-1].stmt); ; - break; } - case 28: +{ yyval.stmt = FunctionDeclStmtNode::alloc( yyvsp[-9].i.lineNumber, yyvsp[-6].s.value, yyvsp[-8].s.value, yyvsp[-4].var, yyvsp[-1].stmt ); ; + break;} +case 28: #line 234 "cmdgram.y" - { yyval.var = NULL; ; - break; } - case 29: +{ yyval.var = NULL; ; + break;} +case 29: #line 236 "cmdgram.y" - { yyval.var = yyvsp[0].var; ; - break; } - case 30: +{ yyval.var = yyvsp[0].var; ; + break;} +case 30: #line 241 "cmdgram.y" - { yyval.var = VarNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL); ; - break; } - case 31: +{ yyval.var = VarNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL ); ; + break;} +case 31: #line 243 "cmdgram.y" - { yyval.var = yyvsp[-2].var; ((StmtNode*)(yyvsp[-2].var))->append((StmtNode*)VarNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL)); ; - break; } - case 32: +{ yyval.var = yyvsp[-2].var; ((StmtNode*)(yyvsp[-2].var))->append((StmtNode*)VarNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL ) ); ; + break;} +case 32: #line 248 "cmdgram.y" - { yyval.stmt = ObjectDeclNode::alloc(yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, NULL, yyvsp[-5].s.value, yyvsp[-2].slist, NULL, true, false, false); ; - break; } - case 33: +{ yyval.stmt = ObjectDeclNode::alloc( yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, NULL, yyvsp[-5].s.value, yyvsp[-2].slist, NULL, true, false, false); ; + break;} +case 33: #line 253 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, false, false); ; - break; } - case 34: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, false, false); ; + break;} +case 34: #line 255 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, false, false); ; - break; } - case 35: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, false, false); ; + break;} +case 35: #line 257 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-11].i.lineNumber, yyvsp[-10].expr, yyvsp[-7].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, true, false); ; - break; } - case 36: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-11].i.lineNumber, yyvsp[-10].expr, yyvsp[-7].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, true, false); ; + break;} +case 36: #line 259 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-8].i.lineNumber, yyvsp[-7].expr, yyvsp[-4].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, true, false); ; - break; } - case 37: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-8].i.lineNumber, yyvsp[-7].expr, yyvsp[-4].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, true, false); ; + break;} +case 37: #line 261 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, false, true); ; - break; } - case 38: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-9].i.lineNumber, yyvsp[-8].expr, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-5].s.value, yyvsp[-1].odcl.slots, yyvsp[-1].odcl.decls, false, false, true); ; + break;} +case 38: #line 263 "cmdgram.y" - { yyval.od = ObjectDeclNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, false, true); ; - break; } - case 39: +{ yyval.od = ObjectDeclNode::alloc( yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, yyvsp[-1].expr, yyvsp[-2].s.value, NULL, NULL, false, false, true); ; + break;} +case 39: #line 268 "cmdgram.y" - { yyval.s.value = NULL; ; - break; } - case 40: +{ yyval.s.value = NULL; ; + break;} +case 40: #line 270 "cmdgram.y" - { yyval.s = yyvsp[0].s; ; - break; } - case 41: +{ yyval.s = yyvsp[0].s; ; + break;} +case 41: #line 275 "cmdgram.y" - { yyval.expr = StrConstNode::alloc(CodeBlock::smCurrentParser->getCurrentLine(), "", false); ; - break; } - case 42: +{ yyval.expr = StrConstNode::alloc( CodeBlock::smCurrentParser->getCurrentLine(), "", false); ; + break;} +case 42: #line 277 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 43: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 43: #line 282 "cmdgram.y" - { yyval.expr = NULL; ; - break; } - case 44: +{ yyval.expr = NULL; ; + break;} +case 44: #line 284 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 45: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 45: #line 289 "cmdgram.y" - { yyval.odcl.slots = NULL; yyval.odcl.decls = NULL; ; - break; } - case 46: +{ yyval.odcl.slots = NULL; yyval.odcl.decls = NULL; ; + break;} +case 46: #line 291 "cmdgram.y" - { yyval.odcl.slots = yyvsp[0].slist; yyval.odcl.decls = NULL; ; - break; } - case 47: +{ yyval.odcl.slots = yyvsp[0].slist; yyval.odcl.decls = NULL; ; + break;} +case 47: #line 293 "cmdgram.y" - { yyval.odcl.slots = NULL; yyval.odcl.decls = yyvsp[0].od; ; - break; } - case 48: +{ yyval.odcl.slots = NULL; yyval.odcl.decls = yyvsp[0].od; ; + break;} +case 48: #line 295 "cmdgram.y" - { yyval.odcl.slots = yyvsp[-1].slist; yyval.odcl.decls = yyvsp[0].od; ; - break; } - case 49: +{ yyval.odcl.slots = yyvsp[-1].slist; yyval.odcl.decls = yyvsp[0].od; ; + break;} +case 49: #line 300 "cmdgram.y" - { yyval.od = yyvsp[-1].od; ; - break; } - case 50: +{ yyval.od = yyvsp[-1].od; ; + break;} +case 50: #line 302 "cmdgram.y" - { yyvsp[-2].od->append(yyvsp[-1].od); yyval.od = yyvsp[-2].od; ; - break; } - case 51: +{ yyvsp[-2].od->append(yyvsp[-1].od); yyval.od = yyvsp[-2].od; ; + break;} +case 51: #line 307 "cmdgram.y" - { yyval.stmt = yyvsp[-1].stmt; ; - break; } - case 52: +{ yyval.stmt = yyvsp[-1].stmt; ; + break;} +case 52: #line 309 "cmdgram.y" - { yyval.stmt = yyvsp[0].stmt; ; - break; } - case 53: +{ yyval.stmt = yyvsp[0].stmt; ; + break;} +case 53: #line 314 "cmdgram.y" - { yyval.stmt = yyvsp[-1].ifnode; yyvsp[-1].ifnode->propagateSwitchExpr(yyvsp[-4].expr, false); ; - break; } - case 54: +{ yyval.stmt = yyvsp[-1].ifnode; yyvsp[-1].ifnode->propagateSwitchExpr(yyvsp[-4].expr, false); ; + break;} +case 54: #line 316 "cmdgram.y" - { yyval.stmt = yyvsp[-1].ifnode; yyvsp[-1].ifnode->propagateSwitchExpr(yyvsp[-4].expr, true); ; - break; } - case 55: +{ yyval.stmt = yyvsp[-1].ifnode; yyvsp[-1].ifnode->propagateSwitchExpr(yyvsp[-4].expr, true); ; + break;} +case 55: #line 321 "cmdgram.y" - { yyval.ifnode = IfStmtNode::alloc(yyvsp[-3].i.lineNumber, yyvsp[-2].expr, yyvsp[0].stmt, NULL, false); ; - break; } - case 56: +{ yyval.ifnode = IfStmtNode::alloc( yyvsp[-3].i.lineNumber, yyvsp[-2].expr, yyvsp[0].stmt, NULL, false); ; + break;} +case 56: #line 323 "cmdgram.y" - { yyval.ifnode = IfStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].stmt, yyvsp[0].stmt, false); ; - break; } - case 57: +{ yyval.ifnode = IfStmtNode::alloc( yyvsp[-6].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].stmt, yyvsp[0].stmt, false); ; + break;} +case 57: #line 325 "cmdgram.y" - { yyval.ifnode = IfStmtNode::alloc(yyvsp[-4].i.lineNumber, yyvsp[-3].expr, yyvsp[-1].stmt, yyvsp[0].ifnode, true); ; - break; } - case 58: +{ yyval.ifnode = IfStmtNode::alloc( yyvsp[-4].i.lineNumber, yyvsp[-3].expr, yyvsp[-1].stmt, yyvsp[0].ifnode, true); ; + break;} +case 58: #line 330 "cmdgram.y" - { yyval.expr = yyvsp[0].expr;; - break; } - case 59: +{ yyval.expr = yyvsp[0].expr;; + break;} +case 59: #line 332 "cmdgram.y" - { (yyvsp[-2].expr)->append(yyvsp[0].expr); yyval.expr = yyvsp[-2].expr; ; - break; } - case 60: +{ (yyvsp[-2].expr)->append(yyvsp[0].expr); yyval.expr=yyvsp[-2].expr; ; + break;} +case 60: #line 337 "cmdgram.y" - { yyval.stmt = IfStmtNode::alloc(yyvsp[-4].i.lineNumber, yyvsp[-2].expr, yyvsp[0].stmt, NULL, false); ; - break; } - case 61: +{ yyval.stmt = IfStmtNode::alloc(yyvsp[-4].i.lineNumber, yyvsp[-2].expr, yyvsp[0].stmt, NULL, false); ; + break;} +case 61: #line 339 "cmdgram.y" - { yyval.stmt = IfStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].expr, yyvsp[-2].stmt, yyvsp[0].stmt, false); ; - break; } - case 62: +{ yyval.stmt = IfStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].expr, yyvsp[-2].stmt, yyvsp[0].stmt, false); ; + break;} +case 62: #line 344 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-4].i.lineNumber, nil, yyvsp[-2].expr, nil, yyvsp[0].stmt, false); ; - break; } - case 63: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-4].i.lineNumber, nil, yyvsp[-2].expr, nil, yyvsp[0].stmt, false); ; + break;} +case 63: #line 346 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-3].i.lineNumber, nil, yyvsp[-1].expr, nil, yyvsp[-4].stmt, true); ; - break; } - case 64: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-3].i.lineNumber, nil, yyvsp[-1].expr, nil, yyvsp[-4].stmt, true); ; + break;} +case 64: #line 351 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-8].i.lineNumber, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].stmt, false); ; - break; } - case 65: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-8].i.lineNumber, yyvsp[-6].expr, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].stmt, false); ; + break;} +case 65: #line 353 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, NULL, yyvsp[0].stmt, false); ; - break; } - case 66: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, yyvsp[-5].expr, yyvsp[-3].expr, NULL, yyvsp[0].stmt, false); ; + break;} +case 66: #line 355 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, yyvsp[-5].expr, NULL, yyvsp[-2].expr, yyvsp[0].stmt, false); ; - break; } - case 67: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, yyvsp[-5].expr, NULL, yyvsp[-2].expr, yyvsp[0].stmt, false); ; + break;} +case 67: #line 357 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].expr, NULL, NULL, yyvsp[0].stmt, false); ; - break; } - case 68: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].expr, NULL, NULL, yyvsp[0].stmt, false); ; + break;} +case 68: #line 359 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].stmt, false); ; - break; } - case 69: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-7].i.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].stmt, false); ; + break;} +case 69: #line 361 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, NULL, yyvsp[-3].expr, NULL, yyvsp[0].stmt, false); ; - break; } - case 70: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, NULL, yyvsp[-3].expr, NULL, yyvsp[0].stmt, false); ; + break;} +case 70: #line 363 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, NULL, NULL, yyvsp[-2].expr, yyvsp[0].stmt, false); ; - break; } - case 71: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-6].i.lineNumber, NULL, NULL, yyvsp[-2].expr, yyvsp[0].stmt, false); ; + break;} +case 71: #line 365 "cmdgram.y" - { yyval.stmt = LoopStmtNode::alloc(yyvsp[-5].i.lineNumber, NULL, NULL, NULL, yyvsp[0].stmt, false); ; - break; } - case 72: +{ yyval.stmt = LoopStmtNode::alloc(yyvsp[-5].i.lineNumber, NULL, NULL, NULL, yyvsp[0].stmt, false); ; + break;} +case 72: #line 370 "cmdgram.y" - { yyval.stmt = IterStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].stmt, false); ; - break; } - case 73: +{ yyval.stmt = IterStmtNode::alloc( yyvsp[-6].i.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].stmt, false ); ; + break;} +case 73: #line 372 "cmdgram.y" - { yyval.stmt = IterStmtNode::alloc(yyvsp[-6].i.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].stmt, true); ; - break; } - case 74: +{ yyval.stmt = IterStmtNode::alloc( yyvsp[-6].i.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].stmt, true ); ; + break;} +case 74: #line 377 "cmdgram.y" - { yyval.stmt = yyvsp[0].expr; ; - break; } - case 75: +{ yyval.stmt = yyvsp[0].expr; ; + break;} +case 75: #line 382 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 76: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 76: #line 384 "cmdgram.y" - { yyval.expr = yyvsp[-1].expr; ; - break; } - case 77: +{ yyval.expr = yyvsp[-1].expr; ; + break;} +case 77: #line 386 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 78: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 78: #line 388 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 79: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 79: #line 390 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 80: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 80: #line 392 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 81: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 81: #line 394 "cmdgram.y" - { yyval.expr = FloatBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 82: +{ yyval.expr = FloatBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 82: #line 396 "cmdgram.y" - { yyval.expr = FloatBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 83: +{ yyval.expr = FloatBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 83: #line 398 "cmdgram.y" - { yyval.expr = FloatBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 84: +{ yyval.expr = FloatBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 84: #line 400 "cmdgram.y" - { yyval.expr = FloatBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 85: +{ yyval.expr = FloatBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 85: #line 402 "cmdgram.y" - { yyval.expr = FloatUnaryExprNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; - break; } - case 86: +{ yyval.expr = FloatUnaryExprNode::alloc( yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; + break;} +case 86: #line 404 "cmdgram.y" - { yyval.expr = TTagDerefNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[0].expr); ; - break; } - case 87: +{ yyval.expr = TTagDerefNode::alloc( yyvsp[-1].i.lineNumber, yyvsp[0].expr ); ; + break;} +case 87: #line 406 "cmdgram.y" - { yyval.expr = TTagExprNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value); ; - break; } - case 88: +{ yyval.expr = TTagExprNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value ); ; + break;} +case 88: #line 408 "cmdgram.y" - { yyval.expr = ConditionalExprNode::alloc(yyvsp[-4].expr->dbgLineNumber, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 89: +{ yyval.expr = ConditionalExprNode::alloc( yyvsp[-4].expr->dbgLineNumber, yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 89: #line 410 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 90: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 90: #line 412 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 91: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 91: #line 414 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 92: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 92: #line 416 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 93: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 93: #line 418 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 94: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 94: #line 420 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 95: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 95: #line 422 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 96: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 96: #line 424 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 97: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 97: #line 426 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 98: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 98: #line 428 "cmdgram.y" - { yyval.expr = IntBinaryExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - case 99: +{ yyval.expr = IntBinaryExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-1].i.value, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +case 99: #line 430 "cmdgram.y" - { yyval.expr = StreqExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, true); ; - break; } - case 100: +{ yyval.expr = StreqExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, true); ; + break;} +case 100: #line 432 "cmdgram.y" - { yyval.expr = StreqExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, false); ; - break; } - case 101: +{ yyval.expr = StreqExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, false); ; + break;} +case 101: #line 434 "cmdgram.y" - { yyval.expr = StrcatExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, yyvsp[-1].i.value); ; - break; } - case 102: +{ yyval.expr = StrcatExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr, yyvsp[-1].i.value); ; + break;} +case 102: #line 436 "cmdgram.y" - { yyval.expr = IntUnaryExprNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; - break; } - case 103: +{ yyval.expr = IntUnaryExprNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; + break;} +case 103: #line 438 "cmdgram.y" - { yyval.expr = IntUnaryExprNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; - break; } - case 104: +{ yyval.expr = IntUnaryExprNode::alloc(yyvsp[-1].i.lineNumber, yyvsp[-1].i.value, yyvsp[0].expr); ; + break;} +case 104: #line 440 "cmdgram.y" - { yyval.expr = StrConstNode::alloc(yyvsp[0].str.lineNumber, yyvsp[0].str.value, true); ; - break; } - case 105: +{ yyval.expr = StrConstNode::alloc( yyvsp[0].str.lineNumber, yyvsp[0].str.value, true); ; + break;} +case 105: #line 442 "cmdgram.y" - { yyval.expr = FloatNode::alloc(yyvsp[0].f.lineNumber, yyvsp[0].f.value); ; - break; } - case 106: +{ yyval.expr = FloatNode::alloc( yyvsp[0].f.lineNumber, yyvsp[0].f.value ); ; + break;} +case 106: #line 444 "cmdgram.y" - { yyval.expr = IntNode::alloc(yyvsp[0].i.lineNumber, yyvsp[0].i.value); ; - break; } - case 107: +{ yyval.expr = IntNode::alloc( yyvsp[0].i.lineNumber, yyvsp[0].i.value ); ; + break;} +case 107: #line 446 "cmdgram.y" - { yyval.expr = ConstantNode::alloc(yyvsp[0].i.lineNumber, StringTable->insert("break")); ; - break; } - case 108: +{ yyval.expr = ConstantNode::alloc( yyvsp[0].i.lineNumber, StringTable->insert("break")); ; + break;} +case 108: #line 448 "cmdgram.y" - { yyval.expr = SlotAccessNode::alloc(yyvsp[0].slot.lineNumber, yyvsp[0].slot.object, yyvsp[0].slot.array, yyvsp[0].slot.slotName); ; - break; } - case 109: +{ yyval.expr = SlotAccessNode::alloc( yyvsp[0].slot.lineNumber, yyvsp[0].slot.object, yyvsp[0].slot.array, yyvsp[0].slot.slotName ); ; + break;} +case 109: #line 450 "cmdgram.y" - { yyval.expr = InternalSlotAccessNode::alloc(yyvsp[0].intslot.lineNumber, yyvsp[0].intslot.object, yyvsp[0].intslot.slotExpr, yyvsp[0].intslot.recurse); ; - break; } - case 110: +{ yyval.expr = InternalSlotAccessNode::alloc( yyvsp[0].intslot.lineNumber, yyvsp[0].intslot.object, yyvsp[0].intslot.slotExpr, yyvsp[0].intslot.recurse); ; + break;} +case 110: #line 452 "cmdgram.y" - { yyval.expr = ConstantNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value); ; - break; } - case 111: +{ yyval.expr = ConstantNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value ); ; + break;} +case 111: #line 454 "cmdgram.y" - { yyval.expr = StrConstNode::alloc(yyvsp[0].str.lineNumber, yyvsp[0].str.value, false); ; - break; } - case 112: +{ yyval.expr = StrConstNode::alloc( yyvsp[0].str.lineNumber, yyvsp[0].str.value, false); ; + break;} +case 112: #line 456 "cmdgram.y" - { yyval.expr = (ExprNode*)VarNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL); ; - break; } - case 113: +{ yyval.expr = (ExprNode*)VarNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value, NULL); ; + break;} +case 113: #line 458 "cmdgram.y" - { yyval.expr = (ExprNode*)VarNode::alloc(yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, yyvsp[-1].expr); ; - break; } - case 114: -#line 460 "cmdgram.y" - { - const U32 bufLen = 64; - UTF8 buffer[bufLen]; - dSprintf(buffer, bufLen, "__anonymous_function%d", gAnonFunctionID++); - StringTableEntry fName = StringTable->insert(buffer); - StmtNode *fndef = FunctionDeclStmtNode::alloc(yyvsp[-6].i.lineNumber, fName, NULL, yyvsp[-4].var, yyvsp[-1].stmt); - - if (!gAnonFunctionList) - gAnonFunctionList = fndef; - else - gAnonFunctionList->append(fndef); - - yyval.expr = StrConstNode::alloc(yyvsp[-6].i.lineNumber, (UTF8*)fName, false); - ; - break; } - case 115: -#line 478 "cmdgram.y" - { yyval.slot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.slot.object = yyvsp[-2].expr; yyval.slot.slotName = yyvsp[0].s.value; yyval.slot.array = NULL; ; - break; } - case 116: +{ yyval.expr = (ExprNode*)VarNode::alloc( yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, yyvsp[-1].expr ); ; + break;} +case 114: #line 480 "cmdgram.y" - { yyval.slot.lineNumber = yyvsp[-5].expr->dbgLineNumber; yyval.slot.object = yyvsp[-5].expr; yyval.slot.slotName = yyvsp[-3].s.value; yyval.slot.array = yyvsp[-1].expr; ; - break; } - case 117: -#line 485 "cmdgram.y" - { yyval.intslot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.intslot.object = yyvsp[-2].expr; yyval.intslot.slotExpr = yyvsp[0].expr; yyval.intslot.recurse = false; ; - break; } - case 118: +{ yyval.slot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.slot.object = yyvsp[-2].expr; yyval.slot.slotName = yyvsp[0].s.value; yyval.slot.array = NULL; ; + break;} +case 115: +#line 482 "cmdgram.y" +{ yyval.slot.lineNumber = yyvsp[-5].expr->dbgLineNumber; yyval.slot.object = yyvsp[-5].expr; yyval.slot.slotName = yyvsp[-3].s.value; yyval.slot.array = yyvsp[-1].expr; ; + break;} +case 116: #line 487 "cmdgram.y" - { yyval.intslot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.intslot.object = yyvsp[-2].expr; yyval.intslot.slotExpr = yyvsp[0].expr; yyval.intslot.recurse = true; ; - break; } - case 119: -#line 492 "cmdgram.y" - { yyval.expr = ConstantNode::alloc(yyvsp[0].s.lineNumber, yyvsp[0].s.value); ; - break; } - case 120: +{ yyval.intslot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.intslot.object = yyvsp[-2].expr; yyval.intslot.slotExpr = yyvsp[0].expr; yyval.intslot.recurse = false; ; + break;} +case 117: +#line 489 "cmdgram.y" +{ yyval.intslot.lineNumber = yyvsp[-2].expr->dbgLineNumber; yyval.intslot.object = yyvsp[-2].expr; yyval.intslot.slotExpr = yyvsp[0].expr; yyval.intslot.recurse = true; ; + break;} +case 118: #line 494 "cmdgram.y" - { yyval.expr = yyvsp[-1].expr; ; - break; } - case 121: -#line 499 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[0].i.lineNumber; yyval.asn.token = opPLUSPLUS; yyval.asn.expr = FloatNode::alloc(yyvsp[0].i.lineNumber, 1); ; - break; } - case 122: +{ yyval.expr = ConstantNode::alloc( yyvsp[0].s.lineNumber, yyvsp[0].s.value ); ; + break;} +case 119: +#line 496 "cmdgram.y" +{ yyval.expr = yyvsp[-1].expr; ; + break;} +case 120: #line 501 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[0].i.lineNumber; yyval.asn.token = opMINUSMINUS; yyval.asn.expr = FloatNode::alloc(yyvsp[0].i.lineNumber, 1); ; - break; } - case 123: +{ yyval.asn.lineNumber = yyvsp[0].i.lineNumber; yyval.asn.token = opPLUSPLUS; yyval.asn.expr = FloatNode::alloc( yyvsp[0].i.lineNumber, 1 ); ; + break;} +case 121: #line 503 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '+'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 124: +{ yyval.asn.lineNumber = yyvsp[0].i.lineNumber; yyval.asn.token = opMINUSMINUS; yyval.asn.expr = FloatNode::alloc( yyvsp[0].i.lineNumber, 1 ); ; + break;} +case 122: #line 505 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '-'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 125: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '+'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 123: #line 507 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '*'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 126: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '-'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 124: #line 509 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '/'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 127: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '*'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 125: #line 511 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '%'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 128: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '/'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 126: #line 513 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '&'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 129: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '%'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 127: #line 515 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '^'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 130: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '&'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 128: #line 517 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '|'; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 131: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '^'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 129: #line 519 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = opSHL; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 132: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = '|'; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 130: #line 521 "cmdgram.y" - { yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = opSHR; yyval.asn.expr = yyvsp[0].expr; ; - break; } - case 133: -#line 526 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 134: +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = opSHL; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 131: +#line 523 "cmdgram.y" +{ yyval.asn.lineNumber = yyvsp[-1].i.lineNumber; yyval.asn.token = opSHR; yyval.asn.expr = yyvsp[0].expr; ; + break;} +case 132: #line 528 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 135: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 133: #line 530 "cmdgram.y" - { yyval.expr = yyvsp[0].od; ; - break; } - case 136: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 134: #line 532 "cmdgram.y" - { yyval.expr = AssignExprNode::alloc(yyvsp[-2].s.lineNumber, yyvsp[-2].s.value, NULL, yyvsp[0].expr); ; - break; } - case 137: +{ yyval.expr = yyvsp[0].od; ; + break;} +case 135: #line 534 "cmdgram.y" - { yyval.expr = AssignExprNode::alloc(yyvsp[-5].s.lineNumber, yyvsp[-5].s.value, yyvsp[-3].expr, yyvsp[0].expr); ; - break; } - case 138: +{ yyval.expr = AssignExprNode::alloc( yyvsp[-2].s.lineNumber, yyvsp[-2].s.value, NULL, yyvsp[0].expr); ; + break;} +case 136: #line 536 "cmdgram.y" - { yyval.expr = AssignOpExprNode::alloc(yyvsp[-1].s.lineNumber, yyvsp[-1].s.value, NULL, yyvsp[0].asn.expr, yyvsp[0].asn.token); ; - break; } - case 139: +{ yyval.expr = AssignExprNode::alloc( yyvsp[-5].s.lineNumber, yyvsp[-5].s.value, yyvsp[-3].expr, yyvsp[0].expr); ; + break;} +case 137: #line 538 "cmdgram.y" - { yyval.expr = AssignOpExprNode::alloc(yyvsp[-4].s.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].asn.expr, yyvsp[0].asn.token); ; - break; } - case 140: +{ yyval.expr = AssignOpExprNode::alloc( yyvsp[-1].s.lineNumber, yyvsp[-1].s.value, NULL, yyvsp[0].asn.expr, yyvsp[0].asn.token); ; + break;} +case 138: #line 540 "cmdgram.y" - { yyval.expr = SlotAssignOpNode::alloc(yyvsp[-1].slot.lineNumber, yyvsp[-1].slot.object, yyvsp[-1].slot.slotName, yyvsp[-1].slot.array, yyvsp[0].asn.token, yyvsp[0].asn.expr); ; - break; } - case 141: +{ yyval.expr = AssignOpExprNode::alloc( yyvsp[-4].s.lineNumber, yyvsp[-4].s.value, yyvsp[-2].expr, yyvsp[0].asn.expr, yyvsp[0].asn.token); ; + break;} +case 139: #line 542 "cmdgram.y" - { yyval.expr = SlotAssignNode::alloc(yyvsp[-2].slot.lineNumber, yyvsp[-2].slot.object, yyvsp[-2].slot.array, yyvsp[-2].slot.slotName, yyvsp[0].expr); ; - break; } - case 142: +{ yyval.expr = SlotAssignOpNode::alloc( yyvsp[-1].slot.lineNumber, yyvsp[-1].slot.object, yyvsp[-1].slot.slotName, yyvsp[-1].slot.array, yyvsp[0].asn.token, yyvsp[0].asn.expr); ; + break;} +case 140: #line 544 "cmdgram.y" - { yyval.expr = SlotAssignNode::alloc(yyvsp[-4].slot.lineNumber, yyvsp[-4].slot.object, yyvsp[-4].slot.array, yyvsp[-4].slot.slotName, yyvsp[-1].expr); ; - break; } - case 143: -#line 549 "cmdgram.y" - { yyval.expr = FuncCallExprNode::alloc(yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, NULL, yyvsp[-1].expr, false); ; - break; } - case 144: +{ yyval.expr = SlotAssignNode::alloc( yyvsp[-2].slot.lineNumber, yyvsp[-2].slot.object, yyvsp[-2].slot.array, yyvsp[-2].slot.slotName, yyvsp[0].expr); ; + break;} +case 141: +#line 546 "cmdgram.y" +{ yyval.expr = SlotAssignNode::alloc( yyvsp[-4].slot.lineNumber, yyvsp[-4].slot.object, yyvsp[-4].slot.array, yyvsp[-4].slot.slotName, yyvsp[-1].expr); ; + break;} +case 142: #line 551 "cmdgram.y" - { yyval.expr = FuncCallExprNode::alloc(yyvsp[-5].s.lineNumber, yyvsp[-3].s.value, yyvsp[-5].s.value, yyvsp[-1].expr, false); ; - break; } - case 145: +{ yyval.expr = FuncCallExprNode::alloc( yyvsp[-3].s.lineNumber, yyvsp[-3].s.value, NULL, yyvsp[-1].expr, false); ; + break;} +case 143: #line 553 "cmdgram.y" - { yyvsp[-5].expr->append(yyvsp[-1].expr); yyval.expr = FuncCallExprNode::alloc(yyvsp[-5].expr->dbgLineNumber, yyvsp[-3].s.value, NULL, yyvsp[-5].expr, true); ; - break; } - case 146: +{ yyval.expr = FuncCallExprNode::alloc( yyvsp[-5].s.lineNumber, yyvsp[-3].s.value, yyvsp[-5].s.value, yyvsp[-1].expr, false); ; + break;} +case 144: #line 555 "cmdgram.y" - { yyval.expr = FuncPointerCallExprNode::alloc(yyvsp[-3].expr->dbgLineNumber, yyvsp[-3].expr, yyvsp[-1].expr); ; - break; } - case 147: -#line 560 "cmdgram.y" - { yyval.expr = AssertCallExprNode::alloc(yyvsp[-3].i.lineNumber, yyvsp[-1].expr, NULL); ; - break; } - case 148: -#line 562 "cmdgram.y" - { yyval.expr = AssertCallExprNode::alloc(yyvsp[-5].i.lineNumber, yyvsp[-3].expr, yyvsp[-1].str.value); ; - break; } - case 149: +{ yyvsp[-5].expr->append(yyvsp[-1].expr); yyval.expr = FuncCallExprNode::alloc( yyvsp[-5].expr->dbgLineNumber, yyvsp[-3].s.value, NULL, yyvsp[-5].expr, true); ; + break;} +case 145: +#line 565 "cmdgram.y" +{ yyval.expr = AssertCallExprNode::alloc( yyvsp[-3].i.lineNumber, yyvsp[-1].expr, NULL ); ; + break;} +case 146: #line 567 "cmdgram.y" - { yyval.expr = NULL; ; - break; } - case 150: -#line 569 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 151: +{ yyval.expr = AssertCallExprNode::alloc( yyvsp[-5].i.lineNumber, yyvsp[-3].expr, yyvsp[-1].str.value ); ; + break;} +case 147: +#line 572 "cmdgram.y" +{ yyval.expr = NULL; ; + break;} +case 148: #line 574 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 152: -#line 576 "cmdgram.y" - { (yyvsp[-2].expr)->append(yyvsp[0].expr); yyval.expr = yyvsp[-2].expr; ; - break; } - case 153: +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 149: +#line 579 "cmdgram.y" +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 150: #line 581 "cmdgram.y" - { yyval.slist = NULL; ; - break; } - case 154: -#line 583 "cmdgram.y" - { yyval.slist = yyvsp[0].slist; ; - break; } - case 155: +{ (yyvsp[-2].expr)->append(yyvsp[0].expr); yyval.expr = yyvsp[-2].expr; ; + break;} +case 151: +#line 586 "cmdgram.y" +{ yyval.slist = NULL; ; + break;} +case 152: #line 588 "cmdgram.y" - { yyval.slist = yyvsp[0].slist; ; - break; } - case 156: -#line 590 "cmdgram.y" - { yyvsp[-1].slist->append(yyvsp[0].slist); yyval.slist = yyvsp[-1].slist; ; - break; } - case 157: +{ yyval.slist = yyvsp[0].slist; ; + break;} +case 153: +#line 593 "cmdgram.y" +{ yyval.slist = yyvsp[0].slist; ; + break;} +case 154: #line 595 "cmdgram.y" - { yyval.slist = SlotAssignNode::alloc(yyvsp[-3].s.lineNumber, NULL, NULL, yyvsp[-3].s.value, yyvsp[-1].expr); ; - break; } - case 158: -#line 597 "cmdgram.y" - { yyval.slist = SlotAssignNode::alloc(yyvsp[-4].i.lineNumber, NULL, NULL, yyvsp[-3].s.value, yyvsp[-1].expr, yyvsp[-4].i.value); ; - break; } - case 159: -#line 599 "cmdgram.y" - { yyval.slist = SlotAssignNode::alloc(yyvsp[-3].i.lineNumber, NULL, NULL, StringTable->insert("datablock"), yyvsp[-1].expr); ; - break; } - case 160: -#line 601 "cmdgram.y" - { yyval.slist = SlotAssignNode::alloc(yyvsp[-6].s.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-6].s.value, yyvsp[-1].expr); ; - break; } - case 161: -#line 603 "cmdgram.y" - { yyval.slist = SlotAssignNode::alloc(yyvsp[-7].i.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-6].s.value, yyvsp[-1].expr, yyvsp[-7].i.value); ; - break; } - case 162: +{ yyvsp[-1].slist->append(yyvsp[0].slist); yyval.slist = yyvsp[-1].slist; ; + break;} +case 155: +#line 600 "cmdgram.y" +{ yyval.slist = SlotAssignNode::alloc( yyvsp[-3].s.lineNumber, NULL, NULL, yyvsp[-3].s.value, yyvsp[-1].expr); ; + break;} +case 156: +#line 602 "cmdgram.y" +{ yyval.slist = SlotAssignNode::alloc( yyvsp[-4].i.lineNumber, NULL, NULL, yyvsp[-3].s.value, yyvsp[-1].expr, yyvsp[-4].i.value); ; + break;} +case 157: +#line 604 "cmdgram.y" +{ yyval.slist = SlotAssignNode::alloc( yyvsp[-3].i.lineNumber, NULL, NULL, StringTable->insert("datablock"), yyvsp[-1].expr); ; + break;} +case 158: +#line 606 "cmdgram.y" +{ yyval.slist = SlotAssignNode::alloc( yyvsp[-6].s.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-6].s.value, yyvsp[-1].expr); ; + break;} +case 159: #line 608 "cmdgram.y" - { yyval.expr = yyvsp[0].expr; ; - break; } - case 163: -#line 610 "cmdgram.y" - { yyval.expr = CommaCatExprNode::alloc(yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr); ; - break; } - } +{ yyval.slist = SlotAssignNode::alloc( yyvsp[-7].i.lineNumber, NULL, yyvsp[-4].expr, yyvsp[-6].s.value, yyvsp[-1].expr, yyvsp[-7].i.value); ; + break;} +case 160: +#line 613 "cmdgram.y" +{ yyval.expr = yyvsp[0].expr; ; + break;} +case 161: +#line 615 "cmdgram.y" +{ yyval.expr = CommaCatExprNode::alloc( yyvsp[-2].expr->dbgLineNumber, yyvsp[-2].expr, yyvsp[0].expr); ; + break;} +} /* the action file gets copied in in place of this dollarsign */ #line 487 "bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; + + yyvsp -= yylen; + yyssp -= yylen; #ifdef YYLSP_NEEDED - yylsp -= yylen; + yylsp -= yylen; #endif #if YYDEBUG != 0 - if (yydebug) - { + if (yydebug) + { short *ssp1 = yyss - 1; - fprintf(stderr, "state stack now"); + fprintf (stderr, "state stack now"); while (ssp1 != yyssp) - fprintf(stderr, " %d", *++ssp1); - fprintf(stderr, "\n"); - } + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } #endif - *++yyvsp = yyval; + *++yyvsp = yyval; #ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { + yylsp++; + if (yylen == 0) + { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp - 1)->last_line; - yylsp->last_column = (yylsp - 1)->last_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp + yylen - 1)->last_line; - yylsp->last_column = (yylsp + yylen - 1)->last_column; - } + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } #endif - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ - yyn = yyr1[yyn]; + yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; - goto yynewstate; + goto yynewstate; yyerrlab: /* here on detecting error */ - if (!yyerrstatus) - /* If not already recovering from an error, report this error. */ - { + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; + { + int size = 0; + char *msg; + int x, count; - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *)malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror("parse error; also virtual memory exceeded"); - } + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } + yyerror("parse error"); + } - goto yyerrlab1; + goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ - if (yyerrstatus == 3) - { + if (yyerrstatus == 3) + { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) - YYABORT; + YYABORT; #if YYDEBUG != 0 if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; - } + } - /* Else will try to reuse lookahead token - after shifting the error token. */ + /* Else will try to reuse lookahead token + after shifting the error token. */ - yyerrstatus = 3; /* Each real token shifted decrements this */ + yyerrstatus = 3; /* Each real token shifted decrements this */ - goto yyerrhandle; + goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; #ifdef YYLSP_NEEDED - yylsp--; + yylsp--; #endif #if YYDEBUG != 0 - if (yydebug) - { + if (yydebug) + { short *ssp1 = yyss - 1; - fprintf(stderr, "Error: state stack now"); + fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) - fprintf(stderr, " %d", *++ssp1); - fprintf(stderr, "\n"); - } + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } #endif yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; - yyn = yytable[yyn]; - if (yyn < 0) - { + yyn = yytable[yyn]; + if (yyn < 0) + { if (yyn == YYFLAG) - goto yyerrpop; + goto yyerrpop; yyn = -yyn; goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; + } + else if (yyn == 0) + goto yyerrpop; - if (yyn == YYFINAL) - YYACCEPT; + if (yyn == YYFINAL) + YYACCEPT; #if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); + if (yydebug) + fprintf(stderr, "Shifting error token, "); #endif - *++yyvsp = yylval; + *++yyvsp = yylval; #ifdef YYLSP_NEEDED - *++yylsp = yylloc; + *++yylsp = yylloc; #endif - yystate = yyn; - goto yynewstate; + yystate = yyn; + goto yynewstate; } -#line 612 "cmdgram.y" +#line 617 "cmdgram.y" diff --git a/Engine/source/console/codeBlock.cpp b/Engine/source/console/codeBlock.cpp index ad363dc17..1d1ad7593 100644 --- a/Engine/source/console/codeBlock.cpp +++ b/Engine/source/console/codeBlock.cpp @@ -405,6 +405,26 @@ bool CodeBlock::read(StringTableEntry fileName, Stream &st) for (i = 0; i < size; i++) st.read(&functionFloats[i]); } + + // Variable register mapping table + st.read(&size); + if (size) + { + for (i = 0; i < size; i++) + { + StringTableEntry fnName = st.readSTString(); + + U32 count; + st.read(&count); + for (U32 j = 0; j < count; j++) + { + StringTableEntry varName = st.readSTString(); + + variableRegisterTable.localVarToRegister[fnName].varList.push_back(varName); + } + } + } + U32 codeLength; st.read(&codeLength); st.read(&lineBreakPairCount); @@ -477,7 +497,6 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con STEtoCode = compileSTEtoCode; gStatementList = NULL; - gAnonFunctionList = NULL; // Set up the parser. smCurrentParser = getParserForFile(fileName); @@ -487,17 +506,6 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con smCurrentParser->setScanBuffer(script, fileName); smCurrentParser->restart(NULL); smCurrentParser->parse(); - if (gStatementList) - { - if (gAnonFunctionList) - { - // Prepend anonymous functions to statement list, so they're defined already when - // the statements run. - gAnonFunctionList->append(gStatementList); - gStatementList = gAnonFunctionList; - } - } - if (gSyntaxError) { @@ -532,7 +540,7 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con lastIp = 0; } - codeStream.emit(OP_RETURN); + codeStream.emit(OP_RETURN_VOID); codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs); lineBreakPairCount = codeStream.getNumLineBreaks(); @@ -545,6 +553,9 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con getGlobalFloatTable().write(st); getFunctionFloatTable().write(st); + // write variable mapping table + getFunctionVariableMappingTable().write(st); + if (lastIp != codeSize) Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched."); @@ -575,11 +586,9 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con st.close(); return true; - - } -ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *inString, 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"); @@ -620,7 +629,6 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in addToCodeList(); gStatementList = NULL; - gAnonFunctionList = NULL; // Set up the parser. smCurrentParser = getParserForFile(fileName); @@ -630,21 +638,11 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in smCurrentParser->setScanBuffer(string, fileName); smCurrentParser->restart(NULL); smCurrentParser->parse(); - if (gStatementList) - { - if (gAnonFunctionList) - { - // Prepend anonymous functions to statement list, so they're defined already when - // the statements run. - gAnonFunctionList->append(gStatementList); - gStatementList = gAnonFunctionList; - } - } if (!gStatementList) { delete this; - return ConsoleValueRef(); + return std::move(ConsoleValue()); } resetTables(); @@ -665,20 +663,27 @@ ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *in globalFloats = getGlobalFloatTable().build(); functionFloats = getFunctionFloatTable().build(); - codeStream.emit(OP_RETURN); + variableRegisterTable = getFunctionVariableMappingTable().copy(); + + codeStream.emit(OP_RETURN_VOID); codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs); - //dumpInstructions(0, false); - consoleAllocReset(); +#ifndef TORQUE_SHIPPING + if (Con::getBoolVariable("$Debug::DumpByteCode")) + { + dumpInstructions(); + } +#endif + if (lineBreakPairCount && fileName) calcBreakList(); if (lastIp + 1 != codeSize) Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp); - return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame); + return std::move(exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame)); } //------------------------------------------------------------------------- @@ -701,10 +706,14 @@ String CodeBlock::getFunctionArgs(U32 ip) { StringBuilder str; + StringTableEntry fnName = CodeToSTE(code, ip); + StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); + StringTableEntry fnNsName = StringTable->insert(avar("%s::%s", fnNamespace, fnName)); + U32 fnArgc = code[ip + 8]; for (U32 i = 0; i < fnArgc; ++i) { - StringTableEntry var = CodeToSTE(code, ip + (i * 2) + 9); + StringTableEntry var = variableRegisterTable.localVarToRegister[fnNsName].varList[i]; if (i != 0) str.append(", "); @@ -739,775 +748,678 @@ void CodeBlock::dumpInstructions(U32 startIp, bool upToReturn) switch (code[ip++]) { - case OP_FUNC_DECL: + case OP_FUNC_DECL: + { + StringTableEntry fnName = CodeToSTE(code, ip); + StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); + StringTableEntry fnPackage = CodeToSTE(code, ip + 4); + bool hasBody = bool(code[ip + 6]); + U32 newIp = code[ip + 7]; + U32 argc = code[ip + 8]; + U32 regCount = code[ip + 9]; + endFuncIp = newIp; + + Con::printf("%i: OP_FUNC_DECL stk=+0 name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i regCount=%i", + ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc, regCount); + + // Skip args. + + ip += 10 + argc; + smInFunction = true; + break; + } + + case OP_CREATE_OBJECT: + { + StringTableEntry objParent = CodeToSTE(code, ip); + bool isDataBlock = code[ip + 2]; + bool isInternal = code[ip + 3]; + bool isSingleton = code[ip + 4]; + U32 lineNumber = code[ip + 5]; + U32 failJump = code[ip + 6]; + + Con::printf("%i: OP_CREATE_OBJECT stk=+0 objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i", + ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump); + + ip += 7; + break; + } + + case OP_ADD_OBJECT: + { + bool placeAtRoot = code[ip++]; + const char* stk = placeAtRoot ? "+1" : "0"; + Con::printf("%i: OP_ADD_OBJECT stk=%s placeAtRoot=%i", ip - 1, stk, placeAtRoot); + break; + } + + case OP_END_OBJECT: + { + bool placeAtRoot = code[ip++]; + const char* stk = placeAtRoot ? "-1" : "0"; + Con::printf("%i: OP_END_OBJECT stk=%s placeAtRoot=%i", ip - 1, stk, placeAtRoot); + break; + } + + case OP_FINISH_OBJECT: + { + Con::printf("%i: OP_FINISH_OBJECT", ip - 1); + break; + } + + case OP_JMPIFFNOT: + { + Con::printf("%i: OP_JMPIFFNOT stk=-1 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMPIFNOT: + { + Con::printf("%i: OP_JMPIFNOT stk=-1 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMPIFF: + { + Con::printf("%i: OP_JMPIFF stk=-1 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMPIF: + { + Con::printf("%i: OP_JMPIF stk=-1 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMPIFNOT_NP: + { + Con::printf("%i: OP_JMPIFNOT_NP stk=-1 or 0 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMPIF_NP: + { + Con::printf("%i: OP_JMPIF_NP stk=-1 or 0 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_JMP: + { + Con::printf("%i: OP_JMP stk=0 ip=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_RETURN_VOID: + { + Con::printf("%i: OP_RETURN_VOID stk=0", ip - 1); + + if (upToReturn) + return; + + break; + } + + case OP_RETURN: + { + Con::printf("%i: OP_RETURN stk=-1", ip - 1); + + if (upToReturn) + return; + + break; + } + + case OP_RETURN_UINT: + { + Con::printf("%i: OP_RETURNUINT stk=-1", ip - 1); + + if (upToReturn) + return; + + break; + } + + case OP_RETURN_FLT: + { + Con::printf("%i: OP_RETURNFLT stk=-1", ip - 1); + + if (upToReturn) + return; + + break; + } + + case OP_CMPEQ: + { + Con::printf("%i: OP_CMPEQ stk=-1", ip - 1); + break; + } + + case OP_CMPGR: + { + Con::printf("%i: OP_CMPGR stk=-1", ip - 1); + break; + } + + case OP_CMPGE: + { + Con::printf("%i: OP_CMPGE stk=-1", ip - 1); + break; + } + + case OP_CMPLT: + { + Con::printf("%i: OP_CMPLT stk=-1", ip - 1); + break; + } + + case OP_CMPLE: + { + Con::printf("%i: OP_CMPLE stk=-1", ip - 1); + break; + } + + case OP_CMPNE: + { + Con::printf("%i: OP_CMPNE stk=-1", ip - 1); + break; + } + + case OP_XOR: + { + Con::printf("%i: OP_XOR stk=-1", ip - 1); + break; + } + + case OP_MOD: + { + Con::printf("%i: OP_MOD stk=-1", ip - 1); + break; + } + + case OP_BITAND: + { + Con::printf("%i: OP_BITAND stk=-1", ip - 1); + break; + } + + case OP_BITOR: + { + Con::printf("%i: OP_BITOR stk=-1", ip - 1); + break; + } + + case OP_NOT: + { + Con::printf("%i: OP_NOT stk=0", ip - 1); + break; + } + + case OP_NOTF: + { + Con::printf("%i: OP_NOTF stk=0", ip - 1); + break; + } + + case OP_ONESCOMPLEMENT: + { + Con::printf("%i: OP_ONESCOMPLEMENT stk=0", ip - 1); + break; + } + + case OP_SHR: + { + Con::printf("%i: OP_SHR stk=-1", ip - 1); + break; + } + + case OP_SHL: + { + Con::printf("%i: OP_SHL stk=-1", ip - 1); + break; + } + + case OP_AND: + { + Con::printf("%i: OP_AND stk=-1", ip - 1); + break; + } + + case OP_OR: + { + Con::printf("%i: OP_OR stk=-1", ip - 1); + break; + } + + case OP_ADD: + { + Con::printf("%i: OP_ADD stk=-1", ip - 1); + break; + } + + case OP_SUB: + { + Con::printf("%i: OP_SUB stk=-1", ip - 1); + break; + } + + case OP_MUL: + { + Con::printf("%i: OP_MUL stk=-1", ip - 1); + break; + } + + case OP_DIV: + { + Con::printf("%i: OP_DIV stk=-1", ip - 1); + break; + } + + case OP_NEG: + { + Con::printf("%i: OP_NEG stk=0", ip - 1); + break; + } + + case OP_INC: + { + Con::printf("%i: OP_INC stk=0 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_SETCURVAR: + { + StringTableEntry var = CodeToSTE(code, ip); + + Con::printf("%i: OP_SETCURVAR stk=0 var=%s", ip - 1, var); + ip += 2; + break; + } + + case OP_SETCURVAR_CREATE: + { + StringTableEntry var = CodeToSTE(code, ip); + + Con::printf("%i: OP_SETCURVAR_CREATE stk=0 var=%s", ip - 1, var); + ip += 2; + break; + } + + case OP_SETCURVAR_ARRAY: + { + Con::printf("%i: OP_SETCURVAR_ARRAY stk=0", ip - 1); + break; + } + + case OP_SETCURVAR_ARRAY_CREATE: + { + Con::printf("%i: OP_SETCURVAR_ARRAY_CREATE stk=0", ip - 1); + break; + } + + case OP_LOADVAR_UINT: + { + Con::printf("%i: OP_LOADVAR_UINT stk=+1", ip - 1); + break; + } + + case OP_LOADVAR_FLT: + { + Con::printf("%i: OP_LOADVAR_FLT stk=+1", ip - 1); + break; + } + + case OP_LOADVAR_STR: + { + Con::printf("%i: OP_LOADVAR_STR stk=+1", ip - 1); + break; + } + + case OP_SAVEVAR_UINT: + { + Con::printf("%i: OP_SAVEVAR_UINT stk=0", ip - 1); + break; + } + + case OP_SAVEVAR_FLT: + { + Con::printf("%i: OP_SAVEVAR_FLT stk=0", ip - 1); + break; + } + + case OP_SAVEVAR_STR: + { + Con::printf("%i: OP_SAVEVAR_STR stk=0", ip - 1); + break; + } + + case OP_LOAD_LOCAL_VAR_UINT: + { + Con::printf("%i: OP_LOAD_LOCAL_VAR_UINT stk=+1 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_LOAD_LOCAL_VAR_FLT: + { + Con::printf("%i: OP_LOAD_LOCAL_VAR_FLT stk=+1 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_LOAD_LOCAL_VAR_STR: + { + Con::printf("%i: OP_LOAD_LOCAL_VAR_STR stk=+1 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_SAVE_LOCAL_VAR_UINT: + { + Con::printf("%i: OP_SAVE_LOCAL_VAR_UINT stk=0 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_SAVE_LOCAL_VAR_FLT: + { + Con::printf("%i: OP_SAVE_LOCAL_VAR_FLT stk=0 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_SAVE_LOCAL_VAR_STR: + { + Con::printf("%i: OP_SAVE_LOCAL_VAR_STR stk=0 reg=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_SETCUROBJECT: + { + Con::printf("%i: OP_SETCUROBJECT stk=0", ip - 1); + break; + } + + case OP_SETCUROBJECT_NEW: + { + Con::printf("%i: OP_SETCUROBJECT_NEW stk=0", ip - 1); + break; + } + + case OP_SETCUROBJECT_INTERNAL: + { + Con::printf("%i: OP_SETCUROBJECT_INTERNAL stk=0", ip - 1); + ++ip; + break; + } + + case OP_SETCURFIELD: + { + StringTableEntry curField = CodeToSTE(code, ip); + Con::printf("%i: OP_SETCURFIELD stk=0 field=%s", ip - 1, curField); + ip += 2; + break; + } + + case OP_SETCURFIELD_ARRAY: + { + Con::printf("%i: OP_SETCURFIELD_ARRAY stk=0", ip - 1); + break; + } + + case OP_SETCURFIELD_TYPE: + { + U32 type = code[ip]; + Con::printf("%i: OP_SETCURFIELD_TYPE stk=0 type=%i", ip - 1, type); + ++ip; + break; + } + + case OP_LOADFIELD_UINT: + { + Con::printf("%i: OP_LOADFIELD_UINT stk=+1", ip - 1); + break; + } + + case OP_LOADFIELD_FLT: + { + Con::printf("%i: OP_LOADFIELD_FLT stk=+1", ip - 1); + break; + } + + case OP_LOADFIELD_STR: + { + Con::printf("%i: OP_LOADFIELD_STR stk=+1", ip - 1); + break; + } + + case OP_SAVEFIELD_UINT: + { + Con::printf("%i: OP_SAVEFIELD_UINT stk=0", ip - 1); + break; + } + + case OP_SAVEFIELD_FLT: + { + Con::printf("%i: OP_SAVEFIELD_FLT stk=0", ip - 1); + break; + } + + case OP_SAVEFIELD_STR: + { + Con::printf("%i: OP_SAVEFIELD_STR stk=0", ip - 1); + break; + } + + case OP_POP_STK: + { + Con::printf("%i: OP_POP_STK stk=-1", ip - 1); + break; + } + + case OP_LOADIMMED_UINT: + { + U32 val = code[ip]; + Con::printf("%i: OP_LOADIMMED_UINT stk=+1 val=%i", ip - 1, val); + ++ip; + break; + } + + case OP_LOADIMMED_FLT: + { + F64 val = (smInFunction ? functionFloats : globalFloats)[code[ip]]; + Con::printf("%i: OP_LOADIMMED_FLT stk=+1 val=%f", ip - 1, val); + ++ip; + break; + } + + case OP_TAG_TO_STR: + { + const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; + Con::printf("%i: OP_TAG_TO_STR stk=0 str=%s", ip - 1, str); + Con::printf(" OP_LOADIMMED_STR stk=+1 (fallthrough)"); + ++ip; + break; + } + + case OP_LOADIMMED_STR: + { + const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; + Con::printf("%i: OP_LOADIMMED_STR stk=+1 str=%s", ip - 1, str); + ++ip; + break; + } + + case OP_DOCBLOCK_STR: + { + const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; + Con::printf("%i: OP_DOCBLOCK_STR stk=0 str=%s", ip - 1, str); + ++ip; + break; + } + + case OP_LOADIMMED_IDENT: + { + StringTableEntry str = CodeToSTE(code, ip); + Con::printf("%i: OP_LOADIMMED_IDENT stk=+1 str=%s", ip - 1, str); + ip += 2; + break; + } + + case OP_CALLFUNC: + { + StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); + StringTableEntry fnName = CodeToSTE(code, ip); + U32 callType = code[ip + 4]; + + StringTableEntry callTypeName; + switch (callType) { - StringTableEntry fnName = CodeToSTE(code, ip); - StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); - StringTableEntry fnPackage = CodeToSTE(code, ip + 4); - bool hasBody = bool(code[ip + 6]); - U32 newIp = code[ip + 7]; - U32 argc = code[ip + 8]; - endFuncIp = newIp; - - Con::printf("%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i", - ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc); - - // Skip args. - - ip += 9 + (argc * 2); - smInFunction = true; - break; + case FuncCallExprNode::FunctionCall: callTypeName = "FunctionCall"; break; + case FuncCallExprNode::MethodCall: callTypeName = "MethodCall"; break; + case FuncCallExprNode::ParentCall: callTypeName = "ParentCall"; break; + case FuncCallExprNode::StaticCall: callTypeName = "StaticCall"; break; } - case OP_CREATE_OBJECT: + Con::printf("%i: OP_CALLFUNC stk=+1 name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, callTypeName); + + ip += 5; + break; + } + + case OP_ADVANCE_STR_APPENDCHAR: + { + char ch = code[ip]; + Con::printf("%i: OP_ADVANCE_STR_APPENDCHAR stk=0 char=%c", ip - 1, ch); + ++ip; + break; + } + + case OP_REWIND_STR: + { + Con::printf("%i: OP_REWIND_STR stk=0", ip - 1); + Con::printf(" OP_TERMINATE_REWIND_STR stk=-1 (fallthrough)"); + break; + } + + case OP_TERMINATE_REWIND_STR: + { + Con::printf("%i: OP_TERMINATE_REWIND_STR stk=-1", ip - 1); + break; + } + + case OP_COMPARE_STR: + { + Con::printf("%i: OP_COMPARE_STR stk=-1", ip - 1); + break; + } + + case OP_PUSH: + { + Con::printf("%i: OP_PUSH stk=-1", ip - 1); + break; + } + + case OP_PUSH_FRAME: + { + Con::printf("%i: OP_PUSH_FRAME stk=0 count=%i", ip - 1, code[ip]); + ++ip; + break; + } + + case OP_ASSERT: + { + const char* message = (smInFunction ? functionStrings : globalStrings) + code[ip]; + Con::printf("%i: OP_ASSERT stk=-1 message=%s", ip - 1, message); + ++ip; + break; + } + + case OP_BREAK: + { + Con::printf("%i: OP_BREAK stk=0", ip - 1); + break; + } + + case OP_ITER_BEGIN: + { + bool isGlobal = code[ip]; + if (isGlobal) { - StringTableEntry objParent = CodeToSTE(code, ip); - bool isDataBlock = code[ip + 2]; - bool isInternal = code[ip + 3]; - bool isSingleton = code[ip + 4]; - U32 lineNumber = code[ip + 5]; - U32 failJump = code[ip + 6]; + StringTableEntry varName = CodeToSTE(code, ip + 1); + U32 failIp = code[ip + 3]; - Con::printf("%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i", - ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump); + Con::printf("%i: OP_ITER_BEGIN stk=0 varName=%s failIp=%i isGlobal=%s", ip - 1, varName, failIp, "true"); - ip += 7; - break; - } - - case OP_ADD_OBJECT: - { - bool placeAtRoot = code[ip++]; - Con::printf("%i: OP_ADD_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot); - break; - } - - case OP_END_OBJECT: - { - bool placeAtRoot = code[ip++]; - Con::printf("%i: OP_END_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot); - break; - } - - case OP_FINISH_OBJECT: - { - Con::printf("%i: OP_FINISH_OBJECT", ip - 1); - break; - } - - case OP_JMPIFFNOT: - { - Con::printf("%i: OP_JMPIFFNOT ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMPIFNOT: - { - Con::printf("%i: OP_JMPIFNOT ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMPIFF: - { - Con::printf("%i: OP_JMPIFF ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMPIF: - { - Con::printf("%i: OP_JMPIF ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMPIFNOT_NP: - { - Con::printf("%i: OP_JMPIFNOT_NP ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMPIF_NP: - { - Con::printf("%i: OP_JMPIF_NP ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_JMP: - { - Con::printf("%i: OP_JMP ip=%i", ip - 1, code[ip]); - ++ip; - break; - } - - case OP_RETURN: - { - Con::printf("%i: OP_RETURN", ip - 1); - - if (upToReturn) - return; - - break; - } - - case OP_RETURN_VOID: - { - Con::printf("%i: OP_RETURNVOID", ip - 1); - - if (upToReturn) - return; - - break; - } - - case OP_RETURN_UINT: - { - Con::printf("%i: OP_RETURNUINT", ip - 1); - - if (upToReturn) - return; - - break; - } - - case OP_RETURN_FLT: - { - Con::printf("%i: OP_RETURNFLT", ip - 1); - - if (upToReturn) - return; - - break; - } - - case OP_CMPEQ: - { - Con::printf("%i: OP_CMPEQ", ip - 1); - break; - } - - case OP_CMPGR: - { - Con::printf("%i: OP_CMPGR", ip - 1); - break; - } - - case OP_CMPGE: - { - Con::printf("%i: OP_CMPGE", ip - 1); - break; - } - - case OP_CMPLT: - { - Con::printf("%i: OP_CMPLT", ip - 1); - break; - } - - case OP_CMPLE: - { - Con::printf("%i: OP_CMPLE", ip - 1); - break; - } - - case OP_CMPNE: - { - Con::printf("%i: OP_CMPNE", ip - 1); - break; - } - - case OP_XOR: - { - Con::printf("%i: OP_XOR", ip - 1); - break; - } - - case OP_MOD: - { - Con::printf("%i: OP_MOD", ip - 1); - break; - } - - case OP_BITAND: - { - Con::printf("%i: OP_BITAND", ip - 1); - break; - } - - case OP_BITOR: - { - Con::printf("%i: OP_BITOR", ip - 1); - break; - } - - case OP_NOT: - { - Con::printf("%i: OP_NOT", ip - 1); - break; - } - - case OP_NOTF: - { - Con::printf("%i: OP_NOTF", ip - 1); - break; - } - - case OP_ONESCOMPLEMENT: - { - Con::printf("%i: OP_ONESCOMPLEMENT", ip - 1); - break; - } - - case OP_SHR: - { - Con::printf("%i: OP_SHR", ip - 1); - break; - } - - case OP_SHL: - { - Con::printf("%i: OP_SHL", ip - 1); - break; - } - - case OP_AND: - { - Con::printf("%i: OP_AND", ip - 1); - break; - } - - case OP_OR: - { - Con::printf("%i: OP_OR", ip - 1); - break; - } - - case OP_ADD: - { - Con::printf("%i: OP_ADD", ip - 1); - break; - } - - case OP_SUB: - { - Con::printf("%i: OP_SUB", ip - 1); - break; - } - - case OP_MUL: - { - Con::printf("%i: OP_MUL", ip - 1); - break; - } - - case OP_DIV: - { - Con::printf("%i: OP_DIV", ip - 1); - break; - } - - case OP_NEG: - { - Con::printf("%i: OP_NEG", ip - 1); - break; - } - - case OP_INC: - { - Con::printf("%i: OP_INC varName=%s", ip - 1, CodeToSTE(code, ip)); - ip += 2; - break; - } - - case OP_DEC: - { - Con::printf("%i: OP_DEC varName=%s", ip - 1, CodeToSTE(code, ip)); - ip += 2; - break; - } - - case OP_SETCURVAR: - { - StringTableEntry var = CodeToSTE(code, ip); - - Con::printf("%i: OP_SETCURVAR var=%s", ip - 1, var); - ip += 2; - break; - } - - case OP_SETCURVAR_CREATE: - { - StringTableEntry var = CodeToSTE(code, ip); - - Con::printf("%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var); - ip += 2; - break; - } - - case OP_SETCURVAR_ARRAY: - { - Con::printf("%i: OP_SETCURVAR_ARRAY", ip - 1); - break; - } - - case OP_SETCURVAR_ARRAY_VARLOOKUP: - { - StringTableEntry arrayName = CodeToSTE(code, ip); - StringTableEntry arrayLookup = CodeToSTE(code, ip + 2); - - Con::printf("%i: OP_SETCURVAR_ARRAY_VARLOOKUP arrayName=%s arrayLookup=%s", ip - 1, arrayName, arrayLookup); ip += 4; - break; } - - case OP_SETCURVAR_ARRAY_CREATE: + else { - Con::printf("%i: OP_SETCURVAR_ARRAY_CREATE", ip - 1); - break; - } - - case OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP: - { - StringTableEntry arrayName = CodeToSTE(code, ip); - StringTableEntry arrayLookup = CodeToSTE(code, ip + 2); - - Con::printf("%i: OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP arrayName=%s arrayLookup=%s", ip - 1, arrayName, arrayLookup); - ip += 4; - break; - } - - case OP_LOADVAR_UINT: - { - Con::printf("%i: OP_LOADVAR_UINT", ip - 1); - break; - } - - case OP_LOADVAR_FLT: - { - Con::printf("%i: OP_LOADVAR_FLT", ip - 1); - break; - } - - case OP_LOADVAR_STR: - { - Con::printf("%i: OP_LOADVAR_STR", ip - 1); - break; - } - - case OP_LOADVAR_VAR: - { - Con::printf("%i: OP_LOADVAR_VAR", ip - 1); - break; - } - - case OP_SAVEVAR_UINT: - { - Con::printf("%i: OP_SAVEVAR_UINT", ip - 1); - break; - } - - case OP_SAVEVAR_FLT: - { - Con::printf("%i: OP_SAVEVAR_FLT", ip - 1); - break; - } - - case OP_SAVEVAR_STR: - { - Con::printf("%i: OP_SAVEVAR_STR", ip - 1); - break; - } - - case OP_SAVEVAR_VAR: - { - Con::printf("%i: OP_SAVEVAR_VAR", ip - 1); - break; - } - - case OP_SETCUROBJECT: - { - Con::printf("%i: OP_SETCUROBJECT", ip - 1); - break; - } - - case OP_SETCUROBJECT_NEW: - { - Con::printf("%i: OP_SETCUROBJECT_NEW", ip - 1); - break; - } - - case OP_SETCUROBJECT_INTERNAL: - { - Con::printf("%i: OP_SETCUROBJECT_INTERNAL", ip - 1); - ++ip; - break; - } - - case OP_SETCURFIELD: - { - StringTableEntry curField = CodeToSTE(code, ip); - Con::printf("%i: OP_SETCURFIELD field=%s", ip - 1, curField); - ip += 2; - break; - } - - case OP_SETCURFIELD_ARRAY: - { - Con::printf("%i: OP_SETCURFIELD_ARRAY", ip - 1); - break; - } - - case OP_SETCURFIELD_ARRAY_VAR: - { - StringTableEntry var = CodeToSTE(code, ip); - Con::printf("%i: OP_SETCURFIELD_ARRAY_VAR var=%s", ip - 1, var); - ip += 2; - break; - } - - case OP_SETCURFIELD_THIS: - { - StringTableEntry curField = CodeToSTE(code, ip); - Con::printf("%i: OP_SETCURFIELD_THIS field=%s", ip - 1, curField); - ip += 2; - break; - } - - case OP_SETCURFIELD_TYPE: - { - U32 type = code[ip]; - Con::printf("%i: OP_SETCURFIELD_TYPE type=%i", ip - 1, type); - ++ip; - break; - } - - case OP_LOADFIELD_UINT: - { - Con::printf("%i: OP_LOADFIELD_UINT", ip - 1); - break; - } - - case OP_LOADFIELD_FLT: - { - Con::printf("%i: OP_LOADFIELD_FLT", ip - 1); - break; - } - - case OP_LOADFIELD_STR: - { - Con::printf("%i: OP_LOADFIELD_STR", ip - 1); - break; - } - - case OP_SAVEFIELD_UINT: - { - Con::printf("%i: OP_SAVEFIELD_UINT", ip - 1); - break; - } - - case OP_SAVEFIELD_FLT: - { - Con::printf("%i: OP_SAVEFIELD_FLT", ip - 1); - break; - } - - case OP_SAVEFIELD_STR: - { - Con::printf("%i: OP_SAVEFIELD_STR", ip - 1); - break; - } - - case OP_STR_TO_UINT: - { - Con::printf("%i: OP_STR_TO_UINT", ip - 1); - break; - } - - case OP_STR_TO_FLT: - { - Con::printf("%i: OP_STR_TO_FLT", ip - 1); - break; - } - - case OP_STR_TO_NONE: - { - Con::printf("%i: OP_STR_TO_NONE", ip - 1); - break; - } - - case OP_FLT_TO_UINT: - { - Con::printf("%i: OP_FLT_TO_UINT", ip - 1); - break; - } - - case OP_FLT_TO_STR: - { - Con::printf("%i: OP_FLT_TO_STR", ip - 1); - break; - } - - case OP_FLT_TO_NONE: - { - Con::printf("%i: OP_FLT_TO_NONE", ip - 1); - break; - } - - case OP_UINT_TO_FLT: - { - Con::printf("%i: OP_SAVEFIELD_STR", ip - 1); - break; - } - - case OP_UINT_TO_STR: - { - Con::printf("%i: OP_UINT_TO_STR", ip - 1); - break; - } - - case OP_UINT_TO_NONE: - { - Con::printf("%i: OP_UINT_TO_NONE", ip - 1); - break; - } - - case OP_COPYVAR_TO_NONE: - { - Con::printf("%i: OP_COPYVAR_TO_NONE", ip - 1); - break; - } - - case OP_LOADIMMED_UINT: - { - U32 val = code[ip]; - Con::printf("%i: OP_LOADIMMED_UINT val=%i", ip - 1, val); - ++ip; - break; - } - - case OP_LOADIMMED_FLT: - { - F64 val = (smInFunction ? functionFloats : globalFloats)[code[ip]]; - Con::printf("%i: OP_LOADIMMED_FLT val=%f", ip - 1, val); - ++ip; - break; - } - - case OP_TAG_TO_STR: - { - const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; - Con::printf("%i: OP_TAG_TO_STR str=%s", ip - 1, str); - ++ip; - break; - } - - case OP_LOADIMMED_STR: - { - const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; - Con::printf("%i: OP_LOADIMMED_STR str=%s", ip - 1, str); - ++ip; - break; - } - - case OP_DOCBLOCK_STR: - { - const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip]; - Con::printf("%i: OP_DOCBLOCK_STR str=%s", ip - 1, str); - ++ip; - break; - } - - case OP_LOADIMMED_IDENT: - { - StringTableEntry str = CodeToSTE(code, ip); - Con::printf("%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str); - ip += 2; - break; - } - - case OP_CALLFUNC_RESOLVE: - { - StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); - StringTableEntry fnName = CodeToSTE(code, ip); - U32 callType = code[ip + 2]; - - Con::printf("%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, - callType == FuncCallExprNode::FunctionCall ? "FunctionCall" - : callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall"); - - ip += 5; - break; - } - - case OP_CALLFUNC: - { - StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); - StringTableEntry fnName = CodeToSTE(code, ip); - U32 callType = code[ip + 4]; - - Con::printf("%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace, - callType == FuncCallExprNode::FunctionCall ? "FunctionCall" - : callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall"); - - ip += 5; - break; - } - - case OP_CALLFUNC_POINTER: - { - Con::printf("%i: OP_CALLFUNC_POINTER", ip - 1); - break; - } - - case OP_CALLFUNC_THIS: - { - StringTableEntry fnName = CodeToSTE(code, ip); - Con::printf("%i: OP_CALLFUNC_THIS name=%s ", ip - 1, fnName); - - ip += 2; - break; - } - - case OP_ADVANCE_STR: - { - Con::printf("%i: OP_ADVANCE_STR", ip - 1); - break; - } - - case OP_ADVANCE_STR_APPENDCHAR: - { - char ch = code[ip]; - Con::printf("%i: OP_ADVANCE_STR_APPENDCHAR char=%c", ip - 1, ch); - ++ip; - break; - } - - case OP_ADVANCE_STR_COMMA: - { - Con::printf("%i: OP_ADVANCE_STR_COMMA", ip - 1); - break; - } - - case OP_ADVANCE_STR_NUL: - { - Con::printf("%i: OP_ADVANCE_STR_NUL", ip - 1); - break; - } - - case OP_REWIND_STR: - { - Con::printf("%i: OP_REWIND_STR", ip - 1); - break; - } - - case OP_TERMINATE_REWIND_STR: - { - Con::printf("%i: OP_TERMINATE_REWIND_STR", ip - 1); - break; - } - - case OP_COMPARE_STR: - { - Con::printf("%i: OP_COMPARE_STR", ip - 1); - break; - } - - case OP_PUSH: - { - Con::printf("%i: OP_PUSH", ip - 1); - break; - } - - case OP_PUSH_UINT: - { - Con::printf("%i: OP_PUSH_UINT", ip - 1); - break; - } - - case OP_PUSH_FLT: - { - Con::printf("%i: OP_PUSH_FLT", ip - 1); - break; - } - - case OP_PUSH_VAR: - { - Con::printf("%i: OP_PUSH_VAR", ip - 1); - break; - } - - case OP_PUSH_THIS: - { - Con::printf("%i: OP_PUSH_THIS varName=%s", ip - 1, CodeToSTE(code, ip)); - ip += 2; - break; - } - - case OP_PUSH_FRAME: - { - Con::printf("%i: OP_PUSH_FRAME", ip - 1); - break; - } - - case OP_ASSERT: - { - const char* message = (smInFunction ? functionStrings : globalStrings) + code[ip]; - Con::printf("%i: OP_ASSERT message=%s", ip - 1, message); - ++ip; - break; - } - - case OP_BREAK: - { - Con::printf("%i: OP_BREAK", ip - 1); - break; - } - - case OP_ITER_BEGIN: - { - StringTableEntry varName = CodeToSTE(code, ip); + S32 reg = code[ip + 1]; U32 failIp = code[ip + 2]; - Con::printf("%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp); + Con::printf("%i: OP_ITER_BEGIN stk=0 varRegister=%d failIp=%i isGlobal=%s", ip - 1, reg, failIp, "false"); ip += 3; - break; } + break; + } - case OP_ITER_BEGIN_STR: + case OP_ITER_BEGIN_STR: + { + bool isGlobal = code[ip]; + if (isGlobal) { - StringTableEntry varName = CodeToSTE(code, ip); + StringTableEntry varName = CodeToSTE(code, ip + 1); + U32 failIp = code[ip + 3]; + + Con::printf("%i: OP_ITER_BEGIN_STR stk=0 varName=%s failIp=%i isGlobal=%s", ip - 1, varName, failIp, "true"); + Con::printf(" OP_ITER_BEGIN stk=0 (fallthrough)"); + + ip += 4; + } + else + { + S32 reg = code[ip + 1]; U32 failIp = code[ip + 2]; - Con::printf("%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp); + Con::printf("%i: OP_ITER_BEGIN_STR stk=0 varRegister=%d failIp=%i isGlobal=%s", ip - 1, reg, failIp, "false"); + Con::printf(" OP_ITER_BEGIN stk=0 (fallthrough)"); ip += 3; - break; } - case OP_ITER: - { - U32 breakIp = code[ip]; + break; + } - Con::printf("%i: OP_ITER breakIp=%i", ip - 1, breakIp); + case OP_ITER: + { + U32 breakIp = code[ip]; - ++ip; - break; - } + Con::printf("%i: OP_ITER stk=0 breakIp=%i", ip - 1, breakIp); - case OP_ITER_END: - { - Con::printf("%i: OP_ITER_END", ip - 1); - break; - } + ++ip; + break; + } - default: - Con::printf("%i: !!INVALID!!", ip - 1); - break; + case OP_ITER_END: + { + Con::printf("%i: OP_ITER_END stk=-1", ip - 1); + break; + } + + default: + Con::printf("%i: !!INVALID!!", ip - 1); + break; } } diff --git a/Engine/source/console/codeBlock.h b/Engine/source/console/codeBlock.h index f789f1a92..57370f683 100644 --- a/Engine/source/console/codeBlock.h +++ b/Engine/source/console/codeBlock.h @@ -23,19 +23,36 @@ #ifndef _CODEBLOCK_H_ #define _CODEBLOCK_H_ +#include +#include + +struct CompilerLocalVariableToRegisterMappingTable +{ + struct RemappingTable + { + std::vector varList; + }; + + std::unordered_map localVarToRegister; + + void add(StringTableEntry functionName, StringTableEntry namespaceName, StringTableEntry varName); + S32 lookup(StringTableEntry namespaceName, StringTableEntry functionName, StringTableEntry varName); + CompilerLocalVariableToRegisterMappingTable copy(); + void reset(); + void write(Stream& stream); +}; + #include "console/compiler.h" #include "console/consoleParser.h" class Stream; class ConsoleValue; -class ConsoleValueRef; /// Core TorqueScript code management class. /// /// This class represents a block of code, usually mapped directly to a file. class CodeBlock { - friend class CodeInterpreter; private: static CodeBlock* smCodeBlockList; static CodeBlock* smCurrentCodeBlock; @@ -78,6 +95,8 @@ public: U32 codeSize; U32 *code; + CompilerLocalVariableToRegisterMappingTable variableRegisterTable; + U32 refCount; U32 lineBreakPairCount; U32 *lineBreakPairs; @@ -130,7 +149,7 @@ public: /// with, zero being the top of the stack. If the the index is /// -1 a new frame is created. If the index is out of range the /// top stack frame is used. - ConsoleValueRef compileExec(StringTableEntry fileName, const char *script, + ConsoleValue compileExec(StringTableEntry fileName, const char *script, bool noCalls, S32 setFrame = -1); /// Executes the existing code in the CodeBlock. The return string is any @@ -148,9 +167,9 @@ public: /// -1 a new frame is created. If the index is out of range the /// top stack frame is used. /// @param packageName The code package name or null. - ConsoleValueRef exec(U32 offset, const char *fnName, Namespace *ns, U32 argc, - ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, + ConsoleValue exec(U32 offset, const char *fnName, Namespace *ns, U32 argc, + ConsoleValue *argv, bool noCalls, StringTableEntry packageName, S32 setFrame = -1); }; -#endif \ No newline at end of file +#endif diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp deleted file mode 100644 index 614eb8fec..000000000 --- a/Engine/source/console/codeInterpreter.cpp +++ /dev/null @@ -1,3018 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// 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. -//----------------------------------------------------------------------------- - -//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// -// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames -// Copyright (C) 2015 Faust Logic, Inc. -//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// - -#include "console/codeInterpreter.h" -#include "console/compiler.h" -#include "console/simBase.h" -#include "console/telnetDebugger.h" -#include "sim/netStringTable.h" -#include "console/ICallMethod.h" -#include "console/stringStack.h" -#include "util/messaging/message.h" -#include "core/strings/findMatch.h" -#include "core/strings/stringUnit.h" -#include "console/console.h" -#include "console/consoleInternal.h" -#include "cinterface/cinterface.h" - -//#define TORQUE_VALIDATE_STACK - -using namespace Compiler; - -enum EvalConstants -{ - MaxStackSize = 1024, - FieldBufferSizeString = 2048, - FieldBufferSizeNumeric = 128, - MethodOnComponent = -2 -}; - -namespace Con -{ - // Current script file name and root, these are registered as - // console variables. - extern StringTableEntry gCurrentFile; - extern StringTableEntry gCurrentRoot; - extern S32 gObjectCopyFailures; -} - -// Gets a component of an object's field value or a variable and returns it -// in val. -static void getFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField, char val[]) -{ - const char* prevVal = NULL; - - // Grab value from object. - if (object && field) - prevVal = object->getDataField(field, array); - - // Otherwise, grab from the string stack. The value coming in will always - // be a string because that is how multicomponent variables are handled. - else - prevVal = STR.getStringValue(); - - // Make sure we got a value. - if (prevVal && *prevVal) - { - static const StringTableEntry xyzw[] = - { - StringTable->insert("x"), - StringTable->insert("y"), - StringTable->insert("z"), - StringTable->insert("w") - }; - - static const StringTableEntry rgba[] = - { - StringTable->insert("r"), - StringTable->insert("g"), - StringTable->insert("b"), - StringTable->insert("a") - }; - - // Translate xyzw and rgba into the indexed component - // of the variable or field. - if (subField == xyzw[0] || subField == rgba[0]) - dStrcpy(val, StringUnit::getUnit(prevVal, 0, " \t\n"), 128); - - else if (subField == xyzw[1] || subField == rgba[1]) - dStrcpy(val, StringUnit::getUnit(prevVal, 1, " \t\n"), 128); - - else if (subField == xyzw[2] || subField == rgba[2]) - dStrcpy(val, StringUnit::getUnit(prevVal, 2, " \t\n"), 128); - - else if (subField == xyzw[3] || subField == rgba[3]) - dStrcpy(val, StringUnit::getUnit(prevVal, 3, " \t\n"), 128); - - else - val[0] = 0; - } - else - val[0] = 0; -} - -// Sets a component of an object's field value based on the sub field. 'x' will -// set the first field, 'y' the second, and 'z' the third. -static void setFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField) -{ - // Copy the current string value - char strValue[1024]; - dStrncpy(strValue, STR.getStringValue(), 1024); - - char val[1024] = ""; - const char* prevVal = NULL; - - // Set the value on an object field. - if (object && field) - prevVal = object->getDataField(field, array); - - // Set the value on a variable. - else if (gEvalState.currentVariable) - prevVal = gEvalState.getStringVariable(); - - // Ensure that the variable has a value - if (!prevVal) - return; - - static const StringTableEntry xyzw[] = - { - StringTable->insert("x"), - StringTable->insert("y"), - StringTable->insert("z"), - StringTable->insert("w") - }; - - static const StringTableEntry rgba[] = - { - StringTable->insert("r"), - StringTable->insert("g"), - StringTable->insert("b"), - StringTable->insert("a") - }; - - // Insert the value into the specified - // component of the string. - if (subField == xyzw[0] || subField == rgba[0]) - dStrcpy(val, StringUnit::setUnit(prevVal, 0, strValue, " \t\n"), 128); - - else if (subField == xyzw[1] || subField == rgba[1]) - dStrcpy(val, StringUnit::setUnit(prevVal, 1, strValue, " \t\n"), 128); - - else if (subField == xyzw[2] || subField == rgba[2]) - dStrcpy(val, StringUnit::setUnit(prevVal, 2, strValue, " \t\n"), 128); - - else if (subField == xyzw[3] || subField == rgba[3]) - dStrcpy(val, StringUnit::setUnit(prevVal, 3, strValue, " \t\n"), 128); - - if (val[0] != 0) - { - // Update the field or variable. - if (object && field) - object->setDataField(field, 0, val); - else if (gEvalState.currentVariable) - gEvalState.setStringVariable(val); - } -} -extern ExprEvalState gEvalState; - -char sTraceBuffer[1024]; - -StringStack STR; -ConsoleValueStack CSTK; - -U32 _FLT = 0; ///< Stack pointer for floatStack. -U32 _UINT = 0; ///< Stack pointer for intStack. -U32 _ITER = 0; ///< Stack pointer for iterStack. - -IterStackRecord iterStack[MaxStackSize]; - -F64 floatStack[MaxStackSize]; -S64 intStack[MaxStackSize]; - -char curFieldArray[256]; -char prevFieldArray[256]; - -typedef OPCodeReturn(CodeInterpreter::*OpFn)(U32&); - -static OpFn gOpCodeArray[MAX_OP_CODELEN]; - -CodeInterpreter::CodeInterpreter(CodeBlock *cb) : - mCodeBlock(cb), - mIterDepth(0), - mCurFloatTable(nullptr), - mCurStringTable(nullptr), - mThisFunctionName(nullptr), - mPopFrame(false), - mObjectCreationStackIndex(0), - mCurrentNewObject(nullptr), - mFailJump(0), - mPrevField(nullptr), - mCurField(nullptr), - mPrevObject(nullptr), - mCurObject(nullptr), - mSaveObject(nullptr), - mThisObject(nullptr), - mNSEntry(nullptr), - mCurFNDocBlock(nullptr), - mCurNSDocBlock(nullptr), - mCallArgc(0), - mCallArgv(nullptr), - mSaveCodeBlock(nullptr), - mCurrentInstruction(0) -{ - dMemset(&mExec, 0, sizeof(mExec)); - dMemset(&mObjectCreationStack, 0, sizeof(mObjectCreationStack)); - dMemset(&mNSDocBlockClass, 0, sizeof(mNSDocBlockClass)); -} - -CodeInterpreter::~CodeInterpreter() -{ -} - -void CodeInterpreter::init() -{ - gOpCodeArray[OP_FUNC_DECL] = &CodeInterpreter::op_func_decl; - gOpCodeArray[OP_CREATE_OBJECT] = &CodeInterpreter::op_create_object; - gOpCodeArray[OP_ADD_OBJECT] = &CodeInterpreter::op_add_object; - gOpCodeArray[OP_END_OBJECT] = &CodeInterpreter::op_end_object; - gOpCodeArray[OP_FINISH_OBJECT] = &CodeInterpreter::op_finish_object; - gOpCodeArray[OP_JMPIFFNOT] = &CodeInterpreter::op_jmpiffnot; - gOpCodeArray[OP_JMPIFNOT] = &CodeInterpreter::op_jmpifnot; - gOpCodeArray[OP_JMPIFF] = &CodeInterpreter::op_jmpiff; - gOpCodeArray[OP_JMPIF] = &CodeInterpreter::op_jmpif; - gOpCodeArray[OP_JMPIFNOT_NP] = &CodeInterpreter::op_jmpifnot_np; - gOpCodeArray[OP_JMPIF_NP] = &CodeInterpreter::op_jmpif_np; - gOpCodeArray[OP_JMP] = &CodeInterpreter::op_jmp; - gOpCodeArray[OP_RETURN] = &CodeInterpreter::op_return; - gOpCodeArray[OP_RETURN_VOID] = &CodeInterpreter::op_return_void; - gOpCodeArray[OP_RETURN_FLT] = &CodeInterpreter::op_return_flt; - gOpCodeArray[OP_RETURN_UINT] = &CodeInterpreter::op_return_uint; - gOpCodeArray[OP_CMPEQ] = &CodeInterpreter::op_cmpeq; - gOpCodeArray[OP_CMPGR] = &CodeInterpreter::op_cmpgr; - gOpCodeArray[OP_CMPGE] = &CodeInterpreter::op_cmpge; - gOpCodeArray[OP_CMPLT] = &CodeInterpreter::op_cmplt; - gOpCodeArray[OP_CMPLE] = &CodeInterpreter::op_cmple; - gOpCodeArray[OP_CMPNE] = &CodeInterpreter::op_cmpne; - gOpCodeArray[OP_XOR] = &CodeInterpreter::op_xor; - gOpCodeArray[OP_MOD] = &CodeInterpreter::op_mod; - gOpCodeArray[OP_BITAND] = &CodeInterpreter::op_bitand; - gOpCodeArray[OP_BITOR] = &CodeInterpreter::op_bitor; - gOpCodeArray[OP_NOT] = &CodeInterpreter::op_not; - gOpCodeArray[OP_NOTF] = &CodeInterpreter::op_notf; - gOpCodeArray[OP_ONESCOMPLEMENT] = &CodeInterpreter::op_onescomplement; - gOpCodeArray[OP_SHR] = &CodeInterpreter::op_shr; - gOpCodeArray[OP_SHL] = &CodeInterpreter::op_shl; - gOpCodeArray[OP_AND] = &CodeInterpreter::op_and; - gOpCodeArray[OP_OR] = &CodeInterpreter::op_or; - gOpCodeArray[OP_ADD] = &CodeInterpreter::op_add; - gOpCodeArray[OP_SUB] = &CodeInterpreter::op_sub; - gOpCodeArray[OP_MUL] = &CodeInterpreter::op_mul; - gOpCodeArray[OP_DIV] = &CodeInterpreter::op_div; - gOpCodeArray[OP_NEG] = &CodeInterpreter::op_neg; - gOpCodeArray[OP_INC] = &CodeInterpreter::op_inc; - gOpCodeArray[OP_DEC] = &CodeInterpreter::op_dec; - gOpCodeArray[OP_SETCURVAR] = &CodeInterpreter::op_setcurvar; - gOpCodeArray[OP_SETCURVAR_CREATE] = &CodeInterpreter::op_setcurvar_create; - gOpCodeArray[OP_SETCURVAR_ARRAY] = &CodeInterpreter::op_setcurvar_array; - gOpCodeArray[OP_SETCURVAR_ARRAY_VARLOOKUP] = &CodeInterpreter::op_setcurvar_array_varlookup; - gOpCodeArray[OP_SETCURVAR_ARRAY_CREATE] = &CodeInterpreter::op_setcurvar_array_create; - gOpCodeArray[OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP] = &CodeInterpreter::op_setcurvar_array_create_varlookup; - gOpCodeArray[OP_LOADVAR_UINT] = &CodeInterpreter::op_loadvar_uint; - gOpCodeArray[OP_LOADVAR_FLT] = &CodeInterpreter::op_loadvar_flt; - gOpCodeArray[OP_LOADVAR_STR] = &CodeInterpreter::op_loadvar_str; - gOpCodeArray[OP_LOADVAR_VAR] = &CodeInterpreter::op_loadvar_var; - gOpCodeArray[OP_SAVEVAR_UINT] = &CodeInterpreter::op_savevar_uint; - gOpCodeArray[OP_SAVEVAR_FLT] = &CodeInterpreter::op_savevar_flt; - gOpCodeArray[OP_SAVEVAR_STR] = &CodeInterpreter::op_savevar_str; - gOpCodeArray[OP_SAVEVAR_VAR] = &CodeInterpreter::op_savevar_var; - gOpCodeArray[OP_SETCUROBJECT] = &CodeInterpreter::op_setcurobject; - gOpCodeArray[OP_SETCUROBJECT_INTERNAL] = &CodeInterpreter::op_setcurobject_internal; - gOpCodeArray[OP_SETCUROBJECT_NEW] = &CodeInterpreter::op_setcurobject_new; - gOpCodeArray[OP_SETCURFIELD] = &CodeInterpreter::op_setcurfield; - gOpCodeArray[OP_SETCURFIELD_ARRAY] = &CodeInterpreter::op_setcurfield_array; - gOpCodeArray[OP_SETCURFIELD_TYPE] = &CodeInterpreter::op_setcurfield_type; - gOpCodeArray[OP_SETCURFIELD_ARRAY_VAR] = &CodeInterpreter::op_setcurfield_array_var; - gOpCodeArray[OP_SETCURFIELD_THIS] = &CodeInterpreter::op_setcurfield_this; - gOpCodeArray[OP_LOADFIELD_UINT] = &CodeInterpreter::op_loadfield_uint; - gOpCodeArray[OP_LOADFIELD_FLT] = &CodeInterpreter::op_loadfield_flt; - gOpCodeArray[OP_LOADFIELD_STR] = &CodeInterpreter::op_loadfield_str; - gOpCodeArray[OP_SAVEFIELD_UINT] = &CodeInterpreter::op_savefield_uint; - gOpCodeArray[OP_SAVEFIELD_FLT] = &CodeInterpreter::op_savefield_flt; - gOpCodeArray[OP_SAVEFIELD_STR] = &CodeInterpreter::op_savefield_str; - gOpCodeArray[OP_STR_TO_UINT] = &CodeInterpreter::op_str_to_uint; - gOpCodeArray[OP_STR_TO_FLT] = &CodeInterpreter::op_str_to_flt; - gOpCodeArray[OP_STR_TO_NONE] = &CodeInterpreter::op_str_to_none; - gOpCodeArray[OP_FLT_TO_UINT] = &CodeInterpreter::op_flt_to_uint; - gOpCodeArray[OP_FLT_TO_STR] = &CodeInterpreter::op_flt_to_str; - gOpCodeArray[OP_FLT_TO_NONE] = &CodeInterpreter::op_flt_to_none; - gOpCodeArray[OP_UINT_TO_FLT] = &CodeInterpreter::op_uint_to_flt; - gOpCodeArray[OP_UINT_TO_STR] = &CodeInterpreter::op_uint_to_str; - gOpCodeArray[OP_UINT_TO_NONE] = &CodeInterpreter::op_uint_to_none; - gOpCodeArray[OP_COPYVAR_TO_NONE] = &CodeInterpreter::op_copyvar_to_none; - gOpCodeArray[OP_LOADIMMED_UINT] = &CodeInterpreter::op_loadimmed_uint; - gOpCodeArray[OP_LOADIMMED_FLT] = &CodeInterpreter::op_loadimmed_flt; - gOpCodeArray[OP_TAG_TO_STR] = &CodeInterpreter::op_tag_to_str; - gOpCodeArray[OP_LOADIMMED_STR] = &CodeInterpreter::op_loadimmed_str; - gOpCodeArray[OP_DOCBLOCK_STR] = &CodeInterpreter::op_docblock_str; - gOpCodeArray[OP_LOADIMMED_IDENT] = &CodeInterpreter::op_loadimmed_ident; - gOpCodeArray[OP_CALLFUNC_RESOLVE] = &CodeInterpreter::op_callfunc_resolve; - gOpCodeArray[OP_CALLFUNC] = &CodeInterpreter::op_callfunc; - gOpCodeArray[OP_CALLFUNC_POINTER] = &CodeInterpreter::op_callfunc_pointer; - gOpCodeArray[OP_CALLFUNC_THIS] = &CodeInterpreter::op_callfunc_this; - gOpCodeArray[OP_ADVANCE_STR] = &CodeInterpreter::op_advance_str; - gOpCodeArray[OP_ADVANCE_STR_APPENDCHAR] = &CodeInterpreter::op_advance_str_appendchar; - gOpCodeArray[OP_ADVANCE_STR_COMMA] = &CodeInterpreter::op_advance_str_comma; - gOpCodeArray[OP_ADVANCE_STR_NUL] = &CodeInterpreter::op_advance_str_nul; - gOpCodeArray[OP_REWIND_STR] = &CodeInterpreter::op_rewind_str; - gOpCodeArray[OP_TERMINATE_REWIND_STR] = &CodeInterpreter::op_terminate_rewind_str; - gOpCodeArray[OP_COMPARE_STR] = &CodeInterpreter::op_compare_str; - gOpCodeArray[OP_PUSH] = &CodeInterpreter::op_push; - gOpCodeArray[OP_PUSH_UINT] = &CodeInterpreter::op_push_uint; - gOpCodeArray[OP_PUSH_FLT] = &CodeInterpreter::op_push_flt; - gOpCodeArray[OP_PUSH_VAR] = &CodeInterpreter::op_push_var; - gOpCodeArray[OP_PUSH_THIS] = &CodeInterpreter::op_push_this; - gOpCodeArray[OP_PUSH_FRAME] = &CodeInterpreter::op_push_frame; - gOpCodeArray[OP_ASSERT] = &CodeInterpreter::op_assert; - gOpCodeArray[OP_BREAK] = &CodeInterpreter::op_break; - gOpCodeArray[OP_ITER_BEGIN_STR] = &CodeInterpreter::op_iter_begin_str; - gOpCodeArray[OP_ITER_BEGIN] = &CodeInterpreter::op_iter_begin; - gOpCodeArray[OP_ITER] = &CodeInterpreter::op_iter; - gOpCodeArray[OP_ITER_END] = &CodeInterpreter::op_iter_end; - gOpCodeArray[OP_INVALID] = &CodeInterpreter::op_invalid; -} - -ConsoleValueRef CodeInterpreter::exec(U32 ip, - StringTableEntry functionName, - Namespace *thisNamespace, - U32 argc, - ConsoleValueRef *argv, - bool noCalls, - StringTableEntry packageName, - S32 setFrame) -{ - mExec.functionName = functionName; - mExec.thisNamespace = thisNamespace; - mExec.argc = argc; - mExec.argv = argv; - mExec.noCalls = noCalls; - mExec.packageName = packageName; - mExec.setFrame = setFrame; - - mCodeBlock->incRefCount(); - - mPopFrame = false; - -#ifdef TORQUE_VALIDATE_STACK - U32 stackStart = STR.mStartStackSize; -#endif - - STR.clearFunctionOffset(); // ensures arg buffer offset is back to 0 - - // Lets load up our function arguments. - parseArgs(ip); - - // Grab the state of the telenet debugger here once - // so that the push and pop frames are always balanced. - const bool telDebuggerOn = TelDebugger && TelDebugger->isConnected(); - if (telDebuggerOn && setFrame < 0) - TelDebugger->pushStackFrame(); - - mSaveCodeBlock = CodeBlock::smCurrentCodeBlock; - CodeBlock::smCurrentCodeBlock = mCodeBlock; - if (mCodeBlock->name) - { - Con::gCurrentFile = mCodeBlock->name; - Con::gCurrentRoot = mCodeBlock->modPath; - } - - U32 *code = mCodeBlock->code; - - while (true) - { - mCurrentInstruction = code[ip++]; - mNSEntry = nullptr; - -#ifdef TORQUE_VALIDATE_STACK - // OP Code check. - AssertFatal(mCurrentInstruction < MAX_OP_CODELEN, "Invalid OP code in script interpreter"); -#endif - - breakContinueLabel: - OPCodeReturn ret = (this->*gOpCodeArray[mCurrentInstruction])(ip); - if (ret == OPCodeReturn::exitCode) - break; - else if (ret == OPCodeReturn::breakContinue) - goto breakContinueLabel; - } - - if (telDebuggerOn && setFrame < 0) - TelDebugger->popStackFrame(); - - if (mPopFrame) - gEvalState.popFrame(); - - if (argv) - { - if (gEvalState.traceOn) - { - sTraceBuffer[0] = 0; - dStrcat(sTraceBuffer, "Leaving ", 1024); - - if (packageName) - { - dStrcat(sTraceBuffer, "[", 1024); - dStrcat(sTraceBuffer, packageName, 1024); - dStrcat(sTraceBuffer, "]", 1024); - } - if (thisNamespace && thisNamespace->mName) - { - dSprintf(sTraceBuffer + dStrlen(sTraceBuffer), (U32)(sizeof(sTraceBuffer) - dStrlen(sTraceBuffer)), - "%s::%s() - return %s", thisNamespace->mName, mThisFunctionName, STR.getStringValue()); - } - else - { - dSprintf(sTraceBuffer + dStrlen(sTraceBuffer), (U32)(sizeof(sTraceBuffer) - dStrlen(sTraceBuffer)), - "%s() - return %s", mThisFunctionName, STR.getStringValue()); - } - Con::printf("%s", sTraceBuffer); - } - } - - CodeBlock::smCurrentCodeBlock = mSaveCodeBlock; - if (mSaveCodeBlock && mSaveCodeBlock->name) - { - Con::gCurrentFile = mSaveCodeBlock->name; - Con::gCurrentRoot = mSaveCodeBlock->modPath; - } - - mCodeBlock->decRefCount(); - -#ifdef TORQUE_VALIDATE_STACK - 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 - - return mReturnValue; -} - -void CodeInterpreter::parseArgs(U32 &ip) -{ - U32 *code = mCodeBlock->code; - - if (mExec.argv) - { - U32 fnArgc = code[ip + 2 + 6]; - mThisFunctionName = Compiler::CodeToSTE(code, ip); - S32 wantedArgc = getMin(mExec.argc - 1, fnArgc); // argv[0] is func name - if (gEvalState.traceOn) - { - sTraceBuffer[0] = 0; - dStrcat(sTraceBuffer, "Entering ", 1024); - - if (mExec.packageName) - { - dStrcat(sTraceBuffer, "[", 1024); - dStrcat(sTraceBuffer, mExec.packageName, 1024); - dStrcat(sTraceBuffer, "]", 1024); - } - if (mExec.thisNamespace && mExec.thisNamespace->mName) - { - dSprintf(sTraceBuffer + dStrlen(sTraceBuffer), (U32)(sizeof(sTraceBuffer) - dStrlen(sTraceBuffer)), - "%s::%s(", mExec.thisNamespace->mName, mThisFunctionName); - } - else - { - dSprintf(sTraceBuffer + dStrlen(sTraceBuffer), (U32)(sizeof(sTraceBuffer) - dStrlen(sTraceBuffer)), - "%s(", mThisFunctionName); - } - for (S32 i = 0; i < wantedArgc; i++) - { - dStrcat(sTraceBuffer, mExec.argv[i + 1], 1024); - if (i != wantedArgc - 1) - dStrcat(sTraceBuffer, ", ", 1024); - } - dStrcat(sTraceBuffer, ")", 1024); - Con::printf("%s", sTraceBuffer); - } - - gEvalState.pushFrame(mThisFunctionName, mExec.thisNamespace); - mPopFrame = true; - - StringTableEntry thisPointer = StringTable->insert("%this"); - - for (S32 i = 0; i < wantedArgc; i++) - { - StringTableEntry var = Compiler::CodeToSTE(code, ip + (2 + 6 + 1) + (i * 2)); - gEvalState.setCurVarNameCreate(var); - - ConsoleValueRef ref = mExec.argv[i + 1]; - - switch (ref.getType()) - { - case ConsoleValue::TypeInternalInt: - gEvalState.setIntVariable(ref); - break; - case ConsoleValue::TypeInternalFloat: - gEvalState.setFloatVariable(ref); - break; - case ConsoleValue::TypeInternalStringStackPtr: - gEvalState.setStringStackPtrVariable(ref.getStringStackPtrValue()); - break; - case ConsoleValue::TypeInternalStackString: - case ConsoleValue::TypeInternalString: - default: - gEvalState.setStringVariable(ref); - break; - } - - if (var == thisPointer) - { - // %this gets optimized as it is flagged as a constant. - // Since it is guarenteed to be constant, we can then perform optimizations. - gEvalState.currentVariable->mIsConstant = true; - - // Store a reference to the this pointer object. - mThisObject = Sim::findObject(gEvalState.getStringVariable()); - } - } - - ip = ip + (fnArgc * 2) + (2 + 6 + 1); - mCurFloatTable = mCodeBlock->functionFloats; - mCurStringTable = mCodeBlock->functionStrings; - } - else - { - mCurFloatTable = mCodeBlock->globalFloats; - mCurStringTable = mCodeBlock->globalStrings; - - // If requested stack frame isn't available, request a new one - // (this prevents assert failures when creating local - // variables without a stack frame) - if (gEvalState.getStackDepth() <= mExec.setFrame) - mExec.setFrame = -1; - - // Do we want this code to execute using a new stack frame? - if (mExec.setFrame < 0) - { - gEvalState.pushFrame(NULL, NULL); - mPopFrame = true; - } - else - { - // We want to copy a reference to an existing stack frame - // on to the top of the stack. Any change that occurs to - // the locals during this new frame will also occur in the - // original frame. - S32 stackIndex = gEvalState.getStackDepth() - mExec.setFrame - 1; - gEvalState.pushFrameRef(stackIndex); - mPopFrame = true; - } - } -} - -OPCodeReturn CodeInterpreter::op_func_decl(U32 &ip) -{ - U32 *code = mCodeBlock->code; - - if (!mExec.noCalls) - { - StringTableEntry fnName = CodeToSTE(code, ip); - StringTableEntry fnNamespace = CodeToSTE(code, ip + 2); - StringTableEntry fnPackage = CodeToSTE(code, ip + 4); - bool hasBody = (code[ip + 6] & 0x01) != 0; - U32 lineNumber = code[ip + 6] >> 1; - - Namespace::unlinkPackages(); - Namespace *ns = Namespace::find(fnNamespace, fnPackage); - ns->addFunction(fnName, mCodeBlock, hasBody ? ip : 0, mCurFNDocBlock ? dStrdup(mCurFNDocBlock) : NULL, lineNumber);// if no body, set the IP to 0 - if (mCurNSDocBlock) - { - // If we have a docblock before we declare the function in the script file, - // this will attempt to set the doc block to the function. - // See OP_DOCBLOCK_STR - if (fnNamespace == StringTable->lookup(mNSDocBlockClass)) - { - char *usageStr = dStrdup(mCurNSDocBlock); - usageStr[dStrlen(usageStr)] = '\0'; - ns->mUsage = usageStr; - ns->mCleanUpUsage = true; - mCurNSDocBlock = NULL; - } - } - Namespace::relinkPackages(); - - // If we had a docblock, it's definitely not valid anymore, so clear it out. - mCurFNDocBlock = NULL; - - //Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip); - } - ip = code[ip + 7]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_create_object(U32 &ip) -{ - U32 *code = mCodeBlock->code; - - // Read some useful info. - StringTableEntry objParent = CodeToSTE(code, ip); - bool isDataBlock = code[ip + 2]; - bool isInternal = code[ip + 3]; - bool isSingleton = code[ip + 4]; - U32 lineNumber = code[ip + 5]; - mFailJump = code[ip + 6]; - - // If we don't allow calls, we certainly don't allow creating objects! - // Moved this to after failJump is set. Engine was crashing when - // noCalls = true and an object was being created at the beginning of - // a file. ADL. - if (mExec.noCalls) - { - ip = mFailJump; - return OPCodeReturn::success; - } - - // Push the old info to the stack - //Assert( objectCreationStackIndex < objectCreationStackSize ); - mObjectCreationStack[mObjectCreationStackIndex].newObject = mCurrentNewObject; - mObjectCreationStack[mObjectCreationStackIndex++].failJump = mFailJump; - - // Get the constructor information off the stack. - CSTK.getArgcArgv(NULL, &mCallArgc, &mCallArgv); - const char *objectName = mCallArgv[2]; - - // Con::printf("Creating object..."); - - // objectName = argv[1]... - mCurrentNewObject = NULL; - - // Are we creating a datablock? If so, deal with case where we override - // an old one. - if (isDataBlock) - { - // Con::printf(" - is a datablock"); - - // Find the old one if any. - SimObject *db = Sim::getDataBlockGroup()->findObject(objectName); - - // Make sure we're not changing types on ourselves... - if (db && dStricmp(db->getClassName(), mCallArgv[1])) - { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare data block %s with a different class.", mCodeBlock->getFileLine(ip), objectName); - ip = mFailJump; - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - - // If there was one, set the currentNewObject and move on. - if (db) - mCurrentNewObject = db; - } - else if (!isInternal) - { - // IF we aren't looking at a local/internal object, then check if - // this object already exists in the global space - - AbstractClassRep* rep = AbstractClassRep::findClassRep(objectName); - if (rep != NULL) { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot name object [%s] the same name as a script class.", - mCodeBlock->getFileLine(ip), objectName); - ip = mFailJump; - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - - SimObject *obj = Sim::findObject((const char*)objectName); - if (obj /*&& !obj->isLocalName()*/) - { - if (isSingleton) - { - // Make sure we're not trying to change types - if (dStricmp(obj->getClassName(), (const char*)mCallArgv[1]) != 0) - { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare object [%s] with a different class [%s] - was [%s].", - mCodeBlock->getFileLine(ip), objectName, (const char*)mCallArgv[1], obj->getClassName()); - ip = mFailJump; - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - - // We're creating a singleton, so use the found object - // instead of creating a new object. - mCurrentNewObject = obj; - } - else - { - const char* redefineBehavior = Con::getVariable("$Con::redefineBehavior"); - - if (dStricmp(redefineBehavior, "replaceExisting") == 0) - { - // Save our constructor args as the argv vector is stored on the - // string stack and may get stomped if deleteObject triggers - // script execution. - - ConsoleValueRef savedArgv[StringStack::MaxArgs]; - for (int i = 0; i< mCallArgc; i++) { - savedArgv[i] = mCallArgv[i]; - } - //dMemcpy( savedArgv, callArgv, sizeof( savedArgv[ 0 ] ) * callArgc ); - - // Prevent stack value corruption - CSTK.pushFrame(); - STR.pushFrame(); - // -- - - obj->deleteObject(); - obj = NULL; - - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - - //dMemcpy( callArgv, savedArgv, sizeof( callArgv[ 0 ] ) * callArgc ); - for (int i = 0; iinsert(newName); - break; - } - } - } - else if (dStricmp(redefineBehavior, "unnameNew") == 0) - { - objectName = StringTable->insert(""); - } - else if (dStricmp(redefineBehavior, "postfixNew") == 0) - { - const char* postfix = Con::getVariable("$Con::redefineBehaviorPostfix"); - String newName = String::ToString("%s%s", objectName, postfix); - - if (Sim::findObject(newName)) - { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare object with postfix [%s].", - mCodeBlock->getFileLine(ip), newName.c_str()); - ip = mFailJump; - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - else - objectName = StringTable->insert(newName); - } - else - { - Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare object [%s].", - mCodeBlock->getFileLine(ip), objectName); - ip = mFailJump; - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - } - } - } - - STR.popFrame(); - CSTK.popFrame(); - - if (!mCurrentNewObject) - { - // Well, looks like we have to create a new object. - ConsoleObject *object = ConsoleObject::create((const char*)mCallArgv[1]); - - // Deal with failure! - if (!object) - { - Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-conobject class %s.", mCodeBlock->getFileLine(ip), (const char*)mCallArgv[1]); - ip = mFailJump; - return OPCodeReturn::success; - } - - // Do special datablock init if appropros - if (isDataBlock) - { - SimDataBlock *dataBlock = dynamic_cast(object); - if (dataBlock) - { - dataBlock->assignId(); - } - else - { - // They tried to make a non-datablock with a datablock keyword! - Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-datablock class %s.", mCodeBlock->getFileLine(ip), (const char*)mCallArgv[1]); - // Clean up... - delete object; - mCurrentNewObject = NULL; - ip = mFailJump; - return OPCodeReturn::success; - } - } - - // Finally, set currentNewObject to point to the new one. - mCurrentNewObject = dynamic_cast(object); - - // Deal with the case of a non-SimObject. - if (!mCurrentNewObject) - { - Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-SimObject class %s.", mCodeBlock->getFileLine(ip), (const char*)mCallArgv[1]); - delete object; - mCurrentNewObject = NULL; - ip = mFailJump; - return OPCodeReturn::success; - } - - // Set the declaration line - mCurrentNewObject->setDeclarationLine(lineNumber); - - // Set the file that this object was created in - mCurrentNewObject->setFilename(mCodeBlock->name); - - // Does it have a parent object? (ie, the copy constructor : syntax, not inheriance) - if (*objParent) - { - // Find it! - SimObject *parent; - if (Sim::findObject(objParent, parent)) - { - // Con::printf(" - Parent object found: %s", parent->getClassName()); - - mCurrentNewObject->setCopySource(parent); - mCurrentNewObject->assignFieldsFrom(parent); - - // copy any substitution statements - SimDataBlock* parent_db = dynamic_cast(parent); - if (parent_db) - { - SimDataBlock* currentNewObject_db = dynamic_cast(mCurrentNewObject); - if (currentNewObject_db) - currentNewObject_db->copySubstitutionsFrom(parent_db); - } - } - else - { - if (Con::gObjectCopyFailures == -1) - Con::errorf(ConsoleLogEntry::General, "%s: Unable to find parent object %s for %s.", mCodeBlock->getFileLine(ip), objParent, (const char*)mCallArgv[1]); - else - ++Con::gObjectCopyFailures; - - // Fail to create the object. - delete object; - mCurrentNewObject = NULL; - ip = mFailJump; - return OPCodeReturn::success; - } - } - - // If a name was passed, assign it. - if (objectName[0]) - { - if (!isInternal) - mCurrentNewObject->assignName(objectName); - else - mCurrentNewObject->setInternalName(objectName); - - // Set the original name - mCurrentNewObject->setOriginalName(objectName); - } - - // Prevent stack value corruption - CSTK.pushFrame(); - STR.pushFrame(); - // -- - - // Do the constructor parameters. - if (!mCurrentNewObject->processArguments(mCallArgc - 3, mCallArgv + 3)) - { - delete mCurrentNewObject; - mCurrentNewObject = NULL; - ip = mFailJump; - - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - return OPCodeReturn::success; - } - - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - - // If it's not a datablock, allow people to modify bits of it. - if (!isDataBlock) - { - mCurrentNewObject->setModStaticFields(true); - mCurrentNewObject->setModDynamicFields(true); - } - } - else - { - mCurrentNewObject->reloadReset(); // AFX (reload-reset) - // Does it have a parent object? (ie, the copy constructor : syntax, not inheriance) - if (*objParent) - { - // Find it! - SimObject *parent; - if (Sim::findObject(objParent, parent)) - { - // Con::printf(" - Parent object found: %s", parent->getClassName()); - - // temporarily block name change - SimObject::preventNameChanging = true; - mCurrentNewObject->setCopySource(parent); - mCurrentNewObject->assignFieldsFrom(parent); - // restore name changing - SimObject::preventNameChanging = false; - - // copy any substitution statements - SimDataBlock* parent_db = dynamic_cast(parent); - if (parent_db) - { - SimDataBlock* currentNewObject_db = dynamic_cast(mCurrentNewObject); - if (currentNewObject_db) - currentNewObject_db->copySubstitutionsFrom(parent_db); - } - } - else - Con::errorf(ConsoleLogEntry::General, "%d: Unable to find parent object %s for %s.", lineNumber, objParent, (const char*)mCallArgv[1]); - } - } - - // Advance the IP past the create info... - ip += 7; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_add_object(U32 &ip) -{ - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - // Do we place this object at the root? - bool placeAtRoot = mCodeBlock->code[ip++]; - - // Con::printf("Adding object %s", currentNewObject->getName()); - - // Prevent stack value corruption - CSTK.pushFrame(); - STR.pushFrame(); - // -- - - // Make sure it wasn't already added, then add it. - if (mCurrentNewObject->isProperlyAdded() == false) - { - bool ret = false; - - Message *msg = dynamic_cast(mCurrentNewObject); - if (msg) - { - SimObjectId id = Message::getNextMessageID(); - if (id != 0xffffffff) - ret = mCurrentNewObject->registerObject(id); - else - Con::errorf("%s: No more object IDs available for messages", mCodeBlock->getFileLine(ip)); - } - else - ret = mCurrentNewObject->registerObject(); - - if (!ret) - { - // This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields(). - Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", mCodeBlock->getFileLine(ip), mCurrentNewObject->getName(), mCurrentNewObject->getClassName()); - delete mCurrentNewObject; - mCurrentNewObject = NULL; - ip = mFailJump; - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - return OPCodeReturn::success; - } - } - - // Are we dealing with a datablock? - SimDataBlock *dataBlock = dynamic_cast(mCurrentNewObject); - static String errorStr; - - // If so, preload it. - if (dataBlock && !dataBlock->preload(true, errorStr)) - { - Con::errorf(ConsoleLogEntry::General, "%s: preload failed for %s: %s.", mCodeBlock->getFileLine(ip), - mCurrentNewObject->getName(), errorStr.c_str()); - dataBlock->deleteObject(); - mCurrentNewObject = NULL; - ip = mFailJump; - - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - return OPCodeReturn::success; - } - - // What group will we be added to, if any? - U32 groupAddId = intStack[_UINT]; - SimGroup *grp = NULL; - SimSet *set = NULL; - bool isMessage = dynamic_cast(mCurrentNewObject) != NULL; - - if (!placeAtRoot || !mCurrentNewObject->getGroup()) - { - if (!isMessage) - { - if (!placeAtRoot) - { - // Otherwise just add to the requested group or set. - if (!Sim::findObject(groupAddId, grp)) - Sim::findObject(groupAddId, set); - } - - if (placeAtRoot) - { - // Deal with the instantGroup if we're being put at the root or we're adding to a component. - if (Con::gInstantGroup.isEmpty() - || !Sim::findObject(Con::gInstantGroup, grp)) - grp = Sim::getRootGroup(); - } - } - - // If we didn't get a group, then make sure we have a pointer to - // the rootgroup. - if (!grp) - grp = Sim::getRootGroup(); - - // add to the parent group - grp->addObject(mCurrentNewObject); - - // If for some reason the add failed, add the object to the - // root group so it won't leak. - if (!mCurrentNewObject->getGroup()) - Sim::getRootGroup()->addObject(mCurrentNewObject); - - // add to any set we might be in - if (set) - set->addObject(mCurrentNewObject); - } - - // store the new object's ID on the stack (overwriting the group/set - // id, if one was given, otherwise getting pushed) - if (placeAtRoot) - intStack[_UINT] = mCurrentNewObject->getId(); - else - intStack[++_UINT] = mCurrentNewObject->getId(); - - // Prevent stack value corruption - CSTK.popFrame(); - STR.popFrame(); - // -- - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_end_object(U32 &ip) -{ - // If we're not to be placed at the root, make sure we clean up - // our group reference. - bool placeAtRoot = mCodeBlock->code[ip++]; - if (!placeAtRoot) - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_finish_object(U32 &ip) -{ - if (mCurrentNewObject) - mCurrentNewObject->onPostAdd(); - - //Assert( objectCreationStackIndex >= 0 ); - // Restore the object info from the stack [7/9/2007 Black] - mCurrentNewObject = mObjectCreationStack[--mObjectCreationStackIndex].newObject; - mFailJump = mObjectCreationStack[mObjectCreationStackIndex].failJump; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmpiffnot(U32 &ip) -{ - if (floatStack[_FLT--]) - { - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - - -OPCodeReturn CodeInterpreter::op_jmpifnot(U32 &ip) -{ - if (intStack[_UINT--]) - { - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmpiff(U32 &ip) -{ - if (!floatStack[_FLT--]) - { - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmpif(U32 &ip) -{ - if (!intStack[_UINT--]) - { - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmpifnot_np(U32 &ip) -{ - if (intStack[_UINT]) - { - _UINT--; - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmpif_np(U32 &ip) -{ - if (!intStack[_UINT]) - { - _UINT--; - ip++; - return OPCodeReturn::success; - } - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_jmp(U32 &ip) -{ - ip = mCodeBlock->code[ip]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_return_void(U32 &ip) -{ - STR.setStringValue(""); - // We're falling thru here on purpose. - - OPCodeReturn ret = op_return(ip); - - return ret; -} - -OPCodeReturn CodeInterpreter::op_return(U32 &ip) -{ - StringStackPtr retValue = STR.getStringValuePtr(); - - if (mIterDepth > 0) - { - // Clear iterator state. - while (mIterDepth > 0) - { - iterStack[--_ITER].mIsStringIter = false; - --mIterDepth; - } - - STR.rewind(); - STR.setStringValue(StringStackPtrRef(retValue).getPtr(&STR)); // Not nice but works. - retValue = STR.getStringValuePtr(); - } - - // Previously the return value was on the stack and would be returned using STR.getStringValue(). - // Now though we need to wrap it in a ConsoleValueRef - mReturnValue.value = CSTK.pushStringStackPtr(retValue); - - return OPCodeReturn::exitCode; -} - -OPCodeReturn CodeInterpreter::op_return_flt(U32 &ip) -{ - if (mIterDepth > 0) - { - // Clear iterator state. - while (mIterDepth > 0) - { - iterStack[--_ITER].mIsStringIter = false; - --mIterDepth; - } - - } - - mReturnValue.value = CSTK.pushFLT(floatStack[_FLT]); - _FLT--; - - return OPCodeReturn::exitCode; -} - -OPCodeReturn CodeInterpreter::op_return_uint(U32 &ip) -{ - if (mIterDepth > 0) - { - // Clear iterator state. - while (mIterDepth > 0) - { - iterStack[--_ITER].mIsStringIter = false; - --mIterDepth; - } - } - - mReturnValue.value = CSTK.pushUINT(intStack[_UINT]); - _UINT--; - - return OPCodeReturn::exitCode; -} - -OPCodeReturn CodeInterpreter::op_cmpeq(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] == floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_cmpgr(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] > floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_cmpge(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] >= floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_cmplt(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] < floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_cmple(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] <= floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_cmpne(U32 &ip) -{ - intStack[_UINT + 1] = bool(floatStack[_FLT] != floatStack[_FLT - 1]); - _UINT++; - _FLT -= 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_xor(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] ^ intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_mod(U32 &ip) -{ - if (intStack[_UINT - 1] != 0) - intStack[_UINT - 1] = intStack[_UINT] % intStack[_UINT - 1]; - else - intStack[_UINT - 1] = 0; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_bitand(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] & intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_bitor(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] | intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_not(U32 &ip) -{ - intStack[_UINT] = !intStack[_UINT]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_notf(U32 &ip) -{ - intStack[_UINT + 1] = !floatStack[_FLT]; - _FLT--; - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_onescomplement(U32 &ip) -{ - intStack[_UINT] = ~intStack[_UINT]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_shr(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] >> intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_shl(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] << intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_and(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] && intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_or(U32 &ip) -{ - intStack[_UINT - 1] = intStack[_UINT] || intStack[_UINT - 1]; - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_add(U32 &ip) -{ - floatStack[_FLT - 1] = floatStack[_FLT] + floatStack[_FLT - 1]; - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_sub(U32 &ip) -{ - floatStack[_FLT - 1] = floatStack[_FLT] - floatStack[_FLT - 1]; - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_mul(U32 &ip) -{ - floatStack[_FLT - 1] = floatStack[_FLT] * floatStack[_FLT - 1]; - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_div(U32 &ip) -{ - floatStack[_FLT - 1] = floatStack[_FLT] / floatStack[_FLT - 1]; - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_neg(U32 &ip) -{ - floatStack[_FLT] = -floatStack[_FLT]; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_inc(U32 &ip) -{ - StringTableEntry var = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // If a variable is set, then these must be NULL. It is necessary - // to set this here so that the vector parser can appropriately - // identify whether it's dealing with a vector. - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarNameCreate(var); - - // In order to let docblocks work properly with variables, we have - // clear the current docblock when we do an assign. This way it - // won't inappropriately carry forward to following function decls. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - F64 val = gEvalState.getFloatVariable() + 1.0; - gEvalState.setFloatVariable(val); - - // We gotta push val onto the stack. What if we have - // more expressions that have to use this. - // If we don't, we send out an op code to pop it. - floatStack[_FLT + 1] = val; - _FLT++; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_dec(U32 &ip) -{ - StringTableEntry var = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // If a variable is set, then these must be NULL. It is necessary - // to set this here so that the vector parser can appropriately - // identify whether it's dealing with a vector. - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarNameCreate(var); - - // In order to let docblocks work properly with variables, we have - // clear the current docblock when we do an assign. This way it - // won't inappropriately carry forward to following function decls. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - F64 val = gEvalState.getFloatVariable() - 1.0; - gEvalState.setFloatVariable(val); - - // We gotta push val onto the stack. What if we have - // more expressions that have to use this. - // If we don't, we send out an op code to pop it. - floatStack[_FLT + 1] = val; - _FLT++; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar(U32 &ip) -{ - StringTableEntry var = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // If a variable is set, then these must be NULL. It is necessary - // to set this here so that the vector parser can appropriately - // identify whether it's dealing with a vector. - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarName(var); - - // In order to let docblocks work properly with variables, we have - // clear the current docblock when we do an assign. This way it - // won't inappropriately carry forward to following function decls. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar_create(U32 &ip) -{ - StringTableEntry var = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // See OP_SETCURVAR - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarNameCreate(var); - - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar_array(U32 &ip) -{ - StringTableEntry var = STR.getSTValue(); - - // See OP_SETCURVAR - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarName(var); - - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar_array_varlookup(U32 &ip) -{ - StringTableEntry arrayName = CodeToSTE(mCodeBlock->code, ip); - StringTableEntry arrayLookup = CodeToSTE(mCodeBlock->code, ip + 2); - ip += 4; - - STR.setStringValue(arrayName); - STR.advance(); - - // See OP_SETCURVAR - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - // resolve arrayLookup to get the 'value' - // Note: we have to setCurVarNameCreate in case the var doesn't exist. - // this won't cause much of a performance hit since vars are hashed. - gEvalState.setCurVarNameCreate(arrayLookup); - StringTableEntry hash = gEvalState.getStringVariable(); - - STR.setStringValue(hash); - STR.rewind(); - - // Generate new array name. - StringTableEntry var = STR.getSTValue(); - gEvalState.setCurVarName(var); - - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar_array_create(U32 &ip) -{ - StringTableEntry var = STR.getSTValue(); - - // See OP_SETCURVAR - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarNameCreate(var); - - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurvar_array_create_varlookup(U32 &ip) -{ - StringTableEntry arrayName = CodeToSTE(mCodeBlock->code, ip); - StringTableEntry arrayLookup = CodeToSTE(mCodeBlock->code, ip + 2); - ip += 4; - - // See OP_SETCURVAR - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - STR.setStringValue(arrayName); - STR.advance(); - - // resolve arrayLookup to get the 'value' - // Note: we have to setCurVarNameCreate in case the var doesn't exist. - // this won't cause much of a performance hit since vars are hashed. - gEvalState.setCurVarNameCreate(arrayLookup); - StringTableEntry hash = gEvalState.getStringVariable(); - - STR.setStringValue(hash); - STR.rewind(); - - // Generate new array name. - StringTableEntry var = STR.getSTValue(); - gEvalState.setCurVarNameCreate(var); - - // See OP_SETCURVAR for why we do this. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadvar_uint(U32 &ip) -{ - intStack[_UINT + 1] = gEvalState.getIntVariable(); - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadvar_flt(U32 &ip) -{ - floatStack[_FLT + 1] = gEvalState.getFloatVariable(); - _FLT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadvar_str(U32 &ip) -{ - StringTableEntry val = gEvalState.getStringVariable(); - STR.setStringValue(val); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadvar_var(U32 &ip) -{ - // Sets current source of OP_SAVEVAR_VAR - gEvalState.copyVariable = gEvalState.currentVariable; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savevar_uint(U32 &ip) -{ - gEvalState.setIntVariable(intStack[_UINT]); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savevar_flt(U32 &ip) -{ - gEvalState.setFloatVariable(floatStack[_FLT]); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savevar_str(U32 &ip) -{ - gEvalState.setStringVariable(STR.getStringValue()); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savevar_var(U32 &ip) -{ - // this basically handles %var1 = %var2 - gEvalState.setCopyVariable(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurobject(U32 &ip) -{ - // Save the previous object for parsing vector fields. - mPrevObject = mCurObject; - StringTableEntry val = STR.getStringValue(); - - // Sim::findObject will sometimes find valid objects from - // multi-component strings. This makes sure that doesn't - // happen. - for (const char* check = val; *check; check++) - { - if (*check == ' ') - { - val = ""; - break; - } - } - mCurObject = Sim::findObject(val); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurobject_internal(U32 &ip) -{ - ++ip; // To skip the recurse flag if the object wasn't found - if (mCurObject) - { - SimSet *set = dynamic_cast(mCurObject); - if (set) - { - StringTableEntry intName = StringTable->insert(STR.getStringValue()); - bool recurse = mCodeBlock->code[ip - 1]; - SimObject *obj = set->findObjectByInternalName(intName, recurse); - intStack[_UINT + 1] = obj ? obj->getId() : 0; - _UINT++; - } - else - { - Con::errorf(ConsoleLogEntry::Script, "%s: Attempt to use -> on non-set %s of class %s.", mCodeBlock->getFileLine(ip - 2), mCurObject->getName(), mCurObject->getClassName()); - intStack[_UINT] = 0; - } - } - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurobject_new(U32 &ip) -{ - mCurObject = mCurrentNewObject; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurfield(U32 &ip) -{ - // Save the previous field for parsing vector fields. - mPrevField = mCurField; - dStrcpy(prevFieldArray, curFieldArray, 256); - mCurField = CodeToSTE(mCodeBlock->code, ip); - curFieldArray[0] = 0; - ip += 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurfield_array(U32 &ip) -{ - dStrcpy(curFieldArray, STR.getStringValue(), 256); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurfield_type(U32 &ip) -{ - if (mCurObject) - mCurObject->setDataFieldType(mCodeBlock->code[ip], mCurField, curFieldArray); - ip++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurfield_array_var(U32 &ip) -{ - StringTableEntry var = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // We set the current var name (create it as well in case if it doesn't exist, - // otherwise we will crash). - gEvalState.setCurVarNameCreate(var); - - // Then load the var and copy the contents to the current field array - dStrncpy(curFieldArray, gEvalState.currentVariable->getStringValue(), sizeof(curFieldArray)); - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_setcurfield_this(U32 &ip) -{ - // set the 'this pointer' as the current object. - mCurObject = mThisObject; - - mPrevField = mCurField; - dStrcpy(prevFieldArray, curFieldArray, 256); - mCurField = CodeToSTE(mCodeBlock->code, ip); - curFieldArray[0] = 0; - ip += 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadfield_uint(U32 &ip) -{ - if (mCurObject) - intStack[_UINT + 1] = U32(dAtoi(mCurObject->getDataField(mCurField, curFieldArray))); - else - { - // The field is not being retrieved from an object. Maybe it's - // a special accessor? - char buff[FieldBufferSizeNumeric]; - memset(buff, 0, sizeof(buff)); - getFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField, buff); - intStack[_UINT + 1] = dAtoi(buff); - } - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadfield_flt(U32 &ip) -{ - if (mCurObject) - floatStack[_FLT + 1] = dAtof(mCurObject->getDataField(mCurField, curFieldArray)); - else - { - // The field is not being retrieved from an object. Maybe it's - // a special accessor? - char buff[FieldBufferSizeNumeric]; - memset(buff, 0, sizeof(buff)); - getFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField, buff); - floatStack[_FLT + 1] = dAtof(buff); - } - _FLT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadfield_str(U32 &ip) -{ - if (mCurObject) - { - StringTableEntry val = mCurObject->getDataField(mCurField, curFieldArray); - STR.setStringValue(val); - } - else - { - // The field is not being retrieved from an object. Maybe it's - // a special accessor? - char buff[FieldBufferSizeString]; - memset(buff, 0, sizeof(buff)); - getFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField, buff); - STR.setStringValue(buff); - } - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savefield_uint(U32 &ip) -{ - STR.setIntValue(intStack[_UINT]); - if (mCurObject) - mCurObject->setDataField(mCurField, curFieldArray, STR.getStringValue()); - else - { - // The field is not being set on an object. Maybe it's - // a special accessor? - setFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField); - mPrevObject = NULL; - } - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savefield_flt(U32 &ip) -{ - STR.setFloatValue(floatStack[_FLT]); - if (mCurObject) - mCurObject->setDataField(mCurField, curFieldArray, STR.getStringValue()); - else - { - // The field is not being set on an object. Maybe it's - // a special accessor? - setFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField); - mPrevObject = NULL; - } - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_savefield_str(U32 &ip) -{ - if (mCurObject) - mCurObject->setDataField(mCurField, curFieldArray, STR.getStringValue()); - else - { - // The field is not being set on an object. Maybe it's - // a special accessor? - setFieldComponent(mPrevObject, mPrevField, prevFieldArray, mCurField); - mPrevObject = NULL; - } - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_str_to_uint(U32 &ip) -{ - intStack[_UINT + 1] = STR.getIntValue(); - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_str_to_flt(U32 &ip) -{ - floatStack[_FLT + 1] = STR.getFloatValue(); - _FLT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_str_to_none(U32 &ip) -{ - // This exists simply to deal with certain typecast situations. - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_flt_to_uint(U32 &ip) -{ - intStack[_UINT + 1] = (S64)floatStack[_FLT]; - _FLT--; - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_flt_to_str(U32 &ip) -{ - STR.setFloatValue(floatStack[_FLT]); - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_flt_to_none(U32 &ip) -{ - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_uint_to_flt(U32 &ip) -{ - floatStack[_FLT + 1] = (F32)intStack[_UINT]; - _UINT--; - _FLT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_uint_to_str(U32 &ip) -{ - STR.setIntValue(intStack[_UINT]); - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_uint_to_none(U32 &ip) -{ - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_copyvar_to_none(U32 &ip) -{ - gEvalState.copyVariable = NULL; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadimmed_uint(U32 &ip) -{ - intStack[_UINT + 1] = mCodeBlock->code[ip++]; - _UINT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadimmed_flt(U32 &ip) -{ - floatStack[_FLT + 1] = mCurFloatTable[mCodeBlock->code[ip]]; - ip++; - _FLT++; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_tag_to_str(U32 &ip) -{ - mCodeBlock->code[ip - 1] = OP_LOADIMMED_STR; - // it's possible the string has already been converted - if (U8(mCurStringTable[mCodeBlock->code[ip]]) != StringTagPrefixByte) - { - U32 id = GameAddTaggedString(mCurStringTable + mCodeBlock->code[ip]); - dSprintf(mCurStringTable + mCodeBlock->code[ip] + 1, 7, "%d", id); - *(mCurStringTable + mCodeBlock->code[ip]) = StringTagPrefixByte; - } - - // Fallthrough - OPCodeReturn ret = op_loadimmed_str(ip); - - return ret; -} - -OPCodeReturn CodeInterpreter::op_loadimmed_str(U32 &ip) -{ - STR.setStringValue(mCurStringTable + mCodeBlock->code[ip++]); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_docblock_str(U32 &ip) -{ - // If the first word of the doc is '\class' or '@class', then this - // is a namespace doc block, otherwise it is a function doc block. - const char* docblock = mCurStringTable + mCodeBlock->code[ip++]; - - const char* sansClass = dStrstr(docblock, "@class"); - if (!sansClass) - sansClass = dStrstr(docblock, "\\class"); - - if (sansClass) - { - // Don't save the class declaration. Scan past the 'class' - // keyword and up to the first whitespace. - sansClass += 7; - S32 index = 0; - while ((*sansClass != ' ') && (*sansClass != '\n') && *sansClass && (index < (nsDocLength - 1))) - { - mNSDocBlockClass[index++] = *sansClass; - sansClass++; - } - mNSDocBlockClass[index] = '\0'; - - mCurNSDocBlock = sansClass + 1; - } - else - mCurFNDocBlock = docblock; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_loadimmed_ident(U32 &ip) -{ - STR.setStringValue(CodeToSTE(mCodeBlock->code, ip)); - ip += 2; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_callfunc_resolve(U32 &ip) -{ - // This deals with a function that is potentially living in a namespace. - StringTableEntry fnNamespace = CodeToSTE(mCodeBlock->code, ip + 2); - StringTableEntry fnName = CodeToSTE(mCodeBlock->code, ip); - - // Try to look it up. - mNSEntry = Namespace::find(fnNamespace)->lookup(fnName); - if (!CInterface::GetCInterface().isMethod(fnNamespace, fnName) && !mNSEntry) - { - ip += 5; - Con::warnf(ConsoleLogEntry::General, - "%s: Unable to find function %s%s%s", - mCodeBlock->getFileLine(ip - 7), fnNamespace ? fnNamespace : "", - fnNamespace ? "::" : "", fnName); - STR.popFrame(); - CSTK.popFrame(); - return OPCodeReturn::success; - } - - // Fallthrough to op_callfunc_resolve - OPCodeReturn ret = op_callfunc(ip); - - return ret; -} - -OPCodeReturn CodeInterpreter::op_callfunc(U32 &ip) -{ - // This routingId is set when we query the object as to whether - // it handles this method. It is set to an enum from the table - // above indicating whether it handles it on a component it owns - // or just on the object. - S32 routingId = 0; - - U32 *code = mCodeBlock->code; - - StringTableEntry fnNamespace = CodeToSTE(mCodeBlock->code, ip + 2); - StringTableEntry fnName = CodeToSTE(code, ip); - - //if this is called from inside a function, append the ip and codeptr - if (gEvalState.getStackDepth() > 0) - { - gEvalState.getCurrentFrame().code = mCodeBlock; - gEvalState.getCurrentFrame().ip = ip - 1; - } - - U32 callType = code[ip + 4]; - - ip += 5; - CSTK.getArgcArgv(fnName, &mCallArgc, &mCallArgv); - - const char *componentReturnValue = ""; - Namespace *ns = NULL; - - bool cFunctionRes = false; - const char* cRetRes = NULL; - - if (callType == FuncCallExprNode::FunctionCall) - { - if (!mNSEntry) - mNSEntry = Namespace::global()->lookup(fnName); - - StringStackWrapper args(mCallArgc, mCallArgv); - cRetRes = CInterface::CallFunction(fnNamespace, fnName, args.argv + 1, args.argc - 1, &cFunctionRes); - } - else if (callType == FuncCallExprNode::MethodCall) - { - mSaveObject = gEvalState.thisObject; - gEvalState.thisObject = Sim::findObject((const char*)mCallArgv[1]); - if (!gEvalState.thisObject) - { - // Go back to the previous saved object. - gEvalState.thisObject = mSaveObject; - - Con::warnf(ConsoleLogEntry::General, "%s: Unable to find object: '%s' attempting to call function '%s'", mCodeBlock->getFileLine(ip - 4), (const char*)mCallArgv[1], fnName); - STR.popFrame(); - CSTK.popFrame(); - STR.setStringValue(""); - return OPCodeReturn::success; - } - - bool handlesMethod = gEvalState.thisObject->handlesConsoleMethod(fnName, &routingId); - if (handlesMethod && routingId == MethodOnComponent) - { - ICallMethod *pComponent = dynamic_cast(gEvalState.thisObject); - if (pComponent) - componentReturnValue = pComponent->callMethodArgList(mCallArgc, mCallArgv, false); - } - - ns = gEvalState.thisObject->getNamespace(); - if (ns) - mNSEntry = ns->lookup(fnName); - else - mNSEntry = NULL; - - StringStackWrapper args(mCallArgc, mCallArgv); - cRetRes = CInterface::CallMethod(gEvalState.thisObject, fnName, args.argv + 2, args.argc - 2, &cFunctionRes); - } - else // it's a ParentCall - { - if (mExec.thisNamespace) - { - ns = mExec.thisNamespace->mParent; - if (ns) - mNSEntry = ns->lookup(fnName); - else - mNSEntry = NULL; - } - else - { - ns = NULL; - mNSEntry = NULL; - } - } - - Namespace::Entry::CallbackUnion * nsCb = NULL; - const char * nsUsage = NULL; - if (mNSEntry) - { - nsCb = &mNSEntry->cb; - nsUsage = mNSEntry->mUsage; - routingId = 0; - } - if (!cFunctionRes && (!mNSEntry || mExec.noCalls)) - { - if (!mExec.noCalls && !(routingId == MethodOnComponent)) - { - if (callType == FuncCallExprNode::MethodCall) - { - if (gEvalState.thisObject != NULL) - { - // Try to use the name instead of the id - StringTableEntry name = gEvalState.thisObject->getName() ? gEvalState.thisObject->getName() : gEvalState.thisObject->getIdString(); - Con::warnf(ConsoleLogEntry::General, "%s: Unknown method %s.%s Namespace List: %s", mCodeBlock->getFileLine(ip - 6), name, fnName, Con::getNamespaceList(ns)); - } - else - { - // NULL. - Con::warnf(ConsoleLogEntry::General, "%s: Unknown method NULL.%s", mCodeBlock->getFileLine(ip - 6), fnName); - } - } - else if (callType == FuncCallExprNode::ParentCall) - { - Con::warnf(ConsoleLogEntry::General, "%s: Unknown parent call %s.", mCodeBlock->getFileLine(ip - 6), fnName); - } - else - { - Con::warnf(ConsoleLogEntry::General, "%s: Unknown function %s.", mCodeBlock->getFileLine(ip - 6), fnName); - } - } - STR.popFrame(); - CSTK.popFrame(); - - if (routingId == MethodOnComponent) - STR.setStringValue(componentReturnValue); - else - STR.setStringValue(""); - return OPCodeReturn::success; - } - - // ConsoleFunctionType is for any function defined by script. - // Any 'callback' type is an engine function that is exposed to script. - if (cFunctionRes || mNSEntry->mType == Namespace::Entry::ConsoleFunctionType) - { - ConsoleValue retVal; - ConsoleValueRef ret; - if (cFunctionRes) - { - retVal.init(); - ret.value = &retVal; - retVal.setStackStringValue(cRetRes); - } - else if (mNSEntry->mFunctionOffset) - { - ret = mNSEntry->mCode->exec(mNSEntry->mFunctionOffset, fnName, mNSEntry->mNamespace, mCallArgc, mCallArgv, false, mNSEntry->mPackage); - } - - STR.popFrame(); - // Functions are assumed to return strings, so look ahead to see if we can skip the conversion - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (U32)((S32)ret); - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = (F32)ret; - } - else if (code[ip] == OP_STR_TO_NONE) - { - STR.setStringValue(ret.getStringValue()); - ip++; - } - else - STR.setStringValue((const char*)ret); - - // This will clear everything including returnValue - CSTK.popFrame(); - //STR.clearFunctionOffset(); - } - else - { - const char* nsName = ns ? ns->mName : ""; -#ifndef TORQUE_DEBUG - // [tom, 12/13/2006] This stops tools functions from working in the console, - // which is useful behavior when debugging so I'm ifdefing this out for debug builds. - if (mNSEntry->mToolOnly && !Con::isCurrentScriptToolScript()) - { - Con::errorf(ConsoleLogEntry::Script, "%s: %s::%s - attempting to call tools only function from outside of tools.", mCodeBlock->getFileLine(ip - 6), nsName, fnName); - } - else -#endif - if ((mNSEntry->mMinArgs && S32(mCallArgc) < mNSEntry->mMinArgs) || (mNSEntry->mMaxArgs && S32(mCallArgc) > mNSEntry->mMaxArgs)) - { - Con::warnf(ConsoleLogEntry::Script, "%s: %s::%s - wrong number of arguments (got %i, expected min %i and max %i).", - mCodeBlock->getFileLine(ip - 6), nsName, fnName, - mCallArgc, mNSEntry->mMinArgs, mNSEntry->mMaxArgs); - Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", mCodeBlock->getFileLine(ip - 6), mNSEntry->mUsage); - STR.popFrame(); - CSTK.popFrame(); - } - else - { - switch (mNSEntry->mType) - { - case Namespace::Entry::StringCallbackType: - { - const char *ret = mNSEntry->cb.mStringCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (ret != STR.getStringValue()) - STR.setStringValue(ret); - //else - // sSTR.setLen(dStrlen(ret)); - break; - } - case Namespace::Entry::IntCallbackType: - { - S32 result = mNSEntry->cb.mIntCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - case Namespace::Entry::FloatCallbackType: - { - F64 result = mNSEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (S64)result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setFloatValue(result); - break; - } - case Namespace::Entry::VoidCallbackType: - mNSEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - if (code[ip] != OP_STR_TO_NONE && Con::getBoolVariable("$Con::warnVoidAssignment", true)) - Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", mCodeBlock->getFileLine(ip - 6), fnName, mExec.functionName); - - STR.popFrame(); - CSTK.popFrame(); - STR.setStringValue(""); - break; - case Namespace::Entry::BoolCallbackType: - { - bool result = mNSEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - } - } - } - - if (callType == FuncCallExprNode::MethodCall) - gEvalState.thisObject = mSaveObject; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_callfunc_pointer(U32 &ip) -{ - // get function name. This is the 'function pointer'. - StringTableEntry fnName = StringTable->insert(STR.getStringValue()); - - U32 *code = mCodeBlock->code; - - mNSEntry = Namespace::global()->lookup(fnName); - - //if this is called from inside a function, append the ip and codeptr - if (gEvalState.getStackDepth() > 0) - { - gEvalState.getCurrentFrame().code = mCodeBlock; - gEvalState.getCurrentFrame().ip = ip - 1; - } - - CSTK.getArgcArgv(fnName, &mCallArgc, &mCallArgv); - - - if (!mNSEntry || mExec.noCalls) - { - if (!mExec.noCalls) - { - Con::warnf(ConsoleLogEntry::General, "%s: Unknown function %s.", mCodeBlock->getFileLine(ip - 6), fnName); - } - STR.popFrame(); - CSTK.popFrame(); - - STR.setStringValue(""); - return OPCodeReturn::success; - } - - // ConsoleFunctionType is for any function defined by script. - // Any 'callback' type is an engine function that is exposed to script. - if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType) - { - ConsoleValueRef ret; - if (mNSEntry->mFunctionOffset) - ret = mNSEntry->mCode->exec(mNSEntry->mFunctionOffset, fnName, mNSEntry->mNamespace, mCallArgc, mCallArgv, false, mNSEntry->mPackage); - - STR.popFrame(); - // Functions are assumed to return strings, so look ahead to see if we can skip the conversion - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (U32)((S32)ret); - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = (F32)ret; - } - else if (code[ip] == OP_STR_TO_NONE) - { - STR.setStringValue(ret.getStringValue()); - ip++; - } - else - STR.setStringValue((const char*)ret); - - // This will clear everything including returnValue - CSTK.popFrame(); - //STR.clearFunctionOffset(); - } - else - { - const char* nsName = ""; - -#ifndef TORQUE_DEBUG - // [tom, 12/13/2006] This stops tools functions from working in the console, - // which is useful behavior when debugging so I'm ifdefing this out for debug builds. - if (mNSEntry->mToolOnly && !Con::isCurrentScriptToolScript()) - { - Con::errorf(ConsoleLogEntry::Script, "%s: %s::%s - attempting to call tools only function from outside of tools.", mCodeBlock->getFileLine(ip - 6), nsName, fnName); - } - else -#endif - if ((mNSEntry->mMinArgs && S32(mCallArgc) < mNSEntry->mMinArgs) || (mNSEntry->mMaxArgs && S32(mCallArgc) > mNSEntry->mMaxArgs)) - { - Con::warnf(ConsoleLogEntry::Script, "%s: %s::%s - wrong number of arguments (got %i, expected min %i and max %i).", - mCodeBlock->getFileLine(ip - 6), nsName, fnName, - mCallArgc, mNSEntry->mMinArgs, mNSEntry->mMaxArgs); - Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", mCodeBlock->getFileLine(ip - 6), mNSEntry->mUsage); - STR.popFrame(); - CSTK.popFrame(); - } - else - { - switch (mNSEntry->mType) - { - case Namespace::Entry::StringCallbackType: - { - const char *ret = mNSEntry->cb.mStringCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (ret != STR.getStringValue()) - STR.setStringValue(ret); - //else - // sSTR.setLen(dStrlen(ret)); - break; - } - case Namespace::Entry::IntCallbackType: - { - S32 result = mNSEntry->cb.mIntCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - case Namespace::Entry::FloatCallbackType: - { - F64 result = mNSEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (S64)result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setFloatValue(result); - break; - } - case Namespace::Entry::VoidCallbackType: - mNSEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - if (code[ip] != OP_STR_TO_NONE && Con::getBoolVariable("$Con::warnVoidAssignment", true)) - Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", mCodeBlock->getFileLine(ip - 6), fnName, mExec.functionName); - - STR.popFrame(); - CSTK.popFrame(); - STR.setStringValue(""); - break; - case Namespace::Entry::BoolCallbackType: - { - bool result = mNSEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - } - } - } - - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_callfunc_this(U32 &ip) -{ - U32 *code = mCodeBlock->code; - - StringTableEntry fnName = CodeToSTE(code, ip); - - //if this is called from inside a function, append the ip and codeptr - if (gEvalState.getStackDepth() > 0) - { - gEvalState.getCurrentFrame().code = mCodeBlock; - gEvalState.getCurrentFrame().ip = ip - 1; - } - - ip += 2; - CSTK.getArgcArgv(fnName, &mCallArgc, &mCallArgv); - - Namespace *ns = mThisObject ? mThisObject->getNamespace() : NULL; - if (ns) - mNSEntry = ns->lookup(fnName); - else - mNSEntry = NULL; - - if (!mNSEntry || mExec.noCalls) - { - if (!mExec.noCalls) - { - if (mThisObject) - { - // Try to use the name instead of the id - StringTableEntry name = mThisObject->getName() ? mThisObject->getName() : mThisObject->getIdString(); - Con::warnf(ConsoleLogEntry::General, "%s: Unknown method %s.%s Namespace List: %s", mCodeBlock->getFileLine(ip - 6), name, fnName, Con::getNamespaceList(ns)); - } - else - { - // At least let the scripter know that they access the object. - Con::warnf(ConsoleLogEntry::General, "%s: Unknown method NULL.%s", mCodeBlock->getFileLine(ip - 6), fnName); - } - } - STR.popFrame(); - CSTK.popFrame(); - - STR.setStringValue(""); - return OPCodeReturn::success; - } - - // ConsoleFunctionType is for any function defined by script. - // Any 'callback' type is an engine function that is exposed to script. - if (mNSEntry->mType == Namespace::Entry::ConsoleFunctionType) - { - ConsoleValueRef ret; - if (mNSEntry->mFunctionOffset) - ret = mNSEntry->mCode->exec(mNSEntry->mFunctionOffset, fnName, mNSEntry->mNamespace, mCallArgc, mCallArgv, false, mNSEntry->mPackage); - - STR.popFrame(); - // Functions are assumed to return strings, so look ahead to see if we can skip the conversion - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (U32)((S32)ret); - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = (F32)ret; - } - else if (code[ip] == OP_STR_TO_NONE) - { - STR.setStringValue(ret.getStringValue()); - ip++; - } - else - STR.setStringValue((const char*)ret); - - // This will clear everything including returnValue - CSTK.popFrame(); - //STR.clearFunctionOffset(); - } - else - { - const char* nsName = ns ? ns->mName : ""; -#ifndef TORQUE_DEBUG - // [tom, 12/13/2006] This stops tools functions from working in the console, - // which is useful behavior when debugging so I'm ifdefing this out for debug builds. - if (mNSEntry->mToolOnly && !Con::isCurrentScriptToolScript()) - { - Con::errorf(ConsoleLogEntry::Script, "%s: %s::%s - attempting to call tools only function from outside of tools.", mCodeBlock->getFileLine(ip - 6), nsName, fnName); - } - else -#endif - if ((mNSEntry->mMinArgs && S32(mCallArgc) < mNSEntry->mMinArgs) || (mNSEntry->mMaxArgs && S32(mCallArgc) > mNSEntry->mMaxArgs)) - { - Con::warnf(ConsoleLogEntry::Script, "%s: %s::%s - wrong number of arguments (got %i, expected min %i and max %i).", - mCodeBlock->getFileLine(ip - 6), nsName, fnName, - mCallArgc, mNSEntry->mMinArgs, mNSEntry->mMaxArgs); - Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", mCodeBlock->getFileLine(ip - 6), mNSEntry->mUsage); - STR.popFrame(); - CSTK.popFrame(); - } - else - { - switch (mNSEntry->mType) - { - case Namespace::Entry::StringCallbackType: - { - const char *ret = mNSEntry->cb.mStringCallbackFunc(mThisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (ret != STR.getStringValue()) - STR.setStringValue(ret); - //else - // sSTR.setLen(dStrlen(ret)); - break; - } - case Namespace::Entry::IntCallbackType: - { - S32 result = mNSEntry->cb.mIntCallbackFunc(mThisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - case Namespace::Entry::FloatCallbackType: - { - F64 result = mNSEntry->cb.mFloatCallbackFunc(mThisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = (S64)result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setFloatValue(result); - break; - } - case Namespace::Entry::VoidCallbackType: - mNSEntry->cb.mVoidCallbackFunc(mThisObject, mCallArgc, mCallArgv); - if (code[ip] != OP_STR_TO_NONE && Con::getBoolVariable("$Con::warnVoidAssignment", true)) - Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", mCodeBlock->getFileLine(ip - 6), fnName, mExec.functionName); - - STR.popFrame(); - CSTK.popFrame(); - STR.setStringValue(""); - break; - case Namespace::Entry::BoolCallbackType: - { - bool result = mNSEntry->cb.mBoolCallbackFunc(mThisObject, mCallArgc, mCallArgv); - STR.popFrame(); - CSTK.popFrame(); - if (code[ip] == OP_STR_TO_UINT) - { - ip++; - intStack[++_UINT] = result; - break; - } - else if (code[ip] == OP_STR_TO_FLT) - { - ip++; - floatStack[++_FLT] = result; - break; - } - else if (code[ip] == OP_STR_TO_NONE) - ip++; - else - STR.setIntValue(result); - break; - } - } - } - } - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_advance_str(U32 &ip) -{ - STR.advance(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_advance_str_appendchar(U32 &ip) -{ - STR.advanceChar(mCodeBlock->code[ip++]); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_advance_str_comma(U32 &ip) -{ - STR.advanceChar('_'); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_advance_str_nul(U32 &ip) -{ - STR.advanceChar(0); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_rewind_str(U32 &ip) -{ - STR.rewind(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_terminate_rewind_str(U32 &ip) -{ - STR.rewindTerminate(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_compare_str(U32 &ip) -{ - intStack[++_UINT] = STR.compare(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push(U32 &ip) -{ - STR.push(); - CSTK.pushStringStackPtr(STR.getPreviousStringValuePtr()); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push_uint(U32 &ip) -{ - CSTK.pushUINT(intStack[_UINT]); - _UINT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push_flt(U32 &ip) -{ - CSTK.pushFLT(floatStack[_FLT]); - _FLT--; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push_var(U32 &ip) -{ - if (gEvalState.currentVariable) - CSTK.pushValue(gEvalState.currentVariable->value); - else - CSTK.pushString(""); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push_this(U32 &ip) -{ - StringTableEntry varName = CodeToSTE(mCodeBlock->code, ip); - ip += 2; - - // shorthand OP_SETCURVAR - - // If a variable is set, then these must be NULL. It is necessary - // to set this here so that the vector parser can appropriately - // identify whether it's dealing with a vector. - mPrevField = NULL; - mPrevObject = NULL; - mCurObject = NULL; - - gEvalState.setCurVarName(varName); - - // In order to let docblocks work properly with variables, we have - // clear the current docblock when we do an assign. This way it - // won't inappropriately carry forward to following function decls. - mCurFNDocBlock = NULL; - mCurNSDocBlock = NULL; - - // shorthand OP_LOADVAR_STR (since objs can be by name we can't assume uint) - STR.setStringValue(gEvalState.getStringVariable()); - - // shorthand OP_PUSH - STR.push(); - CSTK.pushStringStackPtr(STR.getPreviousStringValuePtr()); - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_push_frame(U32 &ip) -{ - STR.pushFrame(); - CSTK.pushFrame(); - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_assert(U32 &ip) -{ - if (!intStack[_UINT--]) - { - const char *message = mCurStringTable + mCodeBlock->code[ip]; - - U32 breakLine, inst; - mCodeBlock->findBreakLine(ip - 1, breakLine, inst); - - if (PlatformAssert::processAssert(PlatformAssert::Fatal, - mCodeBlock->name ? mCodeBlock->name : "eval", - breakLine, - message)) - { - if (TelDebugger && TelDebugger->isConnected() && breakLine > 0) - { - TelDebugger->breakProcess(); - } - else - Platform::debugBreak(); - } - } - - ip++; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_break(U32 &ip) -{ - //append the ip and codeptr before managing the breakpoint! - AssertFatal(gEvalState.getStackDepth() > 0, "Empty eval stack on break!"); - gEvalState.getCurrentFrame().code = mCodeBlock; - gEvalState.getCurrentFrame().ip = ip - 1; - - U32 breakLine; - mCodeBlock->findBreakLine(ip - 1, breakLine, mCurrentInstruction); - if (!breakLine) - return OPCodeReturn::breakContinue; - TelDebugger->executionStopped(mCodeBlock, breakLine); - return OPCodeReturn::breakContinue; -} - -OPCodeReturn CodeInterpreter::op_iter_begin_str(U32 &ip) -{ - iterStack[_ITER].mIsStringIter = true; - - // Emulate fallthrough: - OPCodeReturn fallthrough = op_iter_begin(ip); - - return fallthrough; -} - -OPCodeReturn CodeInterpreter::op_iter_begin(U32 &ip) -{ - StringTableEntry varName = CodeToSTE(mCodeBlock->code, ip); - U32 failIp = mCodeBlock->code[ip + 2]; - - IterStackRecord& iter = iterStack[_ITER]; - - if (varName[0] == '$') - iter.mVariable = gEvalState.globalVars.add(varName); - else - iter.mVariable = gEvalState.getCurrentFrame().add(varName); - - if (iter.mIsStringIter) - { - iter.mData.mStr.mString = STR.getStringValuePtr(); - iter.mData.mStr.mIndex = 0; - } - else - { - // Look up the object. - - SimSet* set; - if (!Sim::findObject(STR.getStringValue(), set)) - { - Con::errorf(ConsoleLogEntry::General, "No SimSet object '%s'", STR.getStringValue()); - Con::errorf(ConsoleLogEntry::General, "Did you mean to use 'foreach$' instead of 'foreach'?"); - ip = failIp; - return OPCodeReturn::success; - } - - // Set up. - - iter.mData.mObj.mSet = set; - iter.mData.mObj.mIndex = 0; - } - - _ITER++; - mIterDepth++; - - STR.push(); - - ip += 3; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_iter(U32 &ip) -{ - U32 breakIp = mCodeBlock->code[ip]; - IterStackRecord& iter = iterStack[_ITER - 1]; - - if (iter.mIsStringIter) - { - const char* str = StringStackPtrRef(iter.mData.mStr.mString).getPtr(&STR); - - U32 startIndex = iter.mData.mStr.mIndex; - U32 endIndex = startIndex; - - // Break if at end. - - if (!str[startIndex]) - { - ip = breakIp; - return OPCodeReturn::success; // continue in old interpreter - } - - // Find right end of current component. - - if (!dIsspace(str[endIndex])) - do ++endIndex; - while (str[endIndex] && !dIsspace(str[endIndex])); - - // Extract component. - - if (endIndex != startIndex) - { - char savedChar = str[endIndex]; - const_cast< char* >(str)[endIndex] = '\0'; // We are on the string stack so this is okay. - iter.mVariable->setStringValue(&str[startIndex]); - const_cast< char* >(str)[endIndex] = savedChar; - } - else - iter.mVariable->setStringValue(""); - - // Skip separator. - if (str[endIndex] != '\0') - ++endIndex; - - iter.mData.mStr.mIndex = endIndex; - } - else - { - U32 index = iter.mData.mObj.mIndex; - SimSet* set = iter.mData.mObj.mSet; - - if (index >= set->size()) - { - ip = breakIp; - return OPCodeReturn::success; // continue in old interpreter - } - - iter.mVariable->setIntValue(set->at(index)->getId()); - iter.mData.mObj.mIndex = index + 1; - } - - ++ip; - - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_iter_end(U32 &ip) -{ - --_ITER; - --mIterDepth; - STR.rewind(); - iterStack[_ITER].mIsStringIter = false; - return OPCodeReturn::success; -} - -OPCodeReturn CodeInterpreter::op_invalid(U32 &ip) -{ - // Invalid does nothing. - return OPCodeReturn::exitCode; -} diff --git a/Engine/source/console/codeInterpreter.h b/Engine/source/console/codeInterpreter.h deleted file mode 100644 index 133222726..000000000 --- a/Engine/source/console/codeInterpreter.h +++ /dev/null @@ -1,262 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// 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. -//----------------------------------------------------------------------------- - -#ifndef _CODEINTERPRETER_H_ -#define _CODEINTERPRETER_H_ - -#include "console/codeBlock.h" -#include "console/console.h" -#include "console/consoleInternal.h" - -/// Frame data for a foreach/foreach$ loop. -struct IterStackRecord -{ - /// If true, this is a foreach$ loop; if not, it's a foreach loop. - bool mIsStringIter; - - /// The iterator variable. - Dictionary::Entry* mVariable; - - /// Information for an object iterator loop. - struct ObjectPos - { - /// The set being iterated over. - SimSet* mSet; - - /// Current index in the set. - U32 mIndex; - }; - - /// Information for a string iterator loop. - struct StringPos - { - /// The raw string data on the string stack. - StringStackPtr mString; - - /// Current parsing position. - U32 mIndex; - }; - - union - { - ObjectPos mObj; - StringPos mStr; - } mData; -}; - -enum OPCodeReturn -{ - exitCode = -1, - success = 0, - breakContinue = 1 -}; - -class CodeInterpreter -{ -public: - CodeInterpreter(CodeBlock *cb); - ~CodeInterpreter(); - - ConsoleValueRef exec(U32 ip, - StringTableEntry functionName, - Namespace *thisNamespace, - U32 argc, - ConsoleValueRef *argv, - bool noCalls, - StringTableEntry packageName, - S32 setFrame); - - static void init(); - - // Methods -private: - void parseArgs(U32 &ip); - - /// Group op codes - /// @{ - - OPCodeReturn op_func_decl(U32 &ip); - OPCodeReturn op_create_object(U32 &ip); - OPCodeReturn op_add_object(U32 &ip); - OPCodeReturn op_end_object(U32 &ip); - OPCodeReturn op_finish_object(U32 &ip); - OPCodeReturn op_jmpiffnot(U32 &ip); - OPCodeReturn op_jmpifnot(U32 &ip); - OPCodeReturn op_jmpiff(U32 &ip); - OPCodeReturn op_jmpif(U32 &ip); - OPCodeReturn op_jmpifnot_np(U32 &ip); - OPCodeReturn op_jmpif_np(U32 &ip); - OPCodeReturn op_jmp(U32 &ip); - OPCodeReturn op_return_void(U32 &ip); - OPCodeReturn op_return(U32 &ip); - OPCodeReturn op_return_flt(U32 &ip); - OPCodeReturn op_return_uint(U32 &ip); - OPCodeReturn op_cmpeq(U32 &ip); - OPCodeReturn op_cmpgr(U32 &ip); - OPCodeReturn op_cmpge(U32 &ip); - OPCodeReturn op_cmplt(U32 &ip); - OPCodeReturn op_cmple(U32 &ip); - OPCodeReturn op_cmpne(U32 &ip); - OPCodeReturn op_xor(U32 &ip); - OPCodeReturn op_mod(U32 &ip); - OPCodeReturn op_bitand(U32 &ip); - OPCodeReturn op_bitor(U32 &ip); - OPCodeReturn op_not(U32 &ip); - OPCodeReturn op_notf(U32 &ip); - OPCodeReturn op_onescomplement(U32 &ip); - OPCodeReturn op_shr(U32 &ip); - OPCodeReturn op_shl(U32 &ip); - OPCodeReturn op_and(U32 &ip); - OPCodeReturn op_or(U32 &ip); - OPCodeReturn op_add(U32 &ip); - OPCodeReturn op_sub(U32 &ip); - OPCodeReturn op_mul(U32 &ip); - OPCodeReturn op_div(U32 &ip); - OPCodeReturn op_neg(U32 &ip); - OPCodeReturn op_inc(U32 &ip); - OPCodeReturn op_dec(U32 &ip); - OPCodeReturn op_setcurvar(U32 &ip); - OPCodeReturn op_setcurvar_create(U32 &ip); - OPCodeReturn op_setcurvar_array(U32 &ip); - OPCodeReturn op_setcurvar_array_varlookup(U32 &ip); - OPCodeReturn op_setcurvar_array_create(U32 &ip); - OPCodeReturn op_setcurvar_array_create_varlookup(U32 &ip); - OPCodeReturn op_loadvar_uint(U32 &ip); - OPCodeReturn op_loadvar_flt(U32 &ip); - OPCodeReturn op_loadvar_str(U32 &ip); - OPCodeReturn op_loadvar_var(U32 &ip); - OPCodeReturn op_savevar_uint(U32 &ip); - OPCodeReturn op_savevar_flt(U32 &ip); - OPCodeReturn op_savevar_str(U32 &ip); - OPCodeReturn op_savevar_var(U32 &ip); - OPCodeReturn op_setcurobject(U32 &ip); - OPCodeReturn op_setcurobject_internal(U32 &ip); - OPCodeReturn op_setcurobject_new(U32 &ip); - OPCodeReturn op_setcurfield(U32 &ip); - OPCodeReturn op_setcurfield_array(U32 &ip); - OPCodeReturn op_setcurfield_type(U32 &ip); - OPCodeReturn op_setcurfield_this(U32 &ip); - OPCodeReturn op_setcurfield_array_var(U32 &ip); - OPCodeReturn op_loadfield_uint(U32 &ip); - OPCodeReturn op_loadfield_flt(U32 &ip); - OPCodeReturn op_loadfield_str(U32 &ip); - OPCodeReturn op_savefield_uint(U32 &ip); - OPCodeReturn op_savefield_flt(U32 &ip); - OPCodeReturn op_savefield_str(U32 &ip); - OPCodeReturn op_str_to_uint(U32 &ip); - OPCodeReturn op_str_to_flt(U32 &ip); - OPCodeReturn op_str_to_none(U32 &ip); - OPCodeReturn op_flt_to_uint(U32 &ip); - OPCodeReturn op_flt_to_str(U32 &ip); - OPCodeReturn op_flt_to_none(U32 &ip); - OPCodeReturn op_uint_to_flt(U32 &ip); - OPCodeReturn op_uint_to_str(U32 &ip); - OPCodeReturn op_uint_to_none(U32 &ip); - OPCodeReturn op_copyvar_to_none(U32 &ip); - OPCodeReturn op_loadimmed_uint(U32 &ip); - OPCodeReturn op_loadimmed_flt(U32 &ip); - OPCodeReturn op_tag_to_str(U32 &ip); - OPCodeReturn op_loadimmed_str(U32 &ip); - OPCodeReturn op_docblock_str(U32 &ip); - OPCodeReturn op_loadimmed_ident(U32 &ip); - OPCodeReturn op_callfunc_resolve(U32 &ip); - OPCodeReturn op_callfunc(U32 &ip); - OPCodeReturn op_callfunc_pointer(U32 &ip); - OPCodeReturn op_callfunc_this(U32 &ip); - OPCodeReturn op_advance_str(U32 &ip); - OPCodeReturn op_advance_str_appendchar(U32 &ip); - OPCodeReturn op_advance_str_comma(U32 &ip); - OPCodeReturn op_advance_str_nul(U32 &ip); - OPCodeReturn op_rewind_str(U32 &ip); - OPCodeReturn op_terminate_rewind_str(U32 &ip); - OPCodeReturn op_compare_str(U32 &ip); - OPCodeReturn op_push(U32 &ip); - OPCodeReturn op_push_uint(U32 &ip); - OPCodeReturn op_push_flt(U32 &ip); - OPCodeReturn op_push_var(U32 &ip); - OPCodeReturn op_push_this(U32 &ip); - OPCodeReturn op_push_frame(U32 &ip); - OPCodeReturn op_assert(U32 &ip); - OPCodeReturn op_break(U32 &ip); - OPCodeReturn op_iter_begin_str(U32 &ip); - OPCodeReturn op_iter_begin(U32 &ip); - OPCodeReturn op_iter(U32 &ip); - OPCodeReturn op_iter_end(U32 &ip); - OPCodeReturn op_invalid(U32 &ip); - - /// @} - -private: - CodeBlock *mCodeBlock; - - /// Group exec arguments. - struct - { - StringTableEntry functionName; - Namespace *thisNamespace; - U32 argc; - ConsoleValueRef *argv; - bool noCalls; - StringTableEntry packageName; - S32 setFrame; - } mExec; - - U32 mIterDepth; - F64 *mCurFloatTable; - char *mCurStringTable; - StringTableEntry mThisFunctionName; - bool mPopFrame; - - // Add local object creation stack [7/9/2007 Black] - static const U32 objectCreationStackSize = 32; - U32 mObjectCreationStackIndex; - struct - { - SimObject *newObject; - U32 failJump; - } mObjectCreationStack[objectCreationStackSize]; - - SimObject *mCurrentNewObject; - U32 mFailJump; - StringTableEntry mPrevField; - StringTableEntry mCurField; - SimObject *mPrevObject; - SimObject *mCurObject; - SimObject *mSaveObject; - SimObject *mThisObject; - Namespace::Entry *mNSEntry; - StringTableEntry mCurFNDocBlock; - StringTableEntry mCurNSDocBlock; - U32 mCallArgc; - ConsoleValueRef *mCallArgv; - CodeBlock *mSaveCodeBlock; - - // note: anything returned is pushed to CSTK and will be invalidated on the next exec() - ConsoleValueRef mReturnValue; - - U32 mCurrentInstruction; - - static const S32 nsDocLength = 128; - char mNSDocBlockClass[nsDocLength]; -}; - -#endif \ No newline at end of file diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 47f5717ad..a18729fd4 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -1,5 +1,7 @@ //----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC +// Copyright (c) 2013 GarageGames, LLC +// Copyright (c) 2015 Faust Logic, Inc. +// 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 @@ -40,8 +42,8 @@ #include "util/messaging/message.h" #include "core/frameAllocator.h" -#include "console/codeInterpreter.h" #include "console/returnBuffer.h" +#include "console/consoleValueStack.h" #ifndef TORQUE_TGB_ONLY #include "materials/materialDefinition.h" @@ -50,13 +52,96 @@ using namespace Compiler; +enum EvalConstants +{ + MaxStackSize = 1024, + FieldBufferSizeString = 2048, + FieldBufferSizeNumeric = 128, + ConcatBufferInitialSize = 8192, + MethodOnComponent = -2 +}; + +/// Frame data for a foreach/foreach$ loop. +struct IterStackRecord +{ + /// If true, this is a foreach$ loop; if not, it's a foreach loop. + bool mIsStringIter; + + /// True if the variable referenced is a global + bool mIsGlobalVariable; + + union + { + + /// The iterator variable if we are a global variable + Dictionary::Entry* mVariable; + + /// The register variable if we are a local variable + S32 mRegister; + } mVar; + + /// Information for an object iterator loop. + struct ObjectPos + { + /// The set being iterated over. + SimSet* mSet; + + /// Current index in the set. + U32 mIndex; + }; + + /// Information for a string iterator loop. + struct StringPos + { + /// The raw string data on the string stack. + const char* mString; + + /// Current parsing position. + U32 mIndex; + }; + union + { + ObjectPos mObj; + StringPos mStr; + } mData; +}; + +ConsoleValueStack<4096> gCallStack; + +StringStack STR; + +IterStackRecord iterStack[MaxStackSize]; +U32 _ITER = 0; ///< Stack pointer for iterStack. + +ConsoleValue stack[MaxStackSize]; +S32 _STK = 0; + +char curFieldArray[256]; +char prevFieldArray[256]; + +const char* tsconcat(const char* strA, const char* strB, S32& outputLen) +{ + S32 lenA = dStrlen(strA); + S32 lenB = dStrlen(strB); + + S32 len = lenA + lenB + 1; + + char* concatBuffer = (char*)dMalloc(len); + + concatBuffer[len - 1] = '\0'; + memcpy(concatBuffer, strA, lenA); + memcpy(concatBuffer + lenA, strB, lenB); + + outputLen = lenA + lenB; + return concatBuffer; +} + namespace Con { // Current script file name and root, these are registered as // console variables. extern StringTableEntry gCurrentFile; extern StringTableEntry gCurrentRoot; - extern S32 gObjectCopyFailures; } namespace Con @@ -79,6 +164,120 @@ namespace Con } } +static void getFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField, char val[], S32 currentLocalRegister) +{ + const char* prevVal = NULL; + + if (object && field) + prevVal = object->getDataField(field, array); + else if (currentLocalRegister != -1) + prevVal = gEvalState.getLocalStringVariable(currentLocalRegister); + else if (gEvalState.currentVariable) + prevVal = gEvalState.getStringVariable(); + + // Make sure we got a value. + if (prevVal && *prevVal) + { + static const StringTableEntry xyzw[] = + { + StringTable->insert("x"), + StringTable->insert("y"), + StringTable->insert("z"), + StringTable->insert("w") + }; + + static const StringTableEntry rgba[] = + { + StringTable->insert("r"), + StringTable->insert("g"), + StringTable->insert("b"), + StringTable->insert("a") + }; + + // Translate xyzw and rgba into the indexed component + // of the variable or field. + if (subField == xyzw[0] || subField == rgba[0]) + dStrcpy(val, StringUnit::getUnit(prevVal, 0, " \t\n"), 128); + + else if (subField == xyzw[1] || subField == rgba[1]) + dStrcpy(val, StringUnit::getUnit(prevVal, 1, " \t\n"), 128); + + else if (subField == xyzw[2] || subField == rgba[2]) + dStrcpy(val, StringUnit::getUnit(prevVal, 2, " \t\n"), 128); + + else if (subField == xyzw[3] || subField == rgba[3]) + dStrcpy(val, StringUnit::getUnit(prevVal, 3, " \t\n"), 128); + + else + val[0] = 0; + } + else + val[0] = 0; +} + +static void setFieldComponent(SimObject* object, StringTableEntry field, const char* array, StringTableEntry subField, S32 currentLocalRegister) +{ + // Copy the current string value + char strValue[1024]; + dStrncpy(strValue, stack[_STK].getString(), 1024); + + char val[1024] = ""; + const char* prevVal = NULL; + + if (object && field) + prevVal = object->getDataField(field, array); + else if (currentLocalRegister != -1) + prevVal = gEvalState.getLocalStringVariable(currentLocalRegister); + // Set the value on a variable. + else if (gEvalState.currentVariable) + prevVal = gEvalState.getStringVariable(); + + // Ensure that the variable has a value + if (!prevVal) + return; + + static const StringTableEntry xyzw[] = + { + StringTable->insert("x"), + StringTable->insert("y"), + StringTable->insert("z"), + StringTable->insert("w") + }; + + static const StringTableEntry rgba[] = + { + StringTable->insert("r"), + StringTable->insert("g"), + StringTable->insert("b"), + StringTable->insert("a") + }; + + // Insert the value into the specified + // component of the string. + if (subField == xyzw[0] || subField == rgba[0]) + dStrcpy(val, StringUnit::setUnit(prevVal, 0, strValue, " \t\n"), 128); + + else if (subField == xyzw[1] || subField == rgba[1]) + dStrcpy(val, StringUnit::setUnit(prevVal, 1, strValue, " \t\n"), 128); + + else if (subField == xyzw[2] || subField == rgba[2]) + dStrcpy(val, StringUnit::setUnit(prevVal, 2, strValue, " \t\n"), 128); + + else if (subField == xyzw[3] || subField == rgba[3]) + dStrcpy(val, StringUnit::setUnit(prevVal, 3, strValue, " \t\n"), 128); + + if (val[0] != 0) + { + // Update the field or variable. + if (object && field) + object->setDataField(field, 0, val); + else if (currentLocalRegister != -1) + gEvalState.setLocalStringVariable(currentLocalRegister, val, dStrlen(val)); + else if (gEvalState.currentVariable) + gEvalState.setStringVariable(val); + } +} + //------------------------------------------------------------ F64 consoleStringToNumber(const char *str, StringTableEntry file, U32 line) @@ -239,38 +438,1910 @@ void ExprEvalState::setStringVariable(const char *val) currentVariable->setStringValue(val); } -void ExprEvalState::setStringStackPtrVariable(StringStackPtr str) +//----------------------------------------------------------------------------- + +enum class FloatOperation { - AssertFatal(currentVariable != NULL, "Invalid evaluator state - trying to set null variable!"); - currentVariable->setStringStackPtrValue(str); + Add, + Sub, + Mul, + Div, + + LT, + LE, + GR, + GE, + EQ, + NE +}; + +template +TORQUE_NOINLINE void doSlowMathOp() +{ + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + // Arithmetic + if constexpr (Op == FloatOperation::Add) + stack[_STK - 1].setFloat(a.getFloat() + b.getFloat()); + else if constexpr (Op == FloatOperation::Sub) + stack[_STK - 1].setFloat(a.getFloat() - b.getFloat()); + else if constexpr (Op == FloatOperation::Mul) + stack[_STK - 1].setFloat(a.getFloat() * b.getFloat()); + else if constexpr (Op == FloatOperation::Div) + stack[_STK - 1].setFloat(a.getFloat() / b.getFloat()); + + // Logical + if constexpr (Op == FloatOperation::LT) + stack[_STK - 1].setInt(a.getFloat() < b.getFloat()); + if constexpr (Op == FloatOperation::LE) + stack[_STK - 1].setInt(a.getFloat() <= b.getFloat()); + if constexpr (Op == FloatOperation::GR) + stack[_STK - 1].setInt(a.getFloat() > b.getFloat()); + if constexpr (Op == FloatOperation::GE) + stack[_STK - 1].setInt(a.getFloat() >= b.getFloat()); + if constexpr (Op == FloatOperation::EQ) + stack[_STK - 1].setInt(a.getFloat() == b.getFloat()); + if constexpr (Op == FloatOperation::NE) + stack[_STK - 1].setInt(a.getFloat() != b.getFloat()); + + _STK--; } -void ExprEvalState::setCopyVariable() +template +TORQUE_FORCEINLINE void doFloatMathOperation() { - if (copyVariable) + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + S32 fastIf = (a.getType() == ConsoleValueType::cvFloat) & (b.getType() == ConsoleValueType::cvFloat); + if (fastIf) { - switch (copyVariable->value.type) - { - case ConsoleValue::TypeInternalInt: - currentVariable->setIntValue(copyVariable->getIntValue()); - break; - case ConsoleValue::TypeInternalFloat: - currentVariable->setFloatValue(copyVariable->getFloatValue()); - break; - default: - currentVariable->setStringValue(copyVariable->getStringValue()); - break; - } + // Arithmetic + if constexpr (Op == FloatOperation::Add) + stack[_STK - 1].setFastFloat(a.getFastFloat() + b.getFastFloat()); + if constexpr (Op == FloatOperation::Sub) + stack[_STK - 1].setFastFloat(a.getFastFloat() - b.getFastFloat()); + if constexpr (Op == FloatOperation::Mul) + stack[_STK - 1].setFastFloat(a.getFastFloat() * b.getFastFloat()); + if constexpr (Op == FloatOperation::Div) + stack[_STK - 1].setFastFloat(a.getFastFloat() / b.getFastFloat()); + + // Logical + if constexpr (Op == FloatOperation::LT) + stack[_STK - 1].setFastInt(a.getFastFloat() < b.getFastFloat()); + if constexpr (Op == FloatOperation::LE) + stack[_STK - 1].setFastInt(a.getFastFloat() <= b.getFastFloat()); + if constexpr (Op == FloatOperation::GR) + stack[_STK - 1].setFastInt(a.getFastFloat() > b.getFastFloat()); + if constexpr (Op == FloatOperation::GE) + stack[_STK - 1].setFastInt(a.getFastFloat() >= b.getFastFloat()); + if constexpr (Op == FloatOperation::EQ) + stack[_STK - 1].setFastInt(a.getFastFloat() == b.getFastFloat()); + if constexpr (Op == FloatOperation::NE) + stack[_STK - 1].setFastInt(a.getFastFloat() != b.getFastFloat()); + + _STK--; + } + else + { + doSlowMathOp(); } } -//------------------------------------------------------------ +//----------------------------------------------------------------------------- - -ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, S32 setFrame) +enum class IntegerOperation { - CodeInterpreter interpreter(this); - return interpreter.exec(ip, functionName, thisNamespace, argc, argv, noCalls, packageName, setFrame); + BitAnd, + BitOr, + Xor, + LShift, + RShift, + + LogicalAnd, + LogicalOr +}; + +template +TORQUE_NOINLINE void doSlowIntegerOp() +{ + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + // Bitwise Op + if constexpr (Op == IntegerOperation::BitAnd) + stack[_STK - 1].setInt(a.getInt() & b.getInt()); + if constexpr (Op == IntegerOperation::BitOr) + stack[_STK - 1].setInt(a.getInt() | b.getInt()); + if constexpr (Op == IntegerOperation::Xor) + stack[_STK - 1].setInt(a.getInt() ^ b.getInt()); + if constexpr (Op == IntegerOperation::LShift) + stack[_STK - 1].setInt(a.getInt() << b.getInt()); + if constexpr (Op == IntegerOperation::RShift) + stack[_STK - 1].setInt(a.getInt() >> b.getInt()); + + // Logical Op + if constexpr (Op == IntegerOperation::LogicalAnd) + stack[_STK - 1].setInt(a.getInt() && b.getInt()); + if constexpr (Op == IntegerOperation::LogicalOr) + stack[_STK - 1].setInt(a.getInt() || b.getInt()); + + _STK--; +} + +template +TORQUE_FORCEINLINE void doIntOperation() +{ + ConsoleValue& a = stack[_STK]; + ConsoleValue& b = stack[_STK - 1]; + + if (a.isNumberType() && b.isNumberType()) + { + // Bitwise Op + if constexpr (Op == IntegerOperation::BitAnd) + stack[_STK - 1].setFastInt(a.getFastInt() & b.getFastInt()); + if constexpr (Op == IntegerOperation::BitOr) + stack[_STK - 1].setFastInt(a.getFastInt() | b.getFastInt()); + if constexpr (Op == IntegerOperation::Xor) + stack[_STK - 1].setFastInt(a.getFastInt() ^ b.getFastInt()); + if constexpr (Op == IntegerOperation::LShift) + stack[_STK - 1].setFastInt(a.getFastInt() << b.getFastInt()); + if constexpr (Op == IntegerOperation::RShift) + stack[_STK - 1].setFastInt(a.getFastInt() >> b.getFastInt()); + + // Logical Op + if constexpr (Op == IntegerOperation::LogicalAnd) + stack[_STK - 1].setFastInt(a.getFastInt() && b.getFastInt()); + if constexpr (Op == IntegerOperation::LogicalOr) + stack[_STK - 1].setFastInt(a.getFastInt() || b.getFastInt()); + + _STK--; + } + else + { + doSlowIntegerOp(); + } +} + +//----------------------------------------------------------------------------- + +U32 gExecCount = 0; +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 = _STK; + gExecCount++; +#endif + + const dsize_t TRACE_BUFFER_SIZE = 1024; + static char traceBuffer[TRACE_BUFFER_SIZE]; + U32 i; + + U32 iterDepth = 0; + ConsoleValue returnValue; + + incRefCount(); + F64* curFloatTable; + char* curStringTable; + S32 curStringTableLen = 0; //clint to ensure we dont overwrite it + + StringTableEntry thisFunctionName = NULL; + bool popFrame = false; + if (argv) + { + // assume this points into a function decl: + U32 fnArgc = code[ip + 2 + 6]; + U32 regCount = code[ip + 2 + 7]; + thisFunctionName = CodeToSTE(code, ip); + S32 wantedArgc = getMin(argc - 1, fnArgc); // argv[0] is func name + if (gEvalState.traceOn) + { + traceBuffer[0] = 0; + dStrcat(traceBuffer, "Entering ", TRACE_BUFFER_SIZE); + if (packageName) + { + dStrcat(traceBuffer, "[", TRACE_BUFFER_SIZE); + dStrcat(traceBuffer, packageName, TRACE_BUFFER_SIZE); + dStrcat(traceBuffer, "]", TRACE_BUFFER_SIZE); + } + if (thisNamespace && thisNamespace->mName) + { + dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer), + "%s::%s(", thisNamespace->mName, thisFunctionName); + } + else + { + dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer), + "%s(", thisFunctionName); + } + for (i = 0; i < wantedArgc; i++) + { + dStrcat(traceBuffer, argv[i + 1].getString(), TRACE_BUFFER_SIZE); + if (i != wantedArgc - 1) + dStrcat(traceBuffer, ", ", TRACE_BUFFER_SIZE); + } + dStrcat(traceBuffer, ")", TRACE_BUFFER_SIZE); + Con::printf("%s", traceBuffer); + } + gEvalState.pushFrame(thisFunctionName, thisNamespace, regCount); + popFrame = true; + for (i = 0; i < wantedArgc; i++) + { + S32 reg = code[ip + (2 + 6 + 1 + 1) + i]; + ConsoleValue& value = argv[i + 1]; + gEvalState.moveConsoleValue(reg, std::move(value)); + } + ip = ip + fnArgc + (2 + 6 + 1 + 1); + curFloatTable = functionFloats; + curStringTable = functionStrings; + curStringTableLen = functionStringsMaxLen; + } + else + { + curFloatTable = globalFloats; + curStringTable = globalStrings; + curStringTableLen = globalStringsMaxLen; + + // If requested stack frame isn't available, request a new one + // (this prevents assert failures when creating local + // variables without a stack frame) + if (gEvalState.getStackDepth() <= setFrame) + setFrame = -1; + + // Do we want this code to execute using a new stack frame? + if (setFrame < 0) + { + gEvalState.pushFrame(NULL, NULL, 0); + gCallStack.pushFrame(0); + popFrame = true; + } + else + { + // We want to copy a reference to an existing stack frame + // on to the top of the stack. Any change that occurs to + // the locals during this new frame will also occur in the + // original frame. + S32 stackIndex = gEvalState.getTopOfStack() - setFrame - 1; + gEvalState.pushFrameRef(stackIndex); + popFrame = true; + } + } + + // Grab the state of the telenet debugger here once + // so that the push and pop frames are always balanced. + const bool telDebuggerOn = TelDebugger && TelDebugger->isConnected(); + if (telDebuggerOn && setFrame < 0) + TelDebugger->pushStackFrame(); + + StringTableEntry var, objParent; + U32 failJump; + StringTableEntry fnName; + StringTableEntry fnNamespace, fnPackage; + + static const U32 objectCreationStackSize = 32; + U32 objectCreationStackIndex = 0; + struct { + SimObject* newObject; + U32 failJump; + } objectCreationStack[objectCreationStackSize]; + + SimObject* currentNewObject = 0; + StringTableEntry prevField = NULL; + StringTableEntry curField = NULL; + SimObject* prevObject = NULL; + SimObject* curObject = NULL; + SimObject* saveObject = NULL; + Namespace::Entry* nsEntry; + Namespace* ns; + const char* curFNDocBlock = NULL; + const char* curNSDocBlock = NULL; + const S32 nsDocLength = 128; + char nsDocBlockClass[nsDocLength]; + + S32 callArgc; + ConsoleValue* callArgv; + + static char curFieldArray[256]; + static char prevFieldArray[256]; + + CodeBlock* saveCodeBlock = smCurrentCodeBlock; + smCurrentCodeBlock = this; + if (this->name) + { + Con::gCurrentFile = this->name; + Con::gCurrentRoot = this->modPath; + } + const char* val; + S32 reg; + S32 currentRegister = -1; + + // The frame temp is used by the variable accessor ops (OP_SAVEFIELD_* and + // OP_LOADFIELD_*) to store temporary values for the fields. + static S32 VAL_BUFFER_SIZE = 1024; + FrameTemp valBuffer(VAL_BUFFER_SIZE); + + for (;;) + { + U32 instruction = code[ip++]; + breakContinue: + switch (instruction) + { + case OP_FUNC_DECL: + if (!noCalls) + { + fnName = CodeToSTE(code, ip); + fnNamespace = CodeToSTE(code, ip + 2); + fnPackage = CodeToSTE(code, ip + 4); + bool hasBody = (code[ip + 6] & 0x01) != 0; + U32 lineNumber = code[ip + 6] >> 1; + + Namespace::unlinkPackages(); + if (fnNamespace == NULL && fnPackage == NULL) + ns = Namespace::global(); + else + ns = Namespace::find(fnNamespace, fnPackage); + ns->addFunction(fnName, this, hasBody ? ip : 0);// if no body, set the IP to 0 + if (curNSDocBlock) + { + if (fnNamespace == StringTable->lookup(nsDocBlockClass)) + { + char* usageStr = dStrdup(curNSDocBlock); + usageStr[dStrlen(usageStr)] = '\0'; + ns->mUsage = usageStr; + ns->mCleanUpUsage = true; + curNSDocBlock = NULL; + } + } + Namespace::relinkPackages(); + + // If we had a docblock, it's definitely not valid anymore, so clear it out. + curFNDocBlock = NULL; + + //Con::printf("Adding function %s::%s (%d)", fnNamespace, fnName, ip); + } + ip = code[ip + 7]; + break; + + case OP_CREATE_OBJECT: + { + // Read some useful info. + objParent = CodeToSTE(code, ip); + bool isDataBlock = code[ip + 2]; + bool isInternal = code[ip + 3]; + bool isSingleton = code[ip + 4]; + U32 lineNumber = code[ip + 5]; + failJump = code[ip + 6]; + + // If we don't allow calls, we certainly don't allow creating objects! + // Moved this to after failJump is set. Engine was crashing when + // noCalls = true and an object was being created at the beginning of + // a file. ADL. + if (noCalls) + { + ip = failJump; + break; + } + + // Push the old info to the stack + //Assert( objectCreationStackIndex < objectCreationStackSize ); + objectCreationStack[objectCreationStackIndex].newObject = currentNewObject; + objectCreationStack[objectCreationStackIndex++].failJump = failJump; + + // Get the constructor information off the stack. + gCallStack.argvc(NULL, callArgc, &callArgv); + AssertFatal(callArgc - 3 >= 0, avar("Call Arg needs at least 3, only has %d", callArgc)); + const char* objectName = callArgv[2].getString(); + + // Con::printf("Creating object..."); + + // objectName = argv[1]... + currentNewObject = NULL; + + // Are we creating a datablock? If so, deal with case where we override + // an old one. + if (isDataBlock) + { + // Con::printf(" - is a datablock"); + + // Find the old one if any. + SimObject* db = Sim::getDataBlockGroup()->findObject(objectName); + + // Make sure we're not changing types on ourselves... + if (db && dStricmp(db->getClassName(), callArgv[1].getString())) + { + Con::errorf(ConsoleLogEntry::General, "Cannot re-declare data block %s with a different class.", objectName); + ip = failJump; + gCallStack.popFrame(); + break; + } + + // If there was one, set the currentNewObject and move on. + if (db) + currentNewObject = db; + } + else if (!isInternal) + { + AbstractClassRep* rep = AbstractClassRep::findClassRep(objectName); + if (rep != NULL) + { + Con::errorf(ConsoleLogEntry::General, "%s: Cannot name object [%s] the same name as a script class.", + getFileLine(ip), objectName); + ip = failJump; + gCallStack.popFrame(); + break; + } + + SimObject* obj = Sim::findObject((const char*)objectName); + if (obj) + { + if (isSingleton) + { + // Make sure we're not trying to change types + if (dStricmp(obj->getClassName(), callArgv[1].getString()) != 0) + { + Con::errorf(ConsoleLogEntry::General, "%s: Cannot re-declare object [%s] with a different class [%s] - was [%s].", + getFileLine(ip), objectName, callArgv[1].getString(), obj->getClassName()); + ip = failJump; + gCallStack.popFrame(); + break; + } + + // We're creating a singleton, so use the found object instead of creating a new object. + currentNewObject = obj; + Con::warnf("%s: Singleton Object was already created with name %s. Using existing object.", + getFileLine(ip), objectName); + } + } + } + + gCallStack.popFrame(); + + if (!currentNewObject) + { + // Well, looks like we have to create a new object. + ConsoleObject* object = ConsoleObject::create(callArgv[1].getString()); + + // Deal with failure! + if (!object) + { + Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-conobject class %s.", getFileLine(ip - 1), callArgv[1].getString()); + ip = failJump; + break; + } + + // Do special datablock init if appropros + if (isDataBlock) + { + SimDataBlock* dataBlock = dynamic_cast(object); + if (dataBlock) + { + dataBlock->assignId(); + } + else + { + // They tried to make a non-datablock with a datablock keyword! + Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-datablock class %s.", getFileLine(ip - 1), callArgv[1].getString()); + + // Clean up... + delete object; + currentNewObject = NULL; + ip = failJump; + break; + } + } + + // Finally, set currentNewObject to point to the new one. + currentNewObject = dynamic_cast(object); + + // Deal with the case of a non-SimObject. + if (!currentNewObject) + { + Con::errorf(ConsoleLogEntry::General, "%s: Unable to instantiate non-SimObject class %s.", getFileLine(ip - 1), callArgv[1].getString()); + delete object; + ip = failJump; + break; + } + + // Set the declaration line + currentNewObject->setDeclarationLine(lineNumber); + + // Set the file that this object was created in + currentNewObject->setFilename(this->name); + + // Does it have a parent object? (ie, the copy constructor : syntax, not inheriance) + if (*objParent) + { + // Find it! + SimObject* parent; + if (Sim::findObject(objParent, parent)) + { + // Con::printf(" - Parent object found: %s", parent->getClassName()); + + currentNewObject->setCopySource(parent); + currentNewObject->assignFieldsFrom(parent); + + // copy any substitution statements + SimDataBlock* parent_db = dynamic_cast(parent); + if (parent_db) + { + SimDataBlock* currentNewObject_db = dynamic_cast(currentNewObject); + if (currentNewObject_db) + currentNewObject_db->copySubstitutionsFrom(parent_db); + } + } + else + { + Con::errorf(ConsoleLogEntry::General, "%s: Unable to find parent object %s for %s.", getFileLine(ip - 1), objParent, callArgv[1].getString()); + delete object; + currentNewObject = NULL; + ip = failJump; + break; + } + } + + // If a name was passed, assign it. + if (objectName[0]) + { + if (!isInternal) + currentNewObject->assignName(objectName); + else + currentNewObject->setInternalName(objectName); + + // Set the original name + currentNewObject->setOriginalName( objectName ); + } + + // Do the constructor parameters. + if (!currentNewObject->processArguments(callArgc - 3, callArgv + 3)) + { + delete currentNewObject; + currentNewObject = NULL; + ip = failJump; + break; + } + + // If it's not a datablock, allow people to modify bits of it. + if (!isDataBlock) + { + currentNewObject->setModStaticFields(true); + currentNewObject->setModDynamicFields(true); + } + } + else + { + currentNewObject->reloadReset(); // AFX (reload-reset) + + // Does it have a parent object? (ie, the copy constructor : syntax, not inheriance) + if (*objParent) + { + // Find it! + SimObject* parent; + if (Sim::findObject(objParent, parent)) + { + // Con::printf(" - Parent object found: %s", parent->getClassName()); + + // temporarily block name change + SimObject::preventNameChanging = true; + currentNewObject->setCopySource(parent); + currentNewObject->assignFieldsFrom(parent); + // restore name changing + SimObject::preventNameChanging = false; + + // copy any substitution statements + SimDataBlock* parent_db = dynamic_cast(parent); + if (parent_db) + { + SimDataBlock* currentNewObject_db = dynamic_cast(currentNewObject); + if (currentNewObject_db) + currentNewObject_db->copySubstitutionsFrom(parent_db); + } + } + else + { + Con::errorf(ConsoleLogEntry::General, "%d: Unable to find parent object %s for %s.", lineNumber, objParent, callArgv[1].getString()); + } + } + } + + // Advance the IP past the create info... + ip += 7; + break; + } + + case OP_ADD_OBJECT: + { + // See OP_SETCURVAR for why we do this. + curFNDocBlock = NULL; + curNSDocBlock = NULL; + + // Do we place this object at the root? + bool placeAtRoot = code[ip++]; + + // Con::printf("Adding object %s", currentNewObject->getName()); + + // Make sure it wasn't already added, then add it. + if (currentNewObject == NULL) + { + break; + } + + bool isMessage = dynamic_cast(currentNewObject) != NULL; + + if (currentNewObject->isProperlyAdded() == false) + { + bool ret = false; + if (isMessage) + { + SimObjectId id = Message::getNextMessageID(); + if (id != 0xffffffff) + ret = currentNewObject->registerObject(id); + else + Con::errorf("%s: No more object IDs available for messages", getFileLine(ip)); + } + else + ret = currentNewObject->registerObject(); + + if (!ret) + { + // This error is usually caused by failing to call Parent::initPersistFields in the class' initPersistFields(). + Con::warnf(ConsoleLogEntry::General, "%s: Register object failed for object %s of class %s.", getFileLine(ip - 2), currentNewObject->getName(), currentNewObject->getClassName()); + delete currentNewObject; + currentNewObject = NULL; + ip = failJump; + break; + } + } + + // Are we dealing with a datablock? + SimDataBlock* dataBlock = dynamic_cast(currentNewObject); + String errorStr; + + // If so, preload it. + if (dataBlock && !dataBlock->preload(true, errorStr)) + { + Con::errorf(ConsoleLogEntry::General, "%s: preload failed for %s: %s.", getFileLine(ip - 2), + currentNewObject->getName(), errorStr.c_str()); + dataBlock->deleteObject(); + ip = failJump; + break; + } + + // What group will we be added to, if any? + U32 groupAddId = (U32)stack[_STK].getInt(); + SimGroup* grp = NULL; + SimSet* set = NULL; + + if (!placeAtRoot || !currentNewObject->getGroup()) + { + if (!isMessage) + { + if (!placeAtRoot) + { + // Otherwise just add to the requested group or set. + if (!Sim::findObject(groupAddId, grp)) + Sim::findObject(groupAddId, set); + } + + if (placeAtRoot) + { + // Deal with the instantGroup if we're being put at the root or we're adding to a component. + if (Con::gInstantGroup.isEmpty() || !Sim::findObject(Con::gInstantGroup, grp)) + grp = Sim::getRootGroup(); + } + } + + // If we didn't get a group, then make sure we have a pointer to + // the rootgroup. + if (!grp) + grp = Sim::getRootGroup(); + + // add to the parent group + grp->addObject(currentNewObject); + + // If for some reason the add failed, add the object to the + // root group so it won't leak. + if (currentNewObject->getGroup() == NULL) + Sim::getRootGroup()->addObject(currentNewObject); + + // add to any set we might be in + if (set) + set->addObject(currentNewObject); + } + + // store the new object's ID on the stack (overwriting the group/set + // id, if one was given, otherwise getting pushed) + S32 id = currentNewObject->getId(); + if (placeAtRoot) + stack[_STK].setInt(id); + else + stack[++_STK].setInt(id); + + break; + } + + case OP_END_OBJECT: + { + // If we're not to be placed at the root, make sure we clean up + // our group reference. + bool placeAtRoot = code[ip++]; + if (!placeAtRoot) + _STK--; + break; + } + + case OP_FINISH_OBJECT: + { + if (currentNewObject) + currentNewObject->onPostAdd(); + + AssertFatal( objectCreationStackIndex >= 0, "Object Stack is empty." ); + // Restore the object info from the stack [7/9/2007 Black] + currentNewObject = objectCreationStack[--objectCreationStackIndex].newObject; + failJump = objectCreationStack[objectCreationStackIndex].failJump; + break; + } + + case OP_JMPIFFNOT: + if (stack[_STK--].getFloat()) + { + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMPIFNOT: + if (stack[_STK--].getInt()) + { + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMPIFF: + if (!stack[_STK--].getFloat()) + { + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMPIF: + if (!stack[_STK--].getFloat()) + { + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMPIFNOT_NP: + if (stack[_STK].getInt()) + { + _STK--; + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMPIF_NP: + if (!stack[_STK].getInt()) + { + _STK--; + ip++; + break; + } + ip = code[ip]; + break; + case OP_JMP: + ip = code[ip]; + break; + + case OP_RETURN_VOID: + { + if (iterDepth > 0) + { + // Clear iterator state. + while (iterDepth > 0) + { + iterStack[--_ITER].mIsStringIter = false; + --iterDepth; + + _STK--; // this is a pop from foreach() + } + } + + returnValue.setEmptyString(); + + goto execFinished; + } + + case OP_RETURN: + { + returnValue = std::move(stack[_STK]); + _STK--; + + // Clear iterator state. + while (iterDepth > 0) + { + iterStack[--_ITER].mIsStringIter = false; + --iterDepth; + + _STK--; + } + + goto execFinished; + } + case OP_RETURN_FLT: + returnValue.setFloat(stack[_STK].getFloat()); + _STK--; + + // Clear iterator state. + while (iterDepth > 0) + { + iterStack[--_ITER].mIsStringIter = false; + --iterDepth; + + _STK--; + } + + goto execFinished; + + case OP_RETURN_UINT: + returnValue.setInt(stack[_STK].getInt()); + _STK--; + + // Clear iterator state. + while (iterDepth > 0) + { + iterStack[--_ITER].mIsStringIter = false; + --iterDepth; + + _STK--; + } + + goto execFinished; + + case OP_CMPEQ: + doFloatMathOperation(); + break; + + case OP_CMPGR: + doFloatMathOperation(); + break; + + case OP_CMPGE: + doFloatMathOperation(); + break; + + case OP_CMPLT: + doFloatMathOperation(); + break; + + case OP_CMPLE: + doFloatMathOperation(); + break; + + case OP_CMPNE: + doFloatMathOperation(); + break; + + case OP_XOR: + doIntOperation(); + break; + + case OP_BITAND: + doIntOperation(); + break; + + case OP_BITOR: + doIntOperation(); + break; + + case OP_NOT: + stack[_STK].setInt(!stack[_STK].getInt()); + break; + + case OP_NOTF: + stack[_STK].setInt(!stack[_STK].getFloat()); + break; + + case OP_ONESCOMPLEMENT: + stack[_STK].setInt(~stack[_STK].getInt()); + break; + + case OP_SHR: + doIntOperation(); + break; + + case OP_SHL: + doIntOperation(); + break; + + case OP_AND: + doIntOperation(); + break; + + case OP_OR: + doIntOperation(); + break; + + case OP_ADD: + doFloatMathOperation(); + break; + + case OP_SUB: + doFloatMathOperation(); + break; + + case OP_MUL: + doFloatMathOperation(); + break; + + case OP_DIV: + doFloatMathOperation(); + break; + + case OP_MOD: + { + S64 divisor = stack[_STK - 1].getInt(); + if (divisor != 0) + stack[_STK - 1].setInt(stack[_STK].getInt() % divisor); + else + stack[_STK - 1].setInt(0); + _STK--; + break; + } + + case OP_NEG: + stack[_STK].setFloat(-stack[_STK].getFloat()); + break; + + case OP_INC: + reg = code[ip++]; + currentRegister = reg; + gEvalState.setLocalFloatVariable(reg, gEvalState.getLocalFloatVariable(reg) + 1.0); + break; + + case OP_SETCURVAR: + var = CodeToSTE(code, ip); + ip += 2; + + // If a variable is set, then these must be NULL. It is necessary + // to set this here so that the vector parser can appropriately + // identify whether it's dealing with a vector. + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + // Used for local variable caching of what is active...when we + // set a global, we aren't active + currentRegister = -1; + + gEvalState.setCurVarName(var); + + // In order to let docblocks work properly with variables, we have + // clear the current docblock when we do an assign. This way it + // won't inappropriately carry forward to following function decls. + curFNDocBlock = NULL; + curNSDocBlock = NULL; + break; + + case OP_SETCURVAR_CREATE: + var = CodeToSTE(code, ip); + ip += 2; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + // Used for local variable caching of what is active...when we + // set a global, we aren't active + currentRegister = -1; + + gEvalState.setCurVarNameCreate(var); + + // See OP_SETCURVAR for why we do this. + curFNDocBlock = NULL; + curNSDocBlock = NULL; + break; + + case OP_SETCURVAR_ARRAY: + var = StringTable->insert(stack[_STK].getString()); + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + // Used for local variable caching of what is active...when we + // set a global, we aren't active + currentRegister = -1; + + gEvalState.setCurVarName(var); + + // See OP_SETCURVAR for why we do this. + curFNDocBlock = NULL; + curNSDocBlock = NULL; + break; + + case OP_SETCURVAR_ARRAY_CREATE: + var = StringTable->insert(stack[_STK].getString()); + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + // Used for local variable caching of what is active...when we + // set a global, we aren't active + currentRegister = -1; + + gEvalState.setCurVarNameCreate(var); + + // See OP_SETCURVAR for why we do this. + curFNDocBlock = NULL; + curNSDocBlock = NULL; + break; + + case OP_LOADVAR_UINT: + currentRegister = -1; + stack[_STK + 1].setInt(gEvalState.getIntVariable()); + _STK++; + break; + + case OP_LOADVAR_FLT: + currentRegister = -1; + stack[_STK + 1].setFloat(gEvalState.getFloatVariable()); + _STK++; + break; + + case OP_LOADVAR_STR: + currentRegister = -1; + stack[_STK + 1].setString(gEvalState.getStringVariable()); + _STK++; + break; + + case OP_SAVEVAR_UINT: + gEvalState.setIntVariable(stack[_STK].getInt()); + break; + + case OP_SAVEVAR_FLT: + gEvalState.setFloatVariable(stack[_STK].getFloat()); + break; + + case OP_SAVEVAR_STR: + gEvalState.setStringVariable(stack[_STK].getString()); + break; + + case OP_LOAD_LOCAL_VAR_UINT: + reg = code[ip++]; + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + stack[_STK + 1].setInt(gEvalState.getLocalIntVariable(reg)); + _STK++; + break; + + case OP_LOAD_LOCAL_VAR_FLT: + reg = code[ip++]; + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + stack[_STK + 1].setFloat(gEvalState.getLocalFloatVariable(reg)); + _STK++; + break; + + case OP_LOAD_LOCAL_VAR_STR: + reg = code[ip++]; + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + val = gEvalState.getLocalStringVariable(reg); + stack[_STK + 1].setString(val); + _STK++; + break; + + case OP_SAVE_LOCAL_VAR_UINT: + reg = code[ip++]; + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + gEvalState.setLocalIntVariable(reg, stack[_STK].getInt()); + break; + + case OP_SAVE_LOCAL_VAR_FLT: + reg = code[ip++]; + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + gEvalState.setLocalFloatVariable(reg, stack[_STK].getFloat()); + break; + + case OP_SAVE_LOCAL_VAR_STR: + reg = code[ip++]; + val = stack[_STK].getString(); + currentRegister = reg; + + // See OP_SETCURVAR + prevField = NULL; + prevObject = NULL; + curObject = NULL; + + gEvalState.setLocalStringVariable(reg, val, (S32)dStrlen(val)); + break; + + case OP_SETCUROBJECT: + // Save the previous object for parsing vector fields. + prevObject = curObject; + val = stack[_STK].getString(); + + // Sim::findObject will sometimes find valid objects from + // multi-component strings. This makes sure that doesn't + // happen. + for (const char* check = val; *check; check++) + { + if (*check == ' ') + { + val = ""; + break; + } + } + curObject = Sim::findObject(val); + break; + + case OP_SETCUROBJECT_INTERNAL: + ++ip; // To skip the recurse flag if the object wasnt found + if (curObject) + { + SimGroup* group = dynamic_cast(curObject); + if (group) + { + StringTableEntry intName = StringTable->insert(stack[_STK].getString()); + bool recurse = code[ip - 1]; + SimObject* obj = group->findObjectByInternalName(intName, recurse); + stack[_STK].setInt(obj ? obj->getId() : 0); + } + else + { + Con::errorf(ConsoleLogEntry::Script, "%s: Attempt to use -> on non-group %s of class %s.", getFileLine(ip - 2), curObject->getName(), curObject->getClassName()); + stack[_STK].setInt(0); + } + } + else + { + Con::errorf(ConsoleLogEntry::Script, "%s: Attempt to use ->, but the group object wasn't found.", getFileLine(ip - 2)); + stack[_STK].setInt(0); + } + break; + + case OP_SETCUROBJECT_NEW: + curObject = currentNewObject; + break; + + case OP_SETCURFIELD: + // Save the previous field for parsing vector fields. + prevField = curField; + dStrcpy(prevFieldArray, curFieldArray, 256); + curField = CodeToSTE(code, ip); + curFieldArray[0] = 0; + ip += 2; + break; + + case OP_SETCURFIELD_ARRAY: + dStrcpy(curFieldArray, stack[_STK].getString(), 256); + break; + + case OP_SETCURFIELD_TYPE: + if(curObject) + curObject->setDataFieldType(code[ip], curField, curFieldArray); + ip++; + break; + + case OP_LOADFIELD_UINT: + if (curObject) + stack[_STK + 1].setInt(dAtol(curObject->getDataField(curField, curFieldArray))); + else + { + // The field is not being retrieved from an object. Maybe it's + // a special accessor? + char buff[FieldBufferSizeNumeric]; + memset(buff, 0, sizeof(buff)); + getFieldComponent(prevObject, prevField, prevFieldArray, curField, buff, currentRegister); + stack[_STK + 1].setInt(dAtol(buff)); + } + _STK++; + break; + + case OP_LOADFIELD_FLT: + if (curObject) + stack[_STK + 1].setFloat(dAtod(curObject->getDataField(curField, curFieldArray))); + else + { + // The field is not being retrieved from an object. Maybe it's + // a special accessor? + char buff[FieldBufferSizeNumeric]; + memset(buff, 0, sizeof(buff)); + getFieldComponent(prevObject, prevField, prevFieldArray, curField, buff, currentRegister); + stack[_STK + 1].setFloat(dAtod(buff)); + } + _STK++; + break; + + case OP_LOADFIELD_STR: + if (curObject) + { + val = curObject->getDataField(curField, curFieldArray); + stack[_STK + 1].setString(val); + } + else + { + // The field is not being retrieved from an object. Maybe it's + // a special accessor? + char buff[FieldBufferSizeString]; + memset(buff, 0, sizeof(buff)); + getFieldComponent(prevObject, prevField, prevFieldArray, curField, buff, currentRegister); + stack[_STK + 1].setString(buff); + } + _STK++; + break; + + case OP_SAVEFIELD_UINT: + if (curObject) + curObject->setDataField(curField, curFieldArray, stack[_STK].getString()); + else + { + // The field is not being set on an object. Maybe it's a special accessor? + setFieldComponent(prevObject, prevField, prevFieldArray, curField, currentRegister); + prevObject = NULL; + } + break; + + case OP_SAVEFIELD_FLT: + if (curObject) + curObject->setDataField(curField, curFieldArray, stack[_STK].getString()); + else + { + // The field is not being set on an object. Maybe it's a special accessor? + setFieldComponent(prevObject, prevField, prevFieldArray, curField, currentRegister); + prevObject = NULL; + } + break; + + case OP_SAVEFIELD_STR: + if (curObject) + curObject->setDataField(curField, curFieldArray, stack[_STK].getString()); + else + { + // The field is not being set on an object. Maybe it's a special accessor? + setFieldComponent(prevObject, prevField, prevFieldArray, curField, currentRegister); + prevObject = NULL; + } + break; + + case OP_POP_STK: + _STK--; + break; + + case OP_LOADIMMED_UINT: + stack[_STK + 1].setInt(code[ip++]); + _STK++; + break; + + case OP_LOADIMMED_FLT: + stack[_STK + 1].setFloat(curFloatTable[code[ip++]]); + _STK++; + break; + + case OP_TAG_TO_STR: + code[ip - 1] = OP_LOADIMMED_STR; + // it's possible the string has already been converted + if (U8(curStringTable[code[ip]]) != StringTagPrefixByte) + { + U32 id = GameAddTaggedString(curStringTable + code[ip]); + dSprintf(curStringTable + code[ip] + 1, 7, "%d", id); + *(curStringTable + code[ip]) = StringTagPrefixByte; + } + TORQUE_CASE_FALLTHROUGH; + + case OP_LOADIMMED_STR: + stack[_STK + 1].setString(curStringTable + code[ip++]); + _STK ++; + break; + + case OP_DOCBLOCK_STR: + { + // If the first word of the doc is '\class' or '@class', then this + // is a namespace doc block, otherwise it is a function doc block. + const char* docblock = curStringTable + code[ip++]; + + const char* sansClass = dStrstr(docblock, "@class"); + if (!sansClass) + sansClass = dStrstr(docblock, "\\class"); + + if (sansClass) + { + // Don't save the class declaration. Scan past the 'class' + // keyword and up to the first whitespace. + sansClass += 7; + S32 index = 0; + while ((*sansClass != ' ') && (*sansClass != '\n') && *sansClass && (index < (nsDocLength - 1))) + { + nsDocBlockClass[index++] = *sansClass; + sansClass++; + } + nsDocBlockClass[index] = '\0'; + + curNSDocBlock = sansClass + 1; + } + else + curFNDocBlock = docblock; + } + + break; + + case OP_LOADIMMED_IDENT: + stack[_STK + 1].setString(CodeToSTE(code, ip)); + _STK++; + ip += 2; + break; + + case OP_CALLFUNC: + { + // This routingId is set when we query the object as to whether + // it handles this method. It is set to an enum from the table + // above indicating whether it handles it on a component it owns + // or just on the object. + S32 routingId = 0; + + fnName = CodeToSTE(code, ip); + fnNamespace = CodeToSTE(code, ip + 2); + U32 callType = code[ip + 4]; + + //if this is called from inside a function, append the ip and codeptr + if (!gEvalState.stack.empty()) + { + gEvalState.getCurrentFrame().code = this; + gEvalState.getCurrentFrame().ip = ip - 1; + } + + ip += 5; + gCallStack.argvc(fnName, callArgc, &callArgv); + + if (callType == FuncCallExprNode::FunctionCall) + { + // Note: This works even if the function was in a package. Reason being is when + // activatePackage() is called, it swaps the namespaceEntry into the global namespace + // (and reverts it when deactivatePackage is called). Method or Static related ones work + // as expected, as the namespace is resolved on the fly. + nsEntry = Namespace::global()->lookup(fnName); + if (!nsEntry) + { + Con::warnf(ConsoleLogEntry::General, + "%s: Unable to find function %s", + getFileLine(ip - 4), fnName); + + gCallStack.popFrame(); + stack[_STK + 1].setEmptyString(); + _STK++; + break; + } + } + else if (callType == FuncCallExprNode::StaticCall) + { + // Try to look it up. + ns = Namespace::find(fnNamespace); + nsEntry = ns->lookup(fnName); + if (!nsEntry) + { + Con::warnf(ConsoleLogEntry::General, + "%s: Unable to find function %s%s%s", + getFileLine(ip - 4), fnNamespace ? fnNamespace : "", + fnNamespace ? "::" : "", fnName); + + gCallStack.popFrame(); + stack[_STK + 1].setEmptyString(); + _STK++; + break; + } + } + else if (callType == FuncCallExprNode::MethodCall) + { + saveObject = gEvalState.thisObject; + + // Optimization: If we're an integer, we can lookup the value by SimObjectId + const ConsoleValue& simObjectLookupValue = callArgv[1]; + if (simObjectLookupValue.getType() == ConsoleValueType::cvInteger) + gEvalState.thisObject = Sim::findObject(static_cast(simObjectLookupValue.getFastInt())); + else + { + SimObject *foundObject = Sim::findObject(simObjectLookupValue.getString()); + + // Optimization: If we're not an integer, let's make it so that the fast path exists + // on the first argument of the method call (speeds up future usage of %this, for example) + if (foundObject != NULL) + callArgv[1].setInt(static_cast(foundObject->getId())); + + gEvalState.thisObject = foundObject; + } + + if (gEvalState.thisObject == NULL) + { + Con::warnf( + ConsoleLogEntry::General, + "%s: Unable to find object: '%s' attempting to call function '%s'", + getFileLine(ip - 6), + simObjectLookupValue.getString(), + fnName + ); + + gCallStack.popFrame(); + stack[_STK + 1].setEmptyString(); + _STK++; + break; + } + + ns = gEvalState.thisObject->getNamespace(); + if (ns) + nsEntry = ns->lookup(fnName); + else + nsEntry = NULL; + } + else // it's a ParentCall + { + if (thisNamespace) + { + ns = thisNamespace->mParent; + if (ns) + nsEntry = ns->lookup(fnName); + else + nsEntry = NULL; + } + else + { + ns = NULL; + nsEntry = NULL; + } + } + + if (!nsEntry || noCalls) + { + if (!noCalls) + { + Con::warnf(ConsoleLogEntry::General, "%s: Unknown command %s.", getFileLine(ip - 4), fnName); + if (callType == FuncCallExprNode::MethodCall) + { + Con::warnf(ConsoleLogEntry::General, " Object %s(%d) %s", + gEvalState.thisObject->getName() ? gEvalState.thisObject->getName() : "", + gEvalState.thisObject->getId(), Con::getNamespaceList(ns)); + } + } + gCallStack.popFrame(); + stack[_STK + 1].setEmptyString(); + _STK++; + break; + } + if (nsEntry->mType == Namespace::Entry::ConsoleFunctionType) + { + if (nsEntry->mFunctionOffset) + { + ConsoleValue returnFromFn = nsEntry->mCode->exec(nsEntry->mFunctionOffset, fnName, nsEntry->mNamespace, callArgc, callArgv, false, nsEntry->mPackage); + stack[_STK + 1] = std::move(returnFromFn); + } + else // no body + stack[_STK + 1].setEmptyString(); + _STK++; + + gCallStack.popFrame(); + } + else + { + if ((nsEntry->mMinArgs && S32(callArgc) < nsEntry->mMinArgs) || (nsEntry->mMaxArgs && S32(callArgc) > nsEntry->mMaxArgs)) + { + const char* nsName = ns ? ns->mName : ""; + Con::warnf(ConsoleLogEntry::Script, "%s: %s::%s - wrong number of arguments.", getFileLine(ip - 4), nsName, fnName); + Con::warnf(ConsoleLogEntry::Script, "%s: usage: %s", getFileLine(ip - 4), nsEntry->mUsage); + gCallStack.popFrame(); + stack[_STK + 1].setEmptyString(); + _STK++; + } + else + { + switch (nsEntry->mType) + { + case Namespace::Entry::StringCallbackType: + { + const char* result = nsEntry->cb.mStringCallbackFunc(gEvalState.thisObject, callArgc, callArgv); + gCallStack.popFrame(); + stack[_STK + 1].setString(result); + _STK++; + break; + } + case Namespace::Entry::IntCallbackType: + { + S64 result = nsEntry->cb.mIntCallbackFunc(gEvalState.thisObject, callArgc, callArgv); + gCallStack.popFrame(); + + if (code[ip] == OP_POP_STK) + { + ip++; + break; + } + + stack[_STK + 1].setInt(result); + _STK++; + break; + } + case Namespace::Entry::FloatCallbackType: + { + F64 result = nsEntry->cb.mFloatCallbackFunc(gEvalState.thisObject, callArgc, callArgv); + gCallStack.popFrame(); + + if (code[ip] == OP_POP_STK) + { + ip++; + break; + } + + stack[_STK + 1].setFloat(result); + _STK++; + break; + } + case Namespace::Entry::VoidCallbackType: + { + nsEntry->cb.mVoidCallbackFunc(gEvalState.thisObject, callArgc, callArgv); + gCallStack.popFrame(); + + if (code[ip] == OP_POP_STK) + { + ip++; + break; + } + + Con::warnf(ConsoleLogEntry::General, "%s: Call to %s in %s uses result of void function call.", getFileLine(ip - 4), fnName, functionName); + stack[_STK + 1].setEmptyString(); + _STK++; + + break; + } + case Namespace::Entry::BoolCallbackType: + { + bool result = nsEntry->cb.mBoolCallbackFunc(gEvalState.thisObject, callArgc, callArgv); + gCallStack.popFrame(); + + if (code[ip] == OP_POP_STK) + { + ip++; + break; + } + + stack[_STK + 1].setBool(result); + _STK++; + + break; + } + } + } + } + + if (callType == FuncCallExprNode::MethodCall) + gEvalState.thisObject = saveObject; + break; + } + + case OP_ADVANCE_STR_APPENDCHAR: + { + char buff[2]; + buff[0] = (char)code[ip++]; + buff[1] = '\0'; + + S32 len; + const char* concat = tsconcat(stack[_STK].getString(), buff, len); + + stack[_STK].setStringRef(concat, len); + break; + } + + case OP_REWIND_STR: + TORQUE_CASE_FALLTHROUGH; + case OP_TERMINATE_REWIND_STR: + { + S32 len; + const char* concat = tsconcat(stack[_STK - 1].getString(), stack[_STK].getString(), len); + + stack[_STK - 1].setStringRef(concat, len); + _STK--; + break; + } + + case OP_COMPARE_STR: + stack[_STK - 1].setBool(!dStricmp(stack[_STK].getString(), stack[_STK - 1].getString())); + _STK--; + break; + + case OP_PUSH: + gCallStack.push(std::move(stack[_STK--])); + break; + + case OP_PUSH_FRAME: + gCallStack.pushFrame(code[ip++]); + break; + + case OP_ASSERT: + { + if (!stack[_STK--].getBool()) + { + const char* message = curStringTable + code[ip]; + + U32 breakLine, inst; + findBreakLine(ip - 1, breakLine, inst); + + if (PlatformAssert::processAssert(PlatformAssert::Fatal, + name ? name : "eval", + breakLine, + message)) + { + if (TelDebugger && TelDebugger->isConnected() && breakLine > 0) + { + TelDebugger->breakProcess(); + } + else + Platform::debugBreak(); + } + } + + ip++; + break; + } + + case OP_BREAK: + { + //append the ip and codeptr before managing the breakpoint! + AssertFatal(!gEvalState.stack.empty(), "Empty eval stack on break!"); + gEvalState.getCurrentFrame().code = this; + gEvalState.getCurrentFrame().ip = ip - 1; + + U32 breakLine; + findBreakLine(ip - 1, breakLine, instruction); + if (!breakLine) + goto breakContinue; + TelDebugger->executionStopped(this, breakLine); + + goto breakContinue; + } + + case OP_ITER_BEGIN_STR: + { + iterStack[_ITER].mIsStringIter = true; + TORQUE_CASE_FALLTHROUGH; + } + + case OP_ITER_BEGIN: + { + bool isGlobal = code[ip]; + + U32 failIp = code[ip + (isGlobal ? 3 : 2)]; + + IterStackRecord& iter = iterStack[_ITER]; + iter.mIsGlobalVariable = isGlobal; + + if (isGlobal) + { + StringTableEntry varName = CodeToSTE(code, ip + 1); + iter.mVar.mVariable = gEvalState.globalVars.add(varName); + } + else + { + iter.mVar.mRegister = code[ip + 1]; + } + + if (iter.mIsStringIter) + { + iter.mData.mStr.mString = stack[_STK].getString(); + iter.mData.mStr.mIndex = 0; + } + else + { + // Look up the object. + + SimSet* set; + if (!Sim::findObject(stack[_STK].getString(), set)) + { + Con::errorf(ConsoleLogEntry::General, "No SimSet object '%s'", stack[_STK].getString()); + Con::errorf(ConsoleLogEntry::General, "Did you mean to use 'foreach$' instead of 'foreach'?"); + ip = failIp; + continue; + } + + // Set up. + + iter.mData.mObj.mSet = set; + iter.mData.mObj.mIndex = 0; + } + + _ITER++; + iterDepth++; + + ip += isGlobal ? 4 : 3; + break; + } + + case OP_ITER: + { + U32 breakIp = code[ip]; + IterStackRecord& iter = iterStack[_ITER - 1]; + + if (iter.mIsStringIter) + { + const char* str = iter.mData.mStr.mString; + + U32 startIndex = iter.mData.mStr.mIndex; + U32 endIndex = startIndex; + + // Break if at end. + + if (!str[startIndex]) + { + ip = breakIp; + continue; + } + + // Find right end of current component. + + if (!dIsspace(str[endIndex])) + do ++endIndex; + while (str[endIndex] && !dIsspace(str[endIndex])); + + // Extract component. + + if (endIndex != startIndex) + { + char savedChar = str[endIndex]; + const_cast(str)[endIndex] = '\0'; // We are on the string stack so this is okay. + + if (iter.mIsGlobalVariable) + iter.mVar.mVariable->setStringValue(&str[startIndex]); + else + gEvalState.setLocalStringVariable(iter.mVar.mRegister, &str[startIndex], endIndex - startIndex); + + const_cast(str)[endIndex] = savedChar; + } + else + { + if (iter.mIsGlobalVariable) + iter.mVar.mVariable->setStringValue(""); + else + gEvalState.setLocalStringVariable(iter.mVar.mRegister, "", 0); + } + + // Skip separator. + if (str[endIndex] != '\0') + ++endIndex; + + iter.mData.mStr.mIndex = endIndex; + } + else + { + U32 index = iter.mData.mObj.mIndex; + SimSet* set = iter.mData.mObj.mSet; + + if (index >= set->size()) + { + ip = breakIp; + continue; + } + + SimObjectId id = set->at(index)->getId(); + + if (iter.mIsGlobalVariable) + iter.mVar.mVariable->setIntValue(id); + else + gEvalState.setLocalIntVariable(iter.mVar.mRegister, id); + + iter.mData.mObj.mIndex = index + 1; + } + + ++ip; + break; + } + + case OP_ITER_END: + { + --_ITER; + --iterDepth; + + _STK--; + + iterStack[_ITER].mIsStringIter = false; + break; + } + + case OP_INVALID: + TORQUE_CASE_FALLTHROUGH; + default: + // error! + AssertISV(false, "Invalid OPCode Processed!"); + goto execFinished; + } + } +execFinished: + + if (telDebuggerOn && setFrame < 0) + TelDebugger->popStackFrame(); + + if (popFrame) + { + gEvalState.popFrame(); + } + + if (argv) + { + if (gEvalState.traceOn) + { + traceBuffer[0] = 0; + dStrcat(traceBuffer, "Leaving ", TRACE_BUFFER_SIZE); + + if (packageName) + { + dStrcat(traceBuffer, "[", TRACE_BUFFER_SIZE); + dStrcat(traceBuffer, packageName, TRACE_BUFFER_SIZE); + dStrcat(traceBuffer, "]", TRACE_BUFFER_SIZE); + } + if (thisNamespace && thisNamespace->mName) + { + dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer), + "%s::%s() - return %s", thisNamespace->mName, thisFunctionName, returnValue.getString()); + } + else + { + dSprintf(traceBuffer + dStrlen(traceBuffer), sizeof(traceBuffer) - dStrlen(traceBuffer), + "%s() - return %s", thisFunctionName, returnValue.getString()); + } + Con::printf("%s", traceBuffer); + } + } + else + { + delete[] const_cast(globalStrings); + delete[] globalFloats; + globalStrings = NULL; + globalFloats = NULL; + } + smCurrentCodeBlock = saveCodeBlock; + if (saveCodeBlock && saveCodeBlock->name) + { + Con::gCurrentFile = saveCodeBlock->name; + Con::gCurrentRoot = saveCodeBlock->modPath; + } + + decRefCount(); + +#ifdef TORQUE_DEBUG + AssertFatal(!(_STK > stackStart), "String stack not popped enough in script exec"); + AssertFatal(!(_STK < stackStart), "String stack popped too much in script exec"); +#endif + + return std::move(returnValue); } //------------------------------------------------------------ diff --git a/Engine/source/console/compiler.cpp b/Engine/source/console/compiler.cpp index 8b1e15a8f..1ab6e7b22 100644 --- a/Engine/source/console/compiler.cpp +++ b/Engine/source/console/compiler.cpp @@ -60,6 +60,7 @@ namespace Compiler CompilerFloatTable *gCurrentFloatTable, gGlobalFloatTable, gFunctionFloatTable; DataChunker gConsoleAllocator; CompilerIdentTable gIdentTable; + CompilerLocalVariableToRegisterMappingTable gFunctionVariableMappingTable; //------------------------------------------------------------ @@ -92,6 +93,8 @@ namespace Compiler CompilerStringTable &getGlobalStringTable() { return gGlobalStringTable; } CompilerStringTable &getFunctionStringTable() { return gFunctionStringTable; } + CompilerLocalVariableToRegisterMappingTable& getFunctionVariableMappingTable() { return gFunctionVariableMappingTable; } + void setCurrentStringTable(CompilerStringTable* cst) { gCurrentStringTable = cst; } CompilerFloatTable *getCurrentFloatTable() { return gCurrentFloatTable; } @@ -117,6 +120,7 @@ namespace Compiler getFunctionFloatTable().reset(); getFunctionStringTable().reset(); getIdentTable().reset(); + getFunctionVariableMappingTable().reset(); } void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); } @@ -208,6 +212,66 @@ void CompilerStringTable::write(Stream &st) //------------------------------------------------------------ +void CompilerLocalVariableToRegisterMappingTable::add(StringTableEntry functionName, StringTableEntry namespaceName, StringTableEntry varName) +{ + StringTableEntry funcLookupTableName = StringTable->insert(avar("%s::%s", namespaceName, functionName)); + + localVarToRegister[funcLookupTableName].varList.push_back(varName);; +} + +S32 CompilerLocalVariableToRegisterMappingTable::lookup(StringTableEntry namespaceName, StringTableEntry functionName, StringTableEntry varName) +{ + StringTableEntry funcLookupTableName = StringTable->insert(avar("%s::%s", namespaceName, functionName)); + + auto functionPosition = localVarToRegister.find(funcLookupTableName); + if (functionPosition != localVarToRegister.end()) + { + const auto& table = localVarToRegister[funcLookupTableName].varList; + auto varPosition = std::find(table.begin(), table.end(), varName); + if (varPosition != table.end()) + { + return std::distance(table.begin(), varPosition); + } + } + + Con::errorf("Unable to find local variable %s in function name %s", varName, funcLookupTableName); + return -1; +} + +CompilerLocalVariableToRegisterMappingTable CompilerLocalVariableToRegisterMappingTable::copy() +{ + // Trivilly copyable as its all plain old data and using STL containers... (We want a deep copy though!) + CompilerLocalVariableToRegisterMappingTable table; + table.localVarToRegister = localVarToRegister; + return table; +} + +void CompilerLocalVariableToRegisterMappingTable::reset() +{ + localVarToRegister.clear(); +} + +void CompilerLocalVariableToRegisterMappingTable::write(Stream& stream) +{ + stream.write((U32)localVarToRegister.size()); + + for (const auto& pair : localVarToRegister) + { + StringTableEntry functionName = pair.first; + stream.writeString(functionName); + + const auto& localVariableTableForFunction = localVarToRegister[functionName].varList; + stream.write((U32)localVariableTableForFunction.size()); + + for (const StringTableEntry& varName : localVariableTableForFunction) + { + stream.writeString(varName); + } + } +} + +//------------------------------------------------------------ + U32 CompilerFloatTable::add(F64 value) { Entry **walk; diff --git a/Engine/source/console/compiler.h b/Engine/source/console/compiler.h index 74dd6d2a0..117576a61 100644 --- a/Engine/source/console/compiler.h +++ b/Engine/source/console/compiler.h @@ -44,6 +44,8 @@ class DataChunker; #include "core/util/tVector.h" #endif +//------------------------------------------------------------ + namespace Compiler { /// The opcodes for the TorqueScript VM. @@ -69,6 +71,7 @@ namespace Compiler OP_RETURN_FLT, OP_RETURN_UINT, + OP_CMPEQ, OP_CMPGR, OP_CMPGE, @@ -93,26 +96,28 @@ namespace Compiler OP_MUL, OP_DIV, OP_NEG, - OP_INC, - OP_DEC, OP_SETCURVAR, OP_SETCURVAR_CREATE, OP_SETCURVAR_ARRAY, - OP_SETCURVAR_ARRAY_VARLOOKUP, OP_SETCURVAR_ARRAY_CREATE, - OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP, OP_LOADVAR_UINT,// 40 OP_LOADVAR_FLT, OP_LOADVAR_STR, - OP_LOADVAR_VAR, OP_SAVEVAR_UINT, OP_SAVEVAR_FLT, OP_SAVEVAR_STR, - OP_SAVEVAR_VAR, + + OP_LOAD_LOCAL_VAR_UINT, + OP_LOAD_LOCAL_VAR_FLT, + OP_LOAD_LOCAL_VAR_STR, + + OP_SAVE_LOCAL_VAR_UINT, + OP_SAVE_LOCAL_VAR_FLT, + OP_SAVE_LOCAL_VAR_STR, OP_SETCUROBJECT, OP_SETCUROBJECT_NEW, @@ -121,8 +126,6 @@ namespace Compiler OP_SETCURFIELD, OP_SETCURFIELD_ARRAY, // 50 OP_SETCURFIELD_TYPE, - OP_SETCURFIELD_ARRAY_VAR, - OP_SETCURFIELD_THIS, OP_LOADFIELD_UINT, OP_LOADFIELD_FLT, @@ -132,43 +135,25 @@ namespace Compiler OP_SAVEFIELD_FLT, OP_SAVEFIELD_STR, - OP_STR_TO_UINT, - OP_STR_TO_FLT, - OP_STR_TO_NONE, // 60 - OP_FLT_TO_UINT, - OP_FLT_TO_STR, - OP_FLT_TO_NONE, - OP_UINT_TO_FLT, - OP_UINT_TO_STR, - OP_UINT_TO_NONE, - OP_COPYVAR_TO_NONE, + OP_POP_STK, OP_LOADIMMED_UINT, OP_LOADIMMED_FLT, OP_TAG_TO_STR, OP_LOADIMMED_STR, // 70 - OP_DOCBLOCK_STR, + OP_DOCBLOCK_STR, // 76 OP_LOADIMMED_IDENT, - OP_CALLFUNC_RESOLVE, OP_CALLFUNC, - OP_CALLFUNC_POINTER, - OP_CALLFUNC_THIS, - OP_ADVANCE_STR, OP_ADVANCE_STR_APPENDCHAR, - OP_ADVANCE_STR_COMMA, - OP_ADVANCE_STR_NUL, OP_REWIND_STR, - OP_TERMINATE_REWIND_STR, // 80 + OP_TERMINATE_REWIND_STR, + OP_COMPARE_STR, - OP_PUSH, // String - OP_PUSH_UINT, // Integer - OP_PUSH_FLT, // Float - OP_PUSH_VAR, // Variable - OP_PUSH_THIS, // This pointer - OP_PUSH_FRAME, // Frame + OP_PUSH, + OP_PUSH_FRAME, OP_ASSERT, OP_BREAK, @@ -269,6 +254,7 @@ namespace Compiler CompilerStringTable *getCurrentStringTable(); CompilerStringTable &getGlobalStringTable(); CompilerStringTable &getFunctionStringTable(); + CompilerLocalVariableToRegisterMappingTable& getFunctionVariableMappingTable(); void setCurrentStringTable(CompilerStringTable* cst); diff --git a/Engine/source/console/console.cpp b/Engine/source/console/console.cpp index a99ab1823..ab93d554e 100644 --- a/Engine/source/console/console.cpp +++ b/Engine/source/console/console.cpp @@ -41,9 +41,40 @@ #include "platform/threads/mutex.h" #include "core/util/journal/journal.h" #include "cinterface/cinterface.h" +#include "console/consoleValueStack.h" extern StringStack STR; -extern ConsoleValueStack CSTK; +extern ConsoleValueStack<4096> gCallStack; + +Vector ConsoleValue::sConversionBuffer; + +void ConsoleValue::init() +{ + sConversionBuffer.reserve(8192); +} + +void ConsoleValue::resetConversionBuffer() +{ + sConversionBuffer.resetAndTreatAsScratchBuffer(); +} + +char* ConsoleValue::convertToBuffer() const +{ + ConversionBuffer conversion; + + if (type == ConsoleValueType::cvFloat) + dSprintf(conversion.buffer, ConversionBufferStride, "%.9g", f); + else + dSprintf(conversion.buffer, ConversionBufferStride, "%lld", i); + + sConversionBuffer.push_back(std::move(conversion)); + return sConversionBuffer.last().buffer; +} + +const char* ConsoleValue::getConsoleData() const +{ + return Con::getData(type, ct->dataPtr, 0, ct->enumTable); +} ConsoleDocFragment* ConsoleDocFragment::smFirst; ExprEvalState gEvalState; @@ -271,8 +302,6 @@ StringTableEntry gCurrentFile; StringTableEntry gCurrentRoot; /// @} -S32 gObjectCopyFailures = -1; - bool alwaysUseDebugOutput = true; bool useTimestamp = false; bool useRealTimestamp = false; @@ -327,6 +356,7 @@ void init() // Setup the console types. ConsoleBaseType::initialize(); + ConsoleValue::init(); // And finally, the ACR... AbstractClassRep::initialize(); @@ -344,10 +374,6 @@ void init() addVariable( "instantGroup", TypeRealString, &gInstantGroup, "The group that objects will be added to when they are created.\n" "@ingroup Console\n"); - addVariable("Con::objectCopyFailures", TypeS32, &gObjectCopyFailures, "If greater than zero then it counts the number of object creation " - "failures based on a missing copy object and does not report an error..\n" - "@ingroup Console\n"); - // Current script file name and root addVariable( "Con::File", TypeString, &gCurrentFile, "The currently executing script file.\n" "@ingroup FileSystem\n"); @@ -1474,7 +1500,7 @@ bool executeFile(const char* fileName, bool noCalls, bool journalScript) return ret; } -ConsoleValueRef evaluate(const char* string, bool echo, const char *fileName) +ConsoleValue evaluate(const char* string, bool echo, const char *fileName) { ConsoleStackFrameSaver stackSaver; stackSaver.save(); @@ -1491,11 +1517,11 @@ ConsoleValueRef evaluate(const char* string, bool echo, const char *fileName) fileName = StringTable->insert(fileName); CodeBlock *newCodeBlock = new CodeBlock(); - return newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0); + return std::move(newCodeBlock->compileExec(fileName, string, false, fileName ? -1 : 0)); } //------------------------------------------------------------------------------ -ConsoleValueRef evaluatef(const char* string, ...) +ConsoleValue evaluatef(const char* string, ...) { ConsoleStackFrameSaver stackSaver; stackSaver.save(); @@ -1512,36 +1538,41 @@ ConsoleValueRef evaluatef(const char* string, ...) //------------------------------------------------------------------------------ // Internal execute for global function which does not save the stack -ConsoleValueRef _internalExecute(S32 argc, ConsoleValueRef argv[]) +ConsoleValue _internalExecute(S32 argc, ConsoleValue argv[]) { + StringTableEntry funcName = StringTable->insert(argv[0].getString()); + const char** argv_str = static_cast(malloc((argc - 1) * sizeof(char *))); for (int i = 0; i < argc - 1; i++) { - argv_str[i] = argv[i + 1]; + argv_str[i] = argv[i + 1].getString(); } bool result; - const char* methodRes = CInterface::CallFunction(NULL, argv[0], argv_str, argc - 1, &result); + const char* methodRes = CInterface::CallFunction(NULL, funcName, argv_str, argc - 1, &result); free(argv_str); if (result) { - return ConsoleValueRef::fromValue(CSTK.pushString(methodRes)); + ConsoleValue ret; + ret.setString(methodRes); + return std::move(ret); } Namespace::Entry *ent; - StringTableEntry funcName = StringTable->insert(argv[0]); + ent = Namespace::global()->lookup(funcName); if(!ent) { - warnf(ConsoleLogEntry::Script, "%s: Unknown command.", (const char*)argv[0]); + warnf(ConsoleLogEntry::Script, "%s: Unknown command.", funcName); STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } - return ent->execute(argc, argv, &gEvalState); + + return std::move(ent->execute(argc, argv, &gEvalState)); } -ConsoleValueRef execute(S32 argc, ConsoleValueRef argv[]) +ConsoleValue execute(S32 argc, ConsoleValue argv[]) { #ifdef TORQUE_MULTITHREAD if(isMainThread()) @@ -1563,23 +1594,23 @@ ConsoleValueRef execute(S32 argc, ConsoleValueRef argv[]) #endif } -ConsoleValueRef execute(S32 argc, const char *argv[]) +ConsoleValue execute(S32 argc, const char *argv[]) { ConsoleStackFrameSaver stackSaver; stackSaver.save(); - StringStackConsoleWrapper args(argc, argv); - return execute(args.count(), args); + StringArrayToConsoleValueWrapper args(argc, argv); + return std::move(execute(args.count(), args)); } //------------------------------------------------------------------------------ // Internal execute for object method which does not save the stack -ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly) +static ConsoleValue _internalExecute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly) { if(argc < 2) { STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } // [neo, 10/05/2007 - #3010] @@ -1590,35 +1621,36 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar ICallMethod *com = dynamic_cast(object); if(com) { - STR.pushFrame(); - CSTK.pushFrame(); + gCallStack.pushFrame(0); com->callMethodArgList(argc, argv, false); - STR.popFrame(); - CSTK.popFrame(); + gCallStack.popFrame(); } } + StringTableEntry funcName = StringTable->insert(argv[0].getString()); + const char** argv_str = static_cast(malloc((argc - 2) * sizeof(char *))); for (int i = 0; i < argc - 2; i++) { - argv_str[i] = argv[i + 2]; + argv_str[i] = argv[i + 2].getString(); } bool result; - const char* methodRes = CInterface::CallMethod(object, argv[0], argv_str, argc - 2, &result); + const char* methodRes = CInterface::CallMethod(object, funcName, argv_str, argc - 2, &result); free(argv_str); if (result) { - return ConsoleValueRef::fromValue(CSTK.pushString(methodRes)); + ConsoleValue val; + val.setString(methodRes); + return val; } if(object->getNamespace()) { U32 ident = object->getId(); - ConsoleValueRef oldIdent(argv[1]); - - StringTableEntry funcName = StringTable->insert(argv[0]); + const char* oldIdent = dStrdup(argv[1].getString()); + Namespace::Entry *ent = object->getNamespace()->lookup(funcName); if(ent == NULL) @@ -1626,37 +1658,35 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar //warnf(ConsoleLogEntry::Script, "%s: undefined for object '%s' - id %d", funcName, object->getName(), object->getId()); STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } // Twiddle %this argument - ConsoleValue func_ident; - func_ident.setIntValue((S32)ident); - argv[1] = ConsoleValueRef::fromValue(&func_ident); + argv[1].setInt(ident); SimObject *save = gEvalState.thisObject; gEvalState.thisObject = object; - ConsoleValueRef ret = ent->execute(argc, argv, &gEvalState); + ConsoleValue ret = std::move(ent->execute(argc, argv, &gEvalState)); gEvalState.thisObject = save; // Twiddle it back - argv[1] = oldIdent; + argv[1].setString(oldIdent); + dFree(oldIdent); return ret; } - warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), (const char*)argv[0]); + warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), funcName); STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } - -ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly) +ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly) { if(argc < 2) { STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } ConsoleStackFrameSaver stackSaver; @@ -1666,7 +1696,7 @@ ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], boo { if (isMainThread()) { - return _internalExecute(object, argc, argv, thisCallOnly); + return std::move(_internalExecute(object, argc, argv, thisCallOnly)); } else { @@ -1676,34 +1706,34 @@ ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], boo } } - warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), (const char*)argv[0]); + warnf(ConsoleLogEntry::Script, "Con::execute - %d has no namespace: %s", object->getId(), argv[0].getString()); STR.clearFunctionOffset(); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } -ConsoleValueRef execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly) +ConsoleValue execute(SimObject *object, S32 argc, const char *argv[], bool thisCallOnly) { ConsoleStackFrameSaver stackSaver; stackSaver.save(); - StringStackConsoleWrapper args(argc, argv); - return execute(object, args.count(), args, thisCallOnly); + StringArrayToConsoleValueWrapper args(argc, argv); + return std::move(execute(object, args.count(), args, thisCallOnly)); } -inline ConsoleValueRef _executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValueRef *argv) +inline ConsoleValue _executef(SimObject *obj, S32 checkArgc, S32 argc, ConsoleValue *argv) { const U32 maxArg = 12; - AssertWarn(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)"); + AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef(SimObject*)"); AssertFatal(argc <= maxArg - 1, "Too many args passed to Con::_executef(SimObject*). Please update the function to handle more."); - return execute(obj, argc, argv); + return std::move(execute(obj, argc, argv)); } //------------------------------------------------------------------------------ -inline ConsoleValueRef _executef(S32 checkArgc, S32 argc, ConsoleValueRef *argv) +inline ConsoleValue _executef(S32 checkArgc, S32 argc, ConsoleValue *argv) { const U32 maxArg = 10; AssertFatal(checkArgc == argc, "Incorrect arg count passed to Con::executef()"); AssertFatal(argc <= maxArg, "Too many args passed to Con::_executef(). Please update the function to handle more."); - return execute(argc, argv); + return std::move(execute(argc, argv)); } //------------------------------------------------------------------------------ @@ -1901,15 +1931,9 @@ StringTableEntry getModNameFromPath(const char *path) void postConsoleInput( RawData data ) { // Schedule this to happen at the next time event. - ConsoleValue values[2]; - ConsoleValueRef argv[2]; - - values[0].init(); - values[0].setStringValue("eval"); - values[1].init(); - values[1].setStringValue((const char*)data.data); - argv[0].value = &values[0]; - argv[1].value = &values[1]; + ConsoleValue argv[2]; + argv[0].setString("eval"); + argv[1].setString(reinterpret_cast(data.data)); Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(2, argv, false)); } @@ -2524,70 +2548,20 @@ DefineEngineFunction( logWarning, void, ( const char* message ),, //------------------------------------------------------------------------------ -extern ConsoleValueStack CSTK; - -ConsoleValueRef::ConsoleValueRef(const ConsoleValueRef &ref) -{ - value = ref.value; -} - -ConsoleValueRef& ConsoleValueRef::operator=(const ConsoleValueRef &newValue) -{ - value = newValue.value; - return *this; -} - -ConsoleValueRef& ConsoleValueRef::operator=(const char *newValue) -{ - AssertFatal(value, "value should not be NULL"); - value->setStringValue(newValue); - return *this; -} - -ConsoleValueRef& ConsoleValueRef::operator=(S32 newValue) -{ - AssertFatal(value, "value should not be NULL"); - value->setIntValue(newValue); - return *this; -} - -ConsoleValueRef& ConsoleValueRef::operator=(U32 newValue) -{ - AssertFatal(value, "value should not be NULL"); - value->setIntValue(newValue); - return *this; -} - -ConsoleValueRef& ConsoleValueRef::operator=(F32 newValue) -{ - AssertFatal(value, "value should not be NULL"); - value->setFloatValue(newValue); - return *this; -} - -ConsoleValueRef& ConsoleValueRef::operator=(F64 newValue) -{ - AssertFatal(value, "value should not be NULL"); - value->setFloatValue(newValue); - return *this; -} - -//------------------------------------------------------------------------------ - -StringStackWrapper::StringStackWrapper(int targc, ConsoleValueRef targv[]) +ConsoleValueToStringArrayWrapper::ConsoleValueToStringArrayWrapper(int targc, ConsoleValue *targv) { argv = new const char*[targc]; argc = targc; - for (int i=0; i bufferLen) - sval = (char *) dRealloc(sval, newLen); - - dStrcpy(sval, internalValue, newLen); - bufferLen = newLen; - - return sval; - } -} - -StringStackPtr ConsoleValue::getStringStackPtr() -{ - if (type == TypeInternalStringStackPtr) - return (uintptr_t)sval; - else - return (uintptr_t)-1; -} - -bool ConsoleValue::getBoolValue() -{ - if(type == TypeInternalString || type == TypeInternalStackString || type == TypeInternalStringStackPtr) - return dAtob(getStringValue()); - if(type == TypeInternalFloat) - return fval > 0; - else if(type == TypeInternalInt) - return ival > 0; - else { - const char *value = Con::getData(type, dataPtr, 0, enumTable); - return dAtob(value); - } -} - -void ConsoleValue::setIntValue(S32 val) -{ - setFloatValue(val); -} - -void ConsoleValue::setIntValue(U32 val) -{ - if(type <= TypeInternalString) - { - fval = (F32)val; - ival = val; - if(bufferLen > 0) - { - dFree(sval); - bufferLen = 0; - } - - sval = typeValueEmpty; - type = TypeInternalInt; - } - else - { - const char *dptr = Con::getData(TypeS32, &val, 0); - Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); - } -} - -void ConsoleValue::setBoolValue(bool val) -{ - return setIntValue(val ? 1 : 0); -} - -void ConsoleValue::setFloatValue(F32 val) -{ - if(type <= TypeInternalString) - { - fval = val; - ival = static_cast(val); - if(bufferLen > 0) - { - dFree(sval); - bufferLen = 0; - } - sval = typeValueEmpty; - type = TypeInternalFloat; - } - else - { - const char *dptr = Con::getData(TypeF32, &val, 0); - Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); - } -} - -//------------------------------------------------------------------------------ - -ConsoleValueRef _BaseEngineConsoleCallbackHelper::_exec() -{ - ConsoleValueRef returnValue; if( mThis ) { // Cannot invoke callback until object has been registered - if (mThis->isProperlyAdded()) { - returnValue = Con::_internalExecute( mThis, mArgc, mArgv, false ); - } else { - STR.clearFunctionOffset(); - returnValue = ConsoleValueRef(); + if (mThis->isProperlyAdded()) + { + ConsoleValue returnValue = Con::_internalExecute( mThis, mArgc, mArgv, false ); + mArgc = mInitialArgc; // reset + return std::move(returnValue); } - } - else - returnValue = Con::_internalExecute( mArgc, mArgv ); + STR.clearFunctionOffset(); + mArgc = mInitialArgc; // reset + return std::move(ConsoleValue()); + } + + ConsoleValue returnValue = std::move(Con::_internalExecute( mArgc, mArgv )); mArgc = mInitialArgc; // reset args - return returnValue; + return std::move(returnValue); } -ConsoleValueRef _BaseEngineConsoleCallbackHelper::_execLater(SimConsoleThreadExecEvent *evt) +ConsoleValue _BaseEngineConsoleCallbackHelper::_execLater(SimConsoleThreadExecEvent *evt) { mArgc = mInitialArgc; // reset args Sim::postEvent((SimObject*)Sim::getRootGroup(), evt, Sim::getCurrentTime()); - return evt->getCB().waitForResult(); + return std::move(evt->getCB().waitForResult()); } //------------------------------------------------------------------------------ void ConsoleStackFrameSaver::save() { - CSTK.pushFrame(); - STR.pushFrame(); + gCallStack.pushFrame(0); mSaved = true; } @@ -2797,7 +2628,6 @@ void ConsoleStackFrameSaver::restore() { if (mSaved) { - CSTK.popFrame(); - STR.popFrame(); + gCallStack.popFrame(); } } diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index ad4d4f622..5c72f34e1 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -36,6 +36,7 @@ #include "core/util/str.h" #include "core/util/journal/journaledSignal.h" +#include "core/stringTable.h" class SimObject; class Namespace; @@ -117,188 +118,313 @@ struct ConsoleLogEntry typedef const char *StringTableEntry; extern char *typeValueEmpty; +enum ConsoleValueType +{ + cvInteger = -4, + cvFloat = -3, + cvString = -2, + cvSTEntry = -1, + cvConsoleValueType = 0 +}; + +struct ConsoleValueConsoleType +{ + void* dataPtr; + EnumTable* enumTable; +}; + class ConsoleValue { -public: - - enum + union { - TypeInternalInt = -5, - TypeInternalFloat = -4, - TypeInternalStringStackPtr = -3, - TypeInternalStackString = -2, - TypeInternalString = -1, + F64 f; + S64 i; + char* s; + void* data; + ConsoleValueConsoleType* ct; }; S32 type; -public: - - // NOTE: This is protected to ensure no one outside - // of this structure is messing with it. - -#pragma warning( push ) -#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union - - // An variable is either a real dynamic type or - // its one exposed from C++ using a data pointer. - // - // We use this nameless union and struct setup - // to optimize the memory usage. - union + enum Constants { - struct - { - char *sval; - U32 ival; // doubles as strlen when type is TypeInternalString - F32 fval; - U32 bufferLen; - }; - - struct - { - /// The real data pointer. - void *dataPtr; - - /// The enum lookup table for enumerated types. - const EnumTable *enumTable; - }; + ConversionBufferStride = 32 }; - U32 getIntValue(); - S32 getSignedIntValue(); - F32 getFloatValue(); - const char *getStringValue(); - StringStackPtr getStringStackPtr(); - bool getBoolValue(); - - void setIntValue(U32 val); - void setIntValue(S32 val); - void setFloatValue(F32 val); - void setStringValue(const char *value); - void setStackStringValue(const char *value); - void setStringStackPtrValue(StringStackPtr ptr); - void setBoolValue(bool val); - - void init() + struct ConversionBuffer { - ival = 0; - fval = 0; - sval = typeValueEmpty; - bufferLen = 0; - type = TypeInternalString; + char buffer[ConversionBufferStride]; + }; + + static Vector sConversionBuffer; + + char* convertToBuffer() const; + + TORQUE_FORCEINLINE bool hasAllocatedData() const + { + return (type == ConsoleValueType::cvString || isConsoleType()) && data != NULL; } - void cleanup() + const char* getConsoleData() const; + + TORQUE_FORCEINLINE void cleanupData() { - if ((type <= TypeInternalString) && (bufferLen > 0)) + if (hasAllocatedData()) { - dFree(sval); - bufferLen = 0; + dFree(data); + data = NULL; } - sval = typeValueEmpty; - type = ConsoleValue::TypeInternalString; - ival = 0; - fval = 0; } - ConsoleValue() { init(); }; - ~ConsoleValue() { cleanup(); }; -}; -// Proxy class for console variables -// Can point to existing console variables, -// or act like a free floating value. -class ConsoleValueRef -{ + TORQUE_FORCEINLINE void _move(ConsoleValue&& ref) noexcept + { + type = ref.type; + + switch (ref.type) + { + case cvInteger: + i = ref.i; + break; + case cvFloat: + f = ref.f; + break; + case cvSTEntry: + TORQUE_CASE_FALLTHROUGH; + case cvString: + s = ref.s; + break; + default: + data = ref.data; + break; + } + + ref.data = NULL; + ref.setEmptyString(); + } + public: - ConsoleValue *value; + ConsoleValue() + { + type = ConsoleValueType::cvSTEntry; + s = const_cast(StringTable->EmptyString()); + } - ConsoleValueRef() : value(0) { ; } - ~ConsoleValueRef() { ; } + ConsoleValue(ConsoleValue&& ref) noexcept + { + _move(std::move(ref)); + } - ConsoleValueRef(const ConsoleValueRef &ref); + TORQUE_FORCEINLINE ConsoleValue& operator=(ConsoleValue&& ref) noexcept + { + _move(std::move(ref)); + return *this; + } - static ConsoleValueRef fromValue(ConsoleValue *value) { ConsoleValueRef ref; ref.value = value; return ref; } + ConsoleValue(const ConsoleValue&) = delete; + ConsoleValue& operator=(const ConsoleValue&) = delete; - const char *getStringValue() { return value ? value->getStringValue() : ""; } - StringStackPtr getStringStackPtrValue() { return value ? value->getStringStackPtr() : 0; } + TORQUE_FORCEINLINE ~ConsoleValue() + { + cleanupData(); + } - inline U32 getIntValue() { return value ? value->getIntValue() : 0; } - inline S32 getSignedIntValue() { return value ? value->getSignedIntValue() : 0; } - inline F32 getFloatValue() { return value ? value->getFloatValue() : 0.0f; } - inline bool getBoolValue() { return value ? value->getBoolValue() : false; } + TORQUE_FORCEINLINE void reset() + { + setEmptyString(); + } - inline operator const char*() { return getStringValue(); } - inline operator String() { return String(getStringValue()); } - inline operator U32() { return getIntValue(); } - inline operator S32() { return getSignedIntValue(); } - inline operator F32() { return getFloatValue(); } - inline operator bool() { return getBoolValue(); } + TORQUE_FORCEINLINE F64 getFloat() const + { + if (type == ConsoleValueType::cvFloat) + return f; + if (type == ConsoleValueType::cvInteger) + return i; + if (isStringType()) + return dAtof(s); + return dAtof(getConsoleData()); + } - inline bool isStringStackPtr() { return value ? value->type == ConsoleValue::TypeInternalStringStackPtr : false; } - inline bool isString() { return value ? value->type >= ConsoleValue::TypeInternalStringStackPtr : true; } - inline bool isInt() { return value ? value->type == ConsoleValue::TypeInternalInt : false; } - inline bool isFloat() { return value ? value->type == ConsoleValue::TypeInternalFloat : false; } - inline S32 getType() { return value ? value->type : -1; } + TORQUE_FORCEINLINE S64 getInt() const + { + if (type == ConsoleValueType::cvInteger) + return i; + if (type == ConsoleValueType::cvFloat) + return f; + if (isStringType()) + return dAtoi(s); + return dAtoi(getConsoleData()); + } - // Note: operators replace value - ConsoleValueRef& operator=(const ConsoleValueRef &other); - ConsoleValueRef& operator=(const char *newValue); - ConsoleValueRef& operator=(U32 newValue); - ConsoleValueRef& operator=(S32 newValue); - ConsoleValueRef& operator=(F32 newValue); - ConsoleValueRef& operator=(F64 newValue); + TORQUE_FORCEINLINE const char* getString() const + { + if (isStringType()) + return s; + if (isNumberType()) + return convertToBuffer(); + return getConsoleData(); + } + + TORQUE_FORCEINLINE operator const char* () const + { + return getString(); + } + + TORQUE_FORCEINLINE bool getBool() const + { + if (type == ConsoleValueType::cvInteger) + return (bool)i; + if (type == ConsoleValueType::cvFloat) + return (bool)f; + if (isStringType()) + return dAtob(s); + return dAtob(getConsoleData()); + } + + TORQUE_FORCEINLINE void setFloat(const F64 val) + { + cleanupData(); + type = ConsoleValueType::cvFloat; + f = val; + } + + TORQUE_FORCEINLINE void setInt(const S64 val) + { + cleanupData(); + type = ConsoleValueType::cvInteger; + i = val; + } + + TORQUE_FORCEINLINE void setString(const char* val) + { + setString(val, val != NULL ? dStrlen(val) : 0); + } + + TORQUE_FORCEINLINE void setString(const char* val, S32 len) + { + if (len == 0) + { + setEmptyString(); + return; + } + + cleanupData(); + + type = ConsoleValueType::cvString; + + s = (char*)dMalloc(static_cast(len) + 1); + s[len] = '\0'; + dStrcpy(s, val, static_cast(len) + 1); + } + + TORQUE_FORCEINLINE void setStringRef(const char* ref, S32 len) + { + cleanupData(); + type = ConsoleValueType::cvString; + s = const_cast(ref); + } + + TORQUE_FORCEINLINE void setBool(const bool val) + { + cleanupData(); + type = ConsoleValueType::cvInteger; + i = (int)val; + } + + TORQUE_FORCEINLINE void setStringTableEntry(StringTableEntry val) + { + cleanupData(); + type = ConsoleValueType::cvSTEntry; + s = const_cast(val); + } + + TORQUE_FORCEINLINE void setEmptyString() + { + setStringTableEntry(StringTable->EmptyString()); + } + + TORQUE_FORCEINLINE void setConsoleData(S32 consoleType, void* dataPtr, const EnumTable* enumTable) + { + cleanupData(); + type = ConsoleValueType::cvSTEntry; + ct = new ConsoleValueConsoleType{ dataPtr, const_cast(enumTable) }; + } + + TORQUE_FORCEINLINE S32 getType() const + { + 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; + } + + TORQUE_FORCEINLINE void setFastFloat(F64 flt) + { + type = ConsoleValueType::cvFloat; + f = flt; + } + + TORQUE_FORCEINLINE F64 getFastFloat() const + { + return f; + } + + TORQUE_FORCEINLINE void setFastInt(S64 flt) + { + type = ConsoleValueType::cvInteger; + i = flt; + } + + TORQUE_FORCEINLINE S64 getFastInt() const + { + return i; + } + + static void init(); + static void resetConversionBuffer(); }; -// Overrides to allow ConsoleValueRefs to be directly converted to S32&F32 - -inline S32 dAtoi(ConsoleValueRef &ref) -{ - return ref.getSignedIntValue(); -} - -inline F32 dAtof(ConsoleValueRef &ref) -{ - return ref.getFloatValue(); -} - -inline bool dAtob(ConsoleValue &ref) -{ - return ref.getBoolValue(); -} - - // Transparently converts ConsoleValue[] to const char** -class StringStackWrapper +class ConsoleValueToStringArrayWrapper { public: const char **argv; - int argc; + S32 argc; - StringStackWrapper(int targc, ConsoleValueRef targv[]); - ~StringStackWrapper(); + ConsoleValueToStringArrayWrapper(int targc, ConsoleValue* targv); + ~ConsoleValueToStringArrayWrapper(); - const char* operator[](int idx) { return argv[idx]; } + const char* operator[](S32 idx) { return argv[idx]; } operator const char**() { return argv; } - int count() { return argc; } + S32 count() { return argc; } }; // Transparently converts const char** to ConsoleValue -class StringStackConsoleWrapper +class StringArrayToConsoleValueWrapper { public: - ConsoleValue *argvValue; - ConsoleValueRef *argv; - int argc; + ConsoleValue *argv; + S32 argc; - StringStackConsoleWrapper(int targc, const char **targv); - ~StringStackConsoleWrapper(); + StringArrayToConsoleValueWrapper(int targc, const char **targv); + ~StringArrayToConsoleValueWrapper(); - ConsoleValueRef& operator[](int idx) { return argv[idx]; } - operator ConsoleValueRef*() { return argv; } + ConsoleValue& operator[](int idx) { return argv[idx]; } + operator ConsoleValue*() { return argv; } - int count() { return argc; } + S32 count() { return argc; } }; /// @defgroup console_callbacks Scripting Engine Callbacks @@ -319,11 +445,11 @@ public: /// @{ /// -typedef const char * (*StringCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); -typedef S32(*IntCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); -typedef F32(*FloatCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); -typedef void(*VoidCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); // We have it return a value so things don't break.. -typedef bool(*BoolCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); +typedef const char * (*StringCallback)(SimObject *obj, S32 argc, ConsoleValue argv[]); +typedef S32(*IntCallback)(SimObject *obj, S32 argc, ConsoleValue argv[]); +typedef F32(*FloatCallback)(SimObject *obj, S32 argc, ConsoleValue argv[]); +typedef void(*VoidCallback)(SimObject *obj, S32 argc, ConsoleValue argv[]); // We have it return a value so things don't break.. +typedef bool(*BoolCallback)(SimObject *obj, S32 argc, ConsoleValue argv[]); typedef void(*ConsumerCallback)(U32 level, const char *consoleLine); /// @} @@ -376,7 +502,8 @@ namespace Con /// 10/14/14 - jamesu - 47->48 Added opcodes to reduce reliance on strings in function calls /// 10/07/17 - JTH - 48->49 Added opcode for function pointers and revamp of interpreter /// from switch to function calls. - DSOVersion = 49, + /// 09/04/21 - JTH - 49->50 Rewrite of interpreter + DSOVersion = 50, MaxLineLength = 512, ///< Maximum length of a line of console input. MaxDataTypes = 256 ///< Maximum number of registered data types. @@ -786,8 +913,8 @@ namespace Con /// char* result = execute(2, argv); /// @endcode /// NOTE: this function restores the console stack on return. - ConsoleValueRef execute(S32 argc, const char* argv[]); - ConsoleValueRef execute(S32 argc, ConsoleValueRef argv[]); + ConsoleValue execute(S32 argc, const char* argv[]); + ConsoleValue execute(S32 argc, ConsoleValue argv[]); /// Call a Torque Script member function of a SimObject from C/C++ code. /// @param object Object on which to execute the method call. @@ -802,8 +929,8 @@ namespace Con /// char* result = execute(mysimobject, 3, argv); /// @endcode /// NOTE: this function restores the console stack on return. - ConsoleValueRef execute(SimObject *object, S32 argc, const char* argv[], bool thisCallOnly = false); - ConsoleValueRef execute(SimObject *object, S32 argc, ConsoleValueRef argv[], bool thisCallOnly = false); + ConsoleValue execute(SimObject *object, S32 argc, const char* argv[], bool thisCallOnly = false); + ConsoleValue execute(SimObject *object, S32 argc, ConsoleValue argv[], bool thisCallOnly = false); /// Executes a script file and compiles it for use in script. /// @@ -821,13 +948,13 @@ namespace Con /// @param echo Should we echo the string to the console? /// @param fileName Indicate what file this code is coming from; used in error reporting and such. /// NOTE: This function restores the console stack on return. - ConsoleValueRef evaluate(const char* string, bool echo = false, const char *fileName = NULL); + ConsoleValue evaluate(const char* string, bool echo = false, const char *fileName = NULL); /// Evaluate an arbitrary line of script. /// /// This wraps dVsprintf(), so you can substitute parameters into the code being executed. /// NOTE: This function restores the console stack on return. - ConsoleValueRef evaluatef(const char* string, ...); + ConsoleValue evaluatef(const char* string, ...); /// @} @@ -915,10 +1042,10 @@ namespace Con /// @see _EngineConsoleExecCallbackHelper /// template - ConsoleValueRef executef(R r, ArgTs ...argTs) + ConsoleValue executef(R r, ArgTs ...argTs) { _EngineConsoleExecCallbackHelper callback(r); - return callback.template call(argTs...); + return std::move(callback.template call(argTs...)); } /// } }; @@ -1192,9 +1319,9 @@ public: static ConsoleConstructor cfg_ConsoleFunctionGroup_##groupName##_GroupBegin(NULL,#groupName,usage) # define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \ - returnType ctf_##name(SimObject *, S32, ConsoleValueRef *argv); \ + returnType ctf_##name(SimObject *, S32, ConsoleValue *argv); \ ConsoleConstructor cc_##name##_obj(NULL,#name,ctf_##name,usage1,minArgs,maxArgs, true); \ - returnType ctf_##name(SimObject *, S32 argc, ConsoleValueRef *argv) + returnType ctf_##name(SimObject *, S32 argc, ConsoleValue *argv) # define ConsoleFunctionGroupEnd(groupName) \ static ConsoleConstructor cfg_##groupName##_GroupEnd(NULL,#groupName,NULL) @@ -1227,23 +1354,23 @@ public: // These are identical to what's above, we just want to null out the usage strings. # define ConsoleFunction(name,returnType,minArgs,maxArgs,usage1) \ - static returnType c##name(SimObject *, S32, ConsoleValueRef*); \ + static returnType c##name(SimObject *, S32, ConsoleValue*); \ static ConsoleConstructor g##name##obj(NULL,#name,c##name,"",minArgs,maxArgs);\ - static returnType c##name(SimObject *, S32 argc, ConsoleValueRef *argv) + static returnType c##name(SimObject *, S32 argc, ConsoleValue *argv) # define ConsoleToolFunction(name,returnType,minArgs,maxArgs,usage1) \ - static returnType c##name(SimObject *, S32, ConsoleValueRef*); \ + static returnType c##name(SimObject *, S32, ConsoleValue*); \ static ConsoleConstructor g##name##obj(NULL,#name,c##name,"",minArgs,maxArgs, true);\ - static returnType c##name(SimObject *, S32 argc, ConsoleValueRef *argv) + static returnType c##name(SimObject *, S32 argc, ConsoleValue *argv) # define ConsoleMethod(className,name,returnType,minArgs,maxArgs,usage1) \ - static inline returnType c##className##name(className *, S32, ConsoleValueRef *argv); \ - static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValueRef *argv) { \ + static inline returnType c##className##name(className *, S32, ConsoleValue *argv); \ + static returnType c##className##name##caster(SimObject *object, S32 argc, ConsoleValue *argv) { \ conmethod_return_##returnType ) c##className##name(static_cast(object),argc,argv); \ }; \ static ConsoleConstructor \ className##name##obj(#className,#name,c##className##name##caster,"",minArgs,maxArgs); \ - static inline returnType c##className##name(className *object, S32 argc, ConsoleValueRef *argv) + static inline returnType c##className##name(className *object, S32 argc, ConsoleValue *argv) #define ConsoleDoc( text ) diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index 88bbc14e3..9a57c31c1 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -2286,7 +2286,8 @@ DefineEngineStringlyVariadicFunction( call, const char *, 2, 0, "( string functi "@endtsexample\n\n" "@ingroup Scripting" ) { - return Con::execute( argc - 1, argv + 1 ); + ConsoleValue returnValue = Con::execute(argc - 1, argv + 1); + return Con::getReturnBuffer(returnValue.getString()); } //----------------------------------------------------------------------------- @@ -2410,7 +2411,9 @@ DefineEngineFunction( exec, bool, ( const char* fileName, bool noCalls, bool jou DefineEngineFunction( eval, const char*, ( const char* consoleString ), , "eval(consoleString)" ) { - return Con::evaluate(consoleString, false, NULL); + ConsoleValue returnValue = Con::evaluate(consoleString, false, NULL); + + return Con::getReturnBuffer(returnValue.getString()); } DefineEngineFunction( getVariable, const char*, ( const char* varName ), , "(string varName)\n" diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index 1184716ba..82f92ca3b 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -183,13 +183,13 @@ void Dictionary::exportVariables(const char *varString, const char *fileName, bo for (s = sortList.begin(); s != sortList.end(); s++) { - switch ((*s)->value.type) + switch ((*s)->type) { - case ConsoleValue::TypeInternalInt: - dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->value.ival, cat); + case Entry::TypeInternalInt: + dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->ival, cat); break; - case ConsoleValue::TypeInternalFloat: - dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->value.fval, cat); + case Entry::TypeInternalFloat: + dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->fval, cat); break; default: expandEscape(expandBuffer, (*s)->getStringValue()); @@ -243,13 +243,11 @@ void Dictionary::exportVariables(const char *varString, Vector *names, V if (values) { - switch ((*s)->value.type) + switch ((*s)->type) { - case ConsoleValue::TypeInternalInt: - values->push_back(String::ToString((*s)->value.ival)); - break; - case ConsoleValue::TypeInternalFloat: - values->push_back(String::ToString((*s)->value.fval)); + case ConsoleValueType::cvInteger: + case ConsoleValueType::cvFloat: + values->push_back(String((*s)->getStringValue())); break; default: expandEscape(expandBuffer, (*s)->getStringValue()); @@ -470,25 +468,94 @@ char *typeValueEmpty = ""; Dictionary::Entry::Entry(StringTableEntry in_name) { name = in_name; - value.type = ConsoleValue::TypeInternalString; + type = TypeInternalString; notify = NULL; nextEntry = NULL; mUsage = NULL; mIsConstant = false; mNext = NULL; - // NOTE: This is data inside a nameless - // union, so we don't need to init the rest. - value.init(); + + ival = 0; + fval = 0; + sval = typeValueEmpty; + bufferLen = 0; } Dictionary::Entry::~Entry() { - value.cleanup(); + reset(); +} +void Dictionary::Entry::reset() +{ + name = NULL; + if (type <= TypeInternalString && sval != typeValueEmpty) + dFree(sval); if (notify) delete notify; } +void Dictionary::Entry::setStringValue(const char* value) +{ + if (mIsConstant) + { + Con::errorf("Cannot assign value to constant '%s'.", name); + return; + } + + if (type <= TypeInternalString) + { + // Let's not remove empty-string-valued global vars from the dict. + // If we remove them, then they won't be exported, and sometimes + // it could be necessary to export such a global. There are very + // few empty-string global vars so there's no performance-related + // need to remove them from the dict. + /* + if(!value[0] && name[0] == '$') + { + gEvalState.globalVars.remove(this); + return; + } + */ + + U32 stringLen = dStrlen(value); + + // If it's longer than 256 bytes, it's certainly not a number. + // + // (This decision may come back to haunt you. Shame on you if it + // does.) + if (stringLen < 256) + { + fval = dAtof(value); + ival = dAtoi(value); + } + else + { + fval = 0.f; + ival = 0; + } + + type = TypeInternalString; + + // may as well pad to the next cache line + U32 newLen = ((stringLen + 1) + 15) & ~15; + + if (sval == typeValueEmpty) + sval = (char*)dMalloc(newLen); + else if (newLen > bufferLen) + sval = (char*)dRealloc(sval, newLen); + + bufferLen = newLen; + dStrcpy(sval, value, newLen); + } + else + Con::setData(type, dataPtr, 0, 1, &value, enumTable); + + // Fire off the notification if we have one. + if (notify) + notify->trigger(); +} + const char *Dictionary::getVariable(StringTableEntry name, bool *entValid) { Entry *ent = lookup(name); @@ -508,150 +575,6 @@ const char *Dictionary::getVariable(StringTableEntry name, bool *entValid) return ""; } -void ConsoleValue::setStringValue(const char * value) -{ - if (value == NULL) value = typeValueEmpty; - - if (type <= ConsoleValue::TypeInternalString) - { - // Let's not remove empty-string-valued global vars from the dict. - // If we remove them, then they won't be exported, and sometimes - // it could be necessary to export such a global. There are very - // few empty-string global vars so there's no performance-related - // need to remove them from the dict. - /* - if(!value[0] && name[0] == '$') - { - gEvalState.globalVars.remove(this); - return; - } - */ - if (value == typeValueEmpty) - { - if (bufferLen > 0) - { - dFree(sval); - bufferLen = 0; - } - - sval = typeValueEmpty; - fval = 0.f; - ival = 0; - type = TypeInternalString; - return; - } - - U32 stringLen = dStrlen(value); - - // If it's longer than 256 bytes, it's certainly not a number. - // - // (This decision may come back to haunt you. Shame on you if it - // does.) - if (stringLen < 256) - { - fval = dAtof(value); - ival = dAtoi(value); - } - else - { - fval = 0.f; - ival = 0; - } - - // may as well pad to the next cache line - U32 newLen = ((stringLen + 1) + 15) & ~15; - - if (bufferLen == 0) - sval = (char *)dMalloc(newLen); - else if (newLen > bufferLen) - sval = (char *)dRealloc(sval, newLen); - - type = TypeInternalString; - - bufferLen = newLen; - dStrcpy(sval, value, newLen); - } - else - Con::setData(type, dataPtr, 0, 1, &value, enumTable); -} - - -void ConsoleValue::setStackStringValue(const char *value) -{ - if (value == NULL) value = typeValueEmpty; - - if (type <= ConsoleValue::TypeInternalString) - { - // sval might still be temporarily present so we need to check and free it - if (bufferLen > 0) - { - dFree(sval); - bufferLen = 0; - } - - if (value == typeValueEmpty) - { - sval = typeValueEmpty; - fval = 0.f; - ival = 0; - type = TypeInternalString; - return; - } - - U32 stringLen = dStrlen(value); - if (stringLen < 256) - { - fval = dAtof(value); - ival = dAtoi(value); - } - else - { - fval = 0.f; - ival = 0; - } - - type = TypeInternalStackString; - sval = (char*)value; - bufferLen = 0; - } - else - Con::setData(type, dataPtr, 0, 1, &value, enumTable); -} - -void ConsoleValue::setStringStackPtrValue(StringStackPtr ptrValue) -{ - if (type <= ConsoleValue::TypeInternalString) - { - const char *value = StringStackPtrRef(ptrValue).getPtr(&STR); - if (bufferLen > 0) - { - dFree(sval); - bufferLen = 0; - } - - U32 stringLen = dStrlen(value); - if (stringLen < 256) - { - fval = dAtof(value); - ival = dAtoi(value); - } - else - { - fval = 0.f; - ival = 0; - } - - type = TypeInternalStringStackPtr; - sval = (char*)(value - STR.mBuffer); - bufferLen = 0; - } - else - { - const char *value = StringStackPtrRef(ptrValue).getPtr(&STR); - Con::setData(type, dataPtr, 0, 1, &value, enumTable); - } -} - S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid) { Entry *ent = lookup(name); @@ -708,19 +631,17 @@ 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); + if (ent->type <= Entry::TypeInternalString && ent->sval != typeValueEmpty) + dFree(ent->sval); - ent->value.type = type; - ent->value.dataPtr = dataPtr; ent->mUsage = usage; + ent->type = type; + ent->dataPtr = dataPtr; // Fetch enum table, if any. - ConsoleBaseType* conType = ConsoleBaseType::getType(type); AssertFatal(conType, "Dictionary::addVariable - invalid console type"); - ent->value.enumTable = conType->getEnumTable(); + ent->enumTable = conType->getEnumTable(); return ent; } @@ -760,7 +681,7 @@ void Dictionary::validate() "Dictionary::validate() - Dictionary not owner of own hashtable!"); } -void ExprEvalState::pushFrame(StringTableEntry frameName, Namespace *ns) +void ExprEvalState::pushFrame(StringTableEntry frameName, Namespace *ns, S32 registerCount) { #ifdef DEBUG_SPEW validate(); @@ -789,6 +710,12 @@ void ExprEvalState::pushFrame(StringTableEntry frameName, Namespace *ns) AssertFatal(!newFrame.getCount(), "ExprEvalState::pushFrame - Dictionary not empty!"); + ConsoleValue* consoleValArray = new ConsoleValue[registerCount](); + localStack.push_back(ConsoleValueFrame(consoleValArray, false)); + currentRegisterArray = &localStack.last(); + + AssertFatal(mStackDepth == localStack.size(), avar("Stack sizes do not match. mStackDepth = %d, localStack = %d", mStackDepth, localStack.size())); + #ifdef DEBUG_SPEW validate(); #endif @@ -809,6 +736,15 @@ void ExprEvalState::popFrame() stack[mStackDepth]->reset(); currentVariable = NULL; + const ConsoleValueFrame& frame = localStack.last(); + localStack.pop_back(); + if (!frame.isReference) + delete[] frame.values; + + currentRegisterArray = localStack.size() ? &localStack.last() : NULL; + + AssertFatal(mStackDepth == localStack.size(), avar("Stack sizes do not match. mStackDepth = %d, localStack = %d", mStackDepth, localStack.size())); + #ifdef DEBUG_SPEW validate(); #endif @@ -816,7 +752,7 @@ void ExprEvalState::popFrame() void ExprEvalState::pushFrameRef(S32 stackIndex) { - AssertFatal(stackIndex >= 0 && stackIndex < stack.size(), "You must be asking for a valid frame!"); + AssertFatal(stackIndex >= 0 && stackIndex < mStackDepth, "You must be asking for a valid frame!"); #ifdef DEBUG_SPEW validate(); @@ -840,11 +776,30 @@ void ExprEvalState::pushFrameRef(S32 stackIndex) mStackDepth++; currentVariable = NULL; + ConsoleValue* values = localStack[stackIndex].values; + localStack.push_back(ConsoleValueFrame(values, true)); + currentRegisterArray = &localStack.last(); + + AssertFatal(mStackDepth == localStack.size(), avar("Stack sizes do not match. mStackDepth = %d, localStack = %d", mStackDepth, localStack.size())); + #ifdef DEBUG_SPEW validate(); #endif } +void ExprEvalState::pushDebugFrame(S32 stackIndex) +{ + pushFrameRef(stackIndex); + + Dictionary& newFrame = *(stack[mStackDepth - 1]); + + // debugger needs to know this info... + newFrame.scopeName = stack[stackIndex]->scopeName; + newFrame.scopeNamespace = stack[stackIndex]->scopeNamespace; + newFrame.code = stack[stackIndex]->code; + newFrame.ip = stack[stackIndex]->ip; +} + ExprEvalState::ExprEvalState() { VECTOR_SET_ASSOCIATION(stack); @@ -1413,7 +1368,7 @@ void Namespace::markGroup(const char* name, const char* usage) extern S32 executeBlock(StmtNode *block, ExprEvalState *state); -ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprEvalState *state) +ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, ExprEvalState *state) { STR.clearFunctionOffset(); @@ -1421,11 +1376,11 @@ ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprE { if (mFunctionOffset) { - return mCode->exec(mFunctionOffset, argv[0], mNamespace, argc, argv, false, mPackage); + return std::move(mCode->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage)); } else { - return ConsoleValueRef(); + return std::move(ConsoleValue()); } } @@ -1435,7 +1390,7 @@ ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprE if (mToolOnly && !Con::isCurrentScriptToolScript()) { Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } #endif @@ -1443,25 +1398,33 @@ ConsoleValueRef Namespace::Entry::execute(S32 argc, ConsoleValueRef *argv, ExprE { Con::warnf(ConsoleLogEntry::Script, "%s::%s - wrong number of arguments.", mNamespace->mName, mFunctionName); Con::warnf(ConsoleLogEntry::Script, "usage: %s", mUsage); - return ConsoleValueRef(); + return std::move(ConsoleValue()); } + ConsoleValue result; switch (mType) { case StringCallbackType: - return ConsoleValueRef::fromValue(CSTK.pushStackString(cb.mStringCallbackFunc(state->thisObject, argc, argv))); + { + const char* str = cb.mStringCallbackFunc(state->thisObject, argc, argv); + result.setString(str); + break; + } case IntCallbackType: - return ConsoleValueRef::fromValue(CSTK.pushUINT((U32)cb.mIntCallbackFunc(state->thisObject, argc, argv))); + result.setInt(cb.mIntCallbackFunc(state->thisObject, argc, argv)); + break; case FloatCallbackType: - return ConsoleValueRef::fromValue(CSTK.pushFLT((U32)cb.mFloatCallbackFunc(state->thisObject, argc, argv))); + result.setFloat(cb.mFloatCallbackFunc(state->thisObject, argc, argv)); + break; case VoidCallbackType: cb.mVoidCallbackFunc(state->thisObject, argc, argv); - return ConsoleValueRef(); + break; case BoolCallbackType: - return ConsoleValueRef::fromValue(CSTK.pushUINT((U32)cb.mBoolCallbackFunc(state->thisObject, argc, argv))); + result.setBool(cb.mBoolCallbackFunc(state->thisObject, argc, argv)); + break; } - return ConsoleValueRef(); + return std::move(result); } //----------------------------------------------------------------------------- diff --git a/Engine/source/console/consoleInternal.h b/Engine/source/console/consoleInternal.h index 129da9dfb..758fd1327 100644 --- a/Engine/source/console/consoleInternal.h +++ b/Engine/source/console/consoleInternal.h @@ -150,7 +150,7 @@ public: void clear(); /// - ConsoleValueRef execute(S32 argc, ConsoleValueRef* argv, ExprEvalState* state); + ConsoleValue execute(S32 argc, ConsoleValue* argv, ExprEvalState* state); /// Return a one-line documentation text string for the function. String getBriefDescription(String* outRemainingDocText = NULL) const; @@ -274,17 +274,24 @@ public: typedef VectorPtr::iterator NamespaceEntryListIterator; - - class Dictionary { public: struct Entry { + friend class Dictionary; + + enum + { + TypeInternalInt = -3, + TypeInternalFloat = -2, + TypeInternalString = -1, + }; + StringTableEntry name; - ConsoleValue value; Entry *nextEntry; + S32 type; typedef Signal NotifySignal; @@ -298,16 +305,56 @@ public: /// Whether this is a constant that cannot be assigned to. bool mIsConstant; + protected: + + // NOTE: This is protected to ensure no one outside + // of this structure is messing with it. + +#pragma warning( push ) +#pragma warning( disable : 4201 ) // warning C4201: nonstandard extension used : nameless struct/union + + // An variable is either a real dynamic type or + // its one exposed from C++ using a data pointer. + // + // We use this nameless union and struct setup + // to optimize the memory usage. + union + { + struct + { + char* sval; + U32 ival; // doubles as strlen when type is TypeInternalString + F32 fval; + U32 bufferLen; + }; + + struct + { + /// The real data pointer. + void* dataPtr; + + /// The enum lookup table for enumerated types. + const EnumTable* enumTable; + }; + }; + +#pragma warning( pop ) // C4201 + public: Entry() { name = NULL; + type = TypeInternalString; notify = NULL; nextEntry = NULL; mUsage = NULL; mIsConstant = false; mNext = NULL; - value.init(); + + ival = 0; + fval = 0; + sval = typeValueEmpty; + bufferLen = 0; } Entry(StringTableEntry name); @@ -315,26 +362,34 @@ public: Entry *mNext; - void reset() { - name = NULL; - value.cleanup(); - if (notify) - delete notify; - } + void reset(); inline U32 getIntValue() { - return value.getIntValue(); + if (type <= TypeInternalString) + return ival; + else + return dAtoi(Con::getData(type, dataPtr, 0, enumTable)); } inline F32 getFloatValue() { - return value.getFloatValue(); + if (type <= TypeInternalString) + return fval; + else + return dAtof(Con::getData(type, dataPtr, 0, enumTable)); } inline const char *getStringValue() { - return value.getStringValue(); + if (type == TypeInternalString) + return sval; + if (type == TypeInternalFloat) + return Con::getData(TypeF32, &fval, 0); + else if (type == TypeInternalInt) + return Con::getData(TypeS32, &ival, 0); + else + return Con::getData(type, dataPtr, 0, enumTable); } void setIntValue(U32 val) @@ -345,7 +400,22 @@ public: return; } - value.setIntValue(val); + if (type <= TypeInternalString) + { + fval = (F32)val; + ival = val; + if (sval != typeValueEmpty) + { + dFree(sval); + sval = typeValueEmpty; + } + type = TypeInternalInt; + } + else + { + const char* dptr = Con::getData(TypeS32, &val, 0); + Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); + } // Fire off the notification if we have one. if (notify) @@ -360,44 +430,29 @@ public: return; } - value.setFloatValue(val); - - // Fire off the notification if we have one. - if (notify) - notify->trigger(); - } - - void setStringStackPtrValue(StringStackPtr newValue) - { - if (mIsConstant) + if (type <= TypeInternalString) { - Con::errorf("Cannot assign value to constant '%s'.", name); - return; + fval = val; + ival = static_cast(val); + if (sval != typeValueEmpty) + { + dFree(sval); + sval = typeValueEmpty; + } + type = TypeInternalFloat; + } + else + { + const char* dptr = Con::getData(TypeF32, &val, 0); + Con::setData(type, dataPtr, 0, 1, &dptr, enumTable); } - value.setStringStackPtrValue(newValue); - - // Fire off the notification if we have one. if (notify) notify->trigger(); } - void setStringValue(const char *newValue) - { - if (mIsConstant) - { - Con::errorf("Cannot assign value to constant '%s'.", name); - return; - } - - value.setStringValue(newValue); - - - // Fire off the notification if we have one. - if (notify) - notify->trigger(); - } + void setStringValue(const char* value); }; struct HashTableData @@ -471,6 +526,21 @@ public: void validate(); }; +struct ConsoleValueFrame +{ + ConsoleValue* values; + bool isReference; + + ConsoleValueFrame() : values(NULL), isReference(false) + {} + + ConsoleValueFrame(ConsoleValue* vals, bool isRef) + { + values = vals; + isReference = isRef; + } +}; + class ExprEvalState { public: @@ -499,6 +569,11 @@ public: /// an interior pointer that will become invalid when the object changes address. Vector< Dictionary* > stack; + S32 getTopOfStack() { return (S32)mStackDepth; } + + Vector< ConsoleValueFrame > localStack; + ConsoleValueFrame* currentRegisterArray; // contains array at to top of localStack + /// Dictionary globalVars; @@ -511,16 +586,56 @@ public: void setIntVariable(S32 val); void setFloatVariable(F64 val); void setStringVariable(const char *str); - void setStringStackPtrVariable(StringStackPtr str); - void setCopyVariable(); - void pushFrame(StringTableEntry frameName, Namespace *ns); + TORQUE_FORCEINLINE S32 getLocalIntVariable(S32 reg) + { + return currentRegisterArray->values[reg].getInt(); + } + + TORQUE_FORCEINLINE F64 getLocalFloatVariable(S32 reg) + { + return currentRegisterArray->values[reg].getFloat(); + } + + TORQUE_FORCEINLINE const char* getLocalStringVariable(S32 reg) + { + return currentRegisterArray->values[reg].getString(); + } + + TORQUE_FORCEINLINE void setLocalIntVariable(S32 reg, S64 val) + { + currentRegisterArray->values[reg].setInt(val); + } + + TORQUE_FORCEINLINE void setLocalFloatVariable(S32 reg, F64 val) + { + currentRegisterArray->values[reg].setFloat(val); + } + + TORQUE_FORCEINLINE void setLocalStringVariable(S32 reg, const char* val, S32 len) + { + currentRegisterArray->values[reg].setString(val, len); + } + + TORQUE_FORCEINLINE void setLocalStringTableEntryVariable(S32 reg, StringTableEntry val) + { + currentRegisterArray->values[reg].setStringTableEntry(val); + } + + TORQUE_FORCEINLINE void moveConsoleValue(S32 reg, ConsoleValue val) + { + currentRegisterArray->values[reg] = std::move(val); + } + + void pushFrame(StringTableEntry frameName, Namespace *ns, S32 regCount); void popFrame(); /// Puts a reference to an existing stack frame /// on the top of the stack. void pushFrameRef(S32 stackIndex); + void pushDebugFrame(S32 stackIndex); + U32 getStackDepth() const { return mStackDepth; @@ -531,6 +646,11 @@ public: return *(stack[mStackDepth - 1]); } + Dictionary& getFrameAt(S32 depth) + { + return *(stack[depth]); + } + /// @} /// Run integrity checks for debugging. diff --git a/Engine/source/console/consoleLogger.cpp b/Engine/source/console/consoleLogger.cpp index fc2095eae..d68cdb6c0 100644 --- a/Engine/source/console/consoleLogger.cpp +++ b/Engine/source/console/consoleLogger.cpp @@ -79,18 +79,18 @@ void ConsoleLogger::initPersistFields() //----------------------------------------------------------------------------- -bool ConsoleLogger::processArguments( S32 argc, ConsoleValueRef *argv ) +bool ConsoleLogger::processArguments( S32 argc, ConsoleValue *argv ) { if( argc == 0 ) return false; bool append = false; - if( argc == 2 ) - append = dAtob( argv[1] ); + if (argc == 2) + append = argv[1].getBool(); mAppend = append; - mFilename = StringTable->insert( argv[0] ); + mFilename = StringTable->insert( argv[0].getString() ); if( init() ) { diff --git a/Engine/source/console/consoleLogger.h b/Engine/source/console/consoleLogger.h index 901f45b17..e969f3ac1 100644 --- a/Engine/source/console/consoleLogger.h +++ b/Engine/source/console/consoleLogger.h @@ -81,7 +81,7 @@ class ConsoleLogger : public SimObject /// // Example script constructor usage. /// %obj = new ConsoleLogger( objName, logFileName, [append = false] ); /// @endcode - bool processArguments( S32 argc, ConsoleValueRef *argv ); + bool processArguments( S32 argc, ConsoleValue *argv ); /// Default constructor, make sure to initalize ConsoleLogger(); diff --git a/Engine/source/console/consoleValueStack.h b/Engine/source/console/consoleValueStack.h new file mode 100644 index 000000000..8b44a652c --- /dev/null +++ b/Engine/source/console/consoleValueStack.h @@ -0,0 +1,109 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +#ifndef _CONSOLE_CONSOLE_VALUE_STACK_H_ +#define _CONSOLE_CONSOLE_VALUE_STACK_H_ + +template +class ConsoleValueStack +{ + constexpr static S32 allocatorSize = sizeof(ConsoleValue) * StackSize; + + struct Frame + { + ConsoleValue* values; + S32 count; + S32 internalCounter; + }; + + Vector stack; + char* memory; + S32 sp; + + TORQUE_FORCEINLINE Frame alloc(S32 count) + { + AssertFatal(sp + count * sizeof(ConsoleValue) < allocatorSize, "ConsoleValueStack overflow"); + + ConsoleValue* ret = reinterpret_cast(memory + sp); + sp += count * sizeof(ConsoleValue); + + return { ret, count, 1 }; + } + + TORQUE_FORCEINLINE void deAlloc(S32 count) + { + sp -= count * sizeof(ConsoleValue); + AssertFatal(sp >= 0, "Popped ConsoleValueStack too far, underflow"); + } + +public: + ConsoleValueStack() + { + memory = (char*)dMalloc(allocatorSize); + for (S32 i = 0; i < allocatorSize; i += sizeof(ConsoleValue)) + { + constructInPlace(reinterpret_cast(memory + i)); + } + sp = 0; + } + + ~ConsoleValueStack() + { + dFree(memory); + } + + TORQUE_FORCEINLINE void pushFrame(S32 count) + { + AssertISV(count >= 0, "Must be >= 0 when pushing stack frame"); + + // +1 for function name in argv[0] + const Frame& frame = alloc(count + 1); + stack.push_back(frame); + } + + TORQUE_FORCEINLINE void popFrame() + { + AssertISV(stack.size() > 0, "Stack Underflow"); + + deAlloc(stack.last().count); + stack.pop_back(); + } + + TORQUE_FORCEINLINE void push(ConsoleValue&& val) + { + Frame& frame = stack.last(); + frame.values[frame.internalCounter++] = std::move(val); + } + + TORQUE_FORCEINLINE void argvc(StringTableEntry fn, S32& argc, ConsoleValue** argv) + { + Frame& frame = stack.last(); + argc = frame.count; + + // First param is always function name + frame.values[0].setStringTableEntry(fn); + *argv = frame.values; + } +}; + +#endif diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index aa8762f4b..0a6af3dcd 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -148,55 +148,45 @@ inline const char* EngineMarshallData( U32 value ) /// Marshal data from native into client form stored directly in /// client function invocation vector. template< typename T > -inline void EngineMarshallData( const T& arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( const T& arg, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = castConsoleTypeToString( arg ); - argc ++; + const char* str = castConsoleTypeToString(arg);; + argv[ argc++ ].setString(str); } -inline void EngineMarshallData( bool arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( bool arg, S32& argc, ConsoleValue *argv ) { - if( arg ) - argv[ argc ] = 1; - else - argv[ argc ] = 0; - argc ++; + argv[ argc++ ].setBool(arg); } -inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( S32 arg, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = arg; - argc ++; + argv[ argc++ ].setInt(arg); } -inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( U32 arg, S32& argc, ConsoleValue *argv ) { EngineMarshallData( S32( arg ), argc, argv ); } -inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( F32 arg, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = arg; - argc ++; + argv[ argc++ ].setFloat(arg); } -inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( const char* arg, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = arg; - argc ++; + argv[ argc++ ].setString(arg); } -inline void EngineMarshallData( char* arg, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( char* arg, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = arg; - argc ++; + argv[ argc++ ].setString(arg); } template< typename T > -inline void EngineMarshallData( T* object, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( T* object, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = object ? object->getId() : 0; - argc ++; + argv[ argc++ ].setInt(object ? object->getId() : 0); } template< typename T > -inline void EngineMarshallData( const T* object, S32& argc, ConsoleValueRef *argv ) +inline void EngineMarshallData( const T* object, S32& argc, ConsoleValue *argv ) { - argv[ argc ] = object ? object->getId() : 0; - argc ++; + argv[ argc++ ].setInt(object ? object->getId() : 0); } /// Unmarshal data from client form to engine form. @@ -216,9 +206,9 @@ struct EngineUnmarshallData template<> struct EngineUnmarshallData< S32 > { - S32 operator()( ConsoleValueRef &ref ) const + S32 operator()( ConsoleValue &ref ) const { - return (S32)ref; + return (S32)ref.getInt(); } S32 operator()( const char* str ) const @@ -229,9 +219,9 @@ struct EngineUnmarshallData< S32 > template<> struct EngineUnmarshallData< U32 > { - U32 operator()( ConsoleValueRef &ref ) const + U32 operator()( ConsoleValue &ref ) const { - return (U32)((S32)ref); + return (U32)ref.getInt(); } U32 operator()( const char* str ) const @@ -242,9 +232,9 @@ struct EngineUnmarshallData< U32 > template<> struct EngineUnmarshallData< F32 > { - F32 operator()( ConsoleValueRef &ref ) const + F32 operator()( ConsoleValue &ref ) const { - return (F32)ref; + return (F32)ref.getFloat(); } F32 operator()( const char* str ) const @@ -255,9 +245,9 @@ struct EngineUnmarshallData< F32 > template<> struct EngineUnmarshallData< U8 > { - U8 operator()( ConsoleValueRef &ref ) const + U8 operator()( ConsoleValue &ref ) const { - return (U8)((S32)ref); + return (U8)((S32)ref.getInt()); } U8 operator()( const char* str ) const @@ -268,9 +258,9 @@ struct EngineUnmarshallData< U8 > template<> struct EngineUnmarshallData< const char* > { - const char* operator()( ConsoleValueRef &ref ) const + const char* operator()( ConsoleValue &ref ) const { - return ref.getStringValue(); + return ref.getString(); } const char* operator()( const char* str ) const @@ -281,9 +271,9 @@ struct EngineUnmarshallData< const char* > template< typename T > struct EngineUnmarshallData< T* > { - T* operator()( ConsoleValueRef &ref ) const + T* operator()( ConsoleValue &ref ) const { - return dynamic_cast< T* >( Sim::findObject( ref.getStringValue() ) ); + return dynamic_cast< T* >( Sim::findObject( ref ) ); } T* operator()( const char* str ) const @@ -294,17 +284,17 @@ struct EngineUnmarshallData< T* > template<> struct EngineUnmarshallData< void > { - void operator()( ConsoleValueRef& ) const {} + void operator()( ConsoleValue& ) const {} void operator()( const char* ) const {} }; template<> -struct EngineUnmarshallData< ConsoleValueRef > +struct EngineUnmarshallData< ConsoleValue > { - ConsoleValueRef operator()( ConsoleValueRef ref ) const + ConsoleValue operator()( ConsoleValue ref ) const { - return ref; + return std::move(ref); } }; @@ -548,7 +538,7 @@ namespace engineAPI{ static const S32 NUM_ARGS = sizeof...(ArgTs) + startArgc; template - static IthArgType getRealArgValue(S32 argc, ConsoleValueRef *argv, const _EngineFunctionDefaultArguments< void(RealArgTs...) >& defaultArgs) + static IthArgType getRealArgValue(S32 argc, ConsoleValue *argv, const _EngineFunctionDefaultArguments< void(RealArgTs...) >& defaultArgs) { if((startArgc + index) < argc) { @@ -559,12 +549,12 @@ namespace engineAPI{ } template - static R dispatchHelper(S32 argc, ConsoleValueRef *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs, Seq){ + static R dispatchHelper(S32 argc, ConsoleValue *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs, Seq){ return fn(SelfType::getRealArgValue(argc, argv, defaultArgs) ...); } template - static R dispatchHelper(S32 argc, ConsoleValueRef *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs, Seq){ + static R dispatchHelper(S32 argc, ConsoleValue *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs, Seq){ return (frame->*fn)(SelfType::getRealArgValue(argc, argv, defaultArgs) ...); } @@ -579,9 +569,9 @@ namespace engineAPI{ } }; - template<> struct MarshallHelpers { - template static void marshallEach(S32 &argc, ConsoleValueRef *argv, const ArgTs& ...args){} - template static void marshallEach(S32 &argc, ConsoleValueRef *argv, const H& head, const Tail& ...tail){ + template<> struct MarshallHelpers { + template static void marshallEach(S32 &argc, ConsoleValue *argv, const ArgTs& ...args){} + template static void marshallEach(S32 &argc, ConsoleValue *argv, const H& head, const Tail& ...tail){ EngineMarshallData(head, argc, argv); marshallEach(argc, argv, tail...); } @@ -604,12 +594,12 @@ public: template using MethodType = typename Helper::template MethodType; static const S32 NUM_ARGS = Helper::NUM_ARGS; - static ReturnType thunk( S32 argc, ConsoleValueRef *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs) + static ReturnType thunk( S32 argc, ConsoleValue *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs) { return _EngineConsoleThunkReturnValue( Helper::dispatchHelper(argc, argv, fn, defaultArgs, SeqType())); } template< typename Frame > - static ReturnType thunk( S32 argc, ConsoleValueRef *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs) + static ReturnType thunk( S32 argc, ConsoleValue *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs) { return _EngineConsoleThunkReturnValue( Helper::dispatchHelper(argc, argv, fn, frame, defaultArgs, SeqType())); } @@ -627,12 +617,12 @@ public: template using MethodType = typename Helper::template MethodType; static const S32 NUM_ARGS = Helper::NUM_ARGS; - static void thunk( S32 argc, ConsoleValueRef *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs) + static void thunk( S32 argc, ConsoleValue *argv, FunctionType fn, const _EngineFunctionDefaultArguments< void(ArgTs...) >& defaultArgs) { Helper::dispatchHelper(argc, argv, fn, defaultArgs, SeqType()); } template< typename Frame > - static void thunk( S32 argc, ConsoleValueRef *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs) + static void thunk( S32 argc, ConsoleValue *argv, MethodType fn, Frame* frame, const _EngineFunctionDefaultArguments< void( typename Frame::ObjectType*, ArgTs...) >& defaultArgs) { Helper::dispatchHelper(argc, argv, fn, frame, defaultArgs, SeqType()); } @@ -705,7 +695,7 @@ public: ( void* ) &fn ## name, \ 0 \ ); \ - static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \ + static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValue *argv ) \ { \ return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \ argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \ @@ -785,7 +775,7 @@ public: ( void* ) &fn ## className ## _ ## name, \ 0 \ ); \ - static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValueRef *argv ) \ + static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject* object, S32 argc, ConsoleValue *argv ) \ { \ _ ## className ## name ## frame frame; \ frame.object = static_cast< className* >( object ); \ @@ -842,7 +832,7 @@ public: ( void* ) &fn ## className ## _ ## name, \ 0 \ ); \ - static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv )\ + static _EngineConsoleThunkType< returnType >::ReturnType _ ## className ## name ## caster( SimObject*, S32 argc, ConsoleValue *argv )\ { \ return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \ argc, argv, &_fn ## className ## name ## impl, _fn ## className ## name ## DefaultArgs \ @@ -859,12 +849,12 @@ public: static inline returnType _fn ## className ## name ## impl args # define DefineEngineStringlyVariadicFunction(name,returnType,minArgs,maxArgs,usage) \ - static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValueRef *argv); \ + static inline returnType _fn ## name ## impl (SimObject *, S32 argc, ConsoleValue *argv); \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ (Vector* vec) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ - StringStackConsoleWrapper args(vec->size(), vec->address()); \ + StringArrayToConsoleValueWrapper args(vec->size(), vec->address()); \ return EngineTypeTraits< returnType >::ReturnValue( \ _fn ## name ## impl(NULL, args.count(), args) \ ); \ @@ -882,20 +872,20 @@ public: 0 \ ); \ ConsoleConstructor cc_##name##_obj(NULL,#name,_fn ## name ## impl,usage,minArgs,maxArgs); \ - returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValueRef *argv) + returnType _fn ## name ## impl(SimObject *, S32 argc, ConsoleValue *argv) # define DefineEngineStringlyVariadicMethod(className, name,returnType,minArgs,maxArgs,usage) \ struct _ ## className ## name ## frame \ { \ typedef className ObjectType; \ className* object; \ - inline returnType _exec (S32 argc, ConsoleValueRef* argv) const; \ + inline returnType _exec (S32 argc, ConsoleValue* argv) const; \ }; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ (className* object, Vector* vec) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ - StringStackConsoleWrapper args(vec->size(), vec->address()); \ + StringArrayToConsoleValueWrapper args(vec->size(), vec->address()); \ _ ## className ## name ## frame frame {}; \ frame.object = static_cast< className* >( object ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -915,14 +905,14 @@ public: ( void* ) &fn ## className ## _ ## name, \ 0 \ ); \ - returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValueRef* argv) { \ + returnType cm_##className##_##name##_caster(SimObject* object, S32 argc, ConsoleValue* argv) { \ AssertFatal( dynamic_cast( object ), "Object passed to " #name " is not a " #className "!" ); \ _ ## className ## name ## frame frame {}; \ frame.object = static_cast< className* >( object ); \ conmethod_return_##returnType ) frame._exec(argc,argv); \ }; \ ConsoleConstructor cc_##className##_##name##_obj(#className,#name,cm_##className##_##name##_caster,usage,minArgs,maxArgs); \ - inline returnType _ ## className ## name ## frame::_exec(S32 argc, ConsoleValueRef *argv) const + inline returnType _ ## className ## name ## frame::_exec(S32 argc, ConsoleValue *argv) const @@ -1167,10 +1157,10 @@ public: S32 mInitialArgc; S32 mArgc; StringTableEntry mCallbackName; - ConsoleValueRef mArgv[ MAX_ARGUMENTS + 2 ]; + ConsoleValue mArgv[ MAX_ARGUMENTS + 2 ]; - ConsoleValueRef _exec(); - ConsoleValueRef _execLater(SimConsoleThreadExecEvent *evt); + ConsoleValue _exec(); + ConsoleValue _execLater(SimConsoleThreadExecEvent *evt); _BaseEngineConsoleCallbackHelper(): mThis(NULL), mInitialArgc(0), mArgc(0), mCallbackName(StringTable->EmptyString()){;} }; @@ -1181,7 +1171,7 @@ public: struct _EngineConsoleCallbackHelper : public _BaseEngineConsoleCallbackHelper { private: - using Helper = engineAPI::detail::MarshallHelpers; + using Helper = engineAPI::detail::MarshallHelpers; public: _EngineConsoleCallbackHelper( StringTableEntry callbackName, SimObject* pThis ) @@ -1197,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...); @@ -1209,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...); @@ -1226,7 +1215,7 @@ public: template struct _EngineConsoleExecCallbackHelper : public _BaseEngineConsoleCallbackHelper { private: - using Helper = engineAPI::detail::MarshallHelpers; + using Helper = engineAPI::detail::MarshallHelpers; public: _EngineConsoleExecCallbackHelper( SimObject* pThis ) @@ -1243,8 +1232,7 @@ public: if (Con::isMainThread()) { ConsoleStackFrameSaver sav; sav.save(); - CSTK.reserveValues(mArgc+sizeof...(ArgTs), mArgv); - mArgv[ 0 ].value->setStackStringValue(simCB); + mArgv[ 0 ].setString(simCB); Helper::marshallEach(mArgc, mArgv, args...); @@ -1255,7 +1243,7 @@ public: SimConsoleThreadExecCallback cb; SimConsoleThreadExecEvent *evt = new SimConsoleThreadExecEvent(mArgc+sizeof...(ArgTs), NULL, true, &cb); evt->populateArgs(mArgv); - mArgv[ 0 ].value->setStackStringValue(simCB); + mArgv[ 0 ].setString(simCB); Helper::marshallEach(mArgc, mArgv, args...); @@ -1270,7 +1258,7 @@ public: template<> struct _EngineConsoleExecCallbackHelper : public _BaseEngineConsoleCallbackHelper { private: - using Helper = engineAPI::detail::MarshallHelpers; + using Helper = engineAPI::detail::MarshallHelpers; public: _EngineConsoleExecCallbackHelper( const char *callbackName ) { @@ -1285,10 +1273,9 @@ 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...); + Helper::marshallEach(mArgc, mArgv, args...); return R( EngineUnmarshallData< R >()( _exec() ) ); } @@ -1297,7 +1284,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...); diff --git a/Engine/source/console/engineDoc.cpp b/Engine/source/console/engineDoc.cpp index cbbc7249d..c471fe820 100644 --- a/Engine/source/console/engineDoc.cpp +++ b/Engine/source/console/engineDoc.cpp @@ -114,7 +114,7 @@ static void dumpVariable( Stream& stream, { // Skip variables defined in script. - if( entry->value.type < 0 ) + if( entry->type <= Dictionary::Entry::TypeInternalString ) 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->type ); if( !type ) { Con::errorf( "Can't find type for variable '%s'", entry->name ); diff --git a/Engine/source/console/optimizer.cpp b/Engine/source/console/optimizer.cpp new file mode 100644 index 000000000..9bfbb09a5 --- /dev/null +++ b/Engine/source/console/optimizer.cpp @@ -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(node)->value; + return (F64)static_cast(node)->value; +} + +static S32 getIntValue(ExprNode* node) +{ + if (node->getExprNodeNameEnum() == NameFloatNode) + return (S32)static_cast(node)->value; + return static_cast(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; +} diff --git a/Engine/source/console/sim.h b/Engine/source/console/sim.h index d43c14b1e..61ff469e0 100644 --- a/Engine/source/console/sim.h +++ b/Engine/source/console/sim.h @@ -125,15 +125,12 @@ namespace Sim SimDataBlockGroup *getDataBlockGroup(); SimGroup* getRootGroup(); - SimObject* findObject(ConsoleValueRef&); SimObject* findObject(SimObjectId); + SimObject* findObject(const ConsoleValue&); + SimObject* findObject(ConsoleValue*); SimObject* findObject(const char* name); SimObject* findObject(const char* fileName, S32 declarationLine); - template inline bool findObject(ConsoleValueRef &ref,T*&t) - { - t = dynamic_cast(findObject(ref)); - return t != NULL; - } + template inline bool findObject(SimObjectId iD,T*&t) { t = dynamic_cast(findObject(iD)); diff --git a/Engine/source/console/simEvents.cpp b/Engine/source/console/simEvents.cpp index ab87f5f0b..f6a044c11 100644 --- a/Engine/source/console/simEvents.cpp +++ b/Engine/source/console/simEvents.cpp @@ -28,30 +28,23 @@ // Stupid globals not declared in a header extern ExprEvalState gEvalState; -SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject) +SimConsoleEvent::SimConsoleEvent(S32 argc, ConsoleValue *argv, bool onObject) { mOnObject = onObject; mArgc = argc; - mArgv = new ConsoleValueRef[argc]; + mArgv = new ConsoleValue[argc](); for (int i=0; itype = ConsoleValue::TypeInternalString; - mArgv[i].value->init(); - if (argv) - { - mArgv[i].value->setStringValue((const char*)argv[i]); - } + if (argv) + { + mArgv[i].setString(argv[i].getString()); + } } } SimConsoleEvent::~SimConsoleEvent() { - for (int i=0; irelease(); } -ConsoleValueRef SimConsoleThreadExecCallback::waitForResult() +ConsoleValue SimConsoleThreadExecCallback::waitForResult() { if(sem->acquire(true)) { - return retVal; + return std::move(retVal); } - return ConsoleValueRef(); + return ConsoleValue(); } //----------------------------------------------------------------------------- -SimConsoleThreadExecEvent::SimConsoleThreadExecEvent(S32 argc, ConsoleValueRef *argv, bool onObject, SimConsoleThreadExecCallback *callback) : +SimConsoleThreadExecEvent::SimConsoleThreadExecEvent(S32 argc, ConsoleValue *argv, bool onObject, SimConsoleThreadExecCallback *callback) : SimConsoleEvent(argc, argv, onObject), cb(callback) { } void SimConsoleThreadExecEvent::process(SimObject* object) { - ConsoleValueRef retVal; - if(mOnObject) - retVal = Con::execute(object, mArgc, mArgv); + if (cb) + { + if (mOnObject) + cb->handleCallback(std::move(Con::execute(object, mArgc, mArgv))); + else + cb->handleCallback(std::move(Con::execute(mArgc, mArgv))); + } else - retVal = Con::execute(mArgc, mArgv); - - if(cb) - cb->handleCallback(retVal); + { + if (mOnObject) + Con::execute(object, mArgc, mArgv); + else + Con::execute(mArgc, mArgv); + } } diff --git a/Engine/source/console/simEvents.h b/Engine/source/console/simEvents.h index 861c7cdde..20fa53f5b 100644 --- a/Engine/source/console/simEvents.h +++ b/Engine/source/console/simEvents.h @@ -83,8 +83,6 @@ public: virtual void process(SimObject *object)=0; }; -class ConsoleValueRef; - /// Implementation of schedule() function. /// /// This allows you to set a console function to be @@ -93,7 +91,7 @@ class SimConsoleEvent : public SimEvent { protected: S32 mArgc; - ConsoleValueRef *mArgv; + ConsoleValue *mArgv; bool mOnObject; public: @@ -110,13 +108,13 @@ public: /// /// @see Con::execute(S32 argc, const char *argv[]) /// @see Con::execute(SimObject *object, S32 argc, const char *argv[]) - SimConsoleEvent(S32 argc, ConsoleValueRef *argv, bool onObject); + SimConsoleEvent(S32 argc, ConsoleValue *argv, bool onObject); ~SimConsoleEvent(); virtual void process(SimObject *object); /// Creates a reference to our internal args list in argv - void populateArgs(ConsoleValueRef *argv); + void populateArgs(ConsoleValue *argv); }; @@ -125,13 +123,13 @@ public: struct SimConsoleThreadExecCallback { Semaphore *sem; - ConsoleValueRef retVal; + ConsoleValue retVal; SimConsoleThreadExecCallback(); ~SimConsoleThreadExecCallback(); - void handleCallback(ConsoleValueRef ret); - ConsoleValueRef waitForResult(); + void handleCallback(ConsoleValue ret); + ConsoleValue waitForResult(); }; class SimConsoleThreadExecEvent : public SimConsoleEvent @@ -139,7 +137,7 @@ class SimConsoleThreadExecEvent : public SimConsoleEvent SimConsoleThreadExecCallback *cb; public: - SimConsoleThreadExecEvent(S32 argc, ConsoleValueRef *argv, bool onObject, SimConsoleThreadExecCallback *callback); + SimConsoleThreadExecEvent(S32 argc, ConsoleValue *argv, bool onObject, SimConsoleThreadExecCallback *callback); SimConsoleThreadExecCallback& getCB() { return *cb; } virtual void process(SimObject *object); diff --git a/Engine/source/console/simManager.cpp b/Engine/source/console/simManager.cpp index fc8a77edd..c8fb60c7f 100644 --- a/Engine/source/console/simManager.cpp +++ b/Engine/source/console/simManager.cpp @@ -328,11 +328,6 @@ SimObject* findObject(const char* fileName, S32 declarationLine) return gRootGroup->findObjectByLineNumber(fileName, declarationLine, true); } -SimObject* findObject(ConsoleValueRef &ref) -{ - return findObject((const char*)ref); -} - SimObject* findObject(const char* name) { PROFILE_SCOPE(SimFindObject); @@ -391,6 +386,20 @@ SimObject* findObject(const char* name) return obj->findObject(name + len + 1); } +SimObject* findObject(const ConsoleValue &val) +{ + if (val.getType() == ConsoleValueType::cvInteger) + return findObject((SimObjectId)val.getFastInt()); + return findObject(val.getString()); +} + +SimObject* findObject(ConsoleValue* val) +{ + if (val->getType() == ConsoleValueType::cvInteger) + return findObject((SimObjectId)val->getFastInt()); + return findObject(val->getString()); +} + SimObject* findObject(SimObjectId id) { return gIdDictionary->find(id); diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index e85047545..6b54bdd1d 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -141,7 +141,7 @@ SimObject::~SimObject() //----------------------------------------------------------------------------- -bool SimObject::processArguments(S32 argc, ConsoleValueRef *argv) +bool SimObject::processArguments(S32 argc, ConsoleValue *argv) { return argc == 0; } @@ -2971,8 +2971,10 @@ 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]; - return Con::execute( object, argc - 1, argv + 1 ); + argv[1].setString(argv[2].getString()); + + ConsoleValue returnValue = Con::execute(object, argc - 1, argv + 1); + return Con::getReturnBuffer(returnValue.getString()); } //----------------------------------------------------------------------------- @@ -3074,9 +3076,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 diff --git a/Engine/source/console/simObject.h b/Engine/source/console/simObject.h index 102689b41..9cef85f0f 100644 --- a/Engine/source/console/simObject.h +++ b/Engine/source/console/simObject.h @@ -587,7 +587,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks virtual ~SimObject(); - virtual bool processArguments(S32 argc, ConsoleValueRef *argv); ///< Process constructor options. (ie, new SimObject(1,2,3)) + virtual bool processArguments(S32 argc, ConsoleValue *argv); ///< Process constructor options. (ie, new SimObject(1,2,3)) /// @} diff --git a/Engine/source/console/simPersistSet.cpp b/Engine/source/console/simPersistSet.cpp index 00840c649..771e8ce0c 100644 --- a/Engine/source/console/simPersistSet.cpp +++ b/Engine/source/console/simPersistSet.cpp @@ -47,7 +47,7 @@ SimPersistSet::SimPersistSet() //----------------------------------------------------------------------------- -bool SimPersistSet::processArguments( S32 argc, ConsoleValueRef *argv ) +bool SimPersistSet::processArguments( S32 argc, ConsoleValue *argv ) { for( U32 i = 0; i < argc; ++ i ) { diff --git a/Engine/source/console/simPersistSet.h b/Engine/source/console/simPersistSet.h index d1769cff0..e09a828ff 100644 --- a/Engine/source/console/simPersistSet.h +++ b/Engine/source/console/simPersistSet.h @@ -58,7 +58,7 @@ class SimPersistSet : public SimSet // SimSet. virtual void addObject( SimObject* ); virtual void write( Stream &stream, U32 tabStop, U32 flags = 0 ); - virtual bool processArguments( S32 argc, ConsoleValueRef *argv ); + virtual bool processArguments( S32 argc, ConsoleValue *argv ); DECLARE_CONOBJECT( SimPersistSet ); DECLARE_CATEGORY( "Console" ); diff --git a/Engine/source/console/simSet.cpp b/Engine/source/console/simSet.cpp index 0be49ca39..bce5cd47d 100644 --- a/Engine/source/console/simSet.cpp +++ b/Engine/source/console/simSet.cpp @@ -229,17 +229,15 @@ void SimSet::scriptSort( const String &scriptCallbackFn ) //----------------------------------------------------------------------------- -void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups ) +void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValue argv[], bool executeOnChildGroups ) { // Prep the arguments for the console exec... // Make sure and leave args[1] empty. - ConsoleValueRef args[21] = { }; - ConsoleValue name_method; - name_method.setStackStringValue(method.c_str()); - args[0] = ConsoleValueRef::fromValue(&name_method); + ConsoleValue args[21] = { }; + args[0].setString(method.c_str()); for (S32 i = 0; i < argc; i++) - args[i + 2] = argv[i]; + args[i + 2].setString(argv[i].getString()); for( iterator i = begin(); i != end(); i++ ) { @@ -838,7 +836,7 @@ SimGroup* SimGroup::deepClone() //----------------------------------------------------------------------------- -bool SimGroup::processArguments(S32, ConsoleValueRef *argv) +bool SimGroup::processArguments(S32, ConsoleValue *argv) { return true; } diff --git a/Engine/source/console/simSet.h b/Engine/source/console/simSet.h index 01f636662..b1f8c3f24 100644 --- a/Engine/source/console/simSet.h +++ b/Engine/source/console/simSet.h @@ -218,7 +218,7 @@ class SimSet : public SimObject, public TamlChildren /// @} - void callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups = true ); + void callOnChildren( const String &method, S32 argc, ConsoleValue argv[], bool executeOnChildGroups = true ); /// Return the number of objects in this set as well as all sets that are contained /// in this set and its children. @@ -464,7 +464,7 @@ class SimGroup: public SimSet virtual SimObject* findObject(const char* name); virtual void onRemove(); - virtual bool processArguments( S32 argc, ConsoleValueRef *argv ); + virtual bool processArguments( S32 argc, ConsoleValue *argv ); virtual SimObject* getObject(const S32& index); diff --git a/Engine/source/console/stringStack.cpp b/Engine/source/console/stringStack.cpp index 96aef1c86..f1ee26702 100644 --- a/Engine/source/console/stringStack.cpp +++ b/Engine/source/console/stringStack.cpp @@ -39,7 +39,6 @@ StringStack::StringStack() mStart = 0; mLen = 0; mStartStackSize = 0; - mFunctionOffset = 0; validateBufferSize(8192); validateArgBufferSize(2048); dMemset(mBuffer, '\0', mBufferSize); @@ -82,7 +81,7 @@ void StringStack::setIntValue(U32 i) void StringStack::setFloatValue(F64 v) { validateBufferSize(mStart + 32); - dSprintf(mBuffer + mStart, 32, "%g", v); + dSprintf(mBuffer + mStart, 32, "%.9g", v); mLen = dStrlen(mBuffer + mStart); } @@ -180,255 +179,3 @@ U32 StringStack::compare() return ret; } - -void StringStack::pushFrame() -{ - //Con::printf("StringStack pushFrame [frame=%i, start=%i]", mNumFrames, mStartStackSize); - mFrameOffsets[mNumFrames++] = mStartStackSize; - mStartOffsets[mStartStackSize++] = mStart; - mStart += ReturnBufferSpace; - validateBufferSize(0); -} - -void StringStack::popFrame() -{ - //Con::printf("StringStack popFrame [frame=%i, start=%i]", mNumFrames, mStartStackSize); - mStartStackSize = mFrameOffsets[--mNumFrames]; - mStart = mStartOffsets[mStartStackSize]; - mLen = 0; -} - -void StringStack::clearFrames() -{ - //Con::printf("StringStack clearFrames"); - mNumFrames = 0; - mStart = 0; - mLen = 0; - mStartStackSize = 0; - mFunctionOffset = 0; -} - - -void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame /* = false */) -{ - U32 startStack = mStackFrames[mFrame-1]; - U32 argCount = getMin(mStackPos - startStack, (U32)MaxArgs - 1); - - *in_argv = mArgv; - mArgv[0].value = CSTK.pushStackString(name); - - for(U32 i = 0; i < argCount; i++) { - ConsoleValueRef *ref = &mArgv[i+1]; - ref->value = &mStack[startStack + i]; - } - argCount++; - - *argc = argCount; - - if(popStackFrame) - popFrame(); -} - -ConsoleValueStack::ConsoleValueStack() : -mFrame(0), -mStackPos(0) -{ - for (int i=0; itype) - { - case ConsoleValue::TypeInternalInt: - mStack[mStackPos++].setIntValue((S32)variable->getIntValue()); - case ConsoleValue::TypeInternalFloat: - mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue()); - default: - mStack[mStackPos++].setStackStringValue(variable->getStringValue()); - } -} - -void ConsoleValueStack::pushValue(ConsoleValue &variable) -{ - if (mStackPos == ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return; - } - - switch (variable.type) - { - case ConsoleValue::TypeInternalInt: - mStack[mStackPos++].setIntValue((S32)variable.getIntValue()); - case ConsoleValue::TypeInternalFloat: - mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue()); - case ConsoleValue::TypeInternalStringStackPtr: - mStack[mStackPos++].setStringStackPtrValue(variable.getStringStackPtr()); - default: - mStack[mStackPos++].setStringValue(variable.getStringValue()); - } -} - -ConsoleValue* ConsoleValueStack::reserveValues(U32 count) -{ - U32 startPos = mStackPos; - if (startPos+count >= ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return NULL; - } - - //Con::printf("[%i]CSTK reserveValues %i", mStackPos, count); - mStackPos += count; - return &mStack[startPos]; -} - -bool ConsoleValueStack::reserveValues(U32 count, ConsoleValueRef *outValues) -{ - U32 startPos = mStackPos; - if (startPos+count >= ConsoleValueStack::MaxStackDepth) { - AssertFatal(false, "Console Value Stack is empty"); - return false; - } - - //Con::printf("[%i]CSTK reserveValues %i", mStackPos, count); - for (U32 i=0; imBuffer + mOffset; } diff --git a/Engine/source/console/telnetDebugger.cpp b/Engine/source/console/telnetDebugger.cpp index 719ed7d32..d3b163f1f 100644 --- a/Engine/source/console/telnetDebugger.cpp +++ b/Engine/source/console/telnetDebugger.cpp @@ -864,6 +864,49 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char * if ( frame < 0 ) frame = 0; + // Local variables use their own memory management and can't be queried by just executing + // TorqueScript, we have to go digging into the interpreter. + S32 evalBufferLen = dStrlen(evalBuffer); + bool isEvaluatingLocalVariable = evalBufferLen > 0 && evalBuffer[0] == '%'; + if (isEvaluatingLocalVariable) + { + // See calculation of current frame in pushing a reference frame for console exec, we need access + // to the proper scope. + //frame = gEvalState.getTopOfStack() - frame - 1; + S32 stackIndex = gEvalState.getTopOfStack() - frame - 1; + + const char* format = "EVALOUT %s %s\r\n"; + + gEvalState.pushDebugFrame(stackIndex); + + Dictionary& stackFrame = gEvalState.getCurrentFrame(); + StringTableEntry functionName = stackFrame.scopeName; + StringTableEntry namespaceName = stackFrame.scopeNamespace->mName; + StringTableEntry varToLookup = StringTable->insert(evalBuffer); + + S32 registerId = stackFrame.code->variableRegisterTable.lookup(namespaceName, functionName, varToLookup); + + if (registerId == -1) + { + // ERROR, can't read the variable! + send("EVALOUT \"\" \"\""); + return; + } + + const char* varResult = gEvalState.getLocalStringVariable(registerId); + + gEvalState.popFrame(); + + S32 len = dStrlen(format) + dStrlen(tag) + dStrlen(varResult); + char* buffer = new char[len]; + dSprintf(buffer, len, format, tag, varResult[0] ? varResult : "\"\""); + + send(buffer); + delete[] buffer; + + return; + } + // Build a buffer just big enough for this eval. const char* format = "return %s;"; dsize_t len = dStrlen( format ) + dStrlen( evalBuffer ); @@ -872,14 +915,14 @@ void TelnetDebugger::evaluateExpression(const char *tag, S32 frame, const char * // Execute the eval. CodeBlock *newCodeBlock = new CodeBlock(); - const char* result = newCodeBlock->compileExec( NULL, buffer, false, frame ); + ConsoleValue result = newCodeBlock->compileExec( NULL, buffer, false, frame ); delete [] buffer; // Create a new buffer that fits the result. format = "EVALOUT %s %s\r\n"; - len = dStrlen( format ) + dStrlen( tag ) + dStrlen( result ); + len = dStrlen( format ) + dStrlen( tag ) + dStrlen( result.getString() ); buffer = new char[ len ]; - dSprintf( buffer, len, format, tag, result[0] ? result : "\"\"" ); + dSprintf( buffer, len, format, tag, result.getString()[0] ? result.getString() : "\"\"" ); send( buffer ); delete [] buffer; diff --git a/Engine/source/console/test/ScriptTest.cpp b/Engine/source/console/test/ScriptTest.cpp index 994606783..05775694f 100644 --- a/Engine/source/console/test/ScriptTest.cpp +++ b/Engine/source/console/test/ScriptTest.cpp @@ -30,139 +30,153 @@ #include "math/mMath.h" #include "console/stringStack.h" -template -inline T Convert(ConsoleValueRef); - -template<> -inline U32 Convert(ConsoleValueRef val) +inline ConsoleValue RunScript(const char* str) { - return val.getIntValue(); -} - -template<> -inline S32 Convert(ConsoleValueRef val) -{ - return val.getSignedIntValue(); -} - -template<> -inline bool Convert(ConsoleValueRef val) -{ - return val.getBoolValue(); -} - -template<> -inline F32 Convert(ConsoleValueRef val) -{ - return val.getFloatValue(); -} - -template<> -inline const char* Convert(ConsoleValueRef val) -{ - return val.getStringValue(); -} - -template<> -inline SimObject* Convert(ConsoleValueRef val) -{ - return Sim::findObject(val); -} - -template -inline T RunScript(const char* str) -{ - return Convert(Con::evaluate(str, false, NULL)); + return std::move(Con::evaluate(str, false, NULL)); } TEST(Script, Basic_Arithmetic) { - S32 add = RunScript(R"( + ConsoleValue add = RunScript(R"( return 1.0 + 1; )"); - EXPECT_EQ(add, 2); + ASSERT_EQ(add.getInt(), 2); - S32 sub = RunScript(R"( + ConsoleValue sub = RunScript(R"( return 10 - 1.0; )"); - EXPECT_EQ(sub, 9); + ASSERT_EQ(sub.getInt(), 9); - S32 mult = RunScript(R"( + ConsoleValue mult = RunScript(R"( return 10 * 2.5; )"); - EXPECT_EQ(mult, 25); + ASSERT_EQ(mult.getInt(), 25); - S32 div = RunScript(R"( + ConsoleValue div = RunScript(R"( return 10.0 / 2; )"); - EXPECT_EQ(div, 5); + ASSERT_EQ(div.getInt(), 5); + + ConsoleValue mod = RunScript(R"( + return 4 % 5; + )"); + + ASSERT_EQ(mod.getInt(), 4); + + ConsoleValue add2 = RunScript(R"( + $a = 0; + $a += 2; + return $a; + )"); + + ASSERT_EQ(add2.getInt(), 2); + + ConsoleValue sub2 = RunScript(R"( + $a = 0; + $a -= 2; + return $a; + )"); + + ASSERT_EQ(sub2.getInt(), -2); + + ConsoleValue mult2 = RunScript(R"( + $a = 2; + $a *= 3; + return $a; + )"); + + ASSERT_EQ(mult2.getInt(), 6); + + ConsoleValue div2 = RunScript(R"( + $a = 10; + $a /= 2; + return $a; + )"); + + ASSERT_EQ(div2.getInt(), 5); + + ConsoleValue pp = RunScript(R"( + $a = 0; + $a++; + return $a; + )"); + + ASSERT_EQ(pp.getInt(), 1); + + ConsoleValue mm = RunScript(R"( + $a = 2; + $a--; + return $a; + )"); + + ASSERT_EQ(mm.getInt(), 1); } TEST(Script, Complex_Arithmetic) { - S32 result = RunScript(R"( + ConsoleValue result = RunScript(R"( return 1 * 2 - (0.5 * 2); )"); - EXPECT_EQ(result, 1); + ASSERT_EQ(result.getInt(), 1); - S32 result2 = RunScript(R"( + ConsoleValue result2 = RunScript(R"( return 1 * 2 * 3 % 2; )"); - EXPECT_EQ(result2, 0); + ASSERT_EQ(result2.getInt(), 0); } TEST(Script, Basic_Concatination) { - const char* result1 = RunScript(R"( + ConsoleValue result1 = RunScript(R"( return "a" @ "b"; )"); - EXPECT_STREQ(result1, "ab"); + ASSERT_STREQ(result1.getString(), "ab"); - const char* result2 = RunScript(R"( + ConsoleValue result2 = RunScript(R"( return "a" SPC "b"; )"); - EXPECT_STREQ(result2, "a b"); + ASSERT_STREQ(result2.getString(), "a b"); - const char* result3 = RunScript(R"( + ConsoleValue result3 = RunScript(R"( return "a" TAB "b"; )"); - EXPECT_STREQ(result3, "a\tb"); + ASSERT_STREQ(result3.getString(), "a\tb"); - const char* result4 = RunScript(R"( + ConsoleValue result4 = RunScript(R"( return "a" NL "b"; )"); - EXPECT_STREQ(result4, "a\nb"); + ASSERT_STREQ(result4.getString(), "a\nb"); - const char* complex = RunScript(R"( + ConsoleValue complex = RunScript(R"( return "a" @ "b" @ "c" @ "d"; )"); - EXPECT_STREQ(complex, "abcd"); + ASSERT_STREQ(complex.getString(), "abcd"); } TEST(Script, Basic_Global_Variable_Tests) { - S32 value = RunScript(R"( + ConsoleValue value = RunScript(R"( $a = 1; return $a; )"); - EXPECT_EQ(value, 1); + ASSERT_EQ(value.getInt(), 1); } TEST(Script, Variable_Chaining_And_Usage) { - S32 value = RunScript(R"( + ConsoleValue value = RunScript(R"( function t() { %a = %b = 2; @@ -171,9 +185,9 @@ TEST(Script, Variable_Chaining_And_Usage) return t(); )"); - EXPECT_EQ(value, 2); + ASSERT_EQ(value.getInt(), 2); - S32 valueGlobal = RunScript(R"( + ConsoleValue valueGlobal = RunScript(R"( function t() { $a = %b = 2; @@ -182,9 +196,9 @@ TEST(Script, Variable_Chaining_And_Usage) return $a; )"); - EXPECT_EQ(valueGlobal, 2); + ASSERT_EQ(valueGlobal.getInt(), 2); - S32 value2 = RunScript(R"( + ConsoleValue value2 = RunScript(R"( function t(%a) { if ((%b = 2 * %a) != 5) @@ -195,26 +209,26 @@ TEST(Script, Variable_Chaining_And_Usage) return t(2); )"); - EXPECT_EQ(value2, 4); + ASSERT_EQ(value2.getInt(), 4); } TEST(Script, Basic_Function_Call_And_Local_Variable_Testing) { - S32 value = RunScript(R"( + ConsoleValue value = RunScript(R"( function t() { %a = 2; return %a; } return t(); )"); - EXPECT_EQ(value, 2); + ASSERT_EQ(value.getInt(), 2); - S32 value2 = RunScript(R"( + ConsoleValue value2 = RunScript(R"( function add(%a, %b) { return %a + %b; } return add(2, 4); )"); - EXPECT_EQ(value2, 6); + ASSERT_EQ(value2.getInt(), 6); - S32 value3 = RunScript(R"( + ConsoleValue value3 = RunScript(R"( function fib(%a) { if (%a == 0) return 0; @@ -225,48 +239,48 @@ TEST(Script, Basic_Function_Call_And_Local_Variable_Testing) return fib(15); )"); - EXPECT_EQ(value3, 610); + ASSERT_EQ(value3.getInt(), 610); - S32 staticCall = RunScript(R"( + ConsoleValue staticCall = RunScript(R"( function SimObject::bar(%a, %b) { return %a + %b; } return SimObject::bar(1, 2); )"); - EXPECT_EQ(staticCall, 3); + ASSERT_EQ(staticCall.getInt(), 3); } TEST(Script, Basic_Conditional_Statements) { - S32 value = RunScript(R"( + ConsoleValue value = RunScript(R"( $a = "hello"; if ($a $= "hello") return 1; return 2; )"); - EXPECT_EQ(value, 1); + ASSERT_EQ(value.getInt(), 1); - const char* ternaryValue = RunScript(R"( + ConsoleValue ternaryValue = RunScript(R"( return $a $= "hello" ? "World" : "No U"; )"); - EXPECT_STREQ(ternaryValue, "World"); + ASSERT_STREQ(ternaryValue.getString(), "World"); } TEST(Script, Basic_Loop_Statements) { - S32 whileValue = RunScript(R"( + ConsoleValue whileValue = RunScript(R"( $count = 0; while ($count < 5) $count++; return $count; )"); - EXPECT_EQ(whileValue, 5); + ASSERT_EQ(whileValue.getInt(), 5); - const char* forValue = RunScript(R"( + ConsoleValue forValue = RunScript(R"( function t(%times) { %result = ""; @@ -278,12 +292,28 @@ TEST(Script, Basic_Loop_Statements) return t(3); )"); - EXPECT_STREQ(forValue, "aaa"); + ASSERT_STREQ(forValue.getString(), "aaa"); - const char* forIfValue = RunScript(R"( - function t() { + ConsoleValue forReverseLoop = RunScript(R"( + function t(%times) + { + %result = ""; + for (%i = %times - 1; %i >= 0; %i--) + %result = %result @ "b"; + return %result; + } + + return t(3); + )"); + + ASSERT_STREQ(forReverseLoop.getString(), "bbb"); + + ConsoleValue forIfValue = RunScript(R"( + function t() + { %str = ""; - for (%i = 0; %i < 5; %i++) { + for (%i = 0; %i < 5; %i++) + { %loopValue = %i; @@ -298,43 +328,238 @@ TEST(Script, Basic_Loop_Statements) return t(); )"); - EXPECT_STREQ(forIfValue, "0, 1, 2, 3, 4"); + ASSERT_STREQ(forIfValue.getString(), "0, 1, 2, 3, 4"); +} + +TEST(Script, ForEachLoop) +{ + ConsoleValue forEach1 = RunScript(R"( + $theSimSet = new SimSet(); + $theSimSet.add(new SimObject()); + $theSimSet.add(new SimObject()); + + $counter = 0; + foreach ($obj in $theSimSet) + { + $counter++; + } + + $theSimSet.delete(); + + return $counter; + )"); + + ASSERT_EQ(forEach1.getInt(), 2); + + ConsoleValue forEach2 = RunScript(R"( + $counter = 0; + foreach$ ($word in "a b c d") + { + $counter++; + } + + return $counter; + )"); + + ASSERT_EQ(forEach2.getInt(), 4); + + ConsoleValue forEach3 = RunScript(R"( + function SimObject::addOne(%this) + { + return 1; + } + + function test() + { + %set = new SimSet(); + %set.add(new SimObject()); + %set.add(new SimObject()); + + %count = 0; + foreach (%obj in %set) + %count += %obj.addOne(); + + %set.delete(); + + return %count; + } + + return test(); + )"); + + ASSERT_EQ(forEach3.getInt(), 2); + + ConsoleValue forEach4 = RunScript(R"( + function test() + { + %string = "a b c d e"; + + %count = 0; + foreach$ (%word in %string) + %count++; + + return %count; + } + + return test(); + )"); + + ASSERT_EQ(forEach4.getInt(), 5); + + ConsoleValue forEach5 = RunScript(R"( + function SimObject::ret1(%this) + { + return 1; + } + + function SimSet::doForeach5(%this) + { + %count = 0; + foreach (%obj in %this) + { + %count += %obj.ret1(); + } + return %count; + } + + function a() + { + %set = new SimSet(); + %set.add(new SimObject()); + %set.add(new SimObject()); + %set.add(new SimObject()); + + return %set.doForeach5(); + } + + return a(); + )"); + + ASSERT_EQ(forEach5.getInt(), 3); + + ConsoleValue forEachContinue = RunScript(R"( + function SimSet::foreach6(%this) + { + %count = 0; + foreach (%obj in %this) + { + if (%obj.getName() $= "A") + continue; + + %count++; + } + return %count; + } + + function a() + { + %set = new SimSet(); + %set.add(new SimObject(A)); + %set.add(new SimObject()); + %set.add(new SimObject()); + + return %set.foreach6(); + } + + return a(); + )"); + + ASSERT_EQ(forEachContinue.getInt(), 2); + + ConsoleValue forEachReturn = RunScript(R"( + function SimSet::findA(%this) + { + foreach (%obj in %this) + { + if (%obj.getName() $= "A") + return 76; + } + return 0; + } + + function a() + { + %set = new SimSet(); + %set.add(new SimObject(A)); + %set.add(new SimObject()); + %set.add(new SimObject()); + + return %set.findA(); + } + + return a(); + )"); + + ASSERT_EQ(forEachReturn.getInt(), 76); + + ConsoleValue forEachNestedReturn = RunScript(R"( + function SimSet::findA(%this) + { + foreach (%obj in %this) + { + foreach (%innerObj in %this) + { + if (%innerObj.getName() $= "A") + return 42; + } + } + return 0; + } + + function a() + { + %set = new SimSet(); + %set.add(new SimObject(A)); + %set.add(new SimObject()); + %set.add(new SimObject()); + + %group = new SimGroup(); + %group.add(%set); + + return %set.findA(); + } + + return a(); + )"); + + ASSERT_EQ(forEachNestedReturn.getInt(), 42); } TEST(Script, TorqueScript_Array_Testing) { - S32 value = RunScript(R"( - function t(%idx) { %a[idx] = 2; return %a[idx]; } + ConsoleValue value = RunScript(R"( + function t(%idx) { %a[%idx] = 2; return %a[%idx]; } return t(5); )"); - EXPECT_EQ(value, 2); + ASSERT_EQ(value.getInt(), 2); - S32 value2 = RunScript(R"( - function t(%idx) { %a[idx, 0] = 2; return %a[idx, 0]; } + ConsoleValue value2 = RunScript(R"( + function t(%idx) { %a[%idx, 0] = 2; return %a[%idx, 0]; } return t(5); )"); - EXPECT_EQ(value2, 2); + ASSERT_EQ(value2.getInt(), 2); } TEST(Script, Basic_SimObject) { - SimObject* object = RunScript(R"( - return new SimObject(FudgeCollector) { + ConsoleValue object = RunScript(R"( + return new SimObject(FudgeCollector) + { fudge = "Chocolate"; }; )"); - EXPECT_NE(object, (SimObject*)NULL); + ASSERT_NE(Sim::findObject(object), (SimObject*)NULL); - const char* propertyValue = RunScript(R"( + ConsoleValue propertyValue = RunScript(R"( return FudgeCollector.fudge; )"); - EXPECT_STREQ(propertyValue, "Chocolate"); + ASSERT_STREQ(propertyValue.getString(), "Chocolate"); - const char* funcReturn = RunScript(R"( + ConsoleValue funcReturn = RunScript(R"( function SimObject::fooFunc(%this) { return "Bar"; @@ -343,9 +568,9 @@ TEST(Script, Basic_SimObject) return FudgeCollector.fooFunc(); )"); - EXPECT_STREQ(funcReturn, "Bar"); + ASSERT_STREQ(funcReturn.getString(), "Bar"); - const char* parentFn = RunScript(R"( + ConsoleValue parentFn = RunScript(R"( new SimObject(Hello); function SimObject::fooFunc2(%this) @@ -362,34 +587,426 @@ TEST(Script, Basic_SimObject) return Hello.fooFunc2(); )"); - EXPECT_STREQ(parentFn, "FooBar"); + ASSERT_STREQ(parentFn.getString(), "FooBar"); + + ConsoleValue simpleFieldTest = RunScript(R"( + function a() + { + FudgeCollector.field = "A"; + return FudgeCollector.field; + } + return a(); + )"); + + ASSERT_STREQ(simpleFieldTest.getString(), "A"); + + ConsoleValue grp = RunScript(R"( + new SimGroup(FudgeCollectorGroup) + { + theName = "fudge"; + + new SimObject(ChocolateFudge) + { + type = "Chocolate"; + }; + new SimObject(PeanutButterFudge) + { + type = "Peanut Butter"; + + field["a"] = "Yes"; + }; + }; + + return FudgeCollectorGroup.getId(); + )"); + + SimGroup* simGroup = dynamic_cast(Sim::findObject(grp)); + ASSERT_NE(simGroup, (SimGroup*)NULL); + ASSERT_EQ(simGroup->size(), 2); + + simGroup->deleteObject(); + + ConsoleValue fieldTest = RunScript(R"( + function a() + { + %obj = new SimObject(); + %obj.field = "A"; + %obj.val[%obj.field] = "B"; + + %value = %obj.val["A"]; + %obj.delete(); + return %value; + } + return a(); + )"); + + ASSERT_STREQ(fieldTest.getString(), "B"); + + ConsoleValue fieldOpTest = RunScript(R"( + function a() + { + %obj = new SimObject(); + %obj.field = 1; + %obj.field += 2; + + %value = %obj.field; + %obj.delete(); + return %value; + } + return a(); + )"); + + ASSERT_EQ(fieldOpTest.getInt(), 3); +} + +TEST(Script, Internal_Name) +{ + ConsoleValue value = RunScript(R"( + function TheFirstInner::_internalCall(%this) + { + return 5; + } + + function a() + { + %grp = new SimGroup(); + %obj = new SimObject(TheFirstInner) + { + internalName = "Yay"; + }; + %grp.add(%obj); + + %val = %grp->Yay._internalCall(); + + %grp.delete(); + + return %val; + } + return a(); + )"); + + ASSERT_EQ(value.getInt(), 5); + + ConsoleValue recursiveValue = RunScript(R"( + function SimGroup::doTheInternalCall(%this) + { + return %this-->Yeah._internalCall2(); + } + + function TheAnotherObject::_internalCall2(%this) + { + return %this.property; + } + + function a() + { + %grp = new SimGroup(); + %obj = new SimGroup() + { + internalName = "Yay2"; + + new SimObject(TheAnotherObject) + { + internalName = "Yeah"; + property = 12; + }; + }; + %grp.add(%obj); + + %val = %grp.doTheInternalCall(); + + %grp.delete(); + + return %val; + } + return a(); + )"); + + ASSERT_EQ(recursiveValue.getInt(), 12); } TEST(Script, Basic_Package) { - S32 value = RunScript(R"( + ConsoleValue value = RunScript(R"( function a() { return 3; } - package overrides { + package overrides + { function a() { return 5; } }; return a(); )"); - EXPECT_EQ(value, 3); + ASSERT_EQ(value.getInt(), 3); - S32 overrideValue = RunScript(R"( + ConsoleValue overrideValue = RunScript(R"( activatePackage(overrides); return a(); )"); - EXPECT_EQ(overrideValue, 5); + ASSERT_EQ(overrideValue.getInt(), 5); - S32 deactivatedValue = RunScript(R"( + ConsoleValue deactivatedValue = RunScript(R"( deactivatePackage(overrides); return a(); )"); - EXPECT_EQ(deactivatedValue, 3); + ASSERT_EQ(deactivatedValue.getInt(), 3); +} + +TEST(Script, Sugar_Syntax) +{ + ConsoleValue value = RunScript(R"( + function a() + { + %vector = "1 2 3"; + return %vector.y; + } + return a(); + )"); + + ASSERT_EQ(value.getInt(), 2); + + ConsoleValue setValue = RunScript(R"( + function a() + { + %vector = "1 2 3"; + %vector.y = 4; + return %vector.y; + } + return a(); + )"); + + ASSERT_EQ(setValue.getInt(), 4); + + ConsoleValue valueArray = RunScript(R"( + function a() + { + %vector[0] = "1 2 3"; + return %vector[0].y; + } + return a(); + )"); + + ASSERT_EQ(valueArray.getInt(), 2); + + ConsoleValue valueSetArray = RunScript(R"( + function a() + { + %vector[0] = "1 2 3"; + %vector[0].z = 5; + return %vector[0].z; + } + return a(); + )"); + + ASSERT_EQ(valueSetArray.getInt(), 5); + + ConsoleValue valueStoreCalculated = RunScript(R"( + function a() + { + %extent = 10 SPC 20; + %scaling = 1; + %size = %extent.x * %scaling; + return %size; + } + + return a(); + )"); + + ASSERT_EQ(valueStoreCalculated.getInt(), 10); + + ConsoleValue globalValueGet = RunScript(R"( + new SimObject(AAAA); + AAAA.doSomething = false; + $vec = "1 2 3"; + return $vec.x * 4; + )"); + + ASSERT_EQ(globalValueGet.getFloat(), 4); + + ConsoleValue globalValueSet = RunScript(R"( + new SimObject(AAAAB); + AAAAB.doSomething = false; + $vec2 = "1 2 3"; + $vec2.x *= 4; + return $vec2.x; + )"); + + ASSERT_EQ(globalValueSet.getFloat(), 4); +} + +TEST(Script, InnerObjectTests) +{ + ConsoleValue theObject = RunScript(R"( + function a() + { + %obj = new SimObject(TheOuterObject) + { + innerObject = new SimObject(TheInnerObject) + { + testField = 123; + position = "1 2 3"; + }; + }; + return %obj; + } + return a(); + )"); + + SimObject* outerObject = Sim::findObject("TheOuterObject"); + ASSERT_NE(outerObject, (SimObject*)NULL); + if (outerObject) + { + ASSERT_EQ(theObject.getInt(), Sim::findObject("TheOuterObject")->getId()); + } + ASSERT_NE(Sim::findObject("TheInnerObject"), (SimObject*)NULL); + + ConsoleValue positionValue = RunScript(R"( + function TheOuterObject::getInnerPosition(%this) + { + return %this.innerObject.position; + } + + function a() + { + %position = TheOuterObject.getInnerPosition(); + return %position.y; + } + return a(); + )"); + + ASSERT_EQ(positionValue.getInt(), 2); + + ConsoleValue nestedFuncCall = RunScript(R"( + function TheInnerObject::test(%this) + { + return %this.testField; + } + + return TheOuterObject.innerObject.test(); + )"); + + ASSERT_EQ(nestedFuncCall.getInt(), 123); +} + +TEST(Script, MiscRegressions) +{ + ConsoleValue regression1 = RunScript(R"( + new SimObject(TheRegressionObject); + + function doTest() + { + TheRegressionObject.hidden = false; + + %previewSize = 100 SPC 100; + %previewScaleSize = 2; + %size = %previewSize.x * %previewScaleSize; + + return %size; + } + + return doTest(); + )"); + + ASSERT_EQ(regression1.getInt(), 200); + + ConsoleValue regression2 = RunScript(R"( + new SimObject(TheRegressionObject2) + { + extent = "100 200"; + }; + + function doTest() + { + %scale = 2; + %position = TheRegressionObject2.extent.x SPC TheRegressionObject2.extent.y * %scale; + return %position.y; + } + + return doTest(); + )"); + + ASSERT_EQ(regression2.getInt(), 400); + + ConsoleValue regression3 = RunScript(R"( + function doTest() + { + %button = new GuiIconButtonCtrl() + { + active = true; + }; + + %button.setExtent(120, 20); + + %button.setExtent("120 20"); + + %button.extent = "120 20"; + + %button.extent.x = 120; + %button.extent.y = 20; + return %button.extent; + } + return doTest(); + )"); + + ASSERT_STREQ(regression3.getString(), "120 20"); + + ConsoleValue regression4 = RunScript(R"( + function doTest() + { + %slider = new GuiSliderCtrl() + { + range = "0 2"; + ticks = 5; + active = true; + }; + + %slider.setValue(0.5); + return %slider.getValue(); + } + return doTest(); + )"); + + ASSERT_EQ(regression4.getFloat(), 0.5); + + ConsoleValue regression5 = RunScript(R"( + function noOpInc() + { + %count = 0; + %var[%count++] = 2; + return %var[1]; + } + return noOpInc(); + )"); + + ASSERT_EQ(regression5.getInt(), 2); + + ConsoleValue regression6 = RunScript(R"( + function SimObject::crashMe(%this, %line) + { + return %line @ "1"; + } + + function doTest() + { + %obj = new SimObject(); + for (%i = 0; %i < 99999; %i++) + { + %function = "crashMe"; + if (%obj.isMethod(%function)) + { + %line = "abcdefg"; + %output = %obj.call(%function, %line); + } + } + + return true; + } + + return doTest(); + )"); + + ASSERT_EQ(regression6.getBool(), true); } #endif diff --git a/Engine/source/console/test/consoleTest.cpp b/Engine/source/console/test/consoleTest.cpp index adea797a2..a143d1835 100644 --- a/Engine/source/console/test/consoleTest.cpp +++ b/Engine/source/console/test/consoleTest.cpp @@ -1,3 +1,5 @@ +#if 0 + #ifdef TORQUE_TESTS_ENABLED #include "testing/unitTesting.h" #include "platform/platform.h" @@ -253,3 +255,4 @@ TEST(Con, execute) } #endif +#endif diff --git a/Engine/source/console/test/engineAPITest.cpp b/Engine/source/console/test/engineAPITest.cpp index 48e780531..32981e260 100644 --- a/Engine/source/console/test/engineAPITest.cpp +++ b/Engine/source/console/test/engineAPITest.cpp @@ -1,3 +1,4 @@ +#if 0 #ifdef TORQUE_TESTS_ENABLED #include "testing/unitTesting.h" #include "platform/platform.h" @@ -147,4 +148,5 @@ TEST(EngineAPI, _EngineConsoleExecCallbackHelper) "All values should be printed in the correct order"; } -#endif \ No newline at end of file +#endif +#endif diff --git a/Engine/source/core/strings/stringFunctions.cpp b/Engine/source/core/strings/stringFunctions.cpp index ed810ea74..893dc5815 100644 --- a/Engine/source/core/strings/stringFunctions.cpp +++ b/Engine/source/core/strings/stringFunctions.cpp @@ -428,7 +428,7 @@ S32 dStrlcpy(char *dst, const char *src, dsize_t dstSize) S32 copyLen = srcLen; //Check for buffer overflow and don't allow it. Warn on debug so we can fix it - AssertWarn(copyLen < dstSize, "Buffer too small in call to dStrlcpy!"); + AssertFatal(copyLen < dstSize, "Buffer too small in call to dStrlcpy!"); if (srcLen + 1 > dstSize) { copyLen = dstSize - 1; diff --git a/Engine/source/core/strings/stringFunctions.h b/Engine/source/core/strings/stringFunctions.h index 918273423..d0c91b734 100644 --- a/Engine/source/core/strings/stringFunctions.h +++ b/Engine/source/core/strings/stringFunctions.h @@ -200,6 +200,11 @@ inline F64 dAtod(const char *str) return strtod(str, NULL); } +inline S64 dAtol(const char* str) +{ + return strtol(str, NULL, 10); +} + inline char dToupper(const char c) { return toupper( c ); diff --git a/Engine/source/core/util/tVector.h b/Engine/source/core/util/tVector.h index 0700a5554..57cb84e24 100644 --- a/Engine/source/core/util/tVector.h +++ b/Engine/source/core/util/tVector.h @@ -160,6 +160,7 @@ class Vector void erase(U32 index, U32 count); void erase_fast(iterator); void clear(); + void resetAndTreatAsScratchBuffer(); void compact(); void sort(compare_func f); void fill( const T& value ); @@ -529,6 +530,15 @@ template inline void Vector::clear() mElementCount = 0; } +/// This method sets the vector as its 0 and will overwrite memory on subsequent usage. +/// Note that the current memory in use is never freed or deallocated, so only use this if the vector +/// is being used as a scratch buffer only. +template inline +void Vector::resetAndTreatAsScratchBuffer() +{ + mElementCount = 0; +} + template inline void Vector::compact() { resize(mElementCount); diff --git a/Engine/source/environment/waterObject.cpp b/Engine/source/environment/waterObject.cpp index 2a2cf86ce..dd5ea1a6f 100644 --- a/Engine/source/environment/waterObject.cpp +++ b/Engine/source/environment/waterObject.cpp @@ -418,7 +418,7 @@ void WaterObject::inspectPostApply() setMaskBits( UpdateMask | WaveMask | TextureMask | SoundMask ); } -bool WaterObject::processArguments( S32 argc, ConsoleValueRef *argv ) +bool WaterObject::processArguments( S32 argc, ConsoleValue *argv ) { if( typeid( *this ) == typeid( WaterObject ) ) { diff --git a/Engine/source/environment/waterObject.h b/Engine/source/environment/waterObject.h index 7a9e9b5d4..3c72ba21e 100644 --- a/Engine/source/environment/waterObject.h +++ b/Engine/source/environment/waterObject.h @@ -158,7 +158,7 @@ public: virtual bool onAdd(); virtual void onRemove(); virtual void inspectPostApply(); - virtual bool processArguments(S32 argc, ConsoleValueRef *argv); + virtual bool processArguments(S32 argc, ConsoleValue *argv); // NetObject virtual U32 packUpdate( NetConnection * conn, U32 mask, BitStream *stream ); diff --git a/Engine/source/gui/controls/guiGameListMenuCtrl.cpp b/Engine/source/gui/controls/guiGameListMenuCtrl.cpp index 787c697f9..61833a8d0 100644 --- a/Engine/source/gui/controls/guiGameListMenuCtrl.cpp +++ b/Engine/source/gui/controls/guiGameListMenuCtrl.cpp @@ -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; diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index 7e0f27791..2011aa68b 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -319,7 +319,7 @@ void GuiControl::initPersistFields() //----------------------------------------------------------------------------- -bool GuiControl::processArguments(S32 argc, ConsoleValueRef *argv) +bool GuiControl::processArguments(S32 argc, ConsoleValue *argv) { // argv[0] - The GuiGroup to add this control to when it's created. // this is an optional parameter that may be specified at diff --git a/Engine/source/gui/core/guiControl.h b/Engine/source/gui/core/guiControl.h index 997213f75..e0b3c0a76 100644 --- a/Engine/source/gui/core/guiControl.h +++ b/Engine/source/gui/core/guiControl.h @@ -341,7 +341,7 @@ class GuiControl : public SimGroup GuiControl(); virtual ~GuiControl(); - virtual bool processArguments(S32 argc, ConsoleValueRef *argv); + virtual bool processArguments(S32 argc, ConsoleValue *argv); static void initPersistFields(); static void consoleInit(); diff --git a/Engine/source/gui/editor/guiFilterCtrl.cpp b/Engine/source/gui/editor/guiFilterCtrl.cpp index 6abc3d53c..1be90b8e2 100644 --- a/Engine/source/gui/editor/guiFilterCtrl.cpp +++ b/Engine/source/gui/editor/guiFilterCtrl.cpp @@ -83,7 +83,7 @@ DefineEngineStringlyVariadicMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, { Filter filter; - StringStackWrapper args(argc - 2, argv + 2); + ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2); filter.set(args.count(), args); object->set(filter); diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index 617287e68..6ee578512 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -318,7 +318,8 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) { char buffer[ 2048 ]; expandEscape( buffer, newValue ); - newValue = (const char*)Con::evaluatef( "%%f = \"%s\"; return ( %s );", oldValue.c_str(), buffer ); + newValue = (const char*)Con::evaluatef( "$f = \"%s\"; return ( %s );", oldValue.c_str(), buffer ); + Con::evaluatef("$f=0;"); } else if( type == TypeS32Vector || type == TypeF32Vector @@ -353,9 +354,10 @@ void GuiInspectorField::setData( const char* data, bool callbacks ) char buffer[ 2048 ]; expandEscape( buffer, newComponentExpr ); - const char* newComponentVal = Con::evaluatef( "%%f = \"%s\"; %%v = \"%s\"; return ( %s );", + const char* newComponentVal = Con::evaluatef( "$f = \"%s\"; $v = \"%s\"; return ( %s );", oldComponentVal, oldValue.c_str(), buffer ); - + Con::evaluatef("$f=0;$v=0;"); + if( !isFirst ) strNew.append( ' ' ); strNew.append( newComponentVal ); diff --git a/Engine/source/gui/editor/popupMenu.cpp b/Engine/source/gui/editor/popupMenu.cpp index 2f250ece7..14fff6844 100644 --- a/Engine/source/gui/editor/popupMenu.cpp +++ b/Engine/source/gui/editor/popupMenu.cpp @@ -120,12 +120,14 @@ void PopupMenu::handleSelectEvent(U32 popID, U32 command) //----------------------------------------------------------------------------- bool PopupMenu::onMessageReceived(StringTableEntry queue, const char* event, const char* data) { - return Con::executef(this, "onMessageReceived", queue, event, data); + ConsoleValue returnValue = Con::executef(this, "onMessageReceived", queue, event, data); + return returnValue.getBool(); } bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg ) { - return Con::executef(this, "onMessageReceived", queue, Con::getIntArg(msg->getId())); + ConsoleValue returnValue = Con::executef(this, "onMessageReceived", queue, Con::getIntArg(msg->getId())); + return returnValue.getBool(); } ////////////////////////////////////////////////////////////////////////// diff --git a/Engine/source/gui/worldEditor/worldEditor.cpp b/Engine/source/gui/worldEditor/worldEditor.cpp index 00ab26c01..d6642cd1c 100644 --- a/Engine/source/gui/worldEditor/worldEditor.cpp +++ b/Engine/source/gui/worldEditor/worldEditor.cpp @@ -2861,17 +2861,17 @@ void WorldEditor::initPersistFields() //------------------------------------------------------------------------------ // These methods are needed for the console interfaces. -void WorldEditor::ignoreObjClass( U32 argc, ConsoleValueRef *argv ) +void WorldEditor::ignoreObjClass( U32 argc, ConsoleValue *argv ) { for(S32 i = 2; i < argc; i++) { - ClassInfo::Entry * entry = getClassEntry(argv[i]); + ClassInfo::Entry * entry = getClassEntry(argv[i].getString()); if(entry) entry->mIgnoreCollision = true; else { entry = new ClassInfo::Entry; - entry->mName = StringTable->insert(argv[i]); + entry->mName = StringTable->insert(argv[i].getString()); entry->mIgnoreCollision = true; if(!addClassEntry(entry)) delete entry; diff --git a/Engine/source/gui/worldEditor/worldEditor.h b/Engine/source/gui/worldEditor/worldEditor.h index e0ecb342f..dd596af74 100644 --- a/Engine/source/gui/worldEditor/worldEditor.h +++ b/Engine/source/gui/worldEditor/worldEditor.h @@ -76,7 +76,7 @@ class WorldEditor : public EditTSCtrl Point3F p2; }; - void ignoreObjClass(U32 argc, ConsoleValueRef* argv); + void ignoreObjClass(U32 argc, ConsoleValue* argv); void clearIgnoreList(); static bool setObjectsUseBoxCenter( void *object, const char *index, const char *data ) { static_cast(object)->setObjectsUseBoxCenter( dAtob( data ) ); return false; }; diff --git a/Engine/source/platform/types.gcc.h b/Engine/source/platform/types.gcc.h index a36759bc0..8255a251d 100644 --- a/Engine/source/platform/types.gcc.h +++ b/Engine/source/platform/types.gcc.h @@ -43,6 +43,10 @@ typedef unsigned long U64; // Compiler Version #define TORQUE_COMPILER_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#define TORQUE_FORCEINLINE __attribute__((always_inline)) +#define TORQUE_CASE_FALLTHROUGH __attribute__((fallthrough)) +#define TORQUE_NOINLINE __attribute__ ((noinline)) +#define TORQUE_UNLIKELY //-------------------------------------- // Identify the compiler string @@ -165,8 +169,5 @@ typedef unsigned long U64; #endif #endif -// Set GCC noinline -#define TORQUE_NOINLINE __attribute__ ((noinline)) - #endif // INCLUDED_TYPES_GCC_H diff --git a/Engine/source/platform/types.visualc.h b/Engine/source/platform/types.visualc.h index 4b937ddf8..4ccc6ce42 100644 --- a/Engine/source/platform/types.visualc.h +++ b/Engine/source/platform/types.visualc.h @@ -102,10 +102,18 @@ typedef unsigned _int64 U64; // disable warning caused by memory layer // see msdn.microsoft.com "Compiler Warning (level 1) C4291" for more details -#pragma warning(disable: 4291) +#pragma warning(disable: 4291) -// Set MSVC noline attribute +#define TORQUE_FORCEINLINE __forceinline #define TORQUE_NOINLINE __declspec(noinline) +#if __cplusplus >= 201703L +#define TORQUE_CASE_FALLTHROUGH [[fallthrough]]; +#define TORQUE_UNLIKELY [[unlikely]] +#else +#define TORQUE_CASE_FALLTHROUGH __fallthrough +#define TORQUE_UNLIKELY +#endif + #endif // INCLUDED_TYPES_VISUALC_H diff --git a/Engine/source/platformMac/macFileIO.mm b/Engine/source/platformMac/macFileIO.mm index b2549e0f7..dae844163 100644 --- a/Engine/source/platformMac/macFileIO.mm +++ b/Engine/source/platformMac/macFileIO.mm @@ -911,7 +911,7 @@ static bool recurseDumpDirectories(const char *basePath, const char *subPath, Ve //----------------------------------------------------------------------------- bool Platform::dumpDirectories(const char *path, Vector &directoryVector, S32 depth, bool noBasePath) { - bool retVal = recurseDumpDirectories(path, "", directoryVector, 0, depth, noBasePath); + bool retVal = recurseDumpDirectories(path, "", directoryVector, -1, depth, noBasePath); clearExcludedDirectories(); return retVal; } diff --git a/Engine/source/platformWin32/winMath.cpp b/Engine/source/platformWin32/winMath.cpp index 3b6e3ec15..b273d25f0 100644 --- a/Engine/source/platformWin32/winMath.cpp +++ b/Engine/source/platformWin32/winMath.cpp @@ -55,31 +55,36 @@ DefineEngineStringlyVariadicFunction( mathInit, void, 1, 10, "( ... )" } for (argc--, argv++; argc; argc--, argv++) { - if (dStricmp(*argv, "DETECT") == 0) { + const char* str = (*argv).getString(); + if (dStricmp(str, "DETECT") == 0) { Math::init(0); return; } - if (dStricmp(*argv, "C") == 0) { + if (dStricmp(str, "C") == 0) { properties |= CPU_PROP_C; continue; } - if (dStricmp(*argv, "FPU") == 0) { + if (dStricmp(str, "FPU") == 0) { properties |= CPU_PROP_FPU; continue; } - if (dStricmp(*argv, "MMX") == 0) { + if (dStricmp(str, "MMX") == 0) { properties |= CPU_PROP_MMX; continue; } - if (dStricmp(*argv, "3DNOW") == 0) { + if (dStricmp(str, "3DNOW") == 0) { properties |= CPU_PROP_3DNOW; continue; } - if (dStricmp(*argv, "SSE") == 0) { + if (dStricmp(str, "SSE") == 0) { properties |= CPU_PROP_SSE; continue; } - Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", argv->getStringValue()); + if (dStricmp(str, "SSE2") == 0) { + properties |= CPU_PROP_SSE2; + continue; + } + Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", str); } Math::init(properties); } diff --git a/Engine/source/sfx/sfxSource.cpp b/Engine/source/sfx/sfxSource.cpp index abc5b35e1..ac8fd6d19 100644 --- a/Engine/source/sfx/sfxSource.cpp +++ b/Engine/source/sfx/sfxSource.cpp @@ -316,7 +316,7 @@ void SFXSource::initPersistFields() //----------------------------------------------------------------------------- -bool SFXSource::processArguments( S32 argc, ConsoleValueRef *argv ) +bool SFXSource::processArguments( S32 argc, ConsoleValue *argv ) { // Don't allow subclasses of this to be created via script. Force // usage of the SFXSystem functions. @@ -791,6 +791,9 @@ void SFXSource::_setStatus( SFXStatus status ) void SFXSource::_updateVolume( const MatrixF& listener ) { + if (!mDescription) + return; + // Handle fades (compute mFadedVolume). mFadedVolume = mPreFadeVolume; @@ -919,13 +922,19 @@ void SFXSource::_updateVolume( const MatrixF& listener ) void SFXSource::_updatePitch() { + if (!mDescription) + return; + mEffectivePitch = mModulativePitch * mPitch; } //----------------------------------------------------------------------------- void SFXSource::_updatePriority() -{ +{ + if (!mDescription) + return; + mEffectivePriority = mPriority * mModulativePriority; SFXSource* group = getSourceGroup(); diff --git a/Engine/source/sfx/sfxSource.h b/Engine/source/sfx/sfxSource.h index 16ab6fd14..8d6bb129f 100644 --- a/Engine/source/sfx/sfxSource.h +++ b/Engine/source/sfx/sfxSource.h @@ -382,7 +382,7 @@ class SFXSource : public SimGroup /// We overload this to disable creation of /// a source via script 'new'. - virtual bool processArguments( S32 argc, ConsoleValueRef *argv ); + virtual bool processArguments( S32 argc, ConsoleValue *argv ); // Console getters/setters. static bool _setDescription( void *obj, const char *index, const char *data ); diff --git a/Engine/source/sfx/sfxTrack.cpp b/Engine/source/sfx/sfxTrack.cpp index 067a202ca..987650c0b 100644 --- a/Engine/source/sfx/sfxTrack.cpp +++ b/Engine/source/sfx/sfxTrack.cpp @@ -95,7 +95,7 @@ void SFXTrack::initPersistFields() //----------------------------------------------------------------------------- -bool SFXTrack::processArguments( S32 argc, ConsoleValueRef *argv ) +bool SFXTrack::processArguments( S32 argc, ConsoleValue *argv ) { if( typeid( *this ) == typeid( SFXTrack ) ) { diff --git a/Engine/source/sfx/sfxTrack.h b/Engine/source/sfx/sfxTrack.h index c0dc8769a..7ee966d43 100644 --- a/Engine/source/sfx/sfxTrack.h +++ b/Engine/source/sfx/sfxTrack.h @@ -61,7 +61,7 @@ class SFXTrack : public SimDataBlock StringTableEntry mParameters[ MaxNumParameters ]; /// Overload this to disable direct instantiation of this class via script 'new'. - virtual bool processArguments( S32 argc, ConsoleValueRef *argv ); + virtual bool processArguments( S32 argc, ConsoleValue *argv ); public: diff --git a/Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp index 3b0467062..99414d133 100644 --- a/Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/customFeatureGLSL.cpp @@ -238,7 +238,7 @@ void CustomFeatureGLSL::addVertTexCoord(String name) mVars.push_back(newVarHolder); } -void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv) +void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValue * argv) { //do the var/arg fetching here Vector varList; @@ -246,7 +246,7 @@ void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg for (U32 i = 0; i < argc; i++) { - String varName = argv[i].getStringValue(); + String varName = argv[i].getString(); Var* newVar = (Var*)LangElement::find(varName.c_str()); if (!newVar) { @@ -304,7 +304,7 @@ void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg if (!newVar) { //couldn't find that variable, bail out - Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue()); + Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getString()); return; } } diff --git a/Engine/source/shaderGen/GLSL/customFeatureGLSL.h b/Engine/source/shaderGen/GLSL/customFeatureGLSL.h index c2d0191cc..b8358a835 100644 --- a/Engine/source/shaderGen/GLSL/customFeatureGLSL.h +++ b/Engine/source/shaderGen/GLSL/customFeatureGLSL.h @@ -128,5 +128,5 @@ public: void addTexture(String name, String type, String samplerState, U32 arraySize); void addConnector(String name, String type, String elementName); void addVertTexCoord(String name); - void writeLine(String format, S32 argc, ConsoleValueRef* argv); + void writeLine(String format, S32 argc, ConsoleValue* argv); }; diff --git a/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp index c9e797fff..e50661056 100644 --- a/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/customFeatureHLSL.cpp @@ -255,7 +255,7 @@ void CustomFeatureHLSL::addVertTexCoord(String name) mVars.push_back(newVarHolder); } -void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv) +void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValue *argv) { //do the var/arg fetching here Vector varList; @@ -263,7 +263,7 @@ void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg for (U32 i = 0; i < argc; i++) { - String varName = argv[i].getStringValue(); + String varName = argv[i].getString(); Var* newVar = (Var*)LangElement::find(varName.c_str()); if (!newVar) { @@ -321,7 +321,7 @@ void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg if (!newVar) { //couldn't find that variable, bail out - Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue()); + Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getString()); return; } } diff --git a/Engine/source/shaderGen/HLSL/customFeatureHLSL.h b/Engine/source/shaderGen/HLSL/customFeatureHLSL.h index dd1ad0a09..be89aeb50 100644 --- a/Engine/source/shaderGen/HLSL/customFeatureHLSL.h +++ b/Engine/source/shaderGen/HLSL/customFeatureHLSL.h @@ -128,5 +128,5 @@ public: void addTexture(String name, String type, String samplerState, U32 arraySize); void addConnector(String name, String type, String elementName); void addVertTexCoord(String name); - void writeLine(String format, S32 argc, ConsoleValueRef* argv); + void writeLine(String format, S32 argc, ConsoleValue* argv); }; diff --git a/Engine/source/shaderGen/customShaderFeature.cpp b/Engine/source/shaderGen/customShaderFeature.cpp index e17cdc088..25e2975b0 100644 --- a/Engine/source/shaderGen/customShaderFeature.cpp +++ b/Engine/source/shaderGen/customShaderFeature.cpp @@ -189,7 +189,7 @@ bool CustomShaderFeatureData::hasFeature(String name) return false; } -void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef* argv) +void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValue* argv) { #ifdef TORQUE_D3D11 if (GFX->getAdapterType() == GFXAdapterType::Direct3D11) @@ -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), (""), "") diff --git a/Engine/source/shaderGen/customShaderFeature.h b/Engine/source/shaderGen/customShaderFeature.h index 57d91e989..fd76380c4 100644 --- a/Engine/source/shaderGen/customShaderFeature.h +++ b/Engine/source/shaderGen/customShaderFeature.h @@ -77,7 +77,7 @@ public: void addVertTexCoord(String name); bool hasFeature(String name); - void writeLine(String format, S32 argc, ConsoleValueRef *argv); + void writeLine(String format, S32 argc, ConsoleValue *argv); }; #endif diff --git a/Engine/source/sim/actionMap.cpp b/Engine/source/sim/actionMap.cpp index e835273ed..40a41aa06 100644 --- a/Engine/source/sim/actionMap.cpp +++ b/Engine/source/sim/actionMap.cpp @@ -2080,7 +2080,7 @@ static ConsoleDocFragment _ActionMapbind2( DefineEngineStringlyVariadicMethod( ActionMap, bind, bool, 5, 10, "actionMap.bind( device, action, [modifier, spec, mod...], command )" "@hide") { - StringStackWrapper args(argc - 2, argv + 2); + ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2); return object->processBind( args.count(), args, NULL ); } @@ -2136,7 +2136,7 @@ DefineEngineStringlyVariadicMethod( ActionMap, bindObj, bool, 6, 11, "(device, a return false; } - StringStackWrapper args(argc - 3, argv + 2); + ConsoleValueToStringArrayWrapper args(argc - 3, argv + 2); return object->processBind( args.count(), args, simObject ); } diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.tscript index 269362638..dbfa7237d 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelInfo.tscript @@ -143,6 +143,7 @@ function parseMissionGroupForIds( %className, %childGroup ) if(!isObject(%currentGroup)) return ""; + %classIds = ""; for(%i = 0; %i < (%currentGroup).getCount(); %i++) { if( (%currentGroup).getObject(%i).getClassName() $= %className ) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.tscript index 64e2aa268..9bb2457ac 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.tscript @@ -193,6 +193,9 @@ function resetMission() clearServerPaths(); + // TODO: Is this right? + %client = ClientGroup.getObject(0); + // Inform the game code we're resetting. %hasGameMode = callGamemodeFunction("onMissionReset", %client); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/console/guis/console.gui b/Templates/BaseGame/game/core/console/guis/console.gui index 1d6153ce2..3c5c217a6 100644 --- a/Templates/BaseGame/game/core/console/guis/console.gui +++ b/Templates/BaseGame/game/core/console/guis/console.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ConsoleDlg) { +$guiContent = new GuiControl(ConsoleDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/core/console/scripts/console.tscript b/Templates/BaseGame/game/core/console/scripts/console.tscript index 201bcfb92..9a024050d 100644 --- a/Templates/BaseGame/game/core/console/scripts/console.tscript +++ b/Templates/BaseGame/game/core/console/scripts/console.tscript @@ -62,7 +62,7 @@ function ConsoleEntry::eval() && !startsWith(%text, "for(") && !startsWith(%text, "switch(") && !startsWith(%text, "switch$(")) - eval("%result = " @ %text); + %result = eval("return" SPC %text); else eval(%text); $Con::warnVoidAssignment = %oldWarnVoidAssignment; diff --git a/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript b/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript index f7bdf56f9..55100d729 100644 --- a/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript +++ b/Templates/BaseGame/game/core/lighting/scripts/advancedLighting_Shaders.tscript @@ -75,7 +75,7 @@ singleton shaderData( AL_VectorLightShader ) pixVersion = 3.0; }; -new CustomMaterial( AL_VectorLightMaterial ) +singleton CustomMaterial( AL_VectorLightMaterial ) { shader = AL_VectorLightShader; stateBlock = AL_VectorLightState; @@ -149,7 +149,7 @@ singleton shaderData( AL_PointLightShader ) pixVersion = 3.0; }; -new CustomMaterial( AL_PointLightMaterial ) +singleton CustomMaterial( AL_PointLightMaterial ) { shader = AL_PointLightShader; stateBlock = AL_ConvexLightState; @@ -186,7 +186,7 @@ singleton shaderData( AL_SpotLightShader ) pixVersion = 3.0; }; -new CustomMaterial( AL_SpotLightMaterial ) +singleton CustomMaterial( AL_SpotLightMaterial ) { shader = AL_SpotLightShader; stateBlock = AL_ConvexLightState; @@ -205,7 +205,7 @@ new CustomMaterial( AL_SpotLightMaterial ) /// This material is used for generating deferred /// materials for objects that do not have materials. -new Material( AL_DefaultDeferredMaterial ) +singleton Material( AL_DefaultDeferredMaterial ) { // We need something in the first pass else it // won't create a proper material instance. @@ -219,7 +219,7 @@ new Material( AL_DefaultDeferredMaterial ) /// This material is used for generating shadow /// materials for objects that do not have materials. -new Material( AL_DefaultShadowMaterial ) +singleton Material( AL_DefaultShadowMaterial ) { // We need something in the first pass else it // won't create a proper material instance. @@ -255,7 +255,7 @@ singleton shaderData( AL_ParticlePointLightShader ) pixVersion = 3.0; }; -new CustomMaterial( AL_ParticlePointLightMaterial ) +singleton CustomMaterial( AL_ParticlePointLightMaterial ) { shader = AL_ParticlePointLightShader; stateBlock = AL_ConvexLightState; diff --git a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.tscript b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.tscript index cf0080923..055411423 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/postFxManager.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/postFxManager.tscript @@ -59,7 +59,7 @@ function PostFXManager::loadPresetFile() { //Show the dialog and set the flag getLoadFilename($PostFXManager::fileFilter, "PostFXManager::loadPresetHandler"); - $PostFXManager::currentPreset = $Tools::FileDialogs::LastFilePath(); + $PostFXManager::currentPreset = $Tools::FileDialogs::LastFilePath; } function PostFXManager::loadPresetHandler( %filename ) diff --git a/Templates/BaseGame/game/core/rendering/scripts/gfxData/warningTerrainMat.tscript b/Templates/BaseGame/game/core/rendering/scripts/gfxData/warningTerrainMat.tscript index 55b8562ac..f528e285a 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/gfxData/warningTerrainMat.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/gfxData/warningTerrainMat.tscript @@ -1,4 +1,4 @@ -new TerrainMaterial() +singleton TerrainMaterial() { diffuseSize = "200"; detailSize = "10"; diff --git a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript index f496111eb..44ec46555 100644 --- a/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript @@ -15,7 +15,7 @@ function findGameObject(%name) //%assetName = AssetDatabase.getAssetName(%assetId); - if(%assetId $= %name) + if(%assetId $= %name) { %gameObjectAsset = AssetDatabase.acquireAsset(%assetId); @@ -47,7 +47,7 @@ function spawnGameObject(%name, %addToScene) %go.setHidden(false); %go.setScopeAlways(); - if(%addToMissionGroup == true) //save instance when saving level + if(%addToScene == true) //save instance when saving level getScene(0).add(%go); else // clear instance on level exit MissionCleanup.add(%go); diff --git a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript index 29d2f5df6..ee7378bf8 100644 --- a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript @@ -524,7 +524,9 @@ function loadDir(%dir) function loadDirs(%dirPath) { - %dirPath = nextToken(%dirPath, token, ";"); + %dirPath = nextToken(%dirPath, "$token", ";"); + %token = $token; + if (%dirPath !$= "") loadDirs(%dirPath); diff --git a/Templates/BaseGame/game/core/utility/scripts/parseArgs.tscript b/Templates/BaseGame/game/core/utility/scripts/parseArgs.tscript index 51975d635..fcff3efb9 100644 --- a/Templates/BaseGame/game/core/utility/scripts/parseArgs.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/parseArgs.tscript @@ -43,11 +43,11 @@ function popFront(%list, %delim) function parseArgs() { - for ($i = 1; $i < $Game::argc ; $i++) + for (%i = 1; %i < $Game::argc ; %i++) { - $arg = $Game::argv[$i]; - $nextArg = $Game::argv[$i+1]; - $hasNextArg = $Game::argc - $i > 1; + $arg = $Game::argv[%i]; + $nextArg = $Game::argv[%i+1]; + $hasNextArg = $Game::argc - %i > 1; $logModeSpecified = false; // Check for dedicated run @@ -55,7 +55,7 @@ function parseArgs() { $userDirs = $defaultGame; $dirCount = 1; - $isDedicated = true; + %isDedicated = true; }*/ switch$ ($arg) @@ -64,15 +64,15 @@ function parseArgs() case "-dedicated": $userDirs = $defaultGame; $dirCount = 1; - $isDedicated = true; + %isDedicated = true; $Server::Dedicated = true; enableWinConsole(true); $argUsed[%i]++; - + //-------------------- case "-mission": $argUsed[%i]++; - if ($hasNextArg) + if ($hasNextArg) { $missionArg = $nextArg; $argUsed[%i+1]++; @@ -84,7 +84,7 @@ function parseArgs() //-------------------- case "-connect": $argUsed[%i]++; - if ($hasNextArg) + if ($hasNextArg) { $JoinGameAddress = $nextArg; $argUsed[%i+1]++; @@ -93,10 +93,10 @@ function parseArgs() else error("Error: Missing Command Line argument. Usage: -connect "); - + //-------------------- case "-log": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { // Turn on console logging @@ -107,22 +107,22 @@ function parseArgs() } setLogMode($nextArg); $logModeSpecified = true; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -log "); //-------------------- case "-dir": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { // Append the mod to the end of the current list $userDirs = strreplace($userDirs, $nextArg, ""); $userDirs = pushFront($userDirs, $nextArg, ";"); - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; $dirCount++; } else @@ -130,15 +130,15 @@ function parseArgs() //-------------------- // changed the default behavior of this command line arg. It now - // defaults to ONLY loading the game, not tools + // defaults to ONLY loading the game, not tools // default auto-run already loads in tools --SRZ 11/29/07 case "-game": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { // Set the selected dir --NOTE: we no longer allow tools with this argument - /* - if( $isDedicated ) + /* + if( %isDedicated ) { $userDirs = $nextArg; $dirCount = 1; @@ -151,8 +151,8 @@ function parseArgs() */ $userDirs = $nextArg; $dirCount = 1; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; error($userDirs); } else @@ -161,121 +161,121 @@ function parseArgs() //-------------------- case "-console": enableWinConsole(true); - $argUsed[$i]++; + $argUsed[%i]++; //-------------------- case "-jSave": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { echo("Saving event log to journal: " @ $nextArg); saveJournal($nextArg); - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -jSave "); //-------------------- case "-jPlay": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { playJournal($nextArg); - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -jPlay "); - + //-------------------- case "-jPlayToVideo": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $VideoCapture::journalName = $nextArg; $VideoCapture::captureFromJournal = true; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -jPlayToVideo "); - + //-------------------- case "-vidCapFile": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $VideoCapture::fileName = $nextArg; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -vidCapFile "); - + //-------------------- case "-vidCapFPS": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $VideoCapture::fps = $nextArg; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -vidCapFPS "); - + //-------------------- case "-vidCapEncoder": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $VideoCapture::encoder = $nextArg; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -vidCapEncoder "); - + //-------------------- case "-vidCapWidth": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $videoCapture::width = $nextArg; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -vidCapWidth "); - + //-------------------- case "-vidCapHeight": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { $videoCapture::height = $nextArg; - $argUsed[$i+1]++; - $i++; + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -vidCapHeight "); //-------------------- case "-level": - $argUsed[$i]++; + $argUsed[%i]++; if ($hasNextArg) { %hasExt = strpos($nextArg, ".mis"); if(%hasExt == -1) { $levelToLoad = $nextArg @ " "; - - for(%i = $i + 2; %i < $Game::argc; %i++) + + for(%j = %i + 2; %j < $Game::argc; %j++) { - $arg = $Game::argv[%i]; + $arg = $Game::argv[%j]; %hasExt = strpos($arg, ".mis"); - + if(%hasExt == -1) { $levelToLoad = $levelToLoad @ $arg @ " "; @@ -285,14 +285,14 @@ function parseArgs() break; } } - } + } else { $levelToLoad = $nextArg; } - - $argUsed[$i+1]++; - $i++; + + $argUsed[%i+1]++; + %i++; } else error("Error: Missing Command Line argument. Usage: -level "); @@ -300,33 +300,33 @@ function parseArgs() //------------------- case "-worldeditor": $startWorldEditor = true; - $argUsed[$i]++; + $argUsed[%i]++; //------------------- case "-guieditor": $startGUIEditor = true; - $argUsed[$i]++; + $argUsed[%i]++; //------------------- case "-help": $displayHelp = true; - $argUsed[$i]++; + $argUsed[%i]++; //------------------- case "-compileAll": $compileAll = true; - $argUsed[$i]++; - + $argUsed[%i]++; + //------------------- case "-compileTools": $compileTools = true; - $argUsed[$i]++; + $argUsed[%i]++; //------------------- case "-genScript": $genScript = true; - $argUsed[$i]++; - + $argUsed[%i]++; + case "-fullscreen": $cliFullscreen = true; $argUsed[%i]++; @@ -357,36 +357,36 @@ function parseArgs() else error("Error: Missing Command Line argument. Usage: -prefs "); - + //------------------- default: - $argUsed[$i]++; + $argUsed[%i]++; if($userDirs $= "") $userDirs = $arg; } } - + //----------------------------------------------- // Play journal to video file? if ($VideoCapture::captureFromJournal && $VideoCapture::journalName !$= "") - { + { if ($VideoCapture::fileName $= "") - $VideoCapture::fileName = $VideoCapture::journalName; - + $VideoCapture::fileName = $VideoCapture::journalName; + if ($VideoCapture::encoder $= "") $VideoCapture::encoder = "THEORA"; - + if ($VideoCapture::fps $= "") $VideoCapture::fps = 30; - + if ($videoCapture::width $= "") $videoCapture::width = 0; - + if ($videoCapture::height $= "") $videoCapture::height = 0; - - playJournalToVideo( $VideoCapture::journalName, $VideoCapture::fileName, - $VideoCapture::encoder, $VideoCapture::fps, + + playJournalToVideo( $VideoCapture::journalName, $VideoCapture::fileName, + $VideoCapture::encoder, $VideoCapture::fps, $videoCapture::width SPC $videoCapture::height ); } -} \ No newline at end of file +} diff --git a/Templates/BaseGame/game/core/utility/scripts/scene.tscript b/Templates/BaseGame/game/core/utility/scripts/scene.tscript index 795d541f3..4062c4749 100644 --- a/Templates/BaseGame/game/core/utility/scripts/scene.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/scene.tscript @@ -1,8 +1,5 @@ function callGamemodeFunction(%gameModeFuncName, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6) { - if(%data !$= "") - %data = "\""@%data@"\""; - %activeSceneCount = getSceneCount(); %hasGameMode = 0; diff --git a/Templates/BaseGame/game/data/ExampleModule/GUIs/ExampleGUI.gui b/Templates/BaseGame/game/data/ExampleModule/GUIs/ExampleGUI.gui index 48bf13f92..396b5b291 100644 --- a/Templates/BaseGame/game/data/ExampleModule/GUIs/ExampleGUI.gui +++ b/Templates/BaseGame/game/data/ExampleModule/GUIs/ExampleGUI.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ExampleGUI) +$guiContent = new GuiControl(ExampleGUI) { position = "0 0"; extent = "100 100"; diff --git a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui b/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui index 5fa0093da..6a98fe6d7 100644 --- a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui +++ b/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(IODropdownDlg) { +$guiContent = new GuiControl(IODropdownDlg) { profile = "GuiDefaultProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui b/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui index 0e863fff5..c13008f11 100644 --- a/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(recordingsDlg) { +$guiContent = new GuiControl(recordingsDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui index e6018fdb1..fc2ffc57e 100644 --- a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ChooseLevelDlg) { +$guiContent = new GuiControl(ChooseLevelDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui b/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui index 291f3a356..cfd2c3e96 100644 --- a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui +++ b/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GuiMusicPlayer) { +$guiContent = new GuiControl(GuiMusicPlayer) { isContainer = "1"; Profile = "GuiWindowProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index 29325c1b6..4343fe7ad 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(JoinServerMenu) { +$guiContent = new GuiControl(JoinServerMenu) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/data/UI/guis/loadingGui.gui b/Templates/BaseGame/game/data/UI/guis/loadingGui.gui index d20abd28d..83357901c 100644 --- a/Templates/BaseGame/game/data/UI/guis/loadingGui.gui +++ b/Templates/BaseGame/game/data/UI/guis/loadingGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiChunkedBitmapCtrl(LoadingGui) { +$guiContent = new GuiChunkedBitmapCtrl(LoadingGui) { bitmapAsset = "UI:background_dark_image"; useVariable = "0"; tile = "0"; diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index ea3dbfae0..4cc06b26e 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -1,7 +1,7 @@ exec( "tools/gui/profiles.ed.tscript" ); //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { +$guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { bitmapAsset = "UI:background_dark_image"; useVariable = "0"; tile = "0"; diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui index 8dd356d97..a78ae98d5 100644 --- a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MessageBoxDlg) { +$guiContent = new GuiControl(MessageBoxDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/netGraphGui.gui b/Templates/BaseGame/game/data/UI/guis/netGraphGui.gui index b034a447e..be8ba1233 100644 --- a/Templates/BaseGame/game/data/UI/guis/netGraphGui.gui +++ b/Templates/BaseGame/game/data/UI/guis/netGraphGui.gui @@ -73,7 +73,7 @@ new GuiControlProfile (NetGraphPacketLossProfile) }; //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(NetGraphGui) { +$guiContent = new GuiControl(NetGraphGui) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsDlg.gui b/Templates/BaseGame/game/data/UI/guis/optionsDlg.gui index 3c78ac116..b2758c32c 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(OptionsDlg) { +$guiContent = new GuiControl(OptionsDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 5d357e9fd..9b76cb979 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(OptionsMenu) { +$guiContent = new GuiControl(OptionsMenu) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 416bbe36b..63488c8d7 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -276,11 +276,8 @@ function OptionsMenu::applyDisplaySettings(%this) // Change the device. if ( %newDevice !$= $pref::Video::displayDevice ) { - if ( %testNeedApply ) - return true; - $pref::Video::displayDevice = %newDevice; - if( %newAdapter !$= getDisplayDeviceInformation() ) + if( %newDevice !$= getDisplayDeviceInformation() ) MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." ); $changingDisplayDevice = %newDevice; @@ -368,10 +365,7 @@ function OptionsMenu::applyGraphicsSettings(%this) // Check the anisotropic filtering. %level = OptionsMenuSettingsList.getCurrentOption(10); if ( %level != $pref::Video::defaultAnisotropy ) - { - if ( %testNeedApply ) - return true; - + { $pref::Video::defaultAnisotropy = %level; } @@ -418,9 +412,6 @@ function updateDisplaySettings() if ( %newMode !$= $pref::Video::mode || %newDeviceID != $pref::Video::deviceId || %newVsync != $pref::Video::disableVerticalSync || %newDeviceMode != $pref::Video::deviceMode) { - if ( %testNeedApply ) - return true; - //****Edge Case Hack // If we're in fullscreen mode and switching to a different monitor at the // same resolution and maintaining fullscreen, GFX...WindowTarget::resetMode() @@ -433,7 +424,7 @@ function updateDisplaySettings() $pref::Video::deviceId = %newDeviceID; $pref::Video::deviceMode = $Video::ModeBorderless; %tmpModeStr = Canvas.getMonitorMode(%newDeviceID, 0); - Canvas.setVideoMode(%tmpModeStr.x, %tmpModeStr.y, false, 32, getWord(%tmpModeStr, $WORD::REFRESH), %aa); + Canvas.setVideoMode(%tmpModeStr.x, %tmpModeStr.y, false, 32, getWord(%tmpModeStr, $WORD::REFRESH), %newFSAA); } $pref::Video::mode = %newMode; @@ -459,6 +450,8 @@ function OptionsMenu::populateAudioSettingsList(%this) %buffer = sfxGetAvailableDevices(); %count = getRecordCount( %buffer ); %audioDriverList = ""; + %audioProviderList = ""; + %audioDeviceList = ""; $currentAudioProvider = $currentAudioProvider $= "" ? $pref::SFX::provider : $currentAudioProvider; diff --git a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui b/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui index bc0e5675e..77356fcdb 100644 --- a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(PauseMenu) { +$guiContent = new GuiControl(PauseMenu) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/data/UI/guis/profiler.gui b/Templates/BaseGame/game/data/UI/guis/profiler.gui index 46628c6df..c6d97a26f 100644 --- a/Templates/BaseGame/game/data/UI/guis/profiler.gui +++ b/Templates/BaseGame/game/data/UI/guis/profiler.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ProfilerGui) { +$guiContent = new GuiControl(ProfilerGui) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/data/UI/guis/profiler.tscript b/Templates/BaseGame/game/data/UI/guis/profiler.tscript index bc73338bf..402f7b1f1 100644 --- a/Templates/BaseGame/game/data/UI/guis/profiler.tscript +++ b/Templates/BaseGame/game/data/UI/guis/profiler.tscript @@ -101,7 +101,7 @@ function showMetics(%var) GlobalActionMap.bind(keyboard, "ctrl F2", showMetics); -%guiContent = new GuiControl(FrameOverlayGui) { +$guiContent = new GuiControl(FrameOverlayGui) { profile = "GuiModelessDialogProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/data/UI/guis/remapConfirmDlg.gui b/Templates/BaseGame/game/data/UI/guis/remapConfirmDlg.gui index 217a2dd74..b7eda83e0 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapConfirmDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/remapConfirmDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(RemapConfirmDlg) { +$guiContent = new GuiControl(RemapConfirmDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui index e8f76b642..82f4c0130 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(RemapDlg) { +$guiContent = new GuiControl(RemapDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/data/UI/guis/startupGui.gui b/Templates/BaseGame/game/data/UI/guis/startupGui.gui index cc6aee78b..647fc1b03 100644 --- a/Templates/BaseGame/game/data/UI/guis/startupGui.gui +++ b/Templates/BaseGame/game/data/UI/guis/startupGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiFadeinBitmapCtrl(StartupGui) { +$guiContent = new GuiFadeinBitmapCtrl(StartupGui) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/data/UI/sounds/buttonClick.asset.taml b/Templates/BaseGame/game/data/UI/sounds/buttonClick.asset.taml new file mode 100644 index 000000000..99773fd2d --- /dev/null +++ b/Templates/BaseGame/game/data/UI/sounds/buttonClick.asset.taml @@ -0,0 +1 @@ + diff --git a/Templates/BaseGame/game/data/UI/sounds/buttonHover.asset.taml b/Templates/BaseGame/game/data/UI/sounds/buttonHover.asset.taml new file mode 100644 index 000000000..00b1af405 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/sounds/buttonHover.asset.taml @@ -0,0 +1 @@ + diff --git a/Templates/BaseGame/game/data/defaults.tscript b/Templates/BaseGame/game/data/defaults.tscript index 6e6a2413c..d45116ff9 100644 --- a/Templates/BaseGame/game/data/defaults.tscript +++ b/Templates/BaseGame/game/data/defaults.tscript @@ -27,7 +27,7 @@ $sceneLighting::cacheSize = 20000; $sceneLighting::purgeMethod = "lastCreated"; $sceneLighting::cacheLighting = 1; -$pref::Video::displayDevice = "D3D11"; +$pref::Video::displayDevice = ($platform $= "windows") ? "D3D11" : "OpenGL"; $pref::Video::disableVerticalSync = 1; $pref::Video::defaultFenceCount = 0; $pref::Video::screenShotSession = 0; diff --git a/Templates/BaseGame/game/data/gameUI/GUIs/playGui.gui b/Templates/BaseGame/game/data/gameUI/GUIs/playGui.gui index e9522b42f..4783b51a7 100644 --- a/Templates/BaseGame/game/data/gameUI/GUIs/playGui.gui +++ b/Templates/BaseGame/game/data/gameUI/GUIs/playGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GameTSCtrl(PlayGui) { +$guiContent = new GameTSCtrl(PlayGui) { cameraZRot = "0"; forceFOV = "0"; reflectPriority = "1"; diff --git a/Templates/BaseGame/game/main.tscript.in b/Templates/BaseGame/game/main.tscript.in index f2cae0249..5d5569e7d 100644 --- a/Templates/BaseGame/game/main.tscript.in +++ b/Templates/BaseGame/game/main.tscript.in @@ -37,9 +37,8 @@ else //If nothing else set a main menu, try to do so now if(!isObject(Canvas.getContent())) { - %mainMenuGUI = ProjectSettings.value("UI/mainMenuName"); - if (isObject( %mainMenuGUI )) - Canvas.setContent( %mainMenuGUI ); + if (isObject( ProjectSettings.value("UI/mainMenuName") )) + Canvas.setContent( ProjectSettings.value("UI/mainMenuName") ); } } diff --git a/Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui b/Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui new file mode 100644 index 000000000..6d40a9164 --- /dev/null +++ b/Templates/BaseGame/game/tools/MainEditor/guis/MainEditorWindow.gui @@ -0,0 +1,485 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiContainer(NewEditorGui) { + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1920 1080"; + minExtent = "8 8"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "1"; + enabled = "1"; + + new GuiSplitContainer(NewEditorGuiLayout) { + orientation = "Vertical"; + splitterSize = "2"; + splitPoint = "1661 100"; + fixedPanel = "None"; + useMinExtent="0"; + fixedSize = "260"; + docking = "None"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1921 1081"; + minExtent = "64 64"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiPanel() { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1659 1081"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "Panel1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiSplitContainer(Editor_ToolsMainSplit) { + orientation = "Vertical"; + splitterSize = "2"; + splitPoint = "230 100"; + fixedPanel = "None"; + useMinExtent="0"; + fixedSize = "1429"; + docking = "None"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1659 1081"; + minExtent = "64 64"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiPanel(Editor_ToolSidebarPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "228 1081"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "Panel1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiWindowCtrl(Editor_ToolsSidebarWindow) { + text = "Tool Settings"; + resizeWidth = "0"; + resizeHeight = "0"; + canMove = "0"; + canClose = "0"; + canMinimize = "0"; + canMaximize = "0"; + canCollapse = "0"; + edgeSnap = "1"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "228 1081"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiWindowProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + new GuiPanel(Editor_MainWindowPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "232 0"; + extent = "1427 1081"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "panel2"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiSplitContainer(Editor_MainViewSplit) { + orientation = "Horizontal"; + splitterSize = "2"; + splitPoint = "182 745"; + fixedPanel = "None"; + useMinExtent="0"; + fixedSize = "273"; + docking = "None"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1427 1081"; + minExtent = "64 64"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiPanel(Editor_MainViewPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1427 743"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "Panel1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiTabBookCtrl(Editor_MainViewTabBook) { + tabPosition = "Top"; + tabMargin = "7"; + minTabWidth = "64"; + tabHeight = "20"; + allowReorder = "0"; + defaultPage = "-1"; + selectedPage = "-1"; + frontTabPadding = "0"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "1427 743"; + minExtent = "8 2"; + horizSizing = "width"; + vertSizing = "height"; + profile = "ToolsGuiTabBookProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl(Editor_InspectorSidebarButton) { + bitmap = "tools/gui/images/iconAdd.png"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "1411 61"; + extent = "15 15"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl(Editor_ToolsSidebarButton) { + bitmap = "tools/gui/images/iconAdd.png"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "0 61"; + extent = "15 15"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl(Editor_AssetBrowserButton) { + bitmap = "tools/gui/images/iconAdd.png"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "1411 725"; + extent = "15 15"; + minExtent = "8 2"; + horizSizing = "left"; + vertSizing = "top"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiBitmapButtonCtrl(Editor_VisibilityOptionsButton) { + bitmap = "tools/gui/images/visible"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "16 30"; + extent = "18 18"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + new GuiPanel(Editor_AssetBrowserPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 747"; + extent = "1427 334"; + minExtent = "16 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "panel2"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + }; + }; + }; + new GuiPanel(Editor_InspectorPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "1663 0"; + extent = "258 1081"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "panel2"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiSplitContainer() { + orientation = "Horizontal"; + splitterSize = "2"; + splitPoint = "182 556"; + fixedPanel = "None"; + useMinExtent="0"; + fixedSize = "100"; + docking = "None"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "258 1081"; + minExtent = "64 64"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiPanel(Editor_SceneTreePanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 0"; + extent = "258 554"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "Panel1"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiPanel(Editor_PropertiesPanel) { + docking = "Client"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 558"; + extent = "258 523"; + minExtent = "0 0"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "panel2"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorPalette.gui b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorPalette.gui index 0963ae68f..dbee21d1e 100644 --- a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorPalette.gui +++ b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorPalette.gui @@ -3,7 +3,7 @@ // Copyright (C) - Violent Tulip //----------------------------------------------------------------------------- -%paletteId = new GuiControl(VPathEditorPalette) { +$paletteId = new GuiControl(VPathEditorPalette) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui index 76fa8aff7..57651df52 100644 --- a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui @@ -3,7 +3,7 @@ // Copyright (C) - Violent Tulip //----------------------------------------------------------------------------- -%guiContent = new GuiControl(VPathEditorToolbar) +$guiContent = new GuiControl(VPathEditorToolbar) { canSaveDynamicFields = "0"; internalName = "VPathEditorToolbar"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui index 10bd0fe35..4c684b6ff 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditor.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(VerveEditorGui) { +$guiContent = new GuiControl(VerveEditorGui) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorGroupBuilder.gui b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorGroupBuilder.gui index 7b041f7f6..19076f551 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorGroupBuilder.gui +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorGroupBuilder.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(VerveEditorGroupBuilderGUI) { +$guiContent = new GuiControl(VerveEditorGroupBuilderGUI) { isContainer = "1"; Profile = "GuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorImportPathNodes.gui b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorImportPathNodes.gui index 6ec7b430c..9309ee64f 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorImportPathNodes.gui +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorImportPathNodes.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(VerveEditorImportPathNodesGUI) { +$guiContent = new GuiControl(VerveEditorImportPathNodesGUI) { isContainer = "1"; Profile = "GuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorPreferences.gui b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorPreferences.gui index 31579a5fb..417f15908 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorPreferences.gui +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/VerveEditorPreferences.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(VerveEditorPreferenceGui) { +$guiContent = new GuiControl(VerveEditorPreferenceGui) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "GuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Controller/VControllerProperties.tscript b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Controller/VControllerProperties.tscript index b3bd39d5c..3fd8b8046 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Controller/VControllerProperties.tscript +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Controller/VControllerProperties.tscript @@ -59,6 +59,7 @@ function VControllerPropertyList::InspectObject( %this, %object ) } %dataFieldCount = %object.getDataFieldCount(); + %dataFieldList = ""; for ( %i = 0; %i < %dataFieldCount; %i++ ) { // Add To List. diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VDirectorGroup.tscript b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VDirectorGroup.tscript index 9360f22d0..c47103b8f 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VDirectorGroup.tscript +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VDirectorGroup.tscript @@ -22,7 +22,7 @@ function VDirectorGroup::PopulateBuildStack( %this, %stack ) function VDirectorGroup::ResolveBuildStack( %this, %stack ) { - Parent::ResolveBuildStack( %this, %stack, %groupObject ); + Parent::ResolveBuildStack( %this, %stack ); // Find the Track Toggle. %directorTrackCheckBox = %stack.findObjectByInternalName( "DirectorTrackToggle", true ); diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSceneObjectGroup.tscript b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSceneObjectGroup.tscript index 7483ea209..209c329fc 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSceneObjectGroup.tscript +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSceneObjectGroup.tscript @@ -62,7 +62,7 @@ function VSceneObjectGroup::PopulateBuildStack( %this, %stack ) function VSceneObjectGroup::ResolveBuildStack( %this, %stack ) { - Parent::ResolveBuildStack( %this, %stack, %groupObject ); + Parent::ResolveBuildStack( %this, %stack ); // Fetch the Controller. %controller = %this.getRoot(); diff --git a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSpawnSphereGroup.tscript b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSpawnSphereGroup.tscript index cd2913ad9..de8280d60 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSpawnSphereGroup.tscript +++ b/Templates/BaseGame/game/tools/VerveEditor/Scripts/Groups/VSpawnSphereGroup.tscript @@ -31,7 +31,7 @@ function VSceneObjectGroup::PopulateBuildStack( %this, %stack ) function VSceneObjectGroup::ResolveBuildStack( %this, %stack ) { - VGroup::ResolveBuildStack( %this, %stack, %groupObject ); + VGroup::ResolveBuildStack( %this, %stack ); // Fetch the Controller. %controller = %this.getRoot(); diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/addModuleWindow.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/addModuleWindow.gui index e8f35a13a..d6f2acc1f 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/addModuleWindow.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/addModuleWindow.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_AddModule) { +$guiContent = new GuiControl(AssetBrowser_AddModule) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/addPackageWindow.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/addPackageWindow.gui index 48a48f5be..1bf51e529 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/addPackageWindow.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/addPackageWindow.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_AddPackage) { +$guiContent = new GuiControl(AssetBrowser_AddPackage) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui index fc815d5cb..57b021106 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetBrowser.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser) { +$guiContent = new GuiControl(AssetBrowser) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui index 103d48901..0f725dbd8 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImport.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetImportCtrl) { +$guiContent = new GuiControl(AssetImportCtrl) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportConfigEditor.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportConfigEditor.gui index 4eb1432be..a3345a24a 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportConfigEditor.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportConfigEditor.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetImportConfigEditor) { +$guiContent = new GuiControl(AssetImportConfigEditor) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportLog.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportLog.gui index 14935f2b1..81aca8284 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportLog.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetImportLog.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowserImportLog) { +$guiContent = new GuiControl(AssetBrowserImportLog) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetNameEdit.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetNameEdit.gui index e99e12118..4e6ddfe69 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/assetNameEdit.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetNameEdit.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_assetNameEdit) { +$guiContent = new GuiControl(AssetBrowser_assetNameEdit) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui new file mode 100644 index 000000000..803f71ba5 --- /dev/null +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/assetPreviewButtonsTemplate.gui @@ -0,0 +1,270 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiControl(AssetPreviewButtonsTemplate) { + position = "0 0"; + extent = "1024 768"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + canSave = "1"; + canSaveDynamicFields = "1"; + + new GuiControl() { + position = "0 0"; + extent = "100 124"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "ShapeAssetPreviewButton"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiObjectView() { + shapeFile = "data/Blockout_Basics/Walls/DoorWall2x2.fbx"; + mountedNode = "mount0"; + lightColor = "1 1 1 1"; + lightAmbient = "0.5 0.5 0.5 1"; + lightDirection = "0 0.707 -0.707"; + orbitDiststance = "5"; + minOrbitDiststance = "141.715"; + maxOrbitDiststance = "5"; + cameraSpeed = "0.01"; + cameraRotation = "0 0 0"; + cameraZRot = "0"; + forceFOV = "0"; + reflectPriority = "0"; + renderStyle = "standard"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "7 4"; + extent = "80 80"; + minExtent = "8 8"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "ToolsGuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "shapeAssetView"; + class = "AssetPreviewControl"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiBitmapButtonCtrl() { + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "0"; + buttonType = "ToggleButton"; + useMouseEvents = "0"; + position = "0 0"; + extent = "80 80"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + internalName="AssetPreviewBorderButton"; + }; + }; + new GuiButtonCtrl() { + groupNum = "0"; + buttonType = "RadioButton"; + useMouseEvents = "1"; + position = "0 0"; + extent = "100 104"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiThumbHighlightButtonProfile"; + visible = "1"; + active = "1"; + command = "AssetBrowser.updateSelection( $ThisControl.getParent().assetName, $ThisControl.getParent().moduleName );"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "\n20540"; + hovertime = "1000"; + isContainer = "0"; + internalName = "Button"; + class = "AssetPreviewButton"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextEditCtrl() { + historySize = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + password = "0"; + passwordMask = "*"; + text = "DoorWall2x2"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 84"; + extent = "100 18"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiTextEditProfile"; + visible = "1"; + active = "0"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "AssetNameLabel"; + class = "AssetNameField"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; + new GuiControl() { + position = "102 0"; + extent = "100 124"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiDefaultProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "GeneralAssetPreviewButton"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiBitmapButtonCtrl() { + bitmap = "Data/Blockout_Basics/Walls/WallGrid2x2_Albedo.png"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "0"; + masked = "0"; + groupNum = "-1"; + buttonType = "PushButton"; + useMouseEvents = "0"; + position = "10 4"; + extent = "80 80"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + internalName = "assetPreviewImage"; + canSave = "1"; + canSaveDynamicFields = "0"; + + new GuiBitmapButtonCtrl() { + bitmap = "tools/materialEditor/gui/cubemapBtnBorder"; + bitmapMode = "Stretched"; + autoFitExtents = "0"; + useModifiers = "0"; + useStates = "1"; + masked = "0"; + groupNum = "0"; + buttonType = "ToggleButton"; + useMouseEvents = "0"; + position = "0 0"; + extent = "80 80"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiButtonProfile"; + visible = "1"; + active = "1"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + internalName="AssetPreviewBorderButton"; + }; + }; + new GuiButtonCtrl() { + groupNum = "0"; + buttonType = "RadioButton"; + useMouseEvents = "1"; + position = "0 0"; + extent = "100 104"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "ToolsGuiThumbHighlightButtonProfile"; + visible = "1"; + active = "1"; + command = "AssetBrowser.updateSelection( $ThisControl.getParent().assetName, $ThisControl.getParent().moduleName );"; + tooltipProfile = "GuiToolTipProfile"; + tooltip = "\n20550"; + hovertime = "1000"; + isContainer = "0"; + internalName = "Button"; + class = "AssetPreviewButton"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + new GuiTextEditCtrl() { + historySize = "0"; + tabComplete = "0"; + sinkAllKeyEvents = "0"; + password = "0"; + passwordMask = "*"; + text = "WallGrid2x2"; + maxLength = "1024"; + margin = "0 0 0 0"; + padding = "0 0 0 0"; + anchorTop = "1"; + anchorBottom = "0"; + anchorLeft = "1"; + anchorRight = "0"; + position = "0 84"; + extent = "100 18"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "bottom"; + profile = "GuiTextEditProfile"; + visible = "1"; + active = "0"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "1"; + internalName = "AssetNameLabel"; + class = "AssetNameField"; + canSave = "1"; + canSaveDynamicFields = "0"; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/createNewCollectionSet.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/createNewCollectionSet.gui index faa48bd6e..9317d8bec 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/createNewCollectionSet.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/createNewCollectionSet.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(CreateNewCollectionSetCtrl) { +$guiContent = new GuiControl(CreateNewCollectionSetCtrl) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/editAsset.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/editAsset.gui index 180b4b5d7..9ac2e2ef2 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/editAsset.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/editAsset.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_editAsset) { +$guiContent = new GuiControl(AssetBrowser_editAsset) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/editModule.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/editModule.gui index 18927399f..c2a59f6ef 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/editModule.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/editModule.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_editModule) { +$guiContent = new GuiControl(AssetBrowser_editModule) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/gameObjectCreator.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/gameObjectCreator.gui index ade837912..8600ad43f 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/gameObjectCreator.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/gameObjectCreator.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GameObjectCreator) { +$guiContent = new GuiControl(GameObjectCreator) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/looseFileAudit.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/looseFileAudit.gui index b4d6d1cce..2bc3d46ee 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/looseFileAudit.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/looseFileAudit.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(LooseFileAudit) { +$guiContent = new GuiControl(LooseFileAudit) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/newAsset.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/newAsset.gui index 722df448d..c8b262973 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/newAsset.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/newAsset.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_newAsset) { +$guiContent = new GuiControl(AssetBrowser_newAsset) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/newComponentAsset.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/newComponentAsset.gui index 0a44d213e..02e70c276 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/newComponentAsset.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/newComponentAsset.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_newComponentAsset) { +$guiContent = new GuiControl(AssetBrowser_newComponentAsset) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/newFolder.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/newFolder.gui index ff1509cb4..7030b5e40 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/newFolder.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/newFolder.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_newFolder) { +$guiContent = new GuiControl(AssetBrowser_newFolder) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/selectModule.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/selectModule.gui index 7a6bcb337..1253b9643 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/selectModule.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/selectModule.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_SelectModule) { +$guiContent = new GuiControl(AssetBrowser_SelectModule) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/selectPackage.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/selectPackage.gui index abf0c48f4..017b19750 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/selectPackage.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/selectPackage.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssetBrowser_SelectPackage) { +$guiContent = new GuiControl(AssetBrowser_SelectPackage) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/guis/selectPath.gui b/Templates/BaseGame/game/tools/assetBrowser/guis/selectPath.gui index ea8b37b9f..b150bbf23 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/guis/selectPath.gui +++ b/Templates/BaseGame/game/tools/assetBrowser/guis/selectPath.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(SelectAssetPath) { +$guiContent = new GuiControl(SelectAssetPath) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript index 0d63f23d4..ec2d0db4d 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript @@ -263,6 +263,8 @@ function AssetBrowser::selectAsset( %this, %asset ) //eval("materialEd_previewMaterial." @ %propertyField @ " = " @ %value @ ";"); if( AssetBrowser.returnType $= "name" ) { + // TODO! + %name = ""; eval( "" @ AssetBrowser.selectCallback @ "(" @ %name @ ");"); } else @@ -689,6 +691,7 @@ function AssetBrowser::loadDirectories( %this ) //Remove any modules that have no assets if we have that filter on if(%this.onlyShowModulesWithAssets) { + %modulesList = ModuleDatabase.findModules(); for(%i=0; %i < getWordCount(%modulesList); %i++) { %moduleName = getWord(%modulesList, %i).ModuleId; @@ -943,6 +946,13 @@ function AssetBrowser::toggleTagFilterPopup(%this) //now, add the asset's category %assetType = AssetDatabase.getAssetCategory(%assetId); + // TODO? + %text = ""; + %var = ""; + %cmd = ""; + %textLength = strlen(%text); + // end todo + %checkBox = new GuiCheckBoxCtrl() { canSaveDynamicFields = "0"; @@ -1003,6 +1013,9 @@ function AssetBrowser::reImportAsset(%this) //if(%assetType $= "ImageAsset") // %filters = ""; + //TODO + %currentFile = ""; + %dlg = new OpenFileDialog() { Filters = "(All Files (*.*)|*.*|"; @@ -1047,7 +1060,7 @@ function AssetBrowserPreviewButton::onRightClick(%this) EditAssetPopup.enableItem(7, true); //Is it an editable type? - if(%assetType $= "ImageAsset" /*|| %assetType $= "GameObjectAsset"*/ || %assetType $= "CppAsset" || %assetType $= "SoundAsset") + if(%assetType $= "ImageAsset" /*|| %assetType $= "GameObjectAsset"*/ || %assetType $= "CppAsset") { EditAssetPopup.enableItem(0, false); } diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript index c4de919f9..a65a0af7b 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImport.tscript @@ -277,6 +277,9 @@ function AssetBrowser::onDropFolder(%this, %filePath) //First, we wanna scan to see if we have modules to contend with. If we do, we'll just plunk them in wholesale //and not process their contents. + // TODO + %fileExt = ""; + //If not modules, it's likely an art pack or other mixed files, so we'll import them as normal if( (%fileExt $= ".png") || (%fileExt $= ".jpg") || (%fileExt $= ".bmp") || (%fileExt $= ".dds") ) %this.importAssetListArray.add("ImageAsset", %filePath); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript index 48df680f8..30eac0209 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetImportConfig.tscript @@ -142,6 +142,7 @@ function ImportAssetOptionsWindow::editImportSettings(%this, %assetItem) %filePath = %assetItem.filePath; %assetName = %assetItem.assetName; %assetConfigObj = %assetItem.importConfig; + %optionsObj = %assetItem.optionsObj; // TODO IS THIS RIGHT ImportOptionsList.startGroup("Asset"); ImportOptionsList.addField("AssetName", "Asset Name", "string", "", "NewAsset", "", %assetItem); @@ -405,6 +406,7 @@ function ImportAssetConfigEditorWindow::editConfig(%this) function ImportAssetConfigEditorWindow::deleteConfig(%this) { + %configList = ImportAssetConfigSettingsList; for(%i=0; %i < %configList.count(); %i++) { diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript index 3e3c08fd2..6488b319f 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/component.tscript @@ -110,7 +110,7 @@ function AssetBrowser::renameComponentAsset(%this, %assetDef, %newAssetId, %orig %line = %file.readLine(); %line = trim( %line ); - %editedFileContents = %editedFileContents @ strreplace(%line, %originalAssetName, %newName) @ "\n"; + %editedFileContents = %editedFileContents @ strreplace(%line, %originalName, %newName) @ "\n"; } %file.close(); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript index a2686fd37..66f7cb64a 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/cpp.tscript @@ -50,6 +50,8 @@ function AssetBrowser::createCpp(%this) TamlWrite(%asset, %tamlpath);*/ + %tamlpath = %assetPath @ %assetName @ ".asset.taml"; + %moduleDef = ModuleDatabase.findModule(%moduleName, 1); AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath); diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript index 9f1a62a40..e46e891c7 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/level.tscript @@ -137,7 +137,7 @@ function AssetBrowser::buildLevelAssetPreview(%this, %assetDef, %previewData) %previewData.assetPath = %assetDef.getLevelPath(); %previewData.doubleClickCommand = "schedule( 1, 0, \"EditorOpenMission\", "@%assetDef@");"; - %levelPreviewImage = %assetDesc.PreviewImage; + %levelPreviewImage = %assetDef.PreviewImage; if(isFile(%levelPreviewImage)) %previewData.previewImage = %levelPreviewImage; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript index 78003103f..1bf590f80 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/script.tscript @@ -49,8 +49,7 @@ function AssetBrowser::importScriptAsset(%this, %assetId) function AssetBrowser::onScriptAssetEditorDropped(%this, %assetDef, %position) { - if(!isObject(%dropTarget)) - return; + } //Renames the asset diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript index 1908e3f23..7764376b4 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.tscript @@ -42,6 +42,10 @@ function AssetBrowser::editShapeAsset(%this, %assetDef) ShapeEditorPlugin.openShapeAsset(%assetDef); } +function AssetBrowser::onShapeAssetChanged(%this, %assetDef) +{ +} + function AssetBrowser::deleteShapeAsset(%this, %assetDef) { @@ -340,7 +344,7 @@ function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position) %newStatic = new TSStatic() { - position = %pos; + position = %position; shapeAsset = %assetId; }; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript index c32222568..3322964bc 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/sound.tscript @@ -1,13 +1,36 @@ +function AssetBrowser::editSoundAsset(%this, %assetDef) +{ + if (isObject($PreviewSoundSource)) + sfxStop($PreviewSoundSource); + $PreviewSoundSource = %assetDef.playSound(); +} + +function AssetBrowser::onSoundAssetChanged(%this, %assetDef) +{ + if (isObject($PreviewSoundSource)) + sfxStop($PreviewSoundSource); +} + function AssetBrowser::buildSoundAssetPreview(%this, %assetDef, %previewData) { %previewData.assetName = %assetDef.assetName; %previewData.assetPath = %assetDef.soundFilePath; - //%previewData.doubleClickCommand = "EditorOpenFileInTorsion( "@%previewData.assetPath@", 0 );"; if(%this.selectMode) + { %previewData.doubleClickCommand = "AssetBrowser.selectAsset( AssetBrowser.selectedAsset );"; + } else + { + if(EditorSettings.value("Assets/Browser/doubleClickAction", "Edit Asset") $= "Edit Asset") + { %previewData.doubleClickCommand = "AssetBrowser.editAsset( "@%assetDef@" );"; + } + else + { + %previewData.doubleClickCommand = "AssetBrowser.onSoundAssetEditorDropped( "@%assetDef@" );"; + } + } %previewData.previewImage = "ToolsModule:soundIcon_image"; @@ -38,7 +61,7 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position) %newSFXEmitter = new SFXEmitter() { position = %pos; - fileName = %assetDef.getSoundPath(); + soundAsset = %assetDef.getAssetId(); pitch = %assetDef.pitchAdjust; volume = %assetDef.volumeAdjust; }; @@ -50,4 +73,28 @@ function AssetBrowser::onSoundAssetEditorDropped(%this, %assetDef, %position) EWorldEditor.isDirty = true; +} + +function GuiInspectorTypeShapeAssetPtr::onControlDropped( %this, %payload, %position ) +{ + Canvas.popDialog(EditorDragAndDropLayer); + + // Make sure this is a color swatch drag operation. + if( !%payload.parentGroup.isInNamespaceHierarchy( "AssetPreviewControlType_AssetDrop" ) ) + return; + + %assetType = %payload.assetType; + + if(%assetType $= "SoundAsset") +{ + %module = %payload.moduleName; + %asset = %payload.assetName; + + %targetComponent = %this.targetObject; + %targetComponent.soundAsset = %module @ ":" @ %asset; + + //Inspector.refresh(); + } + + EWorldEditor.isDirty = true; } \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript index 1a18b7ed1..dff204024 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/stateMachine.tscript @@ -86,6 +86,9 @@ function AssetBrowser::editStateMachineAsset(%this, %assetDef) function AssetBrowser::duplicateStateMachineAsset(%this, %assetDef) { + // TODO: + %targetModule = ""; + //Check if we have a target module, if not we need to select one if(%targetModule $= "") { diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript index 8c1782108..3eb822f21 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/directoryHandling.tscript @@ -325,7 +325,7 @@ function directoryHandler::copyFolder(%this, %fromFolder, %toFolder) if(!%success) error("copyProjectFolder() - failed to copy file: " @ %file); - %file = findNextFileMultiExpr( %fullPath @ "/*.*" ); + %file = findNextFileMultiExpr( %fromFolder @ "/*.*" ); } //do sub directories diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript index 856ba7d11..4b71d7660 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/editAsset.tscript @@ -3,7 +3,14 @@ function AssetBrowser_editAsset::saveAsset(%this) %file = AssetDatabase.getAssetFilePath(%this.editedAssetId); %success = TamlWrite(AssetBrowser_editAsset.editedAsset, %file); - AssetBrowser.loadFilters(); + AssetBrowser.reloadAsset(%this.editedAssetId); + + AssetBrowser.refresh(); + + %assetType = AssetDatabase.getAssetType(%this.editedAssetId); + %assetDef = AssetDatabase.acquireAsset(%this.editedAssetId); + AssetBrowser.call("on" @ %assetType @ "Changed", %assetDef); + AssetDatabase.releaseAsset(%this.editedAssetId); Canvas.popDialog(AssetBrowser_editAsset); } @@ -79,6 +86,17 @@ function AssetBrowser::editAssetInfo(%this) } //------------------------------------------------------------ +function AssetBrowser::reloadAsset(%this, %assetId) +{ + %moduleName = getToken(%assetId, ":", 0); + %moduleDef = ModuleDatabase.findModule(%moduleName); + + %assetName = getToken(%assetId, ":", 1); + %assetFilePath = AssetDatabase.getAssetFilePath(%assetId); + + AssetDatabase.removeDeclaredAsset(%assetId); + AssetDatabase.addDeclaredAsset(%moduleDef, %assetFilePath); +} function AssetBrowser::refreshAsset(%this, %assetId) { @@ -143,6 +161,10 @@ function AssetBrowser::performRenameAsset(%this, %originalAssetName, %newName) //Update the selection to immediately jump to the new asset AssetBrowser-->filterTree.clearSelection(); %ModuleItem = AssetBrowser-->filterTree.findItemByName(%moduleName); + + // TODO is this correct? + %assetType = %ModuleItem.getClassName(); + %assetTypeId = AssetBrowser-->filterTree.findChildItemByName(%ModuleItem, %assetType); AssetBrowser-->filterTree.selectItem(%assetTypeId); @@ -236,9 +258,9 @@ function moveAssetFile(%assetDef, %destinationPath) %assetPath = makeFullPath(AssetDatabase.getAssetFilePath(%assetDef.getAssetId())); %assetFilename = fileName(%assetPath); - %newAssetPath = %destination @ "/" @ %assetFilename; + %newAssetPath = %destinationPath @ "/" @ %assetFilename; - %copiedSuccess = pathCopy(%assetPath, %destination @ "/" @ %assetFilename); + %copiedSuccess = pathCopy(%assetPath, %destinationPath @ "/" @ %assetFilename); if(!%copiedSuccess) return ""; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/guiFile.gui.template b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/guiFile.gui.template index 63dc722d2..5224885a7 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/guiFile.gui.template +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/guiFile.gui.template @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(@@) +$guiContent = new GuiControl(@@) { position = "0 0"; extent = "100 100"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/terrainMaterial.tscript.template b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/terrainMaterial.tscript.template index ef614edaf..ee54d964a 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/terrainMaterial.tscript.template +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/templateFiles/terrainMaterial.tscript.template @@ -11,7 +11,7 @@ singleton Material(TerrainFX_@) impactSoundId = "0"; }; -new TerrainMaterial(@) +singleton TerrainMaterial(@) { internalName = "@"; diffuseMap = ""; diff --git a/Templates/BaseGame/game/tools/componentEditor/gui/TypeMaskFieldGui.gui b/Templates/BaseGame/game/tools/componentEditor/gui/TypeMaskFieldGui.gui index a18277419..a5ce9d51b 100644 --- a/Templates/BaseGame/game/tools/componentEditor/gui/TypeMaskFieldGui.gui +++ b/Templates/BaseGame/game/tools/componentEditor/gui/TypeMaskFieldGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TypeMaskFieldGui) { +$guiContent = new GuiControl(TypeMaskFieldGui) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/componentEditor/gui/superToolTipDlg.ed.gui b/Templates/BaseGame/game/tools/componentEditor/gui/superToolTipDlg.ed.gui index ef506941a..a0a79e60b 100644 --- a/Templates/BaseGame/game/tools/componentEditor/gui/superToolTipDlg.ed.gui +++ b/Templates/BaseGame/game/tools/componentEditor/gui/superToolTipDlg.ed.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(SuperTooltipDlg) { +$guiContent = new GuiControl(SuperTooltipDlg) { canSaveDynamicFields = "0"; Profile = "GuiTransparentProfileModeless"; class = "SuperTooltip"; diff --git a/Templates/BaseGame/game/tools/componentEditor/interface/materialFieldType.tscript b/Templates/BaseGame/game/tools/componentEditor/interface/materialFieldType.tscript index 060333e62..df2535a1b 100644 --- a/Templates/BaseGame/game/tools/componentEditor/interface/materialFieldType.tscript +++ b/Templates/BaseGame/game/tools/componentEditor/interface/materialFieldType.tscript @@ -9,6 +9,13 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % if(%currentMaterial $= "" || %currentMaterial == 0) %currentMaterial = %fieldDefaultVal; + // TODO? + %matName = ""; + %component = ""; + %material = ""; + %accessor = ""; + %precision = ""; + %container = new GuiControl() { canSaveDynamicFields = "0"; Profile = "EditorContainerProfile"; @@ -20,7 +27,7 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = "";// %tooltip; tooltipProfile = "EditorToolTipProfile"; }; @@ -35,7 +42,7 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = ""; //%tooltip; tooltipProfile = "EditorToolTipProfile"; text = %fieldName; maxLength = "1024"; @@ -57,7 +64,7 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % text = %currentMaterial; }; }; - + %previewButton = new GuiBitmapButtonCtrl(){ internalName = %matName; HorizSizing = "right"; @@ -121,7 +128,7 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = ""; //%tooltip; tooltipProfile = "EditorToolTipProfile"; text = "Mapped to:" SPC %material.mapTo; maxLength = "1024"; @@ -140,7 +147,7 @@ function GuiInspectorGroup::buildMaterialField(%this, %fieldName, %fieldLabel, % canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = "";// %tooltip; tooltipProfile = "EditorToolTipProfile"; maxLength = "1024"; historySize = "0"; diff --git a/Templates/BaseGame/game/tools/componentEditor/interface/stateMachineField.tscript b/Templates/BaseGame/game/tools/componentEditor/interface/stateMachineField.tscript index 796c2486b..80c5723ed 100644 --- a/Templates/BaseGame/game/tools/componentEditor/interface/stateMachineField.tscript +++ b/Templates/BaseGame/game/tools/componentEditor/interface/stateMachineField.tscript @@ -201,7 +201,7 @@ function stateMachineFieldList::onSelect(%this) %index = %this.getParent().fieldID; %oldValue = %this.behavior.stateMachine.getValue(%index); - %this.behavior.stateMachine.setValue(%fieldType SPC %oldValue.y); + %this.behavior.stateMachine.setValue(%this.fieldType SPC %oldValue.y); %this.getParent().add(%fieldCtrl); } diff --git a/Templates/BaseGame/game/tools/componentEditor/interface/typeMaskFieldType.tscript b/Templates/BaseGame/game/tools/componentEditor/interface/typeMaskFieldType.tscript index 83cb55a6f..3b7710ad7 100644 --- a/Templates/BaseGame/game/tools/componentEditor/interface/typeMaskFieldType.tscript +++ b/Templates/BaseGame/game/tools/componentEditor/interface/typeMaskFieldType.tscript @@ -13,7 +13,7 @@ function GuiInspectorComponentGroup::buildTypeMaskField(%this, %component, %fiel canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = "";//%tooltip; tooltipProfile = "EditorToolTipProfile"; }; @@ -28,7 +28,7 @@ function GuiInspectorComponentGroup::buildTypeMaskField(%this, %component, %fiel canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = "";//%tooltip; tooltipProfile = "EditorToolTipProfile"; text = %fieldName; maxLength = "1024"; diff --git a/Templates/BaseGame/game/tools/componentEditor/scripts/componentEditor.ed.tscript b/Templates/BaseGame/game/tools/componentEditor/scripts/componentEditor.ed.tscript index 15bc5aa8b..f7063e764 100644 --- a/Templates/BaseGame/game/tools/componentEditor/scripts/componentEditor.ed.tscript +++ b/Templates/BaseGame/game/tools/componentEditor/scripts/componentEditor.ed.tscript @@ -159,6 +159,9 @@ function QuickEditComponentList::onHotTrackItem( %this, %itemID ) { %name = getField(%componentObj.getComponentField(%i), 0); + // TODO: + %description = ""; + SuperTooltipDlg.addParam(%name, %description @ "\n"); } %position = %this.getGlobalPosition(); diff --git a/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.gui b/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.gui index f28b3b5b4..07ecfc7be 100644 --- a/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.gui +++ b/Templates/BaseGame/game/tools/convexEditor/convexEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiConvexEditorCtrl(ConvexEditorGui) { +$guiContent = new GuiConvexEditorCtrl(ConvexEditorGui) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/convexEditor/convexEditorSettingsTab.ed.gui b/Templates/BaseGame/game/tools/convexEditor/convexEditorSettingsTab.ed.gui index 3cd3a1ebd..b77d68f85 100644 --- a/Templates/BaseGame/game/tools/convexEditor/convexEditorSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/convexEditor/convexEditorSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ConvexEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(ConvexEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/convexEditor/convexEditorSidebarGui.gui b/Templates/BaseGame/game/tools/convexEditor/convexEditorSidebarGui.gui index 8fbc97464..99d9b1852 100644 --- a/Templates/BaseGame/game/tools/convexEditor/convexEditorSidebarGui.gui +++ b/Templates/BaseGame/game/tools/convexEditor/convexEditorSidebarGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContnt = new GuiControl(ConvexEditorOptions) +$guiContnt = new GuiControl(ConvexEditorOptions) { position = "0 0"; extent = "800 600"; diff --git a/Templates/BaseGame/game/tools/convexEditor/convexEditorToolbar.ed.gui b/Templates/BaseGame/game/tools/convexEditor/convexEditorToolbar.ed.gui index eebd56e85..e19f4c661 100644 --- a/Templates/BaseGame/game/tools/convexEditor/convexEditorToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/convexEditor/convexEditorToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(convexEditorToolbar, EditorGuiGroup) { +$guiContent = new GuiControl(convexEditorToolbar, EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = ""; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorCreatePrompt.ed.gui b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorCreatePrompt.ed.gui index e8c3b5adb..5f1783390 100644 --- a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorCreatePrompt.ed.gui +++ b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorCreatePrompt.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DatablockEditorCreatePrompt,EditorGuiGroup) { +$guiContent = new GuiControl(DatablockEditorCreatePrompt,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorInspectorWindow.ed.gui b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorInspectorWindow.ed.gui index 25962a61a..28f6abd3d 100644 --- a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorInspectorWindow.ed.gui +++ b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorInspectorWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorTreeWindow.ed.gui b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorTreeWindow.ed.gui index 6877ca6fb..95ba4a277 100644 --- a/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorTreeWindow.ed.gui +++ b/Templates/BaseGame/game/tools/datablockEditor/DatablockEditorTreeWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/datablockEditor/datablockEditorUndo.tscript b/Templates/BaseGame/game/tools/datablockEditor/datablockEditorUndo.tscript index f9a8d30b4..d3630c9e8 100644 --- a/Templates/BaseGame/game/tools/datablockEditor/datablockEditorUndo.tscript +++ b/Templates/BaseGame/game/tools/datablockEditor/datablockEditorUndo.tscript @@ -79,7 +79,7 @@ function ActionCreateDatablock::redo( %this ) %this.editor.selectDatablock( %db ); %this.editor.flagInspectorAsDirty( true ); - UnlistedDatablocks.remove( %id ); + UnlistedDatablocks.remove( %db ); } //--------------------------------------------------------------------------------------------- @@ -99,7 +99,7 @@ function ActionCreateDatablock::undo( %this ) %this.dbName = %db.name; %db.name = ""; - UnlistedDatablocks.add( %this.db ); + UnlistedDatablocks.add( %db ); } //============================================================================================= @@ -155,5 +155,5 @@ function ActionDeleteDatablock::undo( %this ) // Remove from unlisted. - UnlistedDatablocks.remove( %id ); + UnlistedDatablocks.remove( %db ); } diff --git a/Templates/BaseGame/game/tools/debugger/gui/breakConditionDlg.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/breakConditionDlg.ed.gui index d6355e58f..9a5c53881 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/breakConditionDlg.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/breakConditionDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerBreakConditionDlg, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerBreakConditionDlg, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/gui/connectDlg.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/connectDlg.ed.gui index 927312fed..5d72d44ee 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/connectDlg.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/connectDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerConnectDlg, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerConnectDlg, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/gui/debugger.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/debugger.ed.gui index 616a8f0fb..6efe6786c 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/debugger.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/debugger.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerGui, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerGui, EditorGuiGroup) { profile = "ToolsGuiWindowProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/gui/editWatchDlg.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/editWatchDlg.ed.gui index d1d5ebe4e..e53a8c7c8 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/editWatchDlg.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/editWatchDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerEditWatchDlg, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerEditWatchDlg, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/gui/findDlg.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/findDlg.ed.gui index 5a74273d5..a16b9784b 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/findDlg.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/findDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerFindDlg, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerFindDlg, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/gui/watchDlg.ed.gui b/Templates/BaseGame/game/tools/debugger/gui/watchDlg.ed.gui index 898563807..2bd913b85 100644 --- a/Templates/BaseGame/game/tools/debugger/gui/watchDlg.ed.gui +++ b/Templates/BaseGame/game/tools/debugger/gui/watchDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(DebuggerWatchDlg, EditorGuiGroup) { +$guiContent = new GuiControl(DebuggerWatchDlg, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/debugger/scripts/debugger.ed.tscript b/Templates/BaseGame/game/tools/debugger/scripts/debugger.ed.tscript index 408de29eb..0c17b8ccb 100644 --- a/Templates/BaseGame/game/tools/debugger/scripts/debugger.ed.tscript +++ b/Templates/BaseGame/game/tools/debugger/scripts/debugger.ed.tscript @@ -430,7 +430,7 @@ function DbgRemoveBreakPoint(%file, %line) function DbgDeleteSelectedBreak() { %selectedBreak = DebuggerBreakPoints.getSelectedId(); - %rowNum = DebuggerBreakPoints.getRowNumById(%selectedWatch); + %rowNum = DebuggerBreakPoints.getRowNumById(%selectedBreak); if (%rowNum >= 0) { %breakText = DebuggerBreakPoints.getRowText(%rowNum); %breakLine = getField(%breakText, 0); diff --git a/Templates/BaseGame/game/tools/decalEditor/decalEditorGui.gui b/Templates/BaseGame/game/tools/decalEditor/decalEditorGui.gui index 172e33b0e..78210bb43 100644 --- a/Templates/BaseGame/game/tools/decalEditor/decalEditorGui.gui +++ b/Templates/BaseGame/game/tools/decalEditor/decalEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiDecalEditorCtrl(DecalEditorGui) { +$guiContent = new GuiDecalEditorCtrl(DecalEditorGui) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; @@ -472,8 +472,6 @@ Margin = "0 0 0 -3"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -552,8 +550,6 @@ Margin = "0 0 0 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -716,8 +712,6 @@ Margin = "0 0 0 -3"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -796,8 +790,6 @@ Margin = "0 0 0 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiInspector(DecalInspector) { StackingType = "Vertical"; diff --git a/Templates/BaseGame/game/tools/forestEditor/brushes.tscript b/Templates/BaseGame/game/tools/forestEditor/brushes.tscript index ea313e60b..6860a8813 100644 --- a/Templates/BaseGame/game/tools/forestEditor/brushes.tscript +++ b/Templates/BaseGame/game/tools/forestEditor/brushes.tscript @@ -20,8 +20,7 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- -//--- OBJECT WRITE BEGIN --- -%forestBrushesGroup = new SimGroup( ForestBrushGroup ) +$forestBrushesGroup = new SimGroup( ForestBrushGroup ) { }; //--- OBJECT WRITE END --- \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/forestEditor/forestEditToolbar.ed.gui b/Templates/BaseGame/game/tools/forestEditor/forestEditToolbar.ed.gui index c6976584f..5590f016e 100644 --- a/Templates/BaseGame/game/tools/forestEditor/forestEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/forestEditor/forestEditToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ForestEditToolbar,EditorGuiGroup) { +$guiContent = new GuiControl(ForestEditToolbar,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/forestEditor/forestEditorGui.gui b/Templates/BaseGame/game/tools/forestEditor/forestEditorGui.gui index 171c34ffd..e633829e8 100644 --- a/Templates/BaseGame/game/tools/forestEditor/forestEditorGui.gui +++ b/Templates/BaseGame/game/tools/forestEditor/forestEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new ForestEditorCtrl(ForestEditorGui,EditorGuiGroup) { +$guiContent = new ForestEditorCtrl(ForestEditorGui,EditorGuiGroup) { renderMissionArea = "0"; missionAreaFillColor = "255 0 0 20"; missionAreaFrameColor = "255 0 0 128"; diff --git a/Templates/BaseGame/game/tools/gui/EditorLoadingGui.gui b/Templates/BaseGame/game/tools/gui/EditorLoadingGui.gui index 5d7152e44..e5950b677 100644 --- a/Templates/BaseGame/game/tools/gui/EditorLoadingGui.gui +++ b/Templates/BaseGame/game/tools/gui/EditorLoadingGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EditorLoadingGui,EditorGuiGroup) { +$guiContent = new GuiControl(EditorLoadingGui,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/gui/EditorSettingsWindow.ed.gui b/Templates/BaseGame/game/tools/gui/EditorSettingsWindow.ed.gui index 3d5d939ad..93010d0e1 100644 --- a/Templates/BaseGame/game/tools/gui/EditorSettingsWindow.ed.gui +++ b/Templates/BaseGame/game/tools/gui/EditorSettingsWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EditorSettingsWindow,EditorGuiGroup) { +$guiContent = new GuiControl(EditorSettingsWindow,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/gui/GuiEaseEditDlg.ed.gui b/Templates/BaseGame/game/tools/gui/GuiEaseEditDlg.ed.gui index 4c76d8388..abe4422e1 100644 --- a/Templates/BaseGame/game/tools/gui/GuiEaseEditDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/GuiEaseEditDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GuiEaseEditDlg,EditorGuiGroup) { +$guiContent = new GuiControl(GuiEaseEditDlg,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/gui/assimpImport.ed.gui b/Templates/BaseGame/game/tools/gui/assimpImport.ed.gui index a9ba1f768..dcee11033 100644 --- a/Templates/BaseGame/game/tools/gui/assimpImport.ed.gui +++ b/Templates/BaseGame/game/tools/gui/assimpImport.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AssimpImportDlg,EditorGuiGroup) { +$guiContent = new GuiControl(AssimpImportDlg,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "width"; diff --git a/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui b/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui index 4909cee08..ebd2c822a 100644 --- a/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui +++ b/Templates/BaseGame/game/tools/gui/colladaImport.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ColladaImportDlg,EditorGuiGroup) { +$guiContent = new GuiControl(ColladaImportDlg,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "width"; @@ -1754,8 +1754,8 @@ function convertColladaModels(%pattern) function showImportDialog(%shapePath, %cmd) { - %this.path = %shapePath; - %this.cmd = %cmd; + ColladaImportDlg.path = %shapePath; + ColladaImportDlg.cmd = %cmd; if ( fileExt(%shapePath) $= ".dts" || fileExt(%shapePath) $= ".dsq" || fileExt(%shapePath) $= ".dae" || fileExt(%shapePath) $= ".kmz" ) diff --git a/Templates/BaseGame/game/tools/gui/colorPicker.ed.gui b/Templates/BaseGame/game/tools/gui/colorPicker.ed.gui index 0d4f7a975..f390cf95e 100644 --- a/Templates/BaseGame/game/tools/gui/colorPicker.ed.gui +++ b/Templates/BaseGame/game/tools/gui/colorPicker.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiColorPickerCtrl(ColorPickerDlg,EditorGuiGroup) { +$guiContent = new GuiColorPickerCtrl(ColorPickerDlg,EditorGuiGroup) { displayMode = "Dropper"; // this makes the background visible actionOnMove = "1"; position = "0 0"; diff --git a/Templates/BaseGame/game/tools/gui/cubemapEditor.gui b/Templates/BaseGame/game/tools/gui/cubemapEditor.gui index ee274fa10..d238feae5 100644 --- a/Templates/BaseGame/game/tools/gui/cubemapEditor.gui +++ b/Templates/BaseGame/game/tools/gui/cubemapEditor.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(CubemapEditor) { +$guiContent = new GuiControl(CubemapEditor) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript b/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript index 07b3e12b2..fea4a1a6d 100644 --- a/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript +++ b/Templates/BaseGame/game/tools/gui/editorSettingsWindow.ed.tscript @@ -233,7 +233,7 @@ function GuiInspectorVariableGroup::buildOptionsSettingField(%this, %fieldName, canSave = "1"; Visible = "1"; tooltipprofile = "ToolsGuiToolTipProfile"; - tooltip = %tooltip; + tooltip = "";//%tooltip; text = %fieldDefaultVal; hovertime = "1000"; ownerObject = %ownerObj; @@ -520,6 +520,7 @@ function ESettingsWindow::getAssetEditingSettings(%this) SettingsInspector.addSettingsField("Assets/New/alwaysPromptModuleTarget", "Always Prompt Target Module", "bool", "If off, use the default module"); SettingsInspector.endGroup(); + %formattedConfigList = ""; for(%i=0; %i < ImportAssetWindow.importConfigsList.Count(); %i++) { %configName = ImportAssetWindow.importConfigsList.getKey(%i); diff --git a/Templates/BaseGame/game/tools/gui/fieldTypes/assetDependencies.tscript b/Templates/BaseGame/game/tools/gui/fieldTypes/assetDependencies.tscript index 3aaf4f73a..b0f8e5a45 100644 --- a/Templates/BaseGame/game/tools/gui/fieldTypes/assetDependencies.tscript +++ b/Templates/BaseGame/game/tools/gui/fieldTypes/assetDependencies.tscript @@ -34,7 +34,7 @@ function GuiInspectorVariableGroup::buildAssetDependenciesField(%this, %fieldNam canSave = "1"; Visible = "1"; tooltipprofile = "ToolsGuiToolTipProfile"; - tooltip = %tooltip; + tooltip = "";// %tooltip; text = %fieldDefaultVal; hovertime = "1000"; ownerObject = %ownerObj; diff --git a/Templates/BaseGame/game/tools/gui/fieldTypes/buttonField.tscript b/Templates/BaseGame/game/tools/gui/fieldTypes/buttonField.tscript index c0a2392a2..e2f680d05 100644 --- a/Templates/BaseGame/game/tools/gui/fieldTypes/buttonField.tscript +++ b/Templates/BaseGame/game/tools/gui/fieldTypes/buttonField.tscript @@ -33,7 +33,7 @@ function GuiInspectorVariableGroup::buildButtonField(%this, %fieldName, %fieldLa canSave = "1"; Visible = "1"; tooltipprofile = "ToolsGuiToolTipProfile"; - tooltip = %tooltip; + tooltip = "";// %tooltip; text = %fieldName; hovertime = "1000"; command = %fieldDataVals; diff --git a/Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript b/Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript index d636641af..c26f3638d 100644 --- a/Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript +++ b/Templates/BaseGame/game/tools/gui/fieldTypes/listField.tscript @@ -22,7 +22,7 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = ""; ///%tooltip; tooltipProfile = "EditorToolTipProfile"; }; @@ -37,7 +37,7 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe canSave = "0"; Visible = "1"; hovertime = "100"; - tooltip = %tooltip; + tooltip = ""; //%tooltip; tooltipProfile = "EditorToolTipProfile"; text = %fieldLabel; maxLength = "1024"; @@ -66,7 +66,7 @@ function GuiInspectorVariableGroup::buildListField(%this, %fieldName, %fieldLabe canSave = "1"; Visible = "1"; tooltipprofile = "ToolsGuiToolTipProfile"; - tooltip = %tooltip; + tooltip = ""; //%tooltip; text = %fieldDefaultVal; hovertime = "1000"; ownerObject = %ownerObj; diff --git a/Templates/BaseGame/game/tools/gui/fieldTypes/range.tscript b/Templates/BaseGame/game/tools/gui/fieldTypes/range.tscript index 35e55bfe7..efa78ca46 100644 --- a/Templates/BaseGame/game/tools/gui/fieldTypes/range.tscript +++ b/Templates/BaseGame/game/tools/gui/fieldTypes/range.tscript @@ -76,7 +76,7 @@ function GuiInspectorVariableGroup::buildRangeField(%this, %fieldName, %fieldLab Visible = "1"; Command = "$thisControl.onDragComplete();"; tooltipprofile = "GuiToolTipProfile"; - tooltip = %tooltip; + tooltip = ""; //%tooltip; hovertime = "1000"; canSaveDynamicFields = "0"; ownerObject = %ownerObj; diff --git a/Templates/BaseGame/game/tools/gui/fileDialogBase.ed.tscript b/Templates/BaseGame/game/tools/gui/fileDialogBase.ed.tscript index 9d40e0434..7d36db457 100644 --- a/Templates/BaseGame/game/tools/gui/fileDialogBase.ed.tscript +++ b/Templates/BaseGame/game/tools/gui/fileDialogBase.ed.tscript @@ -255,8 +255,7 @@ function FileDialogOkButton::onClick( %this ) // Callback eval( %this.parent.SuccessCallback @ "(\"" @ %fullPath @"\");" ); - - %parent.SuccessCallback = 0; + %this.parent.SuccessCallback = 0; //error("Ok"); diff --git a/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.gui b/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.gui index ecc17c7e2..78f96f804 100644 --- a/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.gui +++ b/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCollapseCtrl() { +$guiContent = new GuiWindowCollapseCtrl() { collapseGroup = "-1"; collapseGroupNum = "-1"; resizeWidth = "1"; diff --git a/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.tscript b/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.tscript index 33b65f6bd..28b2d0d68 100644 --- a/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.tscript +++ b/Templates/BaseGame/game/tools/gui/guiObjectInspector.ed.tscript @@ -37,7 +37,7 @@ function inspectObject( %object ) // Create a new object inspector window. exec( "./guiObjectInspector.ed.gui" ); - if( !isObject( %guiContent) ) + if( !isObject( $guiContent) ) { error( "InspectObject: failed to create GUI from 'guiObjectInspector.ed.gui'" ); return; @@ -45,9 +45,9 @@ function inspectObject( %object ) // Initialize the inspector. - %guiContent.init( %object ); + $guiContent.init( %object ); - Canvas.getContent().add( %guiContent ); + Canvas.getContent().add( $guiContent ); } //============================================================================================= diff --git a/Templates/BaseGame/game/tools/gui/materialSelector.ed.gui b/Templates/BaseGame/game/tools/gui/materialSelector.ed.gui index 09bddd1dd..b043d62fc 100644 --- a/Templates/BaseGame/game/tools/gui/materialSelector.ed.gui +++ b/Templates/BaseGame/game/tools/gui/materialSelector.ed.gui @@ -778,6 +778,8 @@ function MaterialSelector::buildStaticFilters( %this ) // if you want to add any more containers to staticFilterObjects, here's // where to do it + %filterArray = MaterialSelector-->filterArray; + %staticFilterContainer = new GuiControl (){ new GuiContainer(){ profile = "ToolsGuiDefaultProfile"; @@ -1366,7 +1368,7 @@ function MaterialSelector::loadMaterialFilters( %this ) // create category and update current material if there is one function MaterialSelector::createFilter( %this, %filter ) { - if( %filter $= %existingFilters ) + if( %filter $= "" ) { toolsMessageBoxOK( "Error", "Can not create blank filter."); return; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui index a65acf0b0..e62771773 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(IODropdownDlg) { +$guiContent = new GuiControl(IODropdownDlg) { profile = "GuiDefaultProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOK.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOK.ed.gui index f1f2beb76..9ec300d92 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOK.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOK.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxOKDlg) { +$guiContent = new GuiControl(toolsMessageBoxOKDlg) { profile = "GuiOverlayProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKBuy.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKBuy.ed.gui index 176f47a1e..befe7e2fe 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKBuy.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKBuy.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxOKBuyDlg) { +$guiContent = new GuiControl(toolsMessageBoxOKBuyDlg) { profile = "ToolsGuiDefaultProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancel.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancel.ed.gui index 2fc84fa07..9fb96b373 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancel.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancel.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxOKCancelDlg) { +$guiContent = new GuiControl(toolsMessageBoxOKCancelDlg) { profile = "GuiOverlayProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancelDetailsDlg.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancelDetailsDlg.ed.gui index 83d810b4a..0e38c2e4f 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancelDetailsDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxOKCancelDetailsDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxOKCancelDetailsDlg) { +$guiContent = new GuiControl(toolsMessageBoxOKCancelDetailsDlg) { canSaveDynamicFields = "0"; Profile = "GuiOverlayProfile"; HorizSizing = "width"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNo.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNo.ed.gui index 83cc0f1b5..d9d5b45bd 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNo.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNo.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxYesNoDlg) { +$guiContent = new GuiControl(toolsMessageBoxYesNoDlg) { profile = "GuiOverlayProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNoCancel.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNoCancel.ed.gui index 9a707cdca..89e63cb87 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNoCancel.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messageBoxYesNoCancel.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxYesNoCancelDlg) { +$guiContent = new GuiControl(toolsMessageBoxYesNoCancelDlg) { canSaveDynamicFields = "0"; Profile = "GuiOverlayProfile"; HorizSizing = "width"; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/messagePopup.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/messagePopup.ed.gui index 317bbc7d1..475bb928a 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/messagePopup.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/messagePopup.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MessagePopupDlg) { +$guiContent = new GuiControl(MessagePopupDlg) { profile = "GuiDefaultProfile"; horizSizing = "width"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/tools/gui/postFxEditor.gui b/Templates/BaseGame/game/tools/gui/postFxEditor.gui index 4f1977bba..d8d6c4d95 100644 --- a/Templates/BaseGame/game/tools/gui/postFxEditor.gui +++ b/Templates/BaseGame/game/tools/gui/postFxEditor.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(postFXEditor) { +$guiContent = new GuiControl(postFXEditor) { position = "0 0"; extent = "1920 1200"; minExtent = "8 8"; diff --git a/Templates/BaseGame/game/tools/gui/profilerGraph.gui b/Templates/BaseGame/game/tools/gui/profilerGraph.gui index 8e2e2b68f..0a2fc44ab 100644 --- a/Templates/BaseGame/game/tools/gui/profilerGraph.gui +++ b/Templates/BaseGame/game/tools/gui/profilerGraph.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ProfilerGraphGui) { +$guiContent = new GuiControl(ProfilerGraphGui) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui b/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui index f0f829253..79007fda4 100644 --- a/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui +++ b/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(RenderTargetVisualizer) { +$guiContent = new GuiControl(RenderTargetVisualizer) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/gui/saveChangesMBDlg.ed.gui b/Templates/BaseGame/game/tools/gui/saveChangesMBDlg.ed.gui index b6bd3641d..3c7e26fd3 100644 --- a/Templates/BaseGame/game/tools/gui/saveChangesMBDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/saveChangesMBDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(toolsMessageBoxSaveChangesDlg, EditorGuiGroup) { +$guiContent = new GuiControl(toolsMessageBoxSaveChangesDlg, EditorGuiGroup) { canSaveDynamicFields = "0"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "width"; diff --git a/Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui b/Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui index 34cc45762..3758916f6 100644 --- a/Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/scriptEditorDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ScriptEditorDlg,EditorGuiGroup) { +$guiContent = new GuiControl(ScriptEditorDlg,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui b/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui index cc29e03e9..7b35a7284 100644 --- a/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/simViewDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(simViewDlg, EditorGuiGroup) { +$guiContent = new GuiControl(simViewDlg, EditorGuiGroup) { canSaveDynamicFields = "0"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/EditorChooseGUI.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/EditorChooseGUI.ed.gui index 22974b57a..212cbf94a 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/EditorChooseGUI.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/EditorChooseGUI.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiChunkedBitmapCtrl(EditorChooseGUI, EditorGuiGroup) { +$guiContent = new GuiChunkedBitmapCtrl(EditorChooseGUI, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui index baee53ad5..0560ff57b 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditor.ed.gui @@ -3,7 +3,7 @@ // Copyright (C) GarageGames.com, Inc. //--------------------------------------------------------------------------------------------- -%guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) { +$guiContent = new GuiControl(GuiEditorGui, EditorGuiGroup) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorNewGuiDialog.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorNewGuiDialog.ed.gui index 98252410a..1e224911d 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorNewGuiDialog.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorNewGuiDialog.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GuiEditorNewGuiDialog,EditorGuiGroup) { +$guiContent = new GuiControl(GuiEditorNewGuiDialog,EditorGuiGroup) { isContainer = "1"; profile = "ToolsGuiOverlayProfile"; horizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorPrefsDlg.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorPrefsDlg.ed.gui index 6f901d1a8..5ddf53f6d 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorPrefsDlg.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorPrefsDlg.ed.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(GuiEditorPrefsDlg, EditorGuiGroup) { +$guiContent = new GuiControl(GuiEditorPrefsDlg, EditorGuiGroup) { canSaveDynamicFields = "0"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorSelectDlg.ed.gui b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorSelectDlg.ed.gui index 1794a238d..148b77554 100644 --- a/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorSelectDlg.ed.gui +++ b/Templates/BaseGame/game/tools/guiEditor/gui/guiEditorSelectDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GuiEditorSelectDlgContainer,EditorGuiGroup) { +$guiContent = new GuiControl(GuiEditorSelectDlgContainer,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/EditorChooseGUI.ed.tscript b/Templates/BaseGame/game/tools/guiEditor/scripts/EditorChooseGUI.ed.tscript index 698d38bbf..00ec3e024 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/EditorChooseGUI.ed.tscript +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/EditorChooseGUI.ed.tscript @@ -49,7 +49,7 @@ function GE_OpenGUIFile() // The level file should have contained a scenegraph, which should now be in the instant // group. And, it should be the only thing in the group. - if( !isObject( %guiContent ) ) + if( !isObject( $guiContent ) ) { toolsMessageBox( getEngineName(), "You have loaded a Gui file that was created before this version. It has been loaded but you must open it manually from the content list dropdown", @@ -58,7 +58,7 @@ function GE_OpenGUIFile() return 0; } - GuiEditContent( %guiContent ); + GuiEditContent( $guiContent ); } function GE_GUIList::onURL(%this, %url) diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.tscript b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.tscript index 450920e6f..1fbe50c12 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.tscript +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorCanvas.ed.tscript @@ -281,7 +281,7 @@ function GuiEditCanvas::load( %this, %filename ) // The GUI file should have contained a GUIControl which should now be in the instant // group. And, it should be the only thing in the group. - if( !isObject( %guiContent ) ) + if( !isObject( $guiContent ) ) { toolsMessageBox( getEngineName(), "You have loaded a Gui file that was created before this version. It has been loaded but you must open it manually from the content list dropdown", @@ -289,7 +289,7 @@ function GuiEditCanvas::load( %this, %filename ) return 0; } - GuiEditor.openForEditing( %guiContent ); + GuiEditor.openForEditing( $guiContent ); GuiEditorStatusBar.print( "Loaded '" @ %filename @ "'" ); } @@ -449,7 +449,7 @@ function GuiEditCanvas::save( %this, %selectedOnly, %noPrompt ) %fo.writeLine( %beforeNewFileLines[ %i ] ); %fo.writeLine("//--- OBJECT WRITE BEGIN ---"); - %fo.writeObject(%currentObject, "%guiContent = "); + %fo.writeObject(%currentObject, "$guiContent = "); %fo.writeLine("//--- OBJECT WRITE END ---"); // Write out captured TorqueScript below Gui object @@ -488,19 +488,19 @@ function GuiEditCanvas::append( %this ) // Find guiContent. - if( !isObject( %guiContent ) ) + if( !isObject( $guiContent ) ) { toolsMessageBox( "Error loading GUI file", "The GUI content controls could not be found. This function can only be used with files saved by the GUI editor.", "Ok", "Error" ); return; } if( !GuiEditorContent.getCount() ) - GuiEditor.openForEditing( %guiContent ); + GuiEditor.openForEditing( $guiContent ); else { - GuiEditor.getCurrentAddSet().add( %guiContent ); - GuiEditor.readGuides( %guiContent ); - GuiEditor.onAddNewCtrl( %guiContent ); + GuiEditor.getCurrentAddSet().add( $guiContent ); + GuiEditor.readGuides( $guiContent ); + GuiEditor.onAddNewCtrl( $guiContent ); GuiEditor.onHierarchyChanged(); } diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorProfiles.ed.tscript b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorProfiles.ed.tscript index 433f103ae..e2a16756d 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorProfiles.ed.tscript +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorProfiles.ed.tscript @@ -69,6 +69,8 @@ function GuiEditor::createNewProfile( %this, %name, %copySource ) function GuiEditor::getProfileCategory( %this, %profile ) { + // TODO + %name = ""; if( %this.isDefaultProfile( %name ) ) return "Default"; else if( %profile.category !$= "" ) diff --git a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorUndo.ed.tscript b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorUndo.ed.tscript index fad91557e..f28a26109 100644 --- a/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorUndo.ed.tscript +++ b/Templates/BaseGame/game/tools/guiEditor/scripts/guiEditorUndo.ed.tscript @@ -364,6 +364,10 @@ function GenericUndoAction::learn(%this, %object) %oldFieldNames = %this.fieldNames[%object]; %numNewFields = getWordCount(%newFieldNames); %numOldFields = getWordCount(%oldFieldNames); + + %newNullFields = ""; + %oldNullFields = ""; + // compare the old field list to the new field list. // if a field is on the old list that isn't on the new list, // add it to the newNullFields list. diff --git a/Templates/BaseGame/game/tools/main.tscript b/Templates/BaseGame/game/tools/main.tscript index 7e613bc31..218d7d88d 100644 --- a/Templates/BaseGame/game/tools/main.tscript +++ b/Templates/BaseGame/game/tools/main.tscript @@ -255,7 +255,7 @@ function EditorCreateFakeGameSession(%fileName) $Game::MissionGroup = "MissionGroup"; - exec(%file); + exec(%fileName); } function fastLoadWorldEdit(%val) diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/MaterialToolbar.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/MaterialToolbar.ed.gui index e20674037..1995048b0 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/MaterialToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/MaterialToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MaterialEditorToolbar) { +$guiContent = new GuiControl(MaterialEditorToolbar) { canSaveDynamicFields = "0"; internalName = "ShapeEditorToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui index 8b6dedb44..e7606081e 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPreviewWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; internalName = "MatEdPreviewWindowContainer"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index ef31efa50..50b5563a8 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { +$guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "MatEdPropertiesWindowContainer"; Enabled = "1"; @@ -233,8 +233,6 @@ Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -543,9 +541,6 @@ Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -1923,8 +1918,6 @@ Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -2623,8 +2616,6 @@ Margin = "-1 0 0 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -3100,8 +3091,6 @@ Margin = "-1 0 0 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -3373,8 +3362,6 @@ Margin = "-1 0 0 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -4191,8 +4178,6 @@ Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/materialInstancesView.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/materialInstancesView.ed.gui index e7899e547..afc15608d 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/materialInstancesView.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/materialInstancesView.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MaterialInstanceViewCtrl) { +$guiContent = new GuiControl(MaterialInstanceViewCtrl) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript index d37a0c645..18197d09a 100644 --- a/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript +++ b/Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript @@ -1367,7 +1367,8 @@ function MaterialEditorGui::updateAnimationFlags(%this) { MaterialEditorGui.setMaterialDirty(); %single = true; - + %flags = ""; + if(MaterialEditorPropertiesWindow-->RotationAnimation.getValue() == true) { if(%single == true) diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.gui b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.gui index 14bc92d2a..6d50e7fbc 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.gui +++ b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiMeshRoadEditorCtrl(MeshRoadEditorGui,EditorGuiGroup) { +$guiContent = new GuiMeshRoadEditorCtrl(MeshRoadEditorGui,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript index 3fcfd528f..0c8533875 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript +++ b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript @@ -136,7 +136,7 @@ function MeshRoadEditorGui::editNodeDetails( %this ) function MeshRoadEditorGui::onBrowseClicked( %this ) { - //%filename = RETextureFileCtrl.getText(); + %filename = RETextureFileCtrl.getText(); %dlg = new OpenFileDialog() { diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorSettingsTab.gui b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorSettingsTab.gui index 81485d307..9b01c4c33 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorSettingsTab.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(MeshRoadEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(MeshRoadEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorToolbar.gui b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorToolbar.gui index 7245c0ca8..0f0236a7f 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorToolbar.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(MeshRoadEditorToolbar,EditorGuiGroup) { +$guiContent = new GuiControl(MeshRoadEditorToolbar,EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "MeshRoadEditorToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/missionAreaEditor/missionAreaEditorGui.ed.gui b/Templates/BaseGame/game/tools/missionAreaEditor/missionAreaEditorGui.ed.gui index 022801589..487b49c7f 100644 --- a/Templates/BaseGame/game/tools/missionAreaEditor/missionAreaEditorGui.ed.gui +++ b/Templates/BaseGame/game/tools/missionAreaEditor/missionAreaEditorGui.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiMissionAreaEditorCtrl(MissionAreaEditorGui, EditorGuiGroup) { +$guiContent = new GuiMissionAreaEditorCtrl(MissionAreaEditorGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui b/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui index 906990409..412eacaa3 100644 --- a/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui +++ b/Templates/BaseGame/game/tools/navEditor/CreateNewNavMeshDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(CreateNewNavMeshDlg) { +$guiContent = new GuiControl(CreateNewNavMeshDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorConsoleDlg.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorConsoleDlg.gui index 19c063d7a..4fbdfc100 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorConsoleDlg.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorConsoleDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCtrl(NavEditorConsoleDlg) { +$guiContent = new GuiWindowCtrl(NavEditorConsoleDlg) { text = "Nav Console"; resizeWidth = "1"; resizeHeight = "1"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui index e00dbf991..f415a43fa 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) { +$guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui index 1cbe2a81e..9aafcd0b9 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiTabPageCtrl(ENavEditorSettingsPage) { +$guiContent = new GuiTabPageCtrl(ENavEditorSettingsPage) { fitBook = "1"; text = "Navigation Editor"; maxLength = "1024"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorToolbar.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorToolbar.gui index b38fd953a..cdee55fb9 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorToolbar.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(NavEditorToolbar,EditorGuiGroup) { +$guiContent = new GuiControl(NavEditorToolbar,EditorGuiGroup) { position = "306 0"; extent = "800 32"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/particleEditor/ParticleEditor.ed.gui b/Templates/BaseGame/game/tools/particleEditor/ParticleEditor.ed.gui index d2b932abd..681e67f7d 100644 --- a/Templates/BaseGame/game/tools/particleEditor/ParticleEditor.ed.gui +++ b/Templates/BaseGame/game/tools/particleEditor/ParticleEditor.ed.gui @@ -20,7 +20,7 @@ $PE_guielement_pos_colorpicker = "158 0"; $PE_guielement_ext_colorpicker = "18 18"; //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCollapseCtrl(PE_Window) { +$guiContent = new GuiWindowCollapseCtrl(PE_Window) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; @@ -271,8 +271,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -584,8 +582,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -826,9 +822,7 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; - + new GuiStackControl() { StackingType = "Vertical"; HorizStacking = "Left to Right"; @@ -1272,8 +1266,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -1359,7 +1351,7 @@ $PE_guielement_ext_colorpicker = "18 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "%particleId = PEE_EmitterParticle2-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle2-->PopUpMenu.setSelected( %particleId );PE_EmitterEditor.updateParticlesFields();"; + Command = "$_particleId = PEE_EmitterParticle2-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle2-->PopUpMenu.setSelected( $_particleId );PE_EmitterEditor.updateParticlesFields();"; hovertime = "1000"; tooltip = "Clear Particle 2 from Emitter"; text = ""; @@ -1407,7 +1399,7 @@ $PE_guielement_ext_colorpicker = "18 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "%particleId = PEE_EmitterParticle3-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle3-->PopUpMenu.setSelected( %particleId );PE_EmitterEditor.updateParticlesFields();"; + Command = "$_particleId = PEE_EmitterParticle3-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle3-->PopUpMenu.setSelected( $_particleId );PE_EmitterEditor.updateParticlesFields();"; hovertime = "1000"; tooltip = "Clear Particle 3 from Emitter"; text = ""; @@ -1455,7 +1447,7 @@ $PE_guielement_ext_colorpicker = "18 18"; MinExtent = "8 2"; canSave = "1"; Visible = "1"; - Command = "%particleId = PEE_EmitterParticle4-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle4-->PopUpMenu.setSelected( %particleId );PE_EmitterEditor.updateParticlesFields();"; + Command = "$_particleId = PEE_EmitterParticle4-->PopUpMenu.findText( \"None\" ); PEE_EmitterParticle4-->PopUpMenu.setSelected( $_particleId );PE_EmitterEditor.updateParticlesFields();"; hovertime = "1000"; tooltip = "Clear Particle 4 from Emitter"; text = ""; @@ -1479,8 +1471,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -1933,8 +1923,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -2233,8 +2221,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -2518,8 +2504,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -2720,8 +2704,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; @@ -2865,8 +2847,6 @@ $PE_guielement_ext_colorpicker = "18 18"; Margin = "4 4 4 0"; DragSizable = false; container = true; - parentRollout = %this.rollout; - object = %behavior; new GuiStackControl() { StackingType = "Vertical"; diff --git a/Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui b/Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui index b308feed3..480e71704 100644 --- a/Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui +++ b/Templates/BaseGame/game/tools/projectImporter/guis/projectImporter.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ProjectImportCtrl) { +$guiContent = new GuiControl(ProjectImportCtrl) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript index 735e8dd66..99099085e 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/pre40/T3Dpre4ProjectImporter.tscript @@ -838,6 +838,7 @@ T3Dpre4ProjectImporter::genProcessor("afxBillboardData", "texture textureAsset") T3Dpre4ProjectImporter::genProcessor("afxModelData", "shapeName shapeAsset shapeFile shapeAsset"); T3Dpre4ProjectImporter::genProcessor("afxZodiacData", "texture textureAsset"); T3Dpre4ProjectImporter::genProcessor("afxZodiacPlaneData", "texture textureAsset"); +T3Dpre4ProjectImporter::genProcessor("sfxEmitter", "track soundAsset filename soundAsset"); //============================================================================== // Levels //============================================================================== @@ -1064,6 +1065,169 @@ function T3Dpre4ProjectImporter::processTerrainMaterialObject(%this, %file, %obj //============================================================================== T3Dpre4ProjectImporter::genProcessor("PostEffect", "texture textureAsset"); +//============================================================================== +// Sounds +// Sounds are a little weird because there's so much data tied up in a given sound +// source. So our approach is find old SFXProfiles and process those into sound assets +// by cross-referencing the filename for existing asset definitions. +// Using existing SFXProfiles allows us to also injest the descriptions, giving us +// our meta-properties on the sound asset itself. +//============================================================================== +function T3Dpre4ProjectImporter::processSFXProfileLine(%this, %line) +{ + return %line; +} + +function T3Dpre4ProjectImporter::processSFXProfileObject(%this, %file, %objectName) +{ + %soundFilename = findObjectField("filename"); + + %soundFilename = sanitizeFilename(%soundFilename); + + %soundAsset = SoundAsset::getAssetIdByFilename(%soundFilename); + + //Throw a warn that this file's already been claimed and move on + if(%soundAsset !$= "") + { + warn("T3Dpre4ProjectImporter::processSFXProfileObject() - attempting to process SFXProfile " @ %objectName + @ " but its filename is already associated to another sound asset. Continuing, but be aware."); + } + + %assetName = %objectName; + + %moduleName = AssetBrowser.dirHandler.getModuleFromAddress(%soundFilename).ModuleId; + + %assetPath = filePath(%soundFilename) @ "/"; + + %tamlpath = %assetPath @ %assetName @ ".asset.taml"; + + if(isFile(%tamlpath)) + { + error("T3Dpre4ProjectImporter::processSFXProfileObject() - Failed to create as taml file already exists: " @ %soundFilename); + return false; + } + + %asset = new SoundAsset() + { + AssetName = %assetName; + versionId = 1; + shaderData = ""; + soundFile = fileBase(%soundFilename) @ fileExt(%soundFilename); + }; + + %descriptionName = findObjectField("description"); + + if(%descriptionName !$= "") + { + //Optimization, see if we already have this description by happenstance + if(isObject(%descriptionName)) + { + %asset.sourceGroup = %descriptionName.sourceGroup; + %asset.volume = %descriptionName.volume; + %asset.pitch = %descriptionName.pitch; + %asset.isLooping = %descriptionName.isLooping; + %asset.priority = %descriptionName.priority; + %asset.useHardware = %descriptionName.useHardware; + %asset.is3D = %descriptionName.is3D; + %asset.minDistance = %descriptionName.minDistance; + %asset.maxDistance = %descriptionName.maxDistance; + %asset.scatterDistance = %descriptionName.scatterDistance; + %asset.coneInsideAngle = %descriptionName.coneInsideAngle; + %asset.coneOutsideAngle = %descriptionName.coneOutsideAngle; + %asset.coneOutsideVolume = %descriptionName.coneOutsideVolume; + %asset.rolloffFactor = %descriptionName.rolloffFactor; + %asset.isStreaming = %descriptionName.isStreaming; + } + else + { + %objFileFinder = ""; + //first check our cache + if(isObject($ProjectImporter::SFXDescriptionCache) && + $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName) !$= "") + { + %key = $ProjectImporter::SFXDescriptionCache.getIndexFromKey(%descriptionName); + %objFileFinder = $ProjectImporter::SFXDescriptionCache.getValue(%key); + } + else + { + %objFileFinder = findObjectInFiles(%descriptionName); + } + + if(%objFileFinder !$= "") + { + %valueArray = new ArrayObject(); + + %fileObj = getField(%objFileFinder, 0); + + %valueArray.add("sourceGroup" SPC findObjectField("sourceGroup", %fileObj)); + %valueArray.add("volume" SPC findObjectField("volume", %fileObj)); + %valueArray.add("pitch" SPC findObjectField("pitch", %fileObj)); + %valueArray.add("isLooping" SPC findObjectField("isLooping", %fileObj)); + %valueArray.add("priority" SPC findObjectField("priority", %fileObj)); + %valueArray.add("useHardware" SPC findObjectField("useHardware", %fileObj)); + %valueArray.add("is3D" SPC findObjectField("is3D", %fileObj)); + %valueArray.add("minDistance" SPC findObjectField("minDistance", %fileObj)); + %valueArray.add("maxDistance" SPC findObjectField("maxDistance", %fileObj)); + %valueArray.add("scatterDistance" SPC findObjectField("scatterDistance", %fileObj)); + %valueArray.add("coneInsideAngle" SPC findObjectField("coneInsideAngle", %fileObj)); + %valueArray.add("coneOutsideAngle" SPC findObjectField("coneOutsideAngle", %fileObj)); + %valueArray.add("coneOutsideVolume" SPC findObjectField("coneOutsideVolume", %fileObj)); + %valueArray.add("rolloffFactor" SPC findObjectField("rolloffFactor", %fileObj)); + %valueArray.add("isStreaming" SPC findObjectField("isStreaming", %fileObj)); + + if(isObject($ProjectImporter::SFXDescriptionCache)) + { + $ProjectImporter::SFXDescriptionCache.add(%descriptionName, %objFileFinder); + } + + for(%v=0; %v < %valueArray.Count(); %v++) + { + %varSet = %valueArray.getKey(%v); + %var = getWord(%varSet, 0); + %varVal = getWord(%varSet, 1); + + if(%varVal !$= "") + %asset.setFieldValue(%var, %varVal); + } + + %valueArray.delete(); + } + } + } + + TamlWrite(%asset, %tamlpath); + + %moduleDef = ModuleDatabase.findModule(%moduleName, 1); + %success = AssetDatabase.addDeclaredAsset(%moduleDef, %tamlpath); + + if(!%success) + return false; + + //Now mark the original SFXProfile for removal from the file as it's redundant + //now that we have the asset def + $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0); + + return true; +} + +function T3Dpre4ProjectImporter::processAudioProfileObject(%this, %file, %objectName) + { + return %this.processSFXProfileObject(%file, %objectName); + } + +function T3Dpre4ProjectImporter::processSFXDescriptionObject(%this, %file, %objectName) + { + $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0); + + return true; +} + +function T3Dpre4ProjectImporter::processAudioDescriptionObject(%this, %file, %objectName) +{ + $ProjectImporter::ToRemoveObjectList.add(%objectName, %file TAB 0); + + return true; +} //============================================================================== // Misc Utility functions diff --git a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript index 05a0847f4..ab62befb8 100644 --- a/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript +++ b/Templates/BaseGame/game/tools/projectImporter/scripts/projectImporter.tscript @@ -70,7 +70,7 @@ function ProjectImportWindow::selectOGFolder(%this) %dlg = new OpenFolderDialog() { Title = "Select Export Folder"; - Filters = %filter; + Filters = ""; DefaultFile = "data/"; ChangePath = false; MustExist = true; @@ -166,6 +166,16 @@ function ProjectImportWizardPage2::openPage(%this) $ProjectImporter::importTool.delete(); $ProjectImporter::importTool = new ScriptObject($ProjectImporter::versionMode @ "Importer"); + + if(isObject($ProjectImporter::SFXDescriptionCache)) + $ProjectImporter::SFXDescriptionCache.delete(); + + $ProjectImporter::SFXDescriptionCache = new ArrayObject(); + + if(isObject($ProjectImporter::ToRemoveObjectList)) + $ProjectImporter::ToRemoveObjectList.delete(); + + $ProjectImporter::ToRemoveObjectList = new ArrayObject(); } function ProjectImportWizardPage2::processPage(%this) @@ -312,6 +322,28 @@ function ProjectImportWizardPage6::openPage(%this) { $ProjectImporter::importTool.processScriptExtensions(); } + + //All good? now go through and wipe any objects flagged in our files for deletion + %objRemovePM = new PersistenceManager(); + + for(%o = 0; %o < $ProjectImporter::ToRemoveObjectList.count(); %o++) + { + %name = $ProjectImporter::ToRemoveObjectList.getKey(%o); + %file = getField($ProjectImporter::ToRemoveObjectList.getValue(%o),0); + + if(%name !$= "" && isFile(%file)) + { + if(!isObject(%name)) + { + //spoof it + %tmpObj = new SimObject(%name); + %objRemovePM.setDirty(%name, %file); + } + %objRemovePM.removeObjectFromFile(%name, %file); + + %tmpObj.delete(); + } + } } function ProjectImportWizardPage6::processPage(%this) @@ -416,7 +448,7 @@ function sanitizeFilename(%file) %sanitizedName = sanitizeString(%targetName); if(startsWith(%sanitizedName, "_")) { - %sanitizedName = substr(%sanitizedName, 1, -1); + %sanitizedName = getSubStr(%sanitizedName, 1, -1); } if(%sanitizedName !$= %targetName) { @@ -472,6 +504,12 @@ function testFilenameExtensions(%filename) return %filename @ ".dae"; else if(isFile(%filename @ ".dds")) return %filename @ ".dds"; + else if(isFile(%filename @ ".ogg")) + return %filename @ ".ogg"; + else if(isFile(%filename @ ".wav")) + return %filename @ ".wav"; + else if(isFile(%filename @ ".mp3")) + return %filename @ ".dds"; return %filename; } @@ -588,7 +626,7 @@ function processLegacyShapeConstructorField(%line) if(%foundAssets != 0) { %assetId = $ProjectImporter::assetQuery.getAsset(0); - echo("Legacy Project Importer - processing of legacy shape constructor addSequence line's value: " @ %value @ " has found a matching AssetId: " @ %assetId); + echo("Legacy Project Importer - processing of legacy shape constructor addSequence line's value: " @ %animSourcePath @ " has found a matching AssetId: " @ %assetId); } if(%assetId !$= "" && AssetDatabase.isDeclaredAsset(%assetId)) @@ -659,11 +697,14 @@ function findObjectName(%line, %createWord) return %objectName; } -function findObjectField(%fieldName) +function findObjectField(%fieldName, %fileObj) { + if(%fileObj $= "") + %fileObj = $ProjectImporter::fileObject; + %value = ""; %peekLineOffset = 0; - %peekLine = $ProjectImporter::fileObject.peekLine(%peekLineOffset); + %peekLine = %fileObj.peekLine(%peekLineOffset); while(!strIsMatchExpr("*};*", %peekLine) && !strIsMatchExpr("*singleton*(*)*", %peekLine) && !strIsMatchExpr("*new*(*)*", %peekLine) && @@ -671,7 +712,7 @@ function findObjectField(%fieldName) !strIsMatchExpr("\n", %peekLine) && !strIsMatchExpr("\r", %peekLine)) { - if(strpos(%peekLine, %fieldName) != -1) + if(strpos(strlwr(%peekLine), strlwr(%fieldName)) != -1) { %value = ""; %pos = strpos(%peekLine, "= \""); @@ -682,8 +723,7 @@ function findObjectField(%fieldName) %value = getSubStr(%peekLine, %pos+3, %endPos-%pos-3); break; } - else - { + %pos = strpos(%peekLine, "=\""); if(%pos != -1) { @@ -692,16 +732,109 @@ function findObjectField(%fieldName) %value = getSubStr(%peekLine, %pos+2, %endPos-%pos-2); break; } + + %pos = strpos(%peekLine, "= "); + if(%pos != -1) + { + %endPos = strpos(%peekLine, ";", %pos); + + %value = getSubStr(%peekLine, %pos+2, %endPos-%pos-2); + break; + } + + %pos = strpos(%peekLine, "="); + if(%pos != -1) + { + %endPos = strpos(%peekLine, ";", %pos); + + %value = getSubStr(%peekLine, %pos+2, %endPos-%pos-2); + break; } } %peekLineOffset++; - %peekLine = $ProjectImporter::fileObject.peekLine(%peekLineOffset); + %peekLine = %fileObj.peekLine(%peekLineOffset); } return %value; } +function findObjectInFiles(%objectName) +{ + //First, wipe out any files inside the folder first + %file = findFirstFileMultiExpr( "*.*", true); + + %fileObj = new FileObject(); + + while( %file !$= "" ) + { + %filename = fileName(%file); + %fileBase = fileBase(%file); + %fileExt = fileExt(%file); + %filePath = filePath(%file); + + if ( %fileObj.openForRead( %file ) ) + { + %lineNum = 0; + while ( !%fileObj.isEOF() ) + { + %line = %fileObj.readLine(); + %trimmedLine = trim(%line); + + if(strIsMatchExpr("*new*(*)*", %line) && strpos(%line, "::") == -1) + { + %className = findObjectClass(%line, "new"); + if (%className $= "") continue; + + %objName = findObjectName(%line, "new"); + + if(%objectName $= %objName) + { + return %fileObj TAB %file TAB %lineNum; + } + } + else if(strIsMatchExpr("*datablock*(*)*", %line) && strpos(%line, "::") == -1) + { + %className = findObjectClass(%line, "datablock"); + if (%className $= "") continue; + + %objName = findObjectName(%line, "datablock"); + + if(%objectName $= %objName) + { + return %fileObj TAB %file TAB %lineNum; + } + } + else if(strIsMatchExpr("*singleton*(*)*", %line) && strpos(%line, "::") == -1) + { + %className = findObjectClass(%line, "singleton"); + if (%className $= "") continue; + + %objName = findObjectName(%line, "singleton"); + + if(%objectName $= %objName) + { + return %fileObj TAB %file TAB %lineNum; + } + } + + %lineNum++; + } + + %fileObj.close(); + } + else + { + error("findObjectInFiles() - File not able to be opened: " @ %file); + } + + %file = findNextFileMultiExpr( "*.*" ); + } + + %fileObj.delete(); + + return ""; +} //============================================================================== //Shape Importing //============================================================================== @@ -981,6 +1114,7 @@ function processGUIntoAsset(%guiName, %file) warn("Processing GUI into asset: " @ %guiName @ ", file: " @ %file); %filePath = filePath(%file); + %fileName = fileBase(%file); %moduleDef = AssetBrowser.dirHandler.getModuleFromAddress(%file); %moduleName = %moduleDef.ModuleId; %modulePath = %moduleDef.ModulePath; @@ -1182,7 +1316,7 @@ function deleteAssetDefinitions() %dlg = new OpenFolderDialog() { Title = "Select Folder"; - Filters = %filter; + Filters = ""; DefaultFile = "data/"; ChangePath = false; MustExist = true; diff --git a/Templates/BaseGame/game/tools/riverEditor/RiverEditorGui.gui b/Templates/BaseGame/game/tools/riverEditor/RiverEditorGui.gui index 4d4812152..c0ff6e162 100644 --- a/Templates/BaseGame/game/tools/riverEditor/RiverEditorGui.gui +++ b/Templates/BaseGame/game/tools/riverEditor/RiverEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiRiverEditorCtrl(RiverEditorGui, EditorGuiGroup) { +$guiContent = new GuiRiverEditorCtrl(RiverEditorGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/riverEditor/RiverEditorSettingsTab.gui b/Templates/BaseGame/game/tools/riverEditor/RiverEditorSettingsTab.gui index 553e2d7c6..c1c6d37ed 100644 --- a/Templates/BaseGame/game/tools/riverEditor/RiverEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/riverEditor/RiverEditorSettingsTab.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(RiverEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(RiverEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/riverEditor/RiverEditorToolbar.gui b/Templates/BaseGame/game/tools/riverEditor/RiverEditorToolbar.gui index a2fb7574d..42229f4b1 100644 --- a/Templates/BaseGame/game/tools/riverEditor/RiverEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/riverEditor/RiverEditorToolbar.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(RiverEditorToolbar, EditorGuiGroup) { +$guiContent = new GuiControl(RiverEditorToolbar, EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "MeshRoadEditorToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/roadEditor/RoadEditorGui.gui b/Templates/BaseGame/game/tools/roadEditor/RoadEditorGui.gui index 9348f1559..5340f7ac0 100644 --- a/Templates/BaseGame/game/tools/roadEditor/RoadEditorGui.gui +++ b/Templates/BaseGame/game/tools/roadEditor/RoadEditorGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiRoadEditorCtrl(RoadEditorGui) { +$guiContent = new GuiRoadEditorCtrl(RoadEditorGui) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/roadEditor/RoadEditorSettingsTab.gui b/Templates/BaseGame/game/tools/roadEditor/RoadEditorSettingsTab.gui index b37485cda..b2d2ae39a 100644 --- a/Templates/BaseGame/game/tools/roadEditor/RoadEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/roadEditor/RoadEditorSettingsTab.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(RoadEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(RoadEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/roadEditor/RoadEditorToolbar.gui b/Templates/BaseGame/game/tools/roadEditor/RoadEditorToolbar.gui index 960bdbac2..672a0d9be 100644 --- a/Templates/BaseGame/game/tools/roadEditor/RoadEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/roadEditor/RoadEditorToolbar.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(RoadEditorToolbar) { +$guiContent = new GuiControl(RoadEditorToolbar) { canSaveDynamicFields = "0"; internalName = "RoadEditorToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript b/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript index acaad89b8..115da9d5c 100644 --- a/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript +++ b/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript @@ -138,7 +138,7 @@ function RoadEditorGui::editNodeDetails( %this ) function RoadEditorGui::onBrowseClicked( %this ) { - //%filename = RETextureFileCtrl.getText(); + %filename = RETextureFileCtrl.getText(); %dlg = new OpenFileDialog() { diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorSettingsTab.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorSettingsTab.gui index 1a455e9a6..e19052bc2 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorSettingsTab.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ShapeEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(ShapeEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorToolbar.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorToolbar.ed.gui index 8d5ab47d6..7c5e89a82 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/ShapeEditorToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ShapeEditorToolbar, EditorGuiGroup) { +$guiContent = new GuiControl(ShapeEditorToolbar, EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = ""; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAdvancedWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAdvancedWindow.ed.gui index bd76ee516..5ea1e4072 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAdvancedWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAdvancedWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCollapseCtrl(ShapeEdAdvancedWindow, EditorGuiGroup) { +$guiContent = new GuiWindowCollapseCtrl(ShapeEdAdvancedWindow, EditorGuiGroup) { text = "Advanced Properties"; resizeWidth = "0"; resizeHeight = "0"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAnimWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAnimWindow.ed.gui index 624214dea..4e261f726 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAnimWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdAnimWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) { +$guiContent = new GuiWindowCtrl(ShapeEdAnimWindow) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiToolbarWindowProfile"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPreviewWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPreviewWindow.ed.gui index 81b815d5c..65035d565 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPreviewWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPreviewWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui index bbd266004..c931ae1ca 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdPropWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiWindowCollapseCtrl(ShapeEdPropWindow) { +$guiContent = new GuiWindowCollapseCtrl(ShapeEdPropWindow) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiWindowProfile"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdSelectWindow.ed.gui b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdSelectWindow.ed.gui index 71cc4339e..1311e16ea 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdSelectWindow.ed.gui +++ b/Templates/BaseGame/game/tools/shapeEditor/gui/shapeEdSelectWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.tscript b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.tscript index 17e617862..f7181fd69 100644 --- a/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.tscript +++ b/Templates/BaseGame/game/tools/shapeEditor/scripts/shapeEditor.ed.tscript @@ -1444,6 +1444,8 @@ function ShapeEdPropWindow::update_onSequenceBlendChanged( %this, %seqName, %ble %proxyName = ShapeEditor.getProxyName( %seqName ); if ( ShapeEditor.shape.getSequenceIndex( %proxyName ) != -1 ) { + //TODO + %oldBlend = false; if ( %blend && %oldBlend ) ShapeEditor.shape.setSequenceBlend( %proxyName, false, %oldBlendSeq, %oldBlendFrame ); ShapeEditor.shape.setSequenceBlend( %proxyName, %blend, %blendSeq, %blendFrame ); @@ -2228,7 +2230,7 @@ function ShapeEdTriggerList::updateItem( %this, %oldFrame, %oldState, %frame, %s if ( %frame != %oldFrame ) { %pos = ShapeEdAnimWindow.getTimelineBitmapPos( ShapeEdAnimWindow-->seqIn.getText() + %frame, 2 ); - eval( "%ctrl = ShapeEdAnimWindow-->trigger" @ %updatedId @ ";" ); + %ctrl = eval( "return ShapeEdAnimWindow-->trigger" @ %updatedId @ ";" ); %ctrl.position = %pos SPC "0"; } } diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/AddFMODProjectDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/AddFMODProjectDlg.ed.gui index 56c892fa9..b7bc1d86b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/AddFMODProjectDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/AddFMODProjectDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AddFMODProjectDlg,EditorGuiGroup) { +$guiContent = new GuiControl(AddFMODProjectDlg,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiOverlayProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/AxisGizmoSettingsTab.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/AxisGizmoSettingsTab.ed.gui index e5eba667e..08165a2ba 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/AxisGizmoSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/AxisGizmoSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AxisGizmoSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(AxisGizmoSettingsTab,EditorGuiGroup) { isContainer = "1"; profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/CameraSettingsTab.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/CameraSettingsTab.ed.gui index b267b25a6..969109a3b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/CameraSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/CameraSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(CameraSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(CameraSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/EditorChooseLevelGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/EditorChooseLevelGui.ed.gui index 06a8f7599..6ca9dd503 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/EditorChooseLevelGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/EditorChooseLevelGui.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiContainer(EditorChooseLevelGui, EditorGuiGroup) { +$guiContent = new GuiContainer(EditorChooseLevelGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; @@ -34,7 +34,7 @@ }; }; -%guiContent = new GuiContainer(EditorChooseLevelContainer, EditorGuiGroup) { +$guiContent = new GuiContainer(EditorChooseLevelContainer, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui index 93aacceec..a5cfc8380 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/EditorGui.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiContainer(EditorGui,EditorGuiGroup) { +$guiContent = new GuiContainer(EditorGui,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/EditorSettingsWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/EditorSettingsWindow.ed.gui index 7662ecf00..97c607324 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/EditorSettingsWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/EditorSettingsWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EditorSettingsWindow,EditorGuiGroup) { +$guiContent = new GuiControl(EditorSettingsWindow,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/GeneralSettingsTab.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/GeneralSettingsTab.ed.gui index a49ab4064..933e42e8b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/GeneralSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/GeneralSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GeneralSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(GeneralSettingsTab,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/GenericPromptDialog.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/GenericPromptDialog.ed.gui index ade528157..8ab2debf3 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/GenericPromptDialog.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/GenericPromptDialog.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(GenericPromptDialog) { +$guiContent = new GuiControl(GenericPromptDialog) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ManageBookmarksWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ManageBookmarksWindow.ed.gui index 46195d0d7..19c32c0ac 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ManageBookmarksWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ManageBookmarksWindow.ed.gui @@ -1,4 +1,4 @@ -%guiContent = new GuiControl(ManageBookmarksContainer, EditorGuiGroup) { +$guiContent = new GuiControl(ManageBookmarksContainer, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ManageSFXParametersWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ManageSFXParametersWindow.ed.gui index 95081790f..d1b603ece 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ManageSFXParametersWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ManageSFXParametersWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ManageSFXParametersContainer,EditorGuiGroup) { +$guiContent = new GuiControl(ManageSFXParametersContainer,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiModelessDialogProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ObjectEditorSettingsTab.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ObjectEditorSettingsTab.ed.gui index b8928eb7d..97382bb99 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ObjectEditorSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ObjectEditorSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ObjectEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(ObjectEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ObjectSnapOptionsWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ObjectSnapOptionsWindow.ed.gui index ebf204880..258edf72f 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ObjectSnapOptionsWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ObjectSnapOptionsWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ObjectSnapOptionsContainer, EditorGuiGroup) { +$guiContent = new GuiControl(ObjectSnapOptionsContainer, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; @@ -843,7 +843,7 @@ password = "0"; tabComplete = "0"; sinkAllKeyEvents = "0"; - passwordMask = "•"; + passwordMask = "�"; text = "2.0"; maxLength = "6"; margin = "0 0 0 0"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui index 452c23bf6..690d653fa 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ProceduralTerrainPainterGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ProceduralTerrainPainterGui) { +$guiContent = new GuiControl(ProceduralTerrainPainterGui) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/SelectObjectsWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/SelectObjectsWindow.ed.gui index 3e95e91d4..c7955d868 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/SelectObjectsWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/SelectObjectsWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ESelectObjectsWindowContainer,EditorGuiGroup) { +$guiContent = new GuiControl(ESelectObjectsWindowContainer,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui index 6fb188adf..f58b8fb6c 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainBrushSoftnessCurveDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainBrushSoftnessCurveDlg, EditorGuiGroup) { +$guiContent = new GuiControl(TerrainBrushSoftnessCurveDlg, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui index 3c53c7c9f..63d8c010d 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { +$guiContent = new GuiControl(EWTerrainEditToolbar,EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "TerrainEditToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditorSettingsTab.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditorSettingsTab.ed.gui index 8f219ec67..87cc92ff7 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditorSettingsTab.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainEditorSettingsTab.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainEditorSettingsTab,EditorGuiGroup) { +$guiContent = new GuiControl(TerrainEditorSettingsTab,EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui index bffa0d9d4..596ef9b7e 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { +$guiContent = new GuiControl(EWTerrainPainterToolbar,EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "TerrainPainterToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui index 8e6192515..bc703c901 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TerrainPainterWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainPainterContainer,EditorGuiGroup) { +$guiContent = new GuiControl(TerrainPainterContainer,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui index 4b7b8a26e..96f64c447 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TimeAdjustGui.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TimeAdjustGui, EditorGuiGroup) { +$guiContent = new GuiControl(TimeAdjustGui, EditorGuiGroup) { isContainer = "1"; Profile = "ToolsGuiModelessDialogProfile"; HorizSizing = "right"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ConvexEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ConvexEditorPalette.ed.gui index 654ec029f..dc6df04c0 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ConvexEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ConvexEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(ConvexEditorPalette, EditorGuiGroup) { +$paletteId = new GuiControl(ConvexEditorPalette, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/DecalEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/DecalEditorPalette.ed.gui index 1cad1df01..5a9d2be55 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/DecalEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/DecalEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(DecalEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(DecalEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ForestEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ForestEditorPalette.ed.gui index fd6d9620a..6d2128c01 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ForestEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ForestEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(ForestEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(ForestEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/MeshRoadEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/MeshRoadEditorPalette.ed.gui index ab4056d4a..f29b33ca7 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/MeshRoadEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/MeshRoadEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(MeshRoadEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(MeshRoadEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui index 7209b76a4..b099f5835 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/NavEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(NavEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RiverEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RiverEditorPalette.ed.gui index bb6034f46..83fcbe35a 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RiverEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RiverEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(RiverEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(RiverEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RoadEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RoadEditorPalette.ed.gui index 3478d5b0d..209994660 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RoadEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/RoadEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(RoadEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(RoadEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ShapeEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ShapeEditorPalette.ed.gui index 3291f1454..ef237e017 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ShapeEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/ShapeEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(ShapeEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(ShapeEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainEditPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainEditPalette.ed.gui index d794d38ab..534062670 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainEditPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainEditPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(TerrainEditorPalette,EditorGuiGroup) { +$paletteId = new GuiControl(TerrainEditorPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainPainterPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainPainterPalette.ed.gui index 091f7a1c0..9e48b7fd2 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainPainterPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/TerrainPainterPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(TerrainPainterPalette,EditorGuiGroup) { +$paletteId = new GuiControl(TerrainPainterPalette,EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/WorldEditorPalette.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/WorldEditorPalette.ed.gui index 7dd2ed44e..9fc1617b5 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/WorldEditorPalette.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/WorldEditorPalette.ed.gui @@ -1,4 +1,4 @@ -%paletteId = new GuiControl(WorldEditorInspectorPalette, EditorGuiGroup) { +$paletteId = new GuiControl(WorldEditorInspectorPalette, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/init.tscript b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/init.tscript index 0f312633a..b6640e8fd 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/init.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteGroups/init.tscript @@ -30,6 +30,9 @@ function EWToolsPaletteWindow::loadToolsPalettes() exec( %file ); %paletteGroup = 0; + // TODO + %paletteId = 0; + %i = %paletteId.getCount(); for( ; %i != 0; %i--) { @@ -49,6 +52,9 @@ function EWToolsPaletteWindow::loadToolsPalettes() exec( %file ); %paletteGroup = 0; + // TODO + %paletteId = 0; + %i = %paletteId.getCount(); for( ; %i != 0; %i--) { diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui index b6b9c5507..491f7ad1b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsPaletteWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui index 330807ae4..b295abba0 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/ToolsToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiContainer(EWToolsToolbar) { +$guiContent = new GuiContainer(EWToolsToolbar) { canSaveDynamicFields = "0"; Enabled = "0"; internalName = "ToolsToolbar"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/TransformSelectionWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/TransformSelectionWindow.ed.gui index 67cb15d51..94bb55814 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/TransformSelectionWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/TransformSelectionWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TransformSelectionContainer, EditorGuiGroup) { +$guiContent = new GuiControl(TransformSelectionContainer, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/VisibilityLayerWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/VisibilityLayerWindow.ed.gui index 6e65a2749..cff92d9ab 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/VisibilityLayerWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/VisibilityLayerWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(VisibilityLayerContainer, EditorGuiGroup) { +$guiContent = new GuiControl(VisibilityLayerContainer, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui index 9abe8f9e3..bdfff71fb 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorInspectorWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorToolbar.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorToolbar.ed.gui index cde1ff9c5..df639add2 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorToolbar.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorToolbar.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(EWorldEditorToolbar, EditorGuiGroup) { +$guiContent = new GuiControl(EWorldEditorToolbar, EditorGuiGroup) { canSaveDynamicFields = "0"; internalName = "WorldEditorToolbar"; Enabled = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorTreeWindow.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorTreeWindow.ed.gui index a360e9d8d..44b200abd 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorTreeWindow.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/WorldEditorTreeWindow.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl() { +$guiContent = new GuiControl() { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiCreateNewTerrainGui.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiCreateNewTerrainGui.gui index 943e85185..41c9ed965 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiCreateNewTerrainGui.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiCreateNewTerrainGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(CreateNewTerrainGui, EditorGuiGroup) { +$guiContent = new GuiControl(CreateNewTerrainGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainExportGui.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainExportGui.gui index 411e74676..0953e8620 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainExportGui.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainExportGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainExportGui, EditorGuiGroup) { +$guiContent = new GuiControl(TerrainExportGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Profile = "ToolsGuiOverlayProfile"; Enabled = "1"; @@ -288,6 +288,9 @@ function TerrainExportGui::selectFolder( %this ) function TerrainExportGui::doOpenDialog( %this, %filter, %callback ) { + // TODO + %currentFile = ""; + %dlg = new OpenFolderDialog() { Title = "Select Export Folder"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui index 796f6a337..ae0342a2a 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainImportGui.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainImportGui, EditorGuiGroup) { +$guiContent = new GuiControl(TerrainImportGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; @@ -508,6 +508,8 @@ function TerrainImportGui::acceptSettings( %this ) AssetBrowser.newAssetSettings.opacityList = %this-->OpacityLayerTextList; + %opacityList = %this-->OpacityLayerTextList; + for( %i = 0; %i < %opacityList.rowCount(); %i++ ) { %itemText = %opacityList.getRowTextById( %i ); @@ -535,6 +537,9 @@ function TerrainImportGui::cancel( %this ) function TerrainImportGui::doOpenDialog( %this, %filter, %callback ) { + // TODO + %currentFile = ""; + %dlg = new OpenFileDialog() { Filters = %filter; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui index 4e92d9a80..1a7d1caf1 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainMaterialDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainMaterialDlg,EditorGuiGroup) { +$guiContent = new GuiControl(TerrainMaterialDlg,EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui index 47c3549a2..f63f53614 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiTerrainTextureSettingsDlg.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(TerrainTextureSettingsDlg, EditorGuiGroup) { +$guiContent = new GuiControl(TerrainTextureSettingsDlg, EditorGuiGroup) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/guiWorldEditorMissionInspector.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/guiWorldEditorMissionInspector.ed.gui index ab7bfe2f5..166db3024 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/guiWorldEditorMissionInspector.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/guiWorldEditorMissionInspector.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(WorldEditorMissionInspector,EditorGuiGroup) { +$guiContent = new GuiControl(WorldEditorMissionInspector,EditorGuiGroup) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "ToolsGuiDefaultProfile"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui b/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui index 8341ebc7f..755227156 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/objectBuilderGui.ed.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ObjectBuilderGui, EditorGuiGroup) { +$guiContent = new GuiControl(ObjectBuilderGui, EditorGuiGroup) { profile = "ToolsGuiDefaultProfile"; horizSizing = "right"; vertSizing = "bottom"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/probeBakeDlg.gui b/Templates/BaseGame/game/tools/worldEditor/gui/probeBakeDlg.gui index ae952c9b8..cf4f2ad4b 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/probeBakeDlg.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/probeBakeDlg.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(ProbeBakeDlg) { +$guiContent = new GuiControl(ProbeBakeDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 2"; diff --git a/Templates/BaseGame/game/tools/worldEditor/gui/shadowViz.gui b/Templates/BaseGame/game/tools/worldEditor/gui/shadowViz.gui index e130850bd..997d05417 100644 --- a/Templates/BaseGame/game/tools/worldEditor/gui/shadowViz.gui +++ b/Templates/BaseGame/game/tools/worldEditor/gui/shadowViz.gui @@ -4,7 +4,7 @@ //--------------------------------------------------------------------------------------------- //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(AL_ShadowVizOverlayCtrl) { +$guiContent = new GuiControl(AL_ShadowVizOverlayCtrl) { canSaveDynamicFields = "0"; isContainer = "1"; Profile = "GuiModelessDialogProfile"; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript index 4a7f851fe..e7972a4c8 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/EditorGui.ed.tscript @@ -113,9 +113,9 @@ function EditorGui::init(%this) { // Load Terrain Painter GUI exec("~/worldEditor/gui/TerrainPainterWindow.ed.gui"); - if( isObject( %guiContent ) ){ - %this.add( %guiContent->TerrainPainter ); - %this.add( %guiContent->TerrainPainterPreview ); + if( isObject( $guiContent ) ){ + %this.add( $guiContent->TerrainPainter ); + %this.add( $guiContent->TerrainPainterPreview ); } exec("~/worldEditor/gui/guiTerrainMaterialDlg.ed.gui"); @@ -399,7 +399,7 @@ function EditorGui::addToToolsToolbar( %this, %pluginName, %internalName, %image Visible = "1"; Command = "EditorGui.setEditor(" @ %pluginName @ ");"; tooltipprofile = "ToolsGuiToolTipProfile"; - ToolTip = %tooltip; + ToolTip = "";// %tooltip; hovertime = "750"; bitmapAsset = %imageAsset; buttonType = "RadioButton"; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/ManageSFXParametersWindow.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/ManageSFXParametersWindow.ed.tscript index 934a35bd9..ef59de9c9 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/ManageSFXParametersWindow.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/ManageSFXParametersWindow.ed.tscript @@ -137,8 +137,7 @@ function EManageSFXParameters::onVisible( %this, %value ) if( %value ) { // Schedule an update. - - %this.schedule( %SFX_PARAMETERS_UPDATE_INTERVAL, "update" ); + %this.schedule( $SFX_PARAMETERS_UPDATE_INTERVAL, "update" ); } } @@ -770,7 +769,7 @@ function EManageSFXParameters::addParameter( %this, %parameter ) // Set the fields to reflect the parameter's current settings. - %ctrl-->valueField.setValue( %paramter.value ); + %ctrl-->valueField.setValue( %parameter.value ); %ctrl-->rangeMinField.setText( %parameter.range.x ); %ctrl-->rangeMaxField.setText( %parameter.range.y ); %ctrl-->defaultField.setValue( %parameter.defaultValue ); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript index 296fea200..0a47f96ee 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/interfaces/terrainMaterialDlg.ed.tscript @@ -298,7 +298,7 @@ function TerrainMaterialDlg::changeTerrainMatMapAsset(%this) %targetMap.setBitmap( %image ); - %targetMapName = %mapName @ "AssetId"; + %targetMapName = %targetMap @ "AssetId"; %targetMapName.setText(%imgAsset); TerrainMaterialDlg.matDirty = true; diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.tscript index a674aab8d..a1771cdcf 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/menuHandlers.ed.tscript @@ -892,6 +892,7 @@ function EditorToolsMenu::onSelectItem(%this, %id) { %toolName = getField( %this.item[%id], 2 ); + %paletteName = ""; EditorGui.setEditor(%toolName, %paletteName ); %this.checkRadioItem(0, %this.getItemCount(), %id); diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shadowViz.tscript b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shadowViz.tscript index bb07ba596..92cd4a6e5 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shadowViz.tscript +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/visibility/shadowViz.tscript @@ -34,7 +34,7 @@ singleton shaderData( AL_ShadowVisualizeShader ) pixVersion = 2.0; }; -new CustomMaterial( AL_ShadowVisualizeMaterial ) +singleton CustomMaterial( AL_ShadowVisualizeMaterial ) { shader = AL_ShadowVisualizeShader; stateBlock = AL_DepthVisualizeState; diff --git a/Templates/Modules/Verve/gui/VerveCinematic.gui b/Templates/Modules/Verve/gui/VerveCinematic.gui index f71a3171c..d12463244 100644 --- a/Templates/Modules/Verve/gui/VerveCinematic.gui +++ b/Templates/Modules/Verve/gui/VerveCinematic.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GameTSCtrl(VerveCinematicGui) { +$guiContent = new GameTSCtrl(VerveCinematicGui) { canSaveDynamicFields = "1"; Enabled = "1"; isContainer = "1"; diff --git a/Templates/Modules/inputTest/scripts/gui/inputMonitor.gui b/Templates/Modules/inputTest/scripts/gui/inputMonitor.gui index e1549f06f..67708cf2e 100644 --- a/Templates/Modules/inputTest/scripts/gui/inputMonitor.gui +++ b/Templates/Modules/inputTest/scripts/gui/inputMonitor.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(InputMonitorDlg) { +$guiContent = new GuiControl(InputMonitorDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/Modules/inputTest/scripts/gui/joystickSettings.gui b/Templates/Modules/inputTest/scripts/gui/joystickSettings.gui index d9b4d19a9..ca30235d4 100644 --- a/Templates/Modules/inputTest/scripts/gui/joystickSettings.gui +++ b/Templates/Modules/inputTest/scripts/gui/joystickSettings.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = new GuiControl(JoystickSettingsDlg) { +$guiContent = new GuiControl(JoystickSettingsDlg) { position = "0 0"; extent = "1024 768"; minExtent = "8 8"; diff --git a/Templates/Modules/vr/guis/oculusVROverlay.gui b/Templates/Modules/vr/guis/oculusVROverlay.gui index 62a9f719c..d05852cbd 100644 --- a/Templates/Modules/vr/guis/oculusVROverlay.gui +++ b/Templates/Modules/vr/guis/oculusVROverlay.gui @@ -1,5 +1,5 @@ //--- OBJECT WRITE BEGIN --- -%guiContent = singleton GuiControl(OculusVROverlay) { +$guiContent = singleton GuiControl(OculusVROverlay) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1";