Commit graph

7621 commits

Author SHA1 Message Date
Conrad Pankoff
46a897b59b LibJS: Implement typeof operator 2020-03-17 21:28:02 +01:00
Andreas Kling
0a71533aff LibJS: Pass argument value vectors as const Vector<Value>&
Now that Interpreter keeps all arguments in the CallFrame stack, we can
just pass a const-reference to the CallFrame's argument vector to each
function handler (instead of copying it.)
2020-03-17 16:24:53 +01:00
Andreas Kling
bf9912cc59 LibJS: Protect function call "this" and arguments from GC
This patch adds a CallFrame stack to Interpreter, which keeps track of
the "this" value and all argument values passed in function calls.

Interpreter::gather_roots() scans the call stack, making sure that all
argument values get marked. :^)
2020-03-17 11:06:00 +01:00
marprok
666f84b933 Base: Add Joi theme 2020-03-17 09:41:15 +01:00
Andreas Kling
cb2e7d1c5f LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
2020-03-16 19:18:46 +01:00
Andreas Kling
ab404a2f88 LibJS: Implement basic conservative garbage collection
We now scan the stack and CPU registers for potential pointers into the
GC heap, and include any valid Cell pointers in the set of roots.

This works pretty well but we'll also need to solve marking of things
passed to native functions, since those are currently in Vector<Value>
and the Vector storage is on the heap (not scanned.)
2020-03-16 19:14:09 +01:00
Andreas Kling
ad92a1e4bc Kernel: Add sys$get_stack_bounds() for finding the stack base & size
This will be useful when implementing conservative garbage collection.
2020-03-16 19:06:33 +01:00
Andreas Kling
086f68e878 LibJS: Replace the global print() function with console.log() :^) 2020-03-16 14:58:20 +01:00
Andreas Kling
19452230cd LibJS: Add "Heap" and "Runtime" subdirectories
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16 14:37:19 +01:00
0xtechnobabble
6780d70fb1 js: Fix simple scopes example
Weirdly enough, the "simple-scopes" test doesn't return undefined
anymore, at first I thought the scoping was somehow broken, turns out
the interpreter doesn't consider the returned y as the last evaluated
value anymore, possibly because it's undefined (?).
2020-03-16 13:42:13 +01:00
0xtechnobabble
dfbaa8e543 LibJS: Implement abstract equality and inequality 2020-03-16 13:42:13 +01:00
0xtechnobabble
4d22a142f7 LibJS: Loosen type system
This commits makes effort towards tolerating some of javascript's quirks
when it comes to its type system, note that the interpreter's way of
handling type coercion is still not mature at all, for example, we still
have to implement NaN instead of just crashing when trying to parse a
string and failing.
2020-03-16 13:42:13 +01:00
0xtechnobabble
419d57e492 LibJS/Parser: Parse logical expressions 2020-03-16 13:42:13 +01:00
0xtechnobabble
94088640f1 LibJS: Specify overridden functions with 'override' 2020-03-16 13:42:13 +01:00
0xtechnobabble
cfd710eb31 LibJS: Implement null and undefined literals 2020-03-16 13:42:13 +01:00
0xtechnobabble
7aad10d984 LibJS: Fix assignment of const variable on declaration
We were previously assuming that we were reassigning a variable even
when we were not, oops, my bad. :/
2020-03-16 13:42:13 +01:00
Oriko
2a32330257 LibGUI: Add a ThemeChange event 2020-03-16 13:39:34 +01:00
Oriko
2b162ef794 LibGUI: Use themes for syntax highlighting 2020-03-16 13:39:34 +01:00
Andreas Kling
6da7fd9aab
Merge pull request #1473 from muscar/dek20-system-menu-remove-power-options-unveil
SystemMenu: Remove the unveil() call for /etc/PowerOptions.ini
2020-03-16 12:10:37 +01:00
Alex Muscar
838d1c38a1 SystemMenu: Remove the unveil() call for /etc/PowerOptions.ini
The file is not used.
2020-03-16 11:05:48 +00:00
Přemysl Janouch
66794d51ef Keymap: Add a US Dvorak keyboard layout
It is yet undecided how to name regional variants.
2020-03-16 07:42:19 +01:00
Andreas Kling
731abd9978 LibJS: Add String.prototype.repeat() :^) 2020-03-15 21:17:38 +01:00
Andreas Kling
63b3cfdc73 LibJS: Pass "this" as an Object* to NativeFunction callbacks
Instead of every NativeFunction callback having to ask the Interpreter
for the current "this" value and then converting it to an Object etc,
just pass "this" as an Object* directly.
2020-03-15 20:51:36 +01:00
Andreas Kling
3163929990 LibJS: Add a mechanism for callback-based object properties
This patch adds NativeProperty, which can be used to implement object
properties that have C++ getters and/or setters.

Use this to move String.prototype.length to its correct place. :^)
2020-03-15 19:31:00 +01:00
Andreas Kling
bb57bc1b42 LibJS: Remove debug spam in Object::get() 2020-03-15 19:31:00 +01:00
marprok
0fd5f0e4bd Userland: ifconfig can change the IP address of the default gateway
ioctl can now perform a request for a specific route and change
the address of it's default gateway.
2020-03-15 19:09:31 +01:00
Itamar
45d7ea1b63 FileManager: Add "Open Terminal here" action 2020-03-15 19:09:24 +01:00
Itamar
bbe50577f8 Terminal: Add -d option for specifying working directory 2020-03-15 19:09:24 +01:00
Chyza
7967c80222 WindowServer: Resize maximised/tiled windows after resolution change
Previously windows would either extend past the screen or stay at their
previous smaller size in the corner, now they are resized to fit the new
resolution.
2020-03-15 19:01:40 +01:00
Andreas Kling
23b1d97b0d LibJS: Add ObjectPrototype and implement hasOwnProperty()
All Objects will now have ObjectPrototype as their prototype, unless
overridden.
2020-03-15 15:25:43 +01:00
Andreas Kling
f1f14945cf LibJS: Rename collect_roots() => gather_roots()
Since this is about finding the things we should *not* garabge collect,
it seemed wrong to call it "collect_something" :^)
2020-03-15 15:13:24 +01:00
Andreas Kling
8dc6416bba LibJS: Use the same StringPrototype globally
To make sure that everyone has the same instance of StringPrototype,
hang a global prototype off of the Interpreter that can be fetched
when constructing new StringObjects.
2020-03-15 15:11:13 +01:00
Andreas Kling
9b4358e150 LibJS: Add Cell::interpreter() convenience helper
This allows you to go from any Cell* to the Interpreter.
2020-03-15 15:08:27 +01:00
Andreas Kling
fbefb19e10 LibJS: Interpreter should make sure that the "this" stack gets marked 2020-03-15 15:07:49 +01:00
Andreas Kling
2c5b9fb8f9 LibJS: Add StringPrototype and make it the prototype of StringObject
This patch adds String.prototype.charAt() to demonstrate that prototype
property lookup works, and that you can call a prototype function on an
object, and it will do what you expect. :^)
2020-03-15 15:02:49 +01:00
Andreas Kling
f7c15d00c9 LibJS: Add basic prototype support
Object will now traverse up the prototype chain when doing a get().
When a function is called on an object, that object will now also be
the "this" value inside the function. This stuff is probably not very
correct, but we will improve things as we go! :^)
2020-03-15 15:01:10 +01:00
Andreas Kling
d02c37f3e3 LibJS: Add Value::to_i32() helper function 2020-03-15 15:00:18 +01:00
myphs
57646e362f Keymap: Add DE keymap layout
This makes it easier to work with the german keyboard layout.

Some keys are left unset because their corresponding letters
aren't supported yet.
2020-03-15 11:49:59 +01:00
Andreas Kling
8300b78b77 LibWeb: Add missing copyright headers 2020-03-15 10:24:05 +01:00
Shannon Booth
5dc5b8a2b6 LibCore: Rename Udp classes to UDP
The kernel was already using the UDP prefix, and the TCP LibCore classes
are also uppercased. Let's rename for consistency.

Also order the LibCore Makefile alphabetically, because everywhere else
seems to be doing that :)
2020-03-14 23:56:12 +01:00
Brian Callahan
149a9ba5d7 Ports: Add zstd port 2020-03-14 22:25:22 +01:00
Brian Callahan
a521d2f950 Add the libpuffy helper library and jot, patch, and printf utils
from OpenBSD.
2020-03-14 22:24:37 +01:00
Linus Groh
5967262d81 Meta: Add more libraries to ReadMe.md 2020-03-14 20:03:27 +01:00
Linus Groh
42d535ec07 Meta: Add more system services to ReadMe.md 2020-03-14 20:03:27 +01:00
0xtechnobabble
2e90a7eb2d LibJS/Parser: Implement the parsing of unary/prefixed update expressions 2020-03-14 20:02:53 +01:00
0xtechnobabble
db64f364f0 LibJS/AST: Implement prefixed update expressions 2020-03-14 20:02:53 +01:00
0xtechnobabble
20a0fc5576 LibJS: Rename BitNot -> BitwiseNot to match other bitwise operators 2020-03-14 20:02:53 +01:00
Stephan Unverwerth
3389021291 LibJS: Unescape strings in Token::string_value() 2020-03-14 16:00:28 +01:00
0xtechnobabble
644b4f4201 LibJS: Evaluate for statements in their own scope if necessary
We now evaluate for loops in their own scope if their init statement is
a lexical declaration.

Evaluating for loops in their own scope allow us to obtain expected
behaviour, which means for example, that the block-scoped variables
declared in a  for statement will be limited to the scope of the for
loop's body and  statement and not to that of the current scope (i.e the
one where the for statement was made)
2020-03-14 13:58:30 +01:00
0xtechnobabble
0659d07241 LibJS/Parser: Remove superfluous switch case 2020-03-14 13:58:30 +01:00