Commit graph

7982 commits

Author SHA1 Message Date
Andreas Kling
c2a8bbcb59 Revert "Kernel: Change Ext2FS to be backed by a file instead of a block device"
This reverts commit 6b59311d4b.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:29:03 +02:00
Andreas Kling
9ae3cced76 Revert "Kernel & Userland: Allow to mount image files formatted with Ext2FS"
This reverts commit a60ea79a41.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:57 +02:00
Andreas Kling
28be90120b Revert "SystemMonitor: Replace 'device' JSON field with 'source'"
This reverts commit 592f218151.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:25 +02:00
Andreas Kling
031d242e0e LibGUI: Clear any hovered index when the cursor leaves an AbstractView 2020-04-03 21:14:34 +02:00
Linus Groh
c26bef0e53 LibWeb: Add NavigatorObject to Makefile 2020-04-03 20:04:21 +02:00
Linus Groh
07049f98ec LibWeb: Handle invalid URL in HtmlView::load() 2020-04-03 19:41:25 +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
Andreas Kling
a2b0cc8f08 LibWeb: Add "navigator" object and expose navigator.userAgent
A lot of web content looks for this property. We'll probably have to
tweak this as we go, but at least now we have it. :^)
2020-04-03 18:12:20 +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
Andreas Kling
522d8c5d71 Kernel: Non-readable-but-writable regions should still be mapped
Fixes #1436.
2020-04-03 10:10:56 +02:00
AnotherTest
df7062aac5 AK: Add an overwrite API to ByteBuffer
Since ByteBuffer is a Buffer, it should allow us to overwrite parts of
it that we have allocated.
This comes in useful in handling unsequenced writes like handling
fragmented ip packets :^)
2020-04-03 09:42:13 +02:00
Marco Wang
3fae4cb054 Kernel: Prepend missing license 2020-04-03 09:12:29 +02:00
Emanuel Sprung
d0d093fef5 AK: Remove relative path in AK testsuite
With relative filenames in the executable code, the executable is basically not
relocatable. This makes out-of-source builds unneccesery hard. This patchset moves
the relative link into the filesystem: that can be handled much easier :^)
2020-04-03 09:07:19 +02:00
Linus Groh
94afcb54de LibJS: Implement Error.prototype.toString() 2020-04-03 09:07:05 +02:00
Linus Groh
2636cac6e4 LibJS: Remove UndefinedLiteral, add undefined to global object
There is no such thing as a "undefined literal" in JS - undefined is
just a property on the global object with a value of undefined.
This is pretty similar to NaN.

var undefined = "foo"; is a perfectly fine AssignmentExpression :^)
2020-04-03 00:10:52 +02:00
Linus Groh
543c6e00db LibJS: Implement Infinity 2020-04-02 21:52:15 +02:00
Brendan Coles
40b3203941 IRCClient: Update channel user list when a user joins or quits 2020-04-02 21:50:02 +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
Andreas Kling
5e6e1fd482 LibJS: Start implementing object shapes
This patch adds JS::Shape, which implements a transition tree for our
Object class. Object property keys, prototypes and attributes are now
stored in a Shape, and each Object has a Shape.

When adding a property to an Object, we make a transition from the old
Shape to a new Shape. If we've made the same exact transition in the
past (with another Object), we reuse the same transition and both
objects may now share a Shape.

