Skip to content

Commit

Permalink
* parse.y (primary): rescue and ensure clauses should be allowed
Browse files Browse the repository at this point in the history
  to appear in singleton method body.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Mar 6, 2001
1 parent 4a7d313 commit a36e0c7
Show file tree
Hide file tree
Showing 20 changed files with 177 additions and 320 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
Tue Mar 6 10:50:29 2001 Yukihiro Matsumoto <[email protected]>

* parse.y (primary): rescue and ensure clauses should be allowed
to appear in singleton method body.

Mon Mar 5 17:25:13 2001 Yukihiro Matsumoto <[email protected]>

* eval.c (proc_eq): compare Procs using blocktag equality.

* eval.c (proc_to_s): stringify according to block tag address.

Mon Mar 5 17:19:56 2001 WATANABE Hirofumi <[email protected]>

* win32/win32.c (gettimeofday): use GetLocalTime() instead of ftime()
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ misc/rubydb2x.el
misc/rubydb3x.el
missing/alloca.c
missing/crypt.c
missing/dir.h
missing/dup2.c
missing/file.h
missing/finite.c
Expand Down
1 change: 1 addition & 0 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Hacking Interpreter
* warn for inconsistent local variable usage (lv m and method m at the same time).
* MicroRuby
* Built-in Interactive Ruby.
* trap every method invocation, which can be enabled by e.g. trap_call :method.

Standard Libraries

Expand Down
114 changes: 64 additions & 50 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1457,56 +1457,52 @@ ev_const_get(cref, id)
}
cbase = cbase->nd_next;
}
#if 1
return rb_const_get(ruby_class, id);
#else
return rb_const_get(cref->nd_clss, id);
#endif
}

static VALUE
ev_const_set(cref, id, val)
NODE *cref;
ID id;
VALUE val;
{
NODE *cbase = cref;

while (cbase && cbase->nd_clss != rb_cObject) {
struct RClass *klass = RCLASS(cbase->nd_clss);

if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
st_insert(klass->iv_tbl, id, val);
return val;
}
cbase = cbase->nd_next;
}
rb_const_assign(cbase->nd_clss, id, val);
return val;
}

static VALUE
rb_mod_nesting()
{
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
rb_ary_push(ary, cbase->nd_clss);
cbase = cbase->nd_next;
}
return ary;
}

static VALUE
rb_mod_s_constants()
{
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
rb_mod_const_at(cbase->nd_clss, ary);
cbase = cbase->nd_next;
static VALUE
ev_const_set(cref, id, val)
NODE *cref;
ID id;
VALUE val;
{
NODE *cbase = cref;

while (cbase && cbase->nd_clss != rb_cObject) {
struct RClass *klass = RCLASS(cbase->nd_clss);

if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, 0)) {
st_insert(klass->iv_tbl, id, val);
return val;
}
cbase = cbase->nd_next;
}
rb_const_assign(cbase->nd_clss, id, val);
return val;
}

static VALUE
rb_mod_nesting()
{
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
rb_ary_push(ary, cbase->nd_clss);
cbase = cbase->nd_next;
}
return ary;
}

static VALUE
rb_mod_s_constants()
{
NODE *cbase = RNODE(ruby_frame->cbase);
VALUE ary = rb_ary_new();

while (cbase && cbase->nd_clss != rb_cObject) {
rb_mod_const_at(cbase->nd_clss, ary);
cbase = cbase->nd_next;
}

rb_mod_const_of(ruby_cbase, ary);
Expand Down Expand Up @@ -6362,6 +6358,23 @@ proc_eq(self, other)
return Qfalse;
}

static VALUE
proc_to_s(self, other)
VALUE self, other;
{
struct BLOCK *data;
char *cname = rb_class2name(CLASS_OF(self));
VALUE str;

Data_Get_Struct(self, struct BLOCK, data);
str = rb_str_new(0, strlen(cname)+6+16+1); /* 6:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", cname, data->tag);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(self)) OBJ_TAINT(str);

return str;
}

static VALUE
block_pass(self, node)
VALUE self;
Expand Down Expand Up @@ -6780,6 +6793,7 @@ Init_Proc()
rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_method(rb_cProc, "==", proc_eq, 1);
rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
rb_define_global_function("binding", rb_f_binding, 0);
Expand Down Expand Up @@ -7181,15 +7195,15 @@ void
rb_thread_fd_close(fd)
int fd;
{
rb_thread_t th, curr = curr_thread;
rb_thread_t th;

FOREACH_THREAD_FROM(curr, th) {
FOREACH_THREAD(th) {
if ((th->wait_for & WAIT_FD) && fd == th->fd) {
VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
rb_thread_raise(1, &exc, th);
}
}
END_FOREACH_FROM(curr, th);
END_FOREACH(th);
}

static void
Expand Down
65 changes: 0 additions & 65 deletions missing/dir.h

This file was deleted.

2 changes: 2 additions & 0 deletions missing/finite.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* public domain rewrite of finite(3) */

int
finite(n)
double n;
Expand Down
2 changes: 2 additions & 0 deletions missing/isinf.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* public domain rewrite of isinf(3) */

#ifdef __osf__

#define _IEEE 1
Expand Down
2 changes: 2 additions & 0 deletions missing/isnan.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* public domain rewrite of isnan(3) */

#ifdef _MSC_VER

#include <float.h>
Expand Down
5 changes: 1 addition & 4 deletions missing/memcmp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/*
* memcmp --- compare memories.
*
*/
/* public domain rewrite of memcmp(3) */

int
memcmp(s1,s2,len)
Expand Down
32 changes: 14 additions & 18 deletions missing/memmove.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
/*
* memmove --- move memories.
*
* We supply this routine for those systems that aren't standard yet.
*/
/* public domain rewrite of memcmp(3) */

char *
memmove (dst, src, n)
char *dst, *src;
int n;
char *dst, *src;
int n;
{
char *ret = dst;
char *ret = dst;

if (src < dst) {
src += n;
dst += n;
while (n--)
*--dst = *--src;
}
else if (dst < src)
while (n--)
*dst++ = *src++;
return ret;
if (src < dst) {
src += n;
dst += n;
while (n--)
*--dst = *--src;
}
else if (dst < src)
while (n--)
*dst++ = *src++;
return ret;
}
2 changes: 2 additions & 0 deletions missing/os2.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* os/2 compatibility functions -- follows Ruby's lisence */

#include "ruby.h"
#include <stdio.h>
#include <stdlib.h>
Expand Down
6 changes: 5 additions & 1 deletion missing/strcasecmp.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* public domain rewrite of strcasecmp(3) */

#include <ctype.h>

int
strcasecmp(p1, p2)
char *p1, *p2;
{
for ( ; *p1 && *p2; p1++, p2++) {
while (*p1 && *p2) {
if (toupper(*p1) != toupper(*p2))
return toupper(*p1) - toupper(*p2);
p1++;
p2++;
}
return strlen(p1) - strlen(p2);
}
Loading

0 comments on commit a36e0c7

Please sign in to comment.