Beispiel #1
0
        public void T033_Defect_1467187_Update_In_class_collection_property_2()
        {
            String code =
                @"
class B
{    
    a1 : int;
    a2 : double[];
    constructor B (a:int, b : double[])    
    {        
        a1 = a;
        a2 = b;
    }
}
b1 = B.B ( 1, {1.0, 2.0} );
test1 = b1.a2[0];
b1.a2[0] = b1.a2[1];
";

            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("test1", 2.0);
        }
Beispiel #2
0
        static void Run(string filename, bool verbose)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine("Cannot find file " + filename);
                return;
            }

            var profilingThread = new Thread(new ThreadStart(CollectingMemory));
            profilingThread.Start();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
            core.Options.DumpByteCode = verbose;
            core.Options.Verbose = verbose;
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptRunner runner = new ProtoScriptRunner();
            runner.LoadAndExecute(filename, core);
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();

            done = true;
            profilingThread.Join();

            Console.WriteLine("{0},{1},{2}", ms, maxNetMemory, maxPrivateWorkingSet);
        }
Beispiel #3
0
        static void Run(string filename, bool verbose)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine("Cannot find file " + filename);
                return;
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
            core.Options.DumpByteCode = verbose;
            core.Options.Verbose = verbose;
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptRunner runner = new ProtoScriptRunner();

            runner.LoadAndExecute(filename, core);
            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
        }
        public void TestCompilerAndRuntimeComponent01()
        {

            String code =
@"
// Any DS code goes here
a = 10;
";
            // Compile core
            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
            ProtoScriptRunner runner = new ProtoScriptRunner();

            // Compile
            bool compileSucceeded = runner.CompileAndGenerateExe(code, core);
            Assert.IsTrue(compileSucceeded == true);

            // Execute
            RuntimeCore runtimeCore = runner.ExecuteVM(core);

            // Verify
            ExecutionMirror mirror = new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
Beispiel #5
0
        static void DevRun()
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();


            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));
#if DEBUG
            core.Options.DumpByteCode = true;
            core.Options.Verbose = true;
#else
            core.Options.DumpByteCode = false;
            core.Options.Verbose = false;
#endif
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());
            ProtoScriptRunner runner = new ProtoScriptRunner();

            // Assuming current directory in test/debug mode is "...\Dynamo\bin\AnyCPU\Debug"
            runner.LoadAndExecute(@"..\..\..\test\core\dsevaluation\DSFiles\test.ds", core);

            long ms = sw.ElapsedMilliseconds;
            sw.Stop();
            Console.WriteLine(ms);
            Console.ReadLine();
        }
Beispiel #6
0
        public void TestCompilerAndRuntimeComponent01()
        {

            String code =
@"
a = 10;
";
            // Compile core
            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
            ProtoScriptRunner runner = new ProtoScriptRunner();

            // Compiler instance
            ProtoCore.DSASM.Executable dsExecutable;
            bool compileSucceeded = runner.CompileMe(code, core, out dsExecutable);
            Assert.IsTrue(compileSucceeded == true);
            
            // Pass compile data to the runtime 
            RuntimeCore runtimeCore = new RuntimeCore(core.Heap);
            runtimeCore.SetProperties(core.Options, dsExecutable);

            // Runtime
            ExecutionMirror mirror = runner.ExecuteMe(runtimeCore);
            Obj o = mirror.GetValue("a");
Beispiel #7
0
        internal static ProtoCore.Core TestRunnerRunOnly(string code, out RuntimeCore runtimeCore)
        {
            ProtoCore.Core core;
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner();

            // 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.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));

            fsr = new ProtoScriptRunner();

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

            //Run

            fsr.Execute(code, core, out runtimeCore);

            return core;
        }
        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.ProtoScriptRunner fsr = new ProtoScriptRunner();

            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.Associative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(core));

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

            //Run

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

            //sw.Close();

            return core;
        }
        public void PreStart(String source, Dictionary <string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(RunnerCore));
            RunnerCore.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(RunnerCore));

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

            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            Runner = new ProtoScriptRunner();
        }
