コード例 #1
0
        private void loadObjectDescriptors(System.IO.Stream stream, SmalltalkArchive archive)
        {
            long objectId = 0;
            var  objects  = DefaultObjects;

            while ((objectId = readInteger(stream)) != NUL)
            {
                var classId = readInteger(stream);
                var size    = (int)readInteger(stream);
                var @class  = archive.Classes[classId];
                var hash    = readInteger(stream);

                if (@class.IsBytes)
                {
                    var bytes = new byte[size];
                    stream.Read(bytes, 0, size);
                    var obj = new SmalltalkBytesObject(objectId, size, hash, @class, bytes);
                    objects.Add(objectId, obj);
                }
                else if (@class.IsVariable)
                {
                    var obj = new SmalltalkVariableObject(objectId, size, hash, @class);
                    loadInstVarIds(stream, archive, obj, size);
                    objects.Add(objectId, obj);
                }
                else
                {
                    var obj = new SmalltalkPointerObject(objectId, size, hash, @class);
                    loadInstVarIds(stream, archive, obj, size);
                    objects.Add(objectId, obj);
                }
            }
            archive.Objects = objects;
        }
 private void Export(SmalltalkVariableObject variable, XElement xmlObject)
 {
     for (int i = 0; i < variable.InstVars.Count; i++)
     {
         var nodeName = "Value";
         var value    = variable.InstVars[i];
         if (value.HasObjectValue)
         {
             xmlObject.Add(new XElement(nodeName, new XAttribute("refid", value.ObjectId)));
         }
         else if (value.HasLongValue)
         {
             xmlObject.Add(new XElement(nodeName, new XAttribute("int", value.LongValue)));
         }
         else if (value.HasCharValue)
         {
             xmlObject.Add(new XElement(nodeName, new XAttribute("char", value.CharValue)));
         }
         else
         {
             throw new NotImplementedException($"Unexpected value {value.Value}");
         }
     }
 }