Commit Graph

1051 Commits

Author SHA1 Message Date
Sergey Bugaev
eb7af00152 Userland: Use Core::File::read_link() 2020-06-17 15:02:03 +02:00
Andreas Kling
1678aaa555 ProtocolServer+LibProtocol: Propagate HTTP status codes to clients
Clients now receive HTTP status codes like 200, 404, etc.
Note that a 404 with content is still considered a "successful"
download from ProtocolServer's perspective. It's up to the client
to interpret the status code.

I'm not sure if this is the best API, but it'll work for now.
2020-06-13 22:20:37 +02:00
Matthew Olsson
e8e728454c AK: JsonParser improvements
- Parsing invalid JSON no longer asserts
    Instead of asserting when coming across malformed JSON,
    JsonParser::parse now returns an Optional<JsonValue>.
- Disallow trailing commas in JSON objects and arrays
- No longer parse 'undefined', as that is a purely JS thing
- No longer allow non-whitespace after anything consumed by the initial
  parse() call. Examples of things that were valid and no longer are:
    - undefineddfz
    - {"foo": 1}abcd
    - [1,2,3]4
- JsonObject.for_each_member now iterates in original insertion order
2020-06-13 12:43:22 +02:00
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
Andreas Kling
5042e560ef LibJS: Make more Interpreter functions take a GlobalObject& 2020-06-08 21:25:16 +02:00
Linus Groh
5072d4e02d LibJS+js: Support getting last value from "_" variable
The interpreter now has an "underscore is last value" flag, which makes
Interpreter::get_variable() return the last value if:

- The m_underscore_is_last_value flag is enabled
- The name of the variable lookup is "_"
- The result of that lookup is an empty value

That means "_" can still be used as a regular variable and will stop
doing its magic once anything is assigned to it.

Example REPL session:

> 1
1
> _ + _
2
> _ + _
4
> _ = "foo"
"foo"
> 1
1
> _
"foo"
> delete _
true
> 1
1
> _
1
>
2020-06-08 14:01:31 +02:00
Hüseyin ASLITÜRK
f306ddb78b Userland: Remove keymap app from system
We have new KeyboardSettings application and it supports both GUI and CLI.
2020-06-08 09:28:18 +02:00
AnotherTest
0fe3b0dbaf functrace: Output colors only when stdout is a tty 2020-06-08 09:27:51 +02:00
AnotherTest
07c070745f ls: Emit plain text when output is not a tty 2020-06-08 09:27:51 +02:00
Linus Groh
0ff9d7e189 LibJS: Add BigInt 2020-06-07 19:29:40 +02:00
AnotherTest
40829b849a Meta: Run Crypto tests in CI
We skip the tests that are not self-contained (TLS) to avoid adding
extra variables to the tests.
2020-06-07 19:29:40 +02:00
AnotherTest
a3ff4ff8a1 test-crypto: Return 1 if any test failed 2020-06-07 19:29:40 +02:00
AnotherTest
02c53fd1f9 LibCrypto: Add bitwise operations (and/or/xor) 2020-06-07 19:29:40 +02:00
Matthew Olsson
61ac1d3ffa LibJS: Lex and parse regex literals, add RegExp objects
This adds regex parsing/lexing, as well as a relatively empty
RegExpObject. The purpose of this patch is to allow the engine to not
get hung up on parsing regexes. This will aid in finding new syntax
errors (say, from google or twitter) without having to replace all of
their regexes first!
2020-06-07 19:06:55 +02:00
Sergey Bugaev
f2f1975baa Userland: Add find(1)
This is a somewhat incomplete implementation of the Unix find command :^)

Closes https://github.com/SerenityOS/serenity/issues/272
2020-06-06 14:42:31 +02:00
AnotherTest
d8208fd37c LibCrypto: Add a simple SignedBigInteger
This patchset adds a simple SignedBigInteger that is entirely defined in
terms of UnsignedBigInteger.

It also adds a NumberTheory::Power function, which is terribly
inefficient, but since the use of exponentiation is very much
discouraged for large inputs, no particular attempts were made
to make it more performant.
2020-06-05 13:29:44 +02:00
AnotherTest
a3f51089d2 test-crypto: Add a test for #2488 2020-06-04 15:58:04 +02:00
Hüseyin ASLITÜRK
92d03931d6 Userland: keymap, use LibKeyboard to read keymap files 2020-06-03 21:52:40 +02:00
Linus Groh
6c89303e7e js: Print call stack on exception thrown outside the global context 2020-06-02 15:22:34 +02:00
Linus Groh
a48080f62d LibJS: Move Interpreter::get_trace() to ConsoleClient
Having it globally on the interpreter is confusing as the last call frame
is skipped, which is specific to console.trace().
2020-06-02 15:22:34 +02:00
Marcin Gasperowicz
a60a5bc70a Userland/js: Add global property to the global object + help fix
This adds a `global` property to the global object so that 
`global == this` when typed into the REPL.

This matches what Node.js does and helps with testing on existing 
JS code that uses `global` to detect its environment.
2020-06-02 13:50:19 +02:00
Sergey Bugaev
05b7fec517 Kernel: Tighten up some promise checks
Since we're not keeping compatibility with OpenBSD about what promises are
required for which syscalls, tighten things up so that they make more sense.
2020-05-31 21:38:50 +02:00
Andreas Kling
853d900ee8 pro: Show download progress in the terminal window if available :^) 2020-05-30 23:00:35 +02:00
AnotherTest
4aa3d08e21 Userland/js: Prompt for more input on labels and object keys
Closes #2452
2020-05-30 20:35:48 +02:00
Sergey Bugaev
c742306b6f Userland: Port nc(1) to use Core::ArgsParser 2020-05-30 15:01:18 +02:00
Sergey Bugaev
e12388c349 Userland: Treat all text/* MIME types as text when pasting
It's a bit weird to get a newline after plain text but not after, say, a URL
list.
2020-05-30 15:01:18 +02:00
FalseHonesty
20faa93cb0 LibMarkdown: Change internal MD API to return OwnPtrs
Previously, all Markdown blocks had a virtual parse method which has
been swapped out for a static parse method returning an OwnPtr of
that block's type.

The Text class also now has a static parse method that will return an
Optional<Text>.
2020-05-30 00:32:12 +02:00
FalseHonesty
7ca562b200 LibMarkdown: Change MD Document parse API to return a RefPtr
Markdown documents are now obtained via the static Document::parse
method, which returns a RefPtr<Document>, or nullptr on failure.
2020-05-30 00:32:12 +02:00
AnotherTest
2a241a11bb LibCrypto: Fix some issues preventing compilation w/ clang 10 2020-05-29 20:17:12 +02:00
Sergey Bugaev
3847d00727 Kernel+Userland: Support remounting filesystems :^)
This makes it possible to change flags of a mount after the fact, with the
caveats outlined in the man page.
2020-05-29 07:53:30 +02:00
Sergey Bugaev
4b300e085d Userland+SystemMonitor: Recognize the MS_RDONLY mount flag 2020-05-29 07:53:30 +02:00
Sergey Bugaev
67cbc015d5 Userland: Fix displaying mount source
The key is now called "source" instead of "device".
2020-05-29 07:53:30 +02:00
Andreas Kling
42243d2e06 LibWeb: Rename Web::HtmlView => Web::PageView
This widget doesn't just view HTML, it views a web page. :^)
2020-05-28 18:22:54 +02:00
Matthew Olsson
786722149b LibJS: Add strict mode
Adds the ability for a scope (either a function or the entire program)
to be in strict mode. Scopes default to non-strict mode.

There are two ways to determine the strict-ness of the JS engine:

1. In the parser, this can be accessed with the parser_state variable
   m_is_strict_mode boolean. If true, the Parser is currently parsing in
   strict mode. This is done so that the Parser can generate syntax
   errors at parse time, which is required in some cases.

2. With Interpreter.is_strict_mode(). This allows strict mode checking
   at runtime as opposed to compile time.

Additionally, in order to test this, a global isStrictMode() function
has been added to the JS ReplObject under the test-mode flag.
2020-05-28 17:18:42 +02:00
Matthew Olsson
5ae9419a06 LibJS: Object index properties have descriptors; Handle sparse indices
This patch adds an IndexedProperties object for storing indexed
properties within an Object. This accomplishes two goals: indexed
properties now have an associated descriptor, and objects now gracefully
handle sparse properties.

The IndexedProperties class is a wrapper around two other classes, one
for simple indexed properties storage, and one for general indexed
property storage. Simple indexed property storage is the common-case,
and is simply a vector of properties which all have attributes of
default_attributes (writable, enumerable, and configurable).

General indexed property storage is for a collection of indexed
properties where EITHER one or more properties have attributes other
than default_attributes OR there is a property with a large index (in
particular, large is '200' or higher).

Indexed properties are now treated relatively the same as storage within
the various Object methods. Additionally, there is a custom iterator
class for IndexedProperties which makes iteration easy. The iterator
skips empty values by default, but can be configured otherwise.
Likewise, it evaluates getters by default, but can be set not to.
2020-05-28 17:17:13 +02:00
Andreas Kling
5e53c45113 LibWeb: Plumb content encoding into the new HTML parser
We still don't handle non-ASCII input correctly, but at least now we'll
convert e.g ISO-8859-1 to UTF-8 before starting to tokenize.
This patch also makes "view source" work with the new parser. :^)
2020-05-28 12:35:19 +02:00
AnotherTest
0b98924ee7 Userland: Add a basic xargs
This adds a basic implementation of xargs.
The implemenation is missing quite a few options, and is not entirely
POSIX-compliant, but it gets the job done :^)
2020-05-28 11:01:08 +02:00
Matthew Olsson
dd08c992e8 LibJS: Simplify and normalize publicly-exposed Object functions
Previously, the Object class had many different types of functions for
each action. For example: get_by_index, get(PropertyName),
get(FlyString). This is a bit verbose, so these methods have been
shortened to simply use the PropertyName structure. The methods then
internally call _by_index if necessary. Note that the _by_index
have been made private to enforce this change.

Secondly, a clear distinction has been made between "putting" and
"defining" an object property. "Putting" should mean modifying a
(potentially) already existing property. This is akin to doing "a.b =
'foo'".

This implies two things about put operations:
    - They will search the prototype chain for setters and call them, if
      necessary.
    - If no property exists with a particular key, the put operation
      should create a new property with the default attributes
      (configurable, writable, and enumerable).

In contrast, "defining" a property should completely overwrite any
existing value without calling setters (if that property is
configurable, of course).

Thus, all of the many JS objects have had any "put" calls changed to
"define_property" calls. Additionally, "put_native_function" and
"put_native_property" have had their "put" replaced with "define".

Finally, "put_own_property" has been made private, as all necessary
functionality should be exposed with the put and define_property
methods.
2020-05-27 13:17:35 +02:00
Andreas Kling
59a32f29b0 test-crypto: Tweaks to make this build properly in Lagom 2020-05-27 12:39:58 +02:00
AnotherTest
70a213a6ec LibLine: Use Core::EventLoop for outer read loop
This commit changes LibLine's internal structure to work in an event
loop, and as a result, also switches it to being a Core::Object.
2020-05-27 11:13:02 +02:00
Paul Redmond
11405c5139
LibJS: Fix incorrect token column values (#2401)
- initializing m_line_column to 1 in the lexer results in incorrect
  column values in tokens on the first line of input.
- not incrementing m_line_column when EOF is reached results in
  an incorrect column value on the last token.
2020-05-26 19:00:30 +02:00
Linus Groh
015d65bc6f js: Show a "source location hint" for syntax errors :^) 2020-05-26 14:36:30 +02:00
Sergey Bugaev
602c3fdb3a AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath.

This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
4139838a93 Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
62283ade91 Userland: Port sleep(1) to Core::ArgsParser 2020-05-26 14:35:10 +02:00
AnotherTest
bc9013f706 LibLine: Change get_line to return a Result<String, Error>
This fixes a bunch of FIXME's in LibLine.
Also handles the case where read() would read zero bytes in vt_dsr() and
effectively block forever by erroring out.

Fixes #2370
2020-05-25 21:36:51 +02:00
Andreas Kling
45da08a1e6 LibWeb: A whole bunch of work towards spec-compliant <script> elements
This is still very unfinished, but there's at least a skeleton of code.
2020-05-24 23:54:22 +02:00
Andreas Kling
20911efd4d LibWeb: More work on the HTML parser and tokenizer
The parser can now switch the state of the tokenizer! Very webby. :^)
2020-05-24 23:54:22 +02:00
Itamar
10bdb6f33b functrace: use Core::ArgsParser 2020-05-24 10:42:21 +02:00
Andreas Kling
fd1b31d0ff LibWeb: Start building the tree building part of the new HTML parser
This patch adds a new HTMLDocumentParser class. It keeps a tokenizer
object internally and feeds itself with one token at a time from it.

The names and idioms in this class are expressed as closely to the
actual HTML parsing spec as possible, to make development as easy
and bug free as possible. :^)

This is going to become pretty large, but it's pretty cool!
2020-05-24 00:14:23 +02:00
Andreas Kling
ede44853d1 Userland: Allow passing a specific HTML file to the "ht" test program 2020-05-23 18:44:32 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
AnotherTest
0446b7e347 Userland/js: Do not construct a full CompletionSuggestion just to compare against 2020-05-23 01:31:41 +02:00
Andreas Kling
494870e696 Userland: Add a missing license header 2020-05-22 23:16:22 +02:00
Andreas Kling
272b35d2e1 LibWeb: Begin work on a spec-compliant HTML parser
In order to actually view the web as it is, we're gonna need a proper
HTML parser. So let's build one!

This patch introduces the Web::HTMLTokenizer class, which currently
operates on a StringView input stream where it fetches (ASCII only atm)
codepoints and tokenizes acccording to the HTML spec tokenization algo.

The tokenizer state machine looks a bit weird but is written in a way
that tries to mimic the spec as closely as possible, in order to make
development easier and bugs less likely.

This initial version is far from finished, but it can parse a trivial
document with a DOCTYPE and open/close tags. :^)
2020-05-22 21:46:13 +02:00
Andreas Kling
250c3b363d Revert "Build: Include headers from LibC, LibM, and LibPthread with -isystem"
This reverts commit c1eb744ff0.
2020-05-20 16:24:26 +02:00
AnotherTest
7fba21aefc LibLine: Unify completion hooks and adapt its users
LibLine should ultimately not care about what a "token" means in the
context of its user, so force the user to split the buffer itself.
This also allows the users to pick up contextual clues as well, since
they have to lex the line themselves.

This commit pacthes Shell and the JS repl to better handle completions,
so certain wrong behaviours are now corrected as well:
- JS repl can now complete "Object . getOw<tab>"
- Shell can now complete "echo | ca<tab>" and paths inside strings
2020-05-20 13:41:37 +02:00
Andrew Kaster
c1eb744ff0 Build: Include headers from LibC, LibM, and LibPthread with -isystem
Make sure that userspace is always referencing "system" headers in a way
that would build on target :). This means removing the explicit
include_directories of Libraries/LibC in favor of having it export its
headers as SYSTEM. Also remove a redundant include_directories of
Libraries in the 'serenity build' part of the build script. It's already
set at the top.

This causes issues for the Kernel, and for crt0.o. These special cases
are handled individually.
2020-05-20 08:37:50 +02:00
Andrew Kaster
3de808e860 df: Don't include c++ standard <cstring>
Use string.h instead, since that's part of serenity :)
2020-05-20 08:37:50 +02:00
Andreas Kling
9eaf22090f test-crypto: Don't put TLSv12 in an OwnPtr as it's ref-counted :) 2020-05-18 20:15:56 +02:00
AnotherTest
3bc3f36cfe LibLine: Handle unicode correctly
This commit also fixes a problem with us throwing out data that was
inserted while a command was running.
2020-05-18 11:31:43 +02:00
Linus Groh
476094922b LibJS: Pass Interpreter& to Value::to_number() et al.
This patch is unfortunately rather large and might make some things feel
bloated, but it is necessary to fix a few flaws in LibJS, primarily
blindly coercing values to numbers without exception checks - i.e.

interpreter.argument(0).to_i32();  // can fail!!!

Some examples where the interpreter would actually crash:

var o = { toString: () => { throw Error() } };
+o;
o - 1;
"foo".charAt(o);
"bar".repeat(o);

To fix this, we now have the following...

to_double(Interpreter&)
to_i32()
to_i32(Interpreter&)
to_size_t()
to_size_t(Interpreter&)

...and a whole lot of exception checking.

There's intentionally no to_double(), use as_double() directly instead.

This way we still can use these convenient utility functions but don't
need to check for exceptions if we are sure the value already is a
number.

Fixes #2267.
2020-05-18 09:39:55 +02:00
Linus Groh
1a1394f7a2 LibJS: Change Value::to_object(Heap& -> Interpreter&)
Passing a Heap& to it only to then call interpreter() on that is weird.
Let's just give it the Interpreter& directly, like some of the other
to_something() functions.
2020-05-18 09:39:55 +02:00
Andreas Kling
cc42d75209 ls: Make column alignment Unicode-aware :^)
You can now have emojis in file names and they will line up correctly
in "ls" output.
2020-05-17 13:05:39 +02:00
Andreas Kling
21d5f4ada1 Kernel: Absorb LibBareMetal back into the kernel
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
2020-05-16 12:00:04 +02:00
Sergey Bugaev
acc107a44f FileManager+LibGUI+Userland: Switch clipboard to MIME types
We will now actually use MIME types for clipboard. The default type is now
"text/plain" (instead of just "text").

This also fixes some issues in copy(1) and paste(1).
2020-05-16 09:11:46 +02:00
Andreas Kling
c6ddbd1f3e LibJS: Add side-effect-free version of Value::to_string()
There are now two API's on Value:

- Value::to_string(Interpreter&) -- may throw.
- Value::to_string_without_side_effects() -- will never throw.

These are some pretty big sweeping changes, so it's possible that I did
some part the wrong way. We'll work it out as we go. :^)

Fixes #2123.
2020-05-15 13:50:42 +02:00
Linus Groh
4e0ed34d7e js: Throw a regular SyntaxError for errors from the parser 2020-05-15 09:53:52 +02:00
Linus Groh
00b61a212f LibJS: Remove syntax errors from lexer
Giving the lexer the ability to generate errors adds unnecessary
complexity - also it only calls its syntax_error() function in one place
anyway ("unterminated string literal"). But since the lexer *also* emits
tokens like Eof or UnterminatedStringLiteral, it should be up to the
consumer of these tokens to decide what to do.

Also remove the option to not print errors to stderr as that's not
relevant anymore.
2020-05-15 09:53:52 +02:00
Andreas Kling
660f5baf8f ps: Widen the username column slightly 2020-05-15 00:01:01 +02:00
Andreas Kling
953669374c open: Create a Core::EventLoop before using Desktop::Launcher
We can't talk to IPC servers without having an event loop.
2020-05-14 20:22:20 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
3667677008 ls: Emit hyperlinks for files outside the current directory 2020-05-10 17:48:41 +02:00
AnotherTest
c40fd3a902 LibLine: Support RGB colors
This also patches Userland/js.
2020-05-10 10:23:05 +02:00
AnotherTest
ac701cb589 Userland: Send absolute paths to LaunchServer and show what failed 2020-05-10 00:39:14 +02:00
Andres Vieira
7433210fa6 Userland: Add unzip command
The unzip command will unzip a zip file passed as an argument into the
current pwd, with the syntax:
   unzip file.zip

This implementation is pretty barebones as it does not support things
like file access times, compression or even compression detection, so
if the user tries to unzip a compressed zip most probably he would find
wrong data inside the files.

However it's an starting point :^)
2020-05-09 23:50:44 +02:00
Linus Groh
325513b20d Userland: Add missing copyright header to test-crypto.cpp 2020-05-09 23:45:16 +02:00
Linus Groh
3153739d60 Userland: Add missing copyright header to disasm.cpp 2020-05-09 23:45:16 +02:00
Andreas Kling
00b87167fe ls: Make filenames in the output hyperlinked
This allows you to Ctrl+Click in Terminal to open files in "ls" output.
2020-05-09 16:17:47 +02:00
Nicholas Hollett
b7810a31c3 LibDesktop: Switch to LaunchServer for DesktopServices::open
Moves DirectoryServices out of LibCore (because we need to link with
LibIPC), renames it Desktop::Launcher (because Desktop::DesktopServices
doesn't scan right) and ports it to use the LaunchServer which is now
responsible for starting programs for a file.
2020-05-09 15:13:32 +02:00
Ben Wiederhake
eec99b23a0 Userland: Remove double-'#include' in date.cpp 2020-05-09 10:00:29 +02:00
Andreas Kling
5bfd893292 Kernel+Userland: Add "settime" pledge promise for setting system time
We now require the "settime" promise from pledged processes who want to
change the system time.
2020-05-08 22:54:17 +02:00
Linus Groh
9dbab2d05e Misc: Replace "String(string_view)" with "string_view.to_string()"
StringView::to_string() was added in 917ccb1 but not actually used
anywhere yet.
2020-05-06 19:28:59 +02:00
Andreas Kling
5c12f3fef0 js: Tighten up ReplConsoleClient::trace() a little bit
Remove a bunch of unnecessary String copying.
2020-05-05 11:49:14 +02:00
Linus Groh
a2e1f1a872 LibJS: Implement exponentiation assignment operator (**=) 2020-05-05 11:12:27 +02:00
Linus Groh
3e754a15d4 LibJS: Implement bitwise assignment operators (&=, |=, ^=) 2020-05-05 11:12:27 +02:00
Emanuele Torre
73a7a589c2 js: Customise the behaviour of JS::Console with ReplConsoleClient
This also makes our JavaScript tests not fail.
2020-05-05 09:15:16 +02:00
Emanuele Torre
046f9cf115 LibJS: Remove ConsoleMessage from LibJS
We don't need to store the past messages in LibJS.
We'll implement a way to let LibJS users expand the vanilla Console.
2020-05-05 09:15:16 +02:00
Andreas Kling
7dd49047f3 keymap: Fix crash introduced by 637ecdb
Just because a Vector has some inline capacity doesn't mean we can put
data at offsets < Vector::size().

Fixes #2104.
2020-05-05 00:12:51 +02:00
mattco98
adb4accab3 LibJS: Add template literals
Adds fully functioning template literals. Because template literals
contain expressions, most of the work has to be done in the Lexer rather
than the Parser. And because of the complexity of template literals
(expressions, nesting, escapes, etc), the Lexer needs to have some
template-related state.

When entering a new template literal, a TemplateLiteralStart token is
emitted. When inside a literal, all text will be parsed up until a '${'
or '`' (or EOF, but that's a syntax error) is seen, and then a
TemplateLiteralExprStart token is emitted. At this point, the Lexer
proceeds as normal, however it keeps track of the number of opening
and closing curly braces it has seen in order to determine the close
of the expression. Once it finds a matching curly brace for the '${',
a TemplateLiteralExprEnd token is emitted and the state is updated
accordingly.

When the Lexer is inside of a template literal, but not an expression,
and sees a '`', this must be the closing grave: a TemplateLiteralEnd
token is emitted.

The state required to correctly parse template strings consists of a
vector (for nesting) of two pieces of information: whether or not we
are in a template expression (as opposed to a template string); and
the count of the number of unmatched open curly braces we have seen
(only applicable if the Lexer is currently in a template expression).

TODO: Add support for template literal newlines in the JS REPL (this will
cause a syntax error currently):

    > `foo
    > bar`
    'foo
    bar'
2020-05-04 16:46:31 +02:00
Ben Wiederhake
f09a8f8a6e sysctl: Permit 'sysctl -a' invocation
The point of '-a' is to list all keys.
It is counter-intuitive to require the user to then
supply a specific key additionally.
2020-05-04 09:41:43 +02:00
Ben Wiederhake
e6547a7e95 sysctl: Fix newlines in error messages 2020-05-04 09:41:43 +02:00
Andreas Kling
e09b83c60c LibTextCodec: Start fleshing out a simple text codec library
We're starting with a very basic decoding API and only ISO-8859-1 and
UTF-8 decoding (and UTF-8 decoding is really a no-op since String is
expected to be UTF-8.)
2020-05-03 23:01:58 +02:00
Andreas Kling
eb6e35a1be ProtocolServer: Pass HTTP response headers to the client
We now store the response headers in a download object on the protocol
server side and pass it to the client when finishing up a download.

Response headers are passed as an IPC::Dictionary. :^)
2020-05-03 23:01:58 +02:00
DexesTTP
d008a38f93 LibCrypto: Small fixes in BigInteger & test-crypto 2020-05-03 14:31:26 +02:00
DexesTTP
8ad48cca29 test-crypto: Display execution time for passing tests 2020-05-03 14:31:26 +02:00
AnotherTest
06cf9d3fb7 ProtocolServer: Implement and handle download progress
Also updates `pro` to display download progress and speed on stderr
2020-05-03 12:59:26 +02:00
Shannon Booth
637ecdb415 Userland: Fix leak in keymap
Pretty harmless here, but eh
2020-05-03 11:42:32 +02:00
Linus Groh
ce0bed0482 js: Ignore property attributes for completion
Only being able to complete enumerable properties is annoying,
especially since we updated everything to use the correct attributes.

Most standard built-in objects are *not* enumerable.
2020-05-02 19:21:50 +02:00
AnotherTest
b394543d3c Userland: Tweak the tests in test-crypto
- Clarify the purpose of "AES | Specialised Encrypt"
- Decouple the TLS test from the host machine
- Add a "test" mode to run all available tests
2020-05-02 12:24:10 +02:00
AnotherTest
adab43987d LibCrypto: Rename UnsignedBigInteger APIs to match their actions 2020-05-02 12:24:10 +02:00
AnotherTest
75310003e5 Userland test-crypto: Add interactive mode for the tls 'mode'
For all your raw TLS testing needs :^)
2020-05-02 12:24:10 +02:00
AnotherTest
bb46e5f608 LibTLS: Switch to Hash::Manager for hashing and add SHA1
Now we can talk to google.com
2020-05-02 12:24:10 +02:00
AnotherTest
e997661e26 LibCrypto: Implement SHA1 Hash Function 2020-05-02 12:24:10 +02:00
AnotherTest
7384d58a0a Userland: Adapt test-crypto to the new AK::Result API 2020-05-02 12:24:10 +02:00
AnotherTest
2247036acf LibTLS: Implement a preliminary version of the TLS protocol
TLS::TLSv12 is a Core::Socket, however, I think splitting that into a
TLS::Socket would probably be beneficial
2020-05-02 12:24:10 +02:00
AnotherTest
f1578d7e9e LibCrypto: Fix issues in the Crypto stack
This commit fixes up the following:
- HMAC should not reuse a single hasher when successively updating
- AES Key should not assume its user key is valid signed char*
- Mode should have a virtual destructor
And adds a RFC5246 padding mode, which is required for TLS
2020-05-02 12:24:10 +02:00
AnotherTest
7adb93ede9 LibCrypto: Implement RSA in terms of UnsignedBigInteger
This commit also adds enough ASN.1/DER to parse RSA keys
2020-05-02 12:24:10 +02:00
AnotherTest
6b742c69bd LibCrypto: Add ::import_data() and ::export_data() to UnsignedBigInteger
These functions allow conversion to-and-from big-endian buffers
This commit also adds a ""_bigint operator for easy bigint use
2020-05-02 12:24:10 +02:00
Itamar
2125a4debb LibCrypto: Add base-10 string de/serialization methods for bigint 2020-05-02 12:24:10 +02:00
Itamar
709c691f38 LibCrypto: Fix bug in big int subtraction
A regression test was added to the suite.

This commit also generally simplifies the subtraction method.
2020-05-02 12:24:10 +02:00
Itamar
0d2777752e LibCrypto: Add UnsignedBigInteger division
The division operation returns both the quotient and the remainder.
2020-05-02 12:24:10 +02:00
Itamar
2959c4a5e9 LibCrypto: Add UnsignedBigInteger multiplication
Also added documentation for the runtime complexity of some operations.
2020-05-02 12:24:10 +02:00
Itamar
2843dce498 LibCrypto: Fix a bug in big int addition
There was a bug when dealing with a carry when the addition
result for the current word was UINT32_MAX.

This commit also adds a regression test for the bug.
2020-05-02 12:24:10 +02:00
Itamar
e0cf40518c LibCrypto: Add UnsignedBigInteger subtraction and comparison 2020-05-02 12:24:10 +02:00
Itamar
6201f741d4 LibCrypto: Add UnsignedBigInteger and implement addition
UnsignedBigInteger stores an unsigned ainteger of arbitrary length.

A big integer is represented  as a vector of word. Each
word is an unsigned int.
2020-05-02 12:24:10 +02:00
AnotherTest
8c645916b4 LibCrypto: Add SHA512
There is quite a bit of avoidable duplication, however, I could not get
the compiler to be happy about SHA2<Size> (see FIXMEs)
2020-05-02 12:24:10 +02:00
AnotherTest
ca097b093b LibCrypto: Add SHA256 hash function 2020-05-02 12:24:10 +02:00
AnotherTest
f2cd004d11 LibCrypto: Implement HMAC 2020-05-02 12:24:10 +02:00
AnotherTest
4f89a377a4 LibCrypto: Move each subsection into its own namespace 2020-05-02 12:24:10 +02:00
AnotherTest
96dd7c2996 Userland: Add MD5 tests to test-crypto
This commit also reworks the test program to have a better interface:
`test-crypto <mode> [options]`
where each mode has its own default suite
2020-05-02 12:24:10 +02:00
AnotherTest
899ca245ae LibCrypto: Implement Cipher and AES_CBC
Also adds a test program to userland
2020-05-02 12:24:10 +02:00
Emanuele Torre
e861af2a5c js: Print ConsoleMessages and color the output based on their kind :^) 2020-05-02 11:41:35 +02:00
Linus Groh
43c1fa9965 LibJS: Implement (no-op) debugger statement 2020-05-01 22:07:13 +02:00
Andres Vieira
15aedc6866 Userland: "touch" can now handle multiple paths as arguments
You can now do:
  touch a.txt b.txt c.txt d.txt

Also now you can't do:
  touch --test  # This created a "./--test" file

Also adds ArgsParser to the mix to better handle arguments :)
2020-05-01 17:08:46 +02:00
Andreas Kling
b2b30567ab js: Turn on live syntax highlighting by default 2020-04-30 22:37:50 +02:00
mattco98
95abcc3722 LibJS: Implement correct object property ordering
This commit introduces a way to get an object's own properties in the
correct order. The "correct order" for JS object properties is first all
array-like index properties (numeric keys) sorted by insertion order,
followed by all string properties sorted by insertion order.

Objects also now print correctly in the repl! Before this commit:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ bar: 2, foo: 1, baz: 3 }

After:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ foo: 1, bar: 2, baz: 3 }
2020-04-29 18:47:03 +02:00
Andreas Kling
698652a548 LibJS: Make Value::as_string() return a PrimitiveString reference 2020-04-29 12:35:39 +02:00
AnotherTest
9473733d7a LibLine: Handle initialize() internally
This patch makes initialize() transparent to the users, but exposes it
publicly, as the users might need a copy of the default termios (i.e.
Shell)
2020-04-28 23:29:07 +02:00
AnotherTest
7ecf29f206 LibLine: Ignore interrupts unless actively editing
It does not make much sense to receive an interrupt and process it
*much later*.
Also patches Userland/js to only create exceptions while some code is
actually running.
2020-04-28 23:29:07 +02:00
Andreas Kling
ea204ef05b LibMarkdown: Drop MD prefixes and move into "Markdown" namespace :^) 2020-04-28 21:04:25 +02:00
Linus Groh
8f2300afb5 mkdir: Add -p option to create parent directories 2020-04-28 09:36:09 +02:00
Linus Groh
6fd7966d81 mkdir: Use ArgParser, support creating multiple directories 2020-04-28 09:36:09 +02:00
Linus Groh
9540174b40 js: Follow Serenity C++ naming conventions 2020-04-26 18:09:22 +02:00
Luke Payne
f191b84b50 Kernel: Added the ability to set the hostname via new syscall
Userland/hostname: Now takes parameter to set the hostname
LibC/unistd: Added sethostname function
2020-04-26 12:59:09 +02:00
bcoles
03f68a51af
Userland: Add arp utility (#1962) 2020-04-26 12:54:22 +02:00
Brian Gianforcaro
597ff9ec93 Userland: Fix kill to support negative pid values.
The kill system call accepts negative pids, as they
have special meaning:

    pid == -1 means all processes the calling process has access to.

    pid < -1 means every process who's process group ID is -pid.

I don't see any reason why the user space program should mask this.
2020-04-26 12:54:10 +02:00
Andreas Kling
35aea2e454 LibJS: Stop using Optional<Value> in favor of Value's empty state
JS::Value already has the empty state ({} or Value() gives you one.)
Use this instead of wrapping Value in Optional in some places.
I've also added Value::value_or(Value) so you can easily provide a
fallback value when one is not present.
2020-04-25 18:45:22 +02:00
Hüseyin ASLITÜRK
e00b85b8c0 Userland/ls: Remove unnecessary output 2020-04-25 12:09:46 +02:00
Linus Groh
a832ab0f4e js: Interrupt running script or REPL evaluation when receiving SIGINT 2020-04-24 19:43:34 +02:00
Linus Groh
95b51e857d LibJS: Add TokenType::TemplateLiteral
This is required for template literals - we're not quite there yet, but at
least the parser can now tell us when this token is encountered -
currently this yields "Unexpected token Invalid". Not really helpful.

The character is a "backtick", but as we already have
TokenType::{StringLiteral,RegexLiteral} this seemed like a fitting name.

This also enables syntax highlighting for template literals in the js
REPL and LibGUI's JSSyntaxHighlighter.
2020-04-24 11:18:57 +02:00
Andreas Kling
52a250cb61 LibGUI: Make MenuBar a Core::Object
This makes it show up in Inspector with all the menus inside it. :^)
2020-04-21 16:19:18 +02:00
Andreas Kling
98b990f20b Userland: Remove some little temporary test programs
These were never meant to stick around.
2020-04-19 19:40:04 +02:00
Andreas Kling
7eeea4d57f Kernel: rmdir("/") should fail instead of asserting
We can't assume there's always a parent custody -- when we open "/"
there isn't gonna be one!

Fixes #1858.
2020-04-19 18:07:16 +02:00
Andreas Kling
4c19305a17 test_io: Unbreak symlink test after sys$readlink() '\0' changes 2020-04-19 18:07:09 +02:00
AnotherTest
cb3cf589ed LibLine: Allow suggestions to have trailing trivia strings
These strings would be applied when inserted into the buffer, but are
not shown as part of the suggestion.

This commit also patches up Userland/js and Shell to use this
functionality
2020-04-19 17:21:55 +02:00
Sergey Bugaev
b6eb7f42ac Userland: Add open(1)
This is a simple utility for invoking Core::DesktopServices::open() from command
line :^)
2020-04-19 11:14:26 +02:00
Andreas Kling
fca08bd000 LibJS: Move builtin prototypes to the global object
This moves us towards being able to run JavaScript in different global
objects without allocating a separate GC heap.
2020-04-18 13:24:45 +02:00
Andreas Kling
6833004a45 js: Tweak the live syntax highlighting colors a bit 2020-04-16 16:37:32 +02:00
Itamar
ef6dc61291 functrace: Log syscalls 2020-04-16 11:17:33 +02:00
Itamar
f4418361c4 Userland: Add "functrace" utility
functrace traces the function calls a program makes.
It's like strace, but for userspace.

It works by using Debugging functionality to insert breakpoints
at call&ret instructions.
2020-04-16 11:17:33 +02:00
Andreas Kling
64f5185bae js: Tweak colorization of printed values a bit 2020-04-15 10:11:48 +02:00
Sergey Bugaev
f18d6610d3 Kernel: Don't include null terminator in sys$readlink() result
POSIX says, "Conforming applications should not assume that the returned
contents of the symbolic link are null-terminated."

If we do include the null terminator into the returning string, Python
believes it to actually be a part of the returned name, and gets unhappy
about that later. This suggests other systems Python runs in don't include
it, so let's do that too.

Also, make our userspace support non-null-terminated realpath().
2020-04-14 18:40:24 +02:00
Brian Gianforcaro
d74ad81402 js/LibJS: Move test functions to pure javascript.
The addition of assert functions to Userland/js
was done before we had load(..) implemented. Now
that it exists, it seems like the right move the
test helper functions to pure javascript instead
of poluting js with random global functions.
2020-04-14 12:55:31 +02:00
Linus Groh
8e08d111da js: Output text using printf() and return undefined in help() 2020-04-13 23:12:17 +02:00
Linus Groh
0040d6bf2d js: Add assertNotReached() function in test mode 2020-04-13 16:28:50 +02:00
Stephan Unverwerth
984c290ec0 LibJS: Do not execute scripts with parse errors
This adds missing checks in several LibJS consumers.
2020-04-13 10:42:25 +02:00
Brian Gianforcaro
50b6b6ef86 js: Make load() available when running with --test-mode
The work I did to add assert as a native function in js
was a step in the wrong direction. Now that js supports
load() it makes sense to just move assert and anything
we want to add to the test harness into pure javascript.
2020-04-13 10:31:06 +02:00
Itamar
8e87d340c3 strace: Update ptrace() usage
ptrace with PT_TRACEME was updated to also stop the traced thread on
exit from execve.
2020-04-13 00:53:22 +02:00
Linus Groh
6d5d668585 js: Coerce assert() argument to boolean
It's JavaScript after all :^)
2020-04-13 00:47:53 +02:00
Linus Groh
31d0dbe2a0 js: Stylize TokenType::{Throw,Switch,Case} 2020-04-11 17:15:40 +02:00
AnotherTest
2fdce695d6 LibLine: Display suggestions and cycle between them
With extra color (tm)
This commit also patches the users of LibLine to properly use the new
API
2020-04-11 17:15:19 +02:00
AnotherTest
70da0e3fb5 Userland: Add primitive autocomplete to the JS repl
This patch adds primitive support for autocompletion in the JS repl,
it only supports completing global names and properties on variables :^)
2020-04-11 14:29:25 +02:00
AnotherTest
586aa3b1de Userland: Install LibLine's signal handlers in the JS repl 2020-04-11 14:29:25 +02:00
Andreas Kling
e5cde0082a LibX86: Run the instruction decoder in 32-bit mode by default
Let's assume a 32-bit execution environment unless otherwise specified.
2020-04-11 13:24:55 +02:00
Andreas Kling
32d83fdee4 LibX86: Add an X86 instruction decoder library + basic disassembler
This will be very useful for developer tools like ProfileView, and also
for future tools like debuggers and such. :^)
2020-04-11 13:16:17 +02:00
AnotherTest
6545a74743 JS repl: Fix indentation when a line starts with '})]' 2020-04-10 00:58:59 +02:00
Linus Groh
c06a6c67d5 LibJS: Add globalThis
We already have "global" as a way to access the global object in js(1)
(both REPL and script mode). This replaces it with "globalThis", which
is available in all environments, not just js.
2020-04-09 15:58:49 +02:00
Linus Groh
755b206618 LibJS: Handle empty values in Value::to_string() 2020-04-08 18:51:34 +02:00
Andreas Kling
bdffc9e7fb LibJS: Support array holes, encoded as empty JS::Value
This patch adds a new kind of JS::Value, the empty value.
It's what you get when you do JSValue() (or most commonly, {} in C++.)

An empty Value signifies the absence of a value, and should never be
visible to JavaScript itself. As of right now, it's used for array
holes and as a return value when an exception has been thrown and we
just want to unwind.

This patch is a bit of a mess as I had to fix a whole bunch of code
that was relying on JSValue() being undefined, etc.
2020-04-06 20:27:44 +02:00
Andreas Kling
90ba0145f6 LibJS: Add a number-indexed property storage to all Objects
Objects can have both named and indexed properties. Previously we kept
all property names as strings. This patch separates named and indexed
properties and splits them between Object::m_storage and m_elements.

This allows us to do much faster array-style access using numeric
indices. It also makes the Array class much less special, since all
Objects now have number-indexed storage. :^)
2020-04-06 18:09:26 +02:00
Liav A
23fb985f02 Kernel & Userland: Allow to mount image files formatted with Ext2FS 2020-04-06 15:36:36 +02:00
Andreas Kling
e323246517 Meta: Add missing copyright headers 2020-04-06 11:09:01 +02:00
AnotherTest
d077637fd6 JS Repl: Add live syntax highlighting
This patchset adds live syntax highlighting to the js repl.
It is turned off by default and can be enabled via the -s flag.
2020-04-05 16:11:13 +02:00
Brian Gianforcaro
4233c8662b js: Add a new --test-mode option, which exposes an assert() function.
Introduce a central assert implementation so that the LibJS test suite
can take advantage of one implementation instead of copy/pasting the
same function into every test case file.
2020-04-05 15:28:45 +02:00
AnotherTest
77191d82dc Kernel: Add the SO_BINDTODEVICE socket option
This patch adds a way for a socket to ask to be routed through a
specific interface.
Currently, this option only applies to sending, however, it should also
apply to receiving...somehow :^)
2020-04-05 09:50:48 +02:00
Linus Groh
79539378c6 js: Add lines to history 2020-04-05 01:54:38 +02:00
Andreas Kling
2db8716a6f LibJS: Don't return the "last computed value" from Interpreter::run()
Only return whatever a "return" statment told us to return.
The last computed value is now available in Interpreter::last_value()
instead, where the REPL can pick it up.
2020-04-04 23:45:13 +02:00
Andreas Kling
fc5067afd2 ProtocolServer+LibProtocol: Reject unhandled URLs instead of asserting
StartDownload requests for unhandled protocols (or invalid URLs) will
now refuse to load instead of asserting. A failure code is sent back
to LibProtocol and Protocol::Client::start_download() returns nullptr.

Fixes #1604.
2020-04-04 20:01:36 +02:00
Andreas Kling
040ba77d44 Userland: Fix null-pointer deref on unknown user/group in chown/chgrp
We can't just blindly dereference the result of getpwnam()/getgrnam()!

Fixes #1625.
2020-04-04 19:29:30 +02:00
Linus Groh
cd3e2690eb LibJS: Set length property in Object::put_native_function() 2020-04-04 15:58:49 +02:00
Andreas Kling
26eeaef0a8 LibGUI: Add MenuBar::add_menu(name)
This allows us to construct menus in a more natural way:

    auto& file_menu = menubar->add_menu("File");
    file_menu.add_action(...);

Instead of the old way:

    auto file_menu = GUI::Menu::construct();
    file_menu->add_action(...);
    menubar->add_menu(file_menu);
2020-04-04 12:58:05 +02:00
Andreas Kling
faac43597a LibJS: Add js_string(Interpreter&, String) 2020-04-04 12:58:05 +02:00
Linus Groh
a769db6078 js: Return 1 after exception in non-REPL mode 2020-04-04 10:29:42 +02:00
Dov Alperin
fb67bc2f4f Userland/JS: Add the 'save("file")' repl command
Calling save("file") in a repl saves all the typed lines so far
into the specified file. It currently does not have great support for
multilined functions since those get turned into one line.
2020-04-04 00:31:02 +02:00
Andreas Kling
9ae3cced76 Revert "Kernel & Userland: Allow to mount image files formatted with Ext2FS"
This reverts commit a60ea79a41.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:57 +02:00
Andreas Kling
5e6e1fd482 LibJS: Start implementing object shapes
This patch adds JS::Shape, which implements a transition tree for our
Object class. Object property keys, prototypes and attributes are now
stored in a Shape, and each Object has a Shape.

When adding a property to an Object, we make a transition from the old
Shape to a new Shape. If we've made the same exact transition in the
past (with another Object), we reuse the same transition and both
objects may now share a Shape.

This will become the foundation of inline caching and other engine
optimizations in the future. :^)
2020-04-02 19:32:21 +02:00
Dov Alperin
3906d2b46a Userland/JS: Print any exceptions after execution of a JS file 2020-04-02 17:08:37 +02:00
Andreas Kling
57f72f2982 js: Change wording from "Exception caught" to "Uncaught exception" :^)
As Sergey pointed out, these exceptions are actually *not* caught!
2020-04-02 15:25:08 +02:00
Linus Groh
eb1fef2be6 js: Improve exception output for errors with empty message 2020-04-02 15:24:34 +02:00
Liav A
a60ea79a41 Kernel & Userland: Allow to mount image files formatted with Ext2FS 2020-04-02 12:03:08 +02:00
Andreas Kling
8ad890cfa6 js: Handle exceptions thrown during REPL execution
We now print thrown exceptions and clear the interpreter state so it
can continue running instead of refusing to do anything after an
exception has been thrown.

Fixes #1572.
2020-04-02 09:56:13 +02:00
Andreas Kling
cd1d369cdd LibJS: Add argument(i) and argument_count() to Interpreter
Add some convenience accessors for retrieving arguments from the
current call frame.
2020-04-01 22:38:59 +02:00
Andreas Kling
1549c5c48b LibJS: Make Value::as_object() return Object&
Let's move towards using references over pointers in LibJS as well.
I had originally steered away from it because that's how I've seen
things done in other engines. But this is not the other engines. :^)
2020-04-01 22:18:47 +02:00
Dov Alperin
c27e8a258a Userland/JS: Extend the global object when using a REPL
When we enter a repl we call initialize_global_object on our custom
ReplObject in order to expose REPL specific features. Specifically:
help(), exit(code), and load("file1.js", "file2.js", "fileEtc.js").
2020-04-01 22:11:33 +02:00
Andreas Kling
9d5d0261e1 LibJS: Add Interpreter::create<GlobalObjectType>()
Force Interpreter construction to go via a create() helper that takes
the global object type as a template parameter.
2020-04-01 21:05:35 +02:00
Andreas Kling
d062d7baa7 LibWeb+LibJS: Move DOM Window object to dedicated classes
LibWeb now creates a WindowObject which inherits from GlobalObject.
Allocation of the global object is moved out of the Interpreter ctor
to allow for specialized construction.

The existing Window interfaces are moved to WindowObject with their
implementation code in the new Window class.
2020-04-01 18:57:00 +02:00
Linus Groh
632231cc0c js: Implement print function for Date objects 2020-03-31 21:19:21 +02:00
Andreas Kling
b71e504bba js: Don't construct a Line::Editor unless we're going into the REPL
Otherwise the Line::Editor will try to reset termios on exit, which can
have unpleasant effects.
2020-03-31 19:00:20 +02:00
Andreas Kling
8ab576308f LibLine: Rename LineEditor.{cpp,h} => Editor.{cpp,h} 2020-03-31 13:34:57 +02:00
Andreas Kling
6595469de1 LibLine: Rename LineEditor to Line::Editor 2020-03-31 13:34:06 +02:00
Andreas Kling
a30a3277a3 LibLine: Rename from LibLineEdit 2020-03-31 13:32:11 +02:00
Andreas Kling
9c7451a21d js: Don't exit the REPL when pressing enter on an empty line 2020-03-31 13:30:00 +02:00
AnotherTest
06d35d036d Userland/js: Use the new line editor in repl
We now get cursor movements for free!
and we're rid of that icky `free` call, yay.
2020-03-31 13:21:46 +02:00
Brendan Coles
d64589101c Userland: Add optional human readable output to /bin/df
/bin/df now allows the operator to view human readable
output using `-h` or `--human-readable` optional flags.
2020-03-31 09:08:30 +02:00
Linus Groh
d4e3688f4f LibJS: Start implementing Date :^)
This adds:

- A global Date object (with `length` property and `now` function)
- The Date constructor (no arguments yet)
- The Date prototype (with `get*` functions)
2020-03-30 14:11:54 +02:00
Andreas Kling
7cfe712f4d LibGfx+LibIPC: Add Gfx::ShareableBitmap, a bitmap for easy IPC usage
With this patch, it's now possible to pass a Gfx::ShareableBitmap in an
IPC message. As long as the message itself is synchronous, the bitmap
will be adopted by the receiving end, and disowned by the sender nicely
without any accounting effort like we've had to do in the past.

Use this in NotificationServer to allow sending arbitrary bitmaps as
icons instead of paths-to-icons.
2020-03-29 19:37:23 +02:00
Itamar
e5ebdb9bca strace: Change implementation to use ptrace() 2020-03-28 18:27:18 +01:00
Andreas Kling
23c5323a70 js: Publish the global object as "global" 2020-03-27 12:24:58 +01:00
Andreas Kling
faedb763ca NotificationServer: Allow showing an icon in notifications
We currently use icon paths for this because I didn't want to deal with
implementing icon bitmap sharing right now. In the future it would be
better to post a bitmap somehow instead of a path.
2020-03-26 20:38:28 +01:00
Andreas Kling
bc7a9097a7 js: Tweak pretty-printing of functions and null 2020-03-26 14:54:43 +01:00
Andreas Kling
97d3809a17 js: Fix build on Linux
Apparently ESUCCESS is not a thing on my host machine.
2020-03-26 14:46:00 +01:00
Andreas Kling
6e6495fdf9 js: Implement some modest pretty-printing of values 2020-03-26 12:26:11 +01:00
Sergey Bugaev
db4da68618 Base: Add a man page for js(1)
This also changes --ast-dump to --dump-ast, because I like it better
and that is what the variable is actually called.
2020-03-26 08:18:08 +01:00
Sergey Bugaev
ccdfb077d8 Userland: Implement JS REPL
If you invoke `js` without a script path, it will now enter REPL mode,
where you input commands one by one and immediately get each one
interpreted in one shared interpreter. We support multi-line commands
in case we detect you have unclosed braces or parens or brackets.
2020-03-26 08:01:45 +01:00
Andreas Kling
efbcdd6d34 uname: Remove trailing space character 2020-03-25 15:48:35 +01:00
Andreas Kling
2fc56abd4b js: Remove debug message about what the interpreter returned
If you want to see what the interpreter returned, use "js -l" :^)
2020-03-25 09:48:37 +01:00
Andreas Kling
8705c5ffeb js: Make the -l command-line argument actually work 2020-03-24 16:14:10 +01:00
Andreas Kling
b2f005125d LibJS: Always collect all garbage when destroying Heap
When the Heap is going down, it's our last chance to run destructors,
so add a separate collector mode where we simply skip over the marking
phase and go directly to sweeping. This causes everything to get swept
and all live cells get destroyed.

This way, valgrind reports 0 leaks on exit. :^)
2020-03-23 14:11:19 +01:00
Andreas Kling
12b8cd8c10 js: Make printing of the last result optional 2020-03-20 14:52:27 +01:00
Andreas Kling
0bc6bcc2ed js: Ignore the first line of input if it starts with "#!"
This allows us to create executable programs in JavaScript :^)
2020-03-20 14:49:17 +01:00
Andreas Kling
3823d13e21 copy: Use StringBuilder::join() 2020-03-20 14:41:23 +01:00
Liav A
b2585b3577 Userland: Add functionality of changing system date in date utility 2020-03-19 15:48:00 +01:00
rhin123
08a30a4961 LibCore: Moved cal.cpp functions to DateTime 2020-03-18 08:17:01 +01:00
Andreas Kling
cb2e7d1c5f LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
2020-03-16 19:18:46 +01:00
Andreas Kling
19452230cd LibJS: Add "Heap" and "Runtime" subdirectories
Let's try to keep LibJS tidy as it expands. :^)
2020-03-16 14:37:19 +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
howar6hill
01133733dd
LibJS: Allow functions to take arguments (#1405) 2020-03-12 12:22:13 +01:00
Andreas Kling
4d942cc1d0 js: Take the script file as a command-line argument
Now that we have the beginnings of a parser, let's take the script to
run as a command-line argument and move all the test scripts into
/home/anon/js :^)

To run a script, simply use "js":

$ js my-script.js

To get an AST dump before execution, you can use "js -A"
2020-03-12 10:52:47 +01:00
Stephan Unverwerth
f3a9eba987 LibJS: Add Javascript lexer and parser
This adds a basic Javascript lexer and parser. It can parse the
currently existing demo programs. More work needs to be done to
turn it into a complete parser than can parse arbitrary JS Code.

The lexer outputs tokens with preceeding whitespace and comments
in the trivia member. This should allow us to generate the exact
source code by concatenating the generated tokens.

The parser is written in a way that it always returns a complete
syntax tree. Error conditions are represented as nodes in the
tree. This simplifies the code and allows it to be used as an
early stage parser, e.g for parsing JS documents in an IDE while
editing the source code.:
2020-03-12 09:25:49 +01:00
Marios Prokopakis
8cf962a102
Userland: Set the mask of a network adapter with ifconfig (#1388)
A new IP address or a new network mask can be specified in the command
line arguments of ifconfig to replace the old values of a given network
adapter. Additionally, more information is being printed for each adapter.
2020-03-11 21:30:41 +01:00
Andreas Kling
07e5b93c38 js: Oopsie, fix build 2020-03-11 21:07:05 +01:00
0xtechnobabble
df40c85f80
LibJS: Allow the choice of a scope of declaration for a variable (#1408)
Previously, we were assuming all declared variables were bound to a
block scope, now, with the addition of declaration types, we can bind
a variable to a block scope using `let`, or a function scope (the scope
of the inner-most enclosing function of a `var` declaration) using
`var`.
2020-03-11 20:09:20 +01:00
Andreas Kling
542108421e LibJS: Support "hello friends".length
The above snippet is a MemberExpression that necessitates the implicit
construction of a StringObject wrapper around a PrimitiveString.

We then do a property lookup (a "get") on the StringObject, where we
find the "length" property. This is pretty neat! :^)
2020-03-11 19:00:26 +01:00
marprok
bc10e0eeb2 Userland: Correction in the the copyright
Change the date in the copyright.
2020-03-11 10:12:36 +01:00
Andreas Kling
70a3e738f5 js: Make it a little easier to add new AST builder functions 2020-03-09 21:58:27 +01:00
Andreas Kling
ad401ca098 js: Add another little test AST to exercise marking of locals 2020-03-09 21:49:20 +01:00
Andreas Kling
1382dbc5e1 LibJS: Add basic support for (scoped) variables
It's now possible to assign expressions to variables. The variables are
put into the current scope of the interpreter.

Variable lookup follows the scope chain, ending in the global object.
2020-03-09 21:49:20 +01:00
Shannon Booth
28731179b1 Userland: Use ArgParser in stat and support multiple files + links
The '-L' option can be used for calling stat instead of lstat
2020-03-09 12:37:49 +01:00
Mr.doob
4dee1ec0be
js: Fixed program comment (#1391) 2020-03-09 07:33:39 +01:00
Andreas Kling
d9126b1ad5 js: Exercise the garbage collector a little bit 2020-03-08 19:59:59 +01:00
Andreas Kling
37fc6c117c Userspace: Add missing #includes now that AK/StdLibExtras.h is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
b1058b33fb AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)
Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
2020-03-08 13:06:51 +01:00
Andreas Kling
f5476be702 LibJS: Start building a JavaScript engine for SerenityOS :^)
I always tell people to start building things by working on the thing
that seems the most interesting right now. The most interesting thing
here was an AST + simple interpreter, so that's where we start!

There is no lexer or parser yet, we build an AST directly and then
execute it in the interpreter, producing a return value.

This seems like the start of something interesting. :^)
2020-03-07 19:42:11 +01:00
Andreas Kling
830a57c6b2 LibWeb: Rename directory LibHTML => LibWeb
Let's rename this to LibWeb since it aims to provide more parts of the
web platform than just HTML. :^)
2020-03-07 10:32:51 +01:00
Andreas Kling
7a6c4a72d5 LibWeb: Move everything into the Web namespace 2020-03-07 10:27:02 +01:00
Shannon Booth
57f1c919df LibCore: Remove all remaining C prefix references
LibCore's GZip is also moved into the Core namespace with this change.
2020-03-07 01:33:53 +01:00
Shannon Booth
d7cfe61fe4 Userland: Use ArgsParser in crash 2020-03-06 22:46:17 +01:00
Liav A
259ead5d7a Userland: Replace lsinterrupts with lsirq
Also, lsirq will return more useful data than lsinterrupts did
2020-03-06 11:19:51 +01:00
howar6hill
fb09b6a8ce Userland: Add du program 2020-03-04 18:06:17 +01:00