本文整理汇总了C#中ProtoScript.Runners.LiveRunner.InspectNodeValue方法的典型用法代码示例。如果您正苦于以下问题:C# LiveRunner.InspectNodeValue方法的具体用法?C# LiveRunner.InspectNodeValue怎么用?C# LiveRunner.InspectNodeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoScript.Runners.LiveRunner
的用法示例。
在下文中一共展示了LiveRunner.InspectNodeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GraphILTest_Assign01_AstInput
public void GraphILTest_Assign01_AstInput()
{
// Build the AST trees
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
// Update graph using AST node input
ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
liveRunner.UpdateGraph(assign);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
}
示例2: GraphILTest_Assign01
public void GraphILTest_Assign01()
{
// Build the AST trees
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
// Instantiate GraphSyncData
List<Subtree> addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
GraphSyncData syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
liveRunner.UpdateGraph(syncData);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
}
示例3: TestDeltaExpressionFFI_01
public void TestDeltaExpressionFFI_01()
{
liveRunner = new ProtoScript.Runners.LiveRunner();
liveRunner.UpdateCmdLineInterpreter(@"import (""FFITarget.dll"");");
liveRunner.UpdateCmdLineInterpreter("p = DummyPoint.ByCoordinates(10,10,10);");
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("p");
//==============================================
// Translate the point
// newPoint = p.Translate(1,2,3);
//==============================================
liveRunner.UpdateCmdLineInterpreter("newPoint = p.Translate(1,2,3);");
mirror = liveRunner.InspectNodeValue("newPoint");
//==============================================
// Build a binary expression to retirieve the x property
// xval = newPoint.X
//==============================================
liveRunner.UpdateCmdLineInterpreter("xval = newPoint.X;");
mirror = liveRunner.InspectNodeValue("xval");
//==============================================
//
// import ("ProtoGeometry.dll");
// p = Point.Bycoordinates(10.0, 10.0, 10.0);
// newPoint = p.Translate(1.0,2.0,3.0);
// xval = newPoint.X;
//
//==============================================
Assert.IsTrue((double)mirror.GetData().Data == 11.0);
}
示例4: TestDeltaExpression_02
public void TestDeltaExpression_02()
{
liveRunner = new ProtoScript.Runners.LiveRunner();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("x=99;");
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("x");
Assert.IsTrue((Int64)mirror.GetData().Data == 99);
//string o = liveRunner.GetCoreDump();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("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
liveRunner.UpdateCmdLineInterpreter("x = 100;");
mirror = liveRunner.InspectNodeValue("x");
Assert.IsTrue((Int64)mirror.GetData().Data == 100);
mirror = liveRunner.InspectNodeValue("y");
Assert.IsTrue((Int64)mirror.GetData().Data == 100);
}
示例5: TestDeltaExpression_01
public void TestDeltaExpression_01()
{
liveRunner = new ProtoScript.Runners.LiveRunner();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("a=10;");
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
//string o = liveRunner.GetCoreDump();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("c=20;");
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 20);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
//string o = liveRunner.GetCoreDump();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("b = a+c;");
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 20);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue((Int64)mirror.GetData().Data == 30);
//o = liveRunner.GetCoreDump();
// emit the DS code from the AST tree
liveRunner.UpdateCmdLineInterpreter("c= 30;");
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 30);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue((Int64)mirror.GetData().Data == 40);
//o = liveRunner.GetCoreDump();
}
示例6: GraphILTest_ModifiedNode01
public void GraphILTest_ModifiedNode01()
{
////////////////////////////////////////////////////////////////////
// Adds nodes => c = 78; d = a;
// Create subtree, execute
// Adds nodes => a = 10;
// Adds node => b = a;
// Create subtree, execute
// Modify subtree => a = b;
// execute updated graph (cylcic dependency should not occur)
////////////////////////////////////////////////////////////////////
liveRunner = new ProtoScript.Runners.LiveRunner();
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign0 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
new ProtoCore.AST.AssociativeAST.IntNode(78),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign0);
assign0 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("d"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign0);
List<Subtree> addedList = new List<Subtree>();
System.Guid guid0 = System.Guid.NewGuid();
addedList.Add(new Subtree(astList, guid0));
GraphSyncData syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 78);
mirror = liveRunner.InspectNodeValue("d");
Assert.IsTrue(mirror.GetData().IsNull);
// Build the AST trees
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign1);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign2);
addedList = new List<Subtree>();
System.Guid guid1 = System.Guid.NewGuid();
addedList.Add(new Subtree(astList, guid1));
syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 78);
mirror = liveRunner.InspectNodeValue("d");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign3);
List<Subtree> modifiedList = new List<Subtree>();
modifiedList.Add(new Subtree(astList, guid1));
syncData = new GraphSyncData(null, null, modifiedList);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 78);
mirror = liveRunner.InspectNodeValue("d");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
//.........这里部分代码省略.........
示例7: GraphILTest_Assign05
public void GraphILTest_Assign05()
{
////////////////////////////////////////////////////////////////////
// Adds nodes => a = 10;
// executes it
// Adds node => c = 20;
// executes it
// Adds node => b = a + c;
// executes it
// deletes node => c = 20;
// executes updated graph
////////////////////////////////////////////////////////////////////
liveRunner = new ProtoScript.Runners.LiveRunner();
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
// Build the AST trees
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign1);
List<Subtree> addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
// Instantiate GraphSyncData
GraphSyncData syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
//string o = liveRunner.GetCoreDump();
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
new ProtoCore.AST.AssociativeAST.IntNode(20),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign2);
addedList = new List<Subtree>();
System.Guid guid1 = System.Guid.NewGuid();
addedList.Add(new Subtree(astList, guid1));
syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 20);
//string o = liveRunner.GetCoreDump();
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
ProtoCore.DSASM.Operator.add),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign3);
addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue((Int64)mirror.GetData().Data == 20);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue((Int64)mirror.GetData().Data == 30);
//o = liveRunner.GetCoreDump();
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign2);
List<Subtree> deletedList = new List<Subtree>();
deletedList.Add(new Subtree(astList, guid1));
syncData = new GraphSyncData(deletedList, null, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
mirror = liveRunner.InspectNodeValue("c");
Assert.IsTrue(mirror.GetData().IsNull);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue(mirror.GetData().IsNull);
//.........这里部分代码省略.........
示例8: GraphILTest_DeletedNode01
public void GraphILTest_DeletedNode01()
{
//====================================
// Create a = 10
// Execute and verify a = 10
// Delete a = 10
// Create b = a
// Execute and verify b = null
//====================================
// Create a = 10
// Execute and verify a = 10
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
Guid guid = System.Guid.NewGuid();
// Instantiate GraphSyncData
List<Subtree> addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, guid));
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");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
// Delete a = 10
List<Subtree> deletedList = new List<Subtree>();
deletedList.Add(new Subtree(null, guid));
syncData = new GraphSyncData(deletedList, null, null);
liveRunner.UpdateGraph(syncData);
// Create b = a
// Execute and verify b = null
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
ProtoCore.DSASM.Operator.assign);
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign2);
guid = System.Guid.NewGuid();
// Instantiate GraphSyncData
addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, guid));
syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("b");
Assert.IsTrue(mirror.GetData().IsNull);
}
示例9: GraphILTest_Assign02_AstInput
public void GraphILTest_Assign02_AstInput()
{
////////////////////////////////////////////////////////////////////
// Adds a node => a = 10 + 20;
// Creates Subtree and sync data and executes it via delta execution
////////////////////////////////////////////////////////////////////
// Build the AST tree
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IntNode(10),
new ProtoCore.AST.AssociativeAST.IntNode(20),
ProtoCore.DSASM.Operator.add),
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");
Assert.IsTrue((Int64)mirror.GetData().Data == 30);
}
示例10: GraphILTest_Assign01a
public void GraphILTest_Assign01a()
{
////////////////////////////////////////////////////////////////////
// Adds a node => a = 10;
// Creates Subtree, Deletes the node,
// Creates Subtree and sync data and executes it via delta execution
////////////////////////////////////////////////////////////////////
// Build the AST trees
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
// Instantiate GraphSyncData
List<Subtree> addedList = new List<Subtree>();
System.Guid guid1 = System.Guid.NewGuid();
addedList.Add(new Subtree(astList, guid1));
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");
Assert.IsTrue((Int64)mirror.GetData().Data == 10);
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
astList.Add(assign);
List<Subtree> deletedList = new List<Subtree>();
deletedList.Add(new Subtree(astList, guid1));
syncData = new GraphSyncData(deletedList, null, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
mirror = liveRunner.InspectNodeValue("a");
Assert.IsTrue(mirror.GetData().IsNull);
}
示例11: TestBuildAST_01
public void TestBuildAST_01()
{
//==============================================
//
// import("ProtoGeometry.dll");
// p = Point.Bycoordinates(0.0, 2.0, 1.0);
// xval = p.X;
//
//==============================================
//==============================================
// Build the import Nodes
//==============================================
ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
List<string> libs = new List<string>();
libs.Add("ProtoGeometry.dll");
liveRunner.ResetVMAndImportLibrary(libs);
string type = "Point";
long hostInstancePtr = 0;
string functionName = "ByCoordinates";
List<IntPtr> userDefinedArgs = null;
List<string> primitiveArgs = new List<string>();
primitiveArgs.Add("0");
primitiveArgs.Add("2");
primitiveArgs.Add("1");
string formatString = "ddd";
string symbolName = "";
string code = "";
AssociativeNode assign1 = ASTCompilerUtils.BuildAST(type, hostInstancePtr, functionName, userDefinedArgs, primitiveArgs, formatString, liveRunner.Core,
ref symbolName, ref code);
liveRunner.UpdateGraph(assign1);
primitiveArgs.Clear();
primitiveArgs.Add("10");
primitiveArgs.Add("0");
primitiveArgs.Add("0");
functionName = "Translate";
AssociativeNode assign2 = ASTCompilerUtils.BuildAST(symbolName, hostInstancePtr, functionName, userDefinedArgs, primitiveArgs, formatString, liveRunner.Core,
ref symbolName, ref code);
liveRunner.UpdateGraph(assign2);
//==============================================
// Build a binary expression to retirieve the x property
// xval = p.X;
//==============================================
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode(symbolName);
identListNode.Optr = ProtoCore.DSASM.Operator.dot;
identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
identListNode,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt2);
//==============================================
//
// import("ProtoGeometry.dll");
// p = Point.Bycoordinates(0.0, 20.0, 1.0);
// q = p.Translate(10.0, 0.0, 0.0);
// xval = p.X;
//
//==============================================
// update graph
CodeBlockNode cNode = new CodeBlockNode();
cNode.Body = astList;
liveRunner.UpdateGraph(cNode);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
Assert.IsTrue((double)mirror.GetData().Data == 10.0);
}
示例12: GraphILTest_FFIClassUsage_02_astInput
public void GraphILTest_FFIClassUsage_02_astInput()
{
ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
//==============================================
// Build the import Nodes
//==============================================
List<string> libs = new List<string>();
libs.Add("ProtoGeometry.dll");
List<LibraryMirror> libMirrors = liveRunner.ResetVMAndImportLibrary(libs);
//==============================================
// Build the constructor call nodes
// Point.ByCoordinates(10,10,10)
//==============================================
ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
constructorCall.FormalArguments = listArgs;
string className = "Point";
ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);
ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);
//==============================================
// Build the binary expression
// p = Point.ByCoordinates(10,10,10)
//==============================================
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
dotCall,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt1);
//==============================================
// Translate the point
// newPoint = p.Translate(1,2,3);
//==============================================
ProtoCore.AST.AssociativeAST.FunctionCallNode functionCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
functionCallTranslate.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("Translate");
listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(1.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(2.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(3.0));
functionCallTranslate.FormalArguments = listArgs;
//ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = new ProtoCore.AST.AssociativeAST.FunctionDotCallNode("p", functionCallTranslate);
className = "p";
inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);
ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCallTranslate = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, functionCallTranslate, liveRunner.Core);
//==============================================
// Build the binary expression
//==============================================
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint"),
dotCallTranslate,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt2);
//==============================================
// Build a binary expression to retirieve the x property
// xval = newPoint.X
//==============================================
ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("newPoint");
identListNode.Optr = ProtoCore.DSASM.Operator.dot;
identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
identListNode,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt3);
//==============================================
//
// import ("ProtoGeometry.dll");
// p = Point.Bycoordinates(10.0, 10.0, 10.0);
// newPoint = p.Translate(1.0,2.0,3.0);
// xval = newPoint.X;
//
//==============================================
// update graph
CodeBlockNode cNode = new CodeBlockNode();
cNode.Body = astList;
liveRunner.UpdateGraph(cNode);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
Assert.IsTrue((double)mirror.GetData().Data == 11.0);
}
示例13: GraphILTest_FFIClassUsage_01
public void GraphILTest_FFIClassUsage_01()
{
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
//==============================================
// Build the import Nodes
//==============================================
ProtoScript.Runners.ILiveRunner liveRunner = new ProtoScript.Runners.LiveRunner();
List<string> libs = new List<string>();
libs.Add("ProtoGeometry.dll");
liveRunner.ResetVMAndResyncGraph(libs);
//==============================================
// Build the constructor call nodes
// Point.ByCoordinates(10,10,10)
//==============================================
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
ProtoCore.AST.AssociativeAST.FunctionCallNode constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
List<ProtoCore.AST.AssociativeAST.AssociativeNode> listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
constructorCall.FormalArguments = listArgs;
string className = "Point";
ProtoCore.AST.AssociativeAST.IdentifierNode inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);
ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);
//==============================================
// Build the binary expression
// p = Point.ByCoordinates(10,10,10)
//==============================================
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
dotCall,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt1);
//==============================================
// Build a binary expression to retirieve the x property
// xval = p.X;
//==============================================
ProtoCore.AST.AssociativeAST.IdentifierListNode identListNode = new ProtoCore.AST.AssociativeAST.IdentifierListNode();
identListNode.LeftNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("p");
identListNode.Optr = ProtoCore.DSASM.Operator.dot;
identListNode.RightNode = new ProtoCore.AST.AssociativeAST.IdentifierNode("X");
ProtoCore.AST.AssociativeAST.BinaryExpressionNode stmt2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("xval"),
identListNode,
ProtoCore.DSASM.Operator.assign);
astList.Add(stmt2);
//==============================================
// emit the DS code from the AST tree
//
// import("ProtoGeometry.dll");
// p = Point.Bycoordinates(10.0, 10.0, 10.0);
// xval = p.X;
//
//==============================================
// Instantiate GraphSyncData
List<Subtree> addedList = new List<Subtree>();
addedList.Add(new Subtree(astList, System.Guid.NewGuid()));
GraphSyncData syncData = new GraphSyncData(null, addedList, null);
// emit the DS code from the AST tree
liveRunner.UpdateGraph(syncData);
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("xval");
Assert.IsTrue((double)mirror.GetData().Data == 10.0);
///////////////////////////////////////////////////////////////////////////////
libs = new List<string>();
libs.Add("ProtoGeometry.dll");
liveRunner.ResetVMAndResyncGraph(libs);
astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
constructorCall = new ProtoCore.AST.AssociativeAST.FunctionCallNode();
constructorCall.Function = new ProtoCore.AST.AssociativeAST.IdentifierNode("ByCoordinates");
listArgs = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
listArgs.Add(new ProtoCore.AST.AssociativeAST.DoubleNode(10.0));
constructorCall.FormalArguments = listArgs;
className = "Point";
inode = new ProtoCore.AST.AssociativeAST.IdentifierNode(className);
dotCall = ProtoCore.Utils.CoreUtils.GenerateCallDotNode(inode, constructorCall, liveRunner.Core);
//==============================================
// Build the binary expression
// p = Point.ByCoordinates(10,10,10)
//==============================================
stmt1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("p"),
dotCall,
//.........这里部分代码省略.........
示例14: TestDeltaExpressionFFI_02
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);
liveRunner.UpdateCmdLineInterpreter(@"import (""FFITarget.dll"");");
liveRunner.UpdateCmdLineInterpreter("p = DummyPoint.ByCoordinates(10,10,10);");
ProtoCore.Mirror.RuntimeMirror mirror = liveRunner.InspectNodeValue("p");
//==============================================
// Build a binary expression to retirieve the x property
// xval = newPoint.X
//==============================================
liveRunner.UpdateCmdLineInterpreter("xval = p.X;");
mirror = liveRunner.InspectNodeValue("xval");
//==============================================
//
// import ("ProtoGeometry.dll");
// p = Point.Bycoordinates(10.0, 10.0, 10.0);
// newPoint = p.Translate(1.0,2.0,3.0);
// xval = newPoint.X;
//
//==============================================
Assert.IsTrue((double)mirror.GetData().Data == 10.0);
//==============================================
// Translate the point
// newPoint = p.Translate(1,2,3);
//==============================================
liveRunner.UpdateCmdLineInterpreter("p = p.Translate(1,2,3);");
mirror = liveRunner.InspectNodeValue("p");
mirror = liveRunner.InspectNodeValue("xval");
//==============================================
//
// import ("ProtoGeometry.dll");
// p = Point.Bycoordinates(10.0, 10.0, 10.0);
// newPoint = p.Translate(1.0,2.0,3.0);
// xval = newPoint.X;
//
//==============================================
Assert.IsTrue((double)mirror.GetData().Data == 11.0);
}
示例15: GraphILTest_Assign03_astInput
public void GraphILTest_Assign03_astInput()
{
////////////////////////////////////////////////////////////////////
// Adds nodes => a = 10; c = 20; b = a + c;
// Creates 3 separate Subtrees
////////////////////////////////////////////////////////////////////
List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
// Build the AST trees
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign1 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IntNode(10),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign1);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign2 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
new ProtoCore.AST.AssociativeAST.IntNode(20),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign2);
ProtoCore.AST.AssociativeAST.BinaryExpressionNode assign3 = new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("b"),
new ProtoCore.AST.AssociativeAST.BinaryExpressionNode(
new ProtoCore.AST.AssociativeAST.IdentifierNode("a"),
new ProtoCore.AST.AssociativeAST.IdentifierNode("c"),
ProtoCore.DSASM.Operator.add),
ProtoCore.DSASM.Operator.assign);
astList.Add(assign3);
// 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");
Assert.IsTrue((Int64)mirror.GetData().Data == 30);
}