rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
meta
stringlengths
141
403
if (start <= end)
if ( start <= end)
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String prop; Object nextProp = null; Accessor acc = null; if (names[start] instanceof String) { prop = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; prop = pm.getName(); acc = (Accessor) _directAccessors.get(prop); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), prop)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextProp = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { prop = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(prop); if (acc != null) { try { nextProp = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(prop); if ((acc != null) && ((start + 1) <= end)) { try { nextProp = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextProp = acc.get(instance, prop); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + prop) || isMethodRestricted(instance.getClass(), "set" + prop)) throw new PropertyException.RestrictedPropertyException( prop, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( prop, fillInName(names, start), instance.getClass().getName()); } if (start <= end) { try { return _cache.getOperator(nextProp) .getProperty(context, nextProp, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextProp; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7a63005219984b389eda2de9922300e67a035451/PropertyOperatorCache.java/clean/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java
return _cache.getOperator(nextProp) .getProperty(context, nextProp, names, start, end);
return _cache.getOperator(nextPropValue) .getProperty(context, nextPropValue, names, start, end);
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String prop; Object nextProp = null; Accessor acc = null; if (names[start] instanceof String) { prop = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; prop = pm.getName(); acc = (Accessor) _directAccessors.get(prop); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), prop)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextProp = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { prop = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(prop); if (acc != null) { try { nextProp = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(prop); if ((acc != null) && ((start + 1) <= end)) { try { nextProp = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextProp = acc.get(instance, prop); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + prop) || isMethodRestricted(instance.getClass(), "set" + prop)) throw new PropertyException.RestrictedPropertyException( prop, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( prop, fillInName(names, start), instance.getClass().getName()); } if (start <= end) { try { return _cache.getOperator(nextProp) .getProperty(context, nextProp, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextProp; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7a63005219984b389eda2de9922300e67a035451/PropertyOperatorCache.java/clean/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java
return nextProp;
return nextPropValue;
public Object getProperty (final Context context, final Object instance, final Object[] names, int start, int end) throws PropertyException { String prop; Object nextProp = null; Accessor acc = null; if (names[start] instanceof String) { prop = (String) names[start]; } else if (names[start] instanceof PropertyMethod) { PropertyMethod pm = (PropertyMethod) names[start]; prop = pm.getName(); acc = (Accessor) _directAccessors.get(prop); Object[] args = pm.getArguments(context); if (acc == null) { if (isMethodRestricted(instance.getClass(), prop)) throw new PropertyException.RestrictedMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } try { nextProp = acc.get(instance, args); start++; } catch (NoSuchMethodException e) { throw new PropertyException.NoSuchMethodException( pm.toString(), fillInName(names, start), instance.getClass().getName()); } } else { prop = names[start].toString(); } // unary? if (acc == null) { acc = (Accessor) _unaryAccessors.get(prop); if (acc != null) { try { nextProp = acc.get(instance); start++; } catch (NoSuchMethodException e) { acc = null; } } } // binary? if (acc == null) { acc = (Accessor) _binaryAccessors.get(prop); if ((acc != null) && ((start + 1) <= end)) { try { nextProp = acc.get(instance, (String) names[start + 1]); start += 2; } catch (NoSuchMethodException e) { acc = null; } catch (ClassCastException e) { // names[start + 1] was not a String, just move on // this catch is more efficient than using instanceof // since 90% of the time it really will be a string acc = null; } } else { acc = null; } } // hash? if (acc == null) { acc = _hashAccessor; try { if (acc != null) { nextProp = acc.get(instance, prop); start++; } } catch (NoSuchMethodException e) { acc = null; } } if (acc == null) { // user tried to access a property of a property that doesn't exist // ex: $TestObject.FirstName.NotThere // check if object is restricted if (isMethodRestricted(instance.getClass(), "get" + prop) || isMethodRestricted(instance.getClass(), "set" + prop)) throw new PropertyException.RestrictedPropertyException( prop, fillInName(names, start), instance.getClass().getName()); throw new PropertyException.NoSuchPropertyException( prop, fillInName(names, start), instance.getClass().getName()); } if (start <= end) { try { return _cache.getOperator(nextProp) .getProperty(context, nextProp, names, start, end); } catch (NullPointerException e) { // $Foo.getNull().SomeProperty is what makes this happen throw new PropertyException("$" + fillInName(names, start) + " is null. Cannot access ." + names[end]); } } else { return nextProp; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7a63005219984b389eda2de9922300e67a035451/PropertyOperatorCache.java/clean/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java
int parentPos = names.length - 1; int binPos = parentPos - 1;
int binPos = names.length - 2;
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int parentPos = names.length - 1; int binPos = parentPos - 1; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7a63005219984b389eda2de9922300e67a035451/PropertyOperatorCache.java/clean/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java
public boolean setProperty (Context context, Object instance, Object[] names, Object value, int pos) throws PropertyException, NoSuchMethodException { // names[pos] is what we could set from here int parentPos = names.length - 1; int binPos = parentPos - 1; // if we're not yet at the binary-settable parent, go there if (pos < binPos) { Object grandparent = getProperty(context, instance, names, pos, binPos - 1); PropertyOperator po = _cache.getOperator(grandparent); return po.setProperty(context, grandparent, names, value, binPos); } // if we're at the binary-settable parent, try direct first if (pos == binPos) { // try direct -- move to direct parent and try from there Object parent = null; try { parent = getProperty(context, instance, names, pos, pos); if (parent != null) { PropertyOperator po = _cache.getOperator(parent); if (po.setProperty(context, parent, names, value, pos + 1)) { return true; } } } catch (NoSuchMethodException e) { // oh well, keep trying: XXX this makes binOp expensive } // if direct failed, try binary Accessor binOp = (Accessor) _binaryAccessors.get(names[pos]); if (binOp != null) { try { return binOp.set(instance, (String) names[pos + 1], value); } catch (ClassCastException e) { // names[pos+1] was not a string, just move on return false; } catch (NoSuchMethodException e) { return false; } } return false; } // we're the direct parent, use unaryOp or hash method Accessor unaryOp = (Accessor) _unaryAccessors.get(names[pos]); try { if ((unaryOp != null) && unaryOp.set(instance, value)) { return true; } if (_hashAccessor != null) { return _hashAccessor.set(instance, (String) names[pos], value); } } catch (NoSuchMethodException e) { // fall through } catch (ClassCastException e) { // names[pos] was not a string, fall through } return false; }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/7a63005219984b389eda2de9922300e67a035451/PropertyOperatorCache.java/clean/webmacro/src/org/webmacro/engine/PropertyOperatorCache.java
window.setVisible(false);
window.dispose();
public void mouseMoved(MouseEvent e) { if(e != null){ mouseEvent = e; } if(!canShowPopup){ return; } int loc = list.locationToIndex(e.getPoint()); Point point = list.indexToLocation(loc); ContactItem item = (ContactItem)model.getElementAt(loc); if (item == null || item.getFullJID() == null) { return; } if (activeItem != null && activeItem == item) { return; } activeItem = item; window.setVisible(false); window = new JWindow(); window.setFocusableWindowState(false); ContactInfo info = new ContactInfo(item); window.getContentPane().add(info); window.pack(); info.setBorder(BorderFactory.createEtchedBorder()); Point mainWindowLocation = SparkManager.getMainWindow().getLocationOnScreen(); Point listLocation = list.getLocationOnScreen(); int x = (int)mainWindowLocation.getX() + SparkManager.getMainWindow().getWidth(); final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if ((int)screenSize.getWidth() - 250 >= x) { window.setLocation(x, (int)listLocation.getY() + (int)point.getY()); window.setVisible(true); } else { window.setLocation((int)mainWindowLocation.getX() - 250, (int)listLocation.getY() + (int)point.getY()); window.setVisible(true); } }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/30107726addd789f577a8badda45d46e52d4851f/ContactGroup.java/clean/src/java/org/jivesoftware/spark/ui/ContactGroup.java
threadError = ruby.defineClass("ThreadError", standardError);
public void initDefaultExceptionClasses() { RubyClass exceptionClass = ruby.getClasses().getExceptionClass(); systemExit = ruby.defineClass("SystemExit", exceptionClass); fatal = ruby.defineClass("Fatal", exceptionClass); interrupt = ruby.defineClass("Interrupt", exceptionClass); signalException = ruby.defineClass("SignalException", exceptionClass); standardError = ruby.defineClass("StandardError", exceptionClass); typeError = ruby.defineClass("TypeError", standardError); argumentError = ruby.defineClass("ArgumentError", standardError); indexError = ruby.defineClass("IndexError", standardError); rangeError = ruby.defineClass("RangeError", standardError); scriptError = ruby.defineClass("ScriptError", exceptionClass); syntaxError = ruby.defineClass("SyntaxError", scriptError); nameError = ruby.defineClass("NameError", scriptError); loadError = ruby.defineClass("LoadError", scriptError); notImplementedError = ruby.defineClass("NotImplementedError", scriptError); runtimeError = ruby.defineClass("RuntimeError", standardError); securityError = ruby.defineClass("SecurityError", standardError); noMemError = ruby.defineClass("NoMemError", exceptionClass); regexpError = ruby.defineClass("RegexpError", standardError); ioError = ruby.defineClass("IOError", standardError); eofError = ruby.defineClass("EOFError", ioError); systemCallError = ruby.defineClass("SystemCallError", standardError); localJumpError = ruby.defineClass("LocalJumpError", standardError); errnoModule = ruby.defineModule("Errno"); _ENOTEMPTY = setSysErr(ENOTEMPTY, "ENOTEMPTY"); _ERANGE = setSysErr(ERANGE, "ERANGE"); _ESPIPE = setSysErr(ESPIPE, "ESPIPE"); _ENFILE = setSysErr(ENFILE, "ENFILE"); _EXDEV = setSysErr(EXDEV, "EXDEV"); _ENOMEM = setSysErr(ENOMEM, "ENOMEM"); _E2BIG = setSysErr(E2BIG, "E2BIG"); _ENOENT = setSysErr(ENOENT, "ENOENT"); _ENOSYS = setSysErr(ENOSYS, "ENOSYS"); _EDOM = setSysErr(EDOM, "EDOM"); _ENOSPC = setSysErr(ENOSPC, "ENOSPC"); _EINVAL = setSysErr(EINVAL, "EINVAL"); _EEXIST = setSysErr(EEXIST, "EEXIST"); _EAGAIN = setSysErr(EAGAIN, "EAGAIN"); _ENXIO = setSysErr(ENXIO, "ENXIO"); _EILSEQ = setSysErr(EILSEQ, "EILSEQ"); _ENOLCK = setSysErr(ENOLCK, "ENOLCK"); _EPIPE = setSysErr(EPIPE, "EPIPE"); _EFBIG = setSysErr(EFBIG, "EFBIG"); _EISDIR = setSysErr(EISDIR, "EISDIR"); _EBUSY = setSysErr(EBUSY, "EBUSY"); _ECHILD = setSysErr(ECHILD, "ECHILD"); _EIO = setSysErr(EIO, "EIO"); _EPERM = setSysErr(EPERM, "EPERM"); _EDEADLOCK = setSysErr(EDEADLOCK, "EDEADLOCK"); _ENAMETOOLONG = setSysErr(ENAMETOOLONG, "ENAMETOOLONG"); _EMLINK = setSysErr(EMLINK, "EMLINK"); _ENOTTY = setSysErr(ENOTTY, "ENOTTY"); _ENOTDIR = setSysErr(ENOTDIR, "ENOTDIR"); _EFAULT = setSysErr(EFAULT, "EFAULT"); _EBADF = setSysErr(EBADF, "EBADF"); _EINTR = setSysErr(EINTR, "EINTR"); _EWOULDBLOCK = setSysErr(EWOULDBLOCK, "EWOULDBLOCK"); _EDEADLK = setSysErr(EDEADLK, "EDEADLK"); _EROFS = setSysErr(EROFS, "EROFS"); _EMFILE = setSysErr(EMFILE, "EMFILE"); _ENODEV = setSysErr(ENODEV, "ENODEV"); _EACCES = setSysErr(EACCES, "EACCES"); _ENOEXEC = setSysErr(ENOEXEC, "ENOEXEC"); _ESRCH = setSysErr(ESRCH, "ESRCH"); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/97a2e6c00e86a04f4922893e5ab540f1c1636188/RubyExceptions.java/buggy/org/jruby/runtime/RubyExceptions.java
toolBar = new ToolBar(control, registry, maxT, defaultT, maxZ, defaultZ);
initBars(registry, maxT, defaultT, maxZ, defaultZ);
ViewerUIF(ViewerCtrl control, Registry registry, PixelsDimensions pxsDims, int defaultT, int defaultZ) { super("", registry.getTaskBar()); active = false; this.control = control; im = IconManager.getInstance(registry); int maxT = pxsDims.sizeT-1; int maxZ = pxsDims.sizeZ-1; setJMenuBar(createMenuBar(maxZ, maxT)); toolBar = new ToolBar(control, registry, maxT, defaultT, maxZ, defaultZ); initSliders(maxT, defaultT, maxZ, defaultZ); buildGUI(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ff5419c429a530b7d53a76f42ded518c0b34b986/ViewerUIF.java/clean/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java
container.add(bottomBar, BorderLayout.SOUTH);
private void buildGUI() { Container container = getContentPane(); layer = new JLayeredPane(); drawingCanvas = new DrawingCanvas(); canvas = new ImageCanvas(this, control); layer.add(canvas, new Integer(Viewer.IMAGE_LEVEL)); scrollPane = new JScrollPane(layer); container.add(toolBar, BorderLayout.NORTH); container.add(buildMain(), BorderLayout.WEST); container.add(scrollPane, BorderLayout.CENTER); //Configure the display buttons in the TaskBar. configureDisplayButtons(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ff5419c429a530b7d53a76f42ded518c0b34b986/ViewerUIF.java/clean/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java
void setDefaultZT(int t, int z, int sizeT, int sizeZ) { ToolBarManager tbm = toolBar.getManager(); tbm.onTChange(t); tbm.onZChange(z); int maxZ = sizeZ-1; int maxT = sizeT-1; tbm.setMaxT(maxT); tbm.setMaxZ(maxZ); toolBar.getZLabel().setText("/"+maxZ); toolBar.getTLabel().setText("/"+maxT); resetSliders(maxT, t, maxZ, z); boolean bT = false, bZ = false; if (maxT != 0) bT = true; if (maxZ != 0) bZ = true; toolBar.getTField().setEditable(bT); toolBar.getZField().setEditable(bZ); toolBar.getViewer3D().setEnabled(bZ); viewer3DItem.setEnabled(bZ); if (bZ && bT) movieItem.setEnabled(true); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ff5419c429a530b7d53a76f42ded518c0b34b986/ViewerUIF.java/clean/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java
void setDefaultZT(int t, int z, int sizeT, int sizeZ) { ToolBarManager tbm = toolBar.getManager(); tbm.onTChange(t); tbm.onZChange(z); int maxZ = sizeZ-1; int maxT = sizeT-1; tbm.setMaxT(maxT); tbm.setMaxZ(maxZ); toolBar.getZLabel().setText("/"+maxZ); toolBar.getTLabel().setText("/"+maxT); resetSliders(maxT, t, maxZ, z); boolean bT = false, bZ = false; if (maxT != 0) bT = true; if (maxZ != 0) bZ = true; toolBar.getTField().setEditable(bT); toolBar.getZField().setEditable(bZ); toolBar.getViewer3D().setEnabled(bZ); viewer3DItem.setEnabled(bZ); if (bZ && bT) movieItem.setEnabled(true); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ff5419c429a530b7d53a76f42ded518c0b34b986/ViewerUIF.java/clean/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java
RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary;
ArrayList ary = new ArrayList(node.nd_alen()); for (; node != null ; node = node.nd_next()) { ary.add(eval(self, node.nd_head())); } return RubyArray.m_newArray(getRuby(), ary);
public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR: while (true) { BLOCK _block = PUSH_BLOCK(node.nd_var(), node.nd_body(), self); try { rubyIter.push(Iter.ITER_PRE); if (node.nd_type() == NODE_ITER) { result = eval(self, node.nd_iter()); } else { // String file = // int line = _block.flags &= ~BLOCK_D_SCOPE; BLOCK tmp_block = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_iter()); END_CALLARGS(tmp_block); // = file; // = line; result = recv.getRubyClass().call(recv, ruby.intern("each"), null, 0); } rubyIter.pop(); break; } catch (RetryException rExcptn) { POP_BLOCK(_block); } catch (ReturnException rExcptn) { POP_BLOCK(_block); result = rExcptn.getReturnValue(); break; } catch (BreakException bExcptn) { POP_BLOCK(_block); result = ruby.getNil(); break; } } return result; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); if (node.nd_stts().nd_type() == NODE_RESTARGS && ((RubyArray)result).length() == 1) { result = ((RubyArray)result).entry(0); } } else { result = ruby.getNil(); } return yield0(result, null, null, false); case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } rubyIter.push(rubyIter.getIter() != Iter.ITER_NOT ? Iter.ITER_PRE : Iter.ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); rubyIter.pop(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isInstanceVarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setInstanceVar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().declareClassVar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareClassVar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getClassVarSingleton().setClassVar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getInstanceVar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getClassVar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getClassVar((RubyId)node.nd_vid()); } return ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: if (ruby.rubyScope.getLocalVars() == null) { throw new RuntimeException("BUG: unexpected block argument"); } if (isBlockGiven()) { result = getRuby().getNil(); // Create Proc object ruby.rubyScope.setLocalVars(node.nd_cnt(), result); return result; } else { return getRuby().getNil(); } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET: if (rubyFrame.getArgs().size() != 1) { throw new RubyArgumentException("wrong # of arguments(" + rubyFrame.getArgs().size() + "for 1)"); } return self.setInstanceVar((RubyId)node.nd_vid(), (RubyObject)rubyFrame.getArgs().get(0)); case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getInstanceVar("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol());
public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR: while (true) { BLOCK _block = PUSH_BLOCK(node.nd_var(), node.nd_body(), self); try { rubyIter.push(Iter.ITER_PRE); if (node.nd_type() == NODE_ITER) { result = eval(self, node.nd_iter()); } else { // String file = // int line = _block.flags &= ~BLOCK_D_SCOPE; BLOCK tmp_block = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_iter()); END_CALLARGS(tmp_block); // = file; // = line; result = recv.getRubyClass().call(recv, ruby.intern("each"), null, 0); } rubyIter.pop(); break; } catch (RetryException rExcptn) { POP_BLOCK(_block); } catch (ReturnException rExcptn) { POP_BLOCK(_block); result = rExcptn.getReturnValue(); break; } catch (BreakException bExcptn) { POP_BLOCK(_block); result = ruby.getNil(); break; } } return result; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); if (node.nd_stts().nd_type() == NODE_RESTARGS && ((RubyArray)result).length() == 1) { result = ((RubyArray)result).entry(0); } } else { result = ruby.getNil(); } return yield0(result, null, null, false); case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } rubyIter.push(rubyIter.getIter() != Iter.ITER_NOT ? Iter.ITER_PRE : Iter.ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); rubyIter.pop(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isInstanceVarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setInstanceVar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().declareClassVar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareClassVar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getClassVarSingleton().setClassVar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getInstanceVar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getClassVar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getClassVar((RubyId)node.nd_vid()); } return ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: if (ruby.rubyScope.getLocalVars() == null) { throw new RuntimeException("BUG: unexpected block argument"); } if (isBlockGiven()) { result = getRuby().getNil(); // Create Proc object ruby.rubyScope.setLocalVars(node.nd_cnt(), result); return result; } else { return getRuby().getNil(); } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET: if (rubyFrame.getArgs().size() != 1) { throw new RubyArgumentException("wrong # of arguments(" + rubyFrame.getArgs().size() + "for 1)"); } return self.setInstanceVar((RubyId)node.nd_vid(), (RubyObject)rubyFrame.getArgs().get(0)); case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getInstanceVar("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName());
public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR: while (true) { BLOCK _block = PUSH_BLOCK(node.nd_var(), node.nd_body(), self); try { rubyIter.push(Iter.ITER_PRE); if (node.nd_type() == NODE_ITER) { result = eval(self, node.nd_iter()); } else { // String file = // int line = _block.flags &= ~BLOCK_D_SCOPE; BLOCK tmp_block = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_iter()); END_CALLARGS(tmp_block); // = file; // = line; result = recv.getRubyClass().call(recv, ruby.intern("each"), null, 0); } rubyIter.pop(); break; } catch (RetryException rExcptn) { POP_BLOCK(_block); } catch (ReturnException rExcptn) { POP_BLOCK(_block); result = rExcptn.getReturnValue(); break; } catch (BreakException bExcptn) { POP_BLOCK(_block); result = ruby.getNil(); break; } } return result; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); if (node.nd_stts().nd_type() == NODE_RESTARGS && ((RubyArray)result).length() == 1) { result = ((RubyArray)result).entry(0); } } else { result = ruby.getNil(); } return yield0(result, null, null, false); case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } rubyIter.push(rubyIter.getIter() != Iter.ITER_NOT ? Iter.ITER_PRE : Iter.ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); rubyIter.pop(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isInstanceVarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setInstanceVar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().declareClassVar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareClassVar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getClassVarSingleton().setClassVar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getInstanceVar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getClassVar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getClassVar((RubyId)node.nd_vid()); } return ruby_cbase.getInstanceVar("__attached__").getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getClassVarSingleton().getClassVar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: if (ruby.rubyScope.getLocalVars() == null) { throw new RuntimeException("BUG: unexpected block argument"); } if (isBlockGiven()) { result = getRuby().getNil(); // Create Proc object ruby.rubyScope.setLocalVars(node.nd_cnt(), result); return result; } else { return getRuby().getNil(); } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET: if (rubyFrame.getArgs().size() != 1) { throw new RubyArgumentException("wrong # of arguments(" + rubyFrame.getArgs().size() + "for 1)"); } return self.setInstanceVar((RubyId)node.nd_vid(), (RubyObject)rubyFrame.getArgs().get(0)); case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getInstanceVar("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
while (cbase != null && cbase.nd_next() != null) { RubyObject rubyClass = (RubyObject)cbase.nd_clss(); if (rubyClass.isNil()) {
protected RubyObject getConstant(NODE cref, RubyId id, RubyObject self) { NODE cbase = cref; // while (cbase != null && cbase.nd_next() != null) {// RubyObject rubyClass = (RubyObject)cbase.nd_clss();// if (rubyClass.isNil()) { return self.getRubyClass().getConstant(id);// } else if (rubyClass.getInstanceVariables().get(id) != null) {// return (RubyObject)rubyClass.getInstanceVariables().get(id);// }// cbase = cbase.nd_next();// }// return ((RubyModule)cref.nd_clss()).getConstant(id); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
} else if (rubyClass.getInstanceVariables().get(id) != null) { return (RubyObject)rubyClass.getInstanceVariables().get(id); } cbase = cbase.nd_next(); } return ((RubyModule)cref.nd_clss()).getConstant(id);
protected RubyObject getConstant(NODE cref, RubyId id, RubyObject self) { NODE cbase = cref; // while (cbase != null && cbase.nd_next() != null) {// RubyObject rubyClass = (RubyObject)cbase.nd_clss();// if (rubyClass.isNil()) { return self.getRubyClass().getConstant(id);// } else if (rubyClass.getInstanceVariables().get(id) != null) {// return (RubyObject)rubyClass.getInstanceVariables().get(id);// }// cbase = cbase.nd_next();// }// return ((RubyModule)cref.nd_clss()).getConstant(id); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
if (state != 0) {
/*if (state != 0) {
private RubyClass getSuperClass(RubyObject self, NODE node) { RubyObject obj; int state = 1; // unreachable // PUSH_TAG(PROT_NONE); // if ((state = EXEC_TAG()) == 0 ) { obj = eval(self, node); // } // POP_TAG(); if (state != 0) { switch (node.nd_type()) { case NODE_COLON2: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_mid()).toName() + "'"); case NODE_CONST: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_vid()).toName() + "'"); default: throw new RubyTypeException("undefined superclass"); } // JUMP_TAG(state); } if (!(obj instanceof RubyClass)) { throw new RuntimeException(); // goto superclass_error; } if (((RubyClass)obj).isSingleton()) { throw new RubyTypeException("can't make subclass of virtual class"); } return (RubyClass)obj; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_mid()).toName() + "'");
throw new RubyTypeException("undefined superclass '" + ((RubyId)node.nd_mid()).toName() + "'");
private RubyClass getSuperClass(RubyObject self, NODE node) { RubyObject obj; int state = 1; // unreachable // PUSH_TAG(PROT_NONE); // if ((state = EXEC_TAG()) == 0 ) { obj = eval(self, node); // } // POP_TAG(); if (state != 0) { switch (node.nd_type()) { case NODE_COLON2: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_mid()).toName() + "'"); case NODE_CONST: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_vid()).toName() + "'"); default: throw new RubyTypeException("undefined superclass"); } // JUMP_TAG(state); } if (!(obj instanceof RubyClass)) { throw new RuntimeException(); // goto superclass_error; } if (((RubyClass)obj).isSingleton()) { throw new RubyTypeException("can't make subclass of virtual class"); } return (RubyClass)obj; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_vid()).toName() + "'");
throw new RubyTypeException("undefined superclass '" + ((RubyId)node.nd_vid()).toName() + "'");
private RubyClass getSuperClass(RubyObject self, NODE node) { RubyObject obj; int state = 1; // unreachable // PUSH_TAG(PROT_NONE); // if ((state = EXEC_TAG()) == 0 ) { obj = eval(self, node); // } // POP_TAG(); if (state != 0) { switch (node.nd_type()) { case NODE_COLON2: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_mid()).toName() + "'"); case NODE_CONST: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_vid()).toName() + "'"); default: throw new RubyTypeException("undefined superclass"); } // JUMP_TAG(state); } if (!(obj instanceof RubyClass)) { throw new RuntimeException(); // goto superclass_error; } if (((RubyClass)obj).isSingleton()) { throw new RubyTypeException("can't make subclass of virtual class"); } return (RubyClass)obj; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
}
}*/
private RubyClass getSuperClass(RubyObject self, NODE node) { RubyObject obj; int state = 1; // unreachable // PUSH_TAG(PROT_NONE); // if ((state = EXEC_TAG()) == 0 ) { obj = eval(self, node); // } // POP_TAG(); if (state != 0) { switch (node.nd_type()) { case NODE_COLON2: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_mid()).toName() + "'"); case NODE_CONST: throw new RubyTypeException("undefined superclass `" + ((RubyId)node.nd_vid()).toName() + "'"); default: throw new RubyTypeException("undefined superclass"); } // JUMP_TAG(state); } if (!(obj instanceof RubyClass)) { throw new RuntimeException(); // goto superclass_error; } if (((RubyClass)obj).isSingleton()) { throw new RubyTypeException("can't make subclass of virtual class"); } return (RubyClass)obj; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
Frame frame = rubyFrame; frame.setTmp(rubyFrame); rubyFrame = frame;
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
pushClass();
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
getRuby().rubyScope.push();
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
PUSH_CREF(module);
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
POP_CREF();
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
getRuby().rubyScope.pop(); popClass();
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
rubyFrame = frame.getTmp();
public RubyObject setupModule(RubyModule module, NODE n) { NODE node = n; // String file = ruby_sourcefile; // int line = ruby_sourceline; // TMP_PROTECT; // frame = ruby_frame; // frame.tmp(ruby_frame); // ruby_frame = frame; // PUSH_CLASS(); ruby_class = module; // PUSH_SCOPE(); RubyVarmap.push(ruby); if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); } // PUSH_CREF(module); rubyFrame.setCbase((VALUE)ruby_cref); // PUSH_TAG(PROT_NONE); RubyObject result = null; // if (( state = EXEC_TAG()) == 0 ) { // if (trace_func) { // call_trace_func("class", file, line, ruby_class, // ruby_frame->last_func, ruby_frame->last_class ); // } result = eval(ruby_class, node.nd_next()); // } // POP_TAG(); // POP_CREF(); RubyVarmap.pop(ruby); // POP_SCOPE(); // POP_CLASS(); // ruby_frame = frame.tmp;// if (trace_func) {// call_trace_func("end", file, line, 0, ruby_frame->last_func, ruby_frame->last_class );// } // if (state != 0) { // JUMP_TAG(state); // } return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
pushClass();
public RubyObject yield0(RubyObject value, RubyObject self, RubyModule klass, boolean acheck) { RubyObject result = ruby.getNil(); if (!(isBlockGiven() || isFBlockGiven()) || (ruby_block == null)) { throw new RuntimeException("yield called out of block"); } RubyVarmap.push(ruby); // PUSH_CLASS(); BLOCK block = ruby_block; Frame frame = block.frame; frame.setPrev(rubyFrame); rubyFrame = frame; VALUE old_cref = ruby_cref; ruby_cref = (NODE)rubyFrame.getCbase(); RubyScope oldScope = ruby.rubyScope; ruby.rubyScope = block.scope; ruby_block = block.prev; if ((block.flags & BLOCK_D_SCOPE) != 0) { dynamicVars = new RubyVarmap(null, null, block.dyna_vars); } else { dynamicVars = block.dyna_vars; } ruby_class = (klass != null) ? klass : block.klass; if (klass == null) { self = (RubyObject)block.self; } NODE node = block.body; if (block.var != null) { // try { if (block.var == NODE.ONE) { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() != 0) { throw new RubyArgumentException("wrong # of arguments ("+ ((RubyArray)value).length() + " for 0)"); } } else { if (block.var.nd_type() == NODE_MASGN) { massign(self, block.var, value, acheck); } else { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() == 1) { value = ((RubyArray)value).entry(0); } assign(self, block.var, value, acheck); } } // } catch () { // goto pop_state; // } } else { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() == 1) { value = ((RubyArray)value).entry(0); } } rubyIter.push(block.iter); while (true) { try { if (node == null) { result = ruby.getNil(); } else if (node.nd_type() == NODE_CFUNC || node.nd_type() == NODE_IFUNC) { if (value == null) { value = RubyArray.m_newArray(ruby, 0); } result = ((RubyCallbackMethod)node.nd_cfnc()).execute(value, new RubyObject[] {(RubyObject)node.nd_tval(), self}, ruby); } else { result = eval(self, node); } break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { result = ruby.getNil(); break; } catch (BreakException bExcptn) { break; } catch (ReturnException rExcptn) { break; } } // pop_state: rubyIter.pop(); // POP_CLASS(); RubyVarmap.pop(ruby); ruby_block = block; rubyFrame = rubyFrame.getPrev(); ruby_cref = (NODE)old_cref; // if (ruby_scope->flag & SCOPE_DONT_RECYCLE) // scope_dup(old_scope); ruby.rubyScope = oldScope; /* * if (state) { * if (!block->tag) { * switch (state & TAG_MASK) { * case TAG_BREAK: * case TAG_RETURN: * jump_tag_but_local_jump(state & TAG_MASK); * break; * } * } * JUMP_TAG(state); * } */ return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
popClass();
public RubyObject yield0(RubyObject value, RubyObject self, RubyModule klass, boolean acheck) { RubyObject result = ruby.getNil(); if (!(isBlockGiven() || isFBlockGiven()) || (ruby_block == null)) { throw new RuntimeException("yield called out of block"); } RubyVarmap.push(ruby); // PUSH_CLASS(); BLOCK block = ruby_block; Frame frame = block.frame; frame.setPrev(rubyFrame); rubyFrame = frame; VALUE old_cref = ruby_cref; ruby_cref = (NODE)rubyFrame.getCbase(); RubyScope oldScope = ruby.rubyScope; ruby.rubyScope = block.scope; ruby_block = block.prev; if ((block.flags & BLOCK_D_SCOPE) != 0) { dynamicVars = new RubyVarmap(null, null, block.dyna_vars); } else { dynamicVars = block.dyna_vars; } ruby_class = (klass != null) ? klass : block.klass; if (klass == null) { self = (RubyObject)block.self; } NODE node = block.body; if (block.var != null) { // try { if (block.var == NODE.ONE) { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() != 0) { throw new RubyArgumentException("wrong # of arguments ("+ ((RubyArray)value).length() + " for 0)"); } } else { if (block.var.nd_type() == NODE_MASGN) { massign(self, block.var, value, acheck); } else { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() == 1) { value = ((RubyArray)value).entry(0); } assign(self, block.var, value, acheck); } } // } catch () { // goto pop_state; // } } else { if (acheck && value != null && value instanceof RubyArray && ((RubyArray)value).length() == 1) { value = ((RubyArray)value).entry(0); } } rubyIter.push(block.iter); while (true) { try { if (node == null) { result = ruby.getNil(); } else if (node.nd_type() == NODE_CFUNC || node.nd_type() == NODE_IFUNC) { if (value == null) { value = RubyArray.m_newArray(ruby, 0); } result = ((RubyCallbackMethod)node.nd_cfnc()).execute(value, new RubyObject[] {(RubyObject)node.nd_tval(), self}, ruby); } else { result = eval(self, node); } break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { result = ruby.getNil(); break; } catch (BreakException bExcptn) { break; } catch (ReturnException rExcptn) { break; } } // pop_state: rubyIter.pop(); // POP_CLASS(); RubyVarmap.pop(ruby); ruby_block = block; rubyFrame = rubyFrame.getPrev(); ruby_cref = (NODE)old_cref; // if (ruby_scope->flag & SCOPE_DONT_RECYCLE) // scope_dup(old_scope); ruby.rubyScope = oldScope; /* * if (state) { * if (!block->tag) { * switch (state & TAG_MASK) { * case TAG_BREAK: * case TAG_RETURN: * jump_tag_but_local_jump(state & TAG_MASK); * break; * } * } * JUMP_TAG(state); * } */ return result; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/12847c6fd28fea4e223d132ced46eb1b4cb9de9a/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java
IRubyObject argumentArray = JavaUtil.convertJavaToRuby(runtime, commandline.scriptArguments);
IRubyObject argumentArray = RubyArray.newArray(runtime, JavaUtil.convertJavaArrayToRuby(runtime, commandline.scriptArguments));
private static void initializeRuntime(Ruby runtime, String filename) { IRubyObject argumentArray = JavaUtil.convertJavaToRuby(runtime, commandline.scriptArguments); runtime.setVerbose(commandline.verbose); defineGlobal(runtime, "$VERBOSE", commandline.verbose); runtime.defineGlobalConstant("ARGV", argumentArray); defineGlobal(runtime, "$-p", commandline.assumePrinting); defineGlobal(runtime, "$-n", commandline.assumeLoop); defineGlobal(runtime, "$-a", commandline.sDoSplit); defineGlobal(runtime, "$-l", commandline.processLineEnds); runtime.defineReadonlyVariable("$*", argumentArray); runtime.defineVariable(new RubyGlobal.StringGlobalVariable(runtime, "$0", RubyString.newString(runtime, filename))); runtime.getLoadService().init(runtime, commandline.loadPaths()); Iterator iter = commandline.requiredLibraries().iterator(); while (iter.hasNext()) { String scriptName = (String) iter.next(); KernelModule.require(runtime.getTopSelf(), RubyString.newString(runtime, scriptName)); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/05c7de156620b4e1926ea77f476287db1b42b4cc/Main.java/buggy/src/org/jruby/Main.java
runtime.defineReadonlyVariable("$*", argumentArray);
runtime.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argumentArray));
private static void initializeRuntime(Ruby runtime, String filename) { IRubyObject argumentArray = JavaUtil.convertJavaToRuby(runtime, commandline.scriptArguments); runtime.setVerbose(commandline.verbose); defineGlobal(runtime, "$VERBOSE", commandline.verbose); runtime.defineGlobalConstant("ARGV", argumentArray); defineGlobal(runtime, "$-p", commandline.assumePrinting); defineGlobal(runtime, "$-n", commandline.assumeLoop); defineGlobal(runtime, "$-a", commandline.sDoSplit); defineGlobal(runtime, "$-l", commandline.processLineEnds); runtime.defineReadonlyVariable("$*", argumentArray); runtime.defineVariable(new RubyGlobal.StringGlobalVariable(runtime, "$0", RubyString.newString(runtime, filename))); runtime.getLoadService().init(runtime, commandline.loadPaths()); Iterator iter = commandline.requiredLibraries().iterator(); while (iter.hasNext()) { String scriptName = (String) iter.next(); KernelModule.require(runtime.getTopSelf(), RubyString.newString(runtime, scriptName)); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/05c7de156620b4e1926ea77f476287db1b42b4cc/Main.java/buggy/src/org/jruby/Main.java
public static void main (String args[]) {
public static void main(String args[]) {
public static void main (String args[]) { /* System.out.println(); System.out.println("----------------------------------------------------"); System.out.println("--- WARNING this is an ALPHA version of JRuby!!! ---"); System.out.println("----------------------------------------------------"); System.out.println(); */ // Benchmark long now = -1; if (args.length == 0) { printUsage(); } else { int lenArg = args.length; for (int i = 0; i < lenArg; i++) { if (args[i].equals("-h") || args[i].equals("-help")) { printUsage(); } else if (args[i].equals("-e")) { if (i++ >= lenArg) { System.err.println("invalid argument " + i); System.err.println(" -e must be followed by an expression to evaluate"); printUsage(); } else { runInterpreter(args[i], "command line " + i, new String[0]); } } else if (args[i].equals("-b")) { // Benchmark now = System.currentTimeMillis(); } else if (args[i].equals("-rx")) { if (++i >= lenArg) { System.err.println("invalid argument " + i); System.err.println(" -rx must be followed by an expression to evaluate"); printUsage(); } else { try { sRegexpAdapter = Class.forName(args[i]); } catch (Exception e) { System.err.println("invalid argument " + i ); System.err.println("failed to load RegexpAdapter: " + args[i]); System.err.println("defaulting to default RegexpAdapter: GNURegexpAdapter"); } } } else { String[] argv = new String[lenArg - i - 1]; System.arraycopy(args, i + 1, argv, 0, argv.length); runInterpreterOnFile(args[i], argv); break; } } } // Benchmark if (now != -1) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ec719ef82be7ea6956b3d139a2ce2d236eed4568/Main.java/buggy/org/jruby/Main.java
System.err.println("invalid argument " + i );
System.err.println("invalid argument " + i);
public static void main (String args[]) { /* System.out.println(); System.out.println("----------------------------------------------------"); System.out.println("--- WARNING this is an ALPHA version of JRuby!!! ---"); System.out.println("----------------------------------------------------"); System.out.println(); */ // Benchmark long now = -1; if (args.length == 0) { printUsage(); } else { int lenArg = args.length; for (int i = 0; i < lenArg; i++) { if (args[i].equals("-h") || args[i].equals("-help")) { printUsage(); } else if (args[i].equals("-e")) { if (i++ >= lenArg) { System.err.println("invalid argument " + i); System.err.println(" -e must be followed by an expression to evaluate"); printUsage(); } else { runInterpreter(args[i], "command line " + i, new String[0]); } } else if (args[i].equals("-b")) { // Benchmark now = System.currentTimeMillis(); } else if (args[i].equals("-rx")) { if (++i >= lenArg) { System.err.println("invalid argument " + i); System.err.println(" -rx must be followed by an expression to evaluate"); printUsage(); } else { try { sRegexpAdapter = Class.forName(args[i]); } catch (Exception e) { System.err.println("invalid argument " + i ); System.err.println("failed to load RegexpAdapter: " + args[i]); System.err.println("defaulting to default RegexpAdapter: GNURegexpAdapter"); } } } else { String[] argv = new String[lenArg - i - 1]; System.arraycopy(args, i + 1, argv, 0, argv.length); runInterpreterOnFile(args[i], argv); break; } } } // Benchmark if (now != -1) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ec719ef82be7ea6956b3d139a2ce2d236eed4568/Main.java/buggy/org/jruby/Main.java
ruby.getRuntime().setPrintBugs(printBugs);
protected static void runInterpreter(String iString2Eval, String iFileName, String[] args) { // Initialize Runtime Ruby ruby = new Ruby(); if (sRegexpAdapter == null) { try { sRegexpAdapter = Class.forName("org.jruby.regexp.GNURegexpAdapter"); } catch (Exception e) { throw new RuntimeException("Class GNURegexpAdapter not found"); } } ruby.setRegexpAdapterClass(sRegexpAdapter); ruby.init(); // Parse and interpret file RubyString rs = RubyString.m_newString(ruby, iString2Eval); ruby.defineGlobalConstant("ARGV", JavaUtil.convertJavaToRuby(ruby, args, String[].class)); // +++ try { ruby.getRubyTopSelf().eval(ruby.getRubyParser().compileString(iFileName, rs, 0)); } catch (RaiseException rExcptn) { System.out.println(rExcptn.getActException().m_to_s().getValue()); } // --- }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ec719ef82be7ea6956b3d139a2ce2d236eed4568/Main.java/buggy/org/jruby/Main.java
StringBuffer sb = new StringBuffer((int)rubyFile.length());
StringBuffer sb = new StringBuffer((int) rubyFile.length());
protected static void runInterpreterOnFile(String fileName, String[] args) { File rubyFile = new File(fileName); if (!rubyFile.canRead()) { System.out.println("Cannot read Rubyfile: \"" + fileName + "\""); } else { try { StringBuffer sb = new StringBuffer((int)rubyFile.length()); BufferedReader br = new BufferedReader(new FileReader(rubyFile)); String line; while ((line = br.readLine()) != null) { sb.append(line).append('\n'); } br.close(); runInterpreter(sb.toString(), fileName, args); } catch (IOException ioExcptn) { System.out.println("Cannot read Rubyfile: \"" + fileName + "\""); System.out.println("IOEception: " + ioExcptn.getMessage()); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/ec719ef82be7ea6956b3d139a2ce2d236eed4568/Main.java/buggy/org/jruby/Main.java
String klass = arg0.getName().substring( arg0.getPackage().getName().length() + 1); return klass;
String klass = arg0.getName(); int last = klass.lastIndexOf("."); if (last == -1) return klass; return klass.substring(last+1);
private String getClassName(final Class arg0) { if (arg0 ==null) throw new IllegalArgumentException("Class argument cannot be null."); String klass = arg0.getName().substring( arg0.getPackage().getName().length() + 1); return klass; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/51a3c546dfc7a7a98b29771a459df19094fc5b51/ContainerDaoHibernate.java/clean/components/server/src/ome/dao/hibernate/ContainerDaoHibernate.java
generateIDAttributeMapping(out, namespaceMapping, element);
private void generateElementMapping(PrintWriter out, NamespaceMapping namespaceMapping, ElementMapping element) { out.println(); out.println(" <!-- element for type: " + element.getClassName() + " -->"); String localName = element.getElementName(); out.println(" <xs:element name='" + localName + "'>"); out.println(" <xs:complexType>"); int complexCount = 0; for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) { AttributeMapping attributeMapping = (AttributeMapping) iterator.next(); if (!Utils.isSimpleType(attributeMapping.getType())) { complexCount++; } } if (complexCount > 0) { out.println(" <xs:sequence>"); for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) { AttributeMapping attributeMapping = (AttributeMapping) iterator.next(); if (!Utils.isSimpleType(attributeMapping.getType())) { generateElementMappingComplexProperty(out, namespaceMapping, attributeMapping); } } out.println(" </xs:sequence>"); } for (Iterator iterator = element.getAttributes().iterator(); iterator.hasNext();) { AttributeMapping attributeMapping = (AttributeMapping) iterator.next(); if (Utils.isSimpleType(attributeMapping.getType())) { generateElementMappingSimpleProperty(out, attributeMapping); } else if (!attributeMapping.getType().isCollection()) { generateElementMappingComplexPropertyAsRef(out, attributeMapping); } } out.println(" <xs:anyAttribute namespace='##other' processContents='lax'/>"); out.println(" </xs:complexType>"); out.println(" </xs:element>"); out.println(); }
52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/a12f3fd6bb96b0ce9605599496383e842b9ca0c2/XsdGenerator.java/clean/xbean-spring-common/src/main/java/org/apache/xbean/spring/generator/XsdGenerator.java
IRubyObject[] scanArgs(IRuby runtime, IRubyObject[] args, int required, int optional);
IRubyObject[] scanArgs(IRubyObject[] args, int required, int optional);
IRubyObject[] scanArgs(IRuby runtime, IRubyObject[] args, int required, int optional);
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/510a41b06f3103200e881725915b7cc1a5a10b39/IRubyObject.java/clean/src/org/jruby/runtime/builtin/IRubyObject.java
NODE body = searchMethod(name); RubyModule origin = getMethodOrigin(name);
SearchMethodResult smr = searchMethod(name); NODE body = smr.getBody(); RubyModule origin = smr.getOrigin();
public void exportMethod(RubyId name, int noex) { if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } NODE body = searchMethod(name); RubyModule origin = getMethodOrigin(name); if (body == null && isModule()) { body = getRuby().getClasses().getObjectClass().searchMethod(name); origin = getRuby().getClasses().getObjectClass().getMethodOrigin(name); } if (body == null) { } if (body.nd_noex() != noex) { if (this == origin) { body.nd_noex(noex); } else { addMethod(name, NODE.newZSuper(), noex); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/03950522a75c28f406bd4cb011cb1916a662366d/RubyModule.java/clean/org/jruby/RubyModule.java
body = getRuby().getClasses().getObjectClass().searchMethod(name); origin = getRuby().getClasses().getObjectClass().getMethodOrigin(name);
smr = getRuby().getClasses().getObjectClass().searchMethod(name); body = smr.getBody(); origin = smr.getOrigin();
public void exportMethod(RubyId name, int noex) { if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } NODE body = searchMethod(name); RubyModule origin = getMethodOrigin(name); if (body == null && isModule()) { body = getRuby().getClasses().getObjectClass().searchMethod(name); origin = getRuby().getClasses().getObjectClass().getMethodOrigin(name); } if (body == null) { } if (body.nd_noex() != noex) { if (this == origin) { body.nd_noex(noex); } else { addMethod(name, NODE.newZSuper(), noex); } } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/03950522a75c28f406bd4cb011cb1916a662366d/RubyModule.java/clean/org/jruby/RubyModule.java
NODE body = searchMethod(id);
NODE body = searchMethod(id).getBody();
public RubyObject m_module_function(RubyObject[] args) { if (getRuby().getSecurityLevel() >= 4 && !isTaint()) { throw new RubySecurityException("Insecure: can't change method visibility"); } if (args.length == 0) { getRuby().getInterpreter().setActMethodScope(SCOPE_MODFUNC); } else { setMethodVisibility(args, NOEX_PRIVATE); for (int i = 0; i < args.length; i++) { RubyId id = args[i].toId(); NODE body = searchMethod(id); if (body == null || body.nd_body() == null) { throw new RubyBugException("undefined method '" + id.toName() + "'; can't happen"); } getSingletonClass().addMethod(id, body.nd_body(), NOEX_PUBLIC); // rb_clear_cache_by_id(id); funcall(getRuby().intern("singleton_added"), id.toSymbol()); } } return this; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/03950522a75c28f406bd4cb011cb1916a662366d/RubyModule.java/clean/org/jruby/RubyModule.java
RubyClass newClass = new RubyClass(getRuby(), getRuby().getClasses().getClassClass(), superClass);
RubyClass newClass = new RubyClass(getRuby(), superClass);
public RubyClass newIncludeClass(RubyModule superClass) { RubyClass newClass = new RubyClass(getRuby(), getRuby().getClasses().getClassClass(), superClass); newClass.setIncluded(true); newClass.setInstanceVariables(getInstanceVariables()); newClass.setMethods(getMethods()); if (isIncluded()) { newClass.setRubyClass(getRubyClass()); } else { newClass.setRubyClass(this); } return newClass; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/03950522a75c28f406bd4cb011cb1916a662366d/RubyModule.java/clean/org/jruby/RubyModule.java
} public void mouseReleased(MouseEvent e) { if (transcriptWindow.getSelectedText() == null) { getChatInputEditor().requestFocus(); }
protected ChatRoom() { chatPanel = new JPanel(new GridBagLayout()); transcriptWindow = new TranscriptWindow(); splitPane = new JSplitPane(); packetIDList = new ArrayList(); notificationLabel = new JLabel(); toolbar = new ChatToolBar(); bottomPanel = new JPanel(); messageListeners = new ArrayList(); transcript = new ArrayList(); editorBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 1, 1)); fileDropListeners = new ArrayList(); transcriptWindow.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { getChatInputEditor().requestFocus(); } }); textScroller = new JScrollPane(transcriptWindow); textScroller.getVerticalScrollBar().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { mousePressed = true; } public void mouseReleased(MouseEvent e) { mousePressed = false; } }); chatAreaButton = new ChatAreaSendField(SparkRes.getString(SparkRes.SEND)); getChatInputEditor().setSelectedTextColor((Color)UIManager.get("ChatInput.SelectedTextColor")); getChatInputEditor().setSelectionColor((Color)UIManager.get("ChatInput.SelectionColor")); init(); // Initally, set the right pane to null to keep it empty. getSplitPane().setRightComponent(null); notificationLabel.setIcon(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)); getTranscriptWindow().addContextMenuListener(new ContextMenuListener() { public void poppingUp(Object component, JPopupMenu popup) { Action saveAction = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { saveTranscript(); } }; saveAction.putValue(Action.NAME, "Save"); saveAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.SAVE_AS_16x16)); popup.add(saveAction); } public void poppingDown(JPopupMenu popup) { } public boolean handleDefaultAction(MouseEvent e) { return false; } }); this.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F12"), "showDebugger"); this.getActionMap().put("showDebugger", new AbstractAction("showDebugger") { public void actionPerformed(ActionEvent evt) { EnhancedDebuggerWindow window = EnhancedDebuggerWindow.getInstance(); window.setVisible(true); } }); getTranscriptWindow().setTransferHandler(new ChatRoomTransferHandler(this)); getChatInputEditor().setTransferHandler(new ChatRoomTransferHandler(this)); add(toolbar, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/37d2c9c1910f8cad82e65ab912959a96c5121978/ChatRoom.java/clean/src/java/org/jivesoftware/spark/ui/ChatRoom.java
if (sScript != null) {
if (sScript.length() > 0) {
public static void main(String args[]) { /* System.out.println(); System.out.println("----------------------------------------------------"); System.out.println("--- WARNING this is an ALPHA version of JRuby!!! ---"); System.out.println("----------------------------------------------------"); System.out.println(); */ // Benchmark long now = -1; String[] argv = processArgs(args); if (sBenchmarkMode) now = System.currentTimeMillis(); if (sScript != null) { runInterpreter(sScript, "-e", argv); } else if (sFileName != null) { runInterpreterOnFile(sFileName, argv); } else { printUsage(); //interpreting from the command line not supported yet return; } // Benchmark if (now != -1) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d7918aa9361c91d54b455cf39432e037c77360ae/Main.java/clean/org/jruby/Main.java
int sizeZ, int t, int z) { initTxtWidth(); initComponents(registry, sizeZ, sizeT); initTextFields(t, z, sizeT, sizeZ); manager = new ToolBarManager(control, this, sizeT, t, sizeZ, z); manager.attachListeners(); buildToolBar(); }
int sizeZ, int t, int z) { initTxtWidth(); initComponents(registry, sizeZ, sizeT); initTextFields(t, z, sizeT, sizeZ); manager = new ToolBarManager(control, this, sizeT, t, sizeZ, z); manager.attachListeners(); buildToolBar(); }
public ToolBar(ViewerCtrl control, Registry registry, int sizeT, int sizeZ, int t, int z) { initTxtWidth(); initComponents(registry, sizeZ, sizeT); initTextFields(t, z, sizeT, sizeZ); manager = new ToolBarManager(control, this, sizeT, t, sizeZ, z); manager.attachListeners(); buildToolBar(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.add(render); bar.add(inspector); bar.add(viewer3D); bar.add(movie); bar.add(saveAs); bar.add(new JSeparator(SwingConstants.VERTICAL)); return bar; }
{ JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.add(render); bar.add(inspector); bar.add(viewer3D); bar.add(movie); bar.add(roi); bar.add(saveAs); bar.add(new JSeparator(SwingConstants.VERTICAL)); return bar; }
private JToolBar buildBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false); bar.add(render); bar.add(inspector); bar.add(viewer3D); bar.add(movie); bar.add(saveAs); bar.add(new JSeparator(SwingConstants.VERTICAL)); return bar; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ setLayout(new FlowLayout(FlowLayout.LEFT)); add(buildBar()); add(ztPanel); }
{ setLayout(new FlowLayout(FlowLayout.LEFT)); add(buildBar()); add(ztPanel); }
private void buildToolBar() { setLayout(new FlowLayout(FlowLayout.LEFT)); add(buildBar()); add(ztPanel); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ IconManager im = IconManager.getInstance(registry); viewer3D = new JButton(im.getIcon(IconManager.VIEWER3D)); viewer3D.setToolTipText( UIUtilities.formatToolTipText("Bring up the image3D viewer.")); viewer3D.setEnabled(maxZ == 0); saveAs = new JButton(im.getIcon(IconManager.SAVEAS)); saveAs.setToolTipText( UIUtilities.formatToolTipText("Bring up the save image window.")); inspector = new JButton(im.getIcon(IconManager.INSPECTOR)); inspector.setToolTipText( UIUtilities.formatToolTipText("Bring up the inspector panel.")); render = new JButton(im.getIcon(IconManager.RENDER)); render.setToolTipText( UIUtilities.formatToolTipText("Bring up the rendering panel.")); movie = new JButton(im.getIcon(IconManager.MOVIE));
{ IconManager im = IconManager.getInstance(registry); viewer3D = new JButton(im.getIcon(IconManager.VIEWER3D)); viewer3D.setToolTipText( UIUtilities.formatToolTipText("Bring up the image3D viewer.")); viewer3D.setEnabled(maxZ == 0); saveAs = new JButton(im.getIcon(IconManager.SAVEAS)); saveAs.setToolTipText( UIUtilities.formatToolTipText("Bring up the save image window.")); inspector = new JButton(im.getIcon(IconManager.INSPECTOR)); inspector.setToolTipText( UIUtilities.formatToolTipText("Bring up the inspector panel.")); render = new JButton(im.getIcon(IconManager.RENDER)); render.setToolTipText( UIUtilities.formatToolTipText("Bring up the rendering panel.")); movie = new JButton(im.getIcon(IconManager.MOVIE));
private void initComponents(Registry registry, int maxZ, int maxT) { //buttons IconManager im = IconManager.getInstance(registry); viewer3D = new JButton(im.getIcon(IconManager.VIEWER3D)); viewer3D.setToolTipText( UIUtilities.formatToolTipText("Bring up the image3D viewer.")); viewer3D.setEnabled(maxZ == 0); saveAs = new JButton(im.getIcon(IconManager.SAVEAS)); saveAs.setToolTipText( UIUtilities.formatToolTipText("Bring up the save image window.")); inspector = new JButton(im.getIcon(IconManager.INSPECTOR)); inspector.setToolTipText( UIUtilities.formatToolTipText("Bring up the inspector panel.")); render = new JButton(im.getIcon(IconManager.RENDER)); render.setToolTipText( UIUtilities.formatToolTipText("Bring up the rendering panel.")); movie = new JButton(im.getIcon(IconManager.MOVIE)); movie.setToolTipText( UIUtilities.formatToolTipText("Bring up the movie panel.")); if (maxT == 0 && maxZ == 0) movie.setEnabled(true); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
if (maxT == 0 && maxZ == 0) movie.setEnabled(true); }
roi = new JButton(im.getIcon(IconManager.ROI)); roi.setToolTipText( UIUtilities.formatToolTipText("Bring up the roi panel.")); if (maxT == 0 && maxZ == 0) movie.setEnabled(true); }
private void initComponents(Registry registry, int maxZ, int maxT) { //buttons IconManager im = IconManager.getInstance(registry); viewer3D = new JButton(im.getIcon(IconManager.VIEWER3D)); viewer3D.setToolTipText( UIUtilities.formatToolTipText("Bring up the image3D viewer.")); viewer3D.setEnabled(maxZ == 0); saveAs = new JButton(im.getIcon(IconManager.SAVEAS)); saveAs.setToolTipText( UIUtilities.formatToolTipText("Bring up the save image window.")); inspector = new JButton(im.getIcon(IconManager.INSPECTOR)); inspector.setToolTipText( UIUtilities.formatToolTipText("Bring up the inspector panel.")); render = new JButton(im.getIcon(IconManager.RENDER)); render.setToolTipText( UIUtilities.formatToolTipText("Bring up the rendering panel.")); movie = new JButton(im.getIcon(IconManager.MOVIE)); movie.setToolTipText( UIUtilities.formatToolTipText("Bring up the movie panel.")); if (maxT == 0 && maxZ == 0) movie.setEnabled(true); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ zLabel = new JLabel("/"+maxZ); tLabel = new JLabel("/"+maxT); tField = new JTextField(""+t, (""+maxT).length()); tField.setEditable(maxT != 0); tField.setForeground(Viewer.STEELBLUE); tField.setToolTipText( UIUtilities.formatToolTipText("Enter a timepoint.")); zField = new JTextField(""+z, (""+maxZ).length()); zField.setForeground(Viewer.STEELBLUE); zField.setToolTipText( UIUtilities.formatToolTipText("Enter a Z point")); zField.setEditable(maxZ != 0); ztPanel = textFieldsPanel((""+maxZ).length(), (""+maxT).length()); }
{ zLabel = new JLabel("/"+maxZ); tLabel = new JLabel("/"+maxT); tField = new JTextField(""+t, (""+maxT).length()); tField.setEditable(maxT != 0); tField.setForeground(Viewer.STEELBLUE); tField.setToolTipText( UIUtilities.formatToolTipText("Enter a timepoint.")); zField = new JTextField(""+z, (""+maxZ).length()); zField.setForeground(Viewer.STEELBLUE); zField.setToolTipText( UIUtilities.formatToolTipText("Enter a Z point")); zField.setEditable(maxZ != 0); ztPanel = textFieldsPanel((""+maxZ).length(), (""+maxT).length()); }
private void initTextFields(int t, int z, int maxT, int maxZ) { zLabel = new JLabel("/"+maxZ); tLabel = new JLabel("/"+maxT); tField = new JTextField(""+t, (""+maxT).length()); //if (maxT == 0) tField.setEditable(false); tField.setEditable(maxT != 0); tField.setForeground(Viewer.STEELBLUE); tField.setToolTipText( UIUtilities.formatToolTipText("Enter a timepoint.")); zField = new JTextField(""+z, (""+maxZ).length()); zField.setForeground(Viewer.STEELBLUE); zField.setToolTipText( UIUtilities.formatToolTipText("Enter a Z point")); //if (maxZ-1 == 0) zField.setEditable(maxZ != 0); zField.setEditable(maxZ != 0); ztPanel = textFieldsPanel((""+maxZ).length(), (""+maxT).length()); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ FontMetrics metrics = getFontMetrics(getFont()); txtWidth = metrics.charWidth('m'); }
{ FontMetrics metrics = getFontMetrics(getFont()); txtWidth = metrics.charWidth('m'); }
private void initTxtWidth() { FontMetrics metrics = getFontMetrics(getFont()); txtWidth = metrics.charWidth('m'); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
{ JPanel p = new JPanel(); JLabel l = new JLabel(" Z "); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); p.setLayout(gridbag); c.gridx = 0; c.gridy = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(l, c); p.add(l); c.gridx = 1; Insets insets = zField.getInsets(); c.ipadx = insets.left+zLength*txtWidth+insets.right; gridbag.setConstraints(zField, c); p.add(zField); c.gridx = 2; gridbag.setConstraints(zLabel, c); p.add(zLabel); c.gridx = 3; c.ipadx = 0; l = new JLabel(" T "); gridbag.setConstraints(l, c); p.add(l); c.gridx = 4; insets = tField.getInsets(); c.ipadx = insets.left+tLength*txtWidth+insets.right; gridbag.setConstraints(tField, c); p.add(tField); c.gridx = 5; gridbag.setConstraints(tLabel, c); p.add(tLabel); return p; }
{ JPanel p = new JPanel(); JLabel l = new JLabel(" Z "); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); p.setLayout(gridbag); c.gridx = 0; c.gridy = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(l, c); p.add(l); c.gridx = 1; Insets insets = zField.getInsets(); c.ipadx = insets.left+zLength*txtWidth+insets.right; gridbag.setConstraints(zField, c); p.add(zField); c.gridx = 2; gridbag.setConstraints(zLabel, c); p.add(zLabel); c.gridx = 3; c.ipadx = 0; l = new JLabel(" T "); gridbag.setConstraints(l, c); p.add(l); c.gridx = 4; insets = tField.getInsets(); c.ipadx = insets.left+tLength*txtWidth+insets.right; gridbag.setConstraints(tField, c); p.add(tField); c.gridx = 5; gridbag.setConstraints(tLabel, c); p.add(tLabel); return p; }
private JPanel textFieldsPanel(int zLength, int tLength) { JPanel p = new JPanel(); JLabel l = new JLabel(" Z "); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); p.setLayout(gridbag); c.gridx = 0; c.gridy = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; gridbag.setConstraints(l, c); p.add(l); c.gridx = 1; Insets insets = zField.getInsets(); c.ipadx = insets.left+zLength*txtWidth+insets.right; gridbag.setConstraints(zField, c); p.add(zField); c.gridx = 2; gridbag.setConstraints(zLabel, c); p.add(zLabel); c.gridx = 3; c.ipadx = 0; l = new JLabel(" T "); gridbag.setConstraints(l, c); p.add(l); c.gridx = 4; insets = tField.getInsets(); c.ipadx = insets.left+tLength*txtWidth+insets.right; gridbag.setConstraints(tField, c); p.add(tField); c.gridx = 5; gridbag.setConstraints(tLabel, c); p.add(tLabel); return p; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a81a5a58f8e54d006d057455465766c8d3d72998/ToolBar.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/controls/ToolBar.java
buildGUI();
AddWin(Set availablePaths) { super(availablePaths); initTree(); buildTreeNodes(); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/423006aa061b61c5fd6f0a1b95754e8a9a2c0fef/AddWin.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clsf/AddWin.java
dup.toRubyObject().setRubyClass(type()); dup.toRubyObject().frozen = false;
dup.setInternalClass(type()); dup.setFrozen(false);
public IRubyObject dup() { IRubyObject dup = callMethod("clone"); if (!dup.getClass().equals(getClass())) { throw new TypeError(getRuntime(), "duplicated object must be same type"); } dup.toRubyObject().setRubyClass(type());// dup.infectObject(this); //Benoit done by clone dup.toRubyObject().frozen = false; return dup; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
return rubyClass;
return internalClass;
public RubyClass getInternalClass() { if (isNil()) { return getRuntime().getClasses().getNilClass(); } return rubyClass; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
setRubyClass(type);
setInternalClass(type);
public RubyClass makeMetaClass(RubyClass type) { type = type.newSingletonClass(); setRubyClass(type); type.attachSingletonClass(this); return type; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
clone.toRubyObject().setupClone(this);
clone.setupClone(this);
public IRubyObject rbClone() { try { IRubyObject clone = (IRubyObject)clone(); clone.toRubyObject().setupClone(this); if (getInstanceVariables() != null) { clone.toRubyObject().setInstanceVariables(getInstanceVariables().cloneRubyMap()); } return clone; } catch (CloneNotSupportedException cnsExcptn) { // BUG throw new RubyBugException(cnsExcptn.getMessage()); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
clone.toRubyObject().setInstanceVariables(getInstanceVariables().cloneRubyMap());
((RubyObject)clone).setInstanceVariables(getInstanceVariables().cloneRubyMap());
public IRubyObject rbClone() { try { IRubyObject clone = (IRubyObject)clone(); clone.toRubyObject().setupClone(this); if (getInstanceVariables() != null) { clone.toRubyObject().setInstanceVariables(getInstanceVariables().cloneRubyMap()); } return clone; } catch (CloneNotSupportedException cnsExcptn) { // BUG throw new RubyBugException(cnsExcptn.getMessage()); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
setRubyClass(obj.getInternalClass().getSingletonClassClone());
setInternalClass(obj.getInternalClass().getSingletonClassClone());
public void setupClone(IRubyObject obj) { setRubyClass(obj.getInternalClass().getSingletonClassClone()); getInternalClass().attachSingletonClass(this); frozen = obj.isFrozen(); taint = obj.isTaint(); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
return ruby.yield(args[0], args[0], ruby.getRubyClass(), false).toRubyObject();
return ruby.yield(args[0], args[0], ruby.getRubyClass(), false);
public IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // if () { Block oldBlock = ruby.getBlockStack().getCurrent().cloneBlock(); /* copy the block to avoid modifying global data. */ ruby.getBlockStack().getCurrent().getFrame().setNamespace(ruby.getCurrentFrame().getNamespace()); try { return ruby.yield(args[0], args[0], ruby.getRubyClass(), false).toRubyObject(); } finally { ruby.getBlockStack().setCurrent(oldBlock); } // } /* static block, no need to restore */ // ruby.getBlock().frame.setNamespace(ruby.getRubyFrame().getNamespace()); // return ruby.yield0(args[0], args[0], ruby.getRubyClass(), false); } public int getArity() { return -1; } }, new IRubyObject[] { this }); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
return ruby.yield(args[0], args[0], ruby.getRubyClass(), false).toRubyObject();
return ruby.yield(args[0], args[0], ruby.getRubyClass(), false);
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // if () { Block oldBlock = ruby.getBlockStack().getCurrent().cloneBlock(); /* copy the block to avoid modifying global data. */ ruby.getBlockStack().getCurrent().getFrame().setNamespace(ruby.getCurrentFrame().getNamespace()); try { return ruby.yield(args[0], args[0], ruby.getRubyClass(), false).toRubyObject(); } finally { ruby.getBlockStack().setCurrent(oldBlock); } // } /* static block, no need to restore */ // ruby.getBlock().frame.setNamespace(ruby.getRubyFrame().getNamespace()); // return ruby.yield0(args[0], args[0], ruby.getRubyClass(), false); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f235ab756f32ea9496f8f880066b46ad95ebb692/RubyObject.java/clean/org/jruby/RubyObject.java
public RubyObject call(Ruby ruby, RubyObject recv, RubyId id, RubyObject[] args, boolean noSuper) {
public RubyObject call(Ruby ruby, RubyObject recv, RubyId id, RubyPointer args, boolean noSuper) {
public RubyObject call(Ruby ruby, RubyObject recv, RubyId id, RubyObject[] args, boolean noSuper) { return eval(ruby, recv); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f629550c5947df9c1dbe414645f3dc76bcb70df4/IVarNode.java/clean/org/jruby/nodes/IVarNode.java
FastWriter fw = new FastWriter(os, "UTF8");
FastWriter fw = new FastWriter(os, data.getEncoding());
public final Object evaluate(Context data) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(512); FastWriter fw = new FastWriter(os, "UTF8"); write(fw,data); fw.flush(); return os.toString("UTF8"); } catch (IOException e) { _log.exception(e); _log.error("Template: Could not write to ByteArrayOutputStream!"); return null; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/9dc4324fb914abcbf2ec188e4eb77b1bf503f330/WMTemplate.java/buggy/webmacro/src/org/webmacro/engine/WMTemplate.java
return os.toString("UTF8");
return os.toString(data.getEncoding());
public final Object evaluate(Context data) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(512); FastWriter fw = new FastWriter(os, "UTF8"); write(fw,data); fw.flush(); return os.toString("UTF8"); } catch (IOException e) { _log.exception(e); _log.error("Template: Could not write to ByteArrayOutputStream!"); return null; } }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/9dc4324fb914abcbf2ec188e4eb77b1bf503f330/WMTemplate.java/buggy/webmacro/src/org/webmacro/engine/WMTemplate.java
public HttpMethodBase marshal()
public HttpMethod marshal()
public HttpMethodBase marshal() { //Create request. PostMethod request = new PostMethod(); //Marshal. request.addParameter(SESSION_KEY_FIELD, sessionKey); request.addParameter(METHOD_FIELD, method); request.addParameter(PIXELS_ID_FIELD, Long.toString(pixelsID)); request.addParameter(THE_C_FIELD, Integer.toString(theC)); request.addParameter(THE_T_FIELD, Integer.toString(theT)); request.addParameter(BIG_ENDIAN_FIELD, Integer.toString(bigEndian)); return request; }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/c0ee67611abddaf7c5a898ad8033ca4845e9d8fe/GetStackRequest.java/clean/SRC/org/openmicroscopy/shoola/omeis/proxy/GetStackRequest.java
showImages();
showImages(); break; case IMAGES_SELECTION: bringSelector(e); break;
public void actionPerformed(ActionEvent e) { int index = Integer.parseInt(e.getActionCommand()); try { switch (index) { case SAVE: saveSelection(); break; case ALL: selectAll(); break; case CANCEL: cancelSelection(); break; case SHOW_IMAGES: showImages(); } } catch(NumberFormatException nfe) { throw new Error("Invalid Action ID "+index, nfe); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a82d641ae8b6aae180291dcfe5e2b1c45e55ea11/CategoryImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/category/CategoryImagesDiffPaneManager.java
attachBoxListeners(view.selections, IMAGES_SELECTION);
private void attachListeners() { attachButtonListener(view.selectButton, ALL); attachButtonListener(view.cancelButton, CANCEL); attachButtonListener(view.saveButton, SAVE); attachButtonListener(view.showImages, SHOW_IMAGES); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a82d641ae8b6aae180291dcfe5e2b1c45e55ea11/CategoryImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/category/CategoryImagesDiffPaneManager.java
case CategoryImagesDiffPane.IMAGES_USED: images = control.getImagesDiffInUserDatasets(); break;
private void showImages() { int selectedIndex = view.selections.getSelectedIndex(); if (selectedIndex != selectionIndex) { selectionIndex = selectedIndex; List images = null; switch (selectedIndex) { case CategoryImagesDiffPane.IMAGES_IMPORTED: images = control.getImagesDiff(); break; case CategoryImagesDiffPane.IMAGES_USED: images = control.getImagesDiffInUserDatasets(); break; case CategoryImagesDiffPane.IMAGES_GROUP: images = control.getImagesDiffInUserGroup(); break; case CategoryImagesDiffPane.IMAGES_SYSTEM: images = control.getImagesDiffInSystem(); break; } if (images == null || images.size() == 0) return; imagesDiff = images; view.showImages(images); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a82d641ae8b6aae180291dcfe5e2b1c45e55ea11/CategoryImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/category/CategoryImagesDiffPaneManager.java
if (images == null || images.size() == 0) return; imagesDiff = images; view.showImages(images);
displayListImages(images);
private void showImages() { int selectedIndex = view.selections.getSelectedIndex(); if (selectedIndex != selectionIndex) { selectionIndex = selectedIndex; List images = null; switch (selectedIndex) { case CategoryImagesDiffPane.IMAGES_IMPORTED: images = control.getImagesDiff(); break; case CategoryImagesDiffPane.IMAGES_USED: images = control.getImagesDiffInUserDatasets(); break; case CategoryImagesDiffPane.IMAGES_GROUP: images = control.getImagesDiffInUserGroup(); break; case CategoryImagesDiffPane.IMAGES_SYSTEM: images = control.getImagesDiffInSystem(); break; } if (images == null || images.size() == 0) return; imagesDiff = images; view.showImages(images); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/a82d641ae8b6aae180291dcfe5e2b1c45e55ea11/CategoryImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/category/CategoryImagesDiffPaneManager.java
globalProjectData = new ProjectData();
public static ProjectData getGlobalProjectData() { if (globalProjectData != null) return globalProjectData; initialize(); globalProjectData = new ProjectData(); return globalProjectData; }
50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/edbadf596ee0053098884e80bfe34fad03d14803/ProjectData.java/clean/cobertura/src/net/sourceforge/cobertura/coveragedata/ProjectData.java
setAlwaysOnTop(true);
private void setWindowProperties() { setTitle(TITLE); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); setModal(true); setResizable(false); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/43f8c678f03aa7cac6a19865461c28a00cf7eb2b/ColourPicker.java/buggy/SRC/org/openmicroscopy/shoola/util/ui/colourpicker/ColourPicker.java
public RubyClass newSubClass(String name, RubyModule parent) { return new NumericMetaClass(name, this, parent);
public RubyClass newSubClass(String name, SinglyLinkedList parentCRef) { return new NumericMetaClass(name, this, parentCRef);
public RubyClass newSubClass(String name, RubyModule parent) { return new NumericMetaClass(name, this, parent); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/NumericMetaClass.java/buggy/src/org/jruby/runtime/builtin/meta/NumericMetaClass.java
} catch (BreakException bExcptn) {
} catch (BreakJump bExcptn) {
public RubyObject eval(Ruby ruby, RubyObject self) { RubyObject result; ruby.getBlock().push(getVarNode(), getBodyNode(), self); ruby.getIter().push(RubyIter.ITER_PRE); try { while (true) { try { return getIterNode().eval(ruby, self); } catch (RetryException rExcptn) { } } } catch (ReturnException rExcptn) { return rExcptn.getReturnValue(); } catch (BreakException bExcptn) { return ruby.getNil(); } finally { ruby.getIter().pop(); ruby.getBlock().pop(); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/786cea08c1dd2092a02d1254b49fbee371ace5f9/IterNode.java/buggy/org/jruby/nodes/IterNode.java
Visibility visibility, RubyModule parent) {
Visibility visibility, SinglyLinkedList cref) {
public DefaultMethod(RubyModule implementationClass, ScopeNode body, ArgsNode argsNode, Visibility visibility, RubyModule parent) { super(implementationClass, visibility); this.body = body; this.argsNode = argsNode; this.parent = parent; assert body != null; assert argsNode != null; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/DefaultMethod.java/buggy/src/org/jruby/internal/runtime/methods/DefaultMethod.java
this.parent = parent;
this.cref = cref;
public DefaultMethod(RubyModule implementationClass, ScopeNode body, ArgsNode argsNode, Visibility visibility, RubyModule parent) { super(implementationClass, visibility); this.body = body; this.argsNode = argsNode; this.parent = parent; assert body != null; assert argsNode != null; }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/DefaultMethod.java/buggy/src/org/jruby/internal/runtime/methods/DefaultMethod.java
return new DefaultMethod(getImplementationClass(), body, argsNode, getVisibility(), parent);
return new DefaultMethod(getImplementationClass(), body, argsNode, getVisibility(), cref);
public ICallable dup() { return new DefaultMethod(getImplementationClass(), body, argsNode, getVisibility(), parent); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/DefaultMethod.java/buggy/src/org/jruby/internal/runtime/methods/DefaultMethod.java
context.preDefMethodInternalCall(implementationClass, recv, name, args, noSuper);
context.preDefMethodInternalCall(recv, name, args, noSuper, cref);
public void preMethod(IRuby runtime, RubyModule implementationClass, IRubyObject recv, String name, IRubyObject[] args, boolean noSuper) { ThreadContext context = runtime.getCurrentContext(); context.preDefMethodInternalCall(implementationClass, recv, name, args, noSuper); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/DefaultMethod.java/buggy/src/org/jruby/internal/runtime/methods/DefaultMethod.java
try {
try {
public void load() { rwl.writeLock().lock(); try { errorIfNullPixels(); /* * TODO we could also allow for setting of the buffer! perhaps * better caching, etc. */ PixelBuffer buffer = pixDataSrv.getPixelBuffer(pixelsObj); renderer = new Renderer(pixMetaSrv, pixelsObj, rendDefObj, buffer); } finally { rwl.writeLock().unlock(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
public void load() { rwl.writeLock().lock(); try { errorIfNullPixels(); /* * TODO we could also allow for setting of the buffer! perhaps * better caching, etc. */ PixelBuffer buffer = pixDataSrv.getPixelBuffer(pixelsObj); renderer = new Renderer(pixMetaSrv, pixelsObj, rendDefObj, buffer); } finally { rwl.writeLock().unlock(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
} finally {
} finally {
public void load() { rwl.writeLock().lock(); try { errorIfNullPixels(); /* * TODO we could also allow for setting of the buffer! perhaps * better caching, etc. */ PixelBuffer buffer = pixDataSrv.getPixelBuffer(pixelsObj); renderer = new Renderer(pixMetaSrv, pixelsObj, rendDefObj, buffer); } finally { rwl.writeLock().unlock(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
try { this.rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId); this.renderer = null;
try { rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId); renderer = null;
public void lookupRenderingDef(long pixelsId) { rwl.writeLock().lock(); try { this.rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId); this.renderer = null; if ( rendDefObj == null ) throw new ValidationException( "RenderingDef for Pixels="+pixelsId+" not found."); } finally { rwl.writeLock().unlock(); } if (log.isDebugEnabled()) log.debug("lookupRenderingDef for Pixels="+pixelsId+" succeeded: "+this.rendDefObj); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
if ( rendDefObj == null ) throw new ValidationException( "RenderingDef for Pixels="+pixelsId+" not found."); } finally {
if (rendDefObj == null) { rendDefObj = Renderer.createNewRenderingDef(pixelsObj); Renderer.resetDefaults(rendDefObj, pixelsObj, pixMetaSrv); pixMetaSrv.saveRndSettings(rendDefObj); iUpdate.flush(); rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId); } } finally {
public void lookupRenderingDef(long pixelsId) { rwl.writeLock().lock(); try { this.rendDefObj = pixMetaSrv.retrieveRndSettings(pixelsId); this.renderer = null; if ( rendDefObj == null ) throw new ValidationException( "RenderingDef for Pixels="+pixelsId+" not found."); } finally { rwl.writeLock().unlock(); } if (log.isDebugEnabled()) log.debug("lookupRenderingDef for Pixels="+pixelsId+" succeeded: "+this.rendDefObj); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
iUpdate.flush();
public void resetDefaults() { rwl.writeLock().lock(); try { errorIfInvalidState(); renderer.resetDefaults(); } finally { rwl.writeLock().unlock(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/64e6d912272b039f986c1a36d1ca930cc5578578/RenderingBean.java/buggy/components/server/src/ome/services/RenderingBean.java
System.out.println("Cannot read Rubyfile: \"" + fname.getValue() + "\""); System.out.println("IOEception: " + ioExcptn.getMessage());
getErrorStream().println("Cannot read Rubyfile: \"" + fname.getValue() + "\""); getErrorStream().println("IOEception: " + ioExcptn.getMessage());
public void loadFile(RubyString fname, boolean wrap) { // fname = findFile(fname); if (fname == null) { throw new RuntimeException("No such file to load -- " + fname.getValue()); } try { File rubyFile = new File(fname.getValue()); StringBuffer source = new StringBuffer((int)rubyFile.length()); BufferedReader br = new BufferedReader(new FileReader(rubyFile)); String line; while ((line = br.readLine()) != null) { source.append(line).append('\n'); } br.close(); loadScript(fname, RubyString.m_newString(ruby, source.toString()), wrap); } catch (IOException ioExcptn) { System.out.println("Cannot read Rubyfile: \"" + fname.getValue() + "\""); System.out.println("IOEception: " + ioExcptn.getMessage()); } }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/2c6d31ae5651a0a0c68c2bb382ab68cea34c67d7/RubyRuntime.java/clean/org/jruby/runtime/RubyRuntime.java
excptn.printStackTrace();
excptn.printStackTrace(getErrorStream());
public void loadScript(RubyString scriptName, RubyString source, boolean wrap) { RubyObject self = ruby.getRubyTopSelf(); CRefNode savedCRef = ruby.getCRef(); // TMP_PROTECT; if (wrap && ruby.getSecurityLevel() >= 4) { // Check_Type(fname, T_STRING); } else { // Check_SafeStr(fname); } // volatile ID last_func; // ruby_errinfo = Qnil; /* ensure */ RubyVarmap.push(ruby); ruby.pushClass(); RubyModule wrapper = ruby.getWrapper(); ruby.setCRef(ruby.getTopCRef()); if (!wrap) { ruby.secure(4); /* should alter global state */ ruby.setRubyClass(ruby.getClasses().getObjectClass()); ruby.setWrapper(null); } else { /* load in anonymous module as toplevel */ ruby.setWrapper(RubyModule.m_newModule(ruby)); ruby.setRubyClass(ruby.getWrapper()); self = ruby.getRubyTopSelf().m_clone(); self.extendObject(ruby.getRubyClass()); ruby.getCRef().push(ruby.getWrapper()); } ruby.getRubyFrame().push(); ruby.getRubyFrame().setLastFunc(null); ruby.getRubyFrame().setLastClass(null); ruby.getRubyFrame().setSelf(self); ruby.getRubyFrame().setCbase(new CRefNode(ruby.getRubyClass(), null)); ruby.getRubyScope().push(); /* default visibility is private at loading toplevel */ ruby.setActMethodScope(Constants.SCOPE_PRIVATE); RubyId last_func = ruby.getRubyFrame().getLastFunc(); try { // RubyId last_func = ruby.getRubyFrame().getLastFunc(); // DEFER_INTS; ruby.setInEval(ruby.getInEval() + 1); ruby.getRubyParser().compileString(scriptName.getValue(), source, 0); // --- ruby.setInEval(ruby.getInEval() - 1); // evalNode +++ if (ruby.getParserHelper().getEvalTreeBegin() != null) { self.eval(ruby.getParserHelper().getEvalTreeBegin()); ruby.getParserHelper().setEvalTreeBegin(null); } if (ruby.getParserHelper().getEvalTree() != null) { self.eval(ruby.getParserHelper().getEvalTree()); } // evalNode --- } catch (Exception excptn) { excptn.printStackTrace(); } ruby.getRubyFrame().setLastFunc(last_func); /*if (ruby.getRubyScope().getFlags() == SCOPE_ALLOCA && ruby.getRubyClass() == ruby.getClasses().getObjectClass()) { if (ruby_scope->local_tbl) free(ruby_scope->local_tbl); }*/ ruby.setCRef(savedCRef); ruby.getRubyScope().pop(); ruby.getRubyFrame().pop(); ruby.popClass(); RubyVarmap.pop(ruby); ruby.setWrapper(wrapper); /*if (ruby_nerrs > 0) { ruby_nerrs = 0; rb_exc_raise(ruby_errinfo); }*/ }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/2c6d31ae5651a0a0c68c2bb382ab68cea34c67d7/RubyRuntime.java/clean/org/jruby/runtime/RubyRuntime.java
UserCredentials uc = splashScreen.getUserCredentials();
uc = splashScreen.getUserCredentials((max == index-1));
public void onEnd() { //Last update with total number of tasks executed. splashScreen.updateProgress(""); //Try to log onto OMEDS and retry upon failure for at most as many //times as specified in the Container's configuration. Registry reg = container.getRegistry(); LoginConfig cfg = new LoginConfig(reg); int max = cfg.getMaxRetry(); LoginService loginSvc = (LoginService) reg.lookup(LookupNames.LOGIN); boolean succeeded = false; while (0 < max--) { UserCredentials uc = splashScreen.getUserCredentials(); if ((succeeded = loginSvc.login(uc))) break; } //Now get rid of the Splash Screen. splashScreen.close(); //Exit if we couldn't manage to log in. if (!succeeded) { UserNotifier un = UIFactory.makeUserNotifier(); un.notifyError("Login Failure", "A valid connection to OMEDS "+ "couldn't be established. The application will exit."); container.exit(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/84042cbca2e8aeaf65ca18c85ea2224ea4c04d55/SplashScreenInit.java/buggy/SRC/org/openmicroscopy/shoola/env/init/SplashScreenInit.java
splashScreen.close();
public void onEnd() { //Last update with total number of tasks executed. splashScreen.updateProgress(""); //Try to log onto OMEDS and retry upon failure for at most as many //times as specified in the Container's configuration. Registry reg = container.getRegistry(); LoginConfig cfg = new LoginConfig(reg); int max = cfg.getMaxRetry(); LoginService loginSvc = (LoginService) reg.lookup(LookupNames.LOGIN); boolean succeeded = false; while (0 < max--) { UserCredentials uc = splashScreen.getUserCredentials(); if ((succeeded = loginSvc.login(uc))) break; } //Now get rid of the Splash Screen. splashScreen.close(); //Exit if we couldn't manage to log in. if (!succeeded) { UserNotifier un = UIFactory.makeUserNotifier(); un.notifyError("Login Failure", "A valid connection to OMEDS "+ "couldn't be established. The application will exit."); container.exit(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/84042cbca2e8aeaf65ca18c85ea2224ea4c04d55/SplashScreenInit.java/buggy/SRC/org/openmicroscopy/shoola/env/init/SplashScreenInit.java
splashScreen.close();
public void onEnd() { //Last update with total number of tasks executed. splashScreen.updateProgress(""); //Try to log onto OMEDS and retry upon failure for at most as many //times as specified in the Container's configuration. Registry reg = container.getRegistry(); LoginConfig cfg = new LoginConfig(reg); int max = cfg.getMaxRetry(); LoginService loginSvc = (LoginService) reg.lookup(LookupNames.LOGIN); boolean succeeded = false; while (0 < max--) { UserCredentials uc = splashScreen.getUserCredentials(); if ((succeeded = loginSvc.login(uc))) break; } //Now get rid of the Splash Screen. splashScreen.close(); //Exit if we couldn't manage to log in. if (!succeeded) { UserNotifier un = UIFactory.makeUserNotifier(); un.notifyError("Login Failure", "A valid connection to OMEDS "+ "couldn't be established. The application will exit."); container.exit(); } }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/84042cbca2e8aeaf65ca18c85ea2224ea4c04d55/SplashScreenInit.java/buggy/SRC/org/openmicroscopy/shoola/env/init/SplashScreenInit.java
public UserCredentials getUserCredentials();
public UserCredentials getUserCredentials(boolean init);
public UserCredentials getUserCredentials();
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/84042cbca2e8aeaf65ca18c85ea2224ea4c04d55/SplashScreen.java/buggy/SRC/org/openmicroscopy/shoola/env/ui/SplashScreen.java
protected DataLoader createHierarchyLoader()
protected DataLoader createHierarchyLoader(boolean refresh)
protected DataLoader createHierarchyLoader() { return new CategoryGroupLoader(component, ids); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fb3743d6f75abbf12f788b3b2925f4a6f4606dd6/CategoryGroupModel.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/CategoryGroupModel.java
return new CategoryGroupLoader(component, ids);
return new CategoryGroupLoader(component, ids, refresh);
protected DataLoader createHierarchyLoader() { return new CategoryGroupLoader(component, ids); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/fb3743d6f75abbf12f788b3b2925f4a6f4606dd6/CategoryGroupModel.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/CategoryGroupModel.java
return "Group"+(attributeId==null ? ":Hash"+this.hashCode() : ":"+attributeId);
return "Group"+(attributeId==null ? ":Hash_"+this.hashCode() : ":Id_"+attributeId);
public String toString(){ return "Group"+(attributeId==null ? ":Hash"+this.hashCode() : ":"+attributeId); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/51a3c546dfc7a7a98b29771a459df19094fc5b51/Group.java/clean/components/common/src/ome/model/Group.java
assertStringTemplateEquals(tmpl, "");
public void testBinarySetBoolean() throws Exception { String tmpl = "#set $TestObject.Bool=true"; assertTrue(to.bool); }
52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/1cbef201fa09759e4ccbb18278b4bced8fe0a464/TestGetSet.java/clean/webmacro/test/unit/org/webmacro/template/TestGetSet.java
assertTrue(((RubyFixnum) lLoadA.nitems()).getValue() == 2);
assertTrue(RubyNumeric.num2long(lLoadA.nitems()) == 2);
public void testInitLoad() { ArrayList list = new ArrayList(); //check without a RubyHome and with one parameter System.setProperty("jruby.home", ""); list.add("toto"); ruby.initLoad(list); //check that the global vars are correctly valuated RubyObject lCol = ruby.getGlobalVar("$:"); RubyObject lI = ruby.getGlobalVar("$-I"); RubyObject lLoad = ruby.getGlobalVar("$LOAD_PATH"); assertTrue(lCol == lI && lI == lLoad && lLoad != null); RubyArray lLoadA = (RubyArray) lLoad; //check that we have 2 non null element assertTrue(((RubyFixnum) lLoadA.nitems()).getValue() == 2); //check that it is what we expect, a RubyString of the correct type assertTrue(new RubyString(ruby, "toto").equal(lLoadA.shift())); assertTrue(new RubyString(ruby, ".").equal(lLoadA.shift())); //check the case when RubyHome is valuated System.setProperty("jruby.home", "RubyHome"); //MRI result /* C:\dev\jruby>ruby -e "puts $:" /cygdrive/d/ruby/lib/ruby/site_ruby/1.6 /cygdrive/d/ruby/lib/ruby/site_ruby/1.6/i386-cygwin /cygdrive/d/ruby/lib/ruby/site_ruby /cygdrive/d/ruby/lib/ruby/1.6 /cygdrive/d/ruby/lib/ruby/1.6/i386-cygwin . */ ruby.initLoad(new ArrayList()); String wanted; if (File.separatorChar == '/') { wanted = "RubyHome/lib/ruby/site_ruby/1.6" + "RubyHome/lib/ruby/site_ruby/1.6/JAVA" + "RubyHome/lib/ruby/site_ruby" + "RubyHome/lib/ruby/1.6" + "RubyHome/lib/ruby/1.6/JAVA" + "."; } else { wanted = "RubyHome\\lib\\ruby\\site_ruby\\1.6" + "RubyHome\\lib\\ruby\\site_ruby\\1.6\\JAVA" + "RubyHome\\lib\\ruby\\site_ruby" + "RubyHome\\lib\\ruby\\1.6" + "RubyHome\\lib\\ruby\\1.6\\JAVA" + "."; } assertEquals(wanted, eval("puts $:")); }
50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/786cea08c1dd2092a02d1254b49fbee371ace5f9/TestRuby.java/buggy/org/jruby/test/TestRuby.java
System.err.println("viewing spots for execution..."+exec.getID());
private void handleViewSpots(ViewTrackSpotsEvent event) { ChainExecutionData exec = event.getChainExecution(); System.err.println("viewing spots for execution..."+exec.getID()); SpotsTrajectorySet trajectories = new SpotsTrajectorySet(registry,exec); if (trajectories.isEmpty()) { JOptionPane.showMessageDialog(null, "There are no results from this execution that can be displayed", "No Trajectories",JOptionPane.INFORMATION_MESSAGE); return; } SpotsWindow window = new SpotsWindow(registry,trajectories); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/593fde2d2823cacc93db6467f8034ede1fe2bb45/Spots.java/clean/SRC/org/openmicroscopy/shoola/agents/spots/Spots.java
private void handleViewSpots(ViewTrackSpotsEvent event) { ChainExecutionData exec = event.getChainExecution(); System.err.println("viewing spots for execution..."+exec.getID()); SpotsTrajectorySet trajectories = new SpotsTrajectorySet(registry,exec); if (trajectories.isEmpty()) { JOptionPane.showMessageDialog(null, "There are no results from this execution that can be displayed", "No Trajectories",JOptionPane.INFORMATION_MESSAGE); return; } SpotsWindow window = new SpotsWindow(registry,trajectories); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/593fde2d2823cacc93db6467f8034ede1fe2bb45/Spots.java/clean/SRC/org/openmicroscopy/shoola/agents/spots/Spots.java
System.err.println("setting context for spots..");
public void setContext(Registry ctx) { System.err.println("setting context for spots.."); registry = ctx; //The container built our registry, store a reference. EventBus bus = registry.getEventBus(); bus.register(this,ViewTrackSpotsEvent.class); }
54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/593fde2d2823cacc93db6467f8034ede1fe2bb45/Spots.java/clean/SRC/org/openmicroscopy/shoola/agents/spots/Spots.java
public JContactItemField(List items, Window parentWindow) {
public JContactItemField(List items) {
public JContactItemField(List items, Window parentWindow) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) { textField.requestFocus(); } } }); popup = new JWindow(parentWindow); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/451ca5454333fabb40923ca0b6a307994410412c/JContactItemField.java/buggy/src/java/org/jivesoftware/spark/component/JContactItemField.java
list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) { textField.requestFocus(); } } }); popup = new JWindow(parentWindow);
popup = new JWindow();
public JContactItemField(List items, Window parentWindow) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) { textField.requestFocus(); } } }); popup = new JWindow(parentWindow); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/451ca5454333fabb40923ca0b6a307994410412c/JContactItemField.java/buggy/src/java/org/jivesoftware/spark/component/JContactItemField.java
public JContactItemField(List items, Window parentWindow) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); list.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) { textField.requestFocus(); } } }); popup = new JWindow(parentWindow); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/451ca5454333fabb40923ca0b6a307994410412c/JContactItemField.java/buggy/src/java/org/jivesoftware/spark/component/JContactItemField.java