StringIsCompilableUnit() публичный Метод

Check whether a string is ready to be compiled.
Check whether a string is ready to be compiled.

stringIsCompilableUnit is intended to support interactive compilation of JavaScript. If compiling the string would result in an error that might be fixed by appending more source, this method returns false. In every other case, it returns true.

Interactive shells may accumulate source lines, using this method after each new line is appended to check whether the statement being entered is complete.

public StringIsCompilableUnit ( string source ) : bool
source string the source buffer to check
Результат bool
Пример #1
0
			// ContextAction
			/// <summary>
			/// Performs the action given by
			/// <see cref="type">type</see>
			/// .
			/// </summary>
			public virtual object Run(Context cx)
			{
				switch (type)
				{
					case IPROXY_COMPILE_SCRIPT:
					{
						cx.CompileString(text, url, 1, null);
						break;
					}

					case IPROXY_EVAL_SCRIPT:
					{
						Scriptable scope = null;
						if (dim.scopeProvider != null)
						{
							scope = dim.scopeProvider.GetScope();
						}
						if (scope == null)
						{
							scope = new ImporterTopLevel(cx);
						}
						cx.EvaluateString(scope, text, url, 1, null);
						break;
					}

					case IPROXY_STRING_IS_COMPILABLE:
					{
						booleanResult = cx.StringIsCompilableUnit(text);
						break;
					}

					case IPROXY_OBJECT_TO_STRING:
					{
						if (@object == Undefined.instance)
						{
							stringResult = "undefined";
						}
						else
						{
							if (@object == null)
							{
								stringResult = "null";
							}
							else
							{
								if (@object is NativeCall)
								{
									stringResult = "[object Call]";
								}
								else
								{
									stringResult = Context.ToString(@object);
								}
							}
						}
						break;
					}

					case IPROXY_OBJECT_PROPERTY:
					{
						objectResult = dim.GetObjectPropertyImpl(cx, @object, id);
						break;
					}

					case IPROXY_OBJECT_IDS:
					{
						objectArrayResult = dim.GetObjectIdsImpl(cx, @object);
						break;
					}

					default:
					{
						throw Kit.CodeBug();
					}
				}
				return null;
			}