Commit graph

7559 commits

Author SHA1 Message Date
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
Andreas Kling
25db856134 LibJS: Dump CallExpression arguments (if any) 2020-03-12 19:34:59 +01:00
Oriko
137d68a2ae HackStudio: Abstract over syntax highlighter 2020-03-12 19:04:59 +01:00
Oriko
bacd3dd57a HackStudio: Underline header links 2020-03-12 19:04:59 +01:00
Oriko
6d89f48dd8 LibGUI: Add underlines to highlighting 2020-03-12 19:04:59 +01:00
Tibor Nagy
b58893cfe1 LibGUI: Take scroll offset into account on ItemView rubberband selection
Same kind of issue as #1271.
2020-03-12 15:48:32 +01:00
0xtechnobabble
ee5a49e2fe LibJS: Implement const variable declarations
This also tightens the means of redeclaration of a variable by proxy,
since we now have a way of knowing how a variable was initially
declared, we can check if it was declared using `let` or `const` and
not tolerate redeclaration like we did previously.
2020-03-12 14:58:16 +01:00
0xtechnobabble
8557bc56f7 LibJS: Implement update expressions
Note that currently only the non-prefixed variant is supported (i.e i++
not ++i), this variant returns the value of the argument before the
update.
2020-03-12 14:58:16 +01:00
0xtechnobabble
dc9a702aa8 LibJS/Parser: Parse let declarations 2020-03-12 14:58:16 +01:00
Andreas Kling
4dc1d6654f LibJS: Tweak AssignmentOp names 2020-03-12 13:54:56 +01:00
Andreas Kling
4781e3fb72 LibJS: Fix some coding style mistakes in Lexer 2020-03-12 13:52:54 +01:00
Conrad Pankoff
023d121e05 Meta: Add for-loop JavaScript test program 2020-03-12 13:42:23 +01:00
Conrad Pankoff
097e1af4e8 LibJS: Implement for statement 2020-03-12 13:42:23 +01:00
Conrad Pankoff
e88f2f15ee LibJS: Parse === and !== binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
9d41aa4d5d LibJS: Parse > and < binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
2b36b4f09f LibJS: Implement +=, -=, *=, and /= assignment operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
0fe87c5fec LibJS: Implement <= and >= binary operators 2020-03-12 13:42:23 +01:00
Conrad Pankoff
fdf7f81ba9 LibJS: Implement multiplication and division operators 2020-03-12 13:42:23 +01:00
howar6hill
9f3f0d9983 LibJS: Add test for function with arguments 2020-03-12 13:27:28 +01:00
Andreas Kling
f405cb6a77 LibJS: Implement basic MemberExpression parsing
At last we can parse "hello friends".length :^)
2020-03-12 13:05:57 +01:00
Andreas Kling
ed100bc6f4 LibJS: Implement basic lexing + parsing of StringLiteral
This still includes the double-quote characters (") but at least the
AST comes out right.
2020-03-12 13:05:06 +01:00
Oriko
879bf3e97b HackStudio: Add header navigation 2020-03-12 12:37:13 +01:00
Oriko
d8a73dd979 LibGUI: Parse #include statements separately 2020-03-12 12:37:13 +01:00
Liav A
b13417ddb4 ACPI: Examine bit width in Generic address structure before asserting
Also, the switch-case flow is simplified for IO access within a Generic
address strucuture's handling.
2020-03-12 12:36:38 +01:00
Liav A
5d7855adea ACPI: Keep common flags in structures for later usage 2020-03-12 12:36:38 +01:00
marprok
3cbc2f4381 Ext2FS: Reset the found_a_group flag 2020-03-12 12:35:00 +01:00
Alex Muscar
673848f472
LibGUI: Track window visibility with a separate flag (#1424)
See https://github.com/SerenityOS/serenity/pull/1410 for the motivation.
2020-03-12 12:32:28 +01:00
howar6hill
01133733dd
LibJS: Allow functions to take arguments (#1405) 2020-03-12 12:22:13 +01:00
Andreas Kling
425fd3ce51 LibJS: Defer Value construction until a Literal is executed
Remove the need to construct a full Value during parsing. This means
we don't have to worry about plumbing the heap into the parser.

The Literal ASTNode now has a bunch of subclasses that synthesize a
Value on demand.
2020-03-12 12:19:11 +01:00