Linus Groh
b7032b4972
LibJS: Add Number constants
2020-04-07 21:28:43 +02:00
Linus Groh
f631f6a2e6
LibJS: Add Number()
2020-04-07 17:25:50 +02:00
DexesTTP
e586dc285a
LibJS: Allow parsing numeric and string literals in object expressions
...
Also updated the object-basic.js test to include this change
2020-04-07 09:05:16 +02:00
Linus Groh
22f20cd51d
LibJS: Add String.prototype.toUpperCase()
2020-04-07 08:50:35 +02:00
Jack Karamanian
edae926cb0
LibJS: Add Boolean constructor object
2020-04-07 08:41:25 +02:00
Jack Karamanian
57bd194e5a
LibJS: Return false for NaN numbers in Value::to_boolean()
2020-04-07 08:41:25 +02:00
DexesTTP
4a9485f830
LibJS: Fix impossible member access for negative integers
...
The PropertyName class able to match a number or an array can only
accept positive numerical values. However, the computed_property_name
method sometimes returned negative values.
This commit also adds a basic object access test case.
2020-04-06 21:45:20 +02:00
Andreas Kling
cb18b2c74d
LibJS: Add String.prototype.toLowerCase()
2020-04-06 20:46:08 +02:00
Emanuele Torre
1d6c8724b9
LibJS: Fix some tests for Math.min()
...
In some of the tests in Math.min.js, we were testing Math.max() instead
of Math.min()
2020-04-06 15:14:34 +02:00
Linus Groh
f5dacfbb5b
LibJS: Add Math.{cos,sin,tan}()
2020-04-06 10:58:16 +02:00
Andreas Kling
003741db1c
LibJS: Add Math.min()
2020-04-06 08:26:26 +02:00
Linus Groh
9e7dcaa106
LibJS: Return -Infinity in Math.max() with no argument
2020-04-05 19:30:47 +02:00
Andreas Kling
8bfee015bc
LibJS: Make Object::to_string() call the "toString" property if present
2020-04-05 18:19:56 +02:00
Andreas Kling
a7b21ec0f4
LibJS: Add Array.prototype.toString()
2020-04-05 18:07:41 +02:00
Linus Groh
4509350391
LibJS: Remove assert function from exponentiation-basic.js
2020-04-05 16:01:46 +02:00
Linus Groh
30ba2c7cec
LibJS: Simplify Math-constants.js test
...
By borrowing an "expect close" function from LibM/TestMath.cpp, we can
make this a lot simpler. Also the parser now understands decimals!
2020-04-05 16:01:46 +02:00
Linus Groh
0d7a1c3157
LibJS: Update to-number-basic.js test
...
Uncomment lines that are now parsing correctly :^)
2020-04-05 16:01:46 +02:00
Stephan Unverwerth
500f6d9e3a
LibJS: Add numeric literal parsing for different bases and exponents
2020-04-05 16:01:22 +02:00
Linus Groh
0403845d3e
LibJS: Implement exponentiation (** operator)
2020-04-05 15:32:06 +02:00
Brian Gianforcaro
bc40908d32
LibJS: Use the native assert() implementation now avaiable in 'js -t'
...
Switch the LibJS test suite to use the native assert implementation
surfaced inside the js repl when it's launched in test mode.
2020-04-05 15:28:45 +02:00
Brian Gianforcaro
1e67efc5c1
Lagom: Add clang address/memory/undefined-behavior analyzer support
...
Adding the ability to turn on Clang analyzer support in the Lagom build.
Right now the following are working warning free on the LibJS test suite:
-DENABLE_MEMORY_SANITIZER:BOOL=ON
-DENABLE_ADDRESS_SANITIZER:BOOL=ON
The following analyzer produces errors when running the LibJS test suite:
-DENABLE_UNDEFINED_SANITIZER:BOOL=ON
2020-04-05 12:49:06 +02:00
Andreas Kling
058c614110
LibJS: Fix missing paren in modulo-basic.js test
2020-04-05 11:19:00 +02:00
Brian Gianforcaro
240a5b5fd7
LibJS: Add support for Math.ceil() and Math.trunc()
...
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-05 10:56:23 +02:00
Brian Gianforcaro
b8cef3a2d3
LibJS: Add support for floating point modulous
...
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-05 10:38:13 +02:00
Brian Gianforcaro
41bfff1abe
LibJS: Correctness fixes for bitwise_or, address FIXME's in test.
2020-04-05 10:37:02 +02:00
Brian Gianforcaro
4e54d0ff21
LibJS: Add support for arbitrary arguments to Math.max
...
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-05 09:28:58 +02:00
Andreas Kling
9ebd066ac8
LibJS: Add support for "continue" inside "for" statements :^)
2020-04-05 00:22:42 +02:00
Andreas Kling
e3b92caa6d
LibJS: Make "break" actually work inside "switch"
2020-04-05 00:09:48 +02:00
Andreas Kling
97cd1173fa
LibJS: Add String.prototype.indexOf()
2020-04-04 23:44:29 +02:00
Andreas Kling
d4dfe7e525
LibJS: Add Math.sqrt()
2020-04-04 22:44:48 +02:00
Andreas Kling
d155491122
LibJS: Add basic Array constructor
...
We only support Array() with 0 or 1 parameters so far.
2020-04-04 22:28:21 +02:00
Andreas Kling
5e40aa182b
LibJS: Support VariableDeclaration with multiple declarators
...
This patch adds support in the parser and interpreter for this:
var a = 1, b = 2, c = a + b;
VariableDeclaration is now a sequence of VariableDeclarators. :^)
2020-04-04 21:47:12 +02:00
Andreas Kling
f8393b80e3
LibJS: Add support for do..while statements
2020-04-04 21:29:23 +02:00
Andreas Kling
644ff1bbfd
LibJS: Add basic support for modulo (%) in binary expressions
2020-04-04 21:17:34 +02:00
Andreas Kling
9c8363bb5f
LibJS: Allow "for" statement without curly braces around body
2020-04-04 21:09:06 +02:00
Linus Groh
2944039d6b
LibJS: Add Function() and Function.prototype
2020-04-04 15:58:49 +02:00
Linus Groh
4d931b524d
LibJS: Add length property to ScriptFunction
2020-04-04 15:58:49 +02:00
Stephan Unverwerth
520311eb8b
LibJS: Add short circuit logical evaluation
...
When evaluating logical binop expressions, the rhs must not be
evaluated if the lhs leads to the whole expression not being
truthy.
2020-04-03 19:17:52 +02:00
Linus Groh
6e5f9e20eb
LibJS: Fix logical expressions
...
The current implementation of logical AND (&&) and logical OR (||)
always returns a boolean - this is not correct.
2020-04-03 16:32:36 +02:00
Linus Groh
a58640ce6b
LibJS: Parse binary bitwise operators
...
The Lexer and AST already have all the functionality required in place,
so this is just updating Parser::match_secondary_expression() and
Parser::parse_expression() to handle TokenType::{Ampersand,Pipe,Caret},
as well as adding some tests.
2020-04-03 14:10:09 +02:00
Andreas Kling
0622181d1f
LibJS: Implement ConditionalExpression (ternary "?:" operator)
2020-04-03 12:15:14 +02:00
Linus Groh
94afcb54de
LibJS: Implement Error.prototype.toString()
2020-04-03 09:07:05 +02:00
Linus Groh
543c6e00db
LibJS: Implement Infinity
2020-04-02 21:52:15 +02:00
Andreas Kling
99aab4470a
LibJS: Object::put() shouldn't create own properties on prototype chain
...
Unless there is a setter present on the prototype chain, put() should
only set own properties on the object itself.
Fixes #1588 .
2020-04-02 21:36:14 +02:00
Linus Groh
a62230770b
LibJS: Implement unary plus / minus
2020-04-02 19:55:45 +02:00
Jack Karamanian
bb15b37228
LibJS: Evaluate CallExpression arguments before pushing a CallFrame
2020-04-02 08:50:28 +02:00
Linus Groh
a0da97cb5a
LibJS: Add NaN to global object
2020-04-01 22:09:37 +02:00
Linus Groh
ee6472fef2
LibJS: Implement Error function/constructor
2020-04-01 20:47:37 +02:00
Linus Groh
849e2c77e4
LibJS: Implement constructor/non-constructor function calls
...
This adds Function::construct() for constructor function calls via `new`
keyword. NativeFunction doesn't have constructor behaviour by default,
ScriptFunction simply calls call() in construct()
2020-04-01 20:18:36 +02:00
Jack Karamanian
098f1cd0ca
LibJS: Add support for arrow functions
2020-03-30 15:41:36 +02:00