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_DeriveTag
  10. DVM_FunctionDerive
  11. DVM_TypeDerive
  12. DVM_PUSH_INT_1BYTE
  13. DVM_PUSH_INT_2BYTE
  14. DVM_PUSH_INT
  15. DVM_PUSH_DOUBLE_0
  16. DVM_PUSH_DOUBLE_1
  17. DVM_PUSH_DOUBLE
  18. DVM_PUSH_STRING
  19. DVM_PUSH_NULL
  20. DVM_PUSH_STACK_INT
  21. DVM_PUSH_STACK_DOUBLE
  22. DVM_PUSH_STACK_STRING
  23. DVM_POP_STACK_INT
  24. DVM_POP_STACK_DOUBLE
  25. DVM_POP_STACK_STRING
  26. DVM_PUSH_STATIC_INT
  27. DVM_PUSH_STATIC_DOUBLE
  28. DVM_PUSH_STATIC_STRING
  29. DVM_POP_STATIC_INT
  30. DVM_POP_STATIC_DOUBLE
  31. DVM_POP_STATIC_STRING
  32. DVM_ADD_INT
  33. DVM_ADD_DOUBLE
  34. DVM_ADD_STRING
  35. DVM_SUB_INT
  36. DVM_SUB_DOUBLE
  37. DVM_MUL_INT
  38. DVM_MUL_DOUBLE
  39. DVM_DIV_INT
  40. DVM_DIV_DOUBLE
  41. DVM_MOD_INT
  42. DVM_MOD_DOUBLE
  43. DVM_MINUS_INT
  44. DVM_MINUS_DOUBLE
  45. DVM_INCREMENT
  46. DVM_DECREMENT
  47. DVM_CAST_INT_TO_DOUBLE
  48. DVM_CAST_DOUBLE_TO_INT
  49. DVM_CAST_BOOLEAN_TO_STRING
  50. DVM_CAST_INT_TO_STRING
  51. DVM_CAST_DOUBLE_TO_STRING
  52. DVM_EQ_INT
  53. DVM_EQ_DOUBLE
  54. DVM_EQ_STRING
  55. DVM_GT_INT
  56. DVM_GT_DOUBLE
  57. DVM_GT_STRING
  58. DVM_GE_INT
  59. DVM_GE_DOUBLE
  60. DVM_GE_STRING
  61. DVM_LT_INT
  62. DVM_LT_DOUBLE
  63. DVM_LT_STRING
  64. DVM_LE_INT
  65. DVM_LE_DOUBLE
  66. DVM_LE_STRING
  67. DVM_NE_INT
  68. DVM_NE_DOUBLE
  69. DVM_NE_STRING
  70. DVM_LOGICAL_AND
  71. DVM_LOGICAL_OR
  72. DVM_LOGICAL_NOT
  73. DVM_POP
  74. DVM_DUPLICATE
  75. DVM_JUMP
  76. DVM_JUMP_IF_TRUE
  77. DVM_JUMP_IF_FALSE
  78. DVM_PUSH_FUNCTION
  79. DVM_INVOKE
  80. DVM_RETURN
  81. DVM_Opcode
  82. DVM_CONSTANT_INT
  83. DVM_CONSTANT_DOUBLE
  84. DVM_CONSTANT_STRING
  85. DVM_ConstantPoolTag
  86. DVM_ConstantPool
  87. DVM_Variable
  88. 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_DeriveTag;

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

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_STRING,
    DVM_POP_STACK_INT,
    DVM_POP_STACK_DOUBLE,
    DVM_POP_STACK_STRING,
    /**********/
    DVM_PUSH_STATIC_INT,
    DVM_PUSH_STATIC_DOUBLE,
    DVM_PUSH_STATIC_STRING,
    DVM_POP_STATIC_INT,
    DVM_POP_STATIC_DOUBLE,
    DVM_POP_STATIC_STRING,
    /**********/
    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_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_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_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 {
    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;
} 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                 code_size;
    DVM_Byte            *code;
};

#endif /* PUBLIC_DVM_CODE_H_INCLUDED */

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