Commit graph

8469 commits

Author SHA1 Message Date
Andreas Kling
2db2b8b0ef AK: Add FlyString::is_empty() 2020-04-16 20:22:54 +02:00
Andreas Kling
905519bc76 Kernel: Fix dumb logic typo in HardwareTimer::handle_irq() 2020-04-16 18:53:38 +02:00
Andreas Kling
c891c87cb5 Kernel: Rename HardwareTimer::change_function() => set_callback()
Also make it non-virtual since nothing needs to override it.
2020-04-16 18:51:39 +02:00
Andreas Kling
b035267afa Kernel: Remove "stale callback" concept from time management
If a hardware timer doesn't have a callback registered, it's now simply
represented by a null m_callback.
2020-04-16 18:50:22 +02:00
Andreas Kling
4b1f056e3a Kernel: Rename HardwareTimer::m_function_to_call => m_callback 2020-04-16 18:49:20 +02:00
Andreas Kling
1e89f7d64e Kernel: Remove an unnecessary indirection between timer and scheduler
We don't need a wrapper Function object that just forwards the timer
callback to the scheduler tick function. It already has the same
signature, so we can just plug it in directly. :^)

Same with the clock updating function.
2020-04-16 18:49:20 +02:00
Andreas Kling
44d58b85ef Kernel: Simplify the way we pass HardwareTimers around a bit
Instead of passing around indices into the m_hardware_timers vector,
just pass around a HardwareTimer* instead.
2020-04-16 18:49:20 +02:00
Kesse Jones
b0b204822f LibJS: Add String.prototype.substring 2020-04-16 18:47:24 +02:00
Andreas Kling
60d1ef6af4 LibJS: Remove no-op code in ScriptFunction constructor 2020-04-16 16:58:44 +02:00
Andreas Kling
6833004a45 js: Tweak the live syntax highlighting colors a bit 2020-04-16 16:37:32 +02:00
Kesse Jones
7725b1970e LibJS: Add String.prototype.concat 2020-04-16 16:36:51 +02:00
Andreas Kling
e72a537033 LibJS: Make Value::m_type default to Type::Empty
This is not effectful since all constructors overwrite the type anyway,
but it seems reasonable that the default value of m_type would match
what Value() would give you.
2020-04-16 16:11:11 +02:00
Andreas Kling
1b391d78ae LibJS: Allow cells to mark null pointers
This simplifies the cell visiting functions by letting them not worry
about the pointers they pass to the visitor being null.
2020-04-16 16:10:38 +02:00
Read H
1f4e3dd073 LibC netdb: Requested Changes
fix all requested changes including:

- remove explicit vector initialization
- change keep_service_file_open to boolean
- closing service file on seek error
- change C level char allocation to use ByteBuffer instead
- simplified getservby* loops to a single loop
- change fill_getserv_buffers return to early-return style
2020-04-16 15:55:45 +02:00
Read H
844e5faf84 LibC: Service entry API
This commit implements the getservent family of functions:
getservent()
setservent()
endservent()
getservbyname()
getservbyport()

for accessing the /etc/services file.

This commit has addressed the issues identified by utilizing more C++ structures,
addressing unchecked error possibilities, strncpy bounds checking, and other issues
found in the initial pull request
2020-04-16 15:55:45 +02:00
Read H
ce572c9cb5 Base Files: Add services file.
Adding the services database file to /etc/services. This is the most
common location for this file in *nix systems.
2020-04-16 15:55:45 +02:00
Jack Byrne
f65c55791e LibWeb: Scroll back to the top when a new page is loaded 2020-04-16 14:13:03 +02:00
Itamar
1642fdf82d Debugger: Use LibLine 2020-04-16 12:22:59 +02:00
Itamar
ef6dc61291 functrace: Log syscalls 2020-04-16 11:17:33 +02:00
Itamar
af338a34c0 LibDebug: Add ContinueBreakAtSyscall decision
When the user of the DebugSession uses this decision, the debugged
program will be continued until it is either stopped by a singal (e.g
as a reuslt of a breakpoint), or enters a syscall.
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
13865c7c3d LibJS: Remove unreachable code in Interpreter::enter_scope()
Functions are handled and short-circuited at the head of enter_scope().
2020-04-16 10:25:00 +02:00
Andreas Kling
9b9086dcf0 LibJS: Oops, fix StringPrototype build 2020-04-16 10:24:32 +02:00
Andreas Kling
1108dd1659 LibJS: Add some missing |this| checks in StringPrototype
Also some style tweaks
2020-04-16 10:04:21 +02:00
Linus Groh
9eb9b46640 LibWeb: Support alert() with no arguments
No idea why someone would use that though.
2020-04-16 09:45:39 +02:00
Linus Groh
640a24dce8 LibJS: Remove outdated FIXME now that we have lexical environments 2020-04-16 09:41:07 +02:00
Andreas Kling
54c95d44ce LibJS: Functions with no variables don't need to create environment
Just hand out the parent environment instead.
2020-04-15 22:17:17 +02:00
Andreas Kling
ed80952cb6 LibJS: Introduce LexicalEnvironment
This patch replaces the old variable lookup logic with a new one based
on lexical environments.

This brings us closer to the way JavaScript is actually specced, and
also gives us some basic support for closures.

The interpreter's call stack frames now have a pointer to the lexical
environment for that frame. Each lexical environment can have a chain
of parent environments.

Before calling a Function, we first ask it to create_environment().
This gives us a new LexicalEnvironment for that function, which has the
function's lexical parent's environment as its parent. This allows
inner functions to access variables in their outer function:

    function foo() { <-- LexicalEnvironment A
        var x = 1;
        function() { <-- LexicalEnvironment B (parent: A)
            console.log(x);
        }
    }

If we return the result of a function expression from a function, that
new function object will keep a reference to its parent environment,
which is how we get closures. :^)

I'm pretty sure I didn't get everything right here, but it's a pretty
good start. This is quite a bit slower than before, but also correcter!
2020-04-15 22:07:20 +02:00
Linus Groh
cea950fd70 LibJS: Support empty values in array expression 2020-04-15 21:23:06 +02:00
Linus Groh
d30db07048 LibJS: Implement void operator 2020-04-15 19:12:51 +02:00
Andreas Kling
beda751d33 LibJS: Math.round() should call round() instead of roundf()
Neither LibM functions are very strong right now, but let's at least
call the right one.
2020-04-15 19:12:10 +02:00
Andreas Kling
e97a229b90 LibM: Add (not very good) round() implementation 2020-04-15 19:11:53 +02:00
Andreas Kling
fa40b725f9 Kernel: Refuse to set overflowy resolution values in BXVGADevice 2020-04-15 17:15:40 +02:00
Andreas Kling
acf2061837 LibGfx: Use Checked::multiplication_would_overflow() 2020-04-15 17:15:06 +02:00
Andreas Kling
63b8c6913c AK: Add Checked<T>::multiplication_would_overflow()
This allows you to comfortably test if multiply 2 or 3 values would
cause arithmetic overflow.
2020-04-15 17:14:18 +02:00
Andreas Kling
1b610ac2b6 LibWeb: Use Checked<T> when creating <canvas> bitmap buffers 2020-04-15 16:58:46 +02:00
Andreas Kling
f3fc294ac8 LibGfx: Use Checked<T> when creating new bitmaps 2020-04-15 16:58:46 +02:00
Andreas Kling
9c54bad241 AK: Add a Checked<T> template
A Checked<T> is a boxed integer type that asserts if you try to use its
value after an arithmetic overflow.
2020-04-15 16:58:46 +02:00
Andreas Kling
3cdf4cd204 LibX86: Use MakeUnsigned<T> from AK instead of making a custom one 2020-04-15 16:58:46 +02:00
Andreas Kling
bdc753ebd2 AudioServer: Use NumericLimits<T> 2020-04-15 16:58:46 +02:00
Andreas Kling
b517670fc9 LibAudio: Use NumericLimits<T> 2020-04-15 16:58:46 +02:00
Andreas Kling
0e10673c58 Piano: Use NumericLimits<T> 2020-04-15 16:58:46 +02:00
Andreas Kling
9a5dba9e09 AK: Add MakeUnsigned<T> helper template 2020-04-15 16:58:46 +02:00
Andreas Kling
ca2052ae4a AK: Add a simple NumericLimits<T> template
This provides min(), max() and is_signed() for the basic integer types.
2020-04-15 16:58:46 +02:00
Hüseyin ASLITÜRK
abd09ab030
DisplayProperties: Make the preview calculation more accurate (#1807) 2020-04-15 16:40:46 +02:00
Liav A
d6318f2cc6 Kernel: Ensure that we receive IRQs in PIO mode when IOAPIC is enabled
The IOAPIC manual states that "Interrupt Mask-R/W. When this bit is 1,
the interrupt signal is masked. Edge-sensitive interrupts signaled on
a masked interrupt pin are ignored." - Therefore we have to ensure that
we disable interrupts globally with cli(), but also to ensure that we
invoke enable_irq() before sending the hardware command that generates
an IRQ almost immediately.
2020-04-15 16:40:16 +02:00
Linus Groh
4c0ec846a8 Ports: Add gnuplot port
Obviously we don't support many of the common terminals as we're missing
X11, Qt, WxWidgets, Cairo etc. - but at least the "dumb" terminal
(ASCII output) and "canvas" terminal (generates JS to plot on a HTML
<canvas>) are confirmed to be working :^)
2020-04-15 16:39:09 +02:00
Linus Groh
7feb48b1da Ports: Support pre_configure script
This is useful if we want to do something after patching but before
running the configure script - e.g. creating the configure script using
another script :^)
2020-04-15 16:39:09 +02:00
AnotherTest
6b513ca97e LibLine: Avoid crashing if given empty suggestions 2020-04-15 16:38:25 +02:00
Liav A
223a863c6d LibBareMetal: Accept a u16 type pointer in the appropriate IO functions 2020-04-15 12:35:10 +02:00