Пример #1
0
        public bool RunTest1()
        {
            //Test Compile

            string script = @"//lsl2
a() { llSay(0, ""a - success""); }
string b()
{
    vector a = <0,0,0>;
    float b = a.x ;
    return ""b - success"";
}
default { state_entry() { vector a = <0,0,0.04>; vector b; llSay(0, ""Script running.  ""); } 
    touch_start(integer number)
    { 
test:
// doing some testing.
        llSay(0, ""doing more testing //. "");
        /* testing. */
        llSay(0, ""testing some shit /*.*/"");
        for(number = 0; number < 10; number++)
        {
        }
        for(number = 0; number < 10; number++)
            llSay(0,""kill me!"");
        llSay(0,""Touched.""); 
        llMessageLinked(-1, 0, ""c"", ""d"");
goto test;
    }
    link_message(integer num, integer num2, string c, string d)
    {
        llSay(0, (string)num2 + "" "" + c + "" "" + d);
        a();
        llSay(0, b());
    }
}
state testing
{
    state_entry()
    {
        llSay(0, ""Script Start - Testing"");
    }
    touch_start(integer a)
    {
        llSay(0,""testing time..."");
        state default;
    }
}";

            m_compiler.ClearErrors();
            string compiledScript;
            object map;

            Convert(script, out compiledScript, out map);
            if (m_compiler.GetErrors().Length > 0)
            {
                return(false);
            }
            CompilerParameters parameters = new CompilerParameters {
                IncludeDebugInformation = true
            };


            string rootPath =
                System.IO.Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);

            if (rootPath != null)
            {
                parameters.ReferencedAssemblies.Add(System.IO.Path.Combine(rootPath,
                                                                           "Aurora.ScriptEngine.AuroraDotNetEngine.dll"));
            }
            parameters.ReferencedAssemblies.Add("System.dll");
            if (rootPath != null)
            {
                parameters.ReferencedAssemblies.Add(System.IO.Path.Combine(rootPath,
                                                                           "Aurora.Framework.dll"));
                parameters.ReferencedAssemblies.Add(System.IO.Path.Combine(rootPath,
                                                                           "OpenMetaverseTypes.dll"));
            }
            IScriptApi[] apis = m_compiler.ScriptEngine.GetAPIs();
            //Now we need to pull the files they will need to access from them
            foreach (IScriptApi api in apis)
            {
                parameters.ReferencedAssemblies.AddRange(api.ReferencedAssemblies);
            }
            CompilerResults results = Compile(parameters, false, compiledScript);

            if (results.Errors.Count > 0)
            {
                int LineN, CharN;
                FindErrorLine(results.Errors[0], map, script, out LineN, out CharN);
                return(false);
            }
            return(true);
        }