The Bytecode::Interpreter will push a global call frame if needed,
and it needs to make sure that call frame survives until the end
of the Interpreter::run() function.
Unlike the convoluted unwind-until-scope-type mechanism in the AST
interpreter, "continue" maps to a simple Bytecode::Op::Jump here. :^)
We know where to jump based on a stack of "continuable scopes" that
we now maintain on the Bytecode::Generator as we go.
Note that this only supports bare "continue", not continue-with-label.
This also required making Bytecode::Op::Jump support lazy linking
to a target label.
I left a FIXME here about having the "if" statement return the result
value from the taken branch statement. That's what the AST interpreter
does but I'm not sure if it's actually required.
If there's a current Bytecode::Interpreter in action, ScriptFunction
will now compile itself into bytecode and execute in that context.
This patch also adds the Return bytecode instruction so that we can
actually return values from called functions. :^)
Return values are propagated from callee to caller via the caller's
$0 register. Bytecode::Interpreter now keeps a stack of register
"windows". These are not very efficient, but it should be pretty
straightforward to convert them to e.g a sliding register window
architecture later on.
This is pretty dang cool! :^)
This patch adds the Call bytecode instruction which is emitted for the
CallExpression AST node.
It's pretty barebones and doesn't handle 'this' values properly, etc.
But it can perform basic function calls! :^)
Note that the called function will *not* execute as bytecode, but will
simply fall back into the old codepath and use the AST interpreter.
This is intended to perform the same duties as enter_scope() does in
the AST tree-walk interpreter:
- Hoisted function declaration processing
- Hoisted variable declaration processing
- ... maybe more
This first cut only implements the function declaration processing.
This was quite straightforward using the same label/jump machinery that
we added for while statements.
The main addition here is a new JumpIfTrue bytecode instruction.
This introduces two new instructions: Jump and JumpIfFalse.
Jumps are made to a Bytecode::Label, which is a simple object that
represents a location in the bytecode stream.
Note that you may not always know the target of a jump when adding the
jump instruction itself, but we can just update the instruction later
on during codegen once we know where the jump target is.
The Bytecode::Interpreter now implements jumping via a jump slot that
gets checked after each instruction to see if a jump is pending.
If not, we just increment the PC as usual.
- NewString (allocates a new PrimitiveString from the GC heap)
- GetVariable (retrieves a variable in the current scope)
- SetVariable (assigns a variable in the current scope)
This patch begins the work of implementing JavaScript execution in a
bytecode VM instead of an AST tree-walk interpreter.
It's probably quite naive, but we have to start somewhere.
The basic idea is that you call Bytecode::Generator::generate() on an
AST node and it hands you back a Bytecode::Block filled with
instructions that can then be interpreted by a Bytecode::Interpreter.
This first version only implements two instructions: Load and Add. :^)
Each bytecode block has infinity registers, and the interpreter resizes
its register file to fit the block being executed.
Two new `js` options are added in this patch as well:
`-d` will dump the generated bytecode
`-b` will execute the generated bytecode
Note that unless `-d` and/or `-b` are specified, none of the bytecode
related stuff in LibJS runs at all. This is implemented in parallel
with the existing AST interpreter. :^)
And use them to highlight javascript in HTML source.
This commit also changes how TextDocumentSpan::data is interpreted,
as it used to be an opaque pointer, but everyone stuffed an enum value
inside it, which made the values not unique to each highlighter;
that field is now a u64 serial id.
The syntax highlighters don't need to change their ways of stuffing
token types into that field, but a highlighter that calls another
nested highlighter needs to register the nested types for use with
token pairs.
This patch moves the magnifier rect computation over to the server side
to ensure that the mouse cursor position and the screen image never get
out of sync.
This is just a simple helper that dumps the current VM call stack
to the debug console. I find myself rewriting this function over and
over, so let's just have it in the tree.
This is now a bit closer to the spec's 10.4.2.2 ArrayCreate - it will
throw a RangeError if the requested length exceeds 2^32 - 1, so anyone
passing in a custom value (defaults to zero for same behaviour as
before) will need an exception check at the call site.
4d5cdcc893 partially reverted the changes
from d8c5eeceab, but it reverted too much
and reintroduced the bug.
This commit finally fixes the actual bug.
The author hasn't been in his best committing state today.
This adds the new flag -R for the crash utility which tests what
happens when we dereference a null RefPtr. This is useful for testing
the output of the assertion message.
This implements the dladdr() function which lets the caller look up
the symbol name, symbol address as well as library name and library
base address for an arbitrary address.
We're already keeping it alive via `m_notifier`.
This makes the event loop quitting logic simpler by making less
deferred calls and removes a race condition where the notifier would be
deleted before the second deferred_invoke() would be invoked, leading
to a nullptr dereference.
Fixes#7822.
Since DateTime stores months as 1 to 12, while JS accepts months as
0 to 11, we have to account for the difference (by subtracting or
adding 1) where appropriate.
Since theres no way to drop the arguments before the call to the
constructor (or to signal to the constructor that it was not called
directly), we simply reuse the code for the no arguments provided
special case. (And to prevent code duplication, the code was extracted
into the separate static function Date::now(GlobalObject&).
When using Core::DateTime::from_timestamp(0) the resulting Date is
1970-01-01 00:00:00 in UTC, which might be something different in local
time - this is incorrect and relevant as invalid Dates can be made valid
later on.
This is now about as close to the spec as it gets - instead of querying
the |this| value inside of the function, we now pass it in from the
outside.
Also get rid of the oddly specific error messages, they're nice but
pretty inconsistent with most others. Let's prefer consistency and
simplicity for now.
Other than that, no functionality change.
Throws an exception if the given value is nullish, returns it otherwise.
We can now gradually replace such manual checks with this function where
applicable.
This also has the advantage that the somewhat useless "ToObject on null
or undefined" will be replaced with "null cannot be converted to an
object" or "undefined cannot be converted to an object". :^)
This commit initializes the LibVideo library and implements parsing
basic Matroska container files. Currently, it will only parse audio
and video tracks.
This changes the RequestClient::start_request() method to take a URL
object instead of a URL string as argument. All callers of the method
already had a URL object anyway, and start_request() in turn parses the
URL string back into a URL object. This removes this unnecessary
conversion.
By moving the logic to determine what window areas (shadow, frame,
content) into WindowFrame::opaque/transparent_render_rects we can
simplify the occlusion calculation and properly handle more
arbitrary opaque/transparent areas.
This also solves the problem where we would render the entire
window frame as transparency only because the frame had a window
shadow.
I have no idea *why*, but this stopped working suddenly:
return { { .code_point = '-', .is_character_class = false } };
Fails with:
error: could not convert ‘{{'-', false}}’ from
‘<brace-enclosed initializer list>’ to
‘AK::Optional<regex::CharClassRangeElement>
Might be related to 66f15c2 somehow, going one past that commit makes
the build work again, however reverting the commit doesn't. Not sure
what's up with that.
Consider this patch a band-aid until we can find the reason and an
actual fix...
Compiler version:
gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3)
This patch removes some FIXMEs from the StyleResolver, specifically
adding the proper float-parsing to the flex: shorthand. The
functionality was already there it just didn't get plumbed in before.
The line history is unavailable if the alternate screen buffer is
currently enabled. However, since TerminalWidget uses the history size
to offset its line numbers when rendering, it will try to render
inaccessible lines once the history is not empty anymore.
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
According to the definition at https://sqlite.org/lang_expr.html, SQL
expressions could be infinitely deep. For practicality, SQLite enforces
a maxiumum expression tree depth of 1000. Apply the same limit in
LibSQL to avoid stack overflow in the expression parser.
Fixes https://crbug.com/oss-fuzz/34859.
The specification requires that we immediately return Infinity during
the iteration over the arguments if positive or negative infinity is
encountered, and return a NaN if it is encountered and no Infinity was
found. The specification also requires all arguments to be coerced into
numbers before the operation starts, or else a number conversion
exception could be missed due to the Infinity/NaN early return.
The specification requires that we immediately return a NaN during the
iteration over the arguments if one is encountered. It also requires
all arguments to be coerced into numbers before the operation starts,
or else a number conversion exception could be missed due to the NaN
early return.
When clicking on the TreeView in profiler without selecting a node and
then pressing up or pgup, cursor_index was in an invalid state. Instead
select the first node in the index.
On most (if not all) systems rm ignores an empty paths array if -f or
--force is specified. This helps with scripts that may pass an empty
variable where the file paths are supposed to go.
This changes the C++ SyntaxHighlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
Contrary to other syntax highlighters, for this one the change has been
made to the SyntaxHighlighter rather than the Lexer. This is due to the
fact that the Parser also uses the same Lexer. I'm soure there is some
more elegant way to do this, but this patch at least unbreaks the C++
syntax highlighting.
If an include statement didn't contain whitespace between the word
"include" and the '<' or '"', the lexer would previous emit an empty
whitespace token. This has been changed now.
This patch aims to fix wrong highlighting for some cases in HTML's
syntax highlighter. The values were somewhat experimentally determined
are are subject to change. Regardless, it should be more correct with
this patch than without it. :^)
This changes the HTML SyntaxHighlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor. It also
avoids emitting tokens if they have a zero or negative length.
This fixes a bug where single-character tokens were not highlighted
properly.
This patch changes HTMLTokenizer::nth_last_position to not fail if the
requested position is not available. Rather, it will just return (0-0).
While this is not the correct solution, it prevents the tokenizer from
crashing just because it cannot find a source position. This should only
affect SyntaxHighlighter.
This changes the Shell syntax highlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
This also adds some debug output to make debugging easier.
This changes the INI and GML lexers to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
The other user of GMLToken::m_end, GMLAutocompleteProvider, has been
modified to take into account that end position columns have been
incremented by one.
This fixes an off-by-one error in TextEditor's rendering of the syntax
highlighting as generated by Syntax::Highlighter and its subclasses.
Before, a single character span was e.g. (0-3) to (0-3), but this was
considered invalid by GUI::TextRange. Now, a single character span would
be e.g. (0-3) to (0-4).
This fix requires all Syntax::Highlighter subclasses to be adjusted, as
they all relied on the previous implementation. This will then also fix
a bug where single-character HTML tags wouldn't be highlighted.
Previously, when traversing the ClassView tree to find the parent of a
new node, we used the name of the node's declaration to find the path
to the parent in the tree.
However, some nodes in the tree do not have a matching declaration,
which caused a VERIFY failure.
To fix this, we now use the node's name when walking the tree.
We can do this because the node's name should be identical to the name
of its declaration.
Closes#7702.
Now that the cards have rounded corners, draw the stack box behind the
cards with rounded corners as well. This way, the corner of the stack
box doesn't peek out from behind the cards.
The caveat here is that the "play" card stack now needs to hold a
reference to the "waste" stack beneath it so it knows when not to draw
its background on top of the waste stack. To faciliate that, the array
of card stacks is now a NonnullRefPtrVector so the play stack can store
a smart pointer to the waste stack (instead of a raw pointer or
reference).
Now that Desktop.h includes Services/Taskbar/TaskbarWindow.h we have
to install Taskbar's header files so that Desktop.h can be used in
ports or when building software in-target.
This fixes an issue where this would be bound to the global object
by default when operating in strict mode.
According to the specification, the expected value for |this| when
no binding is provided is undefined.
Instead of manually specifying the types and names of imports to stub
out, `--export-noop` can be used to export stub functions for any
unresolved function import.
This makes running and debugging random wasm files much easier.
This commit is a fairly large refactor, mainly because it unified the
two different ways that existed to represent references.
Now Reference values are also a kind of value.
It also implements a printer for values/references instead of copying
the implementation everywhere.