Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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}'");
        }
Exemplo n.º 3
0
        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("");
        }
Exemplo n.º 4
0
 public Engine()
 {
     Scope = new Javascript.Scope(this);
 }
Exemplo n.º 5
0
 public static Javascript.Object Construct(string name, Javascript.Scope scope)
 {
     return(new Javascript.Object(Prototype(name, scope)));
 }