Commit graph

13476 commits

Author SHA1 Message Date
Linus Groh
f4d0babd5d LibJS: Make assignment to CallExpression a syntax error in strict mode 2020-10-05 09:25:04 +02:00
Linus Groh
283ee678f7 LibJS: Validate all assignment expressions, not just "="
The check for invalid lhs and assignment to eval/arguments in strict
mode should happen for all kinds of assignment expressions, not just
AssignmentOp::Assignment.
2020-10-05 09:25:04 +02:00
Linus Groh
e80217a746 LibJS: Unify syntax highlighting
So far we have three different syntax highlighters for LibJS:

- js's Line::Editor stylization
- JS::MarkupGenerator
- GUI::JSSyntaxHighlighter

This not only caused repetition of most token types in each highlighter
but also a lot of inconsistency regarding the styling of certain tokens:

- JSSyntaxHighlighter was considering TokenType::Period to be an
  operator whereas MarkupGenerator categorized it as punctuation.
- MarkupGenerator was considering TokenType::{Break,Case,Continue,
  Default,Switch,With} control keywords whereas JSSyntaxHighlighter just
  disregarded them
- MarkupGenerator considered some future reserved keywords invalid and
  others not. JSSyntaxHighlighter and js disregarded most

Adding a new token type meant adding it to ENUMERATE_JS_TOKENS as well
as each individual highlighter's switch/case construct.

