예제 #1
0
        private ExecutionMirror Execute(string code, ProtoCore.Core core, bool isTest = true)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(code, core, out blockId);

            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushFrameForGlobals(core.GlobOffset);
                core.RunningBlock = blockId;
                Execute(core);

                if (!isTest) { core.Heap.Free(); }


                if (isTest && !core.Options.CompileToLib)
                    return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
                else
                    return null;
            }
            //else
            //  throw new ProtoCore.Exceptions.CompileErrorsOccured();

            //if (isTest && !core.Options.CompileToLib)
            //    return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            //else
            return null;
        }
예제 #2
0
 public void Execute(string code, ProtoCore.Core core)
 {
     int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
     bool succeeded = Compile(code, core, out blockId);
     if (succeeded)
     {
         core.GenerateExecutable();
         core.Rmem.PushFrame(core.GlobOffset);
         core.RunningBlock = blockId;
         Execute(core);
         core.Heap.Free();
     }
     else
         throw new ProtoCore.Exceptions.CompileErrorsOccured();
 }
예제 #3
0
 /// <summary>
 /// The public method to compile DS AST and stores the executable in core
 /// </summary>
 /// <param name="astList"></param>
 /// <param name="compileCore"></param>
 /// <returns></returns>
 public bool CompileAndGenerateExe(
     List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList, 
     ProtoCore.Core compileCore,
     ProtoCore.CompileTime.Context context)
 {
     bool succeeded = Compile(astList, compileCore, context);
     if (succeeded)
     {
         compileCore.GenerateExecutable();
     }
     return succeeded;
 }
예제 #4
0
 /// <summary>
 /// The public method to compile DS code and stores the executable in core
 /// </summary>
 /// <param name="sourcecode"></param>
 /// <param name="compileCore"></param>
 /// <returns></returns>
 public bool CompileAndGenerateExe(string sourcecode, ProtoCore.Core compileCore, ProtoCore.CompileTime.Context context)
 {
     bool succeeded = Compile(sourcecode, compileCore, context);
     if (succeeded)
     {
         compileCore.GenerateExecutable();
     }
     return succeeded;
 }
예제 #5
0
        public ExecutionMirror Execute(string code, ProtoCore.Core core, bool isTest = true)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(code, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushGlobFrame(core.GlobOffset);
                core.RunningBlock = blockId;

                try
                {
                    Execute(core, new ProtoCore.Runtime.Context());
                }
                catch (ProtoCore.Exceptions.ExecutionCancelledException e)
                {
                    Console.WriteLine("The execution has been cancelled!");             
                }
                
                if (!isTest)
                {
                    core.Heap.Free();
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            }

            return null;
        }
예제 #6
0
        public ExecutionMirror Execute(List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList, ProtoCore.Core core, bool isTest = true)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(astList, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushGlobFrame(core.GlobOffset);
                core.RunningBlock = blockId;

                Execute(core, new ProtoCore.Runtime.Context());
                if (!isTest) 
                { 
                    core.Heap.Free(); 
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            }

            return null;
        }
