public override CodeNode VisitFieldAssignment(FieldAssignmentNode node) { _Writer.WriteStartElement("FieldAssignment"); _Writer.WriteAttributeString("Type", node.Type.ToString()); _Writer.WriteAttributeString("FieldIndex", node.FieldIndex.ToString()); _Writer.WriteStartElement("ReadNode"); Visit(node.ReadNode); _Writer.WriteEndElement(); _Writer.WriteStartElement("AssignmentBlock"); Visit(node.AssignmentBlock); _Writer.WriteEndElement(); _Writer.WriteEndElement(); return(node); }
public override CodeNode VisitFieldAssignment(FieldAssignmentNode node) { //ensure we're in a FieldAssignmentBlock if (!_InFieldAssignmentBlock) { throw new InvalidOperationException("EndOfStreamCheckNode must occur within a FieldAssignmentBlockNode"); } _InFieldAssignment = true; try { Log($"Handling field {node.FieldIndex}."); //generate the end of stream check ILGen.Ldloc(_Reader); ILGen.Callvirt(_AtEndOfStreamMethod); ILGen.Brtrue(_EndLabel); //declare the local and enable it in the scope of child visiting _FieldLocal = ILGen.DeclareLocal(node.Type); _FieldLocals[node.FieldIndex] = _FieldLocal; _SkipAssignmentLabel = ILGen.DefineLabel(); var assignmentCompleted = ILGen.DefineLabel(); //visit any read node there is Visit(node.ReadNode); //visit any assignment block if (node.AssignmentBlock != null) { Visit(node.AssignmentBlock); } else { Log($"No assignment for {node.FieldIndex}."); } ILGen.Br(assignmentCompleted); ILGen.MarkLabel(_SkipAssignmentLabel); Log($"Assignment skipped."); ILGen.MarkLabel(assignmentCompleted); Log($"Done with {node.FieldIndex}."); _FieldLocal = null; return(node); } finally { _InFieldAssignment = false; } }
public virtual CodeNode VisitFieldAssignment(FieldAssignmentNode node) { var visitedReadNode = Visit(node.ReadNode); var visitedConditionalsBlock = Visit(node.AssignmentBlock); if (visitedReadNode == node.ReadNode && visitedConditionalsBlock == node.AssignmentBlock) { return(node); } else { return(new FieldAssignmentNode(node.Type, node.FieldIndex, visitedReadNode, visitedConditionalsBlock as BlockNode ?? new BlockNode(visitedConditionalsBlock))); } }
public override CodeNode VisitFieldAssignment(FieldAssignmentNode node) { //ensure we're in a FieldAssignmentBlock if (!_InFieldAssignmentBlock) { throw new InvalidOperationException("EndOfStreamCheckNode must occur within a FieldAssignmentBlockNode"); } _InFieldAssignment = true; try { //generate the end of stream check ILGen.Ldloc(_Reader); ILGen.Callvirt(_AtEndOfStreamMethod); ILGen.Brtrue(_EndLabel); //declare the local and enable it in the scope of child visiting _FieldLocal = ILGen.DeclareLocal(node.Type); _FieldLocals[node.FieldIndex] = _FieldLocal; _SkipAssignmentLabel = ILGen.DefineLabel(); //visit any read node there is Visit(node.ReadNode); //visit any assignment block if (node.AssignmentBlock != null) { Visit(node.AssignmentBlock); } //set the skip assignment label with a nop for fun. ILGen.Nop(); ILGen.MarkLabel(_SkipAssignmentLabel); _FieldLocal = null; return(node); } finally { _InFieldAssignment = false; } }