summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
AgeCommit message (Collapse)Author
2021-07-04LibJS: VERIFY() that property name is valid in Value::get{,_method}()Linus Groh
2021-07-04LibJS: Avoid unnecessary PropertyName creation in MarkupGeneratorLinus Groh
2021-07-04Everywhere: Fix incorrect usages of AK::CheckedIdan Horowitz
Specifically, explicitly specify the checked type, use the resulting value instead of doing the same calculation twice, and break down calculations to discrete operations to ensure no intermediary overflows are missed.
2021-07-04LibJS: Make the `with` statement evaluation follow the spec even moreAndreas Kling
This was almost entirely up-to-spec already, just missing exception checks, and we now leave the lexical environment in the modified state if an exception occurs during statement evaluation.
2021-07-04LibJS: Bring ArrayCreate and ArrayConstructor closer to specIdan Horowitz
Specifically, this now explicitly takes the length, adds missing exceptions checks to calls with user-supplied lengths, takes and uses the prototype argument, and fixes some spec non-conformance in ArrayConstructor and its native functions around the use of ArrayCreate
2021-07-04LibJS: Add the IteratorStep abstract iterator operationIdan Horowitz
As well as add 2 missing exception checks in the IteratorComplete and IteratorValue abstract iterator operations.
2021-07-03LibJS: Don't allow `delete super.property`Andreas Kling
This should throw a ReferenceError, since `delete` is not allowed on super references.
2021-07-03LibJS: Bring the `super` keyword in line with the specAndreas Kling
This patch implements spec-compliant runtime semantics for the following constructs: - super.property - super[property] The MakeSuperPropertyReference AO is added to support this. :^)
2021-07-02LibJS: Improve ResolveBinding + add GetIdentifierReferenceAndreas Kling
ResolveBinding now matches the spec, while the non-conforming parts are moved to GetIdentifierReference. Implementing this properly requires variable bindings.
2021-07-02LibJS: Implement the PrepareForOrdinaryCall abstract operationAndreas Kling
This is used by VM::call_internal() and VM::construct() which roughly map to function objects' [[Call]] and [[Construct]] slots in the spec. Reorganizing this code revealed something weird: NativeFunction gets its strictness by checking VM::in_strict_mode(). In other words, it inherits the strict flag from the caller context. This is quite weird, but many test-js tests rely on it, so let's preserve it until we can think of something nicer.
2021-07-02LibJS: Make SuperCall a proper AST node and clean up evaluationAndreas Kling
2021-07-02LibJS: NewExpression doesn't need compute_this_and_callee()Andreas Kling
Now that NewExpression is separated from CallExpression, it doesn't have to use the ad-hoc compute_this_and_callee() logic.
2021-07-02LibJS: Split out NewExpression evaluation from CallExpressionAndreas Kling
This patch adds an override for NewExpression::execute() in the AST interpreter to separate the logic from CallExpression. As a result, both evaluation functions are simplified. Both expressions are still largely non-conforming, but this makes it easier to work on improving that since we can now deal with them separately. :^)
2021-07-02LibJS: Break out ArgumentListEvaluation AO from CallExpressionAndreas Kling
2021-07-02LibJS: Bring %TypedArray%.prototype.set slightly closer to specIdan Horowitz
Specifically, instead of using the internal {get, put}_by_index methods we now use the GetValueFromBuffer and SetValueInBuffer abstract operations, as required by the specification. While i was here i also replaced a couple custom detached array buffer error messages with the existing ErrorType::DetachedArrayBuffer.
2021-07-02LibJS: Allow patterns in parenthesized arrow function parametersAli Mohammad Pur
2021-07-02LibJS: Allow 'yield' and 'await' as function expression namesAli Mohammad Pur
The spec says so, and test262 checks for this too.
2021-07-02LibJS: Allow binding patterns as for in/of targetsAli Mohammad Pur
2021-07-02LibJS: Allow 'yield' as a variable name outside of generator functionsAli Mohammad Pur
2021-07-02LibJS: Make a slash after a curly close mean not-divisionAli Mohammad Pur
There's no grammar rule that allows this.
2021-07-02LibJS: Parse generator functions in class expressions tooAli Mohammad Pur
2021-07-02LibJS: Implement the %TypedArray%.set() functionAli Mohammad Pur
2021-07-02LibJS: Throw on failed PutValue into an environment referenceAndreas Kling
This should really be handled at a different layer of the stack, but this allows us to make progress on the Object rewrite without breaking strict mode assignment tests.
2021-07-02LibJS: Make Environment::put_into_environment() return a success boolAndreas Kling
This code is non-conforming and will eventually get cleaned out once we implement proper variable bindings. However, this will aid us in improving other parts of the code right now.
2021-07-02LibJS: Make ResolveBinding() produce strict References in strict modeAndreas Kling
2021-07-01LibJS: Try to fix Clang build (NewClass::m_class_expression is unused)Andreas Kling
2021-07-01LibJS: NewClass bytecode instructionJohan Dahlin
This adds a the NewClass bytecode instruction, enough of it is implemented for it to show it in the bytecode (js -d).
2021-07-01LibJS: Bring JSON.parse slightly closer to the specificationIdan Horowitz
This PR does not fix the main issue with our current implementation: The specification requires that we first check the JSON string for validity with an ECMA-404 compliant parser, and then evaluate it as if it was javascript code, of which we do neither at the moment.
2021-07-01LibJS: Move Binding struct into the DeclarativeEnvironment classAndreas Kling
Nobody on the outside needs to access this.
2021-07-01LibJS: Drop "Record" suffix from all the *Environment record classesAndreas Kling
"Records" in the spec are basically C++ classes, so let's drop this mouthful of a suffix.
2021-07-01LibJS: Bring JSON.stringify closer to the specificationIdan Horowitz
2021-07-01LibJS: Stop coercing this to object in Function's Symbol.hasInstanceIdan Horowitz
2021-07-01LibJS: Stop coercing Date.prototype[Symbol.toPrimitive] hint to stringIdan Horowitz
2021-07-01LibJS: Check for DataView in ArrayBuffer.isView()Idan Horowitz
2021-06-30LibJS: Use the GetFunctionRealm abstract-op in ArraySpeciesCreateIdan Horowitz
2021-06-30LibJS: Get the prototype of a new String from the constructor's realmIdan Horowitz
2021-06-30LibJS: Add a [[Realm]] getter to FunctionObject and use it where neededIdan Horowitz
Defined by https://tc39.es/ecma262/#sec-ordinaryfunctioncreate step #17 and by https://tc39.es/ecma262/#sec-createbuiltinfunction step #6.
2021-06-30LibJS: Ensure shift values in left_shift are modded by 32Idan Horowitz
This is equivalent to 58d6a2d0192b7860ecb2edb4aa5d36b389213a15 but for the left shift operation.
2021-06-30LibJS: Add String.prototype.split using the @@split methods on objectdavidot
2021-06-30LibJS: Add String.prototype.indexOf position argumentdavidot
2021-06-30LibJS: Optimize & Bring String.prototype.repeat closer to the specIdan Horowitz
Specifically, we immediately return an empty string when `this` is an empty string, instead of wasting time in a loop doing nothing N times.
2021-06-30LibJS: Bring the Array constructor slightly closer to the specificationIdan Horowitz
Specifically, we now cast to a u32 instead of an i32, as well as use the validity check required by the specification. The current constructor is still quite far from the specification, as we directly set the indexed properties' length instead of going through the Array's overriden DefineOwnProperty. (and as a result the checks imposed by the ArraySetLength abstract operation)
2021-06-29LibJS: Handle the different realms case in ArraySpeciesCreatedavidot
2021-06-29LibJS: Support the radix argument in BigInt.prototype.toStringIdan Horowitz
2021-06-29LibCrypto: Replace from_base{2,8,10,16}() & to_base10 with from_base(N)Idan Horowitz
This allows us to support parsing and serializing BigIntegers to and from any base N (such that 2 <= N <= 36).
2021-06-29LibJS: Check the target function of a bound function in is_constructorIdan Horowitz
This is not exactly compliant with the specification, but our current bound function implementation isn't either, so its not currently possible to implement it the way the specification requires.
2021-06-29LibJS: Make Array.of(...items) genericIdan Horowitz
As well as bring it generally closer to the specification.
2021-06-28LibJS/Tests: Fix toBeFalse() details prefixLinus Groh
Copy/paste error from toBeTrue().
2021-06-28LibJS: Mark FunctionObject::is_ordinary_function() as overrideLeon Albrecht
2021-06-28LibJS: Add the CreateMappedArgumentsObject abstract operationAndreas Kling
This patch adds a new ArgumentsObject class to represent what the spec calls "Arguments Exotic Objects" These are constructed by the new CreateMappedArgumentsObject when the `arguments` identifier is resolved in a callee context. The implementation is incomplete and doesn't yet support mapping of the parameter variables to the indexed properties of `arguments`.