Skip to content

Commit

Permalink
matz
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Aug 28, 2000
1 parent e0f3aab commit 770303d
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 82 deletions.
17 changes: 17 additions & 0 deletions ChangeLog
@@ -1,7 +1,24 @@
Mon Aug 28 18:43:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (is_defined): now handles class variables.

* eval.c (rb_eval): class variable behavior revisited.

* parse.y (assignable): ditto.

* parse.y (gettable): ditto.

* regex.c (PUSH_FAILURE_COUNT): push/pop interval count on failure
stack.

Fri Aug 25 15:24:39 2000 Yukihiro Matsumoto <matz@ruby-lang.org>

* variable.c (rb_cvar_get): should not follow __attached__.

* variable.c (rb_cvar_set): ditto.

* variable.c (rb_cvar_declare): ditto.

* variable.c (mod_av_set): second class variable assignment at the
toplevel shoule not give warning.

Expand Down
1 change: 1 addition & 0 deletions ToDo
Expand Up @@ -47,6 +47,7 @@ Hacking Interpreter
* generational GC ?
* give warnings to assign magic variables.
* export rb_io_{addstr,printf,puts,print}
* autoload should work with threads [ruby-talk:4589]

Standard Libraries

Expand Down
3 changes: 3 additions & 0 deletions config.guess
Expand Up @@ -969,6 +969,9 @@ EOF
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
echo ${UNAME_MACHINE}-apple-darwin${UNAME_RELEASE}
exit 0 ;;
esac

#echo '(No uname command or uname output not recognized.)' 1>&2
Expand Down
3 changes: 2 additions & 1 deletion config.sub
Expand Up @@ -914,7 +914,8 @@ case $os in
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
| -interix* | -uwin* | -rhapsody* | -openstep* | -oskit* \
| -darwin*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
Expand Down
17 changes: 17 additions & 0 deletions configure.in
Expand Up @@ -57,6 +57,10 @@ AC_ARG_ENABLE(fat-binary,
# to ensure AC_HEADER_SYS_WAIT works
AC_DEFINE(_POSIX_SOURCE)
;;
darwin*)
echo -n "MacOS X (Darwin): "
TARGET_ARCHS="ppc"
;;
esac
# /usr/lib/arch_tool -archify_list $TARGET_ARCHS
for archs in $TARGET_ARCHS
Expand Down Expand Up @@ -160,6 +164,7 @@ case "$target_os" in
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
darwin*) ;;
human*) ac_cv_func_getpgrp_void=yes;;
beos*) ;;
cygwin*) rb_cv_have_daylight=no;;
Expand Down Expand Up @@ -443,6 +448,7 @@ if test "$with_dln_a_out" != yes; then
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
darwin*) ;;
human*) ;;
bsdi*) ;;
beos*) ;;
Expand Down Expand Up @@ -524,6 +530,10 @@ if test "$with_dln_a_out" != yes; then
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
darwin*) LDSHARED='cc -dynamic -bundle -undefined suppress'
LDFLAGS=""
DLDFLAGS="$ARCH_FLAG"
rb_cv_dlopen=yes ;;
aix*) LDSHARED='/usr/ccs/bin/ld'
XLDFLAGS='-Wl,-bE:ruby.imp'
DLDFLAGS='-brtl -eInit_$(TARGET) -bI:$(topdir)/ruby.imp -bM:SRE -T512 -H512 -lc'
Expand Down Expand Up @@ -590,6 +600,8 @@ else
AC_DEFINE(DLEXT, ".bundle");;
rhapsody*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
darwin*) DLEXT=bundle
AC_DEFINE(DLEXT, ".bundle");;
os2_emx*) DLEXT=dll
AC_DEFINE(DLEXT, ".dll");;
cygwin*|mingw*) DLEXT=so
Expand Down Expand Up @@ -617,6 +629,8 @@ case "$target_os" in
STRIP='strip -A -n';;
rhapsody*)
STRIP='strip -A -n';;
darwin*)
STRIP='strip -A -n';;
esac

