Open mascarenhas opened 6 years ago
By the way, let's not get hung up on the specific interfaces and implementations for the builtin functions included in this PR, the lack of option types (and optional parameters) and proper error handling in Titan right now restricts what we can do. These builtin functions can improve later as the type system improves.
Merging #232 into master will decrease coverage by
0.41%
. The diff coverage is81.93%
.
Impacted Files | Coverage Δ | |
---|---|---|
titan-compiler/driver.lua | 81.71% <100%> (+2.19%) |
:arrow_up: |
titan-compiler/lexer.lua | 100% <100%> (ø) |
:arrow_up: |
titan-compiler/ast.lua | 100% <100%> (ø) |
:arrow_up: |
titan-compiler/syntax_errors.lua | 100% <100%> (ø) |
:arrow_up: |
titan-compiler/types.lua | 83.5% <31.25%> (-3.21%) |
:arrow_down: |
titan-compiler/checker.lua | 89.27% <78.57%> (-0.56%) |
:arrow_down: |
titan-compiler/parser.lua | 95.3% <85.71%> (-1.03%) |
:arrow_down: |
titan-compiler/coder.lua | 96.24% <92.3%> (-0.13%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 2c09bf8...2784c32. Read the comment docs.
Rebased this onto the current master.
Adds the capability of having builtin functions in the Titan runtime that are callable directly from Titan code, and defines a few builtins available to all Titan modules (such as
print
).The idea is to use builtin functions for standard library functions that need to access Titan's Lua state, and for functions that do not need to access the Lua state but where it is incovenient or impossible to define the function by a combination of Titan code plus FFI calls.
These builtin functions have the Titan calling convention, apart from the addition of variadic arguments, encoded as an
int
parameter that takes the size of the variadic argument list, and a standard C variadic parameter.The C name of a builtin function is always
titan_<name>
for the builtins that are not part of any module, such asprint
andtostring
, andtitan_<mangled_fqtn>
for builtins declared in as part of a module, wheremangled_fqtn
is the fully-qualified name of the function with all dashes and dots replaced by underscores.