-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
841 additions
and
261 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef MCC_SEMA_H | ||
#define MCC_SEMA_H | ||
|
||
// Semantic analysis pass | ||
|
||
#include "arena.h" | ||
#include "diagnostic.h" | ||
|
||
typedef struct TranslationUnit TranslationUnit; | ||
|
||
ErrorsView type_check(TranslationUnit* ast, Arena* permanent_arena); | ||
|
||
#endif // MCC_SEMA_H |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef MCC_TYPE_H | ||
#define MCC_TYPE_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
|
||
#include "arena.h" | ||
#include "str.h" | ||
|
||
typedef enum TypeTag : uint8_t { | ||
TYPE_INVALID = 0, | ||
TYPE_VOID, | ||
TYPE_INTEGER, | ||
TYPE_FUNCTION, | ||
} TypeTag; | ||
|
||
typedef struct Type { | ||
uint32_t size; | ||
uint32_t alignment; | ||
alignas(max_align_t) TypeTag tag; | ||
} Type; | ||
|
||
typedef struct IntegerType { | ||
Type base; | ||
bool is_unsigned; | ||
const char* name; | ||
} IntegerType; | ||
|
||
typedef struct FunctionType { | ||
Type base; | ||
const Type* return_type; | ||
uint32_t param_count; | ||
} FunctionType; | ||
|
||
extern const Type* typ_invalid; | ||
extern const Type* typ_void; | ||
extern const Type* typ_int; | ||
|
||
const Type* func_type(const Type* return_type, uint32_t param_count, | ||
Arena* arena); | ||
|
||
void format_type_to(StringBuffer* buffer, const Type* typ); | ||
|
||
#endif // MCC_TYPE_H |
This file contains 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
This file contains 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
Oops, something went wrong.