Skip to content

Commit

Permalink
Merge pull request #1552 from ruby/backport-mark-global-variables
Browse files Browse the repository at this point in the history
Backport #1551 (mark-global-variables)
  • Loading branch information
soutaro authored Sep 28, 2023
2 parents 6e5a289 + 23e4893 commit 50609ef
Showing 1 changed file with 73 additions and 72 deletions.
145 changes: 73 additions & 72 deletions ext/rbs_extension/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,77 +75,78 @@ VALUE RBS_MethodType;

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) {
ID id_RBS = rb_intern_const("RBS");

RBS = rb_const_get(rb_cObject, id_RBS);
RBS_ParsingError = rb_const_get(RBS, rb_intern("ParsingError"));
RBS_AST = rb_const_get(RBS, rb_intern("AST"));
RBS_AST_Comment = rb_const_get(RBS_AST, rb_intern("Comment"));
RBS_AST_Annotation = rb_const_get(RBS_AST, rb_intern("Annotation"));
RBS_AST_TypeParam = rb_const_get(RBS_AST, rb_intern("TypeParam"));

RBS_AST_Declarations = rb_const_get(RBS_AST, rb_intern("Declarations"));

RBS_AST_Declarations_TypeAlias = rb_const_get(RBS_AST_Declarations, rb_intern("TypeAlias"));
RBS_AST_Declarations_Constant = rb_const_get(RBS_AST_Declarations, rb_intern("Constant"));
RBS_AST_Declarations_Global = rb_const_get(RBS_AST_Declarations, rb_intern("Global"));
RBS_AST_Declarations_Interface = rb_const_get(RBS_AST_Declarations, rb_intern("Interface"));
RBS_AST_Declarations_Module = rb_const_get(RBS_AST_Declarations, rb_intern("Module"));
RBS_AST_Declarations_Module_Self = rb_const_get(RBS_AST_Declarations_Module, rb_intern("Self"));
RBS_AST_Declarations_Class = rb_const_get(RBS_AST_Declarations, rb_intern("Class"));
RBS_AST_Declarations_Class_Super = rb_const_get(RBS_AST_Declarations_Class, rb_intern("Super"));
RBS_AST_Declarations_ClassAlias = rb_const_get(RBS_AST_Declarations, rb_intern("ClassAlias"));
RBS_AST_Declarations_ModuleAlias = rb_const_get(RBS_AST_Declarations, rb_intern("ModuleAlias"));

RBS_AST_Directives = rb_const_get(RBS_AST, rb_intern("Directives"));
RBS_AST_Directives_Use = rb_const_get(RBS_AST_Directives, rb_intern("Use"));
RBS_AST_Directives_Use_SingleClause = rb_const_get(RBS_AST_Directives_Use, rb_intern("SingleClause"));
RBS_AST_Directives_Use_WildcardClause = rb_const_get(RBS_AST_Directives_Use, rb_intern("WildcardClause"));

RBS_AST_Members = rb_const_get(RBS_AST, rb_intern("Members"));
RBS_AST_Members_Alias = rb_const_get(RBS_AST_Members, rb_intern("Alias"));
RBS_AST_Members_AttrAccessor = rb_const_get(RBS_AST_Members, rb_intern("AttrAccessor"));
RBS_AST_Members_AttrReader = rb_const_get(RBS_AST_Members, rb_intern("AttrReader"));
RBS_AST_Members_AttrWriter = rb_const_get(RBS_AST_Members, rb_intern("AttrWriter"));
RBS_AST_Members_ClassInstanceVariable = rb_const_get(RBS_AST_Members, rb_intern("ClassInstanceVariable"));
RBS_AST_Members_ClassVariable = rb_const_get(RBS_AST_Members, rb_intern("ClassVariable"));
RBS_AST_Members_Extend = rb_const_get(RBS_AST_Members, rb_intern("Extend"));
RBS_AST_Members_Include = rb_const_get(RBS_AST_Members, rb_intern("Include"));
RBS_AST_Members_InstanceVariable = rb_const_get(RBS_AST_Members, rb_intern("InstanceVariable"));
RBS_AST_Members_MethodDefinition = rb_const_get(RBS_AST_Members, rb_intern("MethodDefinition"));
RBS_AST_Members_MethodDefinition_Overload = rb_const_get(RBS_AST_Members_MethodDefinition, rb_intern("Overload"));
RBS_AST_Members_Prepend = rb_const_get(RBS_AST_Members, rb_intern("Prepend"));
RBS_AST_Members_Private = rb_const_get(RBS_AST_Members, rb_intern("Private"));
RBS_AST_Members_Public = rb_const_get(RBS_AST_Members, rb_intern("Public"));

RBS_Namespace = rb_const_get(RBS, rb_intern("Namespace"));
RBS_TypeName = rb_const_get(RBS, rb_intern("TypeName"));
RBS_Types = rb_const_get(RBS, rb_intern("Types"));
RBS_Types_Alias = rb_const_get(RBS_Types, rb_intern("Alias"));
RBS_Types_Bases = rb_const_get(RBS_Types, rb_intern("Bases"));
RBS_Types_Bases_Any = rb_const_get(RBS_Types_Bases, rb_intern("Any"));
RBS_Types_Bases_Bool = rb_const_get(RBS_Types_Bases, rb_intern("Bool"));
RBS_Types_Bases_Bottom = rb_const_get(RBS_Types_Bases, rb_intern("Bottom"));
RBS_Types_Bases_Class = rb_const_get(RBS_Types_Bases, rb_intern("Class"));
RBS_Types_Bases_Instance = rb_const_get(RBS_Types_Bases, rb_intern("Instance"));
RBS_Types_Bases_Nil = rb_const_get(RBS_Types_Bases, rb_intern("Nil"));
RBS_Types_Bases_Self = rb_const_get(RBS_Types_Bases, rb_intern("Self"));
RBS_Types_Bases_Top = rb_const_get(RBS_Types_Bases, rb_intern("Top"));
RBS_Types_Bases_Void = rb_const_get(RBS_Types_Bases, rb_intern("Void"));
RBS_Types_Block = rb_const_get(RBS_Types, rb_intern("Block"));
RBS_Types_ClassInstance = rb_const_get(RBS_Types, rb_intern("ClassInstance"));
RBS_Types_ClassSingleton = rb_const_get(RBS_Types, rb_intern("ClassSingleton"));
RBS_Types_Function = rb_const_get(RBS_Types, rb_intern("Function"));
RBS_Types_Function_Param = rb_const_get(RBS_Types_Function, rb_intern("Param"));
RBS_Types_Interface = rb_const_get(RBS_Types, rb_intern("Interface"));
RBS_Types_Intersection = rb_const_get(RBS_Types, rb_intern("Intersection"));
RBS_Types_Literal = rb_const_get(RBS_Types, rb_intern("Literal"));
RBS_Types_Optional = rb_const_get(RBS_Types, rb_intern("Optional"));
RBS_Types_Proc = rb_const_get(RBS_Types, rb_intern("Proc"));
RBS_Types_Record = rb_const_get(RBS_Types, rb_intern("Record"));
RBS_Types_Tuple = rb_const_get(RBS_Types, rb_intern("Tuple"));
RBS_Types_Union = rb_const_get(RBS_Types, rb_intern("Union"));
RBS_Types_Variable = rb_const_get(RBS_Types, rb_intern("Variable"));
RBS_MethodType = rb_const_get(RBS, rb_intern("MethodType"));
IMPORT_CONSTANT(RBS, rb_cObject, "RBS");
IMPORT_CONSTANT(RBS_ParsingError, RBS, "ParsingError");

IMPORT_CONSTANT(RBS_AST, RBS, "AST");
IMPORT_CONSTANT(RBS_AST_Comment, RBS_AST, "Comment");
IMPORT_CONSTANT(RBS_AST_Annotation, RBS_AST, "Annotation");
IMPORT_CONSTANT(RBS_AST_TypeParam, RBS_AST, "TypeParam");

IMPORT_CONSTANT(RBS_AST_Declarations, RBS_AST, "Declarations");

IMPORT_CONSTANT(RBS_AST_Declarations_TypeAlias, RBS_AST_Declarations, "TypeAlias");
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_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_ModuleAlias, RBS_AST_Declarations, "ModuleAlias");

IMPORT_CONSTANT(RBS_AST_Directives, RBS_AST, "Directives");
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, RBS_AST, "Members");
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_Namespace, RBS, "Namespace");
IMPORT_CONSTANT(RBS_TypeName, RBS, "TypeName");
IMPORT_CONSTANT(RBS_Types, RBS, "Types");
IMPORT_CONSTANT(RBS_Types_Alias, RBS_Types, "Alias");
IMPORT_CONSTANT(RBS_Types_Bases, RBS_Types, "Bases");
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_Variable, RBS_Types, "Variable");
IMPORT_CONSTANT(RBS_MethodType, RBS, "MethodType");
}

0 comments on commit 50609ef

Please sign in to comment.