Project

General

Profile

Feature #6972 » patch.diff

Glass_saga (Masaki Matsushita), 09/03/2012 11:24 PM

View differences:

compile.c
1872 1872
		switch (mid) {
1873 1873
		  case idLength: SP_INSN(length); break;
1874 1874
		  case idSize:	 SP_INSN(size);	  break;
1875
		  case idEmpty:  SP_INSN(empty);  break;
1875 1876
		  case idSucc:	 SP_INSN(succ);	  break;
1876 1877
		  case idNot:	 SP_INSN(not);	  break;
1877 1878
		}
id.c
41 41
    REGISTER_SYMID(idEach, "each");
42 42
    REGISTER_SYMID(idLength, "length");
43 43
    REGISTER_SYMID(idSize, "size");
44
    REGISTER_SYMID(idEmpty, "empty?");
44 45
    REGISTER_SYMID(idLambda, "lambda");
45 46
    REGISTER_SYMID(idIntern, "intern");
46 47
    REGISTER_SYMID(idGets, "gets");
insns.def
1991 1991

  
1992 1992
/**
1993 1993
  @c optimize
1994
  @e optimized empty?
1995
  @j 最適化された recv.empty?()。
1996
 */
1997
DEFINE_INSN
1998
opt_empty
1999
(IC ic)
2000
(VALUE recv)
2001
(VALUE val)
2002
{
2003
    if (!SPECIAL_CONST_P(recv)) {
2004
	if (HEAP_CLASS_OF(recv) == rb_cString &&
2005
	    BASIC_OP_UNREDEFINED_P(BOP_EMPTY, STRING_REDEFINED_OP_FLAG)) {
2006
	    if (RSTRING_LEN(recv) == 0) val = Qtrue;
2007
	    else val = Qfalse;
2008
	}
2009
	else if (HEAP_CLASS_OF(recv) == rb_cArray &&
2010
		 BASIC_OP_UNREDEFINED_P(BOP_EMPTY, ARRAY_REDEFINED_OP_FLAG)) {
2011
	    if (RARRAY_LEN(recv) == 0) val = Qtrue;
2012
	    else val = Qfalse;
2013
	}
2014
	else if (HEAP_CLASS_OF(recv) == rb_cHash &&
2015
		 BASIC_OP_UNREDEFINED_P(BOP_EMPTY, HASH_REDEFINED_OP_FLAG)) {
2016
	    if (RHASH_EMPTY_P(recv)) val = Qtrue;
2017
	    else val = Qfalse;
2018
	}
2019
	else {
2020
	    goto INSN_LABEL(normal_dispatch);
2021
	}
2022
    }
2023
    else {
2024
      INSN_LABEL(normal_dispatch):
2025
	PUSH(recv);
2026
	CALL_SIMPLE_METHOD(0, idEmpty, recv);
2027
    }
2028
}
2029

  
2030
/**
2031
  @c optimize
1994 2032
  @e optimized succ
1995 2033
  @j 最適化された recv.succ()。
1996 2034
 */
template/id.h.tmpl
20 20
  MethodMissing
21 21
  Length
22 22
  Size
23
  Empty
23 24
  Gets
24 25
  Succ
25 26
  Each
vm_insnhelper.h
49 49
  BOP_ASET,
50 50
  BOP_LENGTH,
51 51
  BOP_SIZE,
52
  BOP_EMPTY,
52 53
  BOP_SUCC,
53 54
  BOP_GT,
54 55
  BOP_GE,