示例#1
0
        public override StringMangleStackTop?Emit(IStringMangleContext context)
        {
            var emitter = context.Emitter;
            var fr      = new FeatureRequest(Context, emitter);

            using (var r = fr.Enter(context.SourceMethod))
                if (r != null)
                {
                    ValueDemangler cdm;
                    do
                    {
                        cdm = _demanglers.RandomElementOrDefault(Mangler.Rng);
                    } while (fr.IsOnStack(cdm.Method.Method));

                    var part = context.Pieces.Dequeue();
                    using (emitter.UseTempLocal(cdm.Method.Type.TypeMapping.Target.ToTypeSig(), out var instance))
                    {
                        cdm.EmitNew(emitter, Mangler.Rng, instance);
                        var mangledPart = cdm.Codec.Mangle(part.Value);
                        Debug.Assert(Equals(cdm.Codec.Demangle(mangledPart), part.Value));
                        cdm.EmitCall(emitter, Mangler.Rng, instance, mangledPart);
                    }

                    return(StringMangleStackTop.String);
                }

            return(null);
        }
示例#2
0
        public override StringMangleStackTop?Emit(IStringMangleContext context)
        {
            var part = context.Pieces.Peek();

            if (part.Bits * part.Value.Length > 32)
            {
                return(null);
            }
            var emitter = context.Emitter;
            var fr      = new FeatureRequest(Context, emitter);

            using (var r = fr.Enter(context.SourceMethod))
                if (r != null)
                {
                    part = context.Pieces.Dequeue();
                    var be = context.Mangler.Rng.NextBoolean();
                    var i  = SmUtils.String2Int(part.Value, part.Bits, be);
                    Context.IntMangler().Emit(fr, i);
                    return(SmUtils.Int2String(context, part.Value.Length, part.Bits,
                                              be));
                }
            return(null);
        }