示例#1
0
文件: interface.c 项目: 3man/devlang
DVM_ExecutableList *
DKC_compile(DKC_Compiler *compiler, FILE *fp, char *path)
{
    extern FILE *yyin;
    DVM_ExecutableList *list;
    DVM_Executable *exe;

    DBG_assert(st_compiler_list == NULL,
               ("st_compiler_list != NULL(%p)", st_compiler_list));
    set_path_to_compiler(compiler, path);
    compiler->input_mode = FILE_INPUT_MODE;

    yyin = fp;

    list = MEM_malloc(sizeof(DVM_ExecutableList));
    list->list = NULL;
    
    exe = do_compile(compiler, list, NULL, DVM_FALSE);
    exe->path = MEM_strdup(path);
    list->top_level = exe;

    /* dvm_disassemble(exe);*/

    dispose_compiler_list();
    dkc_reset_string_literal_buffer();

    return list;
}
示例#2
0
文件: interface.c 项目: BluePanM/code
DVM_Executable *
DKC_compile_string(DKC_Compiler *compiler, char **lines)
{
    extern int yyparse(void);
    DVM_Executable *exe;

    dkc_set_source_string(lines);
    compiler->current_line_number = 1;
    compiler->input_mode = DKC_STRING_INPUT_MODE;

    exe = do_compile(compiler);

    dkc_reset_string_literal_buffer();

    return exe;
}
示例#3
0
文件: interface.c 项目: BluePanM/code
DVM_Executable *
DKC_compile(DKC_Compiler *compiler, FILE *fp)
{
    extern FILE *yyin;
    DVM_Executable *exe;

    compiler->current_line_number = 1;
    compiler->input_mode = DKC_FILE_INPUT_MODE;

    yyin = fp;

    exe = do_compile(compiler);

    dkc_reset_string_literal_buffer();

    return exe;
}
示例#4
0
文件: interface.c 项目: 3man/devlang
SearchFileStatus
dkc_dynamic_compile(DKC_Compiler *compiler, char *package_name,
                    DVM_ExecutableList *list, DVM_ExecutableItem **add_top,
                    char *search_file)
{
    SearchFileStatus status;
    extern FILE *yyin;
    DVM_ExecutableItem *tail;
    DVM_Executable *exe;
    SourceInput source_input;
    char found_path[FILENAME_MAX];
        
    status = get_dynamic_load_input(package_name, found_path,
                                    search_file, &source_input);
    if (status != SEARCH_FILE_SUCCESS) {
        return status;
    }
    DBG_assert(st_compiler_list == NULL,
               ("st_compiler_list != NULL(%p)", st_compiler_list));

    for (tail = list->list; tail->next; tail = tail->next)
        ;

    compiler->package_name = string_to_package_name(compiler, package_name);
    set_path_to_compiler(compiler, found_path);

    compiler->input_mode = source_input.input_mode;
    if (source_input.input_mode == FILE_INPUT_MODE) {
        yyin = source_input.u.file.fp;
    } else {
        dkc_set_source_string(source_input.u.string.lines);
    }
    exe = do_compile(compiler, list, found_path, DVM_FALSE);

    dispose_compiler_list();
    dkc_reset_string_literal_buffer();

    *add_top = tail->next;

    return SEARCH_FILE_SUCCESS;
}