SetOptimizationLevel() public method

Set the current optimization level.
Set the current optimization level.

The optimization level is expected to be an integer between -1 and 9. Any negative values will be interpreted as -1, and any values greater than 9 will be interpreted as 9. An optimization level of -1 indicates that interpretive mode will always be used. Levels 0 through 9 indicate that class files may be generated. Higher optimization levels trade off compile time performance for runtime performance. The optimizer level can't be set greater than -1 if the optimizer package doesn't exist at run time.

public SetOptimizationLevel ( int optimizationLevel ) : void
optimizationLevel int /// an integer indicating the level of /// optimization to perform ///
return void
Exemplo n.º 1
0
		protected internal override void OnContextCreated(Context cx)
		{
			cx.SetLanguageVersion(languageVersion);
			cx.SetOptimizationLevel(optimizationLevel);
			if (errorReporter != null)
			{
				cx.SetErrorReporter(errorReporter);
			}
			cx.SetGeneratingDebug(generatingDebug);
			base.OnContextCreated(cx);
		}
Exemplo n.º 2
0
			// ContextFactory.Listener
			/// <summary>Called when a Context is created.</summary>
			/// <remarks>Called when a Context is created.</remarks>
			public virtual void ContextCreated(Context cx)
			{
				if (type != IPROXY_LISTEN)
				{
					Kit.CodeBug();
				}
				Dim.ContextData contextData = new Dim.ContextData();
				Rhino.Debug.Debugger debugger = new Dim.DimIProxy(dim, IPROXY_DEBUG);
				cx.SetDebugger(debugger, contextData);
				cx.SetGeneratingDebug(true);
				cx.SetOptimizationLevel(-1);
			}
Exemplo n.º 3
0
		/// <summary>Evaluates script in the given stack frame.</summary>
		/// <remarks>Evaluates script in the given stack frame.</remarks>
		private static string Do_eval(Context cx, Dim.StackFrame frame, string expr)
		{
			string resultString;
			Rhino.Debug.Debugger saved_debugger = cx.GetDebugger();
			object saved_data = cx.GetDebuggerContextData();
			int saved_level = cx.GetOptimizationLevel();
			cx.SetDebugger(null, null);
			cx.SetOptimizationLevel(-1);
			cx.SetGeneratingDebug(false);
			try
			{
				Callable script = (Callable)cx.CompileString(expr, string.Empty, 0, null);
				object result = script.Call(cx, frame.scope, frame.thisObj, ScriptRuntime.emptyArgs);
				if (result == Undefined.instance)
				{
					resultString = string.Empty;
				}
				else
				{
					resultString = ScriptRuntime.ToString(result);
				}
			}
			catch (Exception exc)
			{
				resultString = exc.Message;
			}
			finally
			{
				cx.SetGeneratingDebug(true);
				cx.SetOptimizationLevel(saved_level);
				cx.SetDebugger(saved_debugger, saved_data);
			}
			if (resultString == null)
			{
				resultString = "null";
			}
			return resultString;
		}
Exemplo n.º 4
0
			public object Run(Context context)
			{
				context.SetOptimizationLevel(optimizationLevel);
				return Context.ToString(action.Run(context));
			}
Exemplo n.º 5
0
		public virtual void SetUp()
		{
			cx = Context.Enter();
			cx.SetOptimizationLevel(-1);
			scope = cx.InitStandardObjects();
		}