Skip to content

feat: add math.atan2, math.copysign, string.charpattern, loadfile - #293

Merged
esrrhs merged 4 commits into
masterfrom
feature/math-string-extend
Jul 31, 2026
Merged

feat: add math.atan2, math.copysign, string.charpattern, loadfile#293
esrrhs merged 4 commits into
masterfrom
feature/math-string-extend

Conversation

@esrrhs

@esrrhs esrrhs commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add math.atan2(y, x): two-argument arctangent
  • Add math.copysign(x, y): copy sign of y to magnitude of x
  • Add string.charpattern: compile-time constant pattern "[^%z]" (matches any character except null)
  • Add loadfile(filename): load Lua source from file, compile directly so top-level functions become global, return closure that executes the chunk when called

Implementation

  • math.atan2 / math.copysign: registered as native functions in native_math.cpp
  • string.charpattern: compile-time constant interception in c_gen.cpp (same pattern as math.pi)
  • loadfile: reads file, compiles via CompileString (so globals register properly), returns a closure with special marker \x1bLoadFile that FlEvalLoadClosure recognizes to call __fakelua_init directly

Test Coverage

  • 4 new test cases (each runs under both JIT_TCC and JIT_GCC):
    • test_math.test_math_atan2
    • test_math.test_math_copysign
    • test_string.test_string_charpattern
    • test_string.test_string_loadfile
  • All 33 math/string/basic tests pass

esrrhs and others added 4 commits July 31, 2026 11:39
- math.atan2(y, x): two-argument arctangent
- math.copysign(x, y): copy sign of y to magnitude of x
- string.charpattern: compile-time constant pattern "[^%z]"
- loadfile(filename): load Lua source from file, compile directly so
  top-level functions become global, return closure that executes
  the chunk's __fakelua_init when called

Co-Authored-By: Claude <noreply@anthropic.com>
All four modules (math, table, string, basic) now use the same
categorized sub-heading style for consistency.

Co-Authored-By: Claude <noreply@anthropic.com>
fakelua files only contain functions and constants, no top-level
executable code. After CompileString, the compiler's __fakelua_init
runs automatically. So loadfile just compiles the file directly
(top-level functions become global) and returns nil.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.53086% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.80%. Comparing base (b1313f1) to head (14bdca0).

Files with missing lines Patch % Lines
src/native/native_string.cpp 86.66% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage   90.77%   90.80%   +0.02%     
==========================================
  Files          76       76              
  Lines       17439    17511      +72     
==========================================
+ Hits        15831    15901      +70     
- Misses       1608     1610       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@esrrhs
esrrhs merged commit 74e1dc9 into master Jul 31, 2026
7 checks passed
@esrrhs
esrrhs deleted the feature/math-string-extend branch July 31, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants