Skip to content

Commit

Permalink
2000-02-18
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 18, 2000
1 parent f0886df commit 3d6fde3
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 48 deletions.
21 changes: 19 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Fri Feb 18 00:27:34 2000 Yukihiro Matsumoto <[email protected]>

* variable.c (rb_shared_variable_declare): shared variable (aka
class/module variable) introduced. prefix `@@'. experimental.

* class.c (rb_scan_args): new format char '&'.

Thu Feb 17 19:09:05 2000 Katsuyuki Komatsu <[email protected]>

* win32/win32.c (mypopen): don't close handle if it is not assigned.
* win32/win32.c (my_open_osfhandle): support O_NOINHERIT flag.
* win32/win32.c (win32_getcwd): rename getcwd to win32_getcwd
in order to avoid using the C/C++ runtime DLL's getcwd.
Use CharNext() to process directory name.
* win32/win32.h: map getcwd to win32_getcwd.

Wed Feb 16 00:32:49 2000 Yukihiro Matsumoto <[email protected]>

* eval.c (method_arity): nd_rest is -1 for no rest argument.
Expand All @@ -10,13 +26,14 @@ Tue Feb 15 01:47:00 2000 Yukihiro Matsumoto <[email protected]>

Mon Feb 14 13:59:01 2000 Yukihiro Matsumoto <[email protected]>

* parse.y (yylex): yylex yields wrong token for `:foo=~expr'.
* parse.y (yylex): yylex yields wrong tokens for `:foo=~expr'.

* ruby.c (load_file): exit if reading file is empty.

Mon Feb 14 03:34:52 2000 Yukihiro Matsumoto <[email protected]>

* parse.y (yylex): `foo.bar=' should be <foo><.><bar><=>.
* parse.y (yylex): `foo.bar=1' should be <foo><.><bar><=><1>,
not <foo><.><bar=><1>.

* eval.c (rb_thread_restore_context): process according to
RESTORE_* is moved after longjmp().
Expand Down
8 changes: 5 additions & 3 deletions ToDo
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Language Spec.
* class Foo::Bar<Baz .. end, module Boo::Bar .. end
* def Foo::Bar::baz() .. end ??
* I18N (or M17N) script/string/regexp
* Fixnum 0 as false ????

Hacking Interpreter

Expand Down Expand Up @@ -53,9 +54,8 @@ Standard Libraries
ScriptError<Exception, not StandardError.
- String's bang methods return string always
- Thread::start gives arguments, not a thread object to the block
- regexp: (?>..)
* regexp: \G
* Struct::new([name,]member,...) ??
- regexp: (?>..), \G
- Struct::new([name,]member,...)
* String#scanf(?)
* Object#fmt(?)
* Integer#{bin,oct,hex,heX}
Expand All @@ -65,12 +65,14 @@ Standard Libraries
* Stream or Port, abstract superclass of IO ?
* String#{pred,prev}, String#downto
* optional stepsize argument for succ()
* performance tune for String's non-bang methods.

Extension Libraries

- FastCGI ruby
* ptk.rb pTk wrapper that is compatible to tk.rb
* Berkeley DB extension
* BitVector

Ruby Libraries

Expand Down
31 changes: 19 additions & 12 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -598,19 +598,13 @@ rb_scan_args(argc, argv, fmt, va_alist)
va_dcl
#endif
{
int n, i;
int n, i = 0;
const char *p = fmt;
VALUE *var;
va_list vargs;

va_init_list(vargs, fmt);

if (*p == '*') {
var = va_arg(vargs, VALUE*);
*var = rb_ary_new4(argc, argv);
return argc;
}

if (ISDIGIT(*p)) {
n = *p - '0';
if (n > argc)
Expand Down Expand Up @@ -643,21 +637,34 @@ rb_scan_args(argc, argv, fmt, va_alist)
var = va_arg(vargs, VALUE*);
if (argc > i) {
if (var) *var = rb_ary_new4(argc-i, argv+i);
i = argc;
}
else {
if (var) *var = rb_ary_new();
}
p++;
}
else if (*p == '\0') {
if (argc > i) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);

if (*p == '&') {
var = va_arg(vargs, VALUE*);
if (rb_iterator_p()) {
*var = rb_f_lambda();
}
else {
*var = Qnil;
}
p++;
}
else {
va_end(vargs);

if (*p != '\0') {
goto error;
}

va_end(vargs);
if (argc > i) {
rb_raise(rb_eArgError, "wrong # of arguments(%d for %d)", argc, i);
}

return argc;

error:
Expand Down
5 changes: 3 additions & 2 deletions config_h.dj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
#define FILE_COUNT _cnt
#define DLEXT ".o"
#define RUBY_LIB "/usr/local/lib/ruby/1.5"
#define RUBY_SITE_LIB "/usr/local/lib/ruby/1.5/site_ruby"
#define RUBY_SITE_LIB "/usr/local/lib/ruby/site_ruby"
#define RUBY_SITE_LIB2 "/usr/local/lib/ruby/site_ruby/1.5"
#define RUBY_PLATFORM "i386-djgpp"
#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.5/i386-djgpp"
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/1.5/site_ruby/i386-djgpp"
#define RUBY_SITE_ARCHLIB "/usr/local/lib/ruby/site_ruby/1.5/i386-djgpp"
31 changes: 29 additions & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,8 @@ superclass(self, node)
return val;
}

#define ruby_cbase (((NODE*)ruby_frame->cbase)->nd_clss)

static VALUE
ev_const_defined(cref, id)
NODE *cref;
Expand Down Expand Up @@ -1400,7 +1402,7 @@ rb_mod_s_constants()
cbase = cbase->nd_next;
}

rb_mod_const_of(((NODE*)ruby_frame->cbase)->nd_clss, ary);
rb_mod_const_of(ruby_cbase, ary);
return ary;
}

Expand Down Expand Up @@ -2510,6 +2512,22 @@ rb_eval(self, node)
rb_const_set(ruby_class, node->nd_vid, result);
break;

case NODE_SHASGN:
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class/module to define shared variable");
}
result = rb_eval(self, node->nd_value);
rb_shared_variable_set(ruby_cbase, node->nd_vid, result);
break;

case NODE_SHDECL:
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class/module to define shared variable");
}
result = rb_eval(self, node->nd_value);
rb_shared_variable_declare(ruby_class, node->nd_vid, result);
break;

case NODE_LVAR:
if (ruby_scope->local_vars == 0) {
rb_bug("unexpected local variable");
Expand All @@ -2533,6 +2551,10 @@ rb_eval(self, node)
result = ev_const_get((NODE*)ruby_frame->cbase, node->nd_vid);
break;

case NODE_SHVAR:
result = rb_shared_variable_get(ruby_cbase, node->nd_vid);
break;

case NODE_BLOCK_ARG:
if (ruby_scope->local_vars == 0)
rb_bug("unexpected block argument");
Expand Down Expand Up @@ -3486,6 +3508,11 @@ assign(self, lhs, val, check)
rb_const_set(ruby_class, lhs->nd_vid, val);
break;

case NODE_SHDECL:
case NODE_SHASGN:
rb_shared_variable_set(ruby_cbase, lhs->nd_vid, val);
break;

case NODE_MASGN:
massign(self, lhs, val, check);
break;
Expand Down Expand Up @@ -4433,7 +4460,7 @@ eval(self, src, scope, file, line)
}
}
PUSH_CLASS();
ruby_class = ((NODE*)ruby_frame->cbase)->nd_clss;
ruby_class = ruby_cbase;

ruby_in_eval++;
if (TYPE(ruby_class) == T_ICLASS) {
Expand Down
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,6 @@ Init_IO()
rb_file_const("BINARY", INT2FIX(O_BINARY));
#endif
#ifdef O_SYNC
rb_file_const("BINARY", INT2FIX(O_SYNC));
rb_file_const("SYNC", INT2FIX(O_SYNC));
#endif
}
11 changes: 5 additions & 6 deletions missing/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
# define L_XTND 2 /* seek from end. */
#endif

# ifndef R_OK
# define R_OK 4 /* test whether readable. */
# define W_OK 2 /* test whether writable. */
# define X_OK 1 /* test whether execubale. */
# define F_OK 0 /* test whether exist. */
# endif
#ifndef R_OK
# define R_OK 4 /* test whether readable. */
# define W_OK 2 /* test whether writable. */
# define X_OK 1 /* test whether execubale. */
# define F_OK 0 /* test whether exist. */
#endif

#endif
6 changes: 6 additions & 0 deletions node.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ enum node_type {
NODE_IASGN,
NODE_CASGN,
NODE_CDECL,
NODE_SHASGN,
NODE_SHDECL,
NODE_OP_ASGN1,
NODE_OP_ASGN2,
NODE_OP_ASGN_AND,
Expand All @@ -69,6 +71,7 @@ enum node_type {
NODE_GVAR,
NODE_IVAR,
NODE_CVAR,
NODE_SHVAR,
NODE_NTH_REF,
NODE_BACK_REF,
NODE_MATCH,
Expand Down Expand Up @@ -264,6 +267,8 @@ typedef struct RNode {
#define NEW_IASGN(v,val) rb_node_newnode(NODE_IASGN,v,val,0)
#define NEW_CASGN(v,val) rb_node_newnode(NODE_CASGN,v,val,0)
#define NEW_CDECL(v,val) rb_node_newnode(NODE_CDECL,v,val,0)
#define NEW_SHASGN(v,val) rb_node_newnode(NODE_SHASGN,v,val,0)
#define NEW_SHDECL(v,val) rb_node_newnode(NODE_SHDECL,v,val,0)
#define NEW_OP_ASGN1(p,id,a) rb_node_newnode(NODE_OP_ASGN1,p,id,a)
#define NEW_OP_ASGN2(r,i,o,val) rb_node_newnode(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o))
#define NEW_OP_ASGN22(i,o) rb_node_newnode(NODE_OP_ASGN2,i,o,rb_id_attrset(i))
Expand All @@ -274,6 +279,7 @@ typedef struct RNode {
#define NEW_DVAR(v) rb_node_newnode(NODE_DVAR,v,0,0);
#define NEW_IVAR(v) rb_node_newnode(NODE_IVAR,v,0,0)
#define NEW_CVAR(v) rb_node_newnode(NODE_CVAR,v,0,0)
#define NEW_SHVAR(v) rb_node_newnode(NODE_SHVAR,v,0,0)
#define NEW_NTH_REF(n) rb_node_newnode(NODE_NTH_REF,0,n,local_cnt('~'))
#define NEW_BACK_REF(n) rb_node_newnode(NODE_BACK_REF,0,n,local_cnt('~'))
#define NEW_MATCH(c) rb_node_newnode(NODE_MATCH,c,0,0)
Expand Down
Loading

0 comments on commit 3d6fde3

Please sign in to comment.