EXTSTATIC=
Expand Down Expand Up @@ -803,6 +817,9 @@ case "$target_os" in
rhapsody*)
CFLAGS="$CFLAGS -pipe -no-precomp"
;;
darwin*)
CFLAGS="$CFLAGS -pipe -no-precomp"
;;
os2_emx)
CFLAGS="$CFLAGS -DOS2"
;;
Expand Down
64 changes: 47 additions & 17 deletions eval.c
Expand Up @@ -1717,8 +1717,11 @@ is_defined(self, node, buf)
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_GASGN:
case NODE_IASGN:
case NODE_CASGN:
case NODE_CDECL:
case NODE_CVDECL:
case NODE_CVASGN:
case NODE_CVASGN2:
case NODE_CVASGN3:
return "assignment";

case NODE_LVAR:
Expand All @@ -1744,6 +1747,24 @@ is_defined(self, node, buf)
}
break;

case NODE_CVAR:
if (rb_cvar_defined(ruby_cbase, node->nd_vid)) {
return "class variable";
}
break;

case NODE_CVAR2:
if (rb_cvar_defined(CLASS_OF(self), node->nd_vid)) {
return "class variable";
}
break;

case NODE_CVAR3:
if (rb_cvar_defined_singleton(self, node->nd_vid)) {
return "class variable";
}
break;

case NODE_COLON2:
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
Expand Down Expand Up @@ -2554,14 +2575,6 @@ rb_eval(self, n)
rb_ivar_set(self, node->nd_vid, result);
break;

case NODE_CASGN:
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define constant");
}
result = rb_eval(self, node->nd_value);
ev_const_set(RNODE(ruby_frame->cbase), node->nd_vid, result);
break;

case NODE_CDECL:
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class/module to define constant");
Expand All @@ -2578,6 +2591,16 @@ rb_eval(self, n)
rb_cvar_set(ruby_cbase, node->nd_vid, result);
break;

case NODE_CVASGN2:
result = rb_eval(self, node->nd_value);
rb_cvar_set(CLASS_OF(self), node->nd_vid, result);
break;

case NODE_CVASGN3:
result = rb_eval(self, node->nd_value);
rb_cvar_set_singleton(self, node->nd_vid, result);
break;

case NODE_CVDECL:
if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define class variable");
Expand Down Expand Up @@ -2613,6 +2636,14 @@ rb_eval(self, n)
result = rb_cvar_get(ruby_cbase, node->nd_vid);
break;

case NODE_CVAR2:
result = rb_cvar_get(CLASS_OF(self), node->nd_vid);
break;

case NODE_CVAR3:
result = rb_cvar_get_singleton(self, node->nd_vid);
break;

case NODE_BLOCK_ARG:
if (ruby_scope->local_vars == 0)
rb_bug("unexpected block argument");
Expand Down Expand Up @@ -3581,10 +3612,6 @@ assign(self, lhs, val, check)
dvar_asgn_curr(lhs->nd_vid, val);
break;

case NODE_CASGN:
ev_const_set(RNODE(ruby_frame->cbase), lhs->nd_vid, val);
break;

case NODE_CDECL:
rb_const_set(ruby_class, lhs->nd_vid, val);
break;
Expand All @@ -3597,6 +3624,10 @@ assign(self, lhs, val, check)
rb_cvar_set(ruby_cbase, lhs->nd_vid, val);
break;

case NODE_CVASGN2:
rb_cvar_set(CLASS_OF(self), lhs->nd_vid, val);
break;

case NODE_MASGN:
massign(self, lhs, val, check);
break;
Expand Down Expand Up @@ -5027,8 +5058,7 @@ rb_f_require(obj, fname)
volatile int safe = ruby_safe_level;

Check_SafeStr(fname);
if (rb_provided(RSTRING(fname)->ptr))
return Qfalse;
if (rb_thread_loading(RSTRING(fname)->ptr)) return Qfalse;

