public static string CreateCompilerScript(Compiler compiler,
                                                  List<string> MethodsToAdd, string ScriptClass)
        {
            StringBuilder sb = new StringBuilder();
            foreach (IScriptApi api in compiler.ScriptEngine.GetAPIs())
                foreach (string nameSpace in api.NamespaceAdditions)
                    sb.AppendFormat("using {0};\n", nameSpace);
            sb.AppendLine(
            @"using LSL_Types = Aurora.ScriptEngine.DotNetEngine.LSL_Types;
            using System;
            namespace Script
            {
            [Serializable]
            public class ScriptClass : Aurora.ScriptEngine.DotNetEngine.Runtime.ScriptBaseClass
            {");

            sb.AppendLine(ScriptClass);
            sb.AppendLine(string.Join("\n", MethodsToAdd));

            sb.AppendLine("}}");

            return sb.ToString();
        }
 public static int GetHeaderCount(Compiler compiler)
 {
     int i = 0;
     foreach (IScriptApi api in compiler.ScriptEngine.GetAPIs())
         foreach (string nameSpace in api.NamespaceAdditions)
             i++;
     return 13 + i;
 }
        /// <summary>
        ///     Creates an 'empty' CSCodeGenerator instance.
        /// </summary>
        public CSCodeGenerator(Compiler compiler)
        {
            #region DTFunctions

            // api funtions that can return a time delay only
            // must be type DateTime in stub files and implementation
            DTFunctions.Add("llAddToLandBanList");
            DTFunctions.Add("llAddToLandPassList");
            DTFunctions.Add("llAdjustSoundVolume");
            DTFunctions.Add("llCloseRemoteDataChannel");
            DTFunctions.Add("llCreateLink");
            DTFunctions.Add("llDialog");
            DTFunctions.Add("llEjectFromLand");
            DTFunctions.Add("llEmail");
            DTFunctions.Add("llGiveInventory");
            DTFunctions.Add("llInstantMessage");
            DTFunctions.Add("llLoadURL");
            DTFunctions.Add("llMakeExplosion");
            DTFunctions.Add("llMakeFire");
            DTFunctions.Add("llMakeFountain");
            DTFunctions.Add("llMakeSmoke");
            DTFunctions.Add("llMapDestination");
            DTFunctions.Add("llOffsetTexture");
            DTFunctions.Add("llOpenRemoteDataChannel");
            DTFunctions.Add("llParcelMediaCommandList");
            DTFunctions.Add("llPreloadSound");
            DTFunctions.Add("llRefreshPrimURL");
            DTFunctions.Add("llRemoteDataReply");
            DTFunctions.Add("llRemoteLoadScript");
            DTFunctions.Add("llRemoteLoadScriptPin");
            DTFunctions.Add("llRemoveFromLandBanList");
            DTFunctions.Add("llRemoveFromLandPassList");
            DTFunctions.Add("llResetLandBanList");
            DTFunctions.Add("llResetLandPassList");
            DTFunctions.Add("llRezAtRoot");
            DTFunctions.Add("llRezObject");
            DTFunctions.Add("llRotateTexture");
            DTFunctions.Add("llScaleTexture");
            DTFunctions.Add("llSetLinkTexture");
            DTFunctions.Add("llSetLocalRot");
            DTFunctions.Add("llSetParcelMusicURL");
            DTFunctions.Add("llSetPos");
            DTFunctions.Add("llSetPrimURL");
            DTFunctions.Add("llSetRot");
            DTFunctions.Add("llSetTexture");
            DTFunctions.Add("llSleep");
            DTFunctions.Add("llTeleportAgentHome");
            DTFunctions.Add("llTextBox");
            DTFunctions.Add("osTeleportAgent");
            DTFunctions.Add("osTeleportOwner");

            /* suspended:  some API functions are not compatible with IEnum
                        // Api functions that can return a delay, a value or breakable in timeslices
                        // must be IEnumerator in stub, interface and implementation files

                        IenFunctions.Add("llRequestAgentData", "LSL_Types.LSLString");
                        IenFunctions.Add("llRequestInventoryData", "LSL_Types.LSLString");
                        IenFunctions.Add("llSendRemoteData", "LSL_Types.LSLString");
                        IenFunctions.Add("llXorBase64Strings", "LSL_Types.LSLString");
                        IenFunctions.Add("llRequestSimulatorData", "LSL_Types.LSLString");
                        IenFunctions.Add("llParcelMediaQuery", "LSL_Types.list");
                        IenFunctions.Add("llGetPrimMediaParams", "LSL_Types.list");
                        IenFunctions.Add("llSetPrimMediaParams", "LSL_Types.LSLInteger");
                        IenFunctions.Add("llClearPrimMedia", "LSL_Types.LSLInteger");
                        IenFunctions.Add("llModPow", "LSL_Types.LSLInteger");
                        IenFunctions.Add("llGetNumberOfNotecardLines", "LSL_Types.LSLString");
                        IenFunctions.Add("llGetParcelPrimOwners", "LSL_Types.list");
                        IenFunctions.Add("llGetNotecardLine", "LSL_Types.LSLString");
            */

            // the rest will be directly called

            #endregion

            ResetCounters();
            m_compiler = compiler;

            if(m_apiFunctions == null)
                m_apiFunctions = compiler.ScriptEngine.GetAllFunctionNamesAPIs();
        }