Beispiel #10
0
        public void PreStart(String source, Dictionary<string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


            RunnerCore = new ProtoCore.Core(options);
            RunnerCore.Compilers.Add(ProtoCore.Language.Associative, new ProtoAssociative.Compiler(RunnerCore));
            RunnerCore.Compilers.Add(ProtoCore.Language.Imperative, new ProtoImperative.Compiler(RunnerCore));

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

            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            Runner = new ProtoScriptRunner();
        }
        public void TestCompilerAndRuntimeComponent01()
        {

            String code =
@"
// DesignScript code here
a = 10;
";
            // Compile
            ProtoScriptRunner runner = new ProtoScriptRunner();
            bool compileSucceeded = runner.CompileAndGenerateExe(code, core, new ProtoCore.CompileTime.Context());
            Assert.IsTrue(compileSucceeded == true);
            
            // Execute
            runtimeCore = runner.ExecuteVM(core);

            // Verify
            ExecutionMirror mirror = new ExecutionMirror(runtimeCore.CurrentExecutive.CurrentDSASMExec, runtimeCore);
Beispiel #12
0
        public void T031_Defect_1467302()
        {
            String code =
                @"
def foo ( a : int[] ) 
{
    b = a;
    b[0] = b[1] + 1;
    return = b;
}
a = { 0, 1, 2};
e1 = foo(a);
a = { 1, 2};
";

            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String          errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            thisTest.Verify("e1", new Object[] { 3, 2 });
        }
Beispiel #13
0
        static void Run(string filename, bool verbose)
        {
            if (!File.Exists(filename))
            {
                Console.WriteLine("Cannot find file " + filename);
                return;
            }
            var opts = new Options();
            opts.ExecutionMode = ExecutionMode.Serial;
            ProtoCore.Core core = new Core(opts);
            core.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));
            core.Options.DumpByteCode = verbose;
            core.Options.Verbose = verbose;
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            ProtoScriptRunner runner = new ProtoScriptRunner();

            RuntimeCore runtimeCore = runner.LoadAndExecute(filename, core);
            ExecutionMirror mirror = runtimeCore.Mirror;
        }
Beispiel #14
0
        public ProtoVMState PreStart(String source, Dictionary<string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


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

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

            //Validity.Assert(null == ExecutionContext);
            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            //Validity.Assert(null == Runner);
            Runner = new ProtoScriptRunner();

            // TODO Jun: Implement run and halt at the first instruction
            //ProtoCore.DSASM.Mirror.ExecutionMirror mirror = null; // runner.Execute(executionContext, RunnerCore);

            return new ProtoVMState(RunnerCore, runtimeCore);
        }
Beispiel #15
0
        public ProtoVMState PreStart(String source, Dictionary <string, Object> context)
        {
            ProtoCore.Options options = new ProtoCore.Options();
            options.ExecutionMode = ProtoCore.ExecutionMode.Serial;


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

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

            //Validity.Assert(null == ExecutionContext);
            ExecutionContext = new ProtoCore.CompileTime.Context(source, context);

            //Validity.Assert(null == Runner);
            Runner = new ProtoScriptRunner();

            // TODO Jun: Implement run and halt at the first instruction
            //ProtoCore.DSASM.Mirror.ExecutionMirror mirror = null; // runner.Execute(executionContext, RunnerCore);

            return(new ProtoVMState(RunnerCore, runtimeCore));
        }
Beispiel #16
0
 public override void Setup()
 {
     base.Setup();
     coreRunner = new ProtoScript.Runners.ProtoScriptRunner();
 }
Beispiel #17
0
        internal void TestRunnerRunOnly(string includePath, string code, Dictionary<int, List<string>> map /*, string executionLogFilePath*/)
        {
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScriptRunner();

            // 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.Compilers.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Compiler(core));
            core.Compilers.Add(ProtoCore.Language.kImperative, new ProtoImperative.Compiler(core));

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());
            
            //Run
            RuntimeCore runtimeCore = fsr.Execute(code, core);
            Mirror = runtimeCore.Mirror;

            //sw.Close();
            runtimeCore.Cleanup();
        }
Beispiel #18
0
        public void T031_Defect_1467302_2()
        {
            String code =
@"
def foo ( a : int[] ) 
{
    b = a;
    b[0] = b[1] + 1;
    return = b;
}
i = 1..2;
a = { 0, 1, 2, 3};
e1 = foo(a[i]);
i = 0..2;
";
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("e1", new Object[] { 2, 1, 2 });
        }
