Пример #1
0
        private static FLScriptData LoadScriptData(string file, CLBufferInfo inBuffer, int width, int height, int depth, int channelCount,
                                                   KernelDatabase db, Dictionary <string, FLFunctionInfo> funcs)
        {
            Logger.Log("Loading Script Data for File: " + file, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 6);

            FLScriptData ret = new FLScriptData(LoadSource(file, channelCount));


            ret.Defines.Add(InputBufferName, inBuffer);

            Logger.Log("Parsing Texture Defines for File: " + file, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 5);
            ParseDefines(DefineKey, DefineTexture, ret.Source, ret.Defines, width, height, depth, channelCount, db);

            Logger.Log("Parsing Script Defines for File: " + file, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 5);
            ParseDefines(ScriptDefineKey, DefineScript, ret.Source, ret.Defines, width, height, depth, channelCount, db);

            Logger.Log("Parsing JumpLocations for File: " + file, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 5);
            ret.JumpLocations = ParseJumpLocations(ret.Source);

            Logger.Log("Parsing Instruction Data for File: " + file, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 5);
            foreach (string line in ret.Source)
            {
                Logger.Log("Parsing Instruction Data for Line: " + line, DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 3);
                FLInstructionData data = GetInstructionData(line, ret.Defines, ret.JumpLocations, funcs, db);

                Logger.Log("Parsed Instruction Data: " + Enum.GetName(typeof(FLInstructionType), data.InstructionType), DebugChannel.Log | DebugChannel.OpenFL | DebugChannel.IO, 2);

                ret.ParsedSource.Add(data);
            }


            return(ret);
        }
Пример #2
0
        /// <summary>
        /// Resets the FLInterpreter to work with a new script
        /// </summary>
        /// <param name="file">The file containing the source</param>
        /// <param name="input">The input buffer</param>
        /// <param name="width">Width of the input buffer</param>
        /// <param name="height">Height of the input buffer</param>
        /// <param name="depth">Depth of the input buffer</param>
        /// <param name="channelCount">The Channel Count</param>
        /// <param name="kernelDb">The Kernel DB that will be used</param>
        /// <param name="ignoreDebug">a flag to ignore the brk statement</param>
        public void Reset(string file, MemoryBuffer input, int width, int height, int depth, int channelCount,
                          KernelDatabase kernelDb, bool ignoreDebug)
        {
            //Clear old stuff

            ReleaseResources();

            //Setting variables
            currentBuffer = new CLBufferInfo(input, false);
            currentBuffer.SetKey(INPUT_BUFFER_NAME);

            this.ignoreDebug  = ignoreDebug;
            this.width        = width;
            this.height       = height;
            this.depth        = depth;
            this.channelCount = channelCount;
            this.kernelDb     = kernelDb;
            activeChannels    = new byte[this.channelCount];
            currentArgStack   = new Stack <object>();
            for (int i = 0; i < this.channelCount; i++)
            {
                activeChannels[i] = 1;
            }

            activeChannelBuffer =
                CLAPI.CreateBuffer(instance, activeChannels, MemoryFlag.ReadOnly | MemoryFlag.CopyHostPointer);

            //Parsing File
            currentBuffer.SetKey(INPUT_BUFFER_NAME);
            data = LoadScriptData(instance, file, currentBuffer, width, height, depth, channelCount, kernelDb,
                                  flFunctions);

            Reset();
        }
Пример #3
0
        /// <summary>
        /// Resets the Interpreter to work with a new script
        /// </summary>
        /// <param name="file">The file containing the source</param>
        /// <param name="input">The input buffer</param>
        /// <param name="width">Width of the input buffer</param>
        /// <param name="height">Height of the input buffer</param>
        /// <param name="depth">Depth of the input buffer</param>
        /// <param name="channelCount">The Channel Count</param>
        /// <param name="kernelDB">The Kernel DB that will be used</param>
        /// <param name="ignoreDebug">a flag to ignore the brk statement</param>
        public void Reset(string file, MemoryBuffer input, int width, int height, int depth, int channelCount,
                          KernelDatabase kernelDB, bool ignoreDebug)
        {
            //Clear old stuff

            ReleaseResources();

            //Setting variables
            _currentBuffer = new CLBufferInfo(input, false);
            _currentBuffer.SetKey(InputBufferName);

            _ignoreDebug     = ignoreDebug;
            _width           = width;
            _height          = height;
            _depth           = depth;
            _channelCount    = channelCount;
            _kernelDb        = kernelDB;
            _activeChannels  = new byte[_channelCount];
            _currentArgStack = new Stack <object>();
            for (int i = 0; i < _channelCount; i++)
            {
                _activeChannels[i] = 1;
            }

            _activeChannelBuffer =
                CLAPI.CreateBuffer(_activeChannels, MemoryFlag.ReadOnly | MemoryFlag.CopyHostPointer);

            //Parsing File
            _currentBuffer.SetKey(InputBufferName);
            Data = LoadScriptData(file, _currentBuffer, width, height, depth, channelCount, _kernelDb, _flFunctions);

            Reset();
        }
Пример #4
0
        private FLScriptData LoadScriptData(CLAPI instance, string file, CLBufferInfo inBuffer, int width,
                                            int height, int depth,
                                            int channelCount,
                                            KernelDatabase db, Dictionary <string, FLInterpreterFunctionInfo> funcs)
        {
            Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level6,
                       "Loading Script Data for File: " + file);

            FLScriptData ret = new FLScriptData(LoadSource(file, channelCount));


            ret.Defines.Add(INPUT_BUFFER_NAME, inBuffer);

            Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level5,
                       "Parsing Texture Defines for File: " + file);
            ParseDefines(instance, DEFINE_KEY, DefineTexture, ret.Source, ret.Defines, width, height, depth,
                         channelCount, db);

            Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level5,
                       "Parsing Script Defines for File: " + file);
            ParseDefines(instance, SCRIPT_DEFINE_KEY, DefineScript, ret.Source, ret.Defines, width, height, depth,
                         channelCount,
                         db);

            Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level5,
                       "Parsing JumpLocations for File: " + file);
            ret.JumpLocations = ParseJumpLocations(ret.Source);

            Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level5,
                       "Parsing Instruction Data for File: " + file);
            foreach (string line in ret.Source)
            {
                Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level3,
                           "Parsing Instruction Data for Line: " + line);
                FLInstructionData data = GetInstructionData(line, ret.Defines, ret.JumpLocations, funcs, db);

                Logger.Log(DebugChannel.Log | DebugChannel.OpenFL, Verbosity.Level3,
                           "Parsed Instruction Data: " + Enum.GetName(typeof(FLInstructionType), data.InstructionType));

                ret.ParsedSource.Add(data);
            }


            return(ret);
        }