wip: working on walker (externs)
Begin working on extern walking (libs metadata collet + opcode gen)
This commit is contained in:
@@ -20,8 +20,9 @@ typedef enum
|
||||
FZL_OPCODE_JMP = 0xF20001, // Jump to specified IP address
|
||||
FZL_OPCODE_JZ = 0xF20002, // Jump if top value in dstack is zero
|
||||
|
||||
FZL_OPCODE_CALL = 0xF30001, // Call function
|
||||
FZL_OPCODE_RET = 0xF30002, // Return from function
|
||||
FZL_OPCODE_CALL = 0xF30001, // Call function
|
||||
FZL_OPCODE_RET = 0xF30002, // Return from function
|
||||
FZL_OPCODE_CALL_EXTERN = 0xF30003, // Call external function
|
||||
|
||||
FZL_OPCODE_ALLOC_OBJECT = 0xFA0001, // Allocate N slots
|
||||
FZL_OPCODE_GET_FIELD = 0xFA0002, // Get field N of an object at dstack
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef FZL_EXTERN_H
|
||||
#define FZL_EXTERN_H
|
||||
|
||||
// Library symbol descriptor
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
} fzl_extern_item_t;
|
||||
|
||||
// External library descriptor
|
||||
typedef struct
|
||||
{
|
||||
//
|
||||
} fzl_extern_lib_t;
|
||||
|
||||
#endif // FZL_EXTERN_H
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_analyzer.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/fzl_token.h>
|
||||
#include <compiler/internals/analyzer.h>
|
||||
#include <compiler/utils/fzl_symtable.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@@ -101,7 +103,21 @@ fzl_type_t an_toktotype(fzl_analyzer_t *analyzer, fzl_token_t *tok,
|
||||
if (sym_found)
|
||||
*sym_found = found;
|
||||
|
||||
return found ? sym.type : FZL_TYPE_NULL;
|
||||
if (found && sym.node->type == FZL_NODETYPE_CLASS)
|
||||
return FZL_TYPE_OBJECT;
|
||||
|
||||
if (found && sym.node->type != FZL_NODETYPE_CLASS &&
|
||||
sym.node->type != FZL_NODETYPE_TYPEDEF)
|
||||
{
|
||||
snprintf(an_problem, sizeof(an_problem), "cannot use '%s' as type",
|
||||
sym.name);
|
||||
an_push_error(analyzer, sym.node->token, an_problem);
|
||||
return FZL_TYPE_NULL;
|
||||
}
|
||||
|
||||
return (found || (tok->value && strcmp(tok->value, "null") == 0))
|
||||
? sym.type
|
||||
: FZL_TYPE_NULL;
|
||||
}
|
||||
|
||||
if (sym_found)
|
||||
|
||||
@@ -203,6 +203,9 @@ fzl_walk_res_t walk(fzl_walker_t *walker, fzl_node_t *node)
|
||||
{
|
||||
switch (node->type)
|
||||
{
|
||||
case FZL_NODETYPE_TYPEDEF:
|
||||
break;
|
||||
|
||||
case FZL_NODETYPE_FMT_STRING:
|
||||
{
|
||||
for (size_t i = 0; i < node->list.entry_count; i++)
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ int main(int argc, char **argv)
|
||||
printf("%sok%s!\n", FZL_COK, FZL_CRST);
|
||||
fzl_debug_print_ast(parser->root);
|
||||
printf("%s> building%s\n", FZL_CDEBUG, FZL_CRST);
|
||||
printf("%s-> analyzing AST...%s\n", FZL_CDEBUG, FZL_CRST);
|
||||
printf("%s-> analyzing AST...%s", FZL_CDEBUG, FZL_CRST);
|
||||
}
|
||||
|
||||
fzl_analyzer_t *analyzer = fzl_mkanalyzer(parser->root);
|
||||
|
||||
Reference in New Issue
Block a user