public override CodeNode VisitSkipArrayAssignmentIfLengthIsZero(SkipArrayAssignmentIfLengthIsZeroNode node) { _Writer.WriteStartElement("SkipArrayAssignmentIfLengthIsZero"); _Writer.WriteAttributeString("LengthIndex", node.LengthIndex.ToString()); _Writer.WriteEndElement(); return(node); }
CodeNode GenerateArrayAssignment(KeyValuePair <FieldLayoutAttribute, PropertyInfo> pair) { var fieldType = pair.Key.FieldType; bool isNibbleArray = pair.Key is NibbleArrayFieldLayoutAttribute; int lengthIndex = ((ArrayFieldLayoutAttribute)pair.Key).ArrayLengthFieldIndex; //we can skip entirely if the length field was zero //we'll combine this as part of the "reading" of the field var parseConditionNode = new SkipArrayAssignmentIfLengthIsZeroNode(lengthIndex); //find out if we should even parse this field if (pair.Value != null && !ShouldParseField(pair.Value.Name)) { //we can simply return this skip node since it effectively encapsulates the length check as well return(new SkipTypeNode(fieldType.MakeArrayType(), lengthIndex)); } else { var readNode = new ReadTypeNode(fieldType.MakeArrayType(), lengthIndex, isNibble: isNibbleArray); BlockNode assignmentBlock = null; if (pair.Value != null) { assignmentBlock = new BlockNode(new AssignFieldToPropertyNode(fieldType.MakeArrayType(), pair.Value)); } //return a FieldAssignmentNode. Note we're combining the parseConditionNode and the readNode. return(new FieldAssignmentNode(fieldType.MakeArrayType(), pair.Key.FieldIndex, new BlockNode(parseConditionNode, readNode), assignmentBlock)); } }
public override CodeNode VisitSkipArrayAssignmentIfLengthIsZero(SkipArrayAssignmentIfLengthIsZeroNode node) { if (!_InFieldAssignment) { throw new InvalidOperationException("SkipArrayAssignmentIfLengthIsZeroNode must be in a FieldAssignmentNode"); } //If the length field is zero, skip past assignment var lengthLocal = _FieldLocals[node.LengthIndex]; ILGen.Ldloc(lengthLocal); ILGen.Brfalse(_SkipAssignmentLabel); return(node); }
public virtual CodeNode VisitSkipArrayAssignmentIfLengthIsZero(SkipArrayAssignmentIfLengthIsZeroNode node) { return(node); }