internal override void ProcessMainAttributes (IDictionary atts) { autoEventWireup = GetBool (atts, "AutoEventWireup", autoEventWireup); enableViewState = GetBool (atts, "EnableViewState", enableViewState); string value = GetString (atts, "CompilationMode", compilationMode.ToString ()); if (!String.IsNullOrEmpty (value)) { try { compilationMode = (CompilationMode) Enum.Parse (typeof (CompilationMode), value, true); } catch (Exception ex) { ThrowParseException ("Invalid value of the CompilationMode attribute.", ex); } } atts.Remove ("TargetSchema"); // Ignored #if NET_4_0 value = GetString (atts, "ClientIDMode", null); if (!String.IsNullOrEmpty (value)) { try { clientIDMode = (ClientIDMode) Enum.Parse (typeof (ClientIDMode), value, true); } catch (Exception ex) { ThrowParseException ("Invalid value of the ClientIDMode attribute.", ex); } } #endif base.ProcessMainAttributes (atts); }
public PythonAst(Statement body, bool isModule, ModuleOptions languageFeatures, bool printExpressions, CompilerContext context) { ContractUtils.RequiresNotNull(body, "body"); _body = body; _isModule = isModule; _printExpressions = printExpressions; _languageFeatures = languageFeatures; _mode = ((PythonCompilerOptions)context.Options).CompilationMode ?? GetCompilationMode(context); _compilerContext = context; FuncCodeExpr = _functionCode; PythonCompilerOptions pco = context.Options as PythonCompilerOptions; Debug.Assert(pco != null); string name; if (!context.SourceUnit.HasPath || (pco.Module & ModuleOptions.ExecOrEvalCode) != 0) { name = "<module>"; } else { name = context.SourceUnit.Path; } _name = name; Debug.Assert(_name != null); PythonOptions po = ((PythonContext)context.SourceUnit.LanguageContext).PythonOptions; if (po.EnableProfiler && _mode != CompilationMode.ToDisk) { _profiler = Profiler.GetProfiler(PyContext); } _document = context.SourceUnit.Document ?? Ast.SymbolDocument(name, PyContext.LanguageGuid, PyContext.VendorGuid); }
public DynamicGetMemberExpression(PythonGetMemberBinder/*!*/ binder, CompilationMode/*!*/ mode, MSAst.Expression/*!*/ target, MSAst.Expression codeContext) { Assert.NotNull(binder, mode, target, codeContext); _binder = binder; _mode = mode; _target = target; _codeContext = codeContext; }
internal override void LoadConfigDefaults () { base.LoadConfigDefaults (); PagesSection ps = PagesConfig; autoEventWireup = ps.AutoEventWireup; enableViewState = ps.EnableViewState; compilationMode = ps.CompilationMode; }
/// <summary> /// Default ctor /// </summary> public AssemblyCompiler(CompilationMode mode, List<AssemblyDefinition> assemblies, List<AssemblyDefinition> references, Table resources, NameConverter nameConverter, bool generateDebugInfo, AssemblyClassLoader assemblyClassLoader, HashSet<string> rootClassNames, XModule module) { this.mode = mode; this.assemblies = assemblies; this.references = references; this.resources = resources; this.generateDebugInfo = generateDebugInfo; this.assemblyClassLoader = assemblyClassLoader; this.rootClassNames = rootClassNames; this.module = module; targetPackage = new Target.Dex.DexTargetPackage(nameConverter, this); }
internal override void LoadConfigDefaults () { base.LoadConfigDefaults (); #if NET_2_0 PagesSection ps = PagesConfig; #else PagesConfiguration ps = PagesConfig; #endif #if NET_1_1 autoEventWireup = ps.AutoEventWireup; enableViewState = ps.EnableViewState; #endif #if NET_2_0 compilationMode = ps.CompilationMode; #endif }
public void ApplyCompilationMode(CompilationMode compilationMode) { switch (compilationMode) { case CompilationMode.Debug: case CompilationMode.Testing: Debug = true; OptimizationLevel = 0; break; case CompilationMode.Release: Debug = true; OptimizationLevel = 1; break; case CompilationMode.AppStore: Debug = false; OptimizationLevel = 2; break; } }
/// <summary> /// TODO: the list of parameters has gotten way to long. /// </summary> public AssemblyCompiler(CompilationMode mode, List<AssemblyDefinition> assemblies, List<AssemblyDefinition> references, Table resources, NameConverter nameConverter, bool generateDebugInfo, AssemblyClassLoader assemblyClassLoader, Func<AssemblyDefinition, string> assemblyToFilename, DexMethodBodyCompilerCache ccache, HashSet<string> rootClassNames, XModule module, bool generateSetNextInstructionCode) { this.mode = mode; this.assemblies = assemblies; this.references = references; this.resources = resources; this.generateDebugInfo = generateDebugInfo; this.assemblyClassLoader = assemblyClassLoader; this.assemblyToFilename = assemblyToFilename; this.rootClassNames = rootClassNames; this.module = module; this.generateSetNextInstructionCode = generateDebugInfo && generateSetNextInstructionCode; targetPackage = new Target.Dex.DexTargetPackage(nameConverter, this); methodBodyCompilerCache = ccache; StopAtFirstError = true; }
static DecompilerTestCase CreateTestCase (MethodInfo method, CompiledTestCaseAttribute attribute, CompilationMode mode) { var test_case = new DecompilerTestCase (method, mode); test_case.Language = attribute.GetLanguage (); test_case.Compiler = attribute.CreateCompiler (); test_case.CompilerParameters = attribute.CreateParamaters (); if (mode == CompilationMode.Release) test_case.CompilerParameters.CompilerOptions = "/optimize+"; else test_case.CompilerParameters.CompilerOptions = "/debug+ /optimize-"; test_case.SourceFile = GetTestCaseFile (attribute.SourceFile ?? GetDefaultSourceFile (method, attribute)); test_case.ExpectedResultFile = GetTestCaseFile (attribute.ExpectedResultFile ?? GetDefaultExpectedResultFile (method, attribute)); test_case.MethodName = attribute.MethodName ?? GetDefaultMethodName (method); test_case.CompilerParameters.OutputAssembly = test_case.ExpectedResultFile + "." + mode + ".dll"; return test_case; }
/// <summary> /// Creates a new AstGenerator for top-level (module) code. /// </summary> internal AstGenerator(CompilationMode mode, CompilerContext/*!*/ context, SourceSpan span, string name, bool generator, bool print) : this(name, generator, null, print) { Assert.NotNull(context); _context = context; _pythonContext = (PythonContext)context.SourceUnit.LanguageContext; _document = _context.SourceUnit.Document ?? Ast.SymbolDocument(name, PyContext.LanguageGuid, PyContext.VendorGuid); _funcCodeExpr.Code = _functionCode; switch (mode) { case CompilationMode.Collectable: _globals = new ArrayGlobalAllocator(_pythonContext); break; case CompilationMode.Lookup: _globals = new DictionaryGlobalAllocator(); break; case CompilationMode.ToDisk: _globals = new SavableGlobalAllocator(_pythonContext); break; case CompilationMode.Uncollectable: _globals = new SharedGlobalAllocator(_pythonContext); break; } PythonOptions po = (_pythonContext.Options as PythonOptions); Assert.NotNull(po); if (po.EnableProfiler && mode != CompilationMode.ToDisk) { _profiler = Profiler.GetProfiler(PyContext); if (mode == CompilationMode.Lookup) { _profilerName = NameForExec; } } }
public override CompilationMode GetCompilationMode(CompilationMode current) { return current; }
public override CompilationMode GetCompilationMode(CompilationMode current) { return(CompilationMode.Auto); }
// Allows the filter to return the compilation mode for the page. // If it doesn't want to modify it, it can just return current. public virtual CompilationMode GetCompilationMode(CompilationMode current) { return(current); }
public void SetCompilationMode(CompilationMode compilationMode) { effectCompilerParameters.ApplyCompilationMode(compilationMode); }
public virtual CompilationMode GetCompilationMode(CompilationMode current) {}
public virtual CompilationMode GetCompilationMode (CompilationMode current) { throw new NotImplementedException (); }
/// <summary> /// Returns a ScriptCode object for this PythonAst. The ScriptCode object /// can then be used to execute the code against it's closed over scope or /// to execute it against a different scope. /// </summary> internal ScriptCode ToScriptCode() { return(CompilationMode.MakeScriptCode(this)); }
internal ScriptCode/*!*/ TransformToAst(CompilationMode mode, CompilerContext/*!*/ context) { // Create the ast generator // Use the PrintExpression value for the body (global level code) PythonCompilerOptions pco = context.Options as PythonCompilerOptions; Debug.Assert(pco != null); string name; if (!context.SourceUnit.HasPath || (pco.Module & ModuleOptions.ExecOrEvalCode) != 0) { name = "<module>"; } else { name = context.SourceUnit.Path; } AstGenerator ag = new AstGenerator(mode, context, _body.Span, name, false, _printExpressions); MSAst.Expression body = Ast.Block( Ast.Call( AstGenerator.GetHelperMethod("ModuleStarted"), ag.LocalContext, AstUtils.Constant(ag.BinderState, typeof(object)), AstUtils.Constant(_languageFeatures) ), ag.UpdateLineNumber(0), ag.UpdateLineUpdated(false), ag.WrapScopeStatements(Transform(ag)), // new ComboActionRewriter().VisitNode(Transform(ag)) AstUtils.Empty() ); if (_isModule) { string moduleName = pco.ModuleName; if (moduleName == null) { #if !SILVERLIGHT if (context.SourceUnit.HasPath && context.SourceUnit.Path.IndexOfAny(Path.GetInvalidFileNameChars()) == -1) { moduleName = Path.GetFileNameWithoutExtension(context.SourceUnit.Path); #else if (context.SourceUnit.HasPath) { moduleName = context.SourceUnit.Path; #endif } else { moduleName = "<module>"; } } Debug.Assert(moduleName != null); body = Ast.Block( ag.Globals.Assign(ag.Globals.GetVariable(ag, _fileVariable), Ast.Constant(name)), ag.Globals.Assign(ag.Globals.GetVariable(ag, _nameVariable), Ast.Constant(moduleName)), body // already typed to void ); if ((pco.Module & ModuleOptions.Initialize) != 0) { MSAst.Expression tmp = ag.HiddenVariable(typeof(object), "$originalModule"); // TODO: Should be try/fault body = AstUtils.Try( Ast.Assign(tmp, Ast.Call(AstGenerator.GetHelperMethod("PublishModule"), ag.LocalContext, Ast.Constant(moduleName))), body ).Catch( typeof(Exception), Ast.Call(AstGenerator.GetHelperMethod("RemoveModule"), ag.LocalContext, Ast.Constant(moduleName), tmp), Ast.Rethrow(body.Type) ); } } body = ag.AddProfiling(body); body = ag.AddReturnTarget(body); if (body.Type == typeof(void)) { body = Ast.Block(body, Ast.Constant(null)); } return ag.MakeScriptCode(body, context, this); }
public virtual CompilationMode GetCompilationMode (CompilationMode current) { return current; }
public PythonConstantExpression(CompilationMode mode, object value) { _mode = mode; _value = value; }
public override CompilationMode GetCompilationMode(CompilationMode current) { return CompilationMode.Auto; }
public DynamicConvertExpression(PythonConversionBinder binder, CompilationMode mode, MSAst.Expression target) { _binder = binder; _mode = mode; _target = target; }
public virtual new CompilationMode GetCompilationMode(CompilationMode current) { return default(CompilationMode); }
internal override void ProcessMainAttributes (Hashtable atts) { autoEventWireup = GetBool (atts, "AutoEventWireup", autoEventWireup); enableViewState = GetBool (atts, "EnableViewState", enableViewState); #if NET_2_0 string cmode = GetString (atts, "CompilationMode", compilationMode.ToString ()); if (!String.IsNullOrEmpty (cmode)) { if (String.Compare (cmode, "always", StringComparison.InvariantCultureIgnoreCase) == 0) compilationMode = CompilationMode.Always; else if (String.Compare (cmode, "auto", StringComparison.InvariantCultureIgnoreCase) == 0) compilationMode = CompilationMode.Auto; else if (String.Compare (cmode, "never", StringComparison.InvariantCultureIgnoreCase) == 0) compilationMode = CompilationMode.Never; else ThrowParseException ("Invalid value of the CompilationMode attribute"); } #endif atts.Remove ("TargetSchema"); // Ignored base.ProcessMainAttributes (atts); }
public CompilerEnvironment() { AssemblyNameResolution = CST.AssemblyNameResolution.Name; BreakOnBreak = false; DebugTraceFileName = null; DebugMode = false; CompilationMode = CompilationMode.Plain; DebugLevel = 0; PrettyPrint = false; CLRArraySemantics = true; CLRNullVirtcallSemantics = true; CLRInteropExceptions = true; SafeInterop = true; Root = "IL2JSC"; ReferenceFileNames = new Seq<string>(); CompileFileNames = new Seq<string>(); InputDirectory = "."; OutputDirectory = null; LoadPaths = new Seq<string>(); SkipUpToDate = false; Target = Target.Browser; RenameRules = new Seq<CST.RenameRule>(); AugmentationFileNames = new Seq<string>(); OriginalStrongNames = new Seq<string>(); InitialTraceFileName = null; TraceFileNames = new Seq<string>(); FinalTraceName = null; ImportInlineThreshold = 15; InlineThreshold = 15; NoWarns = new Set<string>(); }
internal AstGenerator(CompilationMode mode, CompilerContext/*!*/ context, SourceSpan span, string name, bool generator, bool print) : this(name, generator, null, print) { Assert.NotNull(context); _context = context; _binderState = new BinderState(Binder); _document = _context.SourceUnit.Document; LanguageContext pc = context.SourceUnit.LanguageContext; switch (mode) { case CompilationMode.Collectable: _globals = new ArrayGlobalAllocator(pc); break; case CompilationMode.Lookup: _globals = new DictionaryGlobalAllocator(); break; case CompilationMode.ToDisk: _globals = new SavableGlobalAllocator(pc); break; case CompilationMode.Uncollectable: _globals = new StaticGlobalAllocator(pc, name); break; } PythonOptions po = (pc.Options as PythonOptions); Assert.NotNull(po); if (po.EnableProfiler && mode != CompilationMode.ToDisk) { _profiler = Profiler.GetProfiler(PythonContext); if (mode == CompilationMode.Lookup) { _profilerName = NameForExec; } } }
public DecompilerTestCase (MethodInfo method, CompilationMode mode) : base (method) { this.TestName.Name = method.Name + "." + mode; this.TestName.FullName = this.TestName.Name; }
internal override Microsoft.Scripting.Ast.LightLambdaExpression GetLambda() { string name = ((PythonCompilerOptions)_compilerContext.Options).ModuleName ?? "<unnamed>"; return(CompilationMode.ReduceAst(this, name)); }