예제 #7
0
        public ExecutionMirror Execute(ProtoCore.CompileTime.Context staticContext, ProtoCore.Runtime.Context runtimeContext, ProtoCore.Core core, bool isTest = true)
        {
            Validity.Assert(null != staticContext.SourceCode && String.Empty != staticContext.SourceCode);
            
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(staticContext, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushGlobFrame(core.GlobOffset);
                core.RunningBlock = blockId;
                core.InitializeContextGlobals(staticContext.GlobalVarList);

                Validity.Assert(null != runtimeContext);
                Execute(core, runtimeContext);
                if (!isTest)
                {
                    core.Heap.Free();
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            }

            return null;
        }
예제 #8
0
        public ExecutionMirror Execute(string code, ProtoCore.Core core, Dictionary<string, Object> values, bool isTest = true)
        {
            //Inject the context data values from external source.
            core.AddContextData(values);
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(code, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushGlobFrame(core.GlobOffset);
                core.RunningBlock = blockId;

                Execute(core, new ProtoCore.Runtime.Context());

                if (!isTest) { core.Heap.Free(); }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            }

            return null;
        }
예제 #9
0
        /// <summary>
        /// The public method to compile DS code
        /// </summary>
        /// <param name="sourcecode"></param>
        /// <param name="compileCore"></param>
        /// <param name="dsExecutable"></param>
        /// <returns></returns>
        public bool CompileMe(string sourcecode, ProtoCore.Core compileCore, out Executable dsExecutable)
        {
            int blockID = 0;
            bool succeeded = Compile(sourcecode, compileCore, out blockID);

            compileCore.GenerateExecutable();
            dsExecutable = compileCore.DSExecutable;

            return succeeded;
        }
예제 #10
0
        /// <summary>
        /// Compile and execute the given sourcecode
        /// </summary>
        /// <param name="code"></param>
        /// <param name="core"></param>
        /// <param name="isTest"></param>
        /// <returns></returns>
        public ExecutionMirror Execute(string sourcecode, ProtoCore.Core core, out ProtoCore.RuntimeCore runtimeCoreOut, bool isTest = true)
        {
            ProtoCore.RuntimeCore runtimeCore = null;
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(sourcecode, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                try
                {
                    runtimeCore = Execute(core, blockId, new ProtoCore.CompileTime.Context());
                }
                catch (ProtoCore.Exceptions.ExecutionCancelledException e)
                {
                    Console.WriteLine("The execution has been cancelled!");             
                }
                
                if (!isTest)
                {
                    runtimeCore.RuntimeMemory.Heap.Free();
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            runtimeCoreOut = runtimeCore;

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
            }

            return null;
        }
예제 #11
0
        /// <summary>
        /// Compile and execute the given list of ASTs
        /// </summary>
        /// <param name="astList"></param>
        /// <param name="core"></param>
        /// <param name="isTest"></param>
        /// <returns></returns>
        public ExecutionMirror Execute(List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList, ProtoCore.Core core, bool isTest = true)
        {
            ProtoCore.RuntimeCore runtimeCore = null;
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(astList, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                runtimeCore = Execute(core, blockId, new ProtoCore.CompileTime.Context());
                if (!isTest) 
                {
                    runtimeCore.RuntimeMemory.Heap.Free(); 
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
            }

            return null;
        }
예제 #12
0
        /// <summary>
        /// Compile and execute the source that is stored in the static context
        /// </summary>
        /// <param name="staticContext"></param>
        /// <param name="runtimeContext"></param>
        /// <param name="core"></param>
        /// <param name="isTest"></param>
        /// <returns></returns>
        public ExecutionMirror Execute(
            ProtoCore.CompileTime.Context staticContext, 
            ProtoCore.Core core, 
            out ProtoCore.RuntimeCore runtimeCoreOut, 
            bool isTest = true)
        {
            Validity.Assert(null != staticContext.SourceCode && String.Empty != staticContext.SourceCode);
            ProtoCore.RuntimeCore runtimeCore = null;

            core.AddContextData(staticContext.GlobalVarList);
   
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(staticContext, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                runtimeCore = Execute(core, blockId, staticContext);
                if (!isTest)
                {
                    runtimeCore.RuntimeMemory.Heap.Free();
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }
            runtimeCoreOut = runtimeCore;

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
            }

            return null;
        }
예제 #13
0
        public ExecutionMirror Execute(string code, ProtoCore.Core core, bool isTest = true)
        {
            int blockId = ProtoCore.DSASM.Constants.kInvalidIndex;
            bool succeeded = Compile(code, core, out blockId);
            if (succeeded)
            {
                core.GenerateExecutable();
                core.Rmem.PushGlobFrame(core.GlobOffset);
                core.RunningBlock = blockId;

                Execute(core, new ProtoCore.Runtime.Context());
                if (!isTest)
                {
                    core.Heap.Free();
                }
            }
            else
            {
                throw new ProtoCore.Exceptions.CompileErrorsOccured();
            }

            if (isTest && !core.Options.CompileToLib)
            {
                return new ExecutionMirror(core.CurrentExecutive.CurrentDSASMExec, core);
            }

            // Save the Callsite state for this execution
            if (core.EnableCallsiteExecutionState)
            {
                ProtoCore.CallsiteExecutionState.SaveState(core.csExecutionState);
            }

            return null;
        }