This will become the foundation of inline caching and other engine
optimizations in the future. :^)
2020-04-02 19:32:21 +02:00
Dov Alperin
3906d2b46a Userland/JS: Print any exceptions after execution of a JS file 2020-04-02 17:08:37 +02:00
Brendan Coles
6bf47252dc IRCClient: Add is_channel_prefix to check if string is a channel name 2020-04-02 15:39:57 +02:00
Andreas Kling
57f72f2982 js: Change wording from "Exception caught" to "Uncaught exception" :^)
As Sergey pointed out, these exceptions are actually *not* caught!
2020-04-02 15:25:08 +02:00
Andreas Kling
fbb16073d1 LibJS: Make JS::Cell non-copyable and non-movable
Also make the JS::Cell default constructor protected to provove a
compilation error if you tried to allocate a plain cell.
2020-04-02 15:24:50 +02:00
Linus Groh
eb1fef2be6 js: Improve exception output for errors with empty message 2020-04-02 15:24:34 +02:00
Brendan Coles
526386a6ba IRCClient: Automatically disable/enable GUI actions upon window change
Toolbar and menu items related to channel operations are now enabled
only when the active window is a channel.
2020-04-02 15:07:32 +02:00
Brendan Coles
855f9286fa IRCClient: Add channel operations to Channel application menu
Add menu options to invite user, op/deop/voice/devoice user,
and cycle channel.
2020-04-02 14:39:05 +02:00
AnotherTest
b3d7c5d9de Kernel: Send Fragmented IPv4 packets if payload size > mtu
This adds IPv4 fragmentation, so now we can send huuuuuuge packets
properly.
2020-04-02 14:38:28 +02:00
Liav A
592f218151 SystemMonitor: Replace 'device' JSON field with 'source' 2020-04-02 12:03:08 +02:00
Liav A
a60ea79a41 Kernel & Userland: Allow to mount image files formatted with Ext2FS 2020-04-02 12:03:08 +02:00
Liav A
6b59311d4b Kernel: Change Ext2FS to be backed by a file instead of a block device
This ensures that we can mount image files as virtual disks without the
need of implementing gross hacks like loopback devices :)
2020-04-02 12:03:08 +02:00
Liav A
2f2016f51d Kernel: Remove unnecessary printf specifier 2020-04-02 12:03:08 +02:00
Andreas Kling
8ad890cfa6 js: Handle exceptions thrown during REPL execution
We now print thrown exceptions and clear the interpreter state so it
can continue running instead of refusing to do anything after an
exception has been thrown.

Fixes #1572.
2020-04-02 09:56:13 +02:00
Andreas Kling
c683665ca9 LibJS: Fix bad cast in Interpreter::run()
We were casting to BlockStatement when we should cast to ScopeNode.
2020-04-02 09:56:13 +02:00
Brendan Coles
b3d8ce44a2 IRCClient: Use active channel window for part,hop,topic,kick commands
The /part, /hop, /topic, /kick commands will now default to the
currently active window if no channel name was provided.
2020-04-02 08:54:54 +02:00
Jack Karamanian
bb15b37228 LibJS: Evaluate CallExpression arguments before pushing a CallFrame 2020-04-02 08:50:28 +02:00
AnotherTest
8f08ec5038 LibLine: Restore previous state only if initialized
This makes the library safe to construct/destruct without actually using
it.
2020-04-02 08:49:11 +02:00
Andreas Kling
cd1d369cdd LibJS: Add argument(i) and argument_count() to Interpreter
Add some convenience accessors for retrieving arguments from the
current call frame.
2020-04-01 22:38:59 +02:00
Andreas Kling
1549c5c48b LibJS: Make Value::as_object() return Object&
Let's move towards using references over pointers in LibJS as well.
I had originally steered away from it because that's how I've seen
things done in other engines. But this is not the other engines. :^)
2020-04-01 22:18:47 +02:00
Emanuel Sprung
b995a499d3 AK: Add equals method to JsonValue to semantically compare two values.
This patchsets adds the semantic check of two values. One first approach
was to compare the (generated) json strings of the two values. This works
out in the most cases, but not with numbers, where "1.0" and "1" in JSON
format are semantically the same. Therefore, this patch adds deep (recursive)
check of two JsonValues.
2020-04-01 22:12:19 +02:00
Dov Alperin
c27e8a258a Userland/JS: Extend the global object when using a REPL
When we enter a repl we call initialize_global_object on our custom
ReplObject in order to expose REPL specific features. Specifically:
help(), exit(code), and load("file1.js", "file2.js", "fileEtc.js").
2020-04-01 22:11:33 +02:00
Linus Groh
a0da97cb5a LibJS: Add NaN to global object 2020-04-01 22:09:37 +02:00
Emanuel Sprung
2577712a1c AK: Add String::replace() functionality
This adds a replace functionality that replaces a string that contains
occurences of a "needle" by a "replacement" value. With "all_occurences"
enabled, all occurences are being replaced, otherwise only the first
occurence is being replaced.
2020-04-01 21:47:23 +02:00
Andreas Kling
9d5d0261e1 LibJS: Add Interpreter::create<GlobalObjectType>()
Force Interpreter construction to go via a create() helper that takes
the global object type as a template parameter.
2020-04-01 21:05:35 +02:00
Andreas Kling
aee4c1f583 LibJS: Add GlobalObject to the forwarding header 2020-04-01 21:05:35 +02:00
Andreas Kling
806d3d8e79 AK: Add adopt_own() to create a NonnullOwnPtr<T> from a T& 2020-04-01 21:05:35 +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