本文整理汇总了C#中EcmaScript.NET.Context.CompileString方法的典型用法代码示例。如果您正苦于以下问题:C# Context.CompileString方法的具体用法?C# Context.CompileString怎么用?C# Context.CompileString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcmaScript.NET.Context
的用法示例。
在下文中一共展示了Context.CompileString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evalSpecial
/// <summary> The eval function property of the global object.
///
/// See ECMA 15.1.2.1
/// </summary>
public static object evalSpecial(Context cx, IScriptable scope, object thisArg, object [] args, string filename, int lineNumber)
{
if (args.Length < 1)
return Undefined.Value;
object x = args [0];
if (!(x is string)) {
if (cx.HasFeature (Context.Features.StrictEval)) {
throw Context.ReportRuntimeErrorById ("msg.eval.nonstring.strict");
}
string message = ScriptRuntime.GetMessage ("msg.eval.nonstring");
Context.ReportWarning (message);
return x;
}
if (filename == null) {
int [] linep = new int [1];
filename = Context.GetSourcePositionFromStack (linep);
if (filename != null) {
lineNumber = linep [0];
}
else {
filename = "";
}
}
string sourceName = ScriptRuntime.makeUrlForGeneratedScript (true, filename, lineNumber);
ErrorReporter reporter;
reporter = DefaultErrorReporter.ForEval (cx.ErrorReporter);
// Compile with explicit interpreter instance to force interpreter
// mode.
IScript script = cx.CompileString ((string)x, new Interpreter (), reporter, sourceName, 1, (object)null);
((InterpretedFunction)script).idata.evalScriptFlag = true;
ICallable c = (ICallable)script;
return c.Call (cx, scope, (IScriptable)thisArg, ScriptRuntime.EmptyArgs);
}