Ejemplo n.º 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;

            JS = new JSSpecialIdentifiers(TypeSystem);
            JSIL = new JSILIdentifier(TypeSystem, JS);
            CLR = new CLRSpecialIdentifiers(TypeSystem);

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

            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));
            }

            foreach (var variable in allVariables) {
                var v = JSVariable.New(variable);
                if (Variables.ContainsKey(v.Identifier)) {
                    v = new JSVariable(variable.OriginalVariable.Name, variable.Type);
                    RenamedVariables[variable] = v;
                    Variables.Add(v.Identifier, v);
                } else {
                    Variables.Add(v.Identifier, v);
                }
            }
        }
            public DefinitelyTypedEmptyAstEmitter(
                JavascriptFormatter output, JSILIdentifier jsil,
                TypeSystem typeSystem, ITypeInfoSource typeInfo,
                Configuration configuration
                )
            {
                //Configuration = configuration;
                //Output = output;
                //JSIL = jsil;
                TypeSystem = typeSystem;
                //TypeInfo = typeInfo;

                //IncludeTypeParens.Push(false);
                //PassByRefStack.Push(false);
                //OverflowCheckStack.Push(false);

                //VisitNestedFunctions = true;

                /*if (output.SourceMapBuilder != null)
                 * {
                 *  BeforeNodeProcessed += AddSourceMapInfo;
                 *  //AfterNodeProcessed += AddSourceMapInfoEnd;
                 * }*/
                ReferenceContext = new TypeReferenceContext();
            }
Ejemplo n.º 3
0
 public SpecialIdentifiers(MethodTypeFactory methodTypes, TypeSystem typeSystem, ITypeInfoSource typeInfo)
 {
     TypeSystem = typeSystem;
     JS         = new JSSpecialIdentifiers(methodTypes, typeSystem);
     CLR        = new CLRSpecialIdentifiers(typeSystem);
     JSIL       = new JSILIdentifier(methodTypes, typeSystem, typeInfo, JS);
 }
Ejemplo n.º 4
0
 public IAstEmitter MakeAstEmitter(
     JSILIdentifier jsil, TypeSystem typeSystem, TypeInfoProvider typeInfoProvider, Configuration configuration
     )
 {
     return(new JavascriptAstEmitter(
                Formatter, jsil, typeSystem, typeInfoProvider, configuration
                ));
 }
Ejemplo n.º 5
0
 public JavascriptAstEmitter(JavascriptFormatter output, JSILIdentifier jsil, TypeSystem typeSystem, ITypeInfoSource typeInfo)
 {
     Output     = output;
     JSIL       = jsil;
     TypeSystem = typeSystem;
     TypeInfo   = typeInfo;
     IncludeTypeParens.Push(false);
 }
Ejemplo n.º 6
0
 public IAstEmitter MakeAstEmitter (
     JSILIdentifier jsil, TypeSystem typeSystem, TypeInfoProvider typeInfoProvider, Configuration configuration
 ) {
     return new JavascriptAstEmitter(
         Formatter, jsil, typeSystem, typeInfoProvider, configuration
     );
 }
Ejemplo n.º 7
0
 public SpecialIdentifiers(MethodTypeFactory methodTypes, TypeSystem typeSystem)
 {
     TypeSystem = typeSystem;
     JS = new JSSpecialIdentifiers(methodTypes, typeSystem);
     CLR = new CLRSpecialIdentifiers(typeSystem);
     JSIL = new JSILIdentifier(methodTypes, typeSystem, JS);
 }
Ejemplo n.º 8
0
 public SpecialIdentifiers(TypeSystem typeSystem)
 {
     TypeSystem = typeSystem;
     JS = new JSSpecialIdentifiers(typeSystem);
     CLR = new CLRSpecialIdentifiers(typeSystem);
     JSIL = new JSILIdentifier(typeSystem, JS);
 }
Ejemplo n.º 9
0
        protected void TranslateModule(DecompilerContext context, JavascriptFormatter output, ModuleDefinition module, List<Action> initializer, HashSet<TypeDefinition> sealedTypes, bool stubbed)
        {
            var moduleInfo = TypeInfoProvider.GetModuleInformation(module);
            if (moduleInfo.IsIgnored)
                return;

            context.CurrentModule = module;

            var js = new JSSpecialIdentifiers(context.CurrentModule.TypeSystem);
            var jsil = new JSILIdentifier(context.CurrentModule.TypeSystem, js);

            // Probably should be an argument, not a member variable...
            AstEmitter = new JavascriptAstEmitter(
                output, jsil, context.CurrentModule.TypeSystem, this.TypeInfoProvider
            );

            foreach (var typedef in module.Types)
                ForwardDeclareType(context, output, typedef);

            foreach (var typedef in module.Types) {
                TranslateTypeDefinition(context, output, typedef, initializer, stubbed);
                SealType(context, output, typedef, sealedTypes);
            }
        }
 public virtual IAstEmitter MakeAstEmitter(JSILIdentifier jsil, TypeSystem typeSystem, TypeInfoProvider typeInfoProvider, Configuration configuration)
 {
     return(new DefinitelyTypedEmptyAstEmitter(
                Formatter, jsil, typeSystem, typeInfoProvider, configuration
                ));
 }
Ejemplo n.º 11
0
 public IAstEmitter MakeAstEmitter(JSILIdentifier jsil, TypeSystem typeSystem, TypeInfoProvider typeInfoProvider, Configuration configuration)
 {
     return new AstEmitter(this, Formatter, jsil, typeSystem, typeInfoProvider, configuration, isTopLevel: false);
 }
Ejemplo n.º 12
0
 public IAstEmitter MakeAstEmitter(JSILIdentifier jsil, TypeSystem typeSystem, TypeInfoProvider typeInfoProvider, Configuration configuration)
 {
     return new NullAstEmitter(typeSystem);
 }