root/include/DVM_code.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. DVM_BOOLEAN_TYPE
  2. DVM_INT_TYPE
  3. DVM_DOUBLE_TYPE
  4. DVM_STRING_TYPE
  5. DVM_NULL_TYPE
  6. DVM_BasicType
  7. DVM_LocalVariable
  8. DVM_FUNCTION_DERIVE
  9. DVM_ARRAY_DERIVE
  10. DVM_DeriveTag
  11. DVM_FunctionDerive
  12. DVM_ArrayDerive
  13. DVM_TypeDerive
  14. DVM_PUSH_INT_1BYTE
  15. DVM_PUSH_INT_2BYTE
  16. DVM_PUSH_INT
  17. DVM_PUSH_DOUBLE_0
  18. DVM_PUSH_DOUBLE_1
  19. DVM_PUSH_DOUBLE
  20. DVM_PUSH_STRING
  21. DVM_PUSH_NULL
  22. DVM_PUSH_STACK_INT
  23. DVM_PUSH_STACK_DOUBLE
  24. DVM_PUSH_STACK_OBJECT
  25. DVM_POP_STACK_INT
  26. DVM_POP_STACK_DOUBLE
  27. DVM_POP_STACK_OBJECT
  28. DVM_PUSH_STATIC_INT
  29. DVM_PUSH_STATIC_DOUBLE
  30. DVM_PUSH_STATIC_OBJECT
  31. DVM_POP_STATIC_INT
  32. DVM_POP_STATIC_DOUBLE
  33. DVM_POP_STATIC_OBJECT
  34. DVM_PUSH_ARRAY_INT
  35. DVM_PUSH_ARRAY_DOUBLE
  36. DVM_PUSH_ARRAY_OBJECT
  37. DVM_POP_ARRAY_INT
  38. DVM_POP_ARRAY_DOUBLE
  39. DVM_POP_ARRAY_OBJECT
  40. DVM_ADD_INT
  41. DVM_ADD_DOUBLE
  42. DVM_ADD_STRING
  43. DVM_SUB_INT
  44. DVM_SUB_DOUBLE
  45. DVM_MUL_INT
  46. DVM_MUL_DOUBLE
  47. DVM_DIV_INT
  48. DVM_DIV_DOUBLE
  49. DVM_MOD_INT
  50. DVM_MOD_DOUBLE
  51. DVM_MINUS_INT
  52. DVM_MINUS_DOUBLE
  53. DVM_INCREMENT
  54. DVM_DECREMENT
  55. DVM_CAST_INT_TO_DOUBLE
  56. DVM_CAST_DOUBLE_TO_INT
  57. DVM_CAST_BOOLEAN_TO_STRING
  58. DVM_CAST_INT_TO_STRING
  59. DVM_CAST_DOUBLE_TO_STRING
  60. DVM_EQ_INT
  61. DVM_EQ_DOUBLE
  62. DVM_EQ_OBJECT
  63. DVM_EQ_STRING
  64. DVM_GT_INT
  65. DVM_GT_DOUBLE
  66. DVM_GT_STRING
  67. DVM_GE_INT
  68. DVM_GE_DOUBLE
  69. DVM_GE_STRING
  70. DVM_LT_INT
  71. DVM_LT_DOUBLE
  72. DVM_LT_STRING
  73. DVM_LE_INT
  74. DVM_LE_DOUBLE
  75. DVM_LE_STRING
  76. DVM_NE_INT
  77. DVM_NE_DOUBLE
  78. DVM_NE_OBJECT
  79. DVM_NE_STRING
  80. DVM_LOGICAL_AND
  81. DVM_LOGICAL_OR
  82. DVM_LOGICAL_NOT
  83. DVM_POP
  84. DVM_DUPLICATE
  85. DVM_JUMP
  86. DVM_JUMP_IF_TRUE
  87. DVM_JUMP_IF_FALSE
  88. DVM_PUSH_FUNCTION
  89. DVM_INVOKE
  90. DVM_RETURN
  91. DVM_NEW_ARRAY
  92. DVM_NEW_ARRAY_LITERAL_INT
  93. DVM_NEW_ARRAY_LITERAL_DOUBLE
  94. DVM_NEW_ARRAY_LITERAL_OBJECT
  95. DVM_Opcode
  96. DVM_CONSTANT_INT
  97. DVM_CONSTANT_DOUBLE
  98. DVM_CONSTANT_STRING
  99. DVM_ConstantPoolTag
  100. DVM_ConstantPool
  101. DVM_Variable
  102. DVM_LineNumber
  103. DVM_Function

#ifndef PUBLIC_DVM_CODE_H_INCLUDED
#define PUBLIC_DVM_CODE_H_INCLUDED
#include <stdio.h>
#include <wchar.h>
#include "DVM.h"

typedef enum {
    DVM_BOOLEAN_TYPE,
    DVM_INT_TYPE,
    DVM_DOUBLE_TYPE,
    DVM_STRING_TYPE,
    DVM_NULL_TYPE
} DVM_BasicType;

typedef struct DVM_TypeSpecifier_tag DVM_TypeSpecifier;

typedef struct {
    char                *name;
    DVM_TypeSpecifier   *type;
} DVM_LocalVariable;

typedef enum {
    DVM_FUNCTION_DERIVE,
    DVM_ARRAY_DERIVE
} DVM_DeriveTag;

typedef struct {
    int                 parameter_count;
    DVM_LocalVariable   *parameter;
} DVM_FunctionDerive;

typedef struct {
    int dummy; /* make compiler happy */
} DVM_ArrayDerive;

typedef struct DVM_TypeDerive_tag {
    DVM_DeriveTag       tag;
    union {
        DVM_FunctionDerive      function_d;
    } u;
} DVM_TypeDerive;

struct DVM_TypeSpecifier_tag {
    DVM_BasicType       basic_type;
    int                 derive_count;
    DVM_TypeDerive      *derive;
};

typedef wchar_t DVM_Char;
typedef unsigned char DVM_Byte;

typedef enum {
    DVM_PUSH_INT_1BYTE = 1,
    DVM_PUSH_INT_2BYTE,
    DVM_PUSH_INT,
    DVM_PUSH_DOUBLE_0,
    DVM_PUSH_DOUBLE_1,
    DVM_PUSH_DOUBLE,
    DVM_PUSH_STRING,
    DVM_PUSH_NULL,
    /**********/
    DVM_PUSH_STACK_INT,
    DVM_PUSH_STACK_DOUBLE,
    DVM_PUSH_STACK_OBJECT,
    DVM_POP_STACK_INT,
    DVM_POP_STACK_DOUBLE,
    DVM_POP_STACK_OBJECT,
    /**********/
    DVM_PUSH_STATIC_INT,
    DVM_PUSH_STATIC_DOUBLE,
    DVM_PUSH_STATIC_OBJECT,
    DVM_POP_STATIC_INT,
    DVM_POP_STATIC_DOUBLE,
    DVM_POP_STATIC_OBJECT,
    /**********/
    DVM_PUSH_ARRAY_INT,
    DVM_PUSH_ARRAY_DOUBLE,
    DVM_PUSH_ARRAY_OBJECT,
    DVM_POP_ARRAY_INT,
    DVM_POP_ARRAY_DOUBLE,
    DVM_POP_ARRAY_OBJECT,
    /**********/
    DVM_ADD_INT,
    DVM_ADD_DOUBLE,
    DVM_ADD_STRING,
    DVM_SUB_INT,
    DVM_SUB_DOUBLE,
    DVM_MUL_INT,
    DVM_MUL_DOUBLE,
    DVM_DIV_INT,
    DVM_DIV_DOUBLE,
    DVM_MOD_INT,
    DVM_MOD_DOUBLE,
    DVM_MINUS_INT,
    DVM_MINUS_DOUBLE,
    DVM_INCREMENT,
    DVM_DECREMENT,
    DVM_CAST_INT_TO_DOUBLE,
    DVM_CAST_DOUBLE_TO_INT,
    DVM_CAST_BOOLEAN_TO_STRING,
    DVM_CAST_INT_TO_STRING,
    DVM_CAST_DOUBLE_TO_STRING,
    DVM_EQ_INT,
    DVM_EQ_DOUBLE,
    DVM_EQ_OBJECT,
    DVM_EQ_STRING,
    DVM_GT_INT,
    DVM_GT_DOUBLE,
    DVM_GT_STRING,
    DVM_GE_INT,
    DVM_GE_DOUBLE,
    DVM_GE_STRING,
    DVM_LT_INT,
    DVM_LT_DOUBLE,
    DVM_LT_STRING,
    DVM_LE_INT,
    DVM_LE_DOUBLE,
    DVM_LE_STRING,
    DVM_NE_INT,
    DVM_NE_DOUBLE,
    DVM_NE_OBJECT,
    DVM_NE_STRING,
    DVM_LOGICAL_AND,
    DVM_LOGICAL_OR,
    DVM_LOGICAL_NOT,
    DVM_POP,
    DVM_DUPLICATE,
    DVM_JUMP,
    DVM_JUMP_IF_TRUE,
    DVM_JUMP_IF_FALSE,
    /**********/
    DVM_PUSH_FUNCTION,
    DVM_INVOKE,
    DVM_RETURN,
    /**********/
    DVM_NEW_ARRAY,
    DVM_NEW_ARRAY_LITERAL_INT,
    DVM_NEW_ARRAY_LITERAL_DOUBLE,
    DVM_NEW_ARRAY_LITERAL_OBJECT
} DVM_Opcode;

typedef enum {
    DVM_CONSTANT_INT,
    DVM_CONSTANT_DOUBLE,
    DVM_CONSTANT_STRING
} DVM_ConstantPoolTag;

typedef struct {
    DVM_ConstantPoolTag tag;
    union {
        int     c_int;
        double  c_double;
        DVM_Char *c_string;
    } u;
} DVM_ConstantPool;

typedef struct {
    char                *name;
    DVM_TypeSpecifier   *type;
} DVM_Variable;

typedef struct {
    int line_number;
    int start_pc;
    int pc_count;
} DVM_LineNumber;

typedef struct {
    DVM_TypeSpecifier   *type;
    char                *name;
    int                 parameter_count;
    DVM_LocalVariable   *parameter;
    DVM_Boolean         is_implemented;
    int                 local_variable_count;
    DVM_LocalVariable   *local_variable;
    int                 code_size;
    DVM_Byte            *code;
    int                 line_number_size;
    DVM_LineNumber      *line_number;
    int                 need_stack_size;
} DVM_Function;

struct DVM_Excecutable_tag {
    int                 constant_pool_count;
    DVM_ConstantPool    *constant_pool;
    int                 global_variable_count;
    DVM_Variable        *global_variable;
    int                 function_count;
    DVM_Function        *function;
    int                 type_specifier_count;
    DVM_TypeSpecifier   *type_specifier;
    int                 code_size;
    DVM_Byte            *code;
    int                 line_number_size;
    DVM_LineNumber      *line_number;
    int                 need_stack_size;
};

#endif /* PUBLIC_DVM_CODE_H_INCLUDED */

/* [<][>][^][v][top][bottom][index][help] */