public override Node VisitRecord([NotNull] TigerParser.RecordContext context) { var node = new RecordNode(context); var typeId = new IdNode(context, context.typeID.Text); node.Children.Add(typeId); // RECORD TYPE ITerminalNode[] ids = context.ID(); TigerParser.ExprContext[] exprs = context.expr(); for (int i = 1; i < ids.Length; i++) { var fieldId = new IdNode( ids[i].Symbol.Line, ids[i].Symbol.Column, ids[i].GetText()); var fieldExpr = Visit(exprs[i - 1]); var field = new FieldNode(fieldId.Line, fieldId.Column); field.Children.Add(fieldId); // field -> FIELD NAME field.Children.Add(fieldExpr); // field -> FIELD EXPRESSION node.Children.Add(field); // FIELD #i } return(node); }
private void VerifyEncodeDecode(List <EsfNode> nodes) { RecordNode rootNode = CreateRootNode(); rootNode.Value = nodes; // EsfFile encodedFile = new EsfFile(rootNode, codec); MemoryStream stream = new MemoryStream(); byte[] encoded; using (BinaryWriter writer = new BinaryWriter(stream)) { codec.EncodeRootNode(writer, rootNode); encoded = stream.ToArray(); } EsfNode decoded; using (BinaryReader reader = new BinaryReader(new MemoryStream(encoded))) { decoded = codec.Parse(reader); } assertEqual(rootNode, decoded); // EsfNode decodedResult = (decoded as ParentNode).AllNodes[0]; for (int i = 0; i < rootNode.AllNodes.Count; i++) { assertEqual(rootNode.AllNodes[i], (decoded as ParentNode).AllNodes[i]); } // nodes.ForEach(node => {assertEqual(node, decodedResult); }); }
public void GenerateNewNode(Record record) { GameObject newNode = Instantiate(nodeObj); newNode.transform.SetParent(content.transform); RecordNode newrecordNode = newNode.GetComponent <RecordNode> (); newrecordNode.Initialize(record, CalcHeight(record.GetRunk())); }
public void AddConverterToRecord(string converterName) { currentConverterRecord = converterRecords.FirstOrDefault(converter => converter.Name == converterName); if (currentConverterRecord != null) { return; } currentConverterRecord = new RecordNode(converterName, ""); converterRecords.Add(currentConverterRecord); }
public void TestRecordNode() { RecordNode node = new RecordNode(codec, (byte)EsfType.RECORD) { Name = "test", Value = createSomeNodes() }; VerifyEncodeDecode(node); }
public int Recording(int seq, HumanBodyBones bone, Transform transfrom) { if (seq > RecordSkipSeq) { if (!records.ContainsKey(seq)) { records[seq] = new List <RecordNode>(); } RecordNode node = new RecordNode(bone, transfrom.position, transfrom.rotation); records[seq].Add(node); } return(records.Keys.Count); }
public static void Main(string[] args) { AbcaFileCodec codec = new AbcaFileCodec { Header = new EsfHeader { ID = 0xABCA } }; RecordNode root = new RecordNode(codec) { Name = "root" }; RecordNode child = new RecordNode(codec) { Name = "copySource" }; EsfValueNode <string> utf16String = (EsfValueNode <string>)codec.CreateValueNode(EsfType.UTF16); utf16String.Value = "utf16"; child.Value.Add(utf16String); root.Value.Add(child); child = new RecordNode(codec) { Name = "copyTarget" }; EsfValueNode <string> copyString = (EsfValueNode <string>)utf16String.CreateCopy(); // copyString.Value = "copy"; copyString.FromString("copy"); child.Value.Add(copyString); root.Value.Add(child); // this is needed for the file to create the record nodes properly SortedList <int, string> nodeNames = new SortedList <int, string>(); nodeNames.Add(0, "root"); nodeNames.Add(1, "copySource"); nodeNames.Add(2, "copyTarget"); // this property needs to be added to the EsfFileCodec, getting and setting EsfFileCodec#nodeNames codec.NodeNames = nodeNames; EsfFile file = new EsfFile(root, codec); EsfCodecUtil.WriteEsfFile("string_container.esf", file); }
// 1. // <CallNode> // | // <ListNode> // | // <Error RecordNode>[Cursor position] // For example, Patch(Accounts, OldRecord, UpdateRecord, {<Cursor position> // 2. // <CallNode> // | // <ListNode> // | // <RecordNode> // | // <Error Node>[Cursor position] // For example, Patch(Accounts, OldRecord, UpdateRecord, {A:"",<cursor position>}) // 3. // <CallNode> // | // <ListNode> // | // <VariadicOpNode> // | // <RecordNode> // | // <Error Identifier Node> [Cursor position] // For example, Patch(Accounts, OldRecord, UpdateRecord, { 'Account Name': ""}); // Patch(Accounts, OldRecord, UpdateRecord,{<Cursor position>); private static bool TryGetRecordNodeWithinACallNode(TexlNode node, out RecordNode recordNode, out CallNode callNode) { Contracts.AssertValue(node); if (!TryGetParentRecordNode(node, out recordNode) || !TryGetParentListNode(recordNode, out ListNode listNode)) { callNode = null; return(false); } if (!(listNode.Parent is CallNode cNode)) { callNode = null; return(false); } callNode = cNode; return(true); }
public void TestEquals() { EsfNode valueNode = new IntNode { Value = 1 }; EsfNode valueNode2 = new IntNode { Value = 1 }; assertEqual(valueNode, valueNode2); List <EsfNode> nodeList1 = new List <EsfNode>(); nodeList1.Add(valueNode); List <EsfNode> nodeList2 = new List <EsfNode>(); nodeList2.Add(valueNode); RecordNode node = new RecordNode(null) { Name = "name", Value = nodeList1 }; EsfNode node2 = new RecordNode(null) { Name = "nodename", Value = nodeList2 }; assertNotEqual(node, node2); node = new RecordNode(null) { Name = "nodename", Value = nodeList1 }; assertEqual(node, node2); AbcaFileCodec codec = new AbcaFileCodec(); EsfFile file = new EsfFile(node, codec); AbceCodec codec2 = new AbceCodec(); EsfFile file2 = new EsfFile(node2, codec2); assertNotEqual(file, file2); file2.Codec = codec; assertEqual(file, file2); }
private static bool TryGetParentRecordNode(TexlNode node, out RecordNode recordNode) { Contracts.AssertValue(node); TexlNode parentNode = node; while (parentNode != null) { if (parentNode.Kind == NodeKind.Record) { recordNode = parentNode.AsRecord(); return(true); } parentNode = parentNode.Parent; } recordNode = null; return(false); }
private void CollectInnerType(RecordNode node, PackageType packageType) { var record = new RecordType(packageType.Name, node.Name); foreach (var item in node.Vars) { var varInfo = GetVar(item); record.AddField(varInfo.Name, varInfo.Type); } bool ok = packageType.AddType(record); types.AddType(record); if (!ok) { Log(String.Format("Запись с именем {0} уже существует", node.Name), node); } }
private static bool TryGetParentListNode(RecordNode node, out ListNode listNode) { Contracts.AssertValue(node); TexlNode parentNode = node; while (parentNode != null) { if (parentNode.Kind == NodeKind.List) { listNode = parentNode.AsList(); return(true); } parentNode = parentNode.Parent; } listNode = null; return(false); }
static void Main(string[] args) { var writer = new StringWriter(); using var digraph = new DigraphWriter("sample", new StreamWriter("G:\\output.dot")); var a = new RecordNode(Direction.Horizontal); a.RootLabel.Add("a"); a.RootLabel.Add("b"); var b = new RecordNode(Direction.Vertical); b.RootLabel.Add("c"); b.RootLabel.Add("d"); digraph.WriteEdge(a, b); digraph.WriteRecord(a); digraph.WriteRecord(b); }
public override bool PreVisit(RecordNode node) { Contracts.AssertValue(node); Contracts.Assert(node.Token.Kind == TokKind.CurlyOpen || node.Token.Kind == TokKind.Ident); if (_cursorPosition <= node.Token.Span.Min || // If cursor position is before the open curly return the record node. node.Count == 0 || // Or if the record node is empty, return the record node. (node.CurlyClose != null && node.CurlyClose.Span.Lim <= _cursorPosition)) // Cursor is after the closed curly. { _result = node; return(false); } // Cursor is between the open and closed curly. int length = CollectionUtils.Size(node.Commas); for (int i = 0; i < length; i++) { Token tokComma = node.Commas[i]; // Cursor position is inside ith child. if (_cursorPosition <= tokComma.Span.Min) { node.Children[i].Accept(this); return(false); } } if (node.CurlyClose == null || _cursorPosition <= node.CurlyClose.Span.Min) { // Cursor is within the last child. node.Children[node.Children.Length - 1].Accept(this); return(false); } // Cursor is after the closing curly. _result = node; return(false); }
public void TestOptimizedIntNode() { OptimizedIntNode optimized = new OptimizedIntNode { Codec = codec, Value = 5 }; OptimizedIntNode other = new OptimizedIntNode { Codec = codec, Value = 5 }; assertEqual(optimized, other); RecordNode rootNode = CreateRootNode(); rootNode.Value = new List <EsfNode>(new EsfNode[] { other }); //rootNode.AllNodes.Add(other); other.FromString("1"); assertTrue(other.Modified); assertTrue(rootNode.Modified); assertEqual(other.Value, 1); //assertEqual(optimized, other); }
public override Result Visit(RecordNode node, Context context) { return(Aggregate(node.Children.Select(child => child.Accept(this, context)))); }
private void Visit(RecordNode node, TypeInfo type) { }
public abstract Result Visit(RecordNode node, Context context);
public virtual bool PreVisit(RecordNode node) { return(true); }
public abstract void PostVisit(RecordNode node);