diff --git a/.gitignore b/.gitignore index 4de66ab2818..849dd5651d5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ runtimeGeneratedExtension/ obj/ int/ packages/ +bin/ #find -type d -name bin -exec git rm -r {} \; diff --git a/src/Engine/ProtoCore/Core.cs b/src/Engine/ProtoCore/Core.cs index f1bb24fb177..cf561fed00d 100644 --- a/src/Engine/ProtoCore/Core.cs +++ b/src/Engine/ProtoCore/Core.cs @@ -180,6 +180,8 @@ public void AddDLLExtensionAppType(System.Type type) /// public bool IsParsingCodeBlockNode { get; set; } + internal bool IsParsingInTestMode { get; set; } + // This is the AST node list of default imported libraries needed for Graph Compiler public CodeBlockNode ImportNodes { get; set; } @@ -424,7 +426,42 @@ public void ResetForPrecompilation() ForLoopBlockIndex = Constants.kInvalidIndex; } - private void ResetAll(Options options) + // The unique subscript for SSA temporaries + // TODO Jun: Organize these variables in core into proper enums/classes/struct + public int SSASubscript { get; set; } + public Guid SSASubscript_GUID { get; set; } + public int SSAExprUID { get; set; } + public int SSAExpressionUID { get; set; } + + /// + /// ExpressionUID is used as the unique id to identify an expression + /// It is incremented by 1 after mapping its current value to an expression + /// + public int ExpressionUID { get; set; } + + private int tempVarId = 0; + private int tempLanguageId = 0; + + + // TODO Jun: Cleansify me - i dont need to be here + public AssociativeNode AssocNode { get; set; } + public int watchStartPC { get; set; } + + + // + // TODO Jun: This is the expression interpreters executable. + // It must be moved to its own core, whre each core is an instance of a compiler+interpreter + // + public Executable ExprInterpreterExe { get; set; } + public int watchFunctionScope { get; set; } + public int watchBaseOffset { get; set; } + public List watchSymbolList { get; set; } + + public CodeGen assocCodegen { get; set; } + + public TextWriter ExecutionLog { get; set; } + + public Core(Options options) { Heap = new Heap(); //Rmem = new RuntimeMemory(Heap); @@ -432,11 +469,11 @@ private void ResetAll(Options options) DllTypesToLoad = new List(); Options = options; - + Compilers = new Dictionary(); ClassIndex = Constants.kInvalidIndex; - FunctionTable = new FunctionTable(); + FunctionTable = new FunctionTable(); watchFunctionScope = Constants.kInvalidIndex; @@ -498,7 +535,7 @@ private void ResetAll(Options options) ParsingMode = ParseMode.Normal; - + IsParsingPreloadedAssembly = false; IsParsingCodeBlockNode = false; ImportHandler = null; @@ -515,46 +552,6 @@ private void ResetAll(Options options) newEntryPoint = Constants.kInvalidIndex; } - // The unique subscript for SSA temporaries - // TODO Jun: Organize these variables in core into proper enums/classes/struct - public int SSASubscript { get; set; } - public Guid SSASubscript_GUID { get; set; } - public int SSAExprUID { get; set; } - public int SSAExpressionUID { get; set; } - - /// - /// ExpressionUID is used as the unique id to identify an expression - /// It is incremented by 1 after mapping its current value to an expression - /// - public int ExpressionUID { get; set; } - - private int tempVarId = 0; - private int tempLanguageId = 0; - - - // TODO Jun: Cleansify me - i dont need to be here - public AssociativeNode AssocNode { get; set; } - public int watchStartPC { get; set; } - - - // - // TODO Jun: This is the expression interpreters executable. - // It must be moved to its own core, whre each core is an instance of a compiler+interpreter - // - public Executable ExprInterpreterExe { get; set; } - public int watchFunctionScope { get; set; } - public int watchBaseOffset { get; set; } - public List watchSymbolList { get; set; } - - public CodeGen assocCodegen { get; set; } - - public TextWriter ExecutionLog { get; set; } - - public Core(Options options) - { - ResetAll(options); - } - public SymbolNode GetFirstVisibleSymbol(string name, int classscope, int function, CodeBlock codeblock) { Validity.Assert(null != codeblock); diff --git a/src/Engine/ProtoCore/Parser/Parser.cs b/src/Engine/ProtoCore/Parser/Parser.cs index 7395d831a28..b9dd25d76a4 100644 --- a/src/Engine/ProtoCore/Parser/Parser.cs +++ b/src/Engine/ProtoCore/Parser/Parser.cs @@ -2,18 +2,18 @@ //#define ENABLE_INC_DEC_FIX using System; using System.Collections.Generic; +using System.IO; using ProtoCore.AST; using ProtoCore.AST.AssociativeAST; using ProtoCore.DSASM; -using ProtoCore.Properties; using ProtoCore.Utils; +using ProtoCore.Properties; -namespace ProtoCore.DesignScriptParser -{ +namespace ProtoCore.DesignScriptParser { - public class Parser { +public class Parser { public const int _EOF = 0; public const int _ident = 1; public const int _number = 2; @@ -791,7 +791,7 @@ bool WeakSeparator(int n, int syFol, int repFol) { void DesignScriptParser() { Node node = null; Hydrogen(out node); - if (!core.IsParsingPreloadedAssembly && !core.IsParsingCodeBlockNode && !builtinMethodsLoaded) + if (!core.IsParsingPreloadedAssembly && !core.IsParsingCodeBlockNode && !builtinMethodsLoaded && !core.IsParsingInTestMode) { CoreUtils.InsertPredefinedAndBuiltinMethods(core, node as CodeBlockNode); root = node; @@ -890,6 +890,11 @@ void Hydrogen(out Node codeBlockNode) { } void Import_Statement(out ProtoCore.AST.AssociativeAST.AssociativeNode node) { + if (core.IsParsingCodeBlockNode) + { + core.BuildStatus.LogSemanticError(Resources.ImportStatementNotSupported); + } + while (!(la.kind == 0 || la.kind == 34)) {SynErr(66); Get();} string moduleName = "", typeName = "", alias = ""; diff --git a/src/Engine/ProtoCore/Parser/Scanner.cs b/src/Engine/ProtoCore/Parser/Scanner.cs index 3aac2502d13..2c110b59ac0 100644 --- a/src/Engine/ProtoCore/Parser/Scanner.cs +++ b/src/Engine/ProtoCore/Parser/Scanner.cs @@ -1,12 +1,11 @@ using System; -using System.Collections; using System.IO; +using System.Collections; -namespace ProtoCore.DesignScriptParser -{ +namespace ProtoCore.DesignScriptParser { - public class Token { +public class Token { public int kind; // token kind public int pos; // token position in bytes in the source text (starting at 0) public int charPos; // token position in characters in the source text (starting at 0) diff --git a/src/Engine/ProtoCore/Parser/atg/Associative.atg b/src/Engine/ProtoCore/Parser/atg/Associative.atg index fd28675b85d..5a60cd19e60 100644 --- a/src/Engine/ProtoCore/Parser/atg/Associative.atg +++ b/src/Engine/ProtoCore/Parser/atg/Associative.atg @@ -102,7 +102,13 @@ Hydrogen . Import_Statement -= SYNC += (. + if (core.IsParsingCodeBlockNode) + { + core.BuildStatus.LogSemanticError(Resources.ImportStatementNotSupported); + } + .) + SYNC (. string moduleName = "", typeName = "", alias = ""; .) @@ -2028,9 +2034,6 @@ Associative_IdentifierList (. - if (!core.IsParsingPreloadedAssembly && !core.IsParsingCodeBlockNode && !builtinMethodsLoaded) + if (!core.IsParsingPreloadedAssembly && !core.IsParsingCodeBlockNode && !builtinMethodsLoaded && !core.IsParsingInTestMode) { CoreUtils.InsertPredefinedAndBuiltinMethods(core, node as CodeBlockNode); root = node; diff --git a/src/Engine/ProtoCore/Properties/AssemblyInfo.cs b/src/Engine/ProtoCore/Properties/AssemblyInfo.cs index d5a5a65c5e0..2c03d467ca7 100644 --- a/src/Engine/ProtoCore/Properties/AssemblyInfo.cs +++ b/src/Engine/ProtoCore/Properties/AssemblyInfo.cs @@ -19,4 +19,5 @@ [assembly: InternalsVisibleTo("ProtoScript")] [assembly: InternalsVisibleTo("NodeDocumentationMarkdownGenerator")] [assembly: InternalsVisibleTo("ProtoAssociative")] +[assembly: InternalsVisibleTo("IntegrationTests")] diff --git a/src/Engine/ProtoCore/Utils/CompilerUtils.cs b/src/Engine/ProtoCore/Utils/CompilerUtils.cs index 7ab4e22195e..060a38b8fda 100644 --- a/src/Engine/ProtoCore/Utils/CompilerUtils.cs +++ b/src/Engine/ProtoCore/Utils/CompilerUtils.cs @@ -314,7 +314,7 @@ private static bool CompileCodeBlockAST(Core core, ParseParam parseParams, IDict bool parsingPreloadFlag = core.IsParsingPreloadedAssembly; - bool parsingCbnFlag = core.IsParsingPreloadedAssembly; + bool parsingCbnFlag = core.IsParsingCodeBlockNode; core.IsParsingPreloadedAssembly = false; core.IsParsingCodeBlockNode = true; @@ -383,7 +383,7 @@ private static void ParseUserCode(ProtoCore.Core core, string expression, string } catch { - // For class declarations, import statements etc. that are currently ignored + // For class declarations etc. that are currently ignored } } @@ -415,11 +415,7 @@ private static void ParseUserCodeCore(Core core, string expression, out List assembly.GetName().Name.Equals(assemblyName, StringComparison.OrdinalIgnoreCase)); + + Assert.False(ffiTargetAsm); + } + [Test] public void TypedIdentifier_AssignedToDifferentType_ThrowsWarning2() { diff --git a/test/Engine/ProtoTest/Associative/MicroFeatureTests.cs b/test/Engine/ProtoTest/Associative/MicroFeatureTests.cs index 58771da87a4..a95a5a080ae 100644 --- a/test/Engine/ProtoTest/Associative/MicroFeatureTests.cs +++ b/test/Engine/ProtoTest/Associative/MicroFeatureTests.cs @@ -2840,8 +2840,8 @@ public void Test_Compare_Node_01() string s1 = "a = 1;"; string s2 = "a=(1);"; - ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.Parse(s1); - ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.Parse(s2); + ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s1, TestFrameWork.TestParserCore()).CodeBlockNode; + ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s2, TestFrameWork.TestParserCore()).CodeBlockNode; bool areEqual = s1Root.Equals(s2Root); Assert.AreEqual(areEqual, true); } @@ -2851,8 +2851,8 @@ public void Test_Compare_Node_02() { string s1 = "a = 1; b=2;"; string s2 = "a=(1) ; b = (2);"; - ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.Parse(s1); - ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.Parse(s2); + ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s1, TestFrameWork.TestParserCore()).CodeBlockNode; + ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s2, TestFrameWork.TestParserCore()).CodeBlockNode; bool areEqual = s1Root.Equals(s2Root); Assert.AreEqual(areEqual, true); } @@ -2862,8 +2862,8 @@ public void Test_Compare_Node_03() { string s1 = "a = 1; c = a+1;"; string s2 = "a = 1; c=a + 1;"; - ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.Parse(s1); - ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.Parse(s2); + ProtoCore.AST.Node s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s1, TestFrameWork.TestParserCore()).CodeBlockNode; + ProtoCore.AST.Node s2Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s2, TestFrameWork.TestParserCore()).CodeBlockNode; bool areEqual = s1Root.Equals(s2Root); Assert.AreEqual(areEqual, true); } @@ -2876,13 +2876,13 @@ public void ParseTypedIdentifier_AstNode() string s3 = "a : A.B.C;"; string s4 = "a : A.B.C = null;"; - var s1Root = ProtoCore.Utils.ParserUtils.Parse(s1); + var s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s1, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(s1Root); var typedNode = s1Root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A", typedNode.datatype.Name); - s1Root = ProtoCore.Utils.ParserUtils.Parse(s2); + s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s2, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(s1Root); var ben = s1Root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); @@ -2890,13 +2890,13 @@ public void ParseTypedIdentifier_AstNode() Assert.IsNotNull(typedNode); Assert.AreEqual("A", typedNode.datatype.Name); - s1Root = ProtoCore.Utils.ParserUtils.Parse(s3); + s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s3, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(s1Root); typedNode = s1Root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A.B.C", typedNode.datatype.Name); - s1Root = ProtoCore.Utils.ParserUtils.Parse(s4); + s1Root = ProtoCore.Utils.ParserUtils.ParseWithCore(s4, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(s1Root); ben = s1Root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); @@ -2918,14 +2918,14 @@ public void ParseTypedIdentifierWithRank_AstNode() string s7 = "a : A.B.C[][];"; string s8 = "a : A.B.C[][] = null;"; - var root = ProtoCore.Utils.ParserUtils.Parse(s1); + var root = ProtoCore.Utils.ParserUtils.ParseWithCore(s1, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); var typedNode = root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A", typedNode.datatype.Name); Assert.AreEqual(1, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s2); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s2, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); var ben = root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); @@ -2934,14 +2934,14 @@ public void ParseTypedIdentifierWithRank_AstNode() Assert.AreEqual("A", typedNode.datatype.Name); Assert.AreEqual(1, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s3); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s3, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); typedNode = root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A.B.C", typedNode.datatype.Name); Assert.AreEqual(1, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s4); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s4, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); ben = root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); @@ -2950,14 +2950,14 @@ public void ParseTypedIdentifierWithRank_AstNode() Assert.AreEqual("A.B.C", typedNode.datatype.Name); Assert.AreEqual(1, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s5); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s5, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); typedNode = root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A", typedNode.datatype.Name); Assert.AreEqual(2, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s6); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s6, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); ben = root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); @@ -2966,14 +2966,14 @@ public void ParseTypedIdentifierWithRank_AstNode() Assert.AreEqual("A", typedNode.datatype.Name); Assert.AreEqual(2, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s7); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s7, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); typedNode = root.Body[0] as TypedIdentifierNode; Assert.IsNotNull(typedNode); Assert.AreEqual("A.B.C", typedNode.datatype.Name); Assert.AreEqual(2, typedNode.datatype.rank); - root = ProtoCore.Utils.ParserUtils.Parse(s8); + root = ProtoCore.Utils.ParserUtils.ParseWithCore(s8, TestFrameWork.TestParserCore()).CodeBlockNode; Assert.IsNotNull(root); ben = root.Body[0] as BinaryExpressionNode; Assert.IsNotNull(ben); diff --git a/test/Engine/ProtoTest/FFITests/CSFFIDispose.cs b/test/Engine/ProtoTest/FFITests/CSFFIDispose.cs index 3721f8039eb..9c19b8dfb9e 100644 --- a/test/Engine/ProtoTest/FFITests/CSFFIDispose.cs +++ b/test/Engine/ProtoTest/FFITests/CSFFIDispose.cs @@ -2907,14 +2907,6 @@ public void DisposeEnumWrapper() thisTest.Verify("x", Days.Monday); } - //Migrate this code into the test framework - private Subtree CreateSubTreeFromCode(Guid guid, string code) - { - var cbn = ProtoCore.Utils.ParserUtils.Parse(code); - var subtree = null == cbn ? new Subtree(null, guid) : new Subtree(cbn.Body, guid); - return subtree; - } - private void AssertValue(string varname, object value) { var mirror = astLiveRunner.InspectNodeValue(varname); diff --git a/test/Engine/ProtoTest/LiveRunnerTests/ChangeSetComputerTests.cs b/test/Engine/ProtoTest/LiveRunnerTests/ChangeSetComputerTests.cs index 1693875aa83..1f207bc2e2b 100644 --- a/test/Engine/ProtoTest/LiveRunnerTests/ChangeSetComputerTests.cs +++ b/test/Engine/ProtoTest/LiveRunnerTests/ChangeSetComputerTests.cs @@ -24,13 +24,6 @@ public override void Setup() runtimeCore = new RuntimeCore(new Heap()); } - private Subtree CreateSubTreeFromCode(Guid guid, string code) - { - var cbn = ProtoCore.Utils.ParserUtils.Parse(code); - var subtree = null == cbn ? new Subtree(null, guid) : new Subtree(cbn.Body, guid); - return subtree; - } - [Test] public void TestAddedNodes01() { diff --git a/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs b/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs index b5ba5bf21c8..96abbb7862c 100644 --- a/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs +++ b/test/Engine/ProtoTest/LiveRunnerTests/MicroFeatureTests.cs @@ -29,14 +29,14 @@ public override void TearDown() liveRunner.Dispose(); } - private void UpdateDsInterpreter(ProtoScript.Runners.LiveRunner liverunner, string code) + private void UpdateDsInterpreter(string code) { Guid guid = Guid.NewGuid(); List added = new List(); Subtree st = TestFrameWork.CreateSubTreeFromCode(guid, code); added.Add(st); var syncData = new GraphSyncData(null, added, null); - liverunner.UpdateGraph(syncData); + liveRunner.UpdateGraph(syncData); } @@ -155,7 +155,6 @@ public void GraphILTest_Assign01() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -174,7 +173,6 @@ public void GraphILTest_Assign01_AstInput() astList.Add(assign); // Update graph using AST node input - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(assign); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -207,7 +205,6 @@ public void GraphILTest_Assign01a() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -251,7 +248,6 @@ public void GraphILTest_Assign02() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -276,7 +272,6 @@ public void GraphILTest_Assign02_AstInput() ProtoCore.DSASM.Operator.assign); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(assign); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -321,7 +316,6 @@ public void GraphILTest_Assign03_astInput() // update graph with ast input CodeBlockNode cNode = new CodeBlockNode(); cNode.Body = astList; - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(cNode); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("b"); @@ -340,8 +334,6 @@ public void GraphILTest_Assign04_astInput() // executes it //////////////////////////////////////////////////////////////////// - liveRunner = new ProtoScript.Runners.LiveRunner(); - // Build the AST trees ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode( new ProtoCore.AST.AssociativeAST.IdentifierNode("a"), @@ -400,7 +392,6 @@ public void GraphILTest_Assign05() // executes updated graph //////////////////////////////////////////////////////////////////// - liveRunner = new ProtoScript.Runners.LiveRunner(); List astList = new List(); // Build the AST trees @@ -503,7 +494,6 @@ public void GraphILTest_ModifiedNode01() // execute updated graph (cylcic dependency should not occur) //////////////////////////////////////////////////////////////////// - liveRunner = new ProtoScript.Runners.LiveRunner(); List astList = new List(); ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign0 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode( @@ -596,10 +586,8 @@ public void GraphILTest_ModifiedNode01() [Test] public void TestDeltaExpression_01() { - liveRunner = new ProtoScript.Runners.LiveRunner(); - // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"a=10;"); + UpdateDsInterpreter("a=10;"); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 10); @@ -607,7 +595,7 @@ public void TestDeltaExpression_01() //string o = liveRunner.GetCoreDump(); // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"c=20;"); + UpdateDsInterpreter("c=20;"); mirror = liveRunner.InspectNodeValue("c"); Assert.IsTrue((Int64)mirror.GetData().Data == 20); @@ -617,7 +605,7 @@ public void TestDeltaExpression_01() //string o = liveRunner.GetCoreDump(); // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"b = a+c;"); + UpdateDsInterpreter("b = a+c;"); mirror = liveRunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 10); @@ -629,7 +617,7 @@ public void TestDeltaExpression_01() //o = liveRunner.GetCoreDump(); // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"c= 30;"); + UpdateDsInterpreter("c= 30;"); mirror = liveRunner.InspectNodeValue("a"); Assert.IsTrue((Int64)mirror.GetData().Data == 10); @@ -644,10 +632,8 @@ public void TestDeltaExpression_01() [Test] public void TestDeltaExpression_02() { - liveRunner = new ProtoScript.Runners.LiveRunner(); - // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"x=99;"); + UpdateDsInterpreter("x=99;"); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("x"); Assert.IsTrue((Int64)mirror.GetData().Data == 99); @@ -655,17 +641,15 @@ public void TestDeltaExpression_02() //string o = liveRunner.GetCoreDump(); // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner,"y=x;"); + UpdateDsInterpreter("y=x;"); mirror = liveRunner.InspectNodeValue("y"); Assert.IsTrue((Int64)mirror.GetData().Data == 99); mirror = liveRunner.InspectNodeValue("x"); Assert.IsTrue((Int64)mirror.GetData().Data == 99); - //string o = liveRunner.GetCoreDump(); - // emit the DS code from the AST tree - UpdateDsInterpreter(liveRunner, "x = 100;"); + UpdateDsInterpreter("x = 100;"); mirror = liveRunner.InspectNodeValue("x"); Assert.IsTrue((Int64)mirror.GetData().Data == 100); @@ -677,10 +661,8 @@ public void TestDeltaExpression_02() [Category("PortToCodeBlocks")] public void TestDeltaExpressionFFI_01() { - liveRunner = new ProtoScript.Runners.LiveRunner(); - - UpdateDsInterpreter(liveRunner, @"import (""FFITarget.dll"");"); - UpdateDsInterpreter(liveRunner, "p = DummyPoint.ByCoordinates(10,10,10);"); + UpdateDsInterpreter(@"import (""FFITarget.dll"");"); + UpdateDsInterpreter("p = DummyPoint.ByCoordinates(10,10,10);"); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("p"); @@ -689,14 +671,14 @@ public void TestDeltaExpressionFFI_01() // newPoint = p.Translate(1,2,3); //============================================== - UpdateDsInterpreter(liveRunner, "newPoint = p.Translate(1,2,3);"); + UpdateDsInterpreter("newPoint = p.Translate(1,2,3);"); mirror = liveRunner.InspectNodeValue("newPoint"); //============================================== // Build a binary expression to retirieve the x property // xval = newPoint.X //============================================== - UpdateDsInterpreter(liveRunner, "xval = newPoint.X;"); + UpdateDsInterpreter("xval = newPoint.X;"); mirror = liveRunner.InspectNodeValue("xval"); //============================================== @@ -714,13 +696,8 @@ public void TestDeltaExpressionFFI_01() [Category("PortToCodeBlocks")] public void TestDeltaExpressionFFI_02() { - liveRunner = new ProtoScript.Runners.LiveRunner(); - - //string code = @"class Point{ X : double; constructor ByCoordinates(x : double, y : double, z : double){X = x;} def Translate(x : double, y : double, z : double){return = Point.ByCoordinates(11,12,13);} }"; - - //liveRunner.UpdateCmdLineInterpreter(code); - UpdateDsInterpreter(liveRunner, @"import (""FFITarget.dll"");"); - UpdateDsInterpreter(liveRunner, "p = DummyPoint.ByCoordinates(10,10,10);"); + UpdateDsInterpreter(@"import (""FFITarget.dll"");"); + UpdateDsInterpreter("p = DummyPoint.ByCoordinates(10,10,10);"); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("p"); @@ -728,7 +705,7 @@ public void TestDeltaExpressionFFI_02() // Build a binary expression to retirieve the x property // xval = newPoint.X //============================================== - UpdateDsInterpreter(liveRunner,"xval = p.X;"); + UpdateDsInterpreter("xval = p.X;"); mirror = liveRunner.InspectNodeValue("xval"); //============================================== @@ -745,7 +722,7 @@ public void TestDeltaExpressionFFI_02() // newPoint = p.Translate(1,2,3); //============================================== - UpdateDsInterpreter(liveRunner,"p = p.Translate(1,2,3);"); + UpdateDsInterpreter("p = p.Translate(1,2,3);"); mirror = liveRunner.InspectNodeValue("p"); @@ -784,7 +761,6 @@ public void GraphILTest_ComplexWatch01() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -821,7 +797,6 @@ public void GraphILTest_DeletedNode01() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a"); @@ -919,7 +894,6 @@ public void GraphILTest_DeletedBinaryExpresionDoesNotEffectReferences() GraphSyncData syncData = new GraphSyncData(null, addedList, null); // emit the DS code from the AST tree - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.UpdateGraph(syncData); // Execute and verify c = true @@ -997,7 +971,6 @@ public void TestAdd01() // in which add order, LiveRunner should get the same result. for (int i = 0; i < shuffleCount; ++i) { - ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.ResetVMAndResyncGraph(new List { "FFITarget.dll" }); index = index.OrderBy(_ => randomGen.Next()); @@ -2415,7 +2388,6 @@ public void TestRedefineFunctionName02() [Test] public void TestFunctionObjectInApply() { - liveRunner = new ProtoScript.Runners.LiveRunner(); liveRunner.ResetVMAndResyncGraph(new List { "DesignScriptBuiltin.dll", "FunctionObject.ds" }); string code = @" def foo(x,y ) { return = x + y; } diff --git a/test/Engine/ProtoTest/ProtoAST/RoundTripTests.cs b/test/Engine/ProtoTest/ProtoAST/RoundTripTests.cs index eae3ec63cf0..0429d4e885c 100644 --- a/test/Engine/ProtoTest/ProtoAST/RoundTripTests.cs +++ b/test/Engine/ProtoTest/ProtoAST/RoundTripTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NUnit.Framework; using ProtoCore.DSASM.Mirror; +using ProtoTestFx.TD; namespace ProtoTest.ProtoAST { @@ -312,7 +313,7 @@ public void TestAstToCode() foreach (var stmt in statements) { - var cbn = ProtoCore.Utils.ParserUtils.Parse(stmt); + var cbn = ProtoCore.Utils.ParserUtils.ParseWithCore(stmt, TestFrameWork.TestParserCore()).CodeBlockNode; if (cbn != null) { foreach (var item in cbn.Body) @@ -328,7 +329,7 @@ public void TestAstToCode() foreach (var stmt in new_statements) { - var cbn = ProtoCore.Utils.ParserUtils.Parse(stmt); + var cbn = ProtoCore.Utils.ParserUtils.ParseWithCore(stmt, TestFrameWork.TestParserCore()).CodeBlockNode; if (cbn != null) { foreach (var item in cbn.Body) diff --git a/test/Engine/ProtoTest/UtilsTests/ImperativeAstVistorTest.cs b/test/Engine/ProtoTest/UtilsTests/ImperativeAstVistorTest.cs index 5f9fac3ad1c..7c7f095e889 100644 --- a/test/Engine/ProtoTest/UtilsTests/ImperativeAstVistorTest.cs +++ b/test/Engine/ProtoTest/UtilsTests/ImperativeAstVistorTest.cs @@ -5,6 +5,7 @@ using ProtoCore.AST.ImperativeAST; using ProtoCore.SyntaxAnalysis; using ProtoCore.Utils; +using ProtoTestFx.TD; namespace ProtoTest.UtilsTests { @@ -72,13 +73,13 @@ private CodeBlockNode GetCodeBlockNode(ProtoCore.AST.AssociativeAST.CodeBlockNod private void TestMapping(string originalCode, string expectedCode) { - var originalResult = ParserUtils.Parse(originalCode); + var originalResult = ParserUtils.ParseWithCore(originalCode, TestFrameWork.TestParserCore()).CodeBlockNode; var cbn = GetCodeBlockNode(originalResult); var mappedCBN = cbn.Accept(replacer) as CodeBlockNode; Assert.IsNotNull(mappedCBN); Assert.IsTrue(mappedCBN.Body.Any()); - var expectedResult = ParserUtils.Parse(expectedCode); + var expectedResult = ParserUtils.ParseWithCore(expectedCode, TestFrameWork.TestParserCore()).CodeBlockNode; var expectedCBN = GetCodeBlockNode(expectedResult); Assert.IsNotNull(expectedCBN); Assert.IsTrue(expectedCBN.Body.Any()); diff --git a/test/Engine/ProtoTestFx/Properties/AssemblyInfo.cs b/test/Engine/ProtoTestFx/Properties/AssemblyInfo.cs index 4196c0f97fe..a87ad67861e 100644 --- a/test/Engine/ProtoTestFx/Properties/AssemblyInfo.cs +++ b/test/Engine/ProtoTestFx/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -15,3 +16,4 @@ "a71ab26a84ef057963dbe6889a22e04196066cb4d7ca3eeb52adb110d0a14bf39a786acf7f4b50" + "b26155bc")] */ +[assembly: InternalsVisibleTo("ProtoTest")] diff --git a/test/Engine/ProtoTestFx/TestFrameWork.cs b/test/Engine/ProtoTestFx/TestFrameWork.cs index 4dc63a9e0f3..caf5e6467c3 100644 --- a/test/Engine/ProtoTestFx/TestFrameWork.cs +++ b/test/Engine/ProtoTestFx/TestFrameWork.cs @@ -43,6 +43,17 @@ public TestFrameWork() runner = new ProtoScriptRunner(); } + internal static ProtoCore.Core TestParserCore() + { + var core = new ProtoCore.Core(new ProtoCore.Options()) + { + ParsingMode = ProtoCore.ParseMode.AllowNonAssignment, + IsParsingPreloadedAssembly = false, + IsParsingInTestMode = true, + }; + return core; + } + /// /// Execute the DS code and verifies the results given a list of verification pairs /// @@ -906,7 +917,7 @@ public static void AssertValue(MirrorData data, object value) public static Subtree CreateSubTreeFromCode(Guid guid, string code) { - var cbn = ProtoCore.Utils.ParserUtils.Parse(code); + var cbn = ProtoCore.Utils.ParserUtils.ParseWithCore(code, TestParserCore()).CodeBlockNode; var subtree = null == cbn ? new Subtree(null, guid) : new Subtree(cbn.Body, guid); subtree.DeltaComputation = false; return subtree; diff --git a/test/System/IntegrationTests/CallsiteRegen.cs b/test/System/IntegrationTests/CallsiteRegen.cs index 090d9b3a418..fb0ae2898ce 100644 --- a/test/System/IntegrationTests/CallsiteRegen.cs +++ b/test/System/IntegrationTests/CallsiteRegen.cs @@ -1,4 +1,4 @@ -using DynamoServices; +using DynamoServices; using NUnit.Framework; using ProtoScript.Runners; using ProtoTestFx.TD; @@ -24,6 +24,7 @@ public void Setup() { testFx = new TestFrameWork(); astLiveRunner = new ProtoScript.Runners.LiveRunner(); + astLiveRunner.Core.IsParsingInTestMode = true; FFITarget.IncrementerTracedClass.ResetForNextTest(); }