Пример #1
0
        public ILBlockTranslator(AssemblyTranslator translator, DecompilerContext context, MethodReference methodReference, MethodDefinition methodDefinition, ILBlock ilb, IEnumerable<ILVariable> parameters, IEnumerable<ILVariable> allVariables)
        {
            Translator = translator;
            Context = context;
            ThisMethodReference = methodReference;
            ThisMethod = methodDefinition;
            Block = ilb;

            SpecialIdentifiers = new JSIL.SpecialIdentifiers(TypeSystem);

            if (methodReference.HasThis)
                Variables.Add("this", JSThisParameter.New(methodReference.DeclaringType, methodReference));

            foreach (var parameter in parameters) {
                if ((parameter.Name == "this") && (parameter.OriginalParameter.Index == -1))
                    continue;

                ParameterNames.Add(parameter.Name);
                Variables.Add(parameter.Name, new JSParameter(parameter.Name, parameter.Type, methodReference));
            }

            foreach (var variable in allVariables) {
                var v = JSVariable.New(variable, methodReference);
                if (Variables.ContainsKey(v.Identifier)) {
                    v = new JSVariable(variable.OriginalVariable.Name, variable.Type, methodReference);
                    RenamedVariables[variable] = v;
                    Variables.Add(v.Identifier, v);
                } else {
                    Variables.Add(v.Identifier, v);
                }
            }
        }
Пример #2
0
 public JavascriptAssemblyEmitter (
     AssemblyTranslator assemblyTranslator,
     JavascriptFormatter formatter
 ) {
     Translator = assemblyTranslator;
     Formatter = formatter;
 }
Пример #3
0
 public IAssemblyEmitter MakeAssemblyEmitter(AssemblyTranslator translator, AssemblyDefinition assembly, JavascriptFormatter formatter)
 {
     if (translator.IsStubbed(assembly) || translator.IsIgnored(assembly))
         return new NullAssemblyEmitter();
     else
         return new WasmSExprAssemblyEmitter(translator, assembly, formatter);
 }
Пример #4
0
 public JavascriptAssemblyEmitter (
     AssemblyTranslator assemblyTranslator,
     JavascriptFormatter formatter,
     IDictionary<AssemblyManifest.Token, string> referenceOverrides
 ) {
     Translator = assemblyTranslator;
     Formatter = formatter;
     _referenceOverrides = referenceOverrides;
 }
Пример #5
0
        bool IAnalyzer.ShouldSkipMember(AssemblyTranslator translator, MemberReference member)
        {
            var result = ShouldSkipMember(member);

            if (result.Item1)
                Warn(translator, member, result.Item2);

            return result.Item1;
        }
Пример #6
0
 public IAssemblyEmitter MakeAssemblyEmitter(
     AssemblyTranslator translator,
     AssemblyDefinition assembly,
     JavascriptFormatter formatter,
     IDictionary<AssemblyManifest.Token, string> referenceOverrides
 )
 {
     if (translator.IsStubbed(assembly) || translator.IsIgnored(assembly))
         return new NullAssemblyEmitter();
     else
         return new WasmSExprAssemblyEmitter(translator, assembly, formatter);
 }
Пример #7
0
        private bool ShouldSilence(AssemblyTranslator translator, MemberReference member)
        {
            var typeInfo = translator.TypeInfoProvider.GetTypeInformation(member.DeclaringType);
            if (typeInfo.IsIgnored || typeInfo.IsExternal)
                return true;

            var asm = member.DeclaringType.Module.Assembly;
            if (translator.IsStubbed(asm) || translator.IsIgnored(asm))
                return true;

            return false;
        }
Пример #8
0
        private void Warn(AssemblyTranslator translator, MemberReference member, string reason)
        {
            if (ShouldSilence(translator, member))
                return;

            if (PreviousWarnings.Contains(member.FullName))
                return;

            PreviousWarnings.Add(member.FullName);
            Console.WriteLine("// Skipping {0}: {1}", member.Name, reason);
        }
Пример #9
0
 public void Analyze(AssemblyTranslator translator, AssemblyDefinition[] assemblies, TypeInfoProvider typeInfoProvider)
 {
 }
Пример #10
0
 public WasmSExprAssemblyEmitter(AssemblyTranslator translator, AssemblyDefinition assembly, JavascriptFormatter formatter)
 {
     Translator = translator;
     Assembly = assembly;
     Formatter = formatter;
 }