Example #1
0
 public void Write(ASMultiname multiname)
 {
     if (multiname?.Kind == MultinameKind.TypeName)
     {
         Write(multiname.QName);
         Write(multiname.TypeIndices.Count);
         foreach (ASMultiname type in multiname.GetTypes())
         {
             Write(type);
         }
     }
     else if (multiname == null ||
              HGame.IsValidIdentifier(multiname.Name, true))
     {
         Write(multiname?.Name ?? "*");
     }
 }
Example #2
0
        private bool TryGetPacketValue(ASMultiname multiname, ASClass @class, out PacketValue value)
        {
            ASMultiname returnValueType = multiname;

            if (@class != null)
            {
                returnValueType = GetTraitType(@class, multiname) ?? GetTraitType(@class.Instance, multiname);
            }

            switch (returnValueType.Name.ToLower())
            {
            case "int":
            case "readint":
            case "gettimer": value = PacketValue.Integer; break;

            case "byte":
            case "readbyte": value = PacketValue.Byte; break;

            case "double":
            case "readdouble": value = PacketValue.Double; break;

            case "string":
            case "readstring": value = PacketValue.String; break;

            case "boolean":
            case "readboolean": value = PacketValue.Boolean; break;

            case "array": value = PacketValue.Unknown; break;

            default:
            {
                if (!IsOutgoing && !HGame.IsValidIdentifier(returnValueType.Name, true))
                {
                    value = PacketValue.Integer;         // This reference call is most likely towards 'readInt'
                }
                else
                {
                    value = PacketValue.Unknown;
                }
                break;
            }
            }
            return(value != PacketValue.Unknown);
        }
Example #3
0
        public string GenerateHash()
        {
            if (!string.IsNullOrWhiteSpace(Hash))
            {
                return(Hash);
            }

            using HashWriter output = new HashWriter(false);
            output.Write(IsOutgoing);
            if (!HGame.IsValidIdentifier(Class.QName.Name, true))
            {
                output.Write(Class.Instance, true);
                output.Write(Class.Instance.Constructor);

                output.Write(References.Count);
                foreach (HReference reference in References)
                {
                    output.Write(reference.IsStatic);
                    output.Write(reference.IsAnonymous);

                    output.Write(reference.MethodRank);
                    output.Write(reference.InstructionRank);

                    output.Write(reference.FromMethod);

                    output.Write(reference.FromClass.Constructor);
                    output.Write(reference.FromClass.Instance.Constructor);
                }
                if (!IsOutgoing && Parser != null)
                {
                    output.Write(Parser.Instance, true);
                }
            }
            else
            {
                output.Write(Class.QName.Name);
            }
            return(Hash = output.GenerateHash());
        }
Example #4
0
        public void Write(ASMethod method)
        {
            Write(method.IsConstructor);
            if (!method.IsConstructor)
            {
                Write(method.ReturnType);
            }
            Write(method.Parameters.Count);
            foreach (ASParameter parameter in method.Parameters)
            {
                Write(parameter.Type);
                if (!string.IsNullOrWhiteSpace(parameter.Name) &&
                    HGame.IsValidIdentifier(parameter.Name, true))
                {
                    Write(parameter.Name);
                }
                Write(parameter.IsOptional);
                if (parameter.IsOptional)
                {
                    Write((byte)parameter.ValueKind);
                    Write(parameter.ValueKind, parameter.Value);
                }
            }
            ASCode code = method.Body.ParseCode();

            foreach (OPCode op in code.GetOPGroups().Keys)
            {
                if (op != OPCode.GetLex &&
                    op != OPCode.GetProperty &&
                    op != OPCode.CallProperty)
                {
                    continue;
                }

                Write((byte)op);
            }
        }