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();
 }
 /// <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;
 }
 /// <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;
        }
        /// <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;
        }