diff -urN release-r77878/linden/etc/message.xml mono-based-on-r77880-r79030/linden/etc/message.xml --- release-r77878/linden/etc/message.xml 2008-01-31 11:04:05.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/etc/message.xml 2008-01-31 11:46:58.000000000 -0800 @@ -423,7 +423,6 @@ trusted-sender false - StartGroupProposal flavor @@ -459,7 +458,7 @@ false UpdateScriptAgentInventory - true + false UpdateGestureTaskInventory false @@ -468,7 +467,7 @@ true UpdateScriptTaskInventory - true + false ViewerStartAuction true diff -urN release-r77878/linden/indra/SConstruct mono-based-on-r77880-r79030/linden/indra/SConstruct --- release-r77878/linden/indra/SConstruct 2008-01-31 11:03:56.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/SConstruct 2008-01-31 11:46:52.000000000 -0800 @@ -29,6 +29,7 @@ import os import random import re +import popen2 import sys platform = sys.platform @@ -209,8 +210,12 @@ ./lldatabase ./llhavok ./llimage ./llinventory ./llmedia ./llmessage ./llprimitive ./llrender ./llscene ./llui ./llvfs ./llwindow ./llxml ./lscript ./lscript/lscript_compile + ./lscript/lscript_execute_mono ../libraries/include ../libraries/include/havok + ../libraries/i686-linux/include/glib-2.0 + ../libraries/include/glib-2.0 + ../libraries/include/mono """ + '../libraries/' + system_str + '/include' ) @@ -391,7 +396,7 @@ base_env = Environment(CXX = compiler, CPPPATH = include_dirs, LIBPATH = lib_path, - LINKFLAGS = system_link_flags + '--no-keep-memory --reduce-memory-overheads ' ) + LINKFLAGS = system_link_flags + '--export-dynamic --no-keep-memory --reduce-memory-overheads ' ) ### Environments for various build types ### @@ -761,10 +766,11 @@ internal_libs + external_libs) # Simulator - external_libs = common_external_libs + [ + Depends('newsim/simulator' + file_suffix, 'mapserver/mapserver' + file_suffix) + external_libs = ['mono', 'm', 'gthread-2.0', 'glib-2.0'] + common_external_libs + [ 'hkdynamics', 'hkgeometry', 'hkmath', 'hkbase', 'hkcollide', 'hkactions', 'boost_regex-gcc-mt', 'openjpeg', 'dl', 'kdu', - 'mysqlclient', 'iconv', 'tcmalloc', 'stacktrace', + 'mysqlclient', 'iconv', 'stacktrace', ] internal_libs = [ 'lscript', 'llprimitive', 'llscene', 'llhavok', 'llinventory', 'llimage', 'llimagej2coj', @@ -772,6 +778,8 @@ 'llmessage', 'llvfs', 'llmath', 'llcommon' ] create_executable('newsim/simulator' + file_suffix, 'newsim', internal_libs + external_libs) + external_libs = ['mono', 'm', 'gthread-2.0', 'glib-2.0'] + common_external_libs + # texture upload verifier external_libs = common_external_libs + [ 'kdu', 'openjpeg', 'dl' ] @@ -803,6 +811,32 @@ internal_libs = ['lscript', 'llmath', 'llcommon'] create_executable('web/doc/asset-upload/plugins/lsl_compiler/lslc' + file_suffix, 'web/doc/asset-upload/plugins/lsl_compiler/', internal_libs + external_libs); + # C# projects used by mono + # HACK! babbage: we should use SConscript(['lib/mono/1.0/SConscript']) + # to do this, but -j10 blows up mcs somehow even if we use scons + # to recursively launch 'scons -j1'. The only thing that seems to work + # is to use python to run the recursive scons -j1 before the outer + # scons starts building anything. + print 'Building lib/mono/1.0 with scons -j1 ...' + child = popen2.Popen3('cd lib/mono/1.0; scons -j1') + status = child.wait() + print 'Finished building lib/mono/1.0, status', status + + # Script tests + external_libs = ['mono', 'dl', 'm', 'gthread-2.0', 'glib-2.0'] + common_external_libs + internal_libs = ['lscript', 'llmath', 'llcommon'] + create_executable('lscript/lscript_execute_test/lscript_execute_test' + file_suffix, 'lscript/lscript_execute_test/', internal_libs + external_libs); + + + external_libs = ['mono', 'dl', 'm', 'gthread-2.0', 'glib-2.0'] + common_external_libs + internal_libs = ['lscript', 'llmath', 'llcommon'] + create_executable('lscript/lscript_execute_mono_test/lscript_execute_mono_test' + file_suffix, 'lscript/lscript_execute_mono_test/', internal_libs + external_libs); + + external_libs = ['mono', 'dl', 'm', 'gthread-2.0', 'glib-2.0'] + common_external_libs + internal_libs = ['lscript', 'llmath', 'llcommon'] + create_executable('lscript/lscript_mono_domain_test/lscript_mono_domain_test' + file_suffix, 'lscript/lscript_mono_domain_test/', internal_libs + external_libs); + + # Test Depends('test/test', 'newsim/simulator' + file_suffix) external_libs = common_external_libs + ['mysqlclient'] diff -urN release-r77878/linden/indra/indra_complete/indra_complete.sln mono-based-on-r77880-r79030/linden/indra/indra_complete/indra_complete.sln --- release-r77878/linden/indra/indra_complete/indra_complete.sln 2008-01-31 11:03:57.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/indra_complete/indra_complete.sln 2008-01-31 11:46:52.000000000 -0800 @@ -97,6 +97,7 @@ EndProjectSection EndProject ProjectSection(ProjectDependencies) = postProject + {7CDA991C-A262-4D18-96E2-38E2CC27A245} = {7CDA991C-A262-4D18-96E2-38E2CC27A245} {AF2D801E-EEE7-4B52-A025-F8E648ADC34B} = {AF2D801E-EEE7-4B52-A025-F8E648ADC34B} {7BCB4B2C-8378-4186-88EA-5742B5ABE17F} = {7BCB4B2C-8378-4186-88EA-5742B5ABE17F} {FCC4483C-5B84-4944-B91F-4589A219BC0B} = {FCC4483C-5B84-4944-B91F-4589A219BC0B} @@ -178,6 +179,10 @@ ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lscript_execute_mono", "..\lscript\lscript_execute_mono\lscript_execute_mono.vcproj", "{7CDA991C-A262-4D18-96E2-38E2CC27A245}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "..\test\test.vcproj", "{BBAA6588-CA96-4A87-A988-B02270B8D02B}" ProjectSection(ProjectDependencies) = postProject {7BCB4B2C-8378-4186-88EA-5742B5ABE17F} = {7BCB4B2C-8378-4186-88EA-5742B5ABE17F} @@ -236,6 +241,42 @@ ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainCreator", "..\lib\mono\1.0\DomainCreator.csproj", "{4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainRegister", "..\lib\mono\1.0\DomainRegister.csproj", "{7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UThread", "..\lib\mono\1.0\UThread.csproj", "{57F11B4C-4DF7-45CF-99B2-7AB283109EB9}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UThreadInjector", "..\lib\mono\1.0\UThreadInjector.csproj", "{278647FB-70F1-4770-B026-EF0573310EAE}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserScript", "..\lib\mono\1.0\UserScript.csproj", "{AF9B020E-4128-4775-B714-8847EB09A3A7}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LslUserScript", "..\lib\mono\1.0\LslUserScript.csproj", "{A14298C8-A261-4C76-9F76-14037FD66C5E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LslLibrary", "..\lib\mono\1.0\LslLibrary.csproj", "{56FA4404-FFEA-48FC-B5B6-994FD8CE4008}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptTypes", "..\lib\mono\1.0\ScriptTypes.csproj", "{334B3F6F-1289-40F1-9180-FF0441E34A9C}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Script", "..\lib\mono\1.0\Script.csproj", "{C9BF0EFB-728C-454E-968C-864AE95C8F68}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -468,6 +509,14 @@ {4B19F64E-AB97-4FB9-8E1D-74A8104DE0C4}.ReleaseForDownload.Build.0 = Release|Win32 {4B19F64E-AB97-4FB9-8E1D-74A8104DE0C4}.ReleaseNoOpt.ActiveCfg = ReleaseNoOpt|Win32 {4B19F64E-AB97-4FB9-8E1D-74A8104DE0C4}.ReleaseNoOpt.Build.0 = ReleaseNoOpt|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.Debug.ActiveCfg = Debug|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.Debug.Build.0 = Debug|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.Release.ActiveCfg = Release|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.Release.Build.0 = Release|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.ReleaseForDownload.ActiveCfg = Release|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.ReleaseForDownload.Build.0 = Release|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.ReleaseNoOpt.ActiveCfg = Release|Win32 + {7CDA991C-A262-4D18-96E2-38E2CC27A245}.ReleaseNoOpt.Build.0 = Release|Win32 {BBAA6588-CA96-4A87-A988-B02270B8D02B}.Debug.ActiveCfg = Debug|Win32 {BBAA6588-CA96-4A87-A988-B02270B8D02B}.Debug.Build.0 = Debug|Win32 {BBAA6588-CA96-4A87-A988-B02270B8D02B}.Release.ActiveCfg = Release|Win32 @@ -523,6 +572,78 @@ {4C8D64D5-649F-481E-96BE-EF1E82A77ACB}.ReleaseForDownload.Build.0 = Release|Win32 {4C8D64D5-649F-481E-96BE-EF1E82A77ACB}.ReleaseNoOpt.ActiveCfg = ReleaseNoOpt|Win32 {4C8D64D5-649F-481E-96BE-EF1E82A77ACB}.ReleaseNoOpt.Build.0 = ReleaseNoOpt|Win32 + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.Debug.ActiveCfg = Debug|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.Debug.Build.0 = Debug|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.Release.ActiveCfg = Release|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.Release.Build.0 = Release|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.ReleaseForDownload.ActiveCfg = Release|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.ReleaseForDownload.Build.0 = Release|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.ReleaseNoOpt.ActiveCfg = Release|.NET + {4D76B7F4-CAEC-47FE-86A0-BFB8B406D845}.ReleaseNoOpt.Build.0 = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.Debug.ActiveCfg = Debug|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.Debug.Build.0 = Debug|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.Release.ActiveCfg = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.Release.Build.0 = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.ReleaseForDownload.ActiveCfg = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.ReleaseForDownload.Build.0 = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.ReleaseNoOpt.ActiveCfg = Release|.NET + {7DEBEBAA-2391-4D85-9E3A-5D1865D310E6}.ReleaseNoOpt.Build.0 = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.Debug.ActiveCfg = Debug|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.Debug.Build.0 = Debug|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.Release.ActiveCfg = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.Release.Build.0 = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.ReleaseForDownload.ActiveCfg = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.ReleaseForDownload.Build.0 = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.ReleaseNoOpt.ActiveCfg = Release|.NET + {57F11B4C-4DF7-45CF-99B2-7AB283109EB9}.ReleaseNoOpt.Build.0 = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.Debug.ActiveCfg = Debug|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.Debug.Build.0 = Debug|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.Release.ActiveCfg = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.Release.Build.0 = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.ReleaseForDownload.ActiveCfg = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.ReleaseForDownload.Build.0 = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.ReleaseNoOpt.ActiveCfg = Release|.NET + {278647FB-70F1-4770-B026-EF0573310EAE}.ReleaseNoOpt.Build.0 = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.Debug.ActiveCfg = Debug|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.Debug.Build.0 = Debug|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.Release.ActiveCfg = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.Release.Build.0 = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.ReleaseForDownload.ActiveCfg = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.ReleaseForDownload.Build.0 = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.ReleaseNoOpt.ActiveCfg = Release|.NET + {AF9B020E-4128-4775-B714-8847EB09A3A7}.ReleaseNoOpt.Build.0 = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.Debug.ActiveCfg = Debug|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.Debug.Build.0 = Debug|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.Release.ActiveCfg = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.Release.Build.0 = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.ReleaseForDownload.ActiveCfg = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.ReleaseForDownload.Build.0 = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.ReleaseNoOpt.ActiveCfg = Release|.NET + {A14298C8-A261-4C76-9F76-14037FD66C5E}.ReleaseNoOpt.Build.0 = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.Debug.ActiveCfg = Debug|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.Debug.Build.0 = Debug|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.Release.ActiveCfg = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.Release.Build.0 = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.ReleaseForDownload.ActiveCfg = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.ReleaseForDownload.Build.0 = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.ReleaseNoOpt.ActiveCfg = Release|.NET + {56FA4404-FFEA-48FC-B5B6-994FD8CE4008}.ReleaseNoOpt.Build.0 = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.Debug.ActiveCfg = Debug|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.Debug.Build.0 = Debug|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.Release.ActiveCfg = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.Release.Build.0 = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.ReleaseForDownload.ActiveCfg = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.ReleaseForDownload.Build.0 = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.ReleaseNoOpt.ActiveCfg = Release|.NET + {334B3F6F-1289-40F1-9180-FF0441E34A9C}.ReleaseNoOpt.Build.0 = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.Debug.ActiveCfg = Debug|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.Debug.Build.0 = Debug|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.Release.ActiveCfg = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.Release.Build.0 = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.ReleaseForDownload.ActiveCfg = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.ReleaseForDownload.Build.0 = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.ReleaseNoOpt.ActiveCfg = Release|.NET + {C9BF0EFB-728C-454E-968C-864AE95C8F68}.ReleaseNoOpt.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff -urN release-r77878/linden/indra/llcommon/llassettype.cpp mono-based-on-r77880-r79030/linden/indra/llcommon/llassettype.cpp --- release-r77878/linden/indra/llcommon/llassettype.cpp 2008-01-31 11:03:57.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llcommon/llassettype.cpp 2008-01-31 11:46:52.000000000 -0800 @@ -128,7 +128,7 @@ "jpeg", "animatn", "gesture", - "simstate", + "simstate" }; // This table is meant for decoding to human readable form. Put any @@ -158,7 +158,7 @@ "jpeg image", "animation", "gesture", - "simstate", + "simstate" }; ///---------------------------------------------------------------------------- diff -urN release-r77878/linden/indra/llcommon/llcommon_vc8.vcproj mono-based-on-r77880-r79030/linden/indra/llcommon/llcommon_vc8.vcproj --- release-r77878/linden/indra/llcommon/llcommon_vc8.vcproj 2008-01-31 11:03:57.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llcommon/llcommon_vc8.vcproj 2008-01-31 11:46:52.000000000 -0800 @@ -109,7 +109,6 @@ /> - - @@ -603,10 +595,6 @@ > - - diff -urN release-r77878/linden/indra/llcommon/llversionserver.h mono-based-on-r77880-r79030/linden/indra/llcommon/llversionserver.h --- release-r77878/linden/indra/llcommon/llversionserver.h 2008-01-31 11:03:57.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llcommon/llversionserver.h 2008-01-31 11:46:52.000000000 -0800 @@ -37,7 +37,7 @@ const S32 LL_VERSION_PATCH = 6; const S32 LL_VERSION_BUILD = 76747; -const char * const LL_CHANNEL = "Second Life Server"; +const char * const LL_CHANNEL = "Mono"; #endif diff -urN release-r77878/linden/indra/llcommon/llversionviewer.h mono-based-on-r77880-r79030/linden/indra/llcommon/llversionviewer.h --- release-r77878/linden/indra/llcommon/llversionviewer.h 2008-01-31 11:03:57.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llcommon/llversionviewer.h 2008-01-31 11:46:52.000000000 -0800 @@ -35,7 +35,7 @@ const S32 LL_VERSION_MAJOR = 1; const S32 LL_VERSION_MINOR = 18; const S32 LL_VERSION_PATCH = 6; -const S32 LL_VERSION_BUILD = 4; +const S32 LL_VERSION_BUILD = 77968; const char * const LL_CHANNEL = "Second Life Release"; diff -urN release-r77878/linden/indra/llmessage/llhttpclient.cpp mono-based-on-r77880-r79030/linden/indra/llmessage/llhttpclient.cpp --- release-r77878/linden/indra/llmessage/llhttpclient.cpp 2008-01-31 11:03:58.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llmessage/llhttpclient.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -204,16 +204,21 @@ LLBufferStream ostream(channels, buffer.get()); llifstream fstream(mFilename.c_str(), std::iostream::binary | std::iostream::out); - fstream.seekg(0, std::ios::end); - U32 fileSize = fstream.tellg(); - fstream.seekg(0, std::ios::beg); - char* fileBuffer; - fileBuffer = new char [fileSize]; - fstream.read(fileBuffer, fileSize); - ostream.write(fileBuffer, fileSize); - fstream.close(); - eos = true; - return STATUS_DONE; + if(fstream.is_open()) + { + fstream.seekg(0, std::ios::end); + U32 fileSize = fstream.tellg(); + fstream.seekg(0, std::ios::beg); + char* fileBuffer; + fileBuffer = new char [fileSize]; + fstream.read(fileBuffer, fileSize); + ostream.write(fileBuffer, fileSize); + fstream.close(); + eos = true; + return STATUS_DONE; + } + + return STATUS_ERROR; } const std::string mFilename; diff -urN release-r77878/linden/indra/llmessage/llsdmessagereader.cpp mono-based-on-r77880-r79030/linden/indra/llmessage/llsdmessagereader.cpp --- release-r77878/linden/indra/llmessage/llsdmessagereader.cpp 2008-01-31 11:03:58.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llmessage/llsdmessagereader.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -63,14 +63,20 @@ } if(! input[block].isArray()) { - llerrs << "block " << block << " not found" << llendl; + // NOTE: babbage: need to return default for missing blocks to allow + // backwards/forwards compatibility - handlers must cope with default + // values. + llwarns << "block " << block << " not found" << llendl; return LLSD(); } LLSD result = input[block][blocknum][var]; if(result.isUndefined()) { - llerrs << "var " << var << " not found" << llendl; + // NOTE: babbage: need to return default for missing vars to allow + // backwards/forwards compatibility - handlers must cope with default + // values. + llwarns << "var " << var << " not found" << llendl; } return result; } diff -urN release-r77878/linden/indra/llmessage/llurlrequest.cpp mono-based-on-r77880-r79030/linden/indra/llmessage/llurlrequest.cpp --- release-r77878/linden/indra/llmessage/llurlrequest.cpp 2008-01-31 11:03:58.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/llmessage/llurlrequest.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -369,6 +369,8 @@ #endif // LL_DARWIN << ", " << (mDetail->mURL ? mDetail->mURL : "") + << ", " + << (mDetail->mCurlErrorBuf ? mDetail->mCurlErrorBuf : "") << llendl; status = STATUS_ERROR; break; diff -urN release-r77878/linden/indra/lscript/files.lst mono-based-on-r77880-r79030/linden/indra/lscript/files.lst --- release-r77878/linden/indra/lscript/files.lst 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/files.lst 2008-01-31 11:46:53.000000000 -0800 @@ -14,3 +14,12 @@ lscript/lscript_library/lscript_alloc.cpp lscript/lscript_library/lscript_library.cpp lscript/lscript_library/lscript_export.cpp +lscript/lscript_execute_mono/assembly.cpp +lscript/lscript_execute_mono/mono_domain.cpp +lscript/lscript_execute_mono/mono_memory_monitor.cpp +lscript/lscript_execute_mono/mono_uthread_class.cpp +lscript/lscript_execute_mono/mono_script_class.cpp +lscript/lscript_execute_mono/mono_script_data.cpp +lscript/lscript_execute_mono/mono_domain_manager.cpp +lscript/lscript_execute_mono/mono_helpers.cpp +lscript/lscript_execute_mono/size.cpp diff -urN release-r77878/linden/indra/lscript/lscript_byteconvert.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_byteconvert.h --- release-r77878/linden/indra/lscript/lscript_byteconvert.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_byteconvert.h 2008-01-31 11:46:53.000000000 -0800 @@ -402,7 +402,7 @@ reset_hp_to_safe_spot(stream); // lsa_print_heap((U8 *)stream); } - fr = LSCRIPTRunTimeFaultBits[fault]; + fr = fault; set_register((U8 *)stream, LREG_FR, fr); } } diff -urN release-r77878/linden/indra/lscript/lscript_byteformat.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_byteformat.h --- release-r77878/linden/indra/lscript/lscript_byteformat.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_byteformat.h 2008-01-31 11:46:53.000000000 -0800 @@ -512,26 +512,12 @@ LSRF_CHAT_OVERRUN, LSRF_TOO_MANY_LISTENS, LSRF_NESTING_LISTS, + LSRF_CLI, LSRF_EOF } LSCRIPTRunTimeFaults; extern char* LSCRIPTRunTimeFaultStrings[LSRF_EOF]; /*Flawfinder: ignore*/ -const S32 LSCRIPTRunTimeFaultBits[LSRF_EOF] = -{ - 0, // LSRF_INVALID - 1, // LSRF_MATH - 2, // LSRF_STACK_HEAP_COLLISION - 3, // LSREF_BOUND_CHECK_ERROR - 4, // LSREF_HEAP_ERROR - 5, // LSREF_VERSION_MISMATCH - 6, // LSREF_MISSING_INVENTORY - 7, // LSRF_SANDBOX - 8, // LSRF_CHAT_OVERRUN - 9, // LSRF_TOO_MANY_LISTENS - 10, // LSRF_NESTING_LISTS -}; - typedef enum e_lscript_runtime_permissions { SCRIPT_PERMISSION_DEBIT, diff -urN release-r77878/linden/indra/lscript/lscript_compile/indra.l mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/indra.l --- release-r77878/linden/indra/lscript/lscript_compile/indra.l 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/indra.l 2008-01-31 11:46:53.000000000 -0800 @@ -655,7 +655,7 @@ //#define EMIT_CIL_ASSEMBLER BOOL lscript_compile(const char* src_filename, const char* dst_filename, - const char* err_filename, BOOL is_god_like) + const char* err_filename, BOOL compile_to_mono, const char* class_name, BOOL is_god_like) { BOOL b_parse_ok = FALSE; BOOL b_dummy = FALSE; @@ -697,6 +697,8 @@ } gScriptp->mGodLike = is_god_like; + + gScriptp->setClassName(class_name); gScopeStringTable = new LLStringTable(16384); #ifdef EMERGENCY_DEBUG_PRINTOUTS @@ -712,23 +714,14 @@ #ifdef EMERGENCY_DEBUG_PRINTOUTS gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); #endif -#ifdef EMIT_CIL_ASSEMBLER - const char* cil_output_file_name = dst_filename? dst_filename : "lscript.cil"; - FILE* cilout = LLFile::fopen(cil_output_file_name, "w"); - if(NULL == cilout) + if(TRUE == compile_to_mono) { - fprintf(yyout, "Error opening cil output file %s\n", cil_output_file_name); + gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_CIL_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); } else { - gScriptp->recurse(cilout, 0, 0, LSCP_EMIT_CIL_ASSEMBLY, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); - if(fclose(cilout) == EOF) - { - fprintf(yyout, "Error closing cil output file %s\n", cil_output_file_name); - } + gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_BYTE_CODE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); } -#endif - gScriptp->recurse(yyout, 0, 0, LSCP_EMIT_BYTE_CODE, LSPRUNE_INVALID, b_dummy, NULL, type, type, b_dummy_count, NULL, NULL, 0, NULL, 0, NULL); } delete gScopeStringTable; gScopeStringTable = NULL; @@ -747,13 +740,15 @@ } -BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE) +BOOL lscript_compile(char *filename, BOOL compile_to_mono, BOOL is_god_like = FALSE) { char src_filename[MAX_STRING]; sprintf(src_filename, "%s.lsl", filename); char err_filename[MAX_STRING]; sprintf(err_filename, "%s.out", filename); - return lscript_compile(src_filename, NULL, err_filename, is_god_like); + char class_name[MAX_STRING]; + sprintf(class_name, "%s", filename); + return lscript_compile(src_filename, NULL, err_filename, compile_to_mono, class_name, is_god_like); } diff -urN release-r77878/linden/indra/lscript/lscript_compile/lscript_error.cpp mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_error.cpp --- release-r77878/linden/indra/lscript/lscript_compile/lscript_error.cpp 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_error.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -72,7 +72,10 @@ "Use of vector or quaternion method on incorrect type", "Lists can't be included in lists", "Unitialized variables can't be included in lists", - "Declaration requires a new scope -- use { and }" + "Declaration requires a new scope -- use { and }", + "CIL assembler failed", + "Bytecode transformer failed", + "Bytecode verification failed" }; void LLScriptGenerateErrorText::writeWarning(FILE *fp, LLScriptFilePosition *pos, LSCRIPTWarnings warning) @@ -98,3 +101,8 @@ fprintf(fp, "(%d, %d) : ERROR : %s\n", line, col, gErrorText[error]); mTotalErrors++; } + +std::string getLScriptErrorString(LSCRIPTErrors error) +{ + return gErrorText[error]; +} diff -urN release-r77878/linden/indra/lscript/lscript_compile/lscript_error.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_error.h --- release-r77878/linden/indra/lscript/lscript_compile/lscript_error.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_error.h 2008-01-31 11:46:53.000000000 -0800 @@ -124,6 +124,9 @@ LSERROR_NO_LISTS_IN_LISTS, LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS, LSERROR_NEED_NEW_SCOPE, + LSERROR_CIL_ASSEMBLER_FAILED = 16, // Mono build error. + LSERROR_BYTECODE_TRANSFORM_FAILED = 17, // Mono build error. + LSERROR_BYTECODE_VERIFICATION_FAILED, // Mono build error. LSERROR_EOF } LSCRIPTErrors; @@ -147,6 +150,8 @@ S32 mTotalWarnings; }; +std::string getLScriptErrorString(LSCRIPTErrors error); + extern LLScriptGenerateErrorText gErrorToText; #endif diff -urN release-r77878/linden/indra/lscript/lscript_compile/lscript_tree.cpp mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_tree.cpp --- release-r77878/linden/indra/lscript/lscript_compile/lscript_tree.cpp 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_tree.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -43,7 +43,7 @@ //#define LSL_INCLUDE_DEBUG_INFO -void print_cil_box(FILE* fp, LSCRIPTType type) +static void print_cil_box(FILE* fp, LSCRIPTType type) { switch(type) { @@ -51,24 +51,28 @@ fprintf(fp, "box [mscorlib]System.Int32\n"); break; case LST_FLOATINGPOINT: - fprintf(fp, "box [mscorlib]System.Double\n"); + fprintf(fp, "box [mscorlib]System.Single\n"); break; case LST_STRING: case LST_KEY: - fprintf(fp, "box [mscorlib]System.String\n"); + // System.String is not a System.ValueType, so does not need to be boxed. + //fprintf(fp, "box [mscorlib]System.String\n"); break; case LST_VECTOR: - fprintf(fp, "box [LScriptLibrary]LLVector\n"); + // LLVector is now not a System.ValueType, so does not need to be boxed. + //fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Vector\n"); break; case LST_QUATERNION: - fprintf(fp, "box [LScriptLibrary]LLQuaternion\n"); + // LLQuaternion is now not a System.ValueType, so does not need to be boxed. + //fprintf(fp, "box [ScriptTypes]LindenLab.SecondLife.Quaternion\n"); break; default: + llassert(false); break; } } -void print_cil_type(FILE* fp, LSCRIPTType type) +static void print_cil_type(FILE* fp, LSCRIPTType type) { switch(type) { @@ -83,10 +87,10 @@ fprintf(fp, "string"); break; case LST_VECTOR: - fprintf(fp, "valuetype [LScriptLibrary]LLVector"); + fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Vector"); break; case LST_QUATERNION: - fprintf(fp, "valuetype [LScriptLibrary]LLQuaternion"); + fprintf(fp, "class [ScriptTypes]LindenLab.SecondLife.Quaternion"); break; case LST_LIST: fprintf(fp, "class [mscorlib]System.Collections.ArrayList"); @@ -189,6 +193,7 @@ break; case LSCP_EMIT_CIL_ASSEMBLY: fprintf(fp, "ldc.i4 %d\n", mValue); + type = mType; break; default: break; @@ -236,7 +241,9 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - fprintf(fp, "ldc.r8 %5.5f\n", mValue); // NOTE: Precision? + fprintf(fp, "ldc.r8 %f\n", mValue); // NOTE: Precision? + type = mType; + break; default: break; } @@ -247,16 +254,34 @@ return LSCRIPTDataSize[LST_FLOATINGPOINT]; } -void print_escape_quotes(FILE* fp, const char* str) +void print_escaped(FILE* fp, const char* str) { putc('"', fp); for(const char* c = str; *c != '\0'; ++c) { - if(*c == '"') + switch(*c) { - putc('\\', fp); + case '"': + putc('\\', fp); + putc(*c, fp); + break; + case '\n': + putc('\\', fp); + putc('n', fp); + break; + case '\t': + putc(' ', fp); + putc(' ', fp); + putc(' ', fp); + putc(' ', fp); + break; + case '\\': + putc('\\', fp); + putc('\\', fp); + break; + default: + putc(*c, fp); } - putc(*c, fp); } putc('"', fp); } @@ -293,7 +318,7 @@ case LSCP_TO_STACK: { chunk->addByte(LSCRIPTOpCodes[LOPC_PUSHARGS]); - chunk->addBytes(mValue, (S32)strlen(mValue) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(mValue, (S32)strlen(mValue) + 1); type = mType; } break; @@ -304,7 +329,7 @@ break; case LSCP_EMIT_CIL_ASSEMBLY: fprintf(fp, "ldstr "); - print_escape_quotes(fp, mValue); + print_escaped(fp, mValue); fprintf(fp, "\n"); default: break; @@ -313,10 +338,9 @@ S32 LLScriptConstantString::getSize() { - return (S32)strlen(mValue) + 1; /*Flawfinder: ignore*/ + return (S32)strlen(mValue) + 1; } - void LLScriptIdentifier::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -388,7 +412,7 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - fprintf(fp, "%s", mName); + fprintf(fp, "'%s'", mName); break; default: break; @@ -428,6 +452,12 @@ return 0; } +static void print_cil_member(FILE* fp, LLScriptIdentifier *ident) +{ + print_cil_type(fp, ident->mScopeEntry->mType); + fprintf(fp, " %s::'%s'\n", gScriptp->getClassName(), ident->mScopeEntry->mIdentifier); +} + void LLScriptSAIdentifier::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -497,6 +527,19 @@ } } break; + + case LSCP_EMIT_CIL_ASSEMBLY: + { + fprintf(fp, "ldarg.0\n"); + fprintf(fp, "ldfld "); + print_cil_member(fp, mIdentifier); + fprintf(fp, "\n"); + if (mNextp) + { + mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + } + break; + } default: mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); if (mNextp) @@ -553,7 +596,7 @@ return mConstant->getSize(); } -void print_cil_cast(FILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) +static void print_cil_cast(FILE* fp, LSCRIPTType srcType, LSCRIPTType targetType) { switch(srcType) { @@ -568,8 +611,8 @@ break; case LST_LIST: fprintf(fp, "box [mscorlib]System.Int32\n"); - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::CreateList()\n"); - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(object, class [mscorlib]System.Collections.ArrayList)\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -582,10 +625,12 @@ fprintf(fp, "conv.i4\n"); break; case LST_STRING: - fprintf(fp, "call string class [mscorlib]System.Convert::ToString(float32)\n"); + fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::FloatToString(float32)\n"); break; case LST_LIST: - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); + fprintf(fp, "box [mscorlib]System.Single\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -595,19 +640,21 @@ switch(targetType) { case LST_INTEGER: - fprintf(fp, "call int32 valuetype [mscorlib]System.Int32::Parse(string)\n"); + fprintf(fp, "call int32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToInt(string)\n"); break; case LST_FLOATINGPOINT: - fprintf(fp, "call float64 valuetype [mscorlib]System.Double::Parse(string)\n"); + fprintf(fp, "call float32 [LslLibrary]LindenLab.SecondLife.LslRunTime::StringToFloat(string)\n"); break; case LST_LIST: - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); + //fprintf(fp, "box [mscorlib]System.String\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; case LST_VECTOR: - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'Parse'(string)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseVector'(string)\n"); break; case LST_QUATERNION: - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'Parse'(string)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'ParseQuaternion'(string)\n"); break; default: break; @@ -621,7 +668,9 @@ case LST_STRING: break; case LST_LIST: - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); + //fprintf(fp, "box [mscorlib]System.String\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -633,10 +682,11 @@ case LST_VECTOR: break; case LST_STRING: - fprintf(fp, "call string valuetype [LScriptLibrary]LLVector::'ToString'(valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call instance string class [ScriptTypes]LindenLab.SecondLife.Vector::'ToString'()\n"); break; case LST_LIST: - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -648,10 +698,11 @@ case LST_QUATERNION: break; case LST_STRING: - fprintf(fp, "call string valuetype [LScriptLibrary]LLQuaternion::'ToString'(valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call instance string class [ScriptTypes]LindenLab.SecondLife.Quaternion::'ToString'()\n"); break; case LST_LIST: - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LScriptLibrary]LScriptInternal::CreateList(object)\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -663,7 +714,7 @@ case LST_LIST: break; case LST_STRING: - fprintf(fp, "call string [LScriptLibrary]LScriptInternal::ListToString(class [mscorlib]System.Collections.ArrayList)\n"); + fprintf(fp, "call string [LslLibrary]LindenLab.SecondLife.LslRunTime::ListToString(class [mscorlib]System.Collections.ArrayList)\n"); break; default: break; @@ -674,10 +725,32 @@ } } -bool is_SA_constant_integer(LLScriptSimpleAssignable* sa) +// HACK! Babbage: should be converted to virtual on LSCRIPTSimpleAssignableType to avoid downcasts. +LSCRIPTType get_type(LLScriptSimpleAssignable* sa) { - // HACK: Downcast based on type. - return (sa->mType == LSSAT_CONSTANT && ((LLScriptSAConstant*) sa)->mConstant->mType == LST_INTEGER); + LSCRIPTType result = LST_NULL; + switch(sa->mType) + { + case LSSAT_IDENTIFIER: + result = ((LLScriptSAIdentifier*) sa)->mIdentifier->mScopeEntry->mType; + break; + case LSSAT_CONSTANT: + result = ((LLScriptSAConstant*) sa)->mConstant->mType; + break; + case LSSAT_VECTOR_CONSTANT: + result = LST_VECTOR; + break; + case LSSAT_QUATERNION_CONSTANT: + result = LST_QUATERNION; + break; + case LSSAT_LIST_CONSTANT: + result = LST_LIST; + break; + default: + result = LST_UNDEFINED; + break; + } + return result; } void LLScriptSAVector::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) @@ -786,23 +859,23 @@ // Load arguments. mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry1)) + if(LST_INTEGER == get_type(mEntry1)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry3)) + if(LST_INTEGER == get_type(mEntry2)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry3)) + if(LST_INTEGER == get_type(mEntry3)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'create'(float32, float32, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); // Next. if (mNextp) @@ -952,28 +1025,28 @@ // Load arguments. mEntry1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry1)) + if(LST_INTEGER == get_type(mEntry1)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } mEntry2->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry2)) + if(LST_INTEGER == get_type(mEntry2)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } mEntry3->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry3)) + if(LST_INTEGER == get_type(mEntry3)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } mEntry4->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if(is_SA_constant_integer(mEntry4)) + if(LST_INTEGER == get_type(mEntry4)) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'create'(float32, float32, float32, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); // Next. if (mNextp) @@ -1049,6 +1122,40 @@ } } break; + case LSCP_EMIT_CIL_ASSEMBLY: + { + // Create list. + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + + // Add elements. + LLScriptSimpleAssignable* current_entry = mEntryList; + LLScriptSimpleAssignable* next_entry = NULL; + while(NULL != current_entry) + { + next_entry = current_entry->mNextp; + + // Null mNextp pointer, so only current list element is processed. + current_entry->mNextp = NULL; + current_entry->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + + // Restore mNextp pointer. + current_entry->mNextp = next_entry; + + // Box element and store in list. + print_cil_box(fp, get_type(current_entry)); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, object)\n"); + + // Process next element. + current_entry = next_entry; + } + + // Process next list. + if (mNextp) + { + mNextp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + } + } + break; default: if (mEntryList) mEntryList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, ldata); @@ -1093,6 +1200,44 @@ } } +// Push initialised variable of type on to stack. +static void print_cil_init_variable(FILE* fp, LSCRIPTType type) +{ + switch(type) + { + case LST_INTEGER: + fprintf(fp, "ldc.i4.0\n"); + break; + case LST_FLOATINGPOINT: + fprintf(fp, "ldc.r8 0\n"); + break; + case LST_STRING: + fprintf(fp, "ldstr \"\"\n"); + break; + case LST_KEY: + fprintf(fp, "ldstr \"00000000-0000-0000-0000-000000000000\"\n"); + break; + case LST_VECTOR: + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); + break; + case LST_QUATERNION: + fprintf(fp, "ldc.r8 1\n"); + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "ldc.r8 0\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); + break; + case LST_LIST: + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); + break; + default: + break; + } +} + void LLScriptGlobalVariable::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -1164,7 +1309,7 @@ // it also includes the name of the variable as well as the type // plus 4 bytes of offset from it's apparent address to the actual data #ifdef LSL_INCLUDE_DEBUG_INFO - count += strlen(mIdentifier->mName) + 1 + 1 + 4; /*Flawfinder: ignore*/ + count += strlen(mIdentifier->mName) + 1 + 1 + 4; #else count += 1 + 1 + 4; #endif @@ -1187,7 +1332,7 @@ chunk->addBytes(&vtype, 1); // null terminated name #ifdef LSL_INCLUDE_DEBUG_INFO - chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); #else chunk->addBytes(1); #endif @@ -1257,16 +1402,27 @@ case LSCP_EMIT_CIL_ASSEMBLY: // Initialisation inside ctor. + fprintf(fp, "ldarg.0\n"); if (mAssignable) { - fprintf(fp, "ldarg.0\n"); + // Initialise to value. mAssignable->recurse(fp, tabs, tabsize, LSCP_EMIT_CIL_ASSEMBLY, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "stfld "); - mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp," LSL::"); - mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "\n"); + if((LST_INTEGER == get_type(mAssignable)) && (LST_FLOATINGPOINT == mType->mType)) + { + print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); + } } + else + { + // Initialise to zero. + print_cil_init_variable(fp, mType->mType); + } + // Store value. + fprintf(fp, "stfld "); + mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp," %s::", gScriptp->getClassName()); + mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "\n"); break; default: mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -1318,7 +1474,7 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "state_entry"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; @@ -1354,7 +1510,7 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "state_exit"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; @@ -1412,11 +1568,18 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "touch_start"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "touch_start( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1470,11 +1633,18 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "touch"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "touch( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1528,11 +1698,18 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "touch_end"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "touch_end( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1586,11 +1763,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "collision_start"; - chunk->addBytes(name, (S32)strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, (S32)strlen(name) + 1); + chunk->addBytes(mCount->mName, (S32)strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "collision_start( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1644,11 +1827,16 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "collision"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "collision( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1702,11 +1890,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "collision_end"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mCount->mName, strlen(mCount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "collision_end( int32 "); + mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mCount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1759,11 +1953,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "land_collision_start"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "land_collision_start( class [ScriptTypes]LindenLab.SecondLife.Vector "); + mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1818,11 +2018,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "land_collision"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "land_collision( class [ScriptTypes]LindenLab.SecondLife.Vector "); + mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1875,12 +2081,18 @@ case LSCP_EMIT_BYTE_CODE: { #ifdef LSL_INCLUDE_DEBUG_INFO - char name[] = "land_collision_end"; /*Flawfinder: ignore*/ - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); /*Flawfinder: ignore*/ + char name[] = "land_collision_end"; + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mPosition->mName, strlen(mPosition->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "land_collision_end( class [ScriptTypes]LindenLab.SecondLife.Vector "); + mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1934,11 +2146,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "changed"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mChange->mName, strlen(mChange->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "changed( int32 "); + mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mChange->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -1991,11 +2209,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "attach"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mAttach->mName, strlen(mAttach->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "attach( string "); + mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )\n"); + break; default: mAttach->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -2061,12 +2285,20 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "dataserver"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mData->mName, strlen(mData->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mID->mName, strlen(mID->mName) + 1); + chunk->addBytes(mData->mName, strlen(mData->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "dataserver( string "); + mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mData->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2099,10 +2331,13 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "timer"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "timer()"); + break; default: break; } @@ -2130,10 +2365,13 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "moving_start"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "moving_start()"); + break; default: break; } @@ -2161,10 +2399,13 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "moving_end"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "moving_end()"); + break; default: break; } @@ -2215,11 +2456,18 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "chat"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mRTPermissions->mName, strlen(mRTPermissions->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + // TODO: Determine if this is broken: chat == run time permissions?? + fdotabs(fp, tabs, tabsize); + fprintf(fp, "chat( int32 "); + mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mRTPermissions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -2311,14 +2559,26 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "chat"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); + chunk->addBytes(mName->mName, strlen(mName->mName) + 1); + chunk->addBytes(mID->mName, strlen(mID->mName) + 1); + chunk->addBytes(mMessage->mName, strlen(mMessage->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "chat( int32 "); + mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mMessage->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2374,11 +2634,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "sensor"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "sensor( int32 "); + mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -2431,11 +2697,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "sensor"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mID->mName, strlen(mID->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "object_rez( string "); + mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -2514,13 +2786,23 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "control"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mName->mName, strlen(mName->mName) + 1); + chunk->addBytes(mLevels->mName, strlen(mLevels->mName) + 1); + chunk->addBytes(mEdges->mName, strlen(mEdges->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "control( string "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mEdges->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLevels->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2614,14 +2896,26 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "link_message"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mID->mName, strlen(mID->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); + chunk->addBytes(mNum->mName, strlen(mNum->mName) + 1); + chunk->addBytes(mStr->mName, strlen(mStr->mName) + 1); + chunk->addBytes(mID->mName, strlen(mID->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "link_message( int32 "); + mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mStr->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mNum->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2742,16 +3036,32 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "remote_event"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mType->mName, strlen(mType->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mType->mName, strlen(mType->mName) + 1); + chunk->addBytes(mChannel->mName, strlen(mChannel->mName) + 1); + chunk->addBytes(mMessageID->mName, strlen(mMessageID->mName) + 1); + chunk->addBytes(mSender->mName, strlen(mSender->mName) + 1); + chunk->addBytes(mIntVal->mName, strlen(mIntVal->mName) + 1); + chunk->addBytes(mStrVal->mName, strlen(mStrVal->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "remote_event( int32 "); + mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mMessageID->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mSender->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mIntVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mStrVal->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mChannel->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2784,7 +3094,7 @@ mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, ", integer "); mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, ", list "); + fprintf(fp, ", class [mscorlib]System.Collections.ArrayList "); mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, ", string "); mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2857,15 +3167,26 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "http_response"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mRequestId->mName, strlen(mRequestId->mName) + 1); + chunk->addBytes(mStatus->mName, strlen(mStatus->mName) + 1); + chunk->addBytes(mMetadata->mName, strlen(mMetadata->mName) + 1); + chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); #endif } break; - + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "http_response( string "); + mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", class [mscorlib]System.Collections.ArrayList "); + mMetadata->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )\n"); + break; default: mRequestId->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mStatus->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -2935,12 +3256,20 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "money"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mName->mName, strlen(mName->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mName->mName, strlen(mName->mName) + 1); + chunk->addBytes(mAmount->mName, strlen(mAmount->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "money( string "); + mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mName->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mAmount->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -3046,15 +3375,29 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "email"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mTime->mName, strlen(mTime->mName) + 1); + chunk->addBytes(mAddress->mName, strlen(mAddress->mName) + 1); + chunk->addBytes(mSubject->mName, strlen(mSubject->mName) + 1); + chunk->addBytes(mBody->mName, strlen(mBody->mName) + 1); + chunk->addBytes(mNumber->mName, strlen(mNumber->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "email( string "); + mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mSubject->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", string "); + mBody->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", int32 "); + mNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mTime->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mAddress->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -3111,11 +3454,17 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "rez"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mStartParam->mName, strlen(mStartParam->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "rez( int32 "); + mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mStartParam->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -3147,10 +3496,13 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "no_sensor"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "no_sensor()"); + break; default: break; } @@ -3226,14 +3578,24 @@ case LSCP_EMIT_BYTE_CODE: { #ifdef LSL_INCLUDE_DEBUG_INFO - char name[] = "at_target"; /*Flawfinder: ignore*/ - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1); /*Flawfinder: ignore*/ + char name[] = "at_target"; + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); + chunk->addBytes(mTargetPosition->mName, strlen(mTargetPosition->mName) + 1); + chunk->addBytes(mOurPosition->mName, strlen(mOurPosition->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "at_target( int32 "); + mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector "); + mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Vector "); + mOurPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mTargetPosition->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -3268,11 +3630,14 @@ case LSCP_EMIT_BYTE_CODE: { #ifdef LSL_INCLUDE_DEBUG_INFO - char name[] = "not_at_target"; /*Flawfinder: ignore*/ - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + char name[] = "not_at_target"; + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "not_at_target()"); + break; default: break; } @@ -3349,13 +3714,23 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "at_rot_target"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1); /*Flawfinder: ignore*/ - chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); + chunk->addBytes(mTargetNumber->mName, strlen(mTargetNumber->mName) + 1); + chunk->addBytes(mTargetRotation->mName, strlen(mTargetRotation->mName) + 1); + chunk->addBytes(mOurRotation->mName, strlen(mOurRotation->mName) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fdotabs(fp, tabs, tabsize); + fprintf(fp, "at_rot_target( int32 "); + mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion "); + mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, ", class [ScriptTypes]LindenLab.SecondLife.Quaternion "); + mOurRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, " )"); + break; default: mTargetNumber->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mTargetRotation->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -3391,10 +3766,13 @@ { #ifdef LSL_INCLUDE_DEBUG_INFO char name[] = "not_at_rot_target"; - chunk->addBytes(name, strlen(name) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(name, strlen(name) + 1); #endif } break; + case LSCP_EMIT_CIL_ASSEMBLY: + fprintf(fp, "not_at_rot_target()"); + break; default: break; } @@ -3563,6 +3941,25 @@ return 0; } +// CIL code generation requires both caller and callee scope entries, so cannot use normal recurse signature. +// TODO: Refactor general purpose recurse calls in to pass specific virtuals using visitor pattern to select method by pass and node type. +static void print_cil_func_expression_list(LLScriptFuncExpressionList* self, FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata, LLScriptScopeEntry *callee_entry) +{ + self->mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + LSCRIPTType argtype = callee_entry->mFunctionArgs.getType(entrycount); + if (argtype != self->mFirstp->mReturnType) + { + print_cil_cast(fp, self->mFirstp->mReturnType, argtype); + } + entrycount++; + if (self->mSecondp) + { + llassert(LET_FUNC_EXPRESSION_LIST == self->mSecondp->mType); + print_cil_func_expression_list((LLScriptFuncExpressionList*) self->mSecondp, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL, callee_entry); + + } +} + void LLScriptFuncExpressionList::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -3660,31 +4057,6 @@ } } break; - /* TODO: Fix conflict between global/local variable determination needing caller scope and cast determination here needs callee scope... - case LSCP_EMIT_CIL_ASSEMBLY: - { - mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - LSCRIPTType argtype = entry->mFunctionArgs.getType(entrycount); - if (argtype != mFirstp->mReturnType) - { - print_cil_cast(fp, mFirstp->mReturnType, argtype); - } - entrycount++; - if (mSecondp) - { - mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if (mSecondp->mReturnType) - { - argtype = entry->mFunctionArgs.getType(entrycount); - if (argtype != mSecondp->mReturnType) - { - print_cil_cast(fp, mFirstp->mReturnType, argtype); - } - } - } - } - break; - */ default: mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); if (mSecondp) @@ -3753,27 +4125,23 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - // Evaluate expressions in reverse order so first expression is on top of stack. - // Results can then be popped and appended to list to result in list with correct order. - if (mSecondp) - { - mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if (mSecondp->mType != LET_LIST_EXPRESSION_LIST) - { - // Box value. - print_cil_box(fp, mSecondp->mReturnType); - - ++count; - } - } mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); if (mFirstp->mType != LET_LIST_EXPRESSION_LIST) { // Box value. print_cil_box(fp, mFirstp->mReturnType); - ++count; } + if (mSecondp) + { + mSecondp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if (mSecondp->mType != LET_LIST_EXPRESSION_LIST) + { + // Box value. + print_cil_box(fp, mSecondp->mReturnType); + ++count; + } + } break; default: mFirstp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -3793,14 +4161,22 @@ // Returns true if identifier is a parameter and false if identifier is a local variable within function_scope. bool is_parameter(LLScriptIdentifier* identifier, LLScriptScopeEntry* function_scope) { - // Function offset stores offset of first local. - // Compare variable offset with function offset to - // determine whether variable is local or parameter. - return (identifier->mScopeEntry->mOffset < function_scope->mOffset); + // Function stores offset of first local. + if(0 == function_scope->mOffset) + { + // Function offset 0 -> no parameters -> identifier is a local. + return false; + } + else + { + // Compare variable offset with function offset to + // determine whether variable is local or parameter. + return (identifier->mScopeEntry->mOffset < function_scope->mOffset); + } } // If assignment is to global variable, pushes this pointer on to stack. -void print_cil_load_address(FILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope) +static void print_cil_load_address(FILE* fp, LLScriptExpression* exp, LLScriptScopeEntry* function_scope) { LLScriptLValue *lvalue = (LLScriptLValue *) exp; LLScriptIdentifier *ident = lvalue->mIdentifier; @@ -3811,7 +4187,9 @@ fprintf(fp, "ldarg.0\n"); } - // If accessor, load address of object. + // If accessor, load value type. + // NOTE: Not loading addresses as although it's more efficient, + // saving managed pointers is not supported by the uthread injector. if(lvalue->mAccessor) { if(ident->mScopeEntry->mIDType == LIT_VARIABLE) @@ -3819,24 +4197,23 @@ if(is_parameter(ident, function_scope)) { // Parameter, load by name. - fprintf(fp, "ldarga.s %s\n", ident->mScopeEntry->mIdentifier); + fprintf(fp, "ldarg.s '%s'\n", ident->mScopeEntry->mIdentifier); } else { // Local, load by index. - fprintf(fp, "ldloca.s %d\n", ident->mScopeEntry->mCount); + fprintf(fp, "ldloc.s %d\n", ident->mScopeEntry->mCount); } } else if (ident->mScopeEntry->mIDType == LIT_GLOBAL) { - fprintf(fp, "ldflda "); - print_cil_type(fp, ident->mScopeEntry->mType); - fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier); + fprintf(fp, "ldfld "); + print_cil_member(fp, ident); } } } -void print_cil_accessor(FILE* fp, LLScriptLValue *lvalue) +static void print_cil_accessor(FILE* fp, LLScriptLValue *lvalue) { LLScriptIdentifier *ident = lvalue->mIdentifier; print_cil_type(fp, lvalue->mReturnType); @@ -3845,12 +4222,6 @@ fprintf(fp, "::%s\n", lvalue->mAccessor->mName); } -void print_cil_member(FILE* fp, LLScriptIdentifier *ident) -{ - print_cil_type(fp, ident->mScopeEntry->mType); - fprintf(fp, " LSL::%s\n", ident->mScopeEntry->mIdentifier); -} - void LLScriptLValue::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -4106,7 +4477,7 @@ if(is_parameter(mIdentifier, entry)) { // Parameter, load by name. - fprintf(fp, "ldarg.s %s\n", mIdentifier->mScopeEntry->mIdentifier); + fprintf(fp, "ldarg.s '%s'\n", mIdentifier->mScopeEntry->mIdentifier); } else { @@ -4136,7 +4507,7 @@ return 0; } -void print_asignment(FILE *fp, LLScriptExpression *exp) +static void print_assignment(FILE *fp, LLScriptExpression *exp) { LLScriptLValue *lvalue = (LLScriptLValue *)exp; LLScriptIdentifier *ident = lvalue->mIdentifier; @@ -4164,7 +4535,7 @@ } } -void print_cil_asignment(FILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope) +static void print_cil_assignment(FILE *fp, LLScriptExpression *exp, LLScriptScopeEntry* function_scope) { LLScriptLValue *lvalue = (LLScriptLValue *) exp; LLScriptIdentifier *ident = lvalue->mIdentifier; @@ -4191,7 +4562,7 @@ if(is_parameter(ident, function_scope)) { // Parameter, store by name. - fprintf(fp, "starg.s %s\n", ident->mScopeEntry->mIdentifier); + fprintf(fp, "starg.s '%s'\n", ident->mScopeEntry->mIdentifier); } else { @@ -4319,9 +4690,9 @@ chunk->addInteger(address); } -void print_cil_numeric_cast(FILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg) +static void print_cil_numeric_cast(FILE* fp, LSCRIPTType currentArg, LSCRIPTType otherArg) { - if((currentArg == LST_INTEGER) && (otherArg == LST_FLOATINGPOINT)) + if((currentArg == LST_INTEGER) && ((otherArg == LST_FLOATINGPOINT) || (otherArg == LST_VECTOR))) { print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); } @@ -4344,7 +4715,7 @@ { mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cast(fp, mReturnType, mRightType); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4371,7 +4742,7 @@ print_cil_load_address(fp, mLValue, entry); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightType, mReturnType); - print_cil_asignment(fp, mLValue, entry); + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4387,8 +4758,15 @@ return 0; } -void print_cil_add(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_add(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { + if(LST_LIST == right_type && LST_LIST != left_type) + { + print_cil_box(fp, left_type); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(class [mscorlib]System.Collections.ArrayList, object)\n"); + return; + } + switch(left_type) { case LST_INTEGER: @@ -4402,27 +4780,39 @@ case LST_KEY: // String concatenation. - fprintf(fp, "call string valuetype [mscorlib]System.String::Concat(string, string)"); + fprintf(fp, "call string valuetype [LslUserScript]LindenLab.SecondLife.LslUserScript::Add(string, string)\n"); break; case LST_VECTOR: // Vector addition. - // TODO: Inline (requires temporary variables, which must be identified in earlier pass). - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'add_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_QUATERNION: // Rotation addition. - // TODO: Inline (requires temporary variables, which must be identified in earlier pass). - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'add_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Add'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); break; case LST_LIST: - print_cil_box(fp, right_type); - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(class [mscorlib]System.Collections.ArrayList, object)\n"); - break; + switch(right_type) + { + case LST_LIST: + // Concatenate lists. + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); + break; + case LST_INTEGER: + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(int32, class [mscorlib]System.Collections.ArrayList)\n"); + break; + case LST_FLOATINGPOINT: + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(float32, class [mscorlib]System.Collections.ArrayList)\n"); + break; + default: + // String, key, vec, quat. + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Append(object, class [mscorlib]System.Collections.ArrayList)\n"); + break; + } default: break; @@ -4447,7 +4837,7 @@ mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "ADD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4475,12 +4865,12 @@ case LSCP_EMIT_CIL_ASSEMBLY: { print_cil_load_address(fp, mLValue, entry); - mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); + mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); print_cil_add(fp, mLValue->mReturnType, mRightSide->mReturnType); - print_cil_asignment(fp, mLValue, entry); + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4496,29 +4886,30 @@ return 0; } -void print_cil_sub(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_sub(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { switch(left_type) { case LST_INTEGER: + if(LST_INTEGER == right_type) + { + fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(int32, int32)\n"); + break; + } case LST_FLOATINGPOINT: - // Numeric subtraction. - fprintf(fp, "sub\n"); + fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Subtract(float64, float64)\n"); break; - case LST_VECTOR: // Vector subtraction. - // TODO: Inline (requires temporary variables, which must be identified in earlier pass). - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'subtract_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_QUATERNION: // Rotation subtraction. - // TODO: Inline (requires temporary variables, which must be identified in earlier pass). - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'subtract_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Subtract'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); break; default: @@ -4546,7 +4937,7 @@ mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "SUB %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4574,12 +4965,12 @@ case LSCP_EMIT_CIL_ASSEMBLY: { print_cil_load_address(fp, mLValue, entry); - mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); + mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); print_cil_sub(fp, mLValue->mReturnType, mRightSide->mReturnType); - print_cil_asignment(fp, mLValue, entry); + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4595,41 +4986,74 @@ return 0; } -void print_cil_mul(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_mul(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { switch(left_type) { case LST_INTEGER: - case LST_FLOATINGPOINT: - // Numeric multiplication. - fprintf(fp, "mul\n"); + switch(right_type) + { + case LST_INTEGER: + case LST_FLOATINGPOINT: + + // Numeric multiplication. + fprintf(fp, "mul\n"); + break; + + case LST_VECTOR: + + // Vector scaling. + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n"); + break; + default: + break; + } break; - - case LST_VECTOR: + + case LST_FLOATINGPOINT: switch(right_type) { case LST_INTEGER: + case LST_FLOATINGPOINT: - print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); + // Numeric multiplication. + fprintf(fp, "mul\n"); + break; + case LST_VECTOR: + + // Vector scaling. + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, float32)\n"); + break; + + default: + break; + } + break; + + case LST_VECTOR: + + switch(right_type) + { + case LST_INTEGER: case LST_FLOATINGPOINT: // Vector scaling. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_float'(valuetype [LScriptLibrary]LLVector, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_VECTOR: // Dot product. - fprintf(fp, "call float32 valuetype [LScriptLibrary]LLVector::'multiply_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call float32 class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_QUATERNION: // Vector rotation. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'multiply_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; default: @@ -4640,7 +5064,7 @@ case LST_QUATERNION: // Rotation multiplication. - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'multiply_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Multiply'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); break; default: @@ -4668,7 +5092,7 @@ mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "MUL %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4696,12 +5120,17 @@ case LSCP_EMIT_CIL_ASSEMBLY: { print_cil_load_address(fp, mLValue, entry); - mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); + mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); print_cil_mul(fp, mLValue->mReturnType, mRightSide->mReturnType); - print_cil_asignment(fp, mLValue, entry); + if((mLValue->mReturnType == LST_INTEGER) && + (mRightSide->mReturnType == LST_FLOATINGPOINT)) + { + print_cil_cast(fp, LST_FLOATINGPOINT, LST_INTEGER); + } + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4717,15 +5146,20 @@ return 0; } -void print_cil_div(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_div(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { switch(left_type) { case LST_INTEGER: + if(LST_INTEGER == right_type) + { + fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(int32, int32)\n"); + break; + } case LST_FLOATINGPOINT: - // Numeric addition. - fprintf(fp, "div\n"); + // Numeric division. + fprintf(fp, "call float64 [LslUserScript]LindenLab.SecondLife.LslUserScript::Divide(float64, float64)\n"); break; case LST_VECTOR: @@ -4733,19 +5167,16 @@ switch(right_type) { case LST_INTEGER: - - print_cil_cast(fp, LST_INTEGER, LST_FLOATINGPOINT); - case LST_FLOATINGPOINT: // Scale. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_float'(valuetype [LScriptLibrary]LLVector, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(float32, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_QUATERNION: // Inverse rotation. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'divide_quat'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; default: @@ -4755,7 +5186,7 @@ case LST_QUATERNION: - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'divide_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Divide'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); break; default: @@ -4783,7 +5214,7 @@ mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "DIV %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4811,12 +5242,12 @@ case LSCP_EMIT_CIL_ASSEMBLY: { print_cil_load_address(fp, mLValue, entry); - mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLValue->mReturnType); + mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLValue->mReturnType, mRightSide->mReturnType); print_cil_div(fp, mLValue->mReturnType, mRightSide->mReturnType); - print_cil_asignment(fp, mLValue, entry); + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4832,20 +5263,20 @@ return 0; } -void print_cil_mod(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_mod(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { switch(left_type) { case LST_INTEGER: // Numeric remainder. - fprintf(fp, "rem\n"); + fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::Modulo(int32, int32)\n"); break; case LST_VECTOR: // Vector cross product. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'mod_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'Modulo'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; default: @@ -4873,7 +5304,7 @@ mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "MOD %s, %s\n", LSCRIPTTypeNames[mRightType], LSCRIPTTypeNames[mLeftType]); - print_asignment(fp, mLValue); + print_assignment(fp, mLValue); } break; case LSCP_TYPE: @@ -4901,10 +5332,10 @@ case LSCP_EMIT_CIL_ASSEMBLY: { print_cil_load_address(fp, mLValue, entry); - mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLValue->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_mod(fp, mLValue->mReturnType, mRightSide->mReturnType); - print_cil_asignment(fp, mLValue, entry); + print_cil_assignment(fp, mLValue, entry); } break; default: @@ -4920,7 +5351,7 @@ return 0; } -void print_cil_eq(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) +static void print_cil_eq(FILE* fp, LSCRIPTType left_type, LSCRIPTType right_type) { switch(left_type) { @@ -4941,17 +5372,17 @@ case LST_VECTOR: // Vector equality. - fprintf(fp, "call bool [LScriptLibrary]LLVector::'equals_vec'(valuetype [LScriptLibrary]LLVector, valuetype [LScriptLibrary]LLVector)\n"); + fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Vector, class [ScriptTypes]LindenLab.SecondLife.Vector)\n"); break; case LST_QUATERNION: // Rotation equality. - fprintf(fp, "call bool [LScriptLibrary]LLQuaternion::'equals_quat'(valuetype [LScriptLibrary]LLQuaternion, valuetype [LScriptLibrary]LLQuaternion)\n"); + fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::'Equals'(class [ScriptTypes]LindenLab.SecondLife.Quaternion, class [ScriptTypes]LindenLab.SecondLife.Quaternion)\n"); break; case LST_LIST: - fprintf(fp, "call bool [LScriptLibrary]LScriptInternal::EqualsList(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); + fprintf(fp, "call bool [LslUserScript]LindenLab.SecondLife.LslUserScript::Equals(class [mscorlib]System.Collections.ArrayList, class [mscorlib]System.Collections.ArrayList)\n"); break; default: @@ -5002,10 +5433,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5063,8 +5494,10 @@ break; case LSCP_EMIT_CIL_ASSEMBLY: mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "ceq\n"); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); + print_cil_eq(fp, mLeftSide->mReturnType, mRightSide->mReturnType); fprintf(fp, "ldc.i4.0\n"); fprintf(fp, "ceq\n"); // Compare result of first compare equal with 0 to get compare not equal. break; @@ -5081,6 +5514,14 @@ return 0; } +static void print_cil_lte(FILE* fp) +{ + // NOTE: LSL pushes operands backwards, so <= becomes >= + fprintf(fp, "clt\n"); + fprintf(fp, "ldc.i4.0\n"); + fprintf(fp, "ceq\n"); +} + void LLScriptLessEquals::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -5122,11 +5563,11 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "cgt\n"); // Test greater than. - fprintf(fp, "ldc.i4.0\n"); // Use (b == 0) implementation of boolean not. - fprintf(fp, "ceq\n"); // Apply boolean not to greater than. If not greater than, then less or equal. + print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); + print_cil_lte(fp); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -5141,6 +5582,14 @@ return 0; } +static void print_cil_gte(FILE* fp) +{ + // NOTE: LSL pushes operands backwards, so >= becomes <= + fprintf(fp, "cgt\n"); + fprintf(fp, "ldc.i4.0\n"); + fprintf(fp, "ceq\n"); +} + void LLScriptGreaterEquals::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -5182,11 +5631,11 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "clt\n"); // Test less than. - fprintf(fp, "ldc.i4.0\n"); // Use (b == 0) implementation of boolean not. - fprintf(fp, "ceq\n"); // Apply boolean not to less than. If not less than, then greater or equal. + print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); + print_cil_gte(fp); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -5201,6 +5650,12 @@ return 0; } +static void print_cil_lt(FILE* fp) +{ + // NOTE: LSL pushes operands backwards, so < becomes > + fprintf(fp, "cgt\n"); +} + void LLScriptLessThan::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -5242,9 +5697,11 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "clt\n"); + print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); + print_cil_lt(fp); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -5259,6 +5716,12 @@ return 0; } +static void print_cil_gt(FILE* fp) +{ + // NOTE: LSL pushes operands backwards, so > becomes < + fprintf(fp, "clt\n"); +} + void LLScriptGreaterThan::recurse(FILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg, LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count, LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) { if (gErrorToText.getErrors()) @@ -5300,9 +5763,11 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "cgt\n"); + print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); + print_cil_gt(fp); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -5358,10 +5823,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); print_cil_add(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5418,10 +5883,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); print_cil_sub(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5478,10 +5943,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); print_cil_mul(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5538,10 +6003,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_numeric_cast(fp, mRightSide->mReturnType, mLeftSide->mReturnType); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_numeric_cast(fp, mLeftSide->mReturnType, mRightSide->mReturnType); print_cil_div(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5598,8 +6063,8 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); print_cil_mod(fp, mLeftSide->mReturnType, mRightSide->mReturnType); break; default: @@ -5654,8 +6119,8 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "and\n"); break; default: @@ -5710,8 +6175,8 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "or\n"); break; default: @@ -5766,8 +6231,8 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "xor\n"); break; default: @@ -5822,8 +6287,8 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "and\n"); break; default: @@ -5934,9 +6399,9 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "shl\n"); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftLeft(int32, int32)\n"); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -5991,9 +6456,9 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); mRightSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "shr\n"); + mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "call int32 [LslUserScript]LindenLab.SecondLife.LslUserScript::ShiftRight(int32, int32)\n"); break; default: mLeftSide->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -6076,6 +6541,12 @@ chunk->addByte(typebyte); } break; + case LSCP_EMIT_CIL_ASSEMBLY: + { + mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "neg\n"); + } + break; default: mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); break; @@ -6219,7 +6690,7 @@ { fprintf(fp, "Unexpected Type\n"); } - print_asignment(fp, mExpression); + print_assignment(fp, mExpression); } break; case LSCP_TYPE: @@ -6266,21 +6737,21 @@ print_cil_load_address(fp, mExpression, entry); if (mReturnType == LST_INTEGER) { - fprintf(fp, "ldc.i4.1\n"); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "ldc.i4.1\n"); fprintf(fp, "add\n"); } else if (mReturnType == LST_FLOATINGPOINT) { - fprintf(fp, "ldc.r8.1\n"); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "ldc.r8 1\n"); fprintf(fp, "add\n"); } else { fprintf(fp, "Unexpected Type\n"); } - print_cil_asignment(fp, mExpression, entry); + print_cil_assignment(fp, mExpression, entry); } break; default: @@ -6327,7 +6798,7 @@ { fprintf(fp, "Unexpected Type\n"); } - print_asignment(fp, mExpression); + print_assignment(fp, mExpression); } break; case LSCP_TYPE: @@ -6374,21 +6845,21 @@ print_cil_load_address(fp, mExpression, entry); if (mReturnType == LST_INTEGER) { - fprintf(fp, "ldc.i4.1\n"); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "ldc.i4.1\n"); fprintf(fp, "sub\n"); } else if (mReturnType == LST_FLOATINGPOINT) { - fprintf(fp, "ldc.r8.1\n"); mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(fp, "ldc.r8 1\n"); fprintf(fp, "sub\n"); } else { fprintf(fp, "Unexpected Type\n"); } - print_cil_asignment(fp, mExpression, entry); + print_cil_assignment(fp, mExpression, entry); } break; default: @@ -6555,7 +7026,7 @@ print_cil_cast(fp, mExpression3->mReturnType, LST_FLOATINGPOINT); } // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. - fprintf(fp, "call valuetype [LScriptLibrary]LLVector valuetype [LScriptLibrary]LLVector::'create'(float32, float32, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Vector class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateVector'(float32, float32, float32)\n"); break; default: mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -6696,7 +7167,7 @@ } // Call named ctor, which leaves new Vector on stack, so it can be saved in to local or argument just like a primitive type. - fprintf(fp, "call valuetype [LScriptLibrary]LLQuaternion valuetype [LScriptLibrary]LLQuaternion::'create'(float32, float32, float32, float32)\n"); + fprintf(fp, "call class [ScriptTypes]LindenLab.SecondLife.Quaternion class [LslUserScript]LindenLab.SecondLife.LslUserScript::'CreateQuaternion'(float32, float32, float32, float32)\n"); break; default: mExpression1->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -6768,12 +7239,12 @@ } // Create list on stack, consuming first boxed element. - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::CreateList()\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::CreateList()\n"); - // Call AddReturnList to add remaining boxed expressions. + // Call Prepend to add remaining boxed expressions. for(U64 i = 0; i < count; i++) { - fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LScriptLibrary]LScriptInternal::AddReturnList(object, class [mscorlib]System.Collections.ArrayList)\n"); + fprintf(fp, "call class [mscorlib]System.Collections.ArrayList class [LslUserScript]LindenLab.SecondLife.LslUserScript::Prepend(object, class [mscorlib]System.Collections.ArrayList)\n"); } count = 0; @@ -6824,7 +7295,7 @@ { fprintf(fp, "Unexpected Type\n"); } - print_asignment(fp, mExpression); + print_assignment(fp, mExpression); fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); } break; @@ -6893,24 +7364,34 @@ break; case LSCP_EMIT_CIL_ASSEMBLY: { + // Push original value on to stack. + mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + + // Load address if needed for store. print_cil_load_address(fp, mExpression, entry); + + // Load value again. + // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values. + // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-) mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp,"dup\n"); // Copy expression result to use as increment operand. if (mReturnType == LST_INTEGER) { fprintf(fp, "ldc.i4.1\n"); } else if (mReturnType == LST_FLOATINGPOINT) { - fprintf(fp, "ldc.r8.1\n"); + fprintf(fp, "ldc.r8 1\n"); } else { fprintf(fp, "Unexpected Type\n"); } fprintf(fp, "add\n"); - print_cil_asignment(fp, mExpression, entry); - fprintf(fp, "pop\n"); // Pop assignment result to leave original expression result on stack. TODO: Optimise away redundant pop/dup pairs. + print_cil_assignment(fp, mExpression, entry); + + // Pop assignment result to leave original expression result on stack. + // TODO: Optimise away redundant pop/dup pairs. + fprintf(fp, "pop\n"); } break; default: @@ -6956,7 +7437,7 @@ { fprintf(fp, "Unexpected Type\n"); } - print_asignment(fp, mExpression); + print_assignment(fp, mExpression); fprintf(fp, "%s\n", LSCRIPTTypePop[mReturnType]); } break; @@ -7025,24 +7506,34 @@ break; case LSCP_EMIT_CIL_ASSEMBLY: { + // Push original value on to stack. + mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + + // Load address if needed for store. print_cil_load_address(fp, mExpression, entry); + + // Load value again. + // TODO: Work out if sideeffects can result in 2 evaluations of expression giving different values. + // Original LSL2 uses this method, so any bugs due to side effects will probably be identical ;-) mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp,"dup\n"); // Copy expression result to use as decrement operand. if (mReturnType == LST_INTEGER) { fprintf(fp, "ldc.i4.1\n"); } else if (mReturnType == LST_FLOATINGPOINT) { - fprintf(fp, "ldc.r8.1\n"); + fprintf(fp, "ldc.r8 1\n"); } else { fprintf(fp, "Unexpected Type\n"); } fprintf(fp, "sub\n"); - print_cil_asignment(fp, mExpression, entry); - fprintf(fp, "pop\n"); // Pop assignment result to leave original expression result on stack. TODO: Optimise away redundant pop/dup pairs. + print_cil_assignment(fp, mExpression, entry); + + // Pop assignment result to leave original expression result on stack. + // TODO: Optimise away redundant pop/dup pairs. + fprintf(fp, "pop\n"); } break; default: @@ -7058,16 +7549,19 @@ } // Generate arg list. -void print_cil_arg_list(FILE *fp, LLScriptFuncExpressionList* exp_list) +static void print_cil_arg_list(FILE *fp, LLScriptArgString& args) { - // Print first argument. - print_cil_type(fp, exp_list->mFirstp->mReturnType); - - // Recursively print next arguments. - if(exp_list->mSecondp != NULL) - { - fprintf(fp, ", "); - print_cil_arg_list(fp, (LLScriptFuncExpressionList*) exp_list->mSecondp); + int i = 0; + bool finished = (i >= args.getNumber()); + while(! finished) + { + print_cil_type(fp, args.getType(i)); + ++i; + finished = (i >= args.getNumber()); + if(! finished) + { + fprintf(fp, ", "); + } } } @@ -7146,7 +7640,7 @@ gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); } } - else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString)) /*Flawfinder: ignore*/ + else if (argcount != strlen(mIdentifier->mScopeEntry->mFunctionArgs.mString)) { gErrorToText.writeError(fp, this, LSERROR_FUNCTION_TYPE_ERROR); } @@ -7217,7 +7711,9 @@ // Load args on to stack. if (mExpressionList) { - mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL); + //mExpressionList->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Needed for is_parameter calls */, 0, NULL); + llassert(LET_FUNC_EXPRESSION_LIST == mExpressionList->mType); + print_cil_func_expression_list((LLScriptFuncExpressionList*) mExpressionList, fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry /* Caller entry needed for is_parameter calls */, 0, NULL, mIdentifier->mScopeEntry /* Callee entry needed for argument casting */); } // Make call. @@ -7233,16 +7729,16 @@ fprintf(fp, " class "); if (library_call) { - fprintf(fp, "[LScriptLibrary]LScriptLibrary"); + fprintf(fp, "[LslLibrary]LindenLab.SecondLife.Library"); } else { - fprintf(fp, "LSL"); + fprintf(fp, gScriptp->getClassName()); } fprintf(fp, "::"); mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, "("); - if (mExpressionList) {print_cil_arg_list(fp, (LLScriptFuncExpressionList*) mExpressionList);} + print_cil_arg_list(fp, mIdentifier->mScopeEntry->mFunctionArgs); fprintf(fp, ")\n"); } break; @@ -7462,7 +7958,7 @@ if (entry->mLocals.mString) { - number = (S32)strlen(entry->mLocals.mString); /*Flawfinder: ignore*/ + number = (S32)strlen(entry->mLocals.mString); for (i = number - 1; i >= 0; i--) { switch(entry->mLocals.getType(i)) @@ -7495,7 +7991,7 @@ if (entry->mFunctionArgs.mString) { - number = (S32)strlen(entry->mFunctionArgs.mString); /*Flawfinder: ignore*/ + number = (S32)strlen(entry->mFunctionArgs.mString); for (i = number - 1; i >= 0; i--) { switch(entry->mFunctionArgs.getType(i)) @@ -7534,7 +8030,7 @@ if (entry->mLocals.mString) { - number = (S32)strlen(entry->mLocals.mString); /*Flawfinder: ignore*/ + number = (S32)strlen(entry->mLocals.mString); for (i = number - 1; i >= 0; i--) { fprintf(fp, "%s", LSCRIPTTypePop[entry->mLocals.getType(i)]); @@ -7543,7 +8039,7 @@ if (entry->mFunctionArgs.mString) { - number = (S32)strlen(entry->mFunctionArgs.mString); /*Flawfinder: ignore*/ + number = (S32)strlen(entry->mFunctionArgs.mString); for (i = number - 1; i >= 0; i--) { fprintf(fp, "%s", LSCRIPTTypePop[entry->mFunctionArgs.getType(i)]); @@ -7610,10 +8106,10 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: - fprintf(fp, "ldstr \""); - mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "\"\n"); - fprintf(fp, "call void class [LScriptLibrary]LScriptInternal::change_state(string)\n"); + fprintf(fp, "ldarg.0\n"); + fprintf(fp, "ldstr \"%s\"\n", mIdentifier->mName); + fprintf(fp, "call instance void class [LslUserScript]LindenLab.SecondLife.LslUserScript::ChangeState(string)\n"); + fprintf(fp, "ret\n"); break; default: mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -7863,6 +8359,7 @@ if (mExpression) { mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + print_cil_cast(fp, mExpression->mReturnType, mType); } fprintf(fp, "ret\n"); break; @@ -8604,24 +9101,13 @@ if (mExpression) { mExpression->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - if (mIdentifier->mScopeEntry->mIDType == LIT_VARIABLE) - { - if(is_parameter(mIdentifier, entry)) - { - // Parameter, store by name. - fprintf(fp, "starg.s %s\n", mIdentifier->mScopeEntry->mIdentifier); - } - else - { - // Local, store by index. - fprintf(fp, "stloc.s %d\n", mIdentifier->mScopeEntry->mCount); - } - } - else if (mIdentifier->mScopeEntry->mIDType == LIT_GLOBAL) - { - gErrorToText.writeError(fp, this, LSERROR_UNDEFINED_NAME); - } + print_cil_cast(fp, mExpression->mReturnType, mIdentifier->mScopeEntry->mType); } + else + { + print_cil_init_variable(fp, mIdentifier->mScopeEntry->mType); + } + fprintf(fp, "stloc.s %d\n", mIdentifier->mScopeEntry->mCount); break; default: if (mExpression) @@ -8751,7 +9237,7 @@ U64 gCurrentHandler = 0; -void print_cil_local_init(FILE* fp, LLScriptScopeEntry* scopeEntry) +static void print_cil_local_init(FILE* fp, LLScriptScopeEntry* scopeEntry) { if(scopeEntry->mLocals.getNumber() > 0) { @@ -8956,6 +9442,10 @@ // first determine resource counts for globals count = 0; mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + + // Store offset of first local as with global functions, so locals and arguments can be distinguished with is_parameter when compiling to CIL. + mScopeEntry->mOffset = (S32) count; + if (mStatement) { entrycount = 0; @@ -9025,7 +9515,7 @@ fprintf(fp, ".method public hidebysig instance default void "); // Mangle event handler name by prefixing it with state name. Allows state changing by finding handlers prefixed with new state name. - fprintf(fp, entry->mIdentifier); /*Flawfinder: ignore*/ + fprintf(fp, entry->mIdentifier); // Handler name and arguments. mEventp->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -9161,7 +9651,7 @@ chunk->addBytes(&typereturn, 1); // name #ifdef LSL_INCLUDE_DEBUG_INFO - chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); #else chunk->addBytes(1); #endif @@ -9176,6 +9666,10 @@ mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); fprintf(fp, " "); mIdentifier->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + if(NULL != mNextp) + { + fprintf(fp, ","); + } break; default: mType->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); @@ -9398,7 +9892,7 @@ // null terminated function name #ifdef LSL_INCLUDE_DEBUG_INFO - chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); #else chunk->addBytes(1); #endif @@ -9649,7 +10143,7 @@ // null terminated state name #ifdef LSL_INCLUDE_DEBUG_INFO - chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); /*Flawfinder: ignore*/ + chunk->addBytes(mIdentifier->mName, strlen(mIdentifier->mName) + 1); #else chunk->addBytes(1); #endif @@ -9693,6 +10187,38 @@ gonext(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); } +// Converts string to a valid CIL class name and stores the result +// in the supplied buffer, which should be at least 32 chars long. +// If the string starts with a UUID, all characters in the UUID are included +// in the generated name. +void to_class_name(char* buffer, const char* string) +{ + strcpy(buffer, "LSL-"); + strcat(buffer, string); + char* current_char = buffer; + while((*current_char) != 0) + { + if(isalnum(*current_char)) + { + ++current_char; + } + else if((*current_char) == '-') + { + (*current_char) = '_'; + ++current_char; + } + else + { + (*current_char) = 0; + } + } +} + +void LLScriptScript::setClassName(const char* class_name) +{ + to_class_name(mClassName, class_name); +} + S32 LLScriptScript::getSize() { return 0; @@ -9704,8 +10230,8 @@ mStates(states), mGlobalScope(NULL), mGlobals(NULL), mGlobalFunctions(NULL), mGodLike(FALSE) { const char DEFAULT_BYTECODE_FILENAME[] = "lscript.lso"; - strncpy(mBytecodeDest, DEFAULT_BYTECODE_FILENAME, sizeof(mBytecodeDest) -1); /*Flawfinder: ignore*/ - mBytecodeDest[MAX_STRING-1] = '\0'; + strcpy(mBytecodeDest, DEFAULT_BYTECODE_FILENAME); + LLScriptGlobalVariable *tvar; LLScriptGlobalFunctions *tfunc; LLScritpGlobalStorage *temp; @@ -9751,17 +10277,15 @@ void LLScriptScript::setBytecodeDest(const char* dst_filename) { - strncpy(mBytecodeDest, dst_filename, MAX_STRING); /*Flawfinder: ignore*/ + strncpy(mBytecodeDest, dst_filename, MAX_STRING); mBytecodeDest[MAX_STRING-1] = '\0'; } -void print_cil_globals(FILE* fp, LLScriptGlobalVariable* global) +static void print_cil_globals(FILE* fp, LLScriptGlobalVariable* global) { - fprintf(fp, ".field private "); + fprintf(fp, ".field public "); print_cil_type(fp, global->mType->mType); - fprintf(fp, " "); - fprintf(fp, global->mIdentifier->mName); /*Flawfinder: ignore*/ - fprintf(fp, "\n"); + fprintf(fp, " '%s'\n", global->mIdentifier->mName); if(NULL != global->mNextp) { print_cil_globals(fp, global->mNextp); @@ -9939,7 +10463,7 @@ // now, put it all together and spit it out // we need - FILE* bcfp = LLFile::fopen(mBytecodeDest, "wb"); /*Flawfinder: ignore*/ + FILE *bcfp = LLFile::fopen(mBytecodeDest, "wb"); code->build(fp, bcfp); fclose(bcfp); @@ -9948,72 +10472,66 @@ } break; case LSCP_EMIT_CIL_ASSEMBLY: + { + FILE *bcfp = fopen(mBytecodeDest, "wb"); - // Output dependencies. - fprintf(fp, ".assembly extern mscorlib {.ver 1:0:5000:0}\n"); - fprintf(fp, ".assembly extern LScriptLibrary {.ver 0:0:0:0}\n"); - - // Output assembly name. - fprintf(fp, ".assembly 'lsl' {.ver 0:0:0:0}\n"); - - // Output class header. - fprintf(fp, ".class public auto ansi beforefieldinit LSL extends [mscorlib]System.Object\n"); - fprintf(fp, "{\n"); - - // Output globals as members. - if(NULL != mGlobals) - { - print_cil_globals(fp, mGlobals); - } - - // Output "runtime". Only needed to allow stand alone execution. Not needed when compiling to DLL and using embedded runtime. - fprintf(fp, ".method public static hidebysig default void Main () cil managed\n"); - fprintf(fp, "{\n"); - fprintf(fp, ".entrypoint\n"); - fprintf(fp, ".maxstack 2\n"); - fprintf(fp, ".locals init (class LSL V_0)\n"); - fprintf(fp, "newobj instance void class LSL::.ctor()\n"); - fprintf(fp, "stloc.0\n"); - fprintf(fp, "ldloc.0\n"); - fprintf(fp, "callvirt instance void class LSL::defaultstate_entry()\n"); - fprintf(fp, "ret\n"); - fprintf(fp, "}\n"); + // Output dependencies. + fprintf(bcfp, ".assembly extern mscorlib {.ver 1:0:5000:0}\n"); + fprintf(bcfp, ".assembly extern LslLibrary {.ver 0:1:0:0}\n"); + fprintf(bcfp, ".assembly extern LslUserScript {.ver 0:1:0:0}\n"); + fprintf(bcfp, ".assembly extern ScriptTypes {.ver 0:1:0:0}\n"); - // Output ctor header. - fprintf(fp, ".method public hidebysig specialname rtspecialname instance default void .ctor () cil managed\n"); - fprintf(fp, "{\n"); - fprintf(fp, ".maxstack 500\n"); + // Output assembly name. + fprintf(bcfp, ".assembly '%s' {.ver 0:0:0:0}\n", gScriptp->getClassName()); - // Initialise globals as members in ctor. - if (mGlobals) - { - fdotabs(fp, tabs, tabsize); - mGlobals->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "\n"); - } + // Output class header. + fprintf(bcfp, ".class public auto ansi serializable beforefieldinit %s extends [LslUserScript]LindenLab.SecondLife.LslUserScript\n", gScriptp->getClassName()); + fprintf(bcfp, "{\n"); - // Output ctor footer. - fprintf(fp, "ldarg.0\n"); - fprintf(fp, "call instance void valuetype [mscorlib]System.Object::.ctor()\n"); - fprintf(fp, "ret\n"); - fprintf(fp, "}\n"); + // Output globals as members. + if(NULL != mGlobals) + { + print_cil_globals(bcfp, mGlobals); + } - // Output functions as methods. - if (mGlobalFunctions) - { - fdotabs(fp, tabs, tabsize); - mGlobalFunctions->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "\n"); - } + // Output ctor header. + fprintf(bcfp, ".method public hidebysig specialname rtspecialname instance default void .ctor () cil managed\n"); + fprintf(bcfp, "{\n"); + fprintf(bcfp, ".maxstack 500\n"); - // Output states as name mangled methods. - fdotabs(fp, tabs, tabsize); - mStates->recurse(fp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); - fprintf(fp, "\n"); + // Initialise globals as members in ctor. + if (mGlobals) + { + fdotabs(bcfp, tabs, tabsize); + mGlobals->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(bcfp, "\n"); + } - // Output class footer. - fprintf(fp, "}\n"); + // Output ctor footer. + fprintf(bcfp, "ldarg.0\n"); + fprintf(bcfp, "call instance void [LslUserScript]LindenLab.SecondLife.LslUserScript::.ctor()\n"); + fprintf(bcfp, "ret\n"); + fprintf(bcfp, "}\n"); + // Output functions as methods. + if (mGlobalFunctions) + { + fdotabs(bcfp, tabs, tabsize); + mGlobalFunctions->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(bcfp, "\n"); + } + + // Output states as name mangled methods. + fdotabs(bcfp, tabs, tabsize); + mStates->recurse(bcfp, tabs, tabsize, pass, ptype, prunearg, scope, type, basetype, count, chunk, heap, stacksize, entry, entrycount, NULL); + fprintf(bcfp, "\n"); + + // Output class footer. + fprintf(bcfp, "}\n"); + + // Close file. + fclose(bcfp); + } break; default: if (mGlobals) diff -urN release-r77878/linden/indra/lscript/lscript_compile/lscript_tree.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_tree.h --- release-r77878/linden/indra/lscript/lscript_compile/lscript_tree.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_compile/lscript_tree.h 2008-01-31 11:46:53.000000000 -0800 @@ -2262,6 +2262,9 @@ void setBytecodeDest(const char* dst_filename); + void setClassName(const char* class_name); + const char* getClassName() {return mClassName;} + LLScriptState *mStates; LLScriptScope *mGlobalScope; LLScriptGlobalVariable *mGlobals; @@ -2270,6 +2273,7 @@ private: char mBytecodeDest[MAX_STRING]; /*Flawfinder: ignore*/ + char mClassName[MAX_STRING]; }; class LLScriptAllocationManager diff -urN release-r77878/linden/indra/lscript/lscript_execute/lscript_execute.cpp mono-based-on-r77880-r79030/linden/indra/lscript/lscript_execute/lscript_execute.cpp --- release-r77878/linden/indra/lscript/lscript_execute/lscript_execute.cpp 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_execute/lscript_execute.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -31,6 +31,7 @@ #include "linden_common.h" +#include #include #include "lscript_execute.h" @@ -45,7 +46,7 @@ char* LSCRIPTRunTimeFaultStrings[LSRF_EOF] = /*Flawfinder: ignore*/ { - "invalid", // LSRF_INVALID, + "Invalid", // LSRF_INVALID, "Math Error", // LSRF_MATH, "Stack-Heap Collision", // LSRF_STACK_HEAP_COLLISION, "Bounds Check Error", // LSRF_BOUND_CHECK_ERROR, @@ -55,13 +56,14 @@ "Hit Sandbox Limit", // LSRF_SANDBOX, "Chat Overrun", // LSRF_CHAT_OVERRUN, "Too Many Listens", // LSRF_TOO_MANY_LISTENS, - "Lists may not contain lists" // LSRF_NESTING_LISTS, + "Lists may not contain lists", // LSRF_NESTING_LISTS, + "CLI Exception" // LSRF_CLI }; //static -S64 LLScriptExecute::sGlobalInstructionCount = 0; +S64 LLScriptExecuteLSL2::sGlobalInstructionCount = 0; -LLScriptExecute::LLScriptExecute(FILE *fp) +LLScriptExecuteLSL2::LLScriptExecuteLSL2(FILE *fp) { U8 sizearray[4]; S32 filesize; @@ -84,19 +86,26 @@ init(); } -LLScriptExecute::LLScriptExecute(U8 *buffer) +LLScriptExecuteLSL2::LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size) { - mBuffer = buffer; - + mBuffer = new U8[TOP_OF_MEMORY]; + memset(mBuffer + bytecode_size, 0, TOP_OF_MEMORY - bytecode_size); + S32 src_offset = 0; + S32 dest_offset = 0; + bytestream2bytestream(mBuffer, dest_offset, bytecode, src_offset, bytecode_size); + mBytecodeSize = bytecode_size; + mBytecode = new U8[mBytecodeSize]; + memcpy(mBytecode, bytecode, mBytecodeSize); init(); } -LLScriptExecute::~LLScriptExecute() +LLScriptExecuteLSL2::~LLScriptExecuteLSL2() { - delete [] mBuffer; + delete[] mBuffer; + delete[] mBytecode; } -void LLScriptExecute::init() +void LLScriptExecuteLSL2::init() { S32 i, j; @@ -270,7 +279,7 @@ // Utility routine for when there's a boundary error parsing bytecode -void LLScriptExecute::recordBoundaryError( const LLUUID &id ) +void LLScriptExecuteLSL2::recordBoundaryError( const LLUUID &id ) { set_fault(mBuffer, LSRF_BOUND_CHECK_ERROR); llwarns << "Script boundary error for ID " << id << llendl; @@ -278,7 +287,7 @@ // set IP to the event handler with some error checking -void LLScriptExecute::setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id ) +void LLScriptExecuteLSL2::setStateEventOpcoodeStartSafely( S32 state, LSCRIPTStateEventType event, const LLUUID &id ) { S32 opcode_start = get_state_event_opcoode_start( mBuffer, state, event ); if ( opcode_start == -1 ) @@ -296,12 +305,475 @@ S32 lscript_push_variable(LLScriptLibData *data, U8 *buffer); -U32 LLScriptExecute::run(BOOL b_print, const LLUUID &id, char **errorstr, BOOL &state_transition) +void LLScriptExecuteLSL2::resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice) +{ + // call opcode run function pointer with buffer and IP + mInstructionCount++; + sGlobalInstructionCount++; + S32 value = get_register(mBuffer, LREG_IP); + S32 tvalue = value; + S32 opcode = safe_instruction_bytestream2byte(mBuffer, tvalue); + mExecuteFuncs[opcode](mBuffer, value, b_print, id); + set_ip(mBuffer, value); + add_register_fp(mBuffer, LREG_ESR, -0.1f); + // lsa_print_heap(mBuffer); + + if (b_print) + { + lsa_print_heap(mBuffer); + printf("ip: 0x%X\n", get_register(mBuffer, LREG_IP)); + printf("sp: 0x%X\n", get_register(mBuffer, LREG_SP)); + printf("bp: 0x%X\n", get_register(mBuffer, LREG_BP)); + printf("hr: 0x%X\n", get_register(mBuffer, LREG_HR)); + printf("hp: 0x%X\n", get_register(mBuffer, LREG_HP)); + } + + // NOTE: Babbage: all mExecuteFuncs return false. +} + +void LLScriptExecuteLSL2::callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) +{ + // push a zero to be popped + lscript_push(mBuffer, 0); + // push sp as current bp + S32 sp = get_register(mBuffer, LREG_SP); + lscript_push(mBuffer, sp); + + // Update current handler and current events registers. + set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); + U64 current_events = get_event_register(mBuffer, LREG_CE, major_version); + current_events &= ~LSCRIPTStateBitField[event]; + set_event_register(mBuffer, LREG_CE, current_events, major_version); + + // now, push any additional stack space + U32 current_state = get_register(mBuffer, LREG_CS); + S32 additional_size = get_event_stack_size(mBuffer, current_state, event); + lscript_pusharge(mBuffer, additional_size); + + // now set the bp correctly + sp = get_register(mBuffer, LREG_SP); + sp += additional_size; + set_bp(mBuffer, sp); + + // set IP to the function + S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event); + set_ip(mBuffer, opcode_start); +} + +//void callStateExitHandler() +//{ +// // push a zero to be popped +// lscript_push(mBuffer, 0); +// // push sp as current bp +// S32 sp = get_register(mBuffer, LREG_SP); +// lscript_push(mBuffer, sp); +// +// // now, push any additional stack space +// S32 additional_size = get_event_stack_size(mBuffer, current_state, LSTT_STATE_EXIT); +// lscript_pusharge(mBuffer, additional_size); +// +// sp = get_register(mBuffer, LREG_SP); +// sp += additional_size; +// set_bp(mBuffer, sp); +// +// // set IP to the event handler +// S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, LSTT_STATE_EXIT); +// set_ip(mBuffer, opcode_start); +//} +// +//void callStateEntryHandler() +//{ +// // push a zero to be popped +// lscript_push(mBuffer, 0); +// // push sp as current bp +// S32 sp = get_register(mBuffer, LREG_SP); +// lscript_push(mBuffer, sp); +// +// event = return_first_event((S32)LSCRIPTStateBitField[LSTT_STATE_ENTRY]); +// set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); +// current_events &= ~LSCRIPTStateBitField[event]; +// set_event_register(mBuffer, LREG_CE, current_events, major_version); +// +// // now, push any additional stack space +// S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size; +// lscript_pusharge(mBuffer, additional_size); +// +// // now set the bp correctly +// sp = get_register(mBuffer, LREG_SP); +// sp += additional_size + size; +// set_bp(mBuffer, sp); +// // set IP to the function +// S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event); +// set_ip(mBuffer, opcode_start); +//} + +void LLScriptExecuteLSL2::callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) +{ + LLScriptDataCollection* eventdata; + + for (eventdata = mEventData.mEventDataList.getFirstData(); eventdata; eventdata = mEventData.mEventDataList.getNextData()) + { + if (eventdata->mType == event) + { + // push a zero to be popped + lscript_push(mBuffer, 0); + // push sp as current bp + S32 sp = get_register(mBuffer, LREG_SP); + lscript_push(mBuffer, sp); + + // Update current handler and current events registers. + set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); + U64 current_events = get_event_register(mBuffer, LREG_CE, major_version); + current_events &= ~LSCRIPTStateBitField[event]; + set_event_register(mBuffer, LREG_CE, current_events, major_version); + + // push any arguments that need to be pushed onto the stack + // last piece of data will be type LST_NULL + LLScriptLibData *data = eventdata->mData; + U32 size = 0; + while (data->mType) + { + size += lscript_push_variable(data, mBuffer); + data++; + } + // now, push any additional stack space + U32 current_state = get_register(mBuffer, LREG_CS); + S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size; + lscript_pusharge(mBuffer, additional_size); + + // now set the bp correctly + sp = get_register(mBuffer, LREG_SP); + sp += additional_size + size; + set_bp(mBuffer, sp); + + // set IP to the function + S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event); + set_ip(mBuffer, opcode_start); + + mEventData.mEventDataList.deleteCurrentData(); + break; + } + } +} + +void LLScriptExecuteLSL2::callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) +{ + LLScriptDataCollection* eventdata = mEventData.getNextEvent(); + if (eventdata) + { + LSCRIPTStateEventType event = eventdata->mType; + + // make sure that we can actually handle this one + if (LSCRIPTStateBitField[event] & event_register) + { + // push a zero to be popped + lscript_push(mBuffer, 0); + // push sp as current bp + S32 sp = get_register(mBuffer, LREG_SP); + lscript_push(mBuffer, sp); + + // Update current handler and current events registers. + set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); + U64 current_events = get_event_register(mBuffer, LREG_CE, major_version); + current_events &= ~LSCRIPTStateBitField[event]; + set_event_register(mBuffer, LREG_CE, current_events, major_version); + + // push any arguments that need to be pushed onto the stack + // last piece of data will be type LST_NULL + LLScriptLibData *data = eventdata->mData; + U32 size = 0; + while (data->mType) + { + size += lscript_push_variable(data, mBuffer); + data++; + } + + // now, push any additional stack space + U32 current_state = get_register(mBuffer, LREG_CS); + S32 additional_size = get_event_stack_size(mBuffer, current_state, event) - size; + lscript_pusharge(mBuffer, additional_size); + + // now set the bp correctly + sp = get_register(mBuffer, LREG_SP); + sp += additional_size + size; + set_bp(mBuffer, sp); + + // set IP to the function + S32 opcode_start = get_state_event_opcoode_start(mBuffer, current_state, event); + set_ip(mBuffer, opcode_start); + } + else + { + llwarns << "Shit, somehow got an event that we're not registered for!" << llendl; + } + delete eventdata; + } +} + +U64 LLScriptExecuteLSL2::nextState() +{ + // copy NS to CS + S32 next_state = get_register(mBuffer, LREG_NS); + set_register(mBuffer, LREG_CS, next_state); + + // copy new state's handled events into ER (SR + CS*4 + 4) + return get_handled_events(mBuffer, next_state); +} + +//virtual +void LLScriptExecuteLSL2::addEvent(LLScriptDataCollection* event) +{ + mEventData.addEventData(event); +} + +//virtual +void LLScriptExecuteLSL2::removeEventType(LSCRIPTStateEventType event_type) +{ + mEventData.removeEventType(event_type); +} + +//virtual +F32 LLScriptExecuteLSL2::getSleep() const +{ + return get_register_fp(mBuffer, LREG_SLR); +} + +//virtual +void LLScriptExecuteLSL2::setSleep(F32 value) +{ + set_register_fp(mBuffer, LREG_SLR, value); +} + +//virtual +U64 LLScriptExecuteLSL2::getCurrentHandler(S32 version) +{ + return get_event_register(mBuffer, LREG_IE, version); +} + +//virtual +F32 LLScriptExecuteLSL2::getEnergy() const +{ + return get_register_fp(mBuffer, LREG_ESR); +} + +//virtual +void LLScriptExecuteLSL2::setEnergy(F32 value) +{ + set_register_fp(mBuffer, LREG_ESR, value); +} + +//virtual +U32 LLScriptExecuteLSL2::getFreeMemory() +{ + return get_register(mBuffer, LREG_SP) - get_register(mBuffer, LREG_HP); +} + +//virtual +S32 LLScriptExecuteLSL2::getParameter() +{ + return get_register(mBuffer, LREG_PR); +} + +//virtual +void LLScriptExecuteLSL2::setParameter(S32 value) +{ + set_register(mBuffer, LREG_PR, value); +} + + +S32 LLScriptExecuteLSL2::writeState(U8 **dest, U32 header_size, U32 footer_size) +{ + // data format: + // 4 bytes of size of Registers, Name and Description, and Global Variables + // Registers, Name and Description, and Global Variables data + // 4 bytes of size of Heap + // Heap data + // 4 bytes of stack size + // Stack data + + S32 registers_size = get_register(mBuffer, LREG_GFR); + + if (get_register(mBuffer, LREG_HP) > TOP_OF_MEMORY) + reset_hp_to_safe_spot(mBuffer); + + S32 heap_size = get_register(mBuffer, LREG_HP) - get_register(mBuffer, LREG_HR); + S32 stack_size = get_register(mBuffer, LREG_TM) - get_register(mBuffer, LREG_SP); + S32 total_size = registers_size + LSCRIPTDataSize[LST_INTEGER] + + heap_size + LSCRIPTDataSize[LST_INTEGER] + + stack_size + LSCRIPTDataSize[LST_INTEGER]; + + // actually allocate data + delete[] *dest; + *dest = new U8[header_size + total_size + footer_size]; + memset(*dest, 0, header_size + total_size + footer_size); + S32 dest_offset = header_size; + S32 src_offset = 0; + + // registers + integer2bytestream(*dest, dest_offset, registers_size); + + // llinfos << "Writing CE: " << getCurrentEvents() << llendl; + bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, registers_size); + + // heap + integer2bytestream(*dest, dest_offset, heap_size); + + src_offset = get_register(mBuffer, LREG_HR); + bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, heap_size); + + // stack + integer2bytestream(*dest, dest_offset, stack_size); + + src_offset = get_register(mBuffer, LREG_SP); + bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, stack_size); + + return total_size; +} + +S32 LLScriptExecuteLSL2::writeBytecode(U8 **dest) +{ + // data format: + // registers through top of heap + // Heap data + S32 total_size = get_register(mBuffer, LREG_HP); + + // actually allocate data + delete [] *dest; + *dest = new U8[total_size]; + S32 dest_offset = 0; + S32 src_offset = 0; + + bytestream2bytestream(*dest, dest_offset, mBuffer, src_offset, total_size); + + return total_size; +} + +S32 LLScriptExecuteLSL2::readState(U8 *src) +{ + // first, blitz heap and stack + S32 hr = get_register(mBuffer, LREG_HR); + S32 tm = get_register(mBuffer, LREG_TM); + memset(mBuffer + hr, 0, tm - hr); + + S32 src_offset = 0; + S32 dest_offset = 0; + S32 size; + + // read register size + size = bytestream2integer(src, src_offset); + + // copy data into register area + bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size); +// llinfos << "Read CE: " << getCurrentEvents() << llendl; + if (get_register(mBuffer, LREG_TM) != TOP_OF_MEMORY) + { + llwarns << "Invalid state. Top of memory register does not match" + << " constant." << llendl; + reset_hp_to_safe_spot(mBuffer); + return -1; + } + + // read heap size + size = bytestream2integer(src, src_offset); + + // set dest offset + dest_offset = get_register(mBuffer, LREG_HR); + + if (dest_offset + size > TOP_OF_MEMORY) + { + reset_hp_to_safe_spot(mBuffer); + return -1; + } + + // copy data into heap area + bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size); + + // read stack size + size = bytestream2integer(src, src_offset); + + // set dest offset + dest_offset = get_register(mBuffer, LREG_SP); + + if (dest_offset + size > TOP_OF_MEMORY) + { + reset_hp_to_safe_spot(mBuffer); + return -1; + } + + // copy data into heap area + bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size); + + // Return offset to first byte after read data. + return src_offset; +} + +void LLScriptExecuteLSL2::reset() +{ + LLScriptExecute::reset(); + + const U8 *src = getBytecode(); + S32 size = getBytecodeSize(); + + if (!src) + return; + + // first, blitz heap and stack + S32 hr = get_register(mBuffer, LREG_HR); + S32 tm = get_register(mBuffer, LREG_TM); + memset(mBuffer + hr, 0, tm - hr); + + S32 dest_offset = 0; + S32 src_offset = 0; + + bytestream2bytestream(mBuffer, dest_offset, src, src_offset, size); +} + +LLScriptExecute::LLScriptExecute() : + mReset(FALSE) +{ +} + +void LLScriptExecute::reset() +{ + mReset = FALSE; +} + +bool LLScriptExecute::isYieldDue() const +{ + if(mReset) + { + return true; + } + + if(getSleep() > 0.f) + { + return true; + } + + if(isFinished()) + { + return true; + } + + if(isStateChangePending()) + { + return true; + } + + return false; +} + +// Run smallest number of instructions possible: +// a single instruction for LSL2, a segment between save tests for Mono +void LLScriptExecute::runInstructions(BOOL b_print, const LLUUID &id, + char **errorstr, + BOOL &state_transition, + U32& events_processed, + F32 quanta) { // is there a fault? // if yes, print out message and exit - state_transition = FALSE; - S32 value = get_register(mBuffer, LREG_VN); + S32 value = getVersion(); S32 major_version = 0; if (value == LSL2_VERSION1_END_NUMBER) { @@ -313,323 +785,151 @@ } else { - set_fault(mBuffer, LSRF_VERSION_MISMATCH); + setFault(LSRF_VERSION_MISMATCH); } - value = get_register(mBuffer, LREG_FR); - if (value) + value = getFaults(); + if (value > LSRF_INVALID && value < LSRF_EOF) { if (b_print) { printf("Error!\n"); } *errorstr = LSCRIPTRunTimeFaultStrings[value]; - return NO_DELETE_FLAG; + return; } else { *errorstr = NULL; } - // Get IP - // is IP nonzero? - value = get_register(mBuffer, LREG_IP); - - if (value) + if (! isFinished()) { - // if yes, we're in opcodes, execute the next opcode by: - // call opcode run function pointer with buffer and IP - mInstructionCount++; - sGlobalInstructionCount++; - S32 tvalue = value; - S32 opcode = safe_instruction_bytestream2byte(mBuffer, tvalue); - S32 b_ret_val = mExecuteFuncs[opcode](mBuffer, value, b_print, id); - set_ip(mBuffer, value); - add_register_fp(mBuffer, LREG_ESR, -0.1f); - // lsa_print_heap(mBuffer); - - if (b_print) - { - lsa_print_heap(mBuffer); - printf("ip: 0x%X\n", get_register(mBuffer, LREG_IP)); - printf("sp: 0x%X\n", get_register(mBuffer, LREG_SP)); - printf("bp: 0x%X\n", get_register(mBuffer, LREG_BP)); - printf("hr: 0x%X\n", get_register(mBuffer, LREG_HR)); - printf("hp: 0x%X\n", get_register(mBuffer, LREG_HP)); - } - // update IP - if (b_ret_val) - { - return DELETE_FLAG | CREDIT_MONEY_FLAG; - } - else - { - return NO_DELETE_FLAG; - } + resumeEventHandler(b_print, id, quanta); + return; } else { // make sure that IE is zero - set_event_register(mBuffer, LREG_IE, 0, major_version); + setCurrentHandler(0, major_version); + + // if no, we're in a state and waiting for an event + U64 current_events = getCurrentEvents(major_version); + U64 event_register = getEventHandlers(major_version); - // if no, we're in a state and waiting for an event - S32 next_state = get_register(mBuffer, LREG_NS); - S32 current_state = get_register(mBuffer, LREG_CS); - U64 current_events = get_event_register(mBuffer, LREG_CE, major_version); - U64 event_register = get_event_register(mBuffer, LREG_ER, major_version); - // check NS to see if need to switch states (NS != CS) - if (next_state != current_state) + // check NS to see if need to switch states (NS != CS) + if (isStateChangePending()) { state_transition = TRUE; + // ok, blow away any pending events - mEventData.mEventDataList.deleteAllData(); + deleteAllEvents(); - // if yes, check state exit flag is set + // if yes, check state exit flag is set if (current_events & LSCRIPTStateBitField[LSTT_STATE_EXIT]) { - // if yes, clear state exit flag - set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[LSTT_STATE_EXIT], major_version); + // if yes, clear state exit flag + setCurrentHandler(LSCRIPTStateBitField[LSTT_STATE_EXIT], major_version); current_events &= ~LSCRIPTStateBitField[LSTT_STATE_EXIT]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); - // check state exit event handler - // if there is a handler, call it + setCurrentEvents(current_events, major_version); + + // check state exit event handler + // if there is a handler, call it if (event_register & LSCRIPTStateBitField[LSTT_STATE_EXIT]) { - // push a zero to be popped - lscript_push(mBuffer, 0); - // push sp as current bp - S32 sp = get_register(mBuffer, LREG_SP); - lscript_push(mBuffer, sp); - - // now, push any additional stack space - S32 additional_size = get_event_stack_size(mBuffer, current_state, LSTT_STATE_EXIT); - if ( additional_size == -1 ) - { - recordBoundaryError( id ); - } - else - { - lscript_pusharge(mBuffer, additional_size); - - sp = get_register(mBuffer, LREG_SP); - sp += additional_size; - set_bp(mBuffer, sp); - // set IP to the event handler - setStateEventOpcoodeStartSafely( current_state, LSTT_STATE_EXIT, id ); - } - return NO_DELETE_FLAG; + ++events_processed; + callEventHandler(LSTT_STATE_EXIT, major_version, id, quanta); + return; } } - // if no handler or no state exit flag switch to new state - // set state entry flag and clear other CE flags + + // if no handler or no state exit flag switch to new state + // set state entry flag and clear other CE flags current_events = LSCRIPTStateBitField[LSTT_STATE_ENTRY]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); - // copy NS to CS - set_register(mBuffer, LREG_CS, next_state); - // copy new state's handled events into ER (SR + CS*4 + 4) - U64 handled_events = get_handled_events(mBuffer, next_state); - set_event_register(mBuffer, LREG_ER, handled_events, major_version); - } -// check to see if any current events are covered by events handled by this state (CE & ER != 0) -// now, we want to look like we were called like a function -// 0x0000: 00 00 00 00 (return ip) -// 0x0004: bp (current sp) -// 0x0008: parameters -// push sp -// add parameter size -// pop bp -// set ip + setCurrentEvents(current_events, major_version); - S32 size = 0; -// try to get next event from stack + U64 handled_events = nextState(); + setEventHandlers(handled_events, major_version); + } + + // try to get next event from stack BOOL b_done = FALSE; LSCRIPTStateEventType event = LSTT_NULL; - LLScriptDataCollection *eventdata; - next_state = get_register(mBuffer, LREG_NS); - current_state = get_register(mBuffer, LREG_CS); - current_events = get_event_register(mBuffer, LREG_CE, major_version); - event_register = get_event_register(mBuffer, LREG_ER, major_version); + current_events = getCurrentEvents(major_version); + event_register = getEventHandlers(major_version); // first, check to see if state_entry or onrez are raised and handled - if ( (current_events & LSCRIPTStateBitField[LSTT_STATE_ENTRY]) + if ((current_events & LSCRIPTStateBitField[LSTT_STATE_ENTRY]) &&(current_events & event_register)) { - // ok, this is easy since there isn't any data waiting, just set it - // push a zero to be popped - lscript_push(mBuffer, 0); -// push sp as current bp - S32 sp = get_register(mBuffer, LREG_SP); - lscript_push(mBuffer, sp); - - event = return_first_event((S32)LSCRIPTStateBitField[LSTT_STATE_ENTRY]); - set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); - current_events &= ~LSCRIPTStateBitField[event]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); -// now, push any additional stack space - S32 additional_size = get_event_stack_size(mBuffer, current_state, event); - if ( additional_size == -1 ) - { // b_done will be set, so we'll exit the loop at the bottom - recordBoundaryError( id ); - } - else - { - additional_size -= size; - lscript_pusharge(mBuffer, additional_size); - -// now set the bp correctly - sp = get_register(mBuffer, LREG_SP); - sp += additional_size + size; - set_bp(mBuffer, sp); -// set IP to the function - setStateEventOpcoodeStartSafely( current_state, event, id ); - } + ++events_processed; + callEventHandler(LSTT_STATE_ENTRY, major_version, id, quanta); b_done = TRUE; } - else if ( (current_events & LSCRIPTStateBitField[LSTT_REZ]) - &&(current_events & event_register)) + else if ((current_events & LSCRIPTStateBitField[LSTT_REZ]) + &&(current_events & event_register)) { - for (eventdata = mEventData.mEventDataList.getFirstData(); eventdata; eventdata = mEventData.mEventDataList.getNextData()) - { - if (eventdata->mType & LSCRIPTStateBitField[LSTT_REZ]) - { - // push a zero to be popped - lscript_push(mBuffer, 0); - // push sp as current bp - S32 sp = get_register(mBuffer, LREG_SP); - lscript_push(mBuffer, sp); - - set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); - current_events &= ~LSCRIPTStateBitField[event]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); - - // push any arguments that need to be pushed onto the stack - // last piece of data will be type LST_NULL - LLScriptLibData *data = eventdata->mData; - while (data->mType) - { - size += lscript_push_variable(data, mBuffer); - data++; - } - // now, push any additional stack space - S32 additional_size = get_event_stack_size(mBuffer, current_state, event); - if ( additional_size == -1 ) - { // b_done will be set, so we'll exit the loop at the bottom - recordBoundaryError( id ); - } - else - { - additional_size -= size; - lscript_pusharge(mBuffer, additional_size); - - // now set the bp correctly - sp = get_register(mBuffer, LREG_SP); - sp += additional_size + size; - set_bp(mBuffer, sp); - // set IP to the function - setStateEventOpcoodeStartSafely( current_state, event, id ); - mEventData.mEventDataList.deleteCurrentData(); - } - b_done = TRUE; - break; - } - } + ++events_processed; + callQueuedEventHandler(LSTT_REZ, major_version, id, quanta); + b_done = TRUE; } while (!b_done) { - eventdata = mEventData.getNextEvent(); - if (eventdata) + // Call handler for next queued event. + if(getEventCount() > 0) { - event = eventdata->mType; - - // make sure that we can actually handle this one - if (LSCRIPTStateBitField[event] & event_register) - { - // push a zero to be popped - lscript_push(mBuffer, 0); - // push sp as current bp - S32 sp = get_register(mBuffer, LREG_SP); - lscript_push(mBuffer, sp); - - set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); - current_events &= ~LSCRIPTStateBitField[event]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); - - // push any arguments that need to be pushed onto the stack - // last piece of data will be type LST_NULL - LLScriptLibData *data = eventdata->mData; - while (data->mType) - { - size += lscript_push_variable(data, mBuffer); - data++; - } - b_done = TRUE; - // now, push any additional stack space - S32 additional_size = get_event_stack_size(mBuffer, current_state, event); - if ( additional_size == -1 ) - { // b_done was just set, so we'll exit the loop at the bottom - recordBoundaryError( id ); - } - else - { - additional_size -= size; - lscript_pusharge(mBuffer, additional_size); - - // now set the bp correctly - sp = get_register(mBuffer, LREG_SP); - sp += additional_size + size; - set_bp(mBuffer, sp); - // set IP to the function - setStateEventOpcoodeStartSafely( current_state, event, id ); - } - } - else - { - llwarns << "Shit, somehow got an event that we're not registered for!" << llendl; - } - delete eventdata; + ++events_processed; + callNextQueuedEventHandler(event_register, major_version, id, quanta); + b_done = TRUE; } else { -// if no data waiting, do it the old way: + // if no data waiting, do it the old way: U64 handled_current = current_events & event_register; if (handled_current) { - // push a zero to be popped - lscript_push(mBuffer, 0); - // push sp as current bp - S32 sp = get_register(mBuffer, LREG_SP); - lscript_push(mBuffer, sp); - event = return_first_event((S32)handled_current); - set_event_register(mBuffer, LREG_IE, LSCRIPTStateBitField[event], major_version); - current_events &= ~LSCRIPTStateBitField[event]; - set_event_register(mBuffer, LREG_CE, current_events, major_version); - // now, push any additional stack space - S32 additional_size = get_event_stack_size(mBuffer, current_state, event); - if ( additional_size == -1 ) - { // b_done will be set, so we'll exit the loop at the bottom - recordBoundaryError( id ); - } - else - { - additional_size -= size; - lscript_pusharge(mBuffer, additional_size); - - // now set the bp correctly - sp = get_register(mBuffer, LREG_SP); - sp += additional_size + size; - set_bp(mBuffer, sp); - // set IP to the function - setStateEventOpcoodeStartSafely( current_state, event, id ); - } + ++events_processed; + callEventHandler(event, major_version, id, quanta); } b_done = TRUE; } - } // while (!b_done) - } // end of else ... in state processing code + } + } +} - return NO_DELETE_FLAG; +// Run for a single timeslice, or until a yield is due +F32 LLScriptExecute::runQuanta(BOOL b_print, const LLUUID &id, char **errorstr, BOOL &state_transition, F32 quanta, U32& events_processed, LLTimer& timer) +{ + U32 timer_checks = 0; + F32 inloop = 0; + + // Loop while not finished, yield not due and time remaining + // NOTE: Default implementation does not do adaptive timer skipping + // to preserve current LSL behaviour and not break scripts that rely + // on current execution speed. + while(true) + { + runInstructions(b_print, id, errorstr, state_transition, + events_processed, quanta); + + static const S32 lsl_timer_check_skip = 4; + if(isYieldDue()) + { + break; + } + else if(timer_checks++ == lsl_timer_check_skip) + { + inloop = timer.getElapsedTimeF32(); + if(inloop > quanta) + { + break; + } + timer_checks = 0; + } + } + return inloop; } BOOL run_noop(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) @@ -3705,6 +4005,9 @@ void lscript_run(char *filename, BOOL b_debug) { LLTimer timer; + char *error; + BOOL b_state; + LLScriptExecuteLSL2 *execute = NULL; if (filename == NULL) { llerrs << "filename is NULL" << llendl; @@ -3712,46 +4015,35 @@ // to check how to abort or error out gracefully // from this function. XXXTBD } - else + FILE* file = LLFile::fopen(filename, "r"); /* Flawfinder: ignore */ + if(file) { - char *error; - BOOL b_state; - LLScriptExecute *execute = NULL; - - FILE* file = LLFile::fopen(filename, "r"); - if (file) - { - execute = new LLScriptExecute(file); - // note: LLScriptExecute() closes file for us - } - file = LLFile::fopen(filename, "r"); - if (file) - { - FILE* fp = LLFile::fopen("lscript.parse", "w"); /*Flawfinder: ignore*/ - LLScriptLSOParse *parse = new LLScriptLSOParse(file); - parse->printData(fp); - delete parse; - fclose(file); - fclose(fp); - } - file = LLFile::fopen(filename, "r"); - if (file && execute) - { - timer.reset(); - while (!execute->run(b_debug, LLUUID::null, &error, b_state)) - ; - F32 time = timer.getElapsedTimeF32(); - F32 ips = execute->mInstructionCount / time; - llinfos << execute->mInstructionCount << " instructions in " << time << " seconds" << llendl; - llinfos << ips/1000 << "K instructions per second" << llendl; - printf("ip: 0x%X\n", get_register(execute->mBuffer, LREG_IP)); - printf("sp: 0x%X\n", get_register(execute->mBuffer, LREG_SP)); - printf("bp: 0x%X\n", get_register(execute->mBuffer, LREG_BP)); - printf("hr: 0x%X\n", get_register(execute->mBuffer, LREG_HR)); - printf("hp: 0x%X\n", get_register(execute->mBuffer, LREG_HP)); - delete execute; - fclose(file); - } + execute = new LLScriptExecuteLSL2(file); + fclose(file); + } + if (execute) + { + timer.reset(); + F32 time_slice = 3600.0f; // 1 hr. + U32 events_processed = 0; + + do { + LLTimer timer2; + execute->runQuanta(b_debug, LLUUID::null, &error, b_state, + time_slice, events_processed, timer2); + } while (!execute->isFinished()); + + F32 time = timer.getElapsedTimeF32(); + F32 ips = execute->mInstructionCount / time; + llinfos << execute->mInstructionCount << " instructions in " << time << " seconds" << llendl; + llinfos << ips/1000 << "K instructions per second" << llendl; + printf("ip: 0x%X\n", get_register(execute->mBuffer, LREG_IP)); + printf("sp: 0x%X\n", get_register(execute->mBuffer, LREG_SP)); + printf("bp: 0x%X\n", get_register(execute->mBuffer, LREG_BP)); + printf("hr: 0x%X\n", get_register(execute->mBuffer, LREG_HR)); + printf("hp: 0x%X\n", get_register(execute->mBuffer, LREG_HP)); + delete execute; + fclose(file); } } diff -urN release-r77878/linden/indra/lscript/lscript_execute.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_execute.h --- release-r77878/linden/indra/lscript/lscript_execute.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_execute.h 2008-01-31 11:46:53.000000000 -0800 @@ -367,18 +367,156 @@ class LLScriptExecute { public: - LLScriptExecute(FILE *fp); - LLScriptExecute(U8 *buffer); - ~LLScriptExecute(); + LLScriptExecute(); + virtual ~LLScriptExecute() {;} + + virtual S32 getVersion() = 0; + virtual void deleteAllEvents() = 0; + virtual void addEvent(LLScriptDataCollection* event) = 0; + virtual U32 getEventCount() = 0; + virtual void removeEventType(LSCRIPTStateEventType event_type) = 0; + virtual S32 getFaults() = 0; + virtual void setFault(LSCRIPTRunTimeFaults fault) = 0; + virtual U32 getFreeMemory() = 0; + virtual S32 getParameter() = 0; + virtual void setParameter(S32 value) = 0; + virtual F32 getSleep() const = 0; + virtual void setSleep(F32 value) = 0; + virtual F32 getEnergy() const = 0; + virtual void setEnergy(F32 value) = 0; + virtual U64 getCurrentEvents(S32 version) = 0; + virtual void setCurrentEvents(U64 value, S32 version) = 0; + virtual U64 getEventHandlers(S32 version) = 0; + virtual void setEventHandlers(U64 value, S32 version) = 0; + virtual U64 getCurrentHandler(S32 version) = 0; + virtual void setCurrentHandler(U64 value, S32 version) = 0; + virtual BOOL isFinished() const = 0; + virtual BOOL isStateChangePending() const = 0; + virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size) = 0; // Allocate memory for header, state and footer return size of state. + virtual U32 getEventsSavedSize() = 0; // Returns 0 if events are written with state. + virtual S32 writeEvents(U8 *dest) = 0; // Must write and return exactly the number of bytes returned by getEventsSavedSize. + virtual void readEvents(U8* src, S32& offset) = 0; + virtual S32 readState(U8 *src) = 0; // Returns number of bytes read. + virtual void reset(); + virtual const U8* getBytecode() const = 0; + virtual U32 getBytecodeSize() const = 0; + virtual bool isMono() const = 0; + virtual void error() {;} // Processing that must be performed when error flag is set and so run is not called. + + // Run current event handler for a maximum of time_slice seconds. + // Updates current handler and current events registers. + virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice) = 0; + + // Run handler for event for a maximum of time_slice seconds. + // Updates current handler and current events registers. + virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0;; + + // Run handler for next queued event for maximum of time_slice seconds. + // Updates current handler and current events registers. + // Removes processed event from queue. + virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice) = 0; + + // Run handler for event for a maximum of time_slice seconds. + // Updates current handler and current events registers. + // Removes processed event from queue. + virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice) = 0; + + // Switch to next state. + // Returns new set of handled events. + virtual U64 nextState() = 0; + + // Returns time taken. + virtual F32 runQuanta(BOOL b_print, const LLUUID &id, char **errorstr, + BOOL &state_transition, F32 quanta, + U32& events_processed, LLTimer& timer); + + // Run smallest possible amount of code: an instruction for LSL2, a segment + // between save tests for Mono + void runInstructions(BOOL b_print, const LLUUID &id, char **errorstr, + BOOL &state_transition, U32& events_processed, + F32 quanta); + + bool isYieldDue() const; + + void setReset(BOOL b) {mReset = b;} + BOOL getReset() const { return mReset; } + +private: + + BOOL mReset; +}; + +class LLScriptExecuteLSL2 : public LLScriptExecute +{ +public: + LLScriptExecuteLSL2(FILE *fp); + LLScriptExecuteLSL2(const U8* bytecode, U32 bytecode_size); + virtual ~LLScriptExecuteLSL2(); + + virtual S32 getVersion() {return get_register(mBuffer, LREG_VN);} + virtual void deleteAllEvents() {mEventData.mEventDataList.deleteAllData();} + virtual void addEvent(LLScriptDataCollection* event); + virtual U32 getEventCount() {return mEventData.mEventDataList.getLength();} + virtual void removeEventType(LSCRIPTStateEventType event_type); + virtual S32 getFaults() {return get_register(mBuffer, LREG_FR);} + virtual void setFault(LSCRIPTRunTimeFaults fault) {set_fault(mBuffer, fault);} + virtual U32 getFreeMemory(); + virtual S32 getParameter(); + virtual void setParameter(S32 value); + virtual F32 getSleep() const; + virtual void setSleep(F32 value); + virtual F32 getEnergy() const; + virtual void setEnergy(F32 value); + virtual U64 getCurrentEvents(S32 version) {return get_event_register(mBuffer, LREG_CE, version);} + virtual void setCurrentEvents(U64 value, S32 version) {return set_event_register(mBuffer, LREG_CE, value, version);} + virtual U64 getEventHandlers(S32 version) {return get_event_register(mBuffer, LREG_ER, version);} + virtual void setEventHandlers(U64 value, S32 version) {set_event_register(mBuffer, LREG_ER, value, version);} + virtual U64 getCurrentHandler(S32 version); + virtual void setCurrentHandler(U64 value, S32 version) {return set_event_register(mBuffer, LREG_IE, value, version);} + virtual BOOL isFinished() const {return get_register(mBuffer, LREG_IP) == 0;} + virtual BOOL isStateChangePending() const {return get_register(mBuffer, LREG_CS) != get_register(mBuffer, LREG_NS);} + virtual S32 writeState(U8 **dest, U32 header_size, U32 footer_size); // Not including Events. + virtual U32 getEventsSavedSize() {return mEventData.getSavedSize();} + virtual S32 writeEvents(U8 *dest) {return mEventData.write2bytestream(dest);} + virtual void readEvents(U8* src, S32& offset) {mEventData.set(src, offset);} + virtual S32 writeBytecode(U8 **dest); + virtual S32 readState(U8 *src); + virtual void reset(); + virtual const U8* getBytecode() const {return mBytecode;} + virtual U32 getBytecodeSize() const {return mBytecodeSize;} + virtual bool isMono() const {return false;} + + // Run current event handler for a maximum of time_slice seconds. + // Updates current handler and current events registers. + virtual void resumeEventHandler(BOOL b_print, const LLUUID &id, F32 time_slice); + + // Run handler for event for a maximum of time_slice seconds. + // Updates current handler and current events registers. + virtual void callEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); + + // Run handler for next queued event for maximum of time_slice seconds. + // Updates current handler and current events registers. + // Removes processed event from queue. + virtual void callNextQueuedEventHandler(U64 event_register, S32 major_version, const LLUUID &id, F32 time_slice); + + // Run handler for event for a maximum of time_slice seconds. + // Updates current handler and current events registers. + // Removes processed event from queue. + virtual void callQueuedEventHandler(LSCRIPTStateEventType event, S32 major_version, const LLUUID &id, F32 time_slice); + + // Switch to next state. + // Returns new set of handled events. + virtual U64 nextState(); void init(); - U32 run(BOOL b_print, const LLUUID &id, char **errorstr, BOOL &state_transition); BOOL (*mExecuteFuncs[0x100])(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id); U32 mInstructionCount; U8 *mBuffer; LLScriptEventData mEventData; + U8* mBytecode; // Initial state and bytecode. + U32 mBytecodeSize; static S64 sGlobalInstructionCount; diff -urN release-r77878/linden/indra/lscript/lscript_library/lscript_library.cpp mono-based-on-r77880-r79030/linden/indra/lscript/lscript_library/lscript_library.cpp --- release-r77878/linden/indra/lscript/lscript_library/lscript_library.cpp 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_library/lscript_library.cpp 2008-01-31 11:46:53.000000000 -0800 @@ -390,9 +390,8 @@ addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetCameraPos", "v", "", "vector llGetCameraPos()\nGets current camera position for agent task has permissions for.")); addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetCameraRot", "q", "", "rotation llGetCameraRot()\nGets current camera orientation for agent task has permissions for.")); - addFunction(new LLScriptLibraryFunction(10.f, 2.f, dummy_func, "llSetPrimURL", NULL, "s", "llSetPrimURL(string url)\nUpdates the URL for the web page shown on the sides of the object.")); + addFunction(new LLScriptLibraryFunction(10.f, 20.f, dummy_func, "llSetPrimURL", NULL, "s", "llSetPrimURL(string url)\nUpdates the URL for the web page shown on the sides of the object.")); addFunction(new LLScriptLibraryFunction(10.f, 20.f, dummy_func, "llRefreshPrimURL", NULL, "", "llRefreshPrimURL()\nReloads the web page shown on the sides of the object.")); - addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llEscapeURL", "s", "s", "string llEscapeURL(string url)\nReturns and escaped/encoded version of url, replacing spaces with %20 etc.")); addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llUnescapeURL", "s", "s", "string llUnescapeURL(string url)\nReturns and unescaped/unencoded version of url, replacing %20 with spaces etc.")); @@ -438,24 +437,6 @@ // existing scripts will crash. } - //Ventrella Follow Cam Script Stuff - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamPitch", NULL, "f", "llSetCamPitch(-45 to 80)\n(Adjusts the angular amount that the camera aims straight ahead vs. straight down, maintaining the same distance. Analogous to 'incidence'.")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamVerticalOffset", NULL, "f", "llSetCamVerticalOffset(-2 to 2)\nAdjusts the vertical position of the camera focus position relative to the subject")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamPositionLag", NULL, "f", "llSetCamPositionLag(0 to 3) \nHow much the camera lags as it tries to move towards its 'ideal' position")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamFocusLag", NULL, "f", "llSetCamFocusLag(0 to 3)\nHow much the camera lags as it tries to aim towards the subject")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamDistance", NULL, "f", "llSetCamDistance(0.5 to 10)\nSets how far away the camera wants to be from its subject")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamBehindnessAngle", NULL, "f", "llSetCamBehindnessAngle(0 to 180)\nSets the angle in degrees within which the camera is not constrained by changes in subject rotation")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamBehindnessLag", NULL, "f", "llSetCamBehindnessLag(0 to 3)\nSets how strongly the camera is forced to stay behind the target if outside of behindness angle")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamPositionThreshold", NULL, "f", "llSetCamPositionThreshold(0 to 4)\nSets the radius of a sphere around the camera's ideal position within which it is not affected by subject motion")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamFocusThreshold", NULL, "f", "llSetCamFocusThreshold(0 to 4)\nSets the radius of a sphere around the camera's subject position within which its focus is not affected by subject motion")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamScriptControl", NULL, "i", "llSetCamScriptControl(TRUE or FALSE)\nTurns on or off scripted control of the camera")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamPosition", NULL, "v", "llSetCamPosition(vector)\nSets the position of the camera")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamFocus", NULL, "v", "llSetCamFocus(vector focus)\nSets the focus (target position) of the camera")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamPositionLocked", NULL, "i", "llSetCamPositionLocked(TRUE or FALSE)\nLocks the camera position so it will not move")); - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetCamFocusLocked", NULL, "i", "llSetCamFocusLocked(TRUE or FALSE)\nLocks the camera focus so it will not move")); - - //addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetForSale", "i", "ii", "integer llSetForSale(integer selltype, integer price)\nSets this object for sale in mode selltype for price. Returns TRUE if successfully set for sale.")); - LLScriptLibraryFunction::LLScriptLibraryFunction(F32 eu, F32 st, void (*exec_func)(LLScriptLibData *, LLScriptLibData *, const LLUUID &), char *name, char *ret_type, char *args, char *desc, BOOL god_only) : mEnergyUse(eu), mSleepTime(st), mExecFunc(exec_func), mName(name), mReturnType(ret_type), mArgs(args), mGodOnly(god_only) { diff -urN release-r77878/linden/indra/lscript/lscript_library.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_library.h --- release-r77878/linden/indra/lscript/lscript_library.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_library.h 2008-01-31 11:46:53.000000000 -0800 @@ -146,9 +146,9 @@ return FALSE; } - S32 getListLength() + S32 getListLength() const { - LLScriptLibData *data = this; + const LLScriptLibData *data = this; S32 retval = 0; while (data->mListp) { diff -urN release-r77878/linden/indra/lscript/lscript_rt_interface.h mono-based-on-r77880-r79030/linden/indra/lscript/lscript_rt_interface.h --- release-r77878/linden/indra/lscript/lscript_rt_interface.h 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/lscript/lscript_rt_interface.h 2008-01-31 11:46:53.000000000 -0800 @@ -32,9 +32,9 @@ #ifndef LL_LSCRIPT_RT_INTERFACE_H #define LL_LSCRIPT_RT_INTERFACE_H -BOOL lscript_compile(char *filename, BOOL is_god_like = FALSE); +BOOL lscript_compile(char *filename, BOOL compile_to_mono, BOOL is_god_like = FALSE); BOOL lscript_compile(const char* src_filename, const char* dst_filename, - const char* err_filename, BOOL is_god_like = FALSE); + const char* err_filename, BOOL compile_to_mono, const char* class_name, BOOL is_god_like = FALSE); void lscript_run(char *filename, BOOL b_debug); diff -urN release-r77878/linden/indra/newview/files.lst mono-based-on-r77880-r79030/linden/indra/newview/files.lst --- release-r77878/linden/indra/newview/files.lst 2008-01-31 11:03:59.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/files.lst 2008-01-31 11:46:53.000000000 -0800 @@ -5,6 +5,7 @@ newview/llanimalcontrols.cpp newview/llappviewer.cpp newview/llappviewerlinux.cpp +newview/llassetuploadqueue.cpp newview/llassetuploadresponders.cpp newview/llaudiosourcevo.cpp newview/llbbox.cpp diff -urN release-r77878/linden/indra/newview/llassetuploadqueue.cpp mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadqueue.cpp --- release-r77878/linden/indra/newview/llassetuploadqueue.cpp 1969-12-31 16:00:00.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadqueue.cpp 2008-01-31 11:46:58.000000000 -0800 @@ -0,0 +1,192 @@ +/** + * @file llassetupload.cpp + * @brief Serializes asset upload request + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2008, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llassetuploadqueue.h" +#include "llviewerregion.h" +#include "llviewerobjectlist.h" + +#include "llassetuploadresponders.h" +#include "llsd.h" +#include + +class LLAssetUploadChainResponder : public LLUpdateTaskInventoryResponder +{ +public: + + LLAssetUploadChainResponder(const LLSD& post_data, + const std::string& file_name, + const LLUUID& queue_id, + const std::string &buffer, + LLAssetUploadQueueSupplier *supplier) : + LLUpdateTaskInventoryResponder(post_data, file_name, queue_id, LLAssetType::AT_LSL_TEXT), + mSupplier(supplier), + mBuffer(buffer) + { + } + + virtual ~LLAssetUploadChainResponder() + { + if(mSupplier) + { + LLAssetUploadQueue *queue = mSupplier->get(); + if (queue) + { + // Give ownership of supplier back to queue. + queue->mSupplier = mSupplier; + mSupplier = NULL; + } + } + delete mSupplier; + } + + virtual void error(U32 statusNum, const std::string& reason) + { + llerrs << "Error: " << reason << llendl; + LLAssetUploadQueue *queue = mSupplier->get(); + if (queue) + { + queue->request(&mSupplier); + } + LLUpdateTaskInventoryResponder::error(statusNum, reason); + } + + virtual void result(const LLSD& content) + { + LLAssetUploadQueue *queue = mSupplier->get(); + if (queue) + { + // Responder is reused across 2 phase upload, + // so only start next upload after 2nd phase complete. + std::string state = content["state"]; + if(state == "complete") + { + queue->request(&mSupplier); + } + } + LLUpdateTaskInventoryResponder::result(content); + } + + virtual void uploadUpload(const LLSD& content) + { + std::string uploader = content["uploader"]; + llinfos << "Compiling " << llendl; + LLHTTPClient::post(uploader, (const U8*)&mBuffer[0], mBuffer.size(), this); + } + + virtual void uploadComplete(const LLSD& content) + { + // Bytecode save completed + if (content["compiled"]) + { + llinfos << "Compiled!" << llendl; + } + else + { + llinfos << content["errors"] << llendl; + } + LLUpdateTaskInventoryResponder::uploadComplete(content); + } + + LLAssetUploadQueueSupplier *mSupplier; + std::string mBuffer; +}; + + +LLAssetUploadQueue::LLAssetUploadQueue(LLAssetUploadQueueSupplier *supplier) : + mSupplier(supplier) +{ +} + +//virtual +LLAssetUploadQueue::~LLAssetUploadQueue() +{ + delete mSupplier; +} + +// Takes ownership of supplier. +void LLAssetUploadQueue::request(LLAssetUploadQueueSupplier** supplier) +{ + if (mQueue.empty()) + return; + + UploadData data = mQueue.front(); + mQueue.pop_front(); + + LLSD body; + body["task_id"] = data.mTaskId; + body["item_id"] = data.mItemId; + body["is_script_running"] = data.mIsRunning; + body["target"] = data.mIsTargetMono? "mono" : "lsl2"; + + std::string url = ""; + LLViewerObject* object = gObjectList.findObject(data.mTaskId); + if (object) + { + url = object->getRegion()->getCapability("UpdateScriptTaskInventory"); + LLHTTPClient::post(url, body, + new LLAssetUploadChainResponder( + body, data.mFilename, data.mQueueId, + data.mBuffer, *supplier)); + } + + *supplier = NULL; +} + +void LLAssetUploadQueue::queue(const std::string& filename, + const LLUUID& task_id, + const LLUUID& item_id, + BOOL is_running, + BOOL is_target_mono, + const LLUUID& queue_id, + const std::string& buffer) +{ + UploadData data; + data.mTaskId = task_id; + data.mItemId = item_id; + data.mIsRunning = is_running; + data.mIsTargetMono = is_target_mono; + data.mQueueId = queue_id; + data.mFilename = filename; + data.mBuffer = buffer; + + mQueue.push_back(data); + + if(mSupplier) + { + request(&mSupplier); + } +} + +LLAssetUploadQueueSupplier::~LLAssetUploadQueueSupplier() +{ +} diff -urN release-r77878/linden/indra/newview/llassetuploadqueue.h mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadqueue.h --- release-r77878/linden/indra/newview/llassetuploadqueue.h 1969-12-31 16:00:00.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadqueue.h 2008-01-31 11:46:57.000000000 -0800 @@ -0,0 +1,91 @@ +/** + * @file llassetuploadqueue.h + * @brief Serializes asset upload request + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2008, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLASSETUPLOADQUEUE_H +#define LL_LLASSETUPLOADQUEUE_H + +#include "lluuid.h" + +#include +#include + +class LLAssetUploadQueueSupplier; + +class LLAssetUploadQueue +{ +public: + + // Takes ownership of supplier. + LLAssetUploadQueue(LLAssetUploadQueueSupplier* supplier); + virtual ~LLAssetUploadQueue(); + + void queue(const std::string& filename, + const LLUUID& task_id, + const LLUUID& item_id, + BOOL is_running, + BOOL is_target_mono, + const LLUUID& queue_id, + const std::string& buffer); + + bool isEmpty() const {return mQueue.empty();} + +private: + + friend class LLAssetUploadChainResponder; + + struct UploadData + { + std::string mFilename; + LLUUID mTaskId; + LLUUID mItemId; + BOOL mIsRunning; + BOOL mIsTargetMono; + LLUUID mQueueId; + std::string mBuffer; + }; + + // Ownership of mSupplier passed to currently waiting responder + // and returned to queue when no requests in progress. + LLAssetUploadQueueSupplier* mSupplier; + std::deque mQueue; + + // Passes on ownership of mSupplier if request is made. + void request(LLAssetUploadQueueSupplier** supplier); +}; + +class LLAssetUploadQueueSupplier +{ +public: + virtual ~LLAssetUploadQueueSupplier(); + virtual LLAssetUploadQueue* get() const = 0; +}; + +#endif // LL_LLASSETUPLOADQUEUE_H diff -urN release-r77878/linden/indra/newview/llassetuploadresponders.cpp mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadresponders.cpp --- release-r77878/linden/indra/newview/llassetuploadresponders.cpp 2008-01-31 11:04:03.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadresponders.cpp 2008-01-31 11:46:57.000000000 -0800 @@ -34,6 +34,7 @@ #include "llassetuploadresponders.h" #include "llagent.h" +#include "llcompilequeue.h" #include "llfloaterbuycurrency.h" #include "lleconomy.h" #include "llfilepicker.h" @@ -73,10 +74,12 @@ } LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data, - const std::string& file_name) + const std::string& file_name, + LLAssetType::EType asset_type) : LLHTTPClient::Responder(), mPostData(post_data), - mFileName(file_name) + mFileName(file_name), + mAssetType(asset_type) { } @@ -181,8 +184,8 @@ { } -LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) +LLNewAgentInventoryResponder::LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) { } @@ -311,8 +314,9 @@ } LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(const LLSD& post_data, - const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) + const std::string& file_name, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) { } @@ -420,8 +424,17 @@ } LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name) -: LLAssetUploadResponder(post_data, file_name) + const std::string& file_name, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type) +{ +} + +LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_data, + const std::string& file_name, + const LLUUID& queue_id, + LLAssetType::EType asset_type) +: LLAssetUploadResponder(post_data, file_name, asset_type), mQueueId(queue_id) { } @@ -432,35 +445,16 @@ LLUUID item_id = mPostData["item_id"]; LLUUID task_id = mPostData["task_id"]; - LLViewerObject* object = gObjectList.findObject(task_id); - if (!object) - { - llwarns << "LLUpdateTaskInventoryResponder::uploadComplete task " << task_id - << " no longer exist." << llendl; - return; - } - LLViewerInventoryItem* item = (LLViewerInventoryItem*)object->getInventoryObject(item_id); - if (!item) - { - llwarns << "LLUpdateTaskInventoryResponder::uploadComplete item " - << item_id << " is no longer in task " << task_id - << "'s inventory." << llendl; - return; - } - LLPointer new_item = new LLViewerInventoryItem(item); - // Update Viewer inventory - object->updateViewerInventoryAsset(new_item, content["new_asset"]); dialog_refresh_all(); - LLInventoryType::EType inventory_type = new_item->getInventoryType(); - switch(inventory_type) + switch(mAssetType) { - case LLInventoryType::IT_NOTECARD: + case LLAssetType::AT_NOTECARD: { // Update the UI with the new asset. LLPreviewNotecard* nc; - nc = (LLPreviewNotecard*)LLPreview::find(new_item->getUUID()); + nc = (LLPreviewNotecard*)LLPreview::find(item_id); if(nc) { // *HACK: we have to delete the asset in the VFS so @@ -480,28 +474,39 @@ } } break; - case LLInventoryType::IT_LSL: + case LLAssetType::AT_LSL_TEXT: { - LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); - if (preview) + if(mQueueId.notNull()) { - // Bytecode save completed - if (content["compiled"]) + LLFloaterCompileQueue* queue = + (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId); + if(NULL != queue) { - preview->callbackLSLCompileSucceeded( - task_id, - item_id, - mPostData["is_script_running"]); + queue->removeItemByItemID(item_id); } - else + } + else + { + LLLiveLSLEditor* preview = LLLiveLSLEditor::find(item_id, task_id); + if (preview) { - preview->callbackLSLCompileFailed(content["errors"]); + // Bytecode save completed + if (content["compiled"]) + { + preview->callbackLSLCompileSucceeded( + task_id, + item_id, + mPostData["is_script_running"]); + } + else + { + preview->callbackLSLCompileFailed(content["errors"]); + } } } } break; - case LLInventoryType::IT_WEARABLE: - default: - break; + default: + break; } } diff -urN release-r77878/linden/indra/newview/llassetuploadresponders.h mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadresponders.h --- release-r77878/linden/indra/newview/llassetuploadresponders.h 2008-01-31 11:04:02.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llassetuploadresponders.h 2008-01-31 11:46:57.000000000 -0800 @@ -42,7 +42,9 @@ LLAssetUploadResponder(const LLSD& post_data, const LLUUID& vfile_id, LLAssetType::EType asset_type); - LLAssetUploadResponder(const LLSD& post_data, const std::string& file_name); + LLAssetUploadResponder(const LLSD& post_data, + const std::string& file_name, + LLAssetType::EType asset_type); ~LLAssetUploadResponder(); virtual void error(U32 statusNum, const std::string& reason); virtual void result(const LLSD& content); @@ -52,8 +54,8 @@ protected: LLSD mPostData; - LLUUID mVFileID; LLAssetType::EType mAssetType; + LLUUID mVFileID; std::string mFileName; }; @@ -63,7 +65,8 @@ LLNewAgentInventoryResponder(const LLSD& post_data, const LLUUID& vfile_id, LLAssetType::EType asset_type); - LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name); + LLNewAgentInventoryResponder(const LLSD& post_data, const std::string& file_name, + LLAssetType::EType asset_type); virtual void uploadComplete(const LLSD& content); }; @@ -74,7 +77,8 @@ const LLUUID& vfile_id, LLAssetType::EType asset_type); LLUpdateAgentInventoryResponder(const LLSD& post_data, - const std::string& file_name); + const std::string& file_name, + LLAssetType::EType asset_type); virtual void uploadComplete(const LLSD& content); }; @@ -85,8 +89,17 @@ const LLUUID& vfile_id, LLAssetType::EType asset_type); LLUpdateTaskInventoryResponder(const LLSD& post_data, - const std::string& file_name); + const std::string& file_name, + LLAssetType::EType asset_type); + LLUpdateTaskInventoryResponder(const LLSD& post_data, + const std::string& file_name, + const LLUUID& queue_id, + LLAssetType::EType asset_type); + virtual void uploadComplete(const LLSD& content); + +private: + LLUUID mQueueId; }; #endif // LL_LLASSETUPLOADRESPONDER_H diff -urN release-r77878/linden/indra/newview/llcompilequeue.cpp mono-based-on-r77880-r79030/linden/indra/newview/llcompilequeue.cpp --- release-r77878/linden/indra/newview/llcompilequeue.cpp 2008-01-31 11:04:03.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llcompilequeue.cpp 2008-01-31 11:46:57.000000000 -0800 @@ -42,6 +42,8 @@ #include "llcompilequeue.h" #include "llagent.h" +#include "llassetuploadqueue.h" +#include "llassetuploadresponders.h" #include "llchat.h" #include "llviewerwindow.h" #include "llcallbacklist.h" @@ -73,20 +75,14 @@ const char* NOT_RUN_QUEUE_TITLE = "Set Not Running Progress"; const char* NOT_RUN_START_STRING = "set not running"; -struct LLCompileQueueData -{ - LLUUID mQueueID; - LLUUID mOldAssetID; - LLCompileQueueData(const LLUUID& q_id, const LLUUID& old_asset_id) : - mQueueID(q_id), mOldAssetID(old_asset_id) {} -}; - struct LLScriptQueueData { LLUUID mQueueID; LLString mScriptName; - LLScriptQueueData(const LLUUID& q_id, const char* name) : - mQueueID(q_id), mScriptName(name) {} + LLUUID mTaskId; + LLUUID mItemId; + LLScriptQueueData(const LLUUID& q_id, const char* name, const LLUUID& task_id, const LLUUID& item_id) : + mQueueID(q_id), mScriptName(name), mTaskId(task_id), mItemId(item_id) {} }; ///---------------------------------------------------------------------------- @@ -106,7 +102,8 @@ RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES) { - + mID.generate(); + gUICtrlFactory->buildFloater(this,"floater_script_queue.xml"); childSetAction("close",onCloseBtn,this); @@ -114,11 +111,8 @@ setTitle(title); - if (!getHost()) - { - LLRect curRect = getRect(); - translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop); - } + LLRect curRect = getRect(); + translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop); mStartString = start_string; mDone = FALSE; @@ -281,7 +275,7 @@ ///---------------------------------------------------------------------------- // static -LLFloaterCompileQueue* LLFloaterCompileQueue::create() +LLFloaterCompileQueue* LLFloaterCompileQueue::create(BOOL mono) { S32 left, top; gFloaterView->getNewFloaterPosition(&left, &top); @@ -289,7 +283,36 @@ rect.translate(left - rect.mLeft, top - rect.mTop); LLFloaterCompileQueue* new_queue = new LLFloaterCompileQueue("queue", rect); - new_queue->open(); /*Flawfinder: ignore*/ + + class LLCompileFloaterUploadQueueSupplier : public LLAssetUploadQueueSupplier + { + public: + + LLCompileFloaterUploadQueueSupplier(const LLUUID& queue_id) : + mQueueId(queue_id) + { + } + + virtual LLAssetUploadQueue* get() const + { + LLFloaterCompileQueue* queue = + (LLFloaterCompileQueue*) LLFloaterScriptQueue::findInstance(mQueueId); + + if(NULL == queue) + { + return NULL; + } + + return queue->mUploadQueue; + } + + private: + LLUUID mQueueId; + }; + + new_queue->mUploadQueue = new LLAssetUploadQueue(new LLCompileFloaterUploadQueueSupplier(new_queue->getID())); + new_queue->mMono = mono; + new_queue->open(); return new_queue; } @@ -307,7 +330,7 @@ // find all of the lsl, leaving off duplicates. We'll remove // all matching asset uuids on compilation success. - typedef std::map > uuid_item_map; + typedef std::multimap > uuid_item_map; uuid_item_map asset_item_map; InventoryObjectList::const_iterator it = inv->begin(); @@ -323,12 +346,7 @@ { LLPointer script = new LLViewerInventoryItem(item); mCurrentScripts.put(script); - - if (!asset_item_map.count(item->getAssetUUID())) - { - // No entry, put in an entry for this supposedly permissive script - asset_item_map[item->getAssetUUID()] = item; - } + asset_item_map.insert(std::make_pair(item->getAssetUUID(), item)); } } } @@ -345,7 +363,8 @@ for(iter = asset_item_map.begin(); iter != asset_item_map.end(); iter++) { LLInventoryItem *itemp = iter->second; - LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str()); + LLScriptQueueData* datap = new LLScriptQueueData(getID(), itemp->getName().c_str(), + viewer_object->getID(), itemp->getUUID()); //llinfos << "ITEM NAME 2: " << names.get(i) << llendl; gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(), @@ -362,7 +381,6 @@ } } - // This is the callback for when each script arrives // static void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id, @@ -387,13 +405,22 @@ asset_id.toString(uuid_str); snprintf(filename, sizeof(filename), "%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ + std::string script; + FILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/ if (fp) { const S32 buf_size = 65536; U8 copy_buf[buf_size]; + while (file.read(copy_buf, buf_size)) /*Flawfinder: ignore*/ { + U32 last_read = file.getLastBytesRead(); + for (U32 i = 0; i < last_read; ++i) + { + script.push_back(copy_buf[i]); + } + if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1) { // return a bad file error if we can't write the whole thing @@ -406,10 +433,31 @@ // It's now in the file, now compile it. snprintf(buffer, sizeof(buffer), "Downloaded, now compiling '%s'.", data->mScriptName.c_str()); /* Flawfinder: ignore */ - queue->compile(filename, asset_id); - - // Delete it after we're done compiling? - LLFile::remove(filename); + + const bool is_running = true; + LLViewerObject* object = gObjectList.findObject(data->mTaskId); + if (object) + { + std::string url = object->getRegion()->getCapability("UpdateScriptTaskInventory"); + if(! url.empty()) + { + queue->mUploadQueue->queue(filename, data->mTaskId, + data->mItemId, is_running, queue->mMono, queue->getID(), + script); + } + else + { + // TODO: babbage: No compile if no cap. + queue->compile(filename, data->mItemId); + + // Delete it after we're done compiling? + LLFile::remove(filename); + } + } + else + { + llerrs << "Unable to find object to compile" << llendl; + } } else { @@ -439,7 +487,7 @@ } llwarns << "Problem downloading script asset." << llendl; - if(queue) queue->removeItemByAssetID(asset_id); + if(queue) queue->removeItemByItemID(data->mItemId); } if(queue) { @@ -471,9 +519,8 @@ (LLFloaterScriptQueue::findInstance(data->mQueueID)); if(queue && (0 == status) && data) { - queue->updateAssetID(data->mOldAssetID, asset_id); - queue->saveItemByAssetID(asset_id); - queue->removeItemByAssetID(asset_id); + queue->saveItemByItemID(data->mItemId); + queue->removeItemByItemID(data->mItemId); } else { @@ -487,9 +534,8 @@ } // compile the file given and save it out. -void LLFloaterCompileQueue::compile(const char* filename, - const LLUUID& asset_id) -{ +void LLFloaterCompileQueue::compile(const char* filename, const LLUUID& item_id) +{ LLUUID new_asset_id; LLTransactionID tid; tid.generate(); @@ -497,37 +543,40 @@ char uuid_string[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ new_asset_id.toString(uuid_string); - char dst_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(dst_filename, sizeof(dst_filename), "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ - char err_filename[LL_MAX_PATH]; /*Flawfinder: ignore*/ - snprintf(err_filename, sizeof(err_filename), "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); /* Flawfinder: ignore */ + + char dst_filename[LL_MAX_PATH]; + sprintf(dst_filename, "%s.lso", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); + char err_filename[LL_MAX_PATH]; + sprintf(err_filename, "%s.out", gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string).c_str()); gAssetStorage->storeAssetData(filename, tid, LLAssetType::AT_LSL_TEXT, &onSaveTextComplete, NULL, FALSE); - if(!lscript_compile(filename, dst_filename, err_filename, gAgent.isGodlike())) + const BOOL compile_to_mono = FALSE; + if(!lscript_compile(filename, dst_filename, err_filename, compile_to_mono, uuid_string, gAgent.isGodlike())) { llwarns << "compile failed" << llendl; - removeItemByAssetID(asset_id); + removeItemByItemID(item_id); } else { llinfos << "compile successful." << llendl; - // Save the bytecode - LLCompileQueueData* data = new LLCompileQueueData(mID, asset_id); - gAssetStorage->storeAssetData(dst_filename, tid, - LLAssetType::AT_LSL_BYTECODE, - &onSaveBytecodeComplete, - (void*)data, FALSE); + + // Save LSL bytecode + LLCompileQueueData* data = new LLCompileQueueData(mID, item_id); + gAssetStorage->storeAssetData(dst_filename, new_asset_id, + LLAssetType::AT_LSL_BYTECODE, + &LLFloaterCompileQueue::onSaveBytecodeComplete, + (void*)data, FALSE); } } -void LLFloaterCompileQueue::removeItemByAssetID(const LLUUID& asset_id) +void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id) { llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl; for(S32 i = 0; i < mCurrentScripts.count(); ) { - if(asset_id == mCurrentScripts.get(i)->getAssetUUID()) + if(asset_id == mCurrentScripts.get(i)->getUUID()) { mCurrentScripts.remove(i); } @@ -542,7 +591,21 @@ } } -void LLFloaterCompileQueue::saveItemByAssetID(const LLUUID& asset_id) +const LLInventoryItem* LLFloaterCompileQueue::findItemByItemID(const LLUUID& asset_id) const +{ + LLInventoryItem* result = NULL; + S32 count = mCurrentScripts.count(); + for(S32 i = 0; i < count; ++i) + { + if(asset_id == mCurrentScripts.get(i)->getUUID()) + { + result = mCurrentScripts.get(i); + } + } + return result; +} + +void LLFloaterCompileQueue::saveItemByItemID(const LLUUID& asset_id) { llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl; LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID); @@ -551,7 +614,7 @@ S32 count = mCurrentScripts.count(); for(S32 i = 0; i < count; ++i) { - if(asset_id == mCurrentScripts.get(i)->getAssetUUID()) + if(asset_id == mCurrentScripts.get(i)->getUUID()) { // *FIX: this auto-resets active to TRUE. That might // be a bad idea. @@ -565,20 +628,6 @@ } } -// find old_asst_id, and set the asset id to new_asset_id -void LLFloaterCompileQueue::updateAssetID(const LLUUID& old_asset_id, - const LLUUID& new_asset_id) -{ - S32 count = mCurrentScripts.count(); - for(S32 i = 0; i < count; ++i) - { - if(old_asset_id == mCurrentScripts.get(i)->getAssetUUID()) - { - mCurrentScripts.get(i)->setAssetUUID(new_asset_id); - } - } -} - ///---------------------------------------------------------------------------- /// Class LLFloaterResetQueue ///---------------------------------------------------------------------------- @@ -592,7 +641,8 @@ rect.translate(left - rect.mLeft, top - rect.mTop); LLFloaterResetQueue* new_queue = new LLFloaterResetQueue("queue", rect); - new_queue->open(); /*Flawfinder: ignore*/ + gFloaterView->addChild(new_queue); + new_queue->open(); return new_queue; } diff -urN release-r77878/linden/indra/newview/llcompilequeue.h mono-based-on-r77880-r79030/linden/indra/newview/llcompilequeue.h --- release-r77878/linden/indra/newview/llcompilequeue.h 2008-01-31 11:04:02.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llcompilequeue.h 2008-01-31 11:46:57.000000000 -0800 @@ -64,6 +64,9 @@ // start() returns TRUE if the queue has started, otherwise FALSE. BOOL start(); + // find an instance by ID. Return NULL if it does not exist. + static LLFloaterScriptQueue* findInstance(const LLUUID& id); + protected: LLFloaterScriptQueue(const std::string& name, const LLRect& rect, const char* title, const char* start_string); @@ -92,9 +95,6 @@ // Get this instances ID. const LLUUID& getID() const { return mID; } - - // find an instance by ID. Return NULL if it does not exist. - static LLFloaterScriptQueue* findInstance(const LLUUID& id); protected: // UI @@ -118,12 +118,29 @@ // This script queue will recompile each script. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +struct LLCompileQueueData +{ + LLUUID mQueueID; + LLUUID mItemId; + LLCompileQueueData(const LLUUID& q_id, const LLUUID& item_id) : + mQueueID(q_id), mItemId(item_id) {} +}; + +class LLAssetUploadQueue; + class LLFloaterCompileQueue : public LLFloaterScriptQueue { public: // Use this method to create a compile queue. Once created, it // will be responsible for it's own destruction. - static LLFloaterCompileQueue* create(); + static LLFloaterCompileQueue* create(BOOL mono); + + static void onSaveBytecodeComplete(const LLUUID& asset_id, + void* user_data, + S32 status); + + // remove any object in mScriptScripts with the matching uuid. + void removeItemByItemID(const LLUUID& item_id); protected: LLFloaterCompileQueue(const std::string& name, const LLRect& rect); @@ -139,24 +156,26 @@ void* user_data, S32 status, LLExtStat ext_status); static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status); + static void onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status); // compile the file given and save it out. - void compile(const char* filename, const LLUUID& asset_id); - - // remove any object in mScriptScripts with the matching uuid. - void removeItemByAssetID(const LLUUID& asset_id); + void compile(const char* filename, const LLUUID& item_id); - // save the items indicatd by the asset id. - void saveItemByAssetID(const LLUUID& asset_id); + // save the items indicated by the item id. + void saveItemByItemID(const LLUUID& item_id); - // find old_asst_id, and set the asset id to new_asset_id - void updateAssetID(const LLUUID& old_asset_id, const LLUUID& new_asset_id); + // find InventoryItem given item id. + const LLInventoryItem* findItemByItemID(const LLUUID& item_id) const; protected: LLViewerInventoryItem::item_array_t mCurrentScripts; + +private: + BOOL mMono; // Compile to mono. + LLAssetUploadQueue* mUploadQueue; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff -urN release-r77878/linden/indra/newview/llpreviewscript.cpp mono-based-on-r77880-r79030/linden/indra/newview/llpreviewscript.cpp --- release-r77878/linden/indra/newview/llpreviewscript.cpp 2008-01-31 11:04:03.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llpreviewscript.cpp 2008-01-31 11:46:57.000000000 -0800 @@ -139,6 +139,12 @@ const S32 MAX_HISTORY_COUNT = 10; const F32 LIVE_HELP_REFRESH_TIME = 1.f; +static bool have_script_upload_cap(LLUUID& object_id) +{ + LLViewerObject* object = gObjectList.findObject(object_id); + return object && (! object->getRegion()->getCapability("UpdateScriptTaskInventory").empty()); +} + /// --------------------------------------------------------------------------- /// LLFloaterScriptSearch /// --------------------------------------------------------------------------- @@ -173,7 +179,7 @@ LLFloaterScriptSearch* LLFloaterScriptSearch::sInstance = NULL; LLFloaterScriptSearch::LLFloaterScriptSearch(std::string title, LLRect rect, LLScriptEdCore* editor_core) - : LLFloater("script search",rect,title), mEditorCore(editor_core) + : LLFloater("script search",rect,title), mEditorCore(editor_core) { gUICtrlFactory->buildFloater(this,"floater_script_search.xml"); @@ -305,14 +311,15 @@ mUserdata( userdata ), mForceClose( FALSE ), mLastHelpToken(NULL), - mLiveHelpHistorySize(0) + mLiveHelpHistorySize(0), + mEnableSave(FALSE) { setFollowsAll(); setBorderVisible(FALSE); gUICtrlFactory->buildPanel(this, "floater_script_ed_panel.xml"); - + mErrorList = LLUICtrlFactory::getScrollListByName(this, "lsl errors"); mFunctions = LLUICtrlFactory::getComboBoxByName(this, "Insert..."); @@ -439,13 +446,13 @@ LLScriptEdCore* self = (LLScriptEdCore*)userdata; if (!self || !self->mEditor) return FALSE; - return !self->mEditor->isPristine(); + return !self->mEditor->isPristine() || self->mEnableSave; } void LLScriptEdCore::draw() { - BOOL script_changed = !mEditor->isPristine(); - childSetEnabled("Save_btn", script_changed); + BOOL script_changed = hasChanged(this); + childSetEnabled("Save_btn", script_changed); if( mEditor->hasFocus() ) { @@ -596,7 +603,7 @@ BOOL LLScriptEdCore::canClose() { - if(mForceClose || mEditor->isPristine()) + if(mForceClose || !hasChanged(this)) { return TRUE; } @@ -1263,7 +1270,7 @@ void LLPreviewLSL::saveIfNeeded() { // llinfos << "LLPreviewLSL::saveIfNeeded()" << llendl; - if(mScriptEd->mEditor->isPristine()) + if(!LLScriptEdCore::hasChanged(mScriptEd)) { return; } @@ -1321,7 +1328,8 @@ llinfos << "Update Agent Inventory via capability" << llendl; LLSD body; body["item_id"] = item_id; - LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename)); + body["target"] = "lsl2"; + LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } void LLPreviewLSL::uploadAssetLegacy(const std::string& filename, @@ -1342,9 +1350,12 @@ std::string dst_filename = llformat("%s.lso", filepath.c_str()); std::string err_filename = llformat("%s.out", filepath.c_str()); + const BOOL compile_to_mono = FALSE; if(!lscript_compile(filename.c_str(), dst_filename.c_str(), err_filename.c_str(), + compile_to_mono, + asset_id.asString().c_str(), gAgent.isGodlike())) { llinfos << "Compile failed!" << llendl; @@ -1640,7 +1651,10 @@ factory_map["script ed panel"] = LLCallbackMap(LLLiveLSLEditor::createScriptEdPanel, this); gUICtrlFactory->buildFloater(this,"floater_live_lsleditor.xml", &factory_map); - + + mMonoCheckbox = LLUICtrlFactory::getCheckBoxByName(this, "mono"); + childSetCommitCallback("mono", &LLLiveLSLEditor::onMonoCheckboxClicked, this); + childSetEnabled("mono", FALSE); childSetCommitCallback("running", LLLiveLSLEditor::onRunningCheckboxClicked, this); childSetEnabled("running", FALSE); @@ -1652,7 +1666,6 @@ mScriptEd->mEditor->makePristine(); loadAsset(is_new); mScriptEd->mEditor->setFocus(TRUE); - if (!getHost()) { @@ -1730,6 +1743,7 @@ mScriptEd->mEditor->setText(childGetText("not_allowed")); mScriptEd->mEditor->makePristine(); mScriptEd->mEditor->setEnabled(FALSE); + mScriptEd->enableSave(FALSE); mAssetStatus = PREVIEW_ASSET_LOADED; } else if(item && mItem.notNull()) @@ -1802,7 +1816,8 @@ else { mScriptEd->mEditor->setText(LLString(HELLO_LSL)); - //mScriptEd->mEditor->setText(LLString::null); + mScriptEd->enableSave(FALSE); + //mScriptEd->mEditor->setText(""); //mScriptEd->mEditor->makePristine(); LLPermissions perm; perm.init(gAgent.getID(), gAgent.getID(), LLUUID::null, gAgent.getGroupID()); @@ -1993,6 +2008,7 @@ // incorrect after a release/claim cycle, but will be // correct after clicking on it. runningCheckbox->set(FALSE); + mMonoCheckbox->set(FALSE); } } else if(!object) @@ -2001,6 +2017,7 @@ // Really ought to put in main window. setTitle("Script (object out of range)"); runningCheckbox->setEnabled(FALSE); + mMonoCheckbox->setEnabled(FALSE); // object may have fallen out of range. mHaveRunningInfo = FALSE; } @@ -2065,7 +2082,7 @@ } // Don't need to save if we're pristine - if(mScriptEd->mEditor->isPristine()) + if(!LLScriptEdCore::hasChanged(mScriptEd)) { return; } @@ -2073,6 +2090,7 @@ mPendingUploads = 0; // save the script + mScriptEd->enableSave(FALSE); mScriptEd->mEditor->makePristine(); mScriptEd->mErrorList->deleteAllItems(); @@ -2112,7 +2130,7 @@ fp = NULL; // save it out to asset server - std::string url = gAgent.getRegion()->getCapability("UpdateScriptTaskInventory"); + std::string url = object->getRegion()->getCapability("UpdateScriptTaskInventory"); getWindow()->incBusyCount(); mPendingUploads++; BOOL is_running = LLUICtrlFactory::getCheckBoxByName(this, "running")->get(); @@ -2138,8 +2156,9 @@ body["task_id"] = task_id; body["item_id"] = item_id; body["is_script_running"] = is_running; + body["target"] = monoChecked() ? "mono": "lsl2"; LLHTTPClient::post(url, body, - new LLUpdateTaskInventoryResponder(body, filename)); + new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT)); } void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename, @@ -2162,9 +2181,12 @@ std::string err_filename = llformat("%s.out", filepath.c_str()); FILE *fp; + const BOOL compile_to_mono = FALSE; if(!lscript_compile(filename.c_str(), dst_filename.c_str(), err_filename.c_str(), + compile_to_mono, + asset_id.asString().c_str(), gAgent.isGodlike())) { // load the error file into the error scrolllist @@ -2403,6 +2425,11 @@ msg->getBOOLFast(_PREHASH_Script, _PREHASH_Running, running); LLCheckBoxCtrl* runningCheckbox = LLUICtrlFactory::getCheckBoxByName(instance, "running"); runningCheckbox->set(running); + BOOL mono; + msg->getBOOLFast(_PREHASH_Script, "Mono", mono); + LLCheckBoxCtrl* monoCheckbox = LLUICtrlFactory::getCheckBoxByName(instance, "mono"); + monoCheckbox->setEnabled(have_script_upload_cap(object_id)); + monoCheckbox->set(mono); } } @@ -2417,3 +2444,19 @@ gSavedSettings.setRect("PreviewScriptRect", mRect); } } + +void LLLiveLSLEditor::onMonoCheckboxClicked(LLUICtrl*, void* userdata) +{ + LLLiveLSLEditor* self = static_cast(userdata); + self->mMonoCheckbox->setEnabled(have_script_upload_cap(self->mObjectID)); + self->mScriptEd->enableSave(TRUE); +} + +BOOL LLLiveLSLEditor::monoChecked() const +{ + if(NULL != mMonoCheckbox) + { + return mMonoCheckbox->getValue()? TRUE : FALSE; + } + return FALSE; +} diff -urN release-r77878/linden/indra/newview/llpreviewscript.h mono-based-on-r77880-r79030/linden/indra/newview/llpreviewscript.h --- release-r77878/linden/indra/newview/llpreviewscript.h 2008-01-31 11:04:03.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llpreviewscript.h 2008-01-31 11:46:57.000000000 -0800 @@ -119,13 +119,14 @@ void selectFirstError(); virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); + + void enableSave(BOOL b) {mEnableSave = b;} protected: void deleteBridges(); void setHelpPage(const LLString& help_string); void updateDynamicHelp(BOOL immediate = FALSE); void addHelpItemToHistory(const LLString& help_string); - static void onErrorList(LLUICtrl*, void* user_data); virtual const char *getTitleName() const { return "Script"; } @@ -148,6 +149,7 @@ LLKeywordToken* mLastHelpToken; LLFrameTimer mLiveHelpTimer; S32 mLiveHelpHistorySize; + BOOL mEnableSave; }; @@ -278,6 +280,13 @@ S32 mPendingUploads; static LLMap sInstances; + +private: + + static void onMonoCheckboxClicked(LLUICtrl*, void* userdata); + BOOL monoChecked() const; + + LLCheckBoxCtrl* mMonoCheckbox; }; // name of help file for lsl diff -urN release-r77878/linden/indra/newview/llviewermenu.cpp mono-based-on-r77880-r79030/linden/indra/newview/llviewermenu.cpp --- release-r77878/linden/indra/newview/llviewermenu.cpp 2008-01-31 11:04:04.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llviewermenu.cpp 2008-01-31 11:46:57.000000000 -0800 @@ -6193,9 +6193,13 @@ { LLString action = userdata.asString(); LLFloaterScriptQueue* queue = NULL; - if (action == "compile") + if (action == "compile mono") { - queue = LLFloaterCompileQueue::create(); + queue = LLFloaterCompileQueue::create(TRUE); + } + if (action == "compile lsl") + { + queue = LLFloaterCompileQueue::create(FALSE); } else if (action == "reset") { @@ -6437,16 +6441,36 @@ return (gSelectMgr->getSelection()->getObjectCount() > 1); } +static bool is_editable_selected() +{ + return (gSelectMgr->getSelection()->getFirstEditableObject() != NULL); +} + class LLEditableSelected : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - bool new_value = (gSelectMgr->getSelection()->getFirstEditableObject() != NULL); - gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); + gMenuHolder->findControl(userdata["control"].asString())->setValue(is_editable_selected()); return true; } }; +class LLEditableSelectedMono : public view_listener_t +{ + bool handleEvent(LLPointer event, const LLSD& userdata) + { + LLViewerRegion* region = gAgent.getRegion(); + if(region && gMenuHolder && gMenuHolder->findControl(userdata["control"].asString())) + { + bool have_cap = (! region->getCapability("UpdateScriptTaskInventory").empty()); + bool selected = is_editable_selected() && have_cap; + gMenuHolder->findControl(userdata["control"].asString())->setValue(selected); + return true; + } + return false; + } +}; + class LLToolsEnableTakeCopy : public view_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) @@ -7733,4 +7757,5 @@ addMenu(new LLSomethingSelected(), "SomethingSelected"); addMenu(new LLSomethingSelectedNoHUD(), "SomethingSelectedNoHUD"); addMenu(new LLEditableSelected(), "EditableSelected"); + addMenu(new LLEditableSelectedMono(), "EditableSelectedMono"); } diff -urN release-r77878/linden/indra/newview/llviewerobject.cpp mono-based-on-r77880-r79030/linden/indra/newview/llviewerobject.cpp --- release-r77878/linden/indra/newview/llviewerobject.cpp 2008-01-31 11:04:04.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llviewerobject.cpp 2008-01-31 11:46:57.000000000 -0800 @@ -2138,7 +2138,7 @@ } void LLViewerObject::doUpdateInventory( - LLViewerInventoryItem* item, + LLPointer& item, U8 key, bool is_new) { @@ -2210,7 +2210,8 @@ --mInventorySerialNum; } } - LLViewerInventoryItem* new_item = new LLViewerInventoryItem(item); + LLViewerInventoryItem* oldItem = item; + LLViewerInventoryItem* new_item = new LLViewerInventoryItem(oldItem); new_item->setPermissions(perm); mInventory->push_front(new_item); doInventoryCallback(); @@ -2596,6 +2597,21 @@ doUpdateInventory(task_item, key, is_new); } +void LLViewerObject::updateInventoryLocal(LLInventoryItem* item, U8 key) +{ + LLPointer task_item = + new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(), + item->getAssetUUID(), item->getType(), + item->getInventoryType(), + item->getName(), item->getDescription(), + item->getSaleInfo(), item->getFlags(), + item->getCreationDate()); + + // do the internal logic + const bool is_new = false; + doUpdateInventory(task_item, key, is_new); +} + LLInventoryObject* LLViewerObject::getInventoryObject(const LLUUID& item_id) { LLInventoryObject* rv = NULL; diff -urN release-r77878/linden/indra/newview/llviewerobject.h mono-based-on-r77880-r79030/linden/indra/newview/llviewerobject.h --- release-r77878/linden/indra/newview/llviewerobject.h 2008-01-31 11:04:03.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llviewerobject.h 2008-01-31 11:46:57.000000000 -0800 @@ -381,6 +381,7 @@ // manager, so do no call updateInventory() from the selection // manager until we have better iterators. void updateInventory(LLViewerInventoryItem* item, U8 key, bool is_new); + void updateInventoryLocal(LLInventoryItem* item, U8 key); // Update without messaging. LLInventoryObject* getInventoryObject(const LLUUID& item_id); void getInventoryContents(InventoryObjectList& objects); LLInventoryObject* getInventoryRoot(); @@ -534,7 +535,7 @@ // do the update/caching logic. called by saveScript and // updateInventory. - void doUpdateInventory(LLViewerInventoryItem* item, U8 key, bool is_new); + void doUpdateInventory(LLPointer& item, U8 key, bool is_new); static LLViewerObject *createObject(const LLUUID &id, LLPCode pcode, LLViewerRegion *regionp); diff -urN release-r77878/linden/indra/newview/llviewertextdoc.h mono-based-on-r77880-r79030/linden/indra/newview/llviewertextdoc.h --- release-r77878/linden/indra/newview/llviewertextdoc.h 1969-12-31 16:00:00.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/llviewertextdoc.h 2008-01-31 11:46:57.000000000 -0800 @@ -0,0 +1,112 @@ +/** + * @file llviewertextdoc.h + * @brief ? + * + * $LicenseInfo:firstyear=2001&license=internal$ + * + * Copyright (c) 2001-2008, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLVIEWERTEXTDOC_H +#define LL_LLVIEWERTEXTDOC_H + +#include "stdtypes.h" +#include "lltextdoc.h" +#include "llinventory.h" + + +const S32 MAX_EMBEDDED_ITEMS = 127; + +class LLEmbeddedItems +{ +public: + LLEmbeddedItems(); + + BOOL isActivated() { return mActivated; } + + void bindExtendedChars(const LLFontGL* font); + void unbindExtendedChars(const LLFontGL* font); + + BOOL insertEmbeddedItem(const LLInventoryItem* item, U8* value, LLTextDoc* doc); + BOOL pasteEmbeddedItem(U8 ext_char_value); + void garbageCollect(const LLWString &wtext); + + LLInventoryItem* getEmbeddedItem(U8 ext_char_value); + + BOOL importFile(FILE* fp); + BOOL exportFile(FILE* fp); +private: + void clear(); + +private: + struct LLItemEntry + { + LLItemEntry() : mUsed(FALSE), mDeletedAge(0), mFlag(FALSE) + { + mItem = new LLInventoryItem; + } + + BOOL mUsed; // TRUE if mItem is valid, whether or not it has been deleted. + S32 mDeletedAge; // 0 if not deleted. Increments during every garbage collection pass where item is not in doc. + LLPointer mItem; // The item itself + BOOL mFlag; // Used during garbage collection + }; + + BOOL mActivated; // Set true the first time an item is inserted + LLItemEntry mEntries[MAX_EMBEDDED_ITEMS]; +}; + + +class LLViewerTextDoc : public LLTextDoc +{ +friend class LLEmbeddedItems; +friend class LLTextCmdInsertEmbeddedItem; + +public: + static LLTextDoc* instance(BOOL allow_embedded, S32 max_length) { return new LLViewerTextDoc(allow_embedded, max_length); } + LLViewerTextDoc(BOOL allow_embedded, S32 max_length); + virtual ~LLViewerTextDoc(); + + BOOL getEmbeddedItemToolTipAtPos(S32 pos, LLWString &wmsg); + LLInventoryItem* getEmbeddedItemAtPos(S32 pos); + BOOL openEmbeddedItemAtPos( S32 pos ); + BOOL openEmbeddedItem(const LLInventoryItem* item); + + S32 insertEmbeddedItem(S32 pos, LLInventoryItem* item); + + // Embedded object operations + /*virtual*/ BOOL pasteEmbeddedItem(U8 ext_char_value) { return mEmbeddedItemList.pasteEmbeddedItem( ext_char_value ); } + /*virtual*/ void bindExtendedChars(const LLFontGL* font) { mEmbeddedItemList.bindExtendedChars( font ); } + /*virtual*/ void unbindExtendedChars(const LLFontGL* font) { mEmbeddedItemList.unbindExtendedChars( font ); } + +private: + void openEmbeddedTexture( const LLInventoryItem* item ); + void openEmbeddedSound( const LLInventoryItem* item ); + void openEmbeddedLandmark( const LLInventoryItem* item ); + void openEmbeddedNotecard( const LLInventoryItem* item ); + void showCopyToInvDialog( const LLInventoryItem* item ); + static void onCopyToInvDialog( S32 option, void* userdata ); + + void showLandmarkDialog( const LLInventoryItem* item ); + static void onLandmarkDialog( S32 option, void* userdata ); + + /*virtual*/ BOOL importFile(FILE* fp); + /*virtual*/ BOOL exportFile(FILE* fp); + +private: + LLEmbeddedItems mEmbeddedItemList; +}; + +#endif // LL_LLVIEWERTEXTDOC_H diff -urN release-r77878/linden/indra/newview/macview.xcodeproj/project.pbxproj mono-based-on-r77880-r79030/linden/indra/newview/macview.xcodeproj/project.pbxproj --- release-r77878/linden/indra/newview/macview.xcodeproj/project.pbxproj 2008-01-31 11:04:01.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/macview.xcodeproj/project.pbxproj 2008-01-31 11:46:56.000000000 -0800 @@ -82,6 +82,7 @@ 2EFEA8F109F4588B00CB0193 /* llpanelgroupgeneral.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EFEA8F009F4588B00CB0193 /* llpanelgroupgeneral.cpp */; }; 3834D6050B73ABC1002B61C8 /* llmessagereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3834D6010B73ABC1002B61C8 /* llmessagereader.cpp */; }; 3834D6060B73ABC1002B61C8 /* lltemplatemessagereader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3834D6030B73ABC1002B61C8 /* lltemplatemessagereader.cpp */; }; + 3881089A0CE34E06004F5532 /* llassetuploadqueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 388108990CE34E06004F5532 /* llassetuploadqueue.cpp */; }; 38D0FA6C0B4BF898003323BA /* lltemplatemessagebuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38D0FA690B4BF897003323BA /* lltemplatemessagebuilder.cpp */; }; 38D0FA6D0B4BF898003323BA /* llmessagetemplate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38D0FA6A0B4BF898003323BA /* llmessagetemplate.cpp */; }; 38D0FA6E0B4BF898003323BA /* llmessagebuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 38D0FA6B0B4BF898003323BA /* llmessagebuilder.cpp */; }; @@ -1288,6 +1289,8 @@ 3834D6020B73ABC1002B61C8 /* llmessagereader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = llmessagereader.h; sourceTree = ""; }; 3834D6030B73ABC1002B61C8 /* lltemplatemessagereader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lltemplatemessagereader.cpp; sourceTree = ""; }; 3834D6040B73ABC1002B61C8 /* lltemplatemessagereader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = lltemplatemessagereader.h; sourceTree = ""; }; + 388108980CE34E05004F5532 /* llassetuploadqueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llassetuploadqueue.h; sourceTree = ""; }; + 388108990CE34E06004F5532 /* llassetuploadqueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = llassetuploadqueue.cpp; sourceTree = ""; }; 38D0FA690B4BF897003323BA /* lltemplatemessagebuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = lltemplatemessagebuilder.cpp; sourceTree = ""; }; 38D0FA6A0B4BF898003323BA /* llmessagetemplate.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llmessagetemplate.cpp; sourceTree = ""; }; 38D0FA6B0B4BF898003323BA /* llmessagebuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = llmessagebuilder.cpp; sourceTree = ""; }; @@ -2565,6 +2568,8 @@ 1AA2EEA00CBBE28C0017E185 /* llclassifiedstatsresponder.cpp */, 1AA2EE9C0CBBE2790017E185 /* llfloaterlandmark.h */, 1AA2EE9D0CBBE2790017E185 /* llfloaterlandmark.cpp */, + 388108980CE34E05004F5532 /* llassetuploadqueue.h */, + 388108990CE34E06004F5532 /* llassetuploadqueue.cpp */, 1AD394120CAB001B004BA76A /* llcommandhandler.cpp */, 1AD3940E0CAB000F004BA76A /* llurlsimstring.cpp */, 1AD3940F0CAB000F004BA76A /* llurldispatcher.cpp */, @@ -4336,7 +4341,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# exit on any error\nset -e\n\n# Check that the message template is compatible\npython ../../scripts/template_verifier.py --mode=\"development\"\n\n# Copy the necessary resources into the build directory.\npython viewer_manifest.py --actions=\"copy\" --configuration=\"${CONFIGURATION}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\n"; + shellScript = "# exit on any error\nset -e\n\n# Check that the message template is compatible\n# python ../../scripts/template_verifier.py --mode=\"development\"\n\n# Copy the necessary resources into the build directory.\npython viewer_manifest.py --actions=\"copy\" --configuration=\"${CONFIGURATION}\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\n"; }; FD53B40409BDF9F600BFE3BC /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -4823,6 +4828,7 @@ FE679A3F0CDFF5AC00959041 /* llvectorperfoptions.cpp in Sources */, FE679A400CDFF5AC00959041 /* llvieweraudio.cpp in Sources */, D2768CE50CEA38940000BD66 /* llfloaterlagmeter.cpp in Sources */, + 3881089A0CE34E06004F5532 /* llassetuploadqueue.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -urN release-r77878/linden/indra/newview/mono_viewer_helpers.cpp mono-based-on-r77880-r79030/linden/indra/newview/mono_viewer_helpers.cpp --- release-r77878/linden/indra/newview/mono_viewer_helpers.cpp 1969-12-31 16:00:00.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/mono_viewer_helpers.cpp 2008-01-31 11:46:58.000000000 -0800 @@ -0,0 +1,139 @@ +/** + * @file mono_viewer_helpers.cpp + * @brief Mono helper functions used on the viewer. + * + * $LicenseInfo:firstyear=2005&license=internal$ + * + * Copyright (c) 2005-2008, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "mono_viewer_helpers.h" + +#include "llviewerobject.h" +#include "llviewerobjectlist.h" +#include "llviewerinventory.h" +#include "llpreviewscript.h" +#include "llcompilequeue.h" +#include "lscript_error.h" +#include "llagent.h" +#include "llviewerwindow.h" + +void upload_cil_assembler(const char* filename, const LLInventoryItem* item, const LLUUID& object_id, BOOL active, const LLUUID& asset_id, const LLUUID& queue_id, const LLUUID& old_asset_id) +{ + // Set up file upload part of message. + S32 index = strlen(filename); + char delim = gDirUtilp->getDirDelimiter()[0]; + while(index && filename[index--] != delim); + index += 2; + const char* basename = &filename[index]; + + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("InitiateCILScriptUpload"); + + msg->nextBlock("FileBlock"); + msg->addString("BaseFilename", basename); + msg->addString("SourceFilename", filename); + + msg->nextBlock("UpdateBlock"); + msg->addUUID("AgentID", gAgent.getID()); + msg->addUUID("GroupID", gAgent.getGroupID()); + msg->addUUID("AssetID", asset_id); + msg->addUUID("OldAssetID", old_asset_id); + msg->addUUID("QueueID", queue_id); + msg->addBOOL("Enabled", active); + + //LLMemType mt(LLMemType::MTYPE_VIEWEROBJECT); + LLPointer task_item; + + // Build inventory item to go in to message. + if(NULL != item) + { + task_item = new LLViewerInventoryItem(item->getUUID(), object_id, item->getPermissions(), + item->getAssetUUID(), item->getType() /*LLAssetType::AT_CIL_BYTECODE*/, + item->getInventoryType(), + item->getName(), item->getDescription(), + item->getSaleInfo(), item->getFlags(), + item->getCreationDate()); + } + else + { + task_item = new LLViewerInventoryItem(); + } + + // Get local object if script is edited live. + LLViewerObject* object = gObjectList.findObject(object_id); + if(object) + { + msg->addU32("ObjectLocalID", object->mLocalID); + + // do the internal logic + object->updateInventoryLocal(task_item, TASK_INVENTORY_ITEM_KEY); + } + else + { + msg->addU32("ObjectLocalID", 0); + } + + // Add inventory item, which is needed even if it's blank. + msg->nextBlock("InventoryBlock"); + task_item->packMessage(msg); + + // Send message. + gAgent.sendReliableMessage(); + llinfos << "upload_cil_assembler" << llendl; +} + +void process_upload_cil_complete(LLMessageSystem* msg, void**) +{ + llinfos << "process_upload_cil_complete" << llendl; + + LLUUID item_id; + LLUUID object_id; + LLUUID asset_id; + LLUUID old_asset_id; + LLUUID queue_id; + S32 status; + msg->getUUIDFast(_PREHASH_Script, _PREHASH_ObjectID, object_id); + msg->getUUIDFast(_PREHASH_Script, _PREHASH_ItemID, item_id); + msg->getUUIDFast(_PREHASH_Script, _PREHASH_AssetID, asset_id); + msg->getUUID("Script", "OldAssetID", old_asset_id); + msg->getUUID("Script", "QueueID", queue_id); + msg->getS32("Script", "Status", status); + + if(status <= 0) + { + if(NULL != LLPreviewLSL::getInstance(item_id)) + { + LLPreviewLSL::onSaveBytecodeComplete(asset_id, new LLUUID(item_id), status); + } + else if(NULL != LLFloaterScriptQueue::findInstance(queue_id)) + { + LLFloaterCompileQueue::onSaveBytecodeComplete(asset_id, (void*) new LLCompileQueueData(queue_id, old_asset_id), status); + } + else + { + LLLiveLSLEditor::onCILUploadComplete(object_id, item_id, status); + } + } + else + { + // Mono build errors are all positive, asset storage errors are negative. + llwarns << "Problem building CIL Bytecode: " << getLScriptErrorString((LSCRIPTErrors) status) << llendl; + + // TODO: Babbage alert dialog... + } +} diff -urN release-r77878/linden/indra/newview/mono_viewer_helpers.h mono-based-on-r77880-r79030/linden/indra/newview/mono_viewer_helpers.h --- release-r77878/linden/indra/newview/mono_viewer_helpers.h 1969-12-31 16:00:00.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/mono_viewer_helpers.h 2008-01-31 11:46:57.000000000 -0800 @@ -0,0 +1,31 @@ +/** + * @file mono_viewer_helpers.h + * @brief Mono helper functions used on the viewer. + * + * $LicenseInfo:firstyear=2005&license=internal$ + * + * Copyright (c) 2005-2008, Linden Research, Inc. + * + * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of + * this source code is governed by the Linden Lab Source Code Disclosure + * Agreement ("Agreement") previously entered between you and Linden + * Lab. By accessing, using, copying, modifying or distributing this + * software, you acknowledge that you have been informed of your + * obligations under the Agreement and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_MONO_VIEWER_HELPERS_H +#define LL_MONO_VIEWER_HELPERS_H + +class LLInventoryItem; +class LLUUID; + +void upload_cil_assembler(const char* filename, const LLInventoryItem* item, const LLUUID& object_id, BOOL active, const LLUUID& asset_id, const LLUUID& queue_id, const LLUUID& old_asset_id); +void process_upload_cil_complete(LLMessageSystem* msg, void**); + +#endif // #ifndef LL_MONO_VIEWER_HELPERS_H diff -urN release-r77878/linden/indra/newview/newview.vcproj mono-based-on-r77880-r79030/linden/indra/newview/newview.vcproj --- release-r77878/linden/indra/newview/newview.vcproj 2008-01-31 11:04:02.000000000 -0800 +++ mono-based-on-r77880-r79030/linden/indra/newview/newview.vcproj 2008-01-31 11:46:57.000000000 -0800 @@ -305,6 +305,9 @@ RelativePath=".\llappviewerwin32.cpp"> + + + +