I added a TokenCategory enum, and each TokenType is now associated to a
certain category, which the syntax highlighters then can use for styling
rather than operating on the token type directly. This also makes
changing a token's category everywhere easier, should we need to do that
(e.g. I decided to make TokenType::{Period,QuestionMarkPeriod}
TokenCategory::Operator for now, but we might want to change them to
Punctuation.
2020-10-04 23:41:31 +02:00
AnotherTest
6b55b007dd HackStudio: Add a Shell language server 2020-10-04 23:12:28 +02:00
AnotherTest
7f3e1fa826 Shell: Fix closest command node detection in Pipes and Sequences
This makes --option completions work for pipes and sequences too.
2020-10-04 23:12:28 +02:00
AnotherTest
a9cee8ee02 Shell+LibLine: Record the input offset of completions
This makes the completion entry retain information about how much of the
suggestion was part of the string that caused the match.
2020-10-04 23:12:28 +02:00
AnotherTest
f164b808b5 Shell: Move everything to the Shell namespace
Also provide a basic default-constructor.
2020-10-04 23:12:28 +02:00
AnotherTest
34039d6639 HackStudio: Do not change the cursor in the LSP autocomplete request
The C++ completion somehow depends on this, so move that behaviour into
the C++ language server instead.
2020-10-04 23:12:28 +02:00
AnotherTest
9e73b0b696 HackStudio: Relay completions requests to the language server unfiltered
Previously, the client would decide when to ask the server for
completions, and it would only do so for identifiers that had spans
(determined via the highlighter!).
Swap this around and make the server decide if it wants to complete
something.
This commit also adds a CompletionKind (which only has one value:
Identifier), to work with other kinds of completions as well.
2020-10-04 23:12:28 +02:00
AnotherTest
b42c6ea281 LibIPC: Make IPC::encode() and ::decode() fail at compiletime when used
This would previously fail at runtime, and it would have zero indication
of what exactly went wrong.
Also adds `AK::DependentFalse<Ts...>', which is a...dependent false.
2020-10-04 23:12:28 +02:00
Andreas Kling
fdb0ac7c1e LibJS: Remove some unused Interpreter member functions 2020-10-04 23:10:07 +02:00
Andreas Kling
94b95a4924 LibJS: Remove Interpreter::call()
Just use VM::call() directly everywhere.
2020-10-04 23:08:49 +02:00
Andreas Kling
ec55490198 LibJS: Make global objects have unique shape from the start
There's no point in trying to achieve shape sharing for global objects,
so we can simply make the shape unique from the start and avoid making
a transition chain.
2020-10-04 22:56:45 +02:00
Andreas Kling
2864cb66c0 LibJS: Avoid an unnecessary MarkedValueList copy in VM::call_internal() 2020-10-04 22:42:24 +02:00
Andreas Kling
2852ce4954 LibJS: Always inline HeapBlock::allocate()
This thing is so simple and sits on the hot path so just inline it.
2020-10-04 19:25:49 +02:00
Andreas Kling
ad0d377e4c LibJS: Pre-size the hash map and vector used in ensure_property_table() 2020-10-04 19:25:49 +02:00
Andreas Kling
b7975abef8 LibJS: Don't force property table reification on Shape::property_count()
Previously whenever you would ask a Shape how many properties it had,
it would reify the property table into a HashMap and use HashMap::size()
to answer the question.

This can be a huge waste of time if we don't need the property table for
anything else, so this patch implements property count tracking in a
separate integer member of Shape. :^)
2020-10-04 19:25:49 +02:00
Andreas Kling
d01b746d88 LibJS: Add StringOrSymbol constructor that takes a FlyString
This avoids refcount churn from implicit conversion in some places.
2020-10-04 19:25:49 +02:00
Andreas Kling
3d053f244f LibJS: Avoid creating a temporary String in StringOrSymbol::operator== 2020-10-04 19:25:49 +02:00
Andreas Kling
d542049596 LibJS: Avoid StringImpl refcount churn when hashing StringOrSymbol
Add a StringOrSymbol::hash() helper function so we can compute the hash
without having to construct a temporary String.
2020-10-04 19:25:49 +02:00
Andreas Kling
cfd141b4f9 LibJS: Avoid unnecessary StringImpl copy in StringOrSymbol(String) 2020-10-04 19:25:49 +02:00
Linus Groh
5de5af60c1 LibJS: Replace a few dbg() with dbgln() 2020-10-04 19:22:02 +02:00
Linus Groh
123f98201e LibJS: Use String::formatted() in various other places 2020-10-04 19:22:02 +02:00
Linus Groh
2e2571743b LibJS: Use string::formatted() in to_string() functions 2020-10-04 19:22:02 +02:00
Linus Groh
bc701658f8 LibJS: Use String::formatted() for parser error messages 2020-10-04 19:22:02 +02:00
Linus Groh
f9eaac62d9 LibJS: Use String::formatted() for throw_exception() message 2020-10-04 19:22:02 +02:00
Linus Groh
a27668cbae LibJS: Use String::formatted() in MarkupGenerator 2020-10-04 19:22:02 +02:00
asynts
59e7ffa86d AK: Make the return type of dbgputstr consistent. 2020-10-04 19:18:32 +02:00
Andreas Kling
4cf3a1eb41 Browser: Remove dbgln() statement that was crashing on startup
Don't have time to dig into this right now, but let's unbreak Browser.
2020-10-04 17:12:11 +02:00
Andreas Kling
6f5322409d Browser: Fix build after dbgf() -> dbgln() rename 2020-10-04 17:09:01 +02:00
asynts
e089855af0 UserspaceEmulator: Remove remaining printf calls. 2020-10-04 17:04:55 +02:00
asynts
d5ffb51a83 AK: Don't add newline for outf/dbgf/warnf.
In the future all (normal) output should be written by any of the
following functions:

    out    (currently called new_out)
    outln
    dbg    (currently called new_dbg)
    dbgln
    warn   (currently called new_warn)
    warnln

However, there are still a ton of uses of the old out/warn/dbg in the
code base so the new functions are called new_out/new_warn/new_dbg. I am
going to rename them as soon as all the other usages are gone (this
might take a while.)

I also added raw_out/raw_dbg/raw_warn which don't do any escaping,
this should be useful if no formatting is required and if the input
contains tons of curly braces. (I am not entirely sure if this function
will stay, but I am adding it for now.)
2020-10-04 17:04:55 +02:00
Andreas Kling
4237089a21 LibJS: Remove unused Heap::interpreter() 2020-10-04 17:03:33 +02:00
Andreas Kling
bfa97b9357 LibJS: Remove Cell::interpreter()
It's never necessary to find the current Interpreter for a given Cell
anymore. Get rid of this accessor.
2020-10-04 17:03:33 +02:00
Andreas Kling
a007b3c379 LibJS: Move "strict mode" state to the call stack
Each call frame now knows whether it's executing in strict mode.
It's no longer necessary to access the scope stack to find this mode.
2020-10-04 17:03:33 +02:00
Andreas Kling
f41b5a4535 AK: Add Formatter for FlyString :^) 2020-10-04 17:03:33 +02:00
asynts
616af36d91 Browser: Use format functions instead of printf. 2020-10-04 14:23:25 +02:00
asynts
b23f66e151 AK: Add formatter for URL. 2020-10-04 14:23:25 +02:00
asynts
aa283d235a AK: Add special formatter for char.
When we format a character we want to put the ascii value and not the
decimal value. The old behaviour can be obtained with '{:d}'.
2020-10-04 14:23:25 +02:00
Matthew Olsson
6eb6752c4c LibJS: Strict mode is now handled by Functions and Programs, not Blocks
Since blocks can't be strict by themselves, it makes no sense for them
to store whether or not they are strict. Strict-ness is now stored in
the Program and FunctionNode ASTNodes. Fixes issue #3641
2020-10-04 10:46:12 +02:00
Peter Elliott
1b3f9c170c Userland: tar: support extracting gzipped files 2020-10-04 00:16:40 +02:00
Peter Elliott
b7c7c80ee2 Userland: Add tar command 2020-10-04 00:16:40 +02:00
Peter Elliott
99ee93149c LibTar: Create LibTar and TarStream
TarStream parses the contents of a tar file from an InputStream
2020-10-04 00:16:40 +02:00
asynts
1f90e4ab8d AK: Replace a write_or_error call with write.
Implicit conversions suck...
2020-10-03 20:16:26 +02:00
asynts
b33921531d AK: Make Buffered<T> non-copyable. 2020-10-03 20:16:26 +02:00
Andreas Kling
e64f43c3a7 LibGUI: Fix null pointer dereference in enter/leave event handling
If an enter/leave event is delivered to a widget after it is removed
from a window, we can't just assume a window is gonna be there.

Fixes #3669.
2020-10-03 19:47:56 +02:00
Andreas Kling
3b2120e7b6 LibGUI: Don't paint borders for invisible bars in ToolBarContainer 2020-10-03 19:43:25 +02:00
asynts
9f00afd8cd AK: Add missing Bytes::slice call in Buffered<T>. 2020-10-03 17:33:14 +02:00
Andreas Kling
00f47bba23 LibGUI: Don't accomodate invisible children in ToolBarContainer height
Skip over invisible children so they don't take up vertical space in
the container. Also make sure we update the preferred size whenever the
widget layout is invalidated.

Fixes #3139.
2020-10-03 14:01:37 +02:00
AnotherTest
2c3842bfe6 Shell: Fix badly worded help string for '--format' 2020-10-03 12:40:03 +02:00