Example #1
0
        public string GetUserDefinedName(int id)
        {
            if (UserDefinedName.TryGetValue(id, out var result))
            {
                return(result);
            }
            else
            {
                switch (EplSystemId.GetType(id))
                {
                case EplSystemId.Type_Method:
                    return($"_Sub_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Global:
                    return($"_Global_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_StaticClass:
                    return($"_Mod_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Dll:
                    return($"_Dll_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_ClassMember:
                    return($"_Mem_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Control:
                    return($"_Control_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Constant:
                    return($"_Const_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_FormClass:
                    return($"_FormCls_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Local:
                    return($"_Local_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_ImageResource:
                    return($"_Img_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_SoundResource:
                    return($"_Sound_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_StructMember:
                    return($"_StructMem_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Struct:
                    return($"_Struct_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_DllParameter:
                    return($"_DllParam_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                case EplSystemId.Type_Class:
                    return($"_Cls_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");

                default:
                    return($"_User_0x{id.ToString("X8")}");
                }
            }
        }
Example #2
0
 public string GetUserDefinedName(int id)
 {
     if (UserDefinedName.TryGetValue(id, out var result))
     {
         return(result);
     }
     else if (IdTypeName.TryGetValue(EplSystemId.GetType(id), out result))
     {
         return($"_{result}_0x{(id & EplSystemId.Mask_Num).ToString("X6")}");
     }
     else
     {
         return($"_User_0x{id.ToString("X8")}");
     }
 }
Example #3
0
        private static Expression ParseExpression(BinaryReader reader, Encoding encoding, bool parseMember = true)
        {
            Expression result = null;
            byte       type;

            while (true)
            {
                type = reader.ReadByte();
                switch (type)
                {
                case 0x01:
                    result = ParamListEnd.Instance;
                    break;

                case 0x16:
                    result = DefaultValueExpression.Instance;
                    break;

                case 0x17:
                    result = new NumberLiteral(reader.ReadDouble());
                    break;

                case 0x18:
                    result = BoolLiteral.ValueOf(reader.ReadInt16() != 0);
                    break;

                case 0x19:
                    result = new DateTimeLiteral(DateTime.FromOADate(reader.ReadDouble()));
                    break;

                case 0x1A:
                    result = new StringLiteral(reader.ReadBStr(encoding));
                    break;

                case 0x1B:
                    result = new ConstantExpression(reader.ReadInt32());
                    break;

                case 0x1C:
                    result = new ConstantExpression((short)(reader.ReadInt16() - 1), (short)(reader.ReadInt16() - 1));
                    break;

                case 0x1D:
                    // 0x1D 0x38 <Int32:VarId>
                    continue;

                case 0x1E:
                    result = new MethodPtrExpression(reader.ReadInt32());
                    break;

                case 0x21:
                    result = ParseCallExpressionWithoutType(reader, encoding);
                    break;

                case 0x23:
                    result = new EmnuConstantExpression((short)(reader.ReadInt16() - 1), (short)(reader.ReadInt16() - 1), reader.ReadInt32() - 1);
                    break;

                case 0x37:
                    continue;

                case 0x1F:
                {
                    var        array = new ArrayLiteralExpression();
                    Expression exp;
                    while (!((exp = ParseExpression(reader, encoding)) is ArrayLiteralEnd))
                    {
                        array.Add(exp);
                    }
                    result = array;
                }
                break;

                case 0x20:
                    result = ArrayLiteralEnd.Instance;
                    break;

                case 0x38:     // ThisCall Or 访问变量
                {
                    int variable = reader.ReadInt32();
                    if (variable == 0x0500FFFE)
                    {
                        reader.ReadByte();         // 0x3A
                        return(ParseExpression(reader, encoding, true));
                    }
                    else
                    {
                        result      = new VariableExpression(variable);
                        parseMember = true;
                    }
                }
                break;

                case 0x3B:
                    result = new NumberLiteral(reader.ReadInt32());
                    break;

                default:
                    throw new Exception($"Unknown Type: {type.ToString("X2")}");
                }
                break;
            }
            if (parseMember &&
                (result is VariableExpression ||
                 result is CallExpression ||
                 result is AccessMemberExpression ||
                 result is AccessArrayExpression))
            {
                while (reader.BaseStream.Position != reader.BaseStream.Length)
                {
                    switch (reader.ReadByte())
                    {
                    case 0x39:
                        int memberId = reader.ReadInt32();
                        if (EplSystemId.GetType(memberId) == EplSystemId.Type_StructMember)
                        {
                            result = new AccessMemberExpression(result, reader.ReadInt32(), memberId);
                        }
                        else
                        {
                            result = new AccessMemberExpression(result, (short)(reader.ReadInt16() - 1), (short)(reader.ReadInt16() - 1), memberId - 1);
                        }
                        break;

                    case 0x3A:
                        result = new AccessArrayExpression(result, ParseExpression(reader, encoding, false));
                        break;

                    case 0x37:
                        goto parse_member_finish;

                    default:
                        reader.BaseStream.Position -= 1;
                        goto parse_member_finish;
                    }
                }
            }
parse_member_finish:
            return(result);
        }