Exemple #1
0
        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
                });
            }
        }
Exemple #2
0
        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}");
            }
        }
Exemple #3
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            if (!DMObjectTree.TryGetGlobalProc(_name, out _))
            {
                throw new CompileErrorException(Location, $"There is no global proc named \"{_name}\"");
            }

            return(DMReference.CreateGlobalProc(_name), false);
        }
Exemple #4
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            if (dmObject.HasProc(_identifier))
            {
                return(DMReference.CreateSrcProc(_identifier), false);
            }
            else if (DMObjectTree.TryGetGlobalProc(_identifier, out _))
            {
                return(DMReference.CreateGlobalProc(_identifier), false);
            }

            throw new CompileErrorException(Location, $"Type {dmObject.Path} does not have a proc named \"{_identifier}\"");
        }
Exemple #5
0
        public override (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc)
        {
            DMProc globalProc = GetProc();

            return(DMReference.CreateGlobalProc(globalProc.Id), false);
        }