Beispiel #19
0
        public void T032_Defect_1467335_Update_In_class_Constructor()
        {
            String code =
@"
class A
{
    b : int[] = { 0, 1, 2, 3 };
    
    def foo (i:int ) 
    {
        b[i] = b[i] + 1;
        return = b;
    }
}
i = 1..2;
e1 = A.A().foo(i);
i = 0..2;
";
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);

            //
            // SSA will transform 
            //      e1 = A.A().foo(i);
            //
            //      to
            //
            //      t0 = A.A()
            //      t1 = i
            //      t2 = t0.foo(t1)
            //
            // This means that the initial value of 'b' will be preserved as class A will not be re-initialed after the update
            //
            thisTest.Verify("e1", new Object[] { new Object[] { 1, 2, 3, 3 }, new Object[] { 1, 3, 3, 3 }, new Object[] { 1, 3, 4, 3 } });
        }
Beispiel #20
0
        public void T033_Defect_1467187_Update_In_class_collection_property()
        {
            String code =
@"
class Point
{
    X : double;
    
    constructor ByCoordinates( x : double )
    {
        X = x;
    
    } 
def foo ( y )
{
    [Imperative]
    {
        X = y + 1;
    }
    return = true;
}    
    
}
p1 = Point.ByCoordinates(1);
test = p1.X;
dummy = p1.foo(2);
//expected test to update to '3'
";
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test", 3.0);
        }
Beispiel #21
0
        public void T033_Defect_1467187_Update_In_class_collection_property_2()
        {
            String code =
@"
class B
{    
    a1 : int;
    a2 : double[];
    constructor B (a:int, b : double[])    
    {        
        a1 = a;
        a2 = b;
    }
}
b1 = B.B ( 1, {1.0, 2.0} );
test1 = b1.a2[0];
b1.a2[0] = b1.a2[1];
";
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String errmsg = "";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test1", 2.0);
        }
Beispiel #22
0
        public void T033_Defect_1467187_Update_In_class_collection_property_3()
        {
            // Tracked by: http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4021
            String code =
@"
class Point
{
    X : double[];
    
    constructor ByCoordinates( x : double[] )
    {
        X = x;
    
    } 
    def foo ( y :double[])
    {
        X = y + 1;
        [Imperative]
        {
           count = 0;
           for (i in y)
           {
               X[count] = y[count] + X[count];
               count = count + 1;
           }
        }
        return = true;
    }    
    
}
p1 = Point.ByCoordinates({0,0,0,0});
test = p1.X;
dummy = p1.foo({1,1,1,1});
p1.X[0..1] = -1;
";
            ProtoScript.Runners.ProtoScriptRunner fsr = new ProtoScript.Runners.ProtoScriptRunner();
            String errmsg = "MAGN-4021 Update issue with collection property in nested imperative scope";
            ExecutionMirror mirror = thisTest.VerifyRunScriptSource(code, errmsg);
            thisTest.Verify("test", new Object[] { -1, -1, 2, 2 });
        }
Beispiel #23
0
        public LiveRunner(Configuration configuration)
        {
            this.configuration = configuration;

            runner = new ProtoScriptRunner();

            InitCore();

            taskQueue = new Queue<Task>();

            workerThread = new Thread(new ThreadStart(TaskExecMethod));
            workerThread.IsBackground = true;
            workerThread.Start();

            staticContext = new ProtoCore.CompileTime.Context();

            terminating = false;
            changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
            changeSetApplier = new ChangeSetApplier();
        }
Beispiel #24
0
 /// <summary>
 /// Re-initializes the LiveRunner to reset the VM 
 /// Used temporarily when importing libraries on-demand during delta execution
 /// Will be deprecated once this is supported by the core language
 /// </summary>
 public void ReInitializeLiveRunner()
 {
     runner = new ProtoScriptRunner();
     deltaSymbols = 0;
     InitCore();
     staticContext = new ProtoCore.CompileTime.Context();
     changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
     CLRModuleType.ClearTypes();
 }
Beispiel #25
0
        public LiveRunner(Configuration configuration)
        {
            this.configuration = configuration;

            runner = new ProtoScriptRunner();

            InitCore();

            staticContext = new ProtoCore.CompileTime.Context();

            changeSetComputer = new ChangeSetComputer(runnerCore, runtimeCore);
            changeSetApplier = new ChangeSetApplier();
        }