Commit Graph

4 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire d548a066a6 Check
- Corrected import path for `compiler.lexer` -> `compiler.lexer.core`

Parser

- Corrected import path for `compiler.lexer` -> `compiler.lexer.core`

TypeChecker

- Corrected import path for `compiler.lexer` -> `compiler.lexer.core`

Compiler

- Moved configuration code outside of it
- Renamed to `compiler.core`

DGen

- Check for any object files to link in, if so append them to the `cc` call

Lexer

- Moved from `compiler.lexer` to `compiler.lexer.core`

Configuration

- Overhauled configuration system

Mapper

- Added definition to `SymbolMappingTechnique`

Command-line

- Migrated to new configuration system
- Migrated `SymbolMappingTechnique` to Mapper module
- Added support for specifying object fils to link in using the `-ll` flag`

Tests

- Added `file_io.c` for testing `simple_extern.t` with `extern_test.sh`
- Added `extern_test.sh` for testing `simple_extern.t`
2023-01-28 18:12:49 +02:00
Tristan B. Velloza Kildaire 9e79bc6f8b Parser
- Added comments and removed TODO for now complete feature on `parseTypedDeclaration()`

Dependency

- Added support for external variable symbols to `transform()` for declarations, assignments and variable expressions

Test cases

- Updated extern evar test case to new symbol name that wouldn't clash
- Added assignment usage and expression usage
2023-01-19 09:03:19 +02:00
Tristan B. Velloza Kildaire d288440e18 Parser
- Added `allowVarDec` and `allwFuncDef` to `parseTypedDeclaration()` as default arguments with `true` as their default values
- If `allowFuncDef` is true then parse a function
- If `allowVarDec` is `true` then allow a variable definition
- If `allowVarDec` is true but we have an assignment and `wantsBody` is false then throw an error
- NOTE: A fix for `parseTypedDeclaration()` is needed for this to work

Tests

- Updated `simple_extern.t` to include an `extern evar`
2023-01-19 08:08:41 +02:00
Tristan B. Velloza Kildaire 2abb28bcaf Check
- Added new symbol types `EXTERN`, `EXTERN_EFUNC` and `EXTERN_EVAR` and related back-mappings

Parser

- `parseFuncDef()` now accepts a default argument (set to `true`) on whether to expect a body for a function or not, in the not case expect a semi-colon - this helps with extern support
- Likewise because `parseFuncDef(bool wantsBody = true)` is called by `parseTypedDeclaration()` we have added same argument to `parseTypedDeclaration(bool wantsBody = true)`
- Ensure we pass the parameter from `parseTypedDeclaration()` into `parseFuncDef(bool)` in function definition case
- Implemented `parseExtern()` for extern support
- `parse()` supports `SymbolType.EXTERN` now

Data

- Added `ExternStmt` to represent the parser node derived from a call to `parseExtern()`
- The `Entity` parser node type now has an `isExternal()` flag to know if the entity is marked for `extern` link time or TLang internal time (default)

Typechecker

- Implemented `processPseudoEntities(Container)` which loops through the given container and finds all extern statements and then extracts those nodes, parents them to the given container and marks them as external (pseudo-handling support)
- Added first call inside `beginCheck()` to be a call to `processPseudoEntities(modulle)`

Dependency

- Added useless no-op check for `ExternStmt` - it does nothing

DGen

- In `emitFunctionSignature()`, prepend the string `extern ` to the signatur if the given `Function` entity is marked as external (`isExternal()` is true)
- In `emitFunctionDefinitions()` do not emit a function body at all (or anything, no signature) if the `Function` is marked as external (`isExternal()` is true)
- Added entry point test for `simple_extern.t`
2023-01-15 20:48:40 +02:00