cc.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Copyright (C) 2016 Jeremiah Orians
  2. * This file is part of M2-Planet.
  3. *
  4. * M2-Planet is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * M2-Planet is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. // CONSTANT MAX_STRING 4096
  21. #define MAX_STRING 4096
  22. // CONSTANT FALSE 0
  23. #define FALSE 0
  24. // CONSTANT TRUE 1
  25. #define TRUE 1
  26. // CONSTANT KNIGHT_NATIVE 0
  27. #define KNIGHT_NATIVE 0
  28. // CONSTANT KNIGHT_POSIX 1
  29. #define KNIGHT_POSIX 1
  30. // CONSTANT X86 2
  31. #define X86 2
  32. // CONSTANT AMD64 3
  33. #define AMD64 3
  34. // CONSTANT ARMV7L 4
  35. #define ARMV7L 4
  36. void file_print(char* s, FILE* f);
  37. int match(char* a, char* b);
  38. char* copy_string(char* target, char* source);
  39. void reset_hold_string();
  40. int in_set(int c, char* s);
  41. struct type
  42. {
  43. struct type* next;
  44. int size;
  45. int offset;
  46. struct type* indirect;
  47. struct type* members;
  48. struct type* type;
  49. char* name;
  50. };
  51. struct token_list
  52. {
  53. struct token_list* next;
  54. union
  55. {
  56. struct token_list* locals;
  57. struct token_list* prev;
  58. };
  59. char* s;
  60. union
  61. {
  62. struct type* type;
  63. char* filename;
  64. };
  65. union
  66. {
  67. struct token_list* arguments;
  68. int depth;
  69. int linenumber;
  70. };
  71. };
  72. /* What types we have */
  73. struct type* global_types;
  74. struct type* prim_types;
  75. /* What we are currently working on */
  76. struct token_list* global_token;
  77. /* Output reorder collections*/
  78. struct token_list* strings_list;
  79. struct token_list* globals_list;
  80. /* Make our string collection more efficient */
  81. char* hold_string;
  82. int string_index;
  83. /* Our Target Architecture */
  84. int Architecture;