Commit graph

7952 commits

Author SHA1 Message Date
Andreas Kling 1923051c5b LibJS: Lexer and parser support for "switch" statements 2020-03-29 15:03:58 +02:00
Tibor Nagy 70dc80fa47 SystemMenu: Sort applications alphabetically 2020-03-29 14:58:26 +02:00
Andreas Kling f95a119627 LibJS: Implement Object.getOwnPropertyNames() 2020-03-29 01:26:57 +01:00
Andreas Kling 62d5f79388 LibJS+LibWeb: Function calls should always go through Interpreter
This ensures that we set up a call frame with |this| and arguments.
2020-03-29 00:45:53 +01:00
Andreas Kling 30440134cb LibJS+LibWeb: Move native properties to separate getters/setters
This was a bit cumbersome now, but it gets us closer to a format suited
for code generation.
2020-03-29 00:37:33 +01:00
Andreas Kling 56936b97d0 LibJS+LibWeb: Move native JS functions into dedicated member functions
Instead of implementing every native function as a lambda function,
use static member functions instead.

This makes it easier to navigate the code + backtraces look nicer. :^)
2020-03-28 23:10:37 +01:00
Andreas Kling 7c4e53f31e LibJS: Rework how native functions are called to improve |this| value
Native functions now only get the Interpreter& as an argument. They can
then extract |this| along with any indexed arguments it wants from it.

This forces functions that want |this| to actually deal with calling
interpreter.this_value().to_object(), and dealing with the possibility
of a non-object |this|.

This is still not great but let's keep massaging it forward.
2020-03-28 22:51:09 +01:00
Linus Groh c209ea1985 LibJS: Implement Array.prototype.{shift,pop} 2020-03-28 22:18:11 +01:00
Linus Groh c5cf740830 Documentation: Add build dependencies for Fedora 2020-03-28 22:12:20 +01:00
Andreas Kling 82ca7ae1f8 LibJS: Oops, "instanceof" was backwards!
Fix the "instanceof" operator to check if the constructor's prototype
property occurs anywhere in the prototype chain of the instance object.

This patch also adds Object.setPrototypeOf() to make it possible to
create a test for this bug.

Thanks to DexesTTP for pointing this out! :^)
2020-03-28 19:48:12 +01:00
Itamar e5ebdb9bca strace: Change implementation to use ptrace() 2020-03-28 18:27:18 +01:00
Itamar 6b74d38aab Kernel: Add 'ptrace' syscall
This commit adds a basic implementation of
the ptrace syscall, which allows one process
(the tracer) to control another process (the tracee).

While a process is being traced, it is stopped whenever a signal is
received (other than SIGCONT).

The tracer can start tracing another thread with PT_ATTACH,
which causes the tracee to stop.