ext = strrchr(RSTRING(fname)->ptr, '.');
if (ext) {
Expand Down Expand Up @@ -5107,8 +5137,8 @@ rb_f_require(obj, fname)

load_dyna:
if (rb_thread_loading(feature)) return Qfalse;

rb_provide(feature);

PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
load = rb_str_new2(file);
Expand Down
8 changes: 7 additions & 1 deletion gc.c
Expand Up @@ -481,7 +481,11 @@ rb_gc_mark(ptr)
case NODE_DASGN:
case NODE_DASGN_CURR:
case NODE_IASGN:
case NODE_CASGN:
case NODE_CDECL:
case NODE_CVDECL:
case NODE_CVASGN:
case NODE_CVASGN2:
case NODE_CVASGN3:
case NODE_MODULE:
case NODE_COLON3:
case NODE_OPT_N:
Expand Down Expand Up @@ -517,6 +521,8 @@ rb_gc_mark(ptr)
case NODE_DVAR:
case NODE_IVAR:
case NODE_CVAR:
case NODE_CVAR2:
case NODE_CVAR3:
case NODE_NTH_REF:
case NODE_BACK_REF:
case NODE_ALIAS:
Expand Down
6 changes: 5 additions & 1 deletion intern.h
Expand Up @@ -366,8 +366,12 @@ void rb_const_assign _((VALUE, ID, VALUE));
VALUE rb_mod_constants _((VALUE));
void rb_autoload_load _((ID));
void rb_cvar_declare _((VALUE, ID, VALUE));
VALUE rb_cvar_get _((VALUE, ID));
int rb_cvar_defined _((VALUE, ID));
void rb_cvar_set _((VALUE, ID, VALUE));
VALUE rb_cvar_get _((VALUE, ID));
int rb_cvar_defined_singleton _((VALUE, ID));
void rb_cvar_set_singleton _((VALUE, ID, VALUE));
VALUE rb_cvar_get_singleton _((VALUE, ID));
/* version.c */
void ruby_show_version _((void));
void ruby_show_copyright _((void));
35 changes: 26 additions & 9 deletions lib/debug.rb
Expand Up @@ -119,6 +119,15 @@ def debug_eval(str, binding)
end
end

def debug_silent_eval(str, binding)
begin
val = eval(str, binding)
val
rescue StandardError, ScriptError
nil
end
end

def var_list(ary, binding)
ary.sort!
if false # ary.size < 0
Expand Down Expand Up @@ -307,9 +316,9 @@ def debug_command(file, line, id, binding)

when /^\s*disp(?:lay)?\s+(.+)$/
exp = $1
display.push.push [true, exp]
stdout.printf " %d: %s = %s\n", display.size, exp,
eval(exp, binding) rescue "--"
display.push [true, exp]
stdout.printf "%d: ", display.size
display_expression(exp, binding)

when /^\s*disp(?:lay)?$/
display_expressions(binding)
Expand Down Expand Up @@ -493,12 +502,17 @@ def display_expressions(binding)
n = 1
for d in display
if d[0]
stdout.printf "%d: %s = %s\n", n, d[1], debug_eval(d[1], binding).to_s
stdout.printf "%d: ", n
display_expression(d[1], binding)
end
n += 1
end
end

def display_expression(exp, binding)
stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
end

def frame_set_pos(file, line)
if @frames[0]
@frames[0][1] = file
Expand Down Expand Up @@ -559,22 +573,25 @@ def debug_funcname(id)
end

def check_break_points(file, pos, binding, id)
return false if break_points.empty?
MUTEX.lock
file = File.basename(file)
n = 1
for b in break_points
if b[0]
if b[1] == 0 and b[2] == file and b[3] == pos
MUTEX.lock
stdout.printf "breakpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
return true
elsif b[1] == 1 and debug_eval(b[2], binding)
MUTEX.lock
stdout.printf "watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
return true
elsif b[1] == 1
if debug_silent_eval(b[2], binding)
stdout.printf "watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
return true
end
end
end
n += 1
end
MUTEX.unlock
return false
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mkmf.rb
Expand Up @@ -30,7 +30,7 @@
CFLAGS = CONFIG["CFLAGS"]
if RUBY_PLATFORM == "m68k-human"
CFLAGS.gsub!(/-c..-stack=[0-9]+ */, '')
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody/
elsif RUBY_PLATFORM =~ /-nextstep|-rhapsody|-darwin/
CFLAGS.gsub!( /-arch\s\w*/, '' )
end

Expand Down

0 comments on commit 770303d

Please sign in to comment.