Exemplo n.º 1
0
        private string buildClassLiteral(ClassLiteral classLiteral)
        {
            var result = "";

            result += "class ";
            // build class name
            var classname = Prefix + Build(classLiteral.TypeName);

            result += classname + " ";
            // build class extends
            result += ": public " + Prefix + "Object";
            if (classLiteral.Extends.Count != 0)
            {
                var extends = "";
                classLiteral.Extends.ForEach(node =>
                {
                    extends += ", " + Prefix + Build(node);
                });
                result += extends;
            }
            result += "{ \n";
            // build class body
            result += Build(classLiteral.Body);
            result += "};";
            // add to defines
            if (blockLevel == 0)
            {
                typeDefines.Add("class " + classname + ";");
            }
            return(result);
        }
Exemplo n.º 2
0
        public void IsView(RuntimeFunction isView)
        {
            IsUnconstructableFunctionWLength(isView, "isView", 1);
            That(ArrayBuffer, Has.OwnProperty("isView", isView, EcmaPropertyAttributes.DefaultMethodProperty));

            Case(_, false);

            Case((_, Undefined), false);
            Case((_, Null), false);
            Case((_, 1), false);
            Case((_, ""), false);
            Case((_, Object.Construct()), false);
            Case((_, EcmaArray.Of()), false);
            Case((_, ArrayBuffer.Construct(1)), false);

            EcmaValue DV = new ClassLiteral(Extends(DataView))
            {
                ["constructor"] = FunctionLiteral(DerivedCtor)
            };

            Case((_, DataView.Construct(ArrayBuffer.Construct(1), 0, 0)), true);
            Case((_, DV.Construct(ArrayBuffer.Construct(1), 0, 0)), true);
            Case((_, DataView), false);
            Case((_, DataView.Construct(ArrayBuffer.Construct(1), 0, 0)["buffer"]), false);

            TestWithTypedArrayConstructors(ctor => {
                EcmaValue TA = new ClassLiteral(Extends(ctor))
                {
                    ["constructor"] = FunctionLiteral(DerivedCtor)
                };
                Case((_, ctor.Construct()), true);
                Case((_, TA.Construct()), true);
                Case((_, ctor), false);
                Case((_, ctor.Construct()["buffer"]), false);
            });
        }