Пример #1
0
//destroy the assembler, must be cakked after proccess_file, or you will leak memory and files
void assembler_destroy(void)
{
	symbol_table_destroy(assembler_data_table);
	symbol_table_destroy(assembler_extern_table);
	symbol_table_destroy(assembler_call_table);
	symbol_table_destroy(assembler_extern_table_data);
	symbol_table_destroy(assembler_entry_table);
	if (NULL != data_file) {
		fclose(data_file);
	}
}
Пример #2
0
void
vm_state_destroy(struct vm_state *vm)
{
   LLVMBasicBlockRef current_block, return_block;
   char *error;

   current_block = LLVMGetInsertBlock(vm->builder);
   return_block = LLVMInsertBasicBlock(current_block, "ret");

   LLVMPositionBuilderAtEnd(vm->builder, current_block);
   LLVMBuildBr(vm->builder, return_block);

   LLVMPositionBuilderAtEnd(vm->builder, return_block);
   LLVMBuildRetVoid(vm->builder);

   LLVMMoveBasicBlockAfter(return_block, current_block);

   LLVMDumpModule(vm->module);

   error = NULL;
   LLVMVerifyModule(vm->module, LLVMAbortProcessAction, &error);
   LLVMDisposeMessage(error);

   LLVMDisposeBuilder(vm->builder);
   LLVMDisposeModule(vm->module);
   symbol_table_destroy(vm->symtab);
}
Пример #3
0
//destroies a symbol table, only call this function, or you will leak memory
void symbol_table_destroy(symbol_table_t *table)
{
	if (NULL != table) {
		if (NULL != table->previous) {
			symbol_table_destroy(table->previous);
		}
		free(table);
	}
}
Пример #4
0
void
typecheck_visit_identifier (struct _Visitor *visitor, struct AstNode *node)
{
    Symbol *sym = symbol_lookup(symtab, node->symbol->name);
    Symbol *_sym = sym;

    // O atributo 'decl_linenum' > 0 indica que o identificador referencia
    // a declaracao de uma variavel/procedimento/funcao.

    void __fetch_symbol(struct AstNode *node, Symbol *sym) {
        symbol_table_destroy(node->symbol);
        node->symbol = sym;
        node->type = sym->type;
    }
Пример #5
0
void expr_lambda_resolve(SyntaxNode* expr, SymbolTable* table)
{
	lambda_t* lambda = (lambda_t*) expr;
	SymbolTable* new_table = symbol_table_create(table);

	param* prm = lambda->params->head;
	param* next;

	symbol_table_add(new_table, " this pointer ");

	while (prm != NULL) {
		next = prm->next;
		symbol_table_add(new_table, prm->name);
		prm = next;
	}

	NODE_RESOLVE(lambda->body, new_table);

	lambda->frameSize = new_table->size;

	symbol_table_destroy(new_table);
}
Пример #6
0
void lisp_context_destroy(LispContext *ctx) {
  symbol_table_destroy(ctx->symbols, unref_symbol, ctx);
  free(ctx);
}