示例#1
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            options.IncludeDirectories.Add(testPath);

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new ProtoScriptTestRunner();

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.Execute(code, core);

            return(core);
        }
示例#2
0
 public override void Setup()
 {
     base.Setup();
     runnerConfig             = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new ProtoScript.Runners.DebugRunner(core);
 }
示例#3
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code)
        {


            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new ProtoScriptTestRunner();

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.Execute(code, core);

            return core;
        }
        internal static ProtoCore.Core DebugRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            vms = fsr.Run();

            return(core);
        }
示例#5
0
 public override void Setup()
 {
     base.Setup();
     runnerConfig = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new ProtoScript.Runners.DebugRunner(core);
 }
示例#6
0
        internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code,
                                                         Dictionary <int, List <string> > map, string geometryFactory,
                                                         string persistentManager, out ExecutionMirror mirror)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.WatchTestMode       = true;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            includePath = Path.GetDirectoryName(includePath);
            options.IncludeDirectories.Add(includePath);

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            core = new ProtoCore.Core(options);

            core.Configurations.Add(ConfigurationKeys.GeometryXmlProperties, true);
            //core.Configurations.Add(ConfigurationKeys.GeometryFactory, geometryFactory);
            //core.Configurations.Add(ConfigurationKeys.PersistentManager, persistentManager);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            //core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.BuildStatus.MessageHandler = fs;

            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run

            mirror = fsr.Execute(code, core);

            //sw.Close();

            return(core);
        }
示例#7
0
 public override void Setup()
 {
     base.Setup();
     runconfig             = new ProtoScript.Config.RunConfiguration();
     runconfig.IsParrallel = false;
     runner = new DebugRunner(core);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#8
0
 public override void Setup()
 {
     base.Setup();
     runconfig = new ProtoScript.Config.RunConfiguration();
     runconfig.IsParrallel = false;
     runner = new DebugRunner(core);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#9
0
 public override void Setup()
 {
     // Specify some of the requirements of IDE.
     runnerConfig = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new DebugRunner(core);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#10
0
 public override void Setup()
 {
     // Specify some of the requirements of IDE.
     runnerConfig             = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new DebugRunner(core);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#11
0
        internal void TestRunnerRunOnly(string includePath, string code, Dictionary <int, List <string> > map /*, string executionLogFilePath*/)
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.

            core.Options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            core.Options.SuppressBuildOutput = false;
            core.Options.WatchTestMode       = true;
            core.Options.GCTempVarsOnDebug   = false;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            core.Options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                core.Options.IncludeDirectories.Add(includePath);
            }

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.BuildStatus.MessageHandler   = fs;
            core.RuntimeStatus.MessageHandler = fs;

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run

            Mirror = fsr.Execute(code, core);

            //sw.Close();
            core.Cleanup();
        }
示例#12
0
 public void Setup()
 {
     // Specify some of the requirements of IDE.
     ProtoCore.Options options = new ProtoCore.Options();
     options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
     options.SuppressBuildOutput = false;
     core = new ProtoCore.Core(options);
     core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
     core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
     runnerConfig = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new ProtoScript.Runners.DebugRunner(core);
 }
示例#13
0
 public void Setup()
 {
     // Specify some of the requirements of IDE.
     ProtoCore.Options options = new ProtoCore.Options();
     options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
     options.SuppressBuildOutput = false;
     core = new ProtoCore.Core(options);
     core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
     core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
     runnerConfig             = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new ProtoScript.Runners.DebugRunner(core);
 }
示例#14
0
 public void Setup()
 {
     var options = new ProtoCore.Options();
     options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
     options.SuppressBuildOutput = false;
     core_ = new ProtoCore.Core(options);
     core_.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core_));
     core_.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core_));
     runconfig_ = new ProtoScript.Config.RunConfiguration();
     runconfig_.IsParrallel = false;
     runner_ = new DebugRunner(core_);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#15
0
 public void Setup()
 {
     // Specify some of the requirements of IDE.
     var options = new ProtoCore.Options();
     options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
     options.SuppressBuildOutput = false;
     core = new ProtoCore.Core(options);
     core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
     core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
     runnerConfig = new ProtoScript.Config.RunConfiguration();
     runnerConfig.IsParrallel = false;
     fsr = new DebugRunner(core);
     DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
     CLRModuleType.ClearTypes();
 }
示例#16
0
        public void Setup()
        {
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            core_ = new ProtoCore.Core(options);
            core_.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core_));
            core_.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core_));
            runconfig_             = new ProtoScript.Config.RunConfiguration();
            runconfig_.IsParrallel = false;
            runner_ = new DebugRunner(core_);
            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();
        }
示例#17
0
        public void Setup()
        {
            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);
            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();
        }
示例#18
0
        internal static ProtoCore.Core DebugRunnerStepOver(string code, out RuntimeCore runtimeCore)
        {
            //Internal setup

            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.GCTempVarsOnDebug   = false;

            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";

            options.IncludeDirectories.Add(testPath);

            core = new ProtoCore.Core(options);
            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));


            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.StepOver();
            }

            runtimeCore = fsr.runtimeCore;
            return(core);
        }
