summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime
AgeCommit message (Collapse)Author
2020-04-10LibJS: Use enumerator macros for boilerplate code around native typesAndreas Kling
2020-04-10LibJS: Boolean, Number and String prototypes should have values tooAndreas Kling
It appears that calling .valueOf() on an objectified primitive's prototype should return a value after all. This matches what other engines are doing.
2020-04-10LibJS: Throw real TypeError, ReferenceError, etc objectsAndreas Kling
Instead of just throwing Error objects with a name string, we now throw the real Error subclass types. :^)
2020-04-10LibJS: Add all the Error subclassesAndreas Kling
This patch adds instance, constructor and prototype classes for: - EvalError - InternalError - RangeError - ReferenceError - SyntaxError - TypeError - URIError Enumerator macros are used to reduce the amount of typing. :^)
2020-04-10LibJS: Add property configuration transitionsAndreas Kling
Object.defineProperty() can now change the attributes of a property already on the object. Internally this becomes a shape transition with the TransitionType::Configure. Such transitions don't expand the property storage capacity, but rather simply keep attributes up to date when generating a property table.
2020-04-10LibJS: Add Object.defineProperty() and start caring about attributesAndreas Kling
We now care (a little bit) about the "configurable" and "writable" property attributes. Property attributes are stored together with the property name in the Shape object. Forward transitions are not attribute-savvy and will cause poor Shape reuse in the case of multiple same-name properties with different attributes. Oh, and this patch also adds Object.getOwnPropertyDescriptor() :^)
2020-04-09LibJS: Add globalThisLinus Groh
We already have "global" as a way to access the global object in js(1) (both REPL and script mode). This replaces it with "globalThis", which is available in all environments, not just js.
2020-04-09LibJS: Fix BooleanPrototype buildAndreas Kling
2020-04-09LibJS: Make BooleanPrototype inherit from ObjectLinus Groh
BooleanPrototype should inherit from Object, not BooleanObject.
2020-04-08LibWeb: Add XMLHttpRequest object :^)Andreas Kling
This patch adds very basic XMLHttpRequest support to LibWeb. Here's an example that currently works: var callback = function() { alert(this.responseText); } var xhr = new XMLHttpRequest(); xhr.addEventListener("load", callback); xhr.open("GET", "http://serenityos.org/~kling/test/example.txt"); xhr.send(); There are many limitations and bugs, but it's pretty dang awesome that we have XHR. :^)
2020-04-08LibJS: Handle empty values in Array.prototype.toString()Linus Groh
2020-04-08LibJS: Add Value::to_double() for convenienceAndreas Kling
2020-04-08LibJS: Add "constructor" property to constructor prototypesAndreas Kling
2020-04-07LibJS: Add Number.isSafeInteger()Linus Groh
2020-04-07LibJS: Add Number constantsLinus Groh
2020-04-07LibJS: Add Number()Linus Groh
2020-04-07LibJS: Reformat BooleanConstructor.{cpp,h}Linus Groh
2020-04-07LibJS: Add String.prototype.toUpperCase()Linus Groh
2020-04-07LibJS: Add Boolean constructor objectJack Karamanian
2020-04-07LibJS: Return false for NaN numbers in Value::to_boolean()Jack Karamanian
2020-04-06LibJS: Add String.prototype.toLowerCase()Andreas Kling
2020-04-06LibJS: Inline JS::Value()Andreas Kling
I had this out of line for debugging reasons. Put it back inline.
2020-04-06LibJS: Support array holes, encoded as empty JS::ValueAndreas Kling
This patch adds a new kind of JS::Value, the empty value. It's what you get when you do JSValue() (or most commonly, {} in C++.) An empty Value signifies the absence of a value, and should never be visible to JavaScript itself. As of right now, it's used for array holes and as a return value when an exception has been thrown and we just want to unwind. This patch is a bit of a mess as I had to fix a whole bunch of code that was relying on JSValue() being undefined, etc.
2020-04-06LibJS: Give argument vectors an inline capacity of 8Andreas Kling
This avoids one malloc/free pair for every function call if there are 8 arguments or fewer.
2020-04-06LibJS: Add a PropertyName class that represents a string or a numberAndreas Kling
Now that we have two separate storages for Object properties depending on what kind of index they have, it's nice to have an abstraction that still allows us to say "here's a property name". We use PropertyName to always choose the optimal storage path directly while interpreting the AST. :^)
2020-04-06LibJS: Add a number-indexed property storage to all ObjectsAndreas Kling
Objects can have both named and indexed properties. Previously we kept all property names as strings. This patch separates named and indexed properties and splits them between Object::m_storage and m_elements. This allows us to do much faster array-style access using numeric indices. It also makes the Array class much less special, since all Objects now have number-indexed storage. :^)
2020-04-06LibJS: Rename variable "max" to "min" in MathObject::min() (#1665)Emanuele Torre
2020-04-06LibJS: Object needs to protect values in its storageAndreas Kling
Otherwise the garbage collector will eat them way too soon! This made it impossible to use "js -g" without crashing.
2020-04-06Meta: Add missing copyright headersAndreas Kling
2020-04-06LibJS: Add Math.{cos,sin,tan}()Linus Groh
2020-04-06LibJS: Simplify MathObject functionsLinus Groh
2020-04-06LibJS: Add Math.min()Andreas Kling
2020-04-05LibJS: Return -Infinity in Math.max() with no argumentLinus Groh
2020-04-05LibJS: Make Object::to_string() call the "toString" property if presentAndreas Kling
2020-04-05LibJS: Add Array.prototype.toString()Andreas Kling
2020-04-05LibJS: Fix Math.SQRT1_2Linus Groh
The value of Math.SQRT1_2 was zero as we were dividing two integers.
2020-04-05LibJS: Implement exponentiation (** operator)Linus Groh
2020-04-05AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtrAndreas Kling
We were allowing this dangerous kind of thing: RefPtr<Base> base; RefPtr<Derived> derived = base; This patch changes the {Nonnull,}RefPtr constructors so this is no longer possible. To downcast one of these pointers, there is now static_ptr_cast<T>: RefPtr<Derived> derived = static_ptr_cast<Derived>(base); Fixing this exposed a ton of cowboy-downcasts in various places, which we're now forced to fix. :^)
2020-04-05LibJS: Add support for Math.ceil() and Math.trunc()Brian Gianforcaro
Introduce support for the both of these Math methods. Math.trunc is implemented in terms of Math.ceil or Math.floor based on the input value. Added tests as well.
2020-04-05LibJS: Add support for floating point modulousBrian Gianforcaro
This change implements floating point mod based on the algorithm used in LibM's fmod() implementation. To avoid taking a dependency on LibM from LibJS I reimplemented the formula in LibJS. I've incuded some of the example MDM test cases as well. This surfaced and issue handling NaN which I've fixed as well.
2020-04-05LibJS: Correctness fixes for bitwise_or, address FIXME's in test.Brian Gianforcaro
2020-04-05LibJS: Add support for arbitrary arguments to Math.maxBrian Gianforcaro
Address the FIXME in MathObject::max to handle an arbitrary number of arguments. Also adding a test case to verify the behavior of Math.max() while I'm here.
2020-04-05LibJS: Add Math.max()Andreas Kling
2020-04-05LibJS: Add Math.round()Andreas Kling
2020-04-05LibJS: Add Math.floor()Andreas Kling
2020-04-04LibJS: Add String.prototype.indexOf()Andreas Kling
2020-04-04LibJS: Math.sqrt.length should be 1Andreas Kling
2020-04-04LibJS: Add NumberObject and make to_object() on number values create itAndreas Kling
2020-04-04LibJS: Add Math.sqrt()Andreas Kling
2020-04-04LibJS: Add basic Array constructorAndreas Kling
We only support Array() with 0 or 1 parameters so far.