本文整理汇总了C#中Rhino.Context.GetOptimizationLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetOptimizationLevel方法的具体用法?C# Context.GetOptimizationLevel怎么用?C# Context.GetOptimizationLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.Context
的用法示例。
在下文中一共展示了Context.GetOptimizationLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitFromContext
public virtual void InitFromContext(Context cx)
{
SetErrorReporter(cx.GetErrorReporter());
languageVersion = cx.GetLanguageVersion();
generateDebugInfo = (!cx.IsGeneratingDebugChanged() || cx.IsGeneratingDebug());
reservedKeywordAsIdentifier = cx.HasFeature(Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER);
allowMemberExprAsFunctionName = cx.HasFeature(Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME);
strictMode = cx.HasFeature(Context.FEATURE_STRICT_MODE);
warningAsError = cx.HasFeature(Context.FEATURE_WARNING_AS_ERROR);
xmlAvailable = cx.HasFeature(Context.FEATURE_E4X);
optimizationLevel = cx.GetOptimizationLevel();
generatingSource = cx.IsGeneratingSource();
activationNames = cx.activationNames;
// Observer code generation in compiled code :
generateObserverCount = cx.generateObserverCount;
}
示例2: InitStandardObjects
public static ScriptableObject InitStandardObjects(Context cx, ScriptableObject scope, bool @sealed)
{
if (scope == null)
{
scope = new NativeObject();
}
scope.AssociateValue(LIBRARY_SCOPE_KEY, scope);
(new ClassCache()).Associate(scope);
BaseFunction.Init(scope, @sealed);
NativeObject.Init(scope, @sealed);
Scriptable objectProto = ScriptableObject.GetObjectPrototype(scope);
// Function.prototype.__proto__ should be Object.prototype
Scriptable functionProto = ScriptableObject.GetClassPrototype(scope, "Function");
functionProto.SetPrototype(objectProto);
// Set the prototype of the object passed in if need be
if (scope.GetPrototype() == null)
{
scope.SetPrototype(objectProto);
}
// must precede NativeGlobal since it's needed therein
NativeError.Init(scope, @sealed);
NativeGlobal.Init(cx, scope, @sealed);
NativeArray.Init(scope, @sealed);
if (cx.GetOptimizationLevel() > 0)
{
// When optimizing, attempt to fulfill all requests for new Array(N)
// with a higher threshold before switching to a sparse
// representation
NativeArray.SetMaximumInitialCapacity(200000);
}
NativeString.Init(scope, @sealed);
NativeBoolean.Init(scope, @sealed);
NativeNumber.Init(scope, @sealed);
NativeDate.Init(scope, @sealed);
NativeMath.Init(scope, @sealed);
NativeJSON.Init(scope, @sealed);
NativeWith.Init(scope, @sealed);
NativeCall.Init(scope, @sealed);
NativeScript.Init(scope, @sealed);
NativeIterator.Init(scope, @sealed);
// Also initializes NativeGenerator
bool withXml = cx.HasFeature(Context.FEATURE_E4X) && cx.GetE4xImplementationFactory() != null;
// define lazy-loaded properties using their class name
new LazilyLoadedCtor(scope, "RegExp", "org.mozilla.javascript.regexp.NativeRegExp", @sealed, true);
new LazilyLoadedCtor(scope, "Packages", "org.mozilla.javascript.NativeJavaTopPackage", @sealed, true);
new LazilyLoadedCtor(scope, "getClass", "org.mozilla.javascript.NativeJavaTopPackage", @sealed, true);
new LazilyLoadedCtor(scope, "JavaAdapter", "org.mozilla.javascript.JavaAdapter", @sealed, true);
new LazilyLoadedCtor(scope, "JavaImporter", "org.mozilla.javascript.ImporterTopLevel", @sealed, true);
new LazilyLoadedCtor(scope, "Continuation", "org.mozilla.javascript.NativeContinuation", @sealed, true);
foreach (string packageName in GetTopPackageNames())
{
new LazilyLoadedCtor(scope, packageName, "org.mozilla.javascript.NativeJavaTopPackage", @sealed, true);
}
if (withXml)
{
string xmlImpl = cx.GetE4xImplementationFactory().GetImplementationClassName();
new LazilyLoadedCtor(scope, "XML", xmlImpl, @sealed, true);
new LazilyLoadedCtor(scope, "XMLList", xmlImpl, @sealed, true);
new LazilyLoadedCtor(scope, "Namespace", xmlImpl, @sealed, true);
new LazilyLoadedCtor(scope, "QName", xmlImpl, @sealed, true);
}
if (scope is TopLevel)
{
((TopLevel)scope).CacheBuiltins();
}
return scope;
}
示例3: Do_eval
/// <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;
}