public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { int id = f.MethodId; switch (id) { case Id_print: for (int i = 0; i < args.Length; i++) { if (i > 0) Console.Out.Write (" "); Console.Out.Write (ScriptConvert.ToString (args [i])); } Console.Out.WriteLine (); return Undefined.Value; case Id_version: if (args.Length > 0) { if (CliHelper.IsNumber (args [0])) { int newVer = (int)ScriptConvert.ToNumber (args [0]); if (Context.IsValidLanguageVersion (newVer)) { cx.Version = Context.ToValidLanguageVersion (newVer); } } } return (int)cx.Version; case Id_options: StringBuilder sb = new StringBuilder (); if (cx.HasFeature (Context.Features.Strict)) sb.Append ("strict"); return sb.ToString (); case Id_gc: GC.Collect (); return Undefined.Value; } throw f.Unknown (); }
public virtual object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { if (f.HasTag(FTAG)) { if (f.MethodId == Id_constructor) { throw Context.ReportRuntimeErrorById("msg.cant.call.indirect", "With"); } } throw f.Unknown(); }
public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { int id = f.MethodId; switch (id) { case Id_print: for (int i = 0; i < args.Length; i++) { if (i > 0) { Console.Out.Write(" "); } Console.Out.Write(ScriptConvert.ToString(args [i])); } Console.Out.WriteLine(); return(Undefined.Value); case Id_version: if (args.Length > 0) { if (CliHelper.IsNumber(args [0])) { int newVer = (int)ScriptConvert.ToNumber(args [0]); if (Context.IsValidLanguageVersion(newVer)) { cx.Version = Context.ToValidLanguageVersion(newVer); } } } return((int)cx.Version); case Id_options: StringBuilder sb = new StringBuilder(); if (cx.HasFeature(Context.Features.Strict)) { sb.Append("strict"); } return(sb.ToString()); case Id_gc: GC.Collect(); return(Undefined.Value); } throw f.Unknown(); }
public virtual object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { if (f.HasTag(FTAG)) { int methodId = f.MethodId; switch (methodId) { case Id_decodeURI: case Id_decodeURIComponent: { string str = ScriptConvert.ToString(args, 0); return(decode(str, methodId == Id_decodeURI)); } case Id_encodeURI: case Id_encodeURIComponent: { string str = ScriptConvert.ToString(args, 0); return(encode(str, methodId == Id_encodeURI)); } case Id_escape: return(js_escape(args)); case Id_eval: return(ImplEval(cx, scope, thisObj, args)); case Id_isFinite: { bool result; if (args.Length < 1) { result = false; } else { double d = ScriptConvert.ToNumber(args [0]); result = (!double.IsNaN(d) && d != System.Double.PositiveInfinity && d != System.Double.NegativeInfinity); } return(result); } case Id_isNaN: { // The global method isNaN, as per ECMA-262 15.1.2.6. bool result; if (args.Length < 1) { result = true; } else { double d = ScriptConvert.ToNumber(args [0]); result = (double.IsNaN(d)); } return(result); } case Id_isXMLName: { object name = (args.Length == 0) ? Undefined.Value : args [0]; XMLLib xmlLib = XMLLib.ExtractFromScope(scope); return(xmlLib.IsXMLName(cx, name)); } case Id_parseFloat: return(js_parseFloat(args)); case Id_parseInt: return(js_parseInt(args)); case Id_unescape: return(js_unescape(args)); case Id_uneval: { object value = (args.Length != 0) ? args [0] : Undefined.Value; return(ScriptRuntime.uneval(cx, scope, value)); } case Id_new_CommonError: // The implementation of all the ECMA error constructors // (SyntaxError, TypeError, etc.) return(BuiltinError.make(cx, scope, f, args)); } } throw f.Unknown(); }
public virtual object ExecIdCall (IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { if (f.HasTag (FTAG)) { int methodId = f.MethodId; switch (methodId) { case Id_decodeURI: case Id_decodeURIComponent: { string str = ScriptConvert.ToString (args, 0); return decode (str, methodId == Id_decodeURI); } case Id_encodeURI: case Id_encodeURIComponent: { string str = ScriptConvert.ToString (args, 0); return encode (str, methodId == Id_encodeURI); } case Id_escape: return js_escape (args); case Id_eval: return ImplEval (cx, scope, thisObj, args); case Id_isFinite: { bool result; if (args.Length < 1) { result = false; } else { double d = ScriptConvert.ToNumber (args [0]); result = (!double.IsNaN (d) && d != System.Double.PositiveInfinity && d != System.Double.NegativeInfinity); } return result; } case Id_isNaN: { // The global method isNaN, as per ECMA-262 15.1.2.6. bool result; if (args.Length < 1) { result = true; } else { double d = ScriptConvert.ToNumber (args [0]); result = (double.IsNaN (d)); } return result; } case Id_isXMLName: { object name = (args.Length == 0) ? Undefined.Value : args [0]; XMLLib xmlLib = XMLLib.ExtractFromScope (scope); return xmlLib.IsXMLName (cx, name); } case Id_parseFloat: return js_parseFloat (args); case Id_parseInt: return js_parseInt (args); case Id_unescape: return js_unescape (args); case Id_uneval: { object value = (args.Length != 0) ? args [0] : Undefined.Value; return ScriptRuntime.uneval (cx, scope, value); } case Id_new_CommonError: // The implementation of all the ECMA error constructors // (SyntaxError, TypeError, etc.) return BuiltinError.make (cx, scope, f, args); } } throw f.Unknown (); }
public virtual object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args) { if (f.HasTag (FTAG)) { if (f.MethodId == Id_constructor) { throw Context.ReportRuntimeErrorById ("msg.cant.call.indirect", "With"); } } throw f.Unknown (); }