From there, the tracer can use PT_CONTINUE
to continue the execution of the tracee,
or use other request codes (which haven't been implemented yet)
to modify the state of the tracee.

Additional request codes are PT_SYSCALL, which causes the tracee to
continue exection but stop at the next entry or exit from a syscall,
and PT_GETREGS which fethces the last saved register set of the tracee
(can be used to inspect syscall arguments and return value).

A special request code is PT_TRACE_ME, which is issued by the tracee
and causes it to stop when it calls execve and wait for the
tracer to attach.
2020-03-28 18:27:18 +01:00
Itamar c9396be83f WaitBlocker: don't unblock if thread has pending SIGCONT
Previosuly, if we sent a SIGCONT to a stopped thread
and then waitpid() with WSTOPPED on that thread before
the signal was dispatched,
then the WaitBlocker would first unblock (because the thread is stopped)
and only after that the thread would get the SIGCONT signal.
This would mean that when waitpid returns
the waitee is not stopped.

To fix this, we do not unblock the waiting thread
if the waitee thread has a pending SIGCONT.
2020-03-28 18:27:18 +01:00
Andreas Kling 14047ca432 LibJS: Add a global "Object" constructor
This patch adds an "Object" constructor to the global object. The only
function it implements so far is Object.getPrototypeOf().
2020-03-28 17:23:54 +01:00
Andreas Kling a3d92b1210 LibJS: Implement the "instanceof" operator
This operator walks the prototype chain of the RHS value and looks for
a "prototype" property with the same value as the prototype of the LHS.

This is pretty cool. :^)
2020-03-28 16:56:54 +01:00
Andreas Kling 37fe16a99c LibJS: Add Function.prototype and make "new" Objects delegate to it 2020-03-28 16:40:36 +01:00
Andreas Kling 0593ce406b LibJS: Implement basic support for the "new" keyword
NewExpression mostly piggybacks on the existing CallExpression. The big
difference is that "new" creates a new Object and passes it as |this|
to the callee.
2020-03-28 16:33:52 +01:00
Andreas Kling fecbef4ffe LibJS: Make it possible to reference the "this" value in JavaScript 2020-03-28 16:33:04 +01:00
Benjamin Rottler 401becb922 NotificationServer: Update locations of notifications after closing one
When multiple notifications are open and one notification in the
beginning or in the middle is closed the location of the remaining
notification windows are updated so that there is no gap between them.
2020-03-28 16:07:47 +01:00
Andreas Kling 14de45296e LibJS: Fix broken parsing of !o.a
Unary expressions parsing now respects precedence and associativity of
operators. This patch also makes `typeof` left-associative which was
an oversight.

Thanks to Conrad for helping me work this out. :^)
2020-03-28 11:51:44 +01:00
Conrad Pankoff f1a074a262 Meta: Add feature policy to contribution guidelines 2020-03-28 10:57:09 +01:00
Andreas Kling 0cbbf6f5eb LibJS: Add a tiny little test for the ReferenceError exception 2020-03-28 10:27:48 +01:00
Andreas Kling c50fbf6da0 Kernel: Remove the floppy driver
Nobody was using this code, and it was not actively worked on, so let's
just not have it. Press F.
2020-03-28 10:09:48 +01:00
Andreas Kling 660ec504ca LibWeb: Move get_element_by_id() to a NonElementParentNode mixin class
This matches the current version of the DOM spec. And since C++ doesn't
have mixins this is actually a CRTP class.
2020-03-28 09:13:29 +01:00
Andreas Kling 95cc4c7e74 AK: Add some string comparison operators
Some of these are very inefficient. It's nice to have some optimization
opportunities in the future though. :^)
2020-03-28 09:11:13 +01:00
Andreas Kling 0d2fb306af LibJS: Check for exceptions in a lot more places 2020-03-27 15:36:00 +01:00
Emanuel Sprung c9059c12dc Browser: Let the user add/remove bookmarks to the bookmarks bar
This patchset adds a Button to the toolbar (right next to the location field)
with a star icon. The star is white if the currently visited url is not yet
bookmarked and yellow if a bookmark for the url exists.

After adding or removing a bookmark, the bookmark json file is synced to disk.
Therefore, some new pledge/unveil's have been added.
2020-03-27 14:12:18 +01:00
Emanuel Sprung 4d50398f02 LibGUI: Add store(), add() and remove() methods to JsonArrayModel
This patchset adds the methods to alter an JSON model and store it back
to the disk.
2020-03-27 14:12:18 +01:00
Emanuel Sprung 337ade9e4c Browser: Add bookmarks bar
This patchset adds a bookmark bar that is backed by a json file backend.
The json file is loaded and checked for the format. According to the
format, the bookmarks bar is populated with the bookmark items.

If the bookmarks do not fit into one line, an expader button is shown
that brings up a menu containing the missing bookmark items.