示例#19
0
        internal static ProtoCore.Core TestRunnerRunOnly(string includePath, string code,
            Dictionary<int, List<string>> map, string geometryFactory,
            string persistentManager, out ExecutionMirror mirror, out RuntimeCore runtimeCoreOut)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();


            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.WatchTestMode = true;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            includePath = Path.GetDirectoryName(includePath);
            options.IncludeDirectories.Add(includePath);

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            core = new ProtoCore.Core(options);

            core.Configurations.Add(ConfigurationKeys.GeometryXmlProperties, true);
            //core.Configurations.Add(ConfigurationKeys.GeometryFactory, geometryFactory);
            //core.Configurations.Add(ConfigurationKeys.PersistentManager, persistentManager);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            //core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.BuildStatus.MessageHandler = fs;

            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run

            mirror = fsr.Execute(code, core, out runtimeCoreOut);

            //sw.Close();

            return core;
        }
示例#20
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/ Dictionary <int, List <string> > map, bool watchNestedMode = false)
        {
            //Internal setup
            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.GCTempVarsOnDebug   = false;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }


            core = new ProtoCore.Core(options);

            // Use the InjectionExecutive to overload POP and POPM
            // as we still need the symbol names and line nos. in debug mode for comparisons
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            fsr.PreStart(code, runnerConfig);

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int    lineAtPrevBreak = -1;
            string symbolName      = null;

            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode    opCode = OpCode.NONE;
                DebugInfo debug  = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug  = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (core.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, ci);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            core.Cleanup();
        }
示例#21
0
        public bool DebugScript(string dsPath)
        {
            if (string.IsNullOrEmpty(GeometryFactoryName))
                throw new Exception("GeometryFactory not set!");

            if (string.IsNullOrEmpty(PersistenceManagerName))
                throw new Exception("PersistenceManager not set!");

            if (!File.Exists(dsPath))
                throw new FileNotFoundException(dsPath + " Does not exist");

            bool success = false;
            System.IO.StringWriter stringStream = new StringWriter();
            executionLog = new StringBuilder();
            ProtoCore.Core core = null;
            try
            {
                core = new ProtoCore.Core(new ProtoCore.Options());
                core.BuildStatus.SetStream(stringStream);
                core.Options.RootModulePathName = ProtoCore.Utils.FileUtils.GetFullPathName(dsPath);
                core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
                core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
                core.Configurations.Add(Autodesk.DesignScript.Interfaces.ConfigurationKeys.GeometryFactory, GeometryFactoryName);
                core.Configurations.Add(Autodesk.DesignScript.Interfaces.ConfigurationKeys.PersistentManager, PersistenceManagerName);
                ProtoScript.Runners.DebugRunner debugRunner = new ProtoScript.Runners.DebugRunner(core);
                ProtoScript.Config.RunConfiguration runnerConfig = new ProtoScript.Config.RunConfiguration();
                runnerConfig.IsParrallel = false; 
                ExecutionMirror mirror; 
                debugRunner.LoadAndPreStart(dsPath, runnerConfig);
                ProtoScript.Runners.DebugRunner.VMState currentVmState ;

               

                executionLog.AppendLine("Script executed successfully.");                

                executionLog.AppendLine();
                executionLog.AppendLine("=================================CoreDump=================================");
                string coreDump;
                bool step = true;

                while (step == true)
                {

                    try
                    {
                        currentVmState = debugRunner.StepOver(); // Perform one step.
                        mirror = currentVmState.mirror;
                        coreDump = null;
                        coreDump = mirror.GetCoreDump();
                        executionLog.AppendLine();
                        executionLog.AppendLine(coreDump);
                        success = true;
                        if (currentVmState.isEnded == true)
                            step = false;
                    }
                    catch (System.Exception ex)
                    {
                        executionLog.AppendLine(ex.Message);
                        executionLog.AppendLine(ex.StackTrace);

                        success = false;
                    }
                }

                executionLog.AppendLine("=================================CoreDump=================================");


            }
            catch (System.Exception ex)
            {
                success = false;
                executionLog.AppendLine("Fail to execute script.");
                executionLog.AppendLine("Exceptions:");
                executionLog.AppendLine(ex.Message);
                executionLog.AppendLine("StackTrace:");
                executionLog.AppendLine(ex.StackTrace);
            }
            finally
            {
                if (core != null)
                {
                    core.BuildStatus.SetStream(null);                    
                }
            }

            return success;
        }
示例#22
0
using System;
示例#23
0
        internal  static ProtoCore.Core DebugRunnerRunOnly(string code)
        {
            ProtoCore.Core core;
            DebugRunner fsr;
            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.GCTempVarsOnDebug = false;

            string testPath = @"..\..\..\test\Engine\ProtoTest\ImportFiles\";
            options.IncludeDirectories.Add(testPath);

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            vms = fsr.Run();

            return core;
        }
示例#24
0
        internal static ProtoCore.Core DebugRunnerStepOver(string code)
        {
            //Internal setup

            ProtoCore.Core core;
            DebugRunner fsr;
            ProtoScript.Config.RunConfiguration runnerConfig;
            string testPath = @"..\..\..\Scripts\Debugger\";

             // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            core = new ProtoCore.Core(options);
            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            CLRModuleType.ClearTypes();

            //Run

            fsr.PreStart(code, runnerConfig);
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
                vms = fsr.StepOver();

            return core;
        }
示例#25
0
        public bool DebugScript(string dsPath)
        {
            if (string.IsNullOrEmpty(GeometryFactoryName))
            {
                throw new Exception("GeometryFactory not set!");
            }

            if (string.IsNullOrEmpty(PersistenceManagerName))
            {
                throw new Exception("PersistenceManager not set!");
            }

            if (!File.Exists(dsPath))
            {
                throw new FileNotFoundException(dsPath + " Does not exist");
            }

            bool success = false;

            System.IO.StringWriter stringStream = new StringWriter();
            executionLog = new StringBuilder();
            ProtoCore.Core        core        = null;
            ProtoCore.RuntimeCore runtimeCore = null;
            try
            {
                core = new ProtoCore.Core(new ProtoCore.Options());
                core.BuildStatus.SetStream(stringStream);
                core.Options.RootModulePathName = ProtoCore.Utils.FileUtils.GetFullPathName(dsPath);
                core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
                core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));

                core.Configurations.Add(Autodesk.DesignScript.Interfaces.ConfigurationKeys.GeometryFactory, GeometryFactoryName);
                core.Configurations.Add(Autodesk.DesignScript.Interfaces.ConfigurationKeys.PersistentManager, PersistenceManagerName);

                ProtoScript.Runners.DebugRunner     debugRunner  = new ProtoScript.Runners.DebugRunner(core);
                ProtoScript.Config.RunConfiguration runnerConfig = new ProtoScript.Config.RunConfiguration();
                runnerConfig.IsParrallel = false;
                ExecutionMirror mirror;
                debugRunner.LoadAndPreStart(dsPath, runnerConfig);
                ProtoScript.Runners.DebugRunner.VMState currentVmState;



                executionLog.AppendLine("Script executed successfully.");

                executionLog.AppendLine();
                executionLog.AppendLine("=================================CoreDump=================================");
                string coreDump;
                bool   step = true;

                while (step == true)
                {
                    try
                    {
                        currentVmState = debugRunner.StepOver(); // Perform one step.
                        mirror         = currentVmState.mirror;
                        coreDump       = null;
                        coreDump       = mirror.GetCoreDump();
                        executionLog.AppendLine();
                        executionLog.AppendLine(coreDump);
                        success = true;
                        if (currentVmState.isEnded == true)
                        {
                            step = false;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        executionLog.AppendLine(ex.Message);
                        executionLog.AppendLine(ex.StackTrace);

                        success = false;
                    }
                }

                executionLog.AppendLine("=================================CoreDump=================================");
            }
            catch (System.Exception ex)
            {
                success = false;
                executionLog.AppendLine("Fail to execute script.");
                executionLog.AppendLine("Exceptions:");
                executionLog.AppendLine(ex.Message);
                executionLog.AppendLine("StackTrace:");
                executionLog.AppendLine(ex.StackTrace);
            }
            finally
            {
                if (core != null)
                {
                    core.BuildStatus.SetStream(null);
                }
            }

            return(success);
        }
示例#26
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/Dictionary<int, List<string>> map, bool watchNestedMode = false)
        {
            //Internal setup
            ProtoCore.Core core;
            DebugRunner fsr;
            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }

            core = new ProtoCore.Core(options);

            // Use the InjectionExecutive to overload POP and POPM
            // as we still need the symbol names and line nos. in debug mode for comparisons
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            fsr.PreStart(code, runnerConfig);

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int lineAtPrevBreak = -1;
            string symbolName = null;
            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode opCode = OpCode.NONE;
                DebugInfo debug = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (core.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, ci);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            core.Cleanup();
        }
示例#27
0
        internal void TestRunnerRunOnly(string includePath, string code, Dictionary<int, List<string>> map /*, string executionLogFilePath*/)
        {
            ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScriptTestRunner();

            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.

            core.Options.ExecutionMode = ProtoCore.ExecutionMode.Serial;
            core.Options.SuppressBuildOutput = false;
            core.Options.WatchTestMode = true;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            core.Options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                core.Options.IncludeDirectories.Add(includePath);
            }

            //StreamWriter sw = File.CreateText(executionLogFilePath);
            TextOutputStream fs = new TextOutputStream(map);

            // By specifying this option we inject a mock Executive ('InjectionExecutive')
            // that prints stackvalues at every assignment statement
            // by overriding the POP_handler instruction - pratapa
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            //core.BuildStatus.MessageHandler = fs;
            core.RuntimeStatus.MessageHandler = fs;

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            ProtoLanguage.CompileStateTracker compileState = null;
            Mirror = fsr.Execute(code, core, out compileState);

            //sw.Close();
            core.Cleanup();
        }