sync#26601
Closed
ylluminate wants to merge 69 commits into
Closed
Conversation
Provides SSL/TLS placeholder types for the BEAM backend: - SSLCerts, SSLConn, SSLListener structs - new_ssl_conn, new_sslcerts functions - read, write, dial, connect methods (stub implementations) This allows V code using net.mbedtls to compile for BEAM. Actual SSL operations would need Erlang ssl module integration.
- Create compress.beam.v with deflate compression stubs using Erlang zlib - Create gzip/gzip.beam.v with gzip compression using zlib:gzip/gunzip - Rename gzip.v to gzip.c.v to mark it as C-backend-specific This enables tar_gz_reader.v and other code using compress.gzip to compile for the BEAM backend.
- Add int_to_hex/1 for integer to hex string conversion - Add hex_to_int/1 for hex string to integer parsing - Add format_int/2 for arbitrary base (2-36) formatting - Add interpolate/1 for V string interpolation support - Update float_to_string and to_binary to use compact decimals
…inary:copy for repeat
- <= becomes =< (Erlang's less-than-or-equal) - != becomes /= (Erlang's not-equal) Also includes string concatenation fix (string + string -> binary concat)
V's / operator performs integer division when both operands are integers. In Erlang, / always returns a float, so we need to use 'div' instead. - Added is_integer_type_or_literal() and is_float_type_or_literal() helpers - Modified infix_expr() to detect integer division and emit 'div' - Float division and mixed operations still use '/'
- Fix generic type stripping: all_before('[') before all_after_last('.')
prevents main.BST[main.KeyVal] → 'KeyVal]' errors
- Fix empty type prefix for array types ([]Flag → 'array' prefix)
- Add method stubs for ~30 V stdlib types (File, Process, FlagParser,
Command, Mutex, RE, Context, Termios, TcpListener, Vec3, etc.)
- Add ~60 free-standing function stubs (open_file, json, signal, etc.)
- Add u8.ascii_str and array bytestr/hex methods
- Add array get_int/get_string/get_bool/get_strings stubs
When V resolves imported functions like `import mymodules { add_xy }`,
node.mod stays as the calling module but node.name contains the full
qualified name (e.g., "mymodules.add_xy"). The codegen now detects this
pattern and emits cross-module `call 'v.mod':'fn'(args)` instead of
local `apply 'fn'/arity(args)`.
Also fixes function references to imported modules (e.g., term.green)
in core_ident - now emits cross-module call in lambda wrappers.
This single fix resolved ALL 7 previously-identified "fundamental
limitations": submodule, poll_coindesk, bst_map, mini_calculator,
jsonrpc/server, jsonrpc/client, and sync_pool all now compile.
Core Erlang parity: 110/117 (94%), remaining 7 are V compilation
failures (not Core Erlang backend issues).
Same fix as Core Erlang path: detect module prefix in full_name when node.mod matches the calling module. V resolves imported functions with node.mod set to caller, but node.name has the qualified name.
Stdlib stubs → real implementations:
- string.beam.v: 30+ methods implemented (split, replace, trim, contains,
starts_with, ends_with, repeat, reverse, to_upper/lower, find_between,
match_glob with real wildcard support, find_between_pair_rune)
- int.beam.v: hex2, hex_full, is_alnum, is_hex_digit, is_space, u8.repeat
- array.beam.v: contains, clear, trim, drop, byterune (full UTF-8), utf8_to_utf32
- strconv.beam.v: format_int/uint, ftoa family, remove_tail_zeros
- map.beam.v: fix deprecated map{} syntax, add codegen documentation
Codegen interception for C-pointer string functions (BEAM binary mapping):
- tos(s, len) → binary:part(S, 0, Len)
- tos2/3/4/5, cstring_to_vstring → hd(binary:split(S, <<0>>))
- tos_clone → binary:copy(S)
- runes() → unicode:characters_to_list(S)
- ascii_str() → erlang:list_to_binary([Byte])
Core Erlang + ETF pipeline improvements:
- Expanded core_exprs.v with string/array/map method codegen
- Expanded core_stmts.v with improved control flow
- Enhanced coregen.v module infrastructure
All 45/45 runtime tests pass on ETF, Text, and Erlang source pipelines.
…tions
irgen.v (1165→1598 lines):
- for..in range loops (label/cmp/jcc structure)
- for..in array loops (array_len + array_get iteration)
- Map IR opcodes: map_new, map_get, map_put, map_delete
- print_float opcode with float type detection
- String interpolation: println('${expr}') and expression form
- Full match expression support (general + match true pattern)
- DumpExpr, CharLiteral, ConcatExpr support
Stdlib real implementations:
- rune.beam.v: 8/8 functions (UTF-8 encoding, str(), bytes(), case conversion)
- time.beam.v: 4 new (strftime, parse_iso8601, parse_rfc3339, parse_format)
- base64.beam.v: 4 new (encode/decode with proper padding)
- os.beam.v: 7 improved (hostname, uname, real_path, glob, posix errors)
Native ARM64 tests: 9/9 pass. BEAM runtime tests: 45/45 pass.
…e 100% JSON parser (json.beam.v 326→793 lines): - Full recursive-descent parser: raw_decode() handles strings, numbers, arrays, objects, booleans, null with Unicode escape support - encode_any/encode_array/encode_map for serialization - Pretty-print with configurable indentation OS/time codegen (core_exprs.v): - 14 interceptions: getenv, setenv, unsetenv, getwd, mkdir, rmdir, getpid, chdir, rename, now, utc, unix, unix_milli, sys_mono_now - Proper charlist↔binary conversion for Erlang stdlib interop Net scaffolding (net.beam.v 621→797 lines): - IPv4 validation, address parsing, TCP/UDP connection scaffolding - Detailed codegen documentation for gen_tcp/gen_udp integration Native irgen.v fixes: - Hex/octal integer literals → decimal conversion - Multi-return assignment bounds check - Void type guard for method calls Compress improvements (gzip/zstd): - Magic number validation, empty data short-circuits, error improvements 46/46 BEAM tests, 9/9 native tests, 68/68 V examples compile natively.
Contributor
Author
|
@codex review |
Contributor
|
Same as @spytheman say: "Please do not submit slop as PR - it has generated .beam, .ir, .core, .etf, .erl files, it has branched from the main repo, instead of from your own one, no tests etc :-| ." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-review via gg sync (main branch)