diff --git a/.gitignore b/.gitignore index 4ea48458ea..c6b874df35 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,4 @@ lib/**/*.so lib/**/*.dll doc/ -include/rbs/constants.h -include/rbs/ruby_objs.h -src/constants.c -src/ruby_objs.c - **/*.gem diff --git a/include/rbs/constants.h b/include/rbs/constants.h new file mode 100644 index 0000000000..995f5f923e --- /dev/null +++ b/include/rbs/constants.h @@ -0,0 +1,82 @@ +/*----------------------------------------------------------------------------*/ +/* This file is generated by the templates/template.rb script and should not */ +/* be modified manually. */ +/* To change the template see */ +/* templates/include/rbs/constants.h.erb */ +/*----------------------------------------------------------------------------*/ + +#ifndef RBS__CONSTANTS_H +#define RBS__CONSTANTS_H + +extern VALUE RBS; + +extern VALUE RBS_AST; +extern VALUE RBS_AST_Declarations; +extern VALUE RBS_AST_Directives; +extern VALUE RBS_AST_Members; +extern VALUE RBS_Types; +extern VALUE RBS_Types_Bases; +extern VALUE RBS_ParsingError; + +extern VALUE RBS_AST_Annotation; +extern VALUE RBS_AST_Comment; +extern VALUE RBS_AST_Declarations_Class; +extern VALUE RBS_AST_Declarations_Class_Super; +extern VALUE RBS_AST_Declarations_ClassAlias; +extern VALUE RBS_AST_Declarations_Constant; +extern VALUE RBS_AST_Declarations_Global; +extern VALUE RBS_AST_Declarations_Interface; +extern VALUE RBS_AST_Declarations_Module; +extern VALUE RBS_AST_Declarations_Module_Self; +extern VALUE RBS_AST_Declarations_ModuleAlias; +extern VALUE RBS_AST_Declarations_TypeAlias; +extern VALUE RBS_AST_Directives_Use; +extern VALUE RBS_AST_Directives_Use_SingleClause; +extern VALUE RBS_AST_Directives_Use_WildcardClause; +extern VALUE RBS_AST_Members_Alias; +extern VALUE RBS_AST_Members_AttrAccessor; +extern VALUE RBS_AST_Members_AttrReader; +extern VALUE RBS_AST_Members_AttrWriter; +extern VALUE RBS_AST_Members_ClassInstanceVariable; +extern VALUE RBS_AST_Members_ClassVariable; +extern VALUE RBS_AST_Members_Extend; +extern VALUE RBS_AST_Members_Include; +extern VALUE RBS_AST_Members_InstanceVariable; +extern VALUE RBS_AST_Members_MethodDefinition; +extern VALUE RBS_AST_Members_MethodDefinition_Overload; +extern VALUE RBS_AST_Members_Prepend; +extern VALUE RBS_AST_Members_Private; +extern VALUE RBS_AST_Members_Public; +extern VALUE RBS_AST_TypeParam; +extern VALUE RBS_MethodType; +extern VALUE RBS_Namespace; +extern VALUE RBS_TypeName; +extern VALUE RBS_Types_Alias; +extern VALUE RBS_Types_Bases_Any; +extern VALUE RBS_Types_Bases_Bool; +extern VALUE RBS_Types_Bases_Bottom; +extern VALUE RBS_Types_Bases_Class; +extern VALUE RBS_Types_Bases_Instance; +extern VALUE RBS_Types_Bases_Nil; +extern VALUE RBS_Types_Bases_Self; +extern VALUE RBS_Types_Bases_Top; +extern VALUE RBS_Types_Bases_Void; +extern VALUE RBS_Types_Block; +extern VALUE RBS_Types_ClassInstance; +extern VALUE RBS_Types_ClassSingleton; +extern VALUE RBS_Types_Function; +extern VALUE RBS_Types_Function_Param; +extern VALUE RBS_Types_Interface; +extern VALUE RBS_Types_Intersection; +extern VALUE RBS_Types_Literal; +extern VALUE RBS_Types_Optional; +extern VALUE RBS_Types_Proc; +extern VALUE RBS_Types_Record; +extern VALUE RBS_Types_Tuple; +extern VALUE RBS_Types_Union; +extern VALUE RBS_Types_UntypedFunction; +extern VALUE RBS_Types_Variable; + +void rbs__init_constants(); + +#endif diff --git a/include/rbs/ruby_objs.h b/include/rbs/ruby_objs.h new file mode 100644 index 0000000000..952ea7e94f --- /dev/null +++ b/include/rbs/ruby_objs.h @@ -0,0 +1,72 @@ +/*----------------------------------------------------------------------------*/ +/* This file is generated by the templates/template.rb script and should not */ +/* be modified manually. */ +/* To change the template see */ +/* templates/include/rbs/ruby_objs.h.erb */ +/*----------------------------------------------------------------------------*/ + +#ifndef RBS__RUBY_OBJS_H +#define RBS__RUBY_OBJS_H + +#include "ruby.h" + +VALUE rbs_ast_annotation(VALUE string, VALUE location); +VALUE rbs_ast_comment(VALUE string, VALUE location); +VALUE rbs_ast_decl_class(VALUE name, VALUE type_params, VALUE super_class, VALUE members, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_decl_class_super(VALUE name, VALUE args, VALUE location); +VALUE rbs_ast_decl_class_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment); +VALUE rbs_ast_decl_constant(VALUE name, VALUE type, VALUE location, VALUE comment); +VALUE rbs_ast_decl_global(VALUE name, VALUE type, VALUE location, VALUE comment); +VALUE rbs_ast_decl_interface(VALUE name, VALUE type_params, VALUE members, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE members, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location); +VALUE rbs_ast_decl_module_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment); +VALUE rbs_ast_decl_type_alias(VALUE name, VALUE type_params, VALUE type, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_directives_use(VALUE clauses, VALUE location); +VALUE rbs_ast_directives_use_single_clause(VALUE type_name, VALUE new_name, VALUE location); +VALUE rbs_ast_directives_use_wildcard_clause(VALUE namespace, VALUE location); +VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_members_attr_accessor(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility); +VALUE rbs_ast_members_attr_reader(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility); +VALUE rbs_ast_members_attr_writer(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility); +VALUE rbs_ast_members_class_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment); +VALUE rbs_ast_members_class_variable(VALUE name, VALUE type, VALUE location, VALUE comment); +VALUE rbs_ast_members_extend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_members_include(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_members_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment); +VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE overloads, VALUE annotations, VALUE location, VALUE comment, VALUE overloading, VALUE visibility); +VALUE rbs_ast_members_method_definition_overload(VALUE annotations, VALUE method_type); +VALUE rbs_ast_members_prepend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment); +VALUE rbs_ast_members_private(VALUE location); +VALUE rbs_ast_members_public(VALUE location); +VALUE rbs_ast_type_param(VALUE name, VALUE variance, VALUE upper_bound, VALUE default_type, VALUE location); +VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location); +VALUE rbs_namespace(VALUE path, VALUE absolute); +VALUE rbs_type_name(VALUE namespace, VALUE name); +VALUE rbs_alias(VALUE name, VALUE args, VALUE location); +VALUE rbs_bases_any(VALUE location); +VALUE rbs_bases_bool(VALUE location); +VALUE rbs_bases_bottom(VALUE location); +VALUE rbs_bases_class(VALUE location); +VALUE rbs_bases_instance(VALUE location); +VALUE rbs_bases_nil(VALUE location); +VALUE rbs_bases_self(VALUE location); +VALUE rbs_bases_top(VALUE location); +VALUE rbs_bases_void(VALUE location); +VALUE rbs_block(VALUE type, VALUE required, VALUE self_type); +VALUE rbs_class_instance(VALUE name, VALUE args, VALUE location); +VALUE rbs_class_singleton(VALUE name, VALUE location); +VALUE rbs_function(VALUE required_positionals, VALUE optional_positionals, VALUE rest_positionals, VALUE trailing_positionals, VALUE required_keywords, VALUE optional_keywords, VALUE rest_keywords, VALUE return_type); +VALUE rbs_function_param(VALUE type, VALUE name, VALUE location); +VALUE rbs_interface(VALUE name, VALUE args, VALUE location); +VALUE rbs_intersection(VALUE types, VALUE location); +VALUE rbs_literal(VALUE literal, VALUE location); +VALUE rbs_optional(VALUE type, VALUE location); +VALUE rbs_proc(VALUE type, VALUE block, VALUE location, VALUE self_type); +VALUE rbs_record(VALUE all_fields, VALUE location); +VALUE rbs_tuple(VALUE types, VALUE location); +VALUE rbs_union(VALUE types, VALUE location); +VALUE rbs_untyped_function(VALUE return_type); +VALUE rbs_variable(VALUE name, VALUE location); + +#endif diff --git a/src/constants.c b/src/constants.c new file mode 100644 index 0000000000..dd1e2ee5c6 --- /dev/null +++ b/src/constants.c @@ -0,0 +1,153 @@ +/*----------------------------------------------------------------------------*/ +/* This file is generated by the templates/template.rb script and should not */ +/* be modified manually. */ +/* To change the template see */ +/* templates/src/constants.c.erb */ +/*----------------------------------------------------------------------------*/ + +#include "rbs_extension.h" + +VALUE RBS_Parser; + +VALUE RBS; +VALUE RBS_AST; +VALUE RBS_AST_Declarations; +VALUE RBS_AST_Directives; +VALUE RBS_AST_Members; +VALUE RBS_Parser; +VALUE RBS_Types; +VALUE RBS_Types_Bases; + +VALUE RBS_AST_Annotation; +VALUE RBS_AST_Comment; +VALUE RBS_AST_Declarations_Class; +VALUE RBS_AST_Declarations_Class_Super; +VALUE RBS_AST_Declarations_ClassAlias; +VALUE RBS_AST_Declarations_Constant; +VALUE RBS_AST_Declarations_Global; +VALUE RBS_AST_Declarations_Interface; +VALUE RBS_AST_Declarations_Module; +VALUE RBS_AST_Declarations_Module_Self; +VALUE RBS_AST_Declarations_ModuleAlias; +VALUE RBS_AST_Declarations_TypeAlias; +VALUE RBS_AST_Directives_Use; +VALUE RBS_AST_Directives_Use_SingleClause; +VALUE RBS_AST_Directives_Use_WildcardClause; +VALUE RBS_AST_Members_Alias; +VALUE RBS_AST_Members_AttrAccessor; +VALUE RBS_AST_Members_AttrReader; +VALUE RBS_AST_Members_AttrWriter; +VALUE RBS_AST_Members_ClassInstanceVariable; +VALUE RBS_AST_Members_ClassVariable; +VALUE RBS_AST_Members_Extend; +VALUE RBS_AST_Members_Include; +VALUE RBS_AST_Members_InstanceVariable; +VALUE RBS_AST_Members_MethodDefinition; +VALUE RBS_AST_Members_MethodDefinition_Overload; +VALUE RBS_AST_Members_Prepend; +VALUE RBS_AST_Members_Private; +VALUE RBS_AST_Members_Public; +VALUE RBS_AST_TypeParam; +VALUE RBS_MethodType; +VALUE RBS_Namespace; +VALUE RBS_TypeName; +VALUE RBS_Types_Alias; +VALUE RBS_Types_Bases_Any; +VALUE RBS_Types_Bases_Bool; +VALUE RBS_Types_Bases_Bottom; +VALUE RBS_Types_Bases_Class; +VALUE RBS_Types_Bases_Instance; +VALUE RBS_Types_Bases_Nil; +VALUE RBS_Types_Bases_Self; +VALUE RBS_Types_Bases_Top; +VALUE RBS_Types_Bases_Void; +VALUE RBS_Types_Block; +VALUE RBS_Types_ClassInstance; +VALUE RBS_Types_ClassSingleton; +VALUE RBS_Types_Function; +VALUE RBS_Types_Function_Param; +VALUE RBS_Types_Interface; +VALUE RBS_Types_Intersection; +VALUE RBS_Types_Literal; +VALUE RBS_Types_Optional; +VALUE RBS_Types_Proc; +VALUE RBS_Types_Record; +VALUE RBS_Types_Tuple; +VALUE RBS_Types_Union; +VALUE RBS_Types_UntypedFunction; +VALUE RBS_Types_Variable; + +VALUE RBS_ParsingError; + +#define IMPORT_CONSTANT(var, parent, name) { var = rb_const_get(parent, rb_intern(name)); rb_gc_register_mark_object(var); } + +void rbs__init_constants(void) { + IMPORT_CONSTANT(RBS, rb_cObject, "RBS"); + IMPORT_CONSTANT(RBS_ParsingError, RBS, "ParsingError"); + + IMPORT_CONSTANT(RBS_AST, RBS, "AST"); + IMPORT_CONSTANT(RBS_AST_Declarations, RBS_AST, "Declarations"); + IMPORT_CONSTANT(RBS_AST_Directives, RBS_AST, "Directives"); + IMPORT_CONSTANT(RBS_AST_Members, RBS_AST, "Members"); + IMPORT_CONSTANT(RBS_Types, RBS, "Types"); + IMPORT_CONSTANT(RBS_Types_Bases, RBS_Types, "Bases"); + + IMPORT_CONSTANT(RBS_AST_Annotation, RBS_AST, "Annotation"); + IMPORT_CONSTANT(RBS_AST_Comment, RBS_AST, "Comment"); + IMPORT_CONSTANT(RBS_AST_Declarations_Class, RBS_AST_Declarations, "Class"); + IMPORT_CONSTANT(RBS_AST_Declarations_Class_Super, RBS_AST_Declarations_Class, "Super"); + IMPORT_CONSTANT(RBS_AST_Declarations_ClassAlias, RBS_AST_Declarations, "ClassAlias"); + IMPORT_CONSTANT(RBS_AST_Declarations_Constant, RBS_AST_Declarations, "Constant"); + IMPORT_CONSTANT(RBS_AST_Declarations_Global, RBS_AST_Declarations, "Global"); + IMPORT_CONSTANT(RBS_AST_Declarations_Interface, RBS_AST_Declarations, "Interface"); + IMPORT_CONSTANT(RBS_AST_Declarations_Module, RBS_AST_Declarations, "Module"); + IMPORT_CONSTANT(RBS_AST_Declarations_Module_Self, RBS_AST_Declarations_Module, "Self"); + IMPORT_CONSTANT(RBS_AST_Declarations_ModuleAlias, RBS_AST_Declarations, "ModuleAlias"); + IMPORT_CONSTANT(RBS_AST_Declarations_TypeAlias, RBS_AST_Declarations, "TypeAlias"); + IMPORT_CONSTANT(RBS_AST_Directives_Use, RBS_AST_Directives, "Use"); + IMPORT_CONSTANT(RBS_AST_Directives_Use_SingleClause, RBS_AST_Directives_Use, "SingleClause"); + IMPORT_CONSTANT(RBS_AST_Directives_Use_WildcardClause, RBS_AST_Directives_Use, "WildcardClause"); + IMPORT_CONSTANT(RBS_AST_Members_Alias, RBS_AST_Members, "Alias"); + IMPORT_CONSTANT(RBS_AST_Members_AttrAccessor, RBS_AST_Members, "AttrAccessor"); + IMPORT_CONSTANT(RBS_AST_Members_AttrReader, RBS_AST_Members, "AttrReader"); + IMPORT_CONSTANT(RBS_AST_Members_AttrWriter, RBS_AST_Members, "AttrWriter"); + IMPORT_CONSTANT(RBS_AST_Members_ClassInstanceVariable, RBS_AST_Members, "ClassInstanceVariable"); + IMPORT_CONSTANT(RBS_AST_Members_ClassVariable, RBS_AST_Members, "ClassVariable"); + IMPORT_CONSTANT(RBS_AST_Members_Extend, RBS_AST_Members, "Extend"); + IMPORT_CONSTANT(RBS_AST_Members_Include, RBS_AST_Members, "Include"); + IMPORT_CONSTANT(RBS_AST_Members_InstanceVariable, RBS_AST_Members, "InstanceVariable"); + IMPORT_CONSTANT(RBS_AST_Members_MethodDefinition, RBS_AST_Members, "MethodDefinition"); + IMPORT_CONSTANT(RBS_AST_Members_MethodDefinition_Overload, RBS_AST_Members_MethodDefinition, "Overload"); + IMPORT_CONSTANT(RBS_AST_Members_Prepend, RBS_AST_Members, "Prepend"); + IMPORT_CONSTANT(RBS_AST_Members_Private, RBS_AST_Members, "Private"); + IMPORT_CONSTANT(RBS_AST_Members_Public, RBS_AST_Members, "Public"); + IMPORT_CONSTANT(RBS_AST_TypeParam, RBS_AST, "TypeParam"); + IMPORT_CONSTANT(RBS_MethodType, RBS, "MethodType"); + IMPORT_CONSTANT(RBS_Namespace, RBS, "Namespace"); + IMPORT_CONSTANT(RBS_TypeName, RBS, "TypeName"); + IMPORT_CONSTANT(RBS_Types_Alias, RBS_Types, "Alias"); + IMPORT_CONSTANT(RBS_Types_Bases_Any, RBS_Types_Bases, "Any"); + IMPORT_CONSTANT(RBS_Types_Bases_Bool, RBS_Types_Bases, "Bool"); + IMPORT_CONSTANT(RBS_Types_Bases_Bottom, RBS_Types_Bases, "Bottom"); + IMPORT_CONSTANT(RBS_Types_Bases_Class, RBS_Types_Bases, "Class"); + IMPORT_CONSTANT(RBS_Types_Bases_Instance, RBS_Types_Bases, "Instance"); + IMPORT_CONSTANT(RBS_Types_Bases_Nil, RBS_Types_Bases, "Nil"); + IMPORT_CONSTANT(RBS_Types_Bases_Self, RBS_Types_Bases, "Self"); + IMPORT_CONSTANT(RBS_Types_Bases_Top, RBS_Types_Bases, "Top"); + IMPORT_CONSTANT(RBS_Types_Bases_Void, RBS_Types_Bases, "Void"); + IMPORT_CONSTANT(RBS_Types_Block, RBS_Types, "Block"); + IMPORT_CONSTANT(RBS_Types_ClassInstance, RBS_Types, "ClassInstance"); + IMPORT_CONSTANT(RBS_Types_ClassSingleton, RBS_Types, "ClassSingleton"); + IMPORT_CONSTANT(RBS_Types_Function, RBS_Types, "Function"); + IMPORT_CONSTANT(RBS_Types_Function_Param, RBS_Types_Function, "Param"); + IMPORT_CONSTANT(RBS_Types_Interface, RBS_Types, "Interface"); + IMPORT_CONSTANT(RBS_Types_Intersection, RBS_Types, "Intersection"); + IMPORT_CONSTANT(RBS_Types_Literal, RBS_Types, "Literal"); + IMPORT_CONSTANT(RBS_Types_Optional, RBS_Types, "Optional"); + IMPORT_CONSTANT(RBS_Types_Proc, RBS_Types, "Proc"); + IMPORT_CONSTANT(RBS_Types_Record, RBS_Types, "Record"); + IMPORT_CONSTANT(RBS_Types_Tuple, RBS_Types, "Tuple"); + IMPORT_CONSTANT(RBS_Types_Union, RBS_Types, "Union"); + IMPORT_CONSTANT(RBS_Types_UntypedFunction, RBS_Types, "UntypedFunction"); + IMPORT_CONSTANT(RBS_Types_Variable, RBS_Types, "Variable"); +} diff --git a/src/ruby_objs.c b/src/ruby_objs.c new file mode 100644 index 0000000000..8f99b7c8ca --- /dev/null +++ b/src/ruby_objs.c @@ -0,0 +1,793 @@ +/*----------------------------------------------------------------------------*/ +/* This file is generated by the templates/template.rb script and should not */ +/* be modified manually. */ +/* To change the template see */ +/* templates/src/ruby_objs.c.erb */ +/*----------------------------------------------------------------------------*/ + +#include "rbs_extension.h" + +#ifdef RB_PASS_KEYWORDS + // Ruby 2.7 or later + #define CLASS_NEW_INSTANCE(klass, argc, argv)\ + rb_class_new_instance_kw(argc, argv, klass, RB_PASS_KEYWORDS) +#else + // Ruby 2.6 + #define CLASS_NEW_INSTANCE(receiver, argc, argv)\ + rb_class_new_instance(argc, argv, receiver) +#endif + +VALUE rbs_ast_annotation(VALUE string, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("string")), string); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Annotation, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_comment(VALUE string, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("string")), string); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Comment, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_class(VALUE name, VALUE type_params, VALUE super_class, VALUE members, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("super_class")), super_class); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Class, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_class_super(VALUE name, VALUE args, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Class_Super, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_class_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_ClassAlias, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_constant(VALUE name, VALUE type, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Constant, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_global(VALUE name, VALUE type, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Global, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_interface(VALUE name, VALUE type_params, VALUE members, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Interface, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_module(VALUE name, VALUE type_params, VALUE self_types, VALUE members, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_types")), self_types); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("members")), members); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Module, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_module_self(VALUE name, VALUE args, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_Module_Self, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_module_alias(VALUE new_name, VALUE old_name, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_ModuleAlias, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_decl_type_alias(VALUE name, VALUE type_params, VALUE type, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Declarations_TypeAlias, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_directives_use(VALUE clauses, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("clauses")), clauses); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Directives_Use, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_directives_use_single_clause(VALUE type_name, VALUE new_name, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_name")), type_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Directives_Use_SingleClause, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_directives_use_wildcard_clause(VALUE namespace, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("namespace")), namespace); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Directives_Use_WildcardClause, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_alias(VALUE new_name, VALUE old_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("new_name")), new_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("old_name")), old_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Alias, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_attr_accessor(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_AttrAccessor, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_attr_reader(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_AttrReader, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_attr_writer(VALUE name, VALUE type, VALUE ivar_name, VALUE kind, VALUE annotations, VALUE location, VALUE comment, VALUE visibility) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("ivar_name")), ivar_name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_AttrWriter, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_class_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_ClassInstanceVariable, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_class_variable(VALUE name, VALUE type, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_ClassVariable, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_extend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Extend, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_include(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Include, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_instance_variable(VALUE name, VALUE type, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_InstanceVariable, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_method_definition(VALUE name, VALUE kind, VALUE overloads, VALUE annotations, VALUE location, VALUE comment, VALUE overloading, VALUE visibility) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("kind")), kind); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("overloads")), overloads); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("overloading")), overloading); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("visibility")), visibility); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_MethodDefinition, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_method_definition_overload(VALUE annotations, VALUE method_type) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("method_type")), method_type); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_MethodDefinition_Overload, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_prepend(VALUE name, VALUE args, VALUE annotations, VALUE location, VALUE comment) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("annotations")), annotations); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("comment")), comment); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Prepend, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_private(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Private, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_members_public(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_Members_Public, + 1, + &_init_kwargs + ); +} + +VALUE rbs_ast_type_param(VALUE name, VALUE variance, VALUE upper_bound, VALUE default_type, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("variance")), variance); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("upper_bound")), upper_bound); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("default_type")), default_type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_AST_TypeParam, + 1, + &_init_kwargs + ); +} + +VALUE rbs_method_type(VALUE type_params, VALUE type, VALUE block, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type_params")), type_params); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("block")), block); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_MethodType, + 1, + &_init_kwargs + ); +} + +VALUE rbs_namespace(VALUE path, VALUE absolute) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("path")), path); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("absolute")), absolute); + + return CLASS_NEW_INSTANCE( + RBS_Namespace, + 1, + &_init_kwargs + ); +} + +VALUE rbs_type_name(VALUE namespace, VALUE name) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("namespace")), namespace); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + + return CLASS_NEW_INSTANCE( + RBS_TypeName, + 1, + &_init_kwargs + ); +} + +VALUE rbs_alias(VALUE name, VALUE args, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Alias, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_any(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Any, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_bool(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Bool, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_bottom(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Bottom, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_class(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Class, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_instance(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Instance, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_nil(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Nil, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_self(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Self, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_top(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Top, + 1, + &_init_kwargs + ); +} + +VALUE rbs_bases_void(VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Bases_Void, + 1, + &_init_kwargs + ); +} + +VALUE rbs_block(VALUE type, VALUE required, VALUE self_type) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required")), required); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_type")), self_type); + + return CLASS_NEW_INSTANCE( + RBS_Types_Block, + 1, + &_init_kwargs + ); +} + +VALUE rbs_class_instance(VALUE name, VALUE args, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_ClassInstance, + 1, + &_init_kwargs + ); +} + +VALUE rbs_class_singleton(VALUE name, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_ClassSingleton, + 1, + &_init_kwargs + ); +} + +VALUE rbs_function(VALUE required_positionals, VALUE optional_positionals, VALUE rest_positionals, VALUE trailing_positionals, VALUE required_keywords, VALUE optional_keywords, VALUE rest_keywords, VALUE return_type) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required_positionals")), required_positionals); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("optional_positionals")), optional_positionals); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("rest_positionals")), rest_positionals); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("trailing_positionals")), trailing_positionals); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("required_keywords")), required_keywords); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("optional_keywords")), optional_keywords); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("rest_keywords")), rest_keywords); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("return_type")), return_type); + + return CLASS_NEW_INSTANCE( + RBS_Types_Function, + 1, + &_init_kwargs + ); +} + +VALUE rbs_function_param(VALUE type, VALUE name, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Function_Param, + 1, + &_init_kwargs + ); +} + +VALUE rbs_interface(VALUE name, VALUE args, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("args")), args); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Interface, + 1, + &_init_kwargs + ); +} + +VALUE rbs_intersection(VALUE types, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Intersection, + 1, + &_init_kwargs + ); +} + +VALUE rbs_literal(VALUE literal, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("literal")), literal); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Literal, + 1, + &_init_kwargs + ); +} + +VALUE rbs_optional(VALUE type, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Optional, + 1, + &_init_kwargs + ); +} + +VALUE rbs_proc(VALUE type, VALUE block, VALUE location, VALUE self_type) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("type")), type); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("block")), block); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("self_type")), self_type); + + return CLASS_NEW_INSTANCE( + RBS_Types_Proc, + 1, + &_init_kwargs + ); +} + +VALUE rbs_record(VALUE all_fields, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("all_fields")), all_fields); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Record, + 1, + &_init_kwargs + ); +} + +VALUE rbs_tuple(VALUE types, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Tuple, + 1, + &_init_kwargs + ); +} + +VALUE rbs_union(VALUE types, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("types")), types); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Union, + 1, + &_init_kwargs + ); +} + +VALUE rbs_untyped_function(VALUE return_type) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("return_type")), return_type); + + return CLASS_NEW_INSTANCE( + RBS_Types_UntypedFunction, + 1, + &_init_kwargs + ); +} + +VALUE rbs_variable(VALUE name, VALUE location) { + VALUE _init_kwargs = rb_hash_new(); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("name")), name); + rb_hash_aset(_init_kwargs, ID2SYM(rb_intern("location")), location); + + return CLASS_NEW_INSTANCE( + RBS_Types_Variable, + 1, + &_init_kwargs + ); +} +