X-Git-Url: https://jxself.org/git/?p=zilutils.git;a=blobdiff_plain;f=zilasm%2Fcompiler.h;fp=zilasm%2Fcompiler.h;h=a885819f400ecb3ee708d3ac4dd3a1626da6056c;hp=0000000000000000000000000000000000000000;hb=b1f151e1500e1fdadafaab6b13df6e0a8f32136e;hpb=c0f515aab1285fdedb65d4582b42cc59db0c8e26 diff --git a/zilasm/compiler.h b/zilasm/compiler.h new file mode 100644 index 0000000..a885819 --- /dev/null +++ b/zilasm/compiler.h @@ -0,0 +1,73 @@ +/* + * compiler.h -- part of ZilUtils/ZilAsm + * + * Copyright (C) 2020 Jason Self + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see + * + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +#ifndef ZILASM_COMPILER +#define ZILASM_COMPILER + + +typedef struct +{ + int todo; +} Opcode_dict; + + + +struct String_Table_Elem +{ + string value; // value in ASCII format + int index; +}; + + +class CCompiler +{ +public: + CCompiler(); + int assembly(); + void fill_config(void); + void get_arguments(int argc, char *argv[], char *envp[]); + char *get_output_file_name(); + CParser parser; + +private: + char *m_output_file; + list < String_Table_Elem > m_string_table; + int m_code_size; + + char *build_output_filename(const char basename[], const char *suffix); + void fill_zserial(void); + void new_file_suffix(char *result, size_t maxlen, const char *src, + const char *newsuffix); + void output_code_section(); + void output_function_table(FILE *file); + void parse_intarg(int *dest, const char name[], int min, int max, + int defval); + void parse_zserial(void); + void print_usage(int failed); + void print_version(); + void wrong_arg(const char *err, ...); +}; + +enum +{ + FAIL = -1, OK = 0, NEED_RESTART = 1 +}; + +#endif