Commit Graph

650 Commits

Author SHA1 Message Date
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
Andreas Kling
0f3e57a6fb LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients 2020-03-04 14:26:16 +01:00