Commit Graph

7587 Commits

Author SHA1 Message Date
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
Andreas Kling
6089d6566b LibJS: Make it possible to go from a Cell* to its Heap&
This patch makes all HeapBlock allocations aligned to their block size,
enabling us to find the HeapBlock* for a given Cell* by simply masking
bits off of the cell address.

Use this to make a simple Heap& getter for Cell, which lets us avoid
plumbing the Heap& everywhere.
2020-03-13 11:08:16 +01:00
Andreas Kling
d9c7009604 LibJS: Split Function into subclasses NativeFunction and ScriptFunction
Both types of functions are now Function and implement calling via:

    virtual Value call(Interpreter&, Vector<Value> arguments);

This removes the need for CallExpression::execute() to care about which
kind of function it's calling. :^)
2020-03-13 11:08:16 +01:00
Till Mayer
de6f697eba Solitaire: Fix automatic moving of cards
A previous change trying to fix an assertion error completely broke
the automatic moving of cards, this commit will fix this problem
2020-03-13 10:40:45 +01:00
Till Mayer
3e25c58755 Solitaire: Minor tweaks to animation x_velocity and bouncyness 2020-03-13 10:40:45 +01:00
Till Mayer
62422eecdc Solitaire: Add about dialog and 32x32 icon 2020-03-13 10:40:45 +01:00
Andreas Kling
1448f4384d LibJS: Move GlobalObject to its own Object subclass
This is mostly for tidiness at the moment.
2020-03-12 20:11:35 +01:00
Andreas Kling
d1d136b4e5 LibJS: Replace $gc() hack with a NativeFunction on the global object
To make this work, also start passing Interpreter& to native functions.
2020-03-12 20:04:54 +01:00
Andreas Kling
9ad17d4674 LibJS: Fix broken parsing of 0-argument CallExpression 2020-03-12 20:03:12 +01:00
Andreas Kling
32963cf74a LibJS: Allow implicit Value construction from GC-allocated things 2020-03-12 19:57:40 +01:00
Andreas Kling
7912f33ea0 LibJS: Add NativeFunction, a callable wrapper around a C++ lambda
This can be used to implement arbitrary functionality, callable from
JavaScript.

To make this work, I had to change the way CallExpression passes
arguments to the callee. Instead of a HashMap<String, Value>, we now
pass an ordered list of Argument { String name; Value value; }.

This patch includes a native "print(argument)" function. :^)
2020-03-12 19:54:47 +01:00
Andreas Kling
cc8e3048bc LibJS: Fix NumericLiteral::dump() output 2020-03-12 19:36:24 +01:00
Andreas Kling
92d1014051 LibJS: Parse CallExpression arguments 2020-03-12 19:35:23 +01:00