Age | Commit message (Collapse) | Author |
|
Implement support for ECMAScript 6 template literals which allow simple
interpolation of variable values into strings without resorting to
`sprintf()` or manual string concatenation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Do not expose the json-c compat functions in ucode's public headers to
avoid clashes when building on systems with modern json-c.
Also remove some explicit json-c/json-c.h includes in places where it is
not needed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The libjson-c versions commonly shipped by Debian and Ubuntu lack unsigned
64bit integer support and a number of extended API functions.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Provide a new API function `uc_stdlib_function()` which allows to fetch
the C implementation of the given named standard library function.
This is useful for loadable modules or applications that embed ucode which
want to reuse core functions such as `sprintf()`.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
We now include `json-c/json-c.h` on all supported environments.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Identifiers starting with one or two underscores are reserved for system
headers and toolchain implementations and should not appear in user code.
Also on OS X, the ucode __TYPES_H_ guard clashes with the system types.h
header. Rename all ucode header guards to avoid such clashes.
Supersedes: #43
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Support ES2016 exponentiation (**) and exponentiation assignment (**=)
- Support ES2020 nullish coalescing (??) and logical nullish assignment (??=)
- Support ES2021 logical and assignment (&&=) and logical or assignment (||=)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Instead of implementing a custom limited refcount logic, turn uc_source_t
instances into proper uc_value_t objects.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Instead of treating individual program functions as managed ucode types,
demote uc_function_t values to pointers into a uc_program_t entity
- Promote uc_program_t to a managed type
- Let uc_closure_t claim references to the owning program of the enclosed
uc_function_t
- Redefine public APIs uc_compile() and uc_vm_execute() APIs to return and
expect an uc_program_t object respectively
- Remove vallist indirection for function loading and let the compiler
emit the function id directly when producing function construction code
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Extend source objects with a `runpath` field which contains the original
path of the source being executed by the VM.
When instantiating source objects from file paths, the `runpath` will be
set to the `filename`. When instantiating source buffers using
`uc_source_new_buffer()`, the runpath is initially unset.
A new function `uc_source_runpath_set()` can be used to adjust the runtime
path being associated with a source object.
Extend bytecode loading logic to set the source buffer runtime path to the
precompiled bytecode file path being loaded and executed. This is required
for `sourcepath()` and relative paths in `include()` to function correctly
when executing precompiled programs.
Finally rename `uc_program_from_file()` and `uc_program_to_file()` to
`uc_program_load()` and `uc_program_write()` respectively since the load
part now operates on an `uc_source_t` input buffer instead of a plain
`FILE *` handle.
Adjust users of these API functions accordingly.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Introduce new command line flags `-o` and `-O` to write compiled program
code into the specified output file
- Add support for transparently executing precompiled files, the
lexical analyzing and com,pilation phase is skipped in this case
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Move source object pointer into program entity which is referenced by
each function
- Move lineinfo related routines into source.c and use them from lexer.c
since lineinfo encoding does not belong into the lexical analyzer.
- Implement initial infrastructure for detecting source file type,
this is required later to differentiate between plaintext and
precompiled bytecode files
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Instead of storing constant values per function, maintain a global program
wide list for all constant values within the current compilation unit.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Introduce a new "program" entity which holds the list of functions
created during compilation
- Instead of storing pointers to the in-memory function representation
in the constant list, store the index of the function within the
program's function list
- When loading functions from the constant list, retrieve the function
by index from the program entity
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Import the binary64 double packing routines from the struct module and
use them to store numeric double values in a platform agnostic big
endian format.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Parse integer literals as unsigned numeric values in order to be able
to represent the entire unsigned 64bit value range
- Stop parsing minus-prefixed integer literals as negative numbers but
treat them as separate minus operator followed by a positive integer
instead
- Only store unsigned numeric constants in bytecode
- Rework numeric comparison logic to be able to handle full 64bit
unsigned integers
- If possible, yield unsigned 64 bit results for additions
- Simplify numeric value conversion API
- Compile code with -fwrapv for defined signed overflow semantics
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce a new, lazily allocated value registry which can be used by C
code to store values which should not be garbage collected.
The registry is a plain ucode object internally and treated as GC root
but not exposed to ucode script code, this allows it to retain references
to values which are otherwise completely unreachable from ucode scripts.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fix various misspelling of "resource".
This commit changes the exported libucode ABI.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
No functional changes.
Fixes: ff52440 ("treewide: consolidate typedef naming")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fix instances of misspelled "resource".
This commit breaks the exported libucode ABI.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Introduce new operators `?.`, `?.[…]` and `?.(…)` to simplify looking up
deeply nested property chain in a secure manner.
The `?.` operator behaves like the `.` property access operator but yields
`null` if the left hand side is `null` or not an object.
Like `?.`, the `?.[…]` operator behaves like the `[…]` computed property
access but yields `null` if the left hand side is `null` or neither an
object or array.
Finally the `?.(…)` operator behaves like the function call operator `(…)`
but yields `null` if the left hand side is `null` or not a callable
function.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
# ucode -mrtnl -Rs 'printf("%.J", rtnl.request(rtnl.const.RTM_GETLINK, 0, { dev: "lo" }))'
{
"family": 0,
"type": 772,
"dev": "lo",
"flags": 65609,
"address": "00:00:00:00:00:00",
"broadcast": "00:00:00:00:00:00",
"txqlen": 1000,
"mtu": 65536,
"carrier": true,
"linkmode": 0,
"operstate": 0,
"num_tx_queues": 1,
"num_rx_queues": 1,
"af_spec": {
"inet": {
"conf": {
"forwarding": 1,
"mc_forwarding": 0,
"proxy_arp": 0,
"accept_redirects": 1,
"secure_redirects": 1,
"send_redirects": 1,
"shared_media": 1,
"rp_filter": 0,
"accept_source_route": 1,
"bootp_relay": 0,
"log_martians": 0,
"tag": 0,
"arpfilter": 0,
"medium_id": 0,
"noxfrm": 1,
"nopolicy": 1,
"force_igmp_version": 0,
"arp_announce": 0,
"arp_ignore": 0,
"promote_secondaries": 0,
"arp_accept": 0,
"arp_notify": 0,
"accept_local": 0,
"src_vmark": 0,
"proxy_arp_pvlan": 0,
"route_localnet": 0,
"igmpv2_unsolicited_report_interval": 10000,
"igmpv3_unsolicited_report_interval": 1000,
"ignore_routes_with_linkdown": 0,
"drop_unicast_in_l2_multicast": 0,
"drop_gratuitous_arp": 0,
"bc_forwarding": 0
}
},
"inet6": {
"mode": 0,
"flags": 2147483648,
"conf": {
"forwarding": 0,
"hoplimit": 64,
"mtu6": 65536,
"accept_ra": 1,
"accept_redirects": 1,
"autoconf": 1,
"dad_transmits": 1,
"rtr_solicits": -1,
"rtr_solicit_interval": 4000,
"rtr_solicit_delay": 1000,
"use_tempaddr": -1,
"temp_valid_lft": 604800,
"temp_prefered_lft": 86400,
"regen_max_retry": 3,
"max_desync_factor": 600,
"max_addresses": 16,
"force_mld_version": 0,
"accept_ra_defrtr": 1,
"accept_ra_pinfo": 1,
"accept_ra_rtr_pref": 1,
"rtr_probe_interval": 60000,
"accept_ra_rt_info_max_plen": 0,
"proxy_ndp": 0,
"optimistic_dad": 0,
"accept_source_route": 0,
"mc_forwarding": 0,
"disable_ipv6": 0,
"accept_dad": -1,
"force_tllao": 0,
"ndisc_notify": 0,
"mldv1_unsolicited_report_interval": 10000,
"mldv2_unsolicited_report_interval": 1000,
"suppress_frag_ndisc": 1,
"accept_ra_from_local": 0,
"use_optimistic": 0,
"accept_ra_mtu": 1,
"stable_secret": 0,
"use_oif_addrs_only": 0,
"accept_ra_min_hop_limit": 1,
"ignore_routes_with_linkdown": 0,
"drop_unicast_in_l2_multicast": 0,
"drop_unsolicited_na": 0,
"keep_addr_on_down": 0,
"rtr_solicit_max_interval": 3600000,
"seg6_enabled": 0,
"seg6_require_hmac": 0,
"enhanced_dad": 1,
"addr_gen_mode": 0,
"disable_policy": 0,
"accept_ra_rt_info_min_plen": 0,
"ndisc_tclass": 0,
"rpl_seg_enabled": 0
}
}
},
"proto_down": false,
"group": 0,
"ifname": "lo"
}
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Ensure that most functions follow the subject_verb naming schema
- Move type related function from value.c to types.c
- Rename value.c to vallist.c
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Provide separate public ucv_gc() and ucv_freeall() functions to perform
an incremental and complete GC run respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|