Ejemplo n.º 1
0
        public static ScriptingAssembly Decompile(byte[] scriptNodeData, ScriptEngineDefinition engineDefinition, string[] tagList, ScenarioBase scnr)
        {
            s_nodeDataReader = new BinaryReader(new MemoryStream(scriptNodeData, 56, scriptNodeData.Length - 56, false));
            s_globals        = new List <NodeBase>();
            s_scripts        = new List <NodeBase>();

            s_engineDefinition = engineDefinition;
            s_tagList          = tagList;
            s_scnr             = scnr;

            ScenarioScriptGlobal[] scnrGlobals = s_scnr.GetScriptGlobals();
            ScenarioScript[]       scnrScripts = s_scnr.GetScripts();

            foreach (ScenarioScriptGlobal g in scnrGlobals)
            {
                CompiledScriptNode cnode = new CompiledScriptNode(g.InitialisationExpressionIndex, s_nodeDataReader);
                s_globals.Add(new VariableNode(g.Name, g.Type, DecompileNode(cnode)));
            }

            foreach (ScenarioScript s in scnrScripts)
            {
                CompiledScriptNode cnode = new CompiledScriptNode(s.RootExpressionIndex, s_nodeDataReader);
                s_scripts.Add(new ScriptNode(s.Name, (ScriptType)s.ScriptType, s.ReturnType, DecompileNode(cnode).Children));
            }

            ScriptingAssembly assembly = new ScriptingAssembly(s_engineDefinition, s_globals, s_scripts);

            s_nodeDataReader   = null;
            s_globals          = null;
            s_scripts          = null;
            s_engineDefinition = null;
            s_tagList          = null;
            s_scnr             = null;

            return(assembly);
        }