There is currently no way to add or remove bookmarks. A hover over a
bookmark is also not yet showing the url in the statusbar.
2020-03-27 14:12:18 +01:00
Emanuel Sprung a9e943ae4c Browser: Add empty, toogleable bookmarks bar 2020-03-27 14:12:18 +01:00
Andreas Kling 6a5cd32205 LibJS: The global isNaN() should coerce to number before testing NaN
For stricter NaN checking, we'll have to implement Number.isNaN().
2020-03-27 12:59:41 +01:00
Andreas Kling c60dc84a33 LibJS: Allow function calls with missing arguments
We were interpreting "undefined" as a variable lookup failure in some
cases and throwing a ReferenceError exception instead of treating it
as the valid value "undefined".

This patch wraps the result of variable lookup in Optional<>, which
allows us to only throw ReferenceError when lookup actually fails.
2020-03-27 12:56:05 +01:00
Andreas Kling 04ced9e24a LibJS: Add global isNaN() function 2020-03-27 12:45:36 +01:00
Andreas Kling 9a78b4af2c LibJS: Basic NaN support
This patch adds js_nan() for constructing a NaN value. You can check
if a Value is NaN with Value::is_nan().
2020-03-27 12:40:22 +01:00
Andreas Kling 23c5323a70 js: Publish the global object as "global" 2020-03-27 12:24:58 +01:00
Andreas Kling 9494865f99 LibJS: Actually pop frames off of the scope stack when exiting a scope 2020-03-27 11:34:58 +01:00
Andreas Kling d52c5a94b4 IRCClient: Use the IRCClient app icon in notifications :^) 2020-03-26 20:39:36 +01:00
Andreas Kling faedb763ca NotificationServer: Allow showing an icon in notifications
We currently use icon paths for this because I didn't want to deal with
implementing icon bitmap sharing right now. In the future it would be
better to post a bitmap somehow instead of a path.
2020-03-26 20:38:28 +01:00
Andreas Kling 3c29818048 IRCClient: Only notify about channel messages containing our nickname 2020-03-26 20:18:22 +01:00
Andreas Kling 163812df97 IRCClient: Post desktop notifications when messaged while inactive
If you receive a channel or query message while the app is inactive,
or while the channel/query is inactive, we now post a desktop
notification so you can learn that something is happening. :^)
2020-03-26 20:11:23 +01:00
Andreas Kling 96c7e2cd6d LibGUI: Make a new connection to NotificationServer each time
Since NotificationServer is a spawn-on-demand + die-when-not-used type
of service, we can't expect a singleton connection to it to remain open
and useful.

We solve this for now by making a new IPC connection for every new
notification sent. Maybe there's a better solution for this.
2020-03-26 20:10:03 +01:00
Andreas Kling bc7a9097a7 js: Tweak pretty-printing of functions and null 2020-03-26 14:54:43 +01:00
Andreas Kling 97d3809a17 js: Fix build on Linux
Apparently ESUCCESS is not a thing on my host machine.
2020-03-26 14:46:00 +01:00
Andreas Kling 4802413f71 LibJS: Say "return {}" instead of "return js_undefined()" in AST nodes
This looks a bit nicer somehow.
2020-03-26 12:36:52 +01:00
Andreas Kling ad6ede7ee4 LibJS: Make FunctionDeclaration return undefined
FunctionExpression returns a JS::Function, while FunctionDeclaration
declares one in the relevant scope.
2020-03-26 12:27:15 +01:00
Andreas Kling 6e6495fdf9 js: Implement some modest pretty-printing of values 2020-03-26 12:26:11 +01:00
Andreas Kling 68dec2801d LibJS: Add Object::own_properties() convenience accessor 2020-03-26 12:19:01 +01:00
Andreas Kling d7073b9f3e LibJS: Add Value::is_array() 2020-03-26 12:02:18 +01:00
Andreas Kling f3c245fb96 Kernel: Make ^W and ^U actually erase characters
This is quite hackish but it makes using the js REPL a lot nicer. :^)
2020-03-26 08:18:47 +01:00
Sergey Bugaev 5ba8247cbb LibC: Fix getline() forgetting to null-terminate on EOF 2020-03-26 08:18:08 +01:00