public static Javascript.Array ToArray(IList <string> list, Javascript.Scope scope) { var array = new Javascript.Array(); foreach (var s in list) { array.List.Add(new Javascript.String(s)); } return(array); }
public static Javascript.Object Prototype(string name, Javascript.Scope scope) { var obj = scope.Engine.GetPrototype(name); var prototype = obj.Get("prototype"); if (prototype is Javascript.Object o) { return(o); } throw new Javascript.InternalError($"Could not get prototype of '{name}'"); }
public static string ToString(Javascript.Constant constant, Javascript.Scope scope) { var node = new Javascript.Call() { Left = new Javascript.Access(true) { Left = constant, Right = new Javascript.Variable("toString") }, Right = new Javascript.ArgumentList() { Arguments = new Javascript.Constant[] { } } }; var result = node.Execute(scope); if (result is Javascript.String s) { return(s.Value); } return(""); }
public Engine() { Scope = new Javascript.Scope(this); }
public static Javascript.Object Construct(string name, Javascript.Scope scope) { return(new Javascript.Object(Prototype(name, scope))); }