Finish the Import mechanism, plus some bug fixes
This commit is contained in:
parent
2c27f2eb40
commit
4e62bbdc51
|
@ -70,6 +70,25 @@
|
|||
DieMessage("Unable to access the imported module", ModulePath);
|
||||
|
||||
// At this point, the file exists and we have the path.
|
||||
// Pass it to the lexer and have at it.
|
||||
// Save the current file, so that we can restore it later
|
||||
struct FileData* SavedFile = CurrentFile;
|
||||
|
||||
// Create a new file with the module name
|
||||
struct FileData* ModuleData = malloc(sizeof(struct FileData));
|
||||
ModuleData->AllowDefinitions = false;
|
||||
ModuleData->SourceName = ModulePath;
|
||||
|
||||
printf("Swapping to module %s..\n\n", ModulePath);
|
||||
|
||||
// Parse all relevant data from the module file...
|
||||
Compile(ModuleData);
|
||||
|
||||
printf("\n\nSwapping back to file %s..\n", SavedFile->SourceName);
|
||||
|
||||
// Reinstate the saved file
|
||||
CurrentFile = SavedFile;
|
||||
|
||||
// Tokenise past the string we just parsed
|
||||
Tokenise();
|
||||
|
||||
}
|
|
@ -155,6 +155,7 @@ int main(int argc, char* argv[]) {
|
|||
// Prepare the source metadata before we start compiling
|
||||
struct FileData* Source = malloc(sizeof(struct FileData));
|
||||
Source->SourceName = argv[i];
|
||||
Source->AllowDefinitions = true;
|
||||
Files[i] = Source;
|
||||
|
||||
// Compile the file by invoking the Delegate
|
||||
|
|
|
@ -433,7 +433,7 @@ struct ASTNode* CallFunction() {
|
|||
*/
|
||||
struct ASTNode* GetExpressionList() {
|
||||
struct ASTNode* Tree = NULL, * Child = NULL;
|
||||
int Count;
|
||||
int Count = 0;
|
||||
|
||||
while (CurrentFile->CurrentSymbol.type != LI_RPARE) {
|
||||
Child = ParsePrecedenceASTNode(0);
|
||||
|
@ -605,7 +605,7 @@ void ParseGlobals() {
|
|||
if (FunctionComing && CurrentFile->CurrentSymbol.type == LI_LPARE) {
|
||||
printf("\tParsing function\n");
|
||||
Tree = ParseFunction(Type);
|
||||
if (Tree) {
|
||||
if (Tree && CurrentFile->AllowDefinitions) {
|
||||
printf("\nBeginning assembler creation of new function %s\n", Tree->Symbol->Name);
|
||||
AssembleTree(Tree, -1, 0);
|
||||
FreeLocals();
|
||||
|
|
|
@ -77,6 +77,7 @@ int ParseOptionalPointer(struct SymbolTableEntry** Composite) {
|
|||
|
||||
switch (CurrentFile->CurrentSymbol.type) {
|
||||
case KW_IMPORT:
|
||||
Type = DAT_NONE;
|
||||
ImportModule();
|
||||
break;
|
||||
case TY_VOID:
|
||||
|
|
Loading…
Reference in New Issue
Block a user