Beispiel #1
0
        public override CodeNode VisitSetLengthLocal(SetLengthLocalNode node)
        {
            Log($"Setting length for field {node.LengthFieldIndex}.");
            var arrayFieldLocal  = _FieldLocals[node.ArrayFieldIndex];
            var lengthFieldLocal = _FieldLocals[node.LengthFieldIndex];

            //TODO: this code is duplicated in VisitValidateSharedLengthLocal
            var notNull     = ILGen.DefineLabel();
            var storeLength = ILGen.DefineLabel();

            //if the array is not null, goto notNull
            ILGen.Ldloc(arrayFieldLocal);
            ILGen.Ldnull();
            ILGen.Ceq();
            ILGen.Brfalse(notNull);

            //it is null, treat the length as 0 and compare the length
            Log($"Array is null (treat as zero length).");
            ILGen.Ldc_I4_0();
            ILGen.Br(storeLength);

            //array is not null. get its real length
            ILGen.MarkLabel(notNull);
            Log($"Getting array length.");
            ILGen.Ldloc(arrayFieldLocal);
            ILGen.Ldlen();
            ILGen.Br(storeLength);

            //store the length
            ILGen.MarkLabel(storeLength);
            Log($"Storing array length.");
            ILGen.Stloc(lengthFieldLocal);
            return(node);
        }
Beispiel #2
0
 public override CodeNode VisitSetLengthLocal(SetLengthLocalNode node)
 {
     _Writer.WriteStartElement("SetLengthLocal");
     _Writer.WriteAttributeString("ArrayFieldIndex", node.ArrayFieldIndex.ToString());
     _Writer.WriteAttributeString("LengthFieldIndex", node.LengthFieldIndex.ToString());
     _Writer.WriteEndElement();
     return(node);
 }
Beispiel #3
0
 public virtual CodeNode VisitSetLengthLocal(SetLengthLocalNode node)
 {
     return(node);
 }