mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* class.c (rb_define_class): should handle autoload.
* class.c (rb_define_module): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7bb210b303
								
							
						
					
					
						commit
						601d06f3e3
					
				
					 4 changed files with 27 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Thu Mar 14 16:42:37 2002  Yukihiro Matsumoto  <matz@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* class.c (rb_define_class): should handle autoload.
 | 
			
		||||
 | 
			
		||||
	* class.c (rb_define_module): ditto.
 | 
			
		||||
 | 
			
		||||
Thu Mar 14 00:29:12 2002  Yukihiro Matsumoto  <matz@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* re.c (rb_reg_match): should clear $~ if operand is nil.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										6
									
								
								class.c
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								class.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -162,6 +162,9 @@ rb_define_class(name, super)
 | 
			
		|||
    ID id;
 | 
			
		||||
 | 
			
		||||
    id = rb_intern(name);
 | 
			
		||||
    if (rb_autoload_defined(id)) {
 | 
			
		||||
	rb_autoload_load(id);
 | 
			
		||||
    }
 | 
			
		||||
    if (rb_const_defined(rb_cObject, id)) {
 | 
			
		||||
	klass = rb_const_get(rb_cObject, id);
 | 
			
		||||
	if (TYPE(klass) != T_CLASS) {
 | 
			
		||||
| 
						 | 
				
			
			@ -242,6 +245,9 @@ rb_define_module(name)
 | 
			
		|||
    ID id;
 | 
			
		||||
 | 
			
		||||
    id = rb_intern(name);
 | 
			
		||||
    if (rb_autoload_defined(id)) {
 | 
			
		||||
	rb_autoload_load(id);
 | 
			
		||||
    }
 | 
			
		||||
    if (rb_const_defined(rb_cObject, id)) {
 | 
			
		||||
	module = rb_const_get(rb_cObject, id);
 | 
			
		||||
	if (TYPE(module) == T_MODULE)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -471,11 +471,12 @@ w_object(obj, arg, limit)
 | 
			
		|||
		VALUE klass = CLASS_OF(obj);
 | 
			
		||||
		char *path;
 | 
			
		||||
 | 
			
		||||
		if (FL_TEST(klass, FL_SINGLETON)) {
 | 
			
		||||
		while (FL_TEST(klass, FL_SINGLETON) || BUILTIN_TYPE(klass) == T_ICLASS) {
 | 
			
		||||
		    if (RCLASS(klass)->m_tbl->num_entries > 0 ||
 | 
			
		||||
			RCLASS(klass)->iv_tbl->num_entries > 1) {
 | 
			
		||||
			rb_raise(rb_eTypeError, "singleton can't be dumped");
 | 
			
		||||
		    }
 | 
			
		||||
		    klass = RCLASS(klass)->super;
 | 
			
		||||
		}
 | 
			
		||||
		path = rb_class2name(klass);
 | 
			
		||||
		w_unique(path, arg);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										21
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								parse.y
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -380,7 +380,7 @@ stmt		: kALIAS fitem {lex_state = EXPR_FNAME;} fitem
 | 
			
		|||
			if (in_def || in_single) {
 | 
			
		||||
			    yyerror("BEGIN in method");
 | 
			
		||||
			}
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		    }
 | 
			
		||||
		  '{' compstmt '}'
 | 
			
		||||
		    {
 | 
			
		||||
| 
						 | 
				
			
			@ -1249,7 +1249,7 @@ primary		: literal
 | 
			
		|||
			if (in_def || in_single)
 | 
			
		||||
			    yyerror("class definition in method body");
 | 
			
		||||
			class_nest++;
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		        $<num>$ = ruby_sourceline;
 | 
			
		||||
		    }
 | 
			
		||||
		  compstmt
 | 
			
		||||
| 
						 | 
				
			
			@ -1270,7 +1270,7 @@ primary		: literal
 | 
			
		|||
		        $<num>$ = in_single;
 | 
			
		||||
		        in_single = 0;
 | 
			
		||||
			class_nest++;
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		    }
 | 
			
		||||
		  compstmt
 | 
			
		||||
		  kEND
 | 
			
		||||
| 
						 | 
				
			
			@ -1287,7 +1287,7 @@ primary		: literal
 | 
			
		|||
			if (in_def || in_single)
 | 
			
		||||
			    yyerror("module definition in method body");
 | 
			
		||||
			class_nest++;
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		        $<num>$ = ruby_sourceline;
 | 
			
		||||
		    }
 | 
			
		||||
		  compstmt
 | 
			
		||||
| 
						 | 
				
			
			@ -1305,7 +1305,7 @@ primary		: literal
 | 
			
		|||
			$<id>$ = cur_mid;
 | 
			
		||||
			cur_mid = $2;
 | 
			
		||||
			in_def++;
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		    }
 | 
			
		||||
		  f_arglist
 | 
			
		||||
		  compstmt
 | 
			
		||||
| 
						 | 
				
			
			@ -1333,7 +1333,7 @@ primary		: literal
 | 
			
		|||
		    {
 | 
			
		||||
			value_expr($2);
 | 
			
		||||
			in_single++;
 | 
			
		||||
			local_push();
 | 
			
		||||
			local_push(1);
 | 
			
		||||
		        lex_state = EXPR_END; /* force for args */
 | 
			
		||||
		    }
 | 
			
		||||
		  f_arglist
 | 
			
		||||
| 
						 | 
				
			
			@ -4684,11 +4684,12 @@ static struct local_vars {
 | 
			
		|||
    int nofree;
 | 
			
		||||
    int cnt;
 | 
			
		||||
    int dlev;
 | 
			
		||||
    struct RVarmap* dyna_vars;
 | 
			
		||||
    struct local_vars *prev;
 | 
			
		||||
} *lvtbl;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
local_push()
 | 
			
		||||
local_push(int dyna_init)
 | 
			
		||||
{
 | 
			
		||||
    struct local_vars *local;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4698,7 +4699,10 @@ local_push()
 | 
			
		|||
    local->cnt = 0;
 | 
			
		||||
    local->tbl = 0;
 | 
			
		||||
    local->dlev = 0;
 | 
			
		||||
    local->dyna_vars = ruby_dyna_vars;
 | 
			
		||||
    lvtbl = local;
 | 
			
		||||
 | 
			
		||||
    if (dyna_init) ruby_dyna_vars = (struct RVarmap* )0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
| 
						 | 
				
			
			@ -4710,6 +4714,7 @@ local_pop()
 | 
			
		|||
	if (!lvtbl->nofree) free(lvtbl->tbl);
 | 
			
		||||
	else lvtbl->tbl[0] = lvtbl->cnt;
 | 
			
		||||
    }
 | 
			
		||||
    ruby_dyna_vars = lvtbl->dyna_vars;
 | 
			
		||||
    free(lvtbl);
 | 
			
		||||
    lvtbl = local;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -4772,7 +4777,7 @@ local_id(id)
 | 
			
		|||
static void
 | 
			
		||||
top_local_init()
 | 
			
		||||
{
 | 
			
		||||
    local_push();
 | 
			
		||||
    local_push(0);
 | 
			
		||||
    lvtbl->cnt = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
 | 
			
		||||
    if (lvtbl->cnt > 0) {
 | 
			
		||||
	lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+3);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue