Commit graph

7599 commits

Author SHA1 Message Date
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
Andreas Kling
b5a22fc408 LibWeb: Implement Document.getElementById()
This was pleasantly simple! We don't have an ElementWrapper yet, so it
just returns a NodeWrapper, but it still basically works. :^)
2020-03-14 13:25:40 +01:00
Andreas Kling
1c406294fc LibWeb: Start implementing basic JavaScript DOM bindings
This patch introduces the Wrapper and Wrappable classes.

Node now inherits from Wrappable, and can be wrapped in a GC-allocated
Bindings::NodeWrapper object. The only property we expose right now is
the very simple nodeName property.

When a Document's JS::Interpreter is first instantiated, we add a
"document" property with a DocumentWrapper object to the global object.

This is pretty cool! :^)
2020-03-14 13:25:40 +01:00
Andreas Kling
9c9d3f0904 LibWeb: Parse <script> elements and run any JavaScript found inside
This patch begins integrating LibJS into LibWeb. Document holds the
JS::Interpreter for now, and it is created on demand when you first
call Document::interpreter().

We also add a simple "alert()" function to the global object.
2020-03-14 13:25:38 +01:00
Andreas Kling
f94099f796 LibJS: Strip double-quote characters from StringLiteral tokens
This is very hackish since I'm just doing it to make progress on
something else. :^)
2020-03-14 12:40:06 +01:00
Stephan Unverwerth
c0e6234219 LibJS: Lex single quote strings, escaped chars and unterminated strings 2020-03-14 12:13:53 +01:00
Oriko
d439013903 LibGUI: Highlight new JS tokens 2020-03-14 11:30:31 +01:00
Oriko
e273203d27 LibJS: Add missing tokens to name() 2020-03-14 11:30:31 +01:00
Andreas Kling
1ec4771904 Meta: Update .clang-format to not indent nested namespaces 2020-03-14 10:10:21 +01:00
Stephan Unverwerth
15d5b2d29e LibJS: Add operator precedence parsing
Obey precedence and associativity rules when parsing expressions
with chained operators.
2020-03-14 00:11:24 +01:00
Tibor Nagy
f347dd5c5e Applications: Use "Document - AppName" window title format
Fixes #1444
2020-03-13 23:30:12 +01:00
Oriko
b4381be0ba LibGUI: Add missing copyright headers 2020-03-13 23:09:58 +01:00
Oriko
2d7f4bea90 LibJS: Fix endless loop in string lexing 2020-03-13 22:53:13 +01:00
Oriko
b6e1c1b516 HackStudio: Use Javascript syntax highlighter 2020-03-13 22:53:13 +01:00
Oriko
c2884d29d6 TextEditor: Use Javascript syntax highlighter 2020-03-13 22:53:13 +01:00
Oriko
196352ef67 LibGUI: Add Javascript syntax highlighter 2020-03-13 22:53:13 +01:00
Oriko
c02037e944 LibGUI: Abstract token pair matching 2020-03-13 22:53:13 +01:00
Stephan Unverwerth
ac524b632f LibJS: Fix lexing of the last character in a file
Before this commit the last character in a file would be swallowed.
This also fixes parsing of empty files which would previously ASSERT.
2020-03-13 21:47:57 +01:00
Oriko
8285102b6d HackStudio: Add Javascript projects 2020-03-13 20:19:01 +01:00
Oriko
792a709765 HackStudio: Fix the wrong cursor being drawn 2020-03-13 20:19:01 +01:00
Linus Groh
0e04e2cff0 LibJS: Add parsed parameters to FunctionDeclaration 2020-03-13 20:16:01 +01:00
0xtechnobabble
83ea7bb9e7 LibJS: Don't allow the redeclaration of a var variable using let/const
Previously, we were allowing the redeclaration of a variable with `let`
or `const` if it was declared initially using `var`, we should not
tolerate any form of variable redeclaration using let/const.
2020-03-13 20:15:52 +01:00
Andreas Kling
9f38f4dbfb LibJS: Add Object::put_native_function() for convenience
This makes it a little bit nicer to add native function properties
to JavaScript objects.

Thanks to Sergey for suggesting it! :^)
2020-03-13 11:08:16 +01:00