github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-objmodel.h (about)

     1  /*
     2   * jit-objmodel.h - Interfaces for pluggable object models.
     3   *
     4   * Copyright (C) 2004  Southern Storm Software, Pty Ltd.
     5   *
     6   * The libjit library is free software: you can redistribute it and/or
     7   * modify it under the terms of the GNU Lesser General Public License
     8   * as published by the Free Software Foundation, either version 2.1 of
     9   * the License, or (at your option) any later version.
    10   *
    11   * The libjit library is distributed in the hope that it will be useful,
    12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14   * Lesser General Public License for more details.
    15   *
    16   * You should have received a copy of the GNU Lesser General Public
    17   * License along with the libjit library.  If not, see
    18   * <http://www.gnu.org/licenses/>.
    19   */
    20  
    21  #ifndef	_JIT_OBJMODEL_H
    22  #define	_JIT_OBJMODEL_H
    23  
    24  #include <jit/jit-common.h>
    25  
    26  #ifdef	__cplusplus
    27  extern	"C" {
    28  #endif
    29  
    30  /*
    31   * Opaque types that describe object model elements.
    32   */
    33  typedef struct jit_objmodel *jit_objmodel_t;
    34  typedef struct jitom_class *jitom_class_t;
    35  typedef struct jitom_field *jitom_field_t;
    36  typedef struct jitom_method *jitom_method_t;
    37  
    38  /*
    39   * Modifier flags that describe an item's properties.
    40   */
    41  #define	JITOM_MODIFIER_ACCESS_MASK				0x0007
    42  #define	JITOM_MODIFIER_PUBLIC					0x0000
    43  #define	JITOM_MODIFIER_PRIVATE					0x0001
    44  #define	JITOM_MODIFIER_PROTECTED				0x0002
    45  #define	JITOM_MODIFIER_PACKAGE					0x0003
    46  #define	JITOM_MODIFIER_PACKAGE_OR_PROTECTED		0x0004
    47  #define	JITOM_MODIFIER_PACKAGE_AND_PROTECTED	0x0005
    48  #define	JITOM_MODIFIER_OTHER1					0x0006
    49  #define	JITOM_MODIFIER_OTHER2					0x0007
    50  #define	JITOM_MODIFIER_STATIC					0x0008
    51  #define	JITOM_MODIFIER_VIRTUAL					0x0010
    52  #define	JITOM_MODIFIER_NEW_SLOT					0x0020
    53  #define	JITOM_MODIFIER_ABSTRACT					0x0040
    54  #define	JITOM_MODIFIER_LITERAL					0x0080
    55  #define	JITOM_MODIFIER_CTOR						0x0100
    56  #define	JITOM_MODIFIER_STATIC_CTOR				0x0200
    57  #define	JITOM_MODIFIER_DTOR						0x0400
    58  #define	JITOM_MODIFIER_INTERFACE				0x0800
    59  #define	JITOM_MODIFIER_VALUE					0x1000
    60  #define	JITOM_MODIFIER_FINAL					0x2000
    61  #define	JITOM_MODIFIER_DELETE					0x4000
    62  #define	JITOM_MODIFIER_REFERENCE_COUNTED		0x8000
    63  
    64  /*
    65   * Type tags that are used to mark instances of object model classes.
    66   */
    67  #define	JITOM_TYPETAG_CLASS		11000	/* Object reference */
    68  #define	JITOM_TYPETAG_VALUE		11001	/* Inline stack value */
    69  
    70  /*
    71   * Operations on object models.
    72   */
    73  void jitom_destroy_model(jit_objmodel_t model) JIT_NOTHROW;
    74  jitom_class_t jitom_get_class_by_name
    75  	(jit_objmodel_t model, const char *name) JIT_NOTHROW;
    76  
    77  /*
    78   * Operations on object model classes.
    79   */
    80  char *jitom_class_get_name
    81  	(jit_objmodel_t model, jitom_class_t klass) JIT_NOTHROW;
    82  int jitom_class_get_modifiers
    83  	(jit_objmodel_t model, jitom_class_t klass) JIT_NOTHROW;
    84  jit_type_t jitom_class_get_type
    85  	(jit_objmodel_t model, jitom_class_t klass) JIT_NOTHROW;
    86  jit_type_t jitom_class_get_value_type
    87  	(jit_objmodel_t model, jitom_class_t klass) JIT_NOTHROW;
    88  jitom_class_t jitom_class_get_primary_super
    89  	(jit_objmodel_t model, jitom_class_t klass) JIT_NOTHROW;
    90  jitom_class_t *jitom_class_get_all_supers
    91  	(jit_objmodel_t model, jitom_class_t klass, unsigned int *num) JIT_NOTHROW;
    92  jitom_class_t *jitom_class_get_interfaces
    93  	(jit_objmodel_t model, jitom_class_t klass, unsigned int *num) JIT_NOTHROW;
    94  jitom_field_t *jitom_class_get_fields
    95  	(jit_objmodel_t model, jitom_class_t klass, unsigned int *num) JIT_NOTHROW;
    96  jitom_method_t *jitom_class_get_methods
    97  	(jit_objmodel_t model, jitom_class_t klass, unsigned int *num) JIT_NOTHROW;
    98  jit_value_t jitom_class_new
    99  	(jit_objmodel_t model, jitom_class_t klass,
   100  	 jitom_method_t ctor, jit_function_t func,
   101  	 jit_value_t *args, unsigned int num_args, int flags) JIT_NOTHROW;
   102  jit_value_t jitom_class_new_value
   103  	(jit_objmodel_t model, jitom_class_t klass,
   104  	 jitom_method_t ctor, jit_function_t func,
   105  	 jit_value_t *args, unsigned int num_args, int flags) JIT_NOTHROW;
   106  int jitom_class_delete
   107  	(jit_objmodel_t model, jitom_class_t klass,
   108  	 jit_value_t obj_value) JIT_NOTHROW;
   109  int jitom_class_add_ref
   110  	(jit_objmodel_t model, jitom_class_t klass,
   111  	 jit_value_t obj_value) JIT_NOTHROW;
   112  
   113  /*
   114   * Operations on object model fields.
   115   */
   116  char *jitom_field_get_name
   117  	(jit_objmodel_t model, jitom_class_t klass,
   118  	 jitom_field_t field) JIT_NOTHROW;
   119  jit_type_t jitom_field_get_type
   120  	(jit_objmodel_t model, jitom_class_t klass,
   121  	 jitom_field_t field) JIT_NOTHROW;
   122  int jitom_field_get_modifiers
   123  	(jit_objmodel_t model, jitom_class_t klass,
   124  	 jitom_field_t field) JIT_NOTHROW;
   125  jit_value_t jitom_field_load
   126  	(jit_objmodel_t model, jitom_class_t klass, jitom_field_t field,
   127  	 jit_function_t func, jit_value_t obj_value) JIT_NOTHROW;
   128  jit_value_t jitom_field_load_address
   129  	(jit_objmodel_t model, jitom_class_t klass, jitom_field_t field,
   130  	 jit_function_t func, jit_value_t obj_value) JIT_NOTHROW;
   131  int jitom_field_store
   132  	(jit_objmodel_t model, jitom_class_t klass, jitom_field_t field,
   133  	 jit_function_t func, jit_value_t obj_value, jit_value_t value) JIT_NOTHROW;
   134  
   135  /*
   136   * Operations on object model methods.
   137   */
   138  char *jitom_method_get_name
   139  	(jit_objmodel_t model, jitom_class_t klass,
   140  	 jitom_method_t method) JIT_NOTHROW;
   141  jit_type_t jitom_method_get_type
   142  	(jit_objmodel_t model, jitom_class_t klass,
   143  	 jitom_method_t method) JIT_NOTHROW;
   144  int jitom_method_get_modifiers
   145  	(jit_objmodel_t model, jitom_class_t klass,
   146  	 jitom_method_t method) JIT_NOTHROW;
   147  jit_value_t jitom_method_invoke
   148  	(jit_objmodel_t model, jitom_class_t klass, jitom_method_t method,
   149  	 jit_function_t func, jit_value_t *args,
   150  	 unsigned int num_args, int flags) JIT_NOTHROW;
   151  jit_value_t jitom_method_invoke_virtual
   152  	(jit_objmodel_t model, jitom_class_t klass, jitom_method_t method,
   153  	 jit_function_t func, jit_value_t *args,
   154  	 unsigned int num_args, int flags) JIT_NOTHROW;
   155  
   156  /*
   157   * Manipulate types that represent objects and inline values.
   158   */
   159  jit_type_t jitom_type_tag_as_class
   160  	(jit_type_t type, jit_objmodel_t model,
   161  	 jitom_class_t klass, int incref) JIT_NOTHROW;
   162  jit_type_t jitom_type_tag_as_value
   163  	(jit_type_t type, jit_objmodel_t model,
   164  	 jitom_class_t klass, int incref) JIT_NOTHROW;
   165  int jitom_type_is_class(jit_type_t type) JIT_NOTHROW;
   166  int jitom_type_is_value(jit_type_t type) JIT_NOTHROW;
   167  jit_objmodel_t jitom_type_get_model(jit_type_t type) JIT_NOTHROW;
   168  jitom_class_t jitom_type_get_class(jit_type_t type) JIT_NOTHROW;
   169  
   170  #ifdef	__cplusplus
   171  };
   172  #endif
   173  
   174  #endif /* _JIT_OBJMODEL_H */