public void VisitExport(ExportNode exportNode) { CheckForGraph(exportNode.ExportValue); CheckForString(exportNode.FileName); CheckForAttributeFunctions(exportNode.VertexLabels); CheckForAttributeFunctions(exportNode.EdgeLabels); }
public virtual void Visit(ExportNode node) { if (node != null) { foreach (var specifier in node.Children) { specifier.Accept(this); } } }
public void VisitExport(ExportNode node) { _dispatch(node.ExportValue, new List <string>() { }); _dispatch(node.FileName, new List <string>() { }); node.VertexLabels.ForEach(x => _dispatch(x, new List <string>())); node.EdgeLabels.ForEach(x => _dispatch(x, new List <string>())); }
public void ExportReal_Real_ReturnsCorrectResult(double input, double expected) { RealLiteralExpression realLit = new RealLiteralExpression(input, 1, 1); ExportNode exportNode = new ExportNode(realLit, 1, 1); IInterpreterReal parent = Substitute.For <IInterpreterReal>(); parent.DispatchReal(realLit, Arg.Any <List <object> >()).Returns(input); RealHelper realHelper = SetUpHelper(parent); double res = realHelper.ExportReal(exportNode, new List <object>()); Assert.AreEqual(expected, res); }
private void InsertDeclaration(AST ast, ASTNode himeNode) { if (himeNode.Children[0].Value == "export") { ExportNode exportNode = CreateExportNode(himeNode); ast.Exports.Add(exportNode); } else { FunctionNode functionNode = CreateFunctionNode(himeNode); ast.Functions.Add(functionNode); } }
public void TreeInsertItem(object sender, EventArgs e) { // special behavior if this is a fake export node inside a SWF file ExportNode node = pluginUI.Tree.SelectedNode as ExportNode; if (node != null) { projectActions.InsertFile(MainForm, Project, node.ContainingSwfPath, node.Export); } else { projectActions.InsertFile(MainForm, Project, pluginUI.Tree.SelectedPath, null); } }
public void ParseExportKeyword() { var nodes = StyleParser.Parse(@" export const color0 = rgba(1, 0, 0, 1); "); // there should be two style nodes Assert.AreEqual(1, nodes.Count); Assert.AreEqual(StyleASTNodeType.Export, nodes[0].type); ExportNode exportNode = (ExportNode)nodes[0]; Assert.AreEqual("color0", exportNode.constNode.constName); Assert.AreEqual(StyleASTNodeType.Rgba, exportNode.constNode.value.type); }
private int GetElementIndex(ExportNode node, Function function, Element input, List <Element> vertices, ElementComparer comparer) { FunctionNode functionNode = _functions[function.Reference]; List <Object> parameters = function.Scope.ToList(); parameters.Add(input); Element element = _interpreter.Function <Element>(functionNode, parameters); int index = vertices.BinarySearch(element, comparer); if (index < 0) { throw new InvalidElementException(node, element); } return(index); }
public void ExportGraph_GraphAndFileName_ReturnsCorrectLabelGraphWithLabels() { IInterpreterGraph parent = Substitute.For <IInterpreterGraph>(); GraphHelper graphHelper = SetUpHelper(parent); AST ast = GetAST(); graphHelper.SetASTRoot(ast); parent.Function <Element>(Arg.Any <FunctionNode>(), Arg.Any <List <Object> >()).Returns(new Element(5)); parent.DispatchString(Arg.Any <ExpressionNode>(), Arg.Any <List <Object> >()).Returns("File"); parent.DispatchGraph(Arg.Any <ExpressionNode>(), Arg.Any <List <Object> >()).Returns(GetGraph()); parent.DispatchFunction(Arg.Any <IdentifierExpression>(), Arg.Any <List <Object> >()).Returns(new Function(0)); parent.DispatchFunction(Arg.Any <FunctionCallExpression>(), Arg.Any <List <Object> >()).Returns(new Function(1)); parent.Function <string>(ast.Functions[0], Arg.Any <List <Object> >()).Returns("a"); parent.Function <string>(ast.Functions[1], Arg.Any <List <Object> >()).Returns("b"); List <int> src = new List <int> { 0, 0, 0 }; List <int> dst = new List <int> { 0, 0, 0 }; string[,] vertexLabels = new string[, ] { { "a", "a", "a" }, { "b", "b", "b" } }; string[,] edgeLabels = new string[, ] { { "a", "a", "a" } }; LabelGraph expected = new LabelGraph("File", src, dst, vertexLabels, edgeLabels, 3); IdentifierExpression identifier = new IdentifierExpression("", 0, 0); FunctionCallExpression functionCall = new FunctionCallExpression("", null, 0, 0); ExportNode node = new ExportNode(identifier, identifier, new List <ExpressionNode>() { identifier, functionCall }, new List <ExpressionNode>() { identifier }, 0, 0); LabelGraph result = graphHelper.ExportGraph(node); result.Should().BeEquivalentTo(expected); }
private LabelGraph HandleExceptions(ExportNode n) { if (_catchExceptions) { try { return(_graphHelper.ExportGraph(n)); } catch (CompilerException e) { _exceptions.Add(e); return(null); } } else { return(_graphHelper.ExportGraph(n)); } }
public LabelGraph ExportGraph(ExportNode node) { List <Object> emptyParameters = new List <Object>(); Graph graph = _interpreter.DispatchGraph(node.ExportValue, emptyParameters); string fileName = _interpreter.DispatchString(node.FileName, emptyParameters); List <int> src = new List <int>(); List <int> dst = new List <int>(); ElementComparer comparer = new ElementComparer(); List <Element> vertices = graph.Vertices.List; vertices.Sort(comparer); foreach (Element e in graph.Edges.Elements) { src.Add(GetElementIndex(node, graph.Src, e, vertices, comparer)); dst.Add(GetElementIndex(node, graph.Dst, e, vertices, comparer)); } string[,] edgeLabels = GetLabels(node.EdgeLabels, graph.Edges); string[,] vertexLabels = GetLabels(node.VertexLabels, graph.Vertices); return(new LabelGraph(fileName, src, dst, vertexLabels, edgeLabels, graph.Vertices.Elements.Count)); }
private void AddExportItems(MergableMenu menu, ExportNode node) { // it DOES make sense to allow insert of assets inside the injection target! if (project.UsesInjection && project.GetRelativePath(node.ContainingSwfPath) != project.InputPath) return; if (node is ClassExportNode) menu.Add(Open, 0); menu.Add(Insert, 0); }
public double ExportReal(ExportNode node, List <object> parameters) { return(_interpreter.DispatchReal(node.ExportValue, parameters)); }
public static void AddExportNode(AST ast, ExportNode exportNode) { ast.Exports.Add(exportNode); }
public static AST GetMultiGraphExample() { AST ast = GetAstSkeleton(); FunctionCallExpression vertices = GetFunctionCallExpression("vertexSet", GetIdentifierExpression("n", 0, true), 1); SetExpression edges = GetSetExpression(GetElementNode("x", "i", -1), GetBoundNode("i", 0, GetAdditionExpression(GetIdentifierExpression("n", 0, true), -1))); AnonymousFunctionExpression src = GetAnonymousFunctionExpression("e", TypeEnum.Element, GetFunctionCallExpression("edgeFunc", GetIdentifierExpression("e", 1, true), 2)); AnonymousFunctionExpression dst = GetAnonymousFunctionExpression("e", TypeEnum.Element, GetFunctionCallExpression("edgeFunc", new List <ExpressionNode>() { GetIdentifierExpression("e", 1, true), GetIdentifierExpression("n", 0, true) }, 3)); GraphExpression graphExpression = GetGraphExpression(vertices, edges, src, dst); FunctionNode graphFunc = GetFunctionNode(graphExpression, "graphFunc", "n", TypeEnum.Integer, TypeEnum.Graph); AddFunctionNode(ast, graphFunc); FunctionNode vertexSet = GetFunctionNode(GetSetExpression(GetElementNode("x", "i", -1), GetBoundNode("i", 0, GetAdditionExpression(GetIdentifierExpression("n", 0, true), -1))), "vertexSet", "n", TypeEnum.Integer, TypeEnum.Set); AddFunctionNode(ast, vertexSet); FunctionNode edgeFunc = GetFunctionNode(GetIdentifierExpression("e", 0, true), "edgeFunc", "e", TypeEnum.Element, TypeEnum.Element); AddFunctionNode(ast, edgeFunc); FunctionNode edgeFunc2 = GetFunctionNode(new List <ConditionNode>() { GetConditionNode(new List <ElementNode>() { GetElementNode("e", "i", 0) }, null, GetElementExpression(GetModuloExpression(GetAdditionExpression(GetIdentifierExpression("i", 2, true), 1), GetIdentifierExpression("n", 1, true)))) }, "edgeFunc", new List <string>() { "e", "n" }, new List <TypeEnum>() { TypeEnum.Element, TypeEnum.Integer }, TypeEnum.Element); AddFunctionNode(ast, edgeFunc2); FunctionNode vLabel = GetFunctionNode(new List <ConditionNode>() { GetConditionNode(new List <ElementNode>() { GetElementNode("e", "i", 0) }, null, GetAdditionExpression(GetStringLiteralExpression("Vertex: "), GetIdentifierExpression("i", 1, true))) }, "vLabel", new List <string>() { "e" }, new List <TypeEnum>() { TypeEnum.Element }, TypeEnum.String); AddFunctionNode(ast, vLabel); FunctionNode eLabel = GetFunctionNode(new List <ConditionNode>() { GetConditionNode(new List <ElementNode>() { GetElementNode("e", "i", 0) }, null, GetAdditionExpression(GetStringLiteralExpression("Edge: "), GetIdentifierExpression("i", 1, true))) }, "eLabel", new List <string>() { "e" }, new List <TypeEnum>() { TypeEnum.Element }, TypeEnum.String); AddFunctionNode(ast, eLabel); ExportNode export = GetExportNode(GetFunctionCallExpression("graphFunc", GetIntegerLiteralExpression(2), 0), "MultiIntegration", GetIdentifierExpression("vLabel", 4, false), GetIdentifierExpression("eLabel", 5, false)); AddExportNode(ast, export); return(ast); }
public InvalidSetTypeException(ExportNode node) : base(node, "Export should be given a set in this iteration") { }
public void Visit(ExportNode node) { // not applicable; terminate }
public InvalidElementException(ExportNode node, Element e) : base(node, GetMessage(e)) { }