private DMReference ReadReference(BinaryReader reader) { DMReference.Type refType = (DMReference.Type)reader.ReadByte(); switch (refType) { case DMReference.Type.Argument: return(DMReference.CreateArgument(reader.ReadByte())); case DMReference.Type.Local: return(DMReference.CreateLocal(reader.ReadByte())); case DMReference.Type.Global: return(DMReference.CreateGlobal(reader.ReadInt32())); case DMReference.Type.GlobalProc: return(DMReference.CreateGlobalProc(reader.ReadInt32())); case DMReference.Type.Field: return(DMReference.CreateField(Program.CompiledJson.Strings[reader.ReadInt32()])); case DMReference.Type.SrcField: return(DMReference.CreateSrcField(Program.CompiledJson.Strings[reader.ReadInt32()])); case DMReference.Type.Proc: return(DMReference.CreateProc(Program.CompiledJson.Strings[reader.ReadInt32()])); case DMReference.Type.SrcProc: return(DMReference.CreateSrcProc(Program.CompiledJson.Strings[reader.ReadInt32()])); default: return(new DMReference() { RefType = refType }); } }
public DMReference ReadReference() { DMReference.Type refType = (DMReference.Type)ReadByte(); switch (refType) { case DMReference.Type.Local: return(DMReference.CreateLocal(ReadByte())); case DMReference.Type.Global: return(DMReference.CreateGlobal(ReadInt())); case DMReference.Type.Field: return(DMReference.CreateField(ReadString())); case DMReference.Type.SrcField: return(DMReference.CreateSrcField(ReadString())); case DMReference.Type.Proc: return(DMReference.CreateProc(ReadString())); case DMReference.Type.GlobalProc: return(DMReference.CreateGlobalProc(ReadString())); case DMReference.Type.SrcProc: return(DMReference.CreateSrcProc(ReadString())); case DMReference.Type.Src: return(DMReference.Src); case DMReference.Type.Self: return(DMReference.Self); case DMReference.Type.Usr: return(DMReference.Usr); case DMReference.Type.Args: return(DMReference.Args); case DMReference.Type.SuperProc: return(DMReference.SuperProc); case DMReference.Type.ListIndex: return(DMReference.ListIndex); default: throw new Exception($"Invalid reference type {refType}"); } }
public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { _expr.EmitPushValue(dmObject, proc); return(DMReference.CreateProc(_field), _conditional); }