Exemplo n.º 1
0
 protected virtual void EmitImportNode(ProtoCore.AST.AssociativeAST.ImportNode importNode)
 {
     Validity.Assert(null != importNode);
     EmitCode("import(");
     EmitCode("\"");
     EmitCode(importNode.ModuleName);
     EmitCode("\"");
     EmitCode(");\n");
 }
Exemplo n.º 2
0
 protected virtual void EmitImportNode(ProtoCore.AST.AssociativeAST.ImportNode importNode)
 {
 }
Exemplo n.º 3
0
 public void GraphILTest_FFIClassUsage_02()
 {
     List<ProtoCore.AST.AssociativeAST.AssociativeNode> astList = new List<ProtoCore.AST.AssociativeAST.AssociativeNode>();
     //==============================================
     // Build the import Nodes
     //==============================================
     ProtoCore.AST.AssociativeAST.ImportNode importNode = new ProtoCore.AST.AssociativeAST.ImportNode();
     importNode.ModuleName = "ProtoGeometry.dll";
     astList.Add(importNode);
     //==============================================
     // 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;
     ProtoCore.AST.AssociativeAST.FunctionDotCallNode dotCall = new ProtoCore.AST.AssociativeAST.FunctionDotCallNode("Point", constructorCall);
     //==============================================
     // 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);
     //==============================================
     // 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);
     //==============================================
     // emit the DS code from the AST tree
     //
     // import ("ProtoGeometry.dll");
     // p = Point.Bycoordinates(10.0, 10.0, 10.0);
     // newPoint = p.Translate(1.0,2.0,3.0);
     // xval = newPoint.X;
     //
     //==============================================
     GraphToDSCompiler.GraphCompiler gc = GraphToDSCompiler.GraphCompiler.CreateInstance();
     string code = gc.Emit(astList);
     //==============================================
     // Verify the results - get the value of the x property
     //==============================================
     ExecutionMirror mirror = thisTest.RunScriptSource(code);
     Obj o = mirror.GetValue("xval");
     Assert.IsTrue((Double)o.Payload == 11.0);
 }