titan-lang / titan

The Titan programming language
http://titan-lang.org
MIT License
406 stars 13 forks source link

Support for compiling stand-alone executables #230

Closed hishamhm closed 6 years ago

hishamhm commented 6 years ago

This PR adds support for compiling stand-alone executables.

If a module contains a main function with signature function({string}):integer, that is the main entry point of the program. The input argument is an array of strings containing the command-line arguments, and the integer return value is the exit code of the program.

Only one of the modules given to titanc may contain a main function.

When compiling a program as a single executable, titanc does not use dynamic linking to resolve references in imports. Instead, it generates simple extern declarations that are resolved in the linking step.

The examples.sdl_demo example is modified to demonstrate this, moving the helper function into a separate module.

Additionally, this adds a -v/--verbose flag to titanc, which makes it display the C compiler invocations.

codecov-io commented 6 years ago

Codecov Report

Merging #230 into master will decrease coverage by 1.1%. The diff coverage is 58.69%.

Impacted Files Coverage Δ
titan-compiler/driver.lua 59.57% <43.47%> (-14.26%) :arrow_down:
titan-compiler/checker.lua 89.5% <8.33%> (-1.11%) :arrow_down:
titan-compiler/coder.lua 96.34% <97.05%> (-0.05%) :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 b473e32...a089310. Read the comment docs.