rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); | boolean lmacro = (l instanceof Macro); boolean rmacro = (r instanceof Macro); | public final Object build(BuildContext pc) throws BuildException { Object l, r; l = _l.build(pc); r = _r.build(pc); boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); if (!lcond && !rcond) { if ((l == null) || (r == null)) { return (l == r) ? Boolean.TRUE : Boolean.FALSE; } else { return (l.equals(r)) ? Boolean.TRUE : Boolean.FALSE; } } if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); } if (lcond) { return new EqualConstantCondition((Condition) l, r); } else { return new EqualConstantCondition((Condition) r, l); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
if (!lcond && !rcond) { | if (!lmacro && !rmacro) { | public final Object build(BuildContext pc) throws BuildException { Object l, r; l = _l.build(pc); r = _r.build(pc); boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); if (!lcond && !rcond) { if ((l == null) || (r == null)) { return (l == r) ? Boolean.TRUE : Boolean.FALSE; } else { return (l.equals(r)) ? Boolean.TRUE : Boolean.FALSE; } } if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); } if (lcond) { return new EqualConstantCondition((Condition) l, r); } else { return new EqualConstantCondition((Condition) r, l); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); | if (lmacro && rmacro) { return new EqualCondition((Macro) l, (Macro) r); | public final Object build(BuildContext pc) throws BuildException { Object l, r; l = _l.build(pc); r = _r.build(pc); boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); if (!lcond && !rcond) { if ((l == null) || (r == null)) { return (l == r) ? Boolean.TRUE : Boolean.FALSE; } else { return (l.equals(r)) ? Boolean.TRUE : Boolean.FALSE; } } if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); } if (lcond) { return new EqualConstantCondition((Condition) l, r); } else { return new EqualConstantCondition((Condition) r, l); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
if (lcond) { return new EqualConstantCondition((Condition) l, r); | if (lmacro) { return new EqualConstantCondition((Macro) l, r); | public final Object build(BuildContext pc) throws BuildException { Object l, r; l = _l.build(pc); r = _r.build(pc); boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); if (!lcond && !rcond) { if ((l == null) || (r == null)) { return (l == r) ? Boolean.TRUE : Boolean.FALSE; } else { return (l.equals(r)) ? Boolean.TRUE : Boolean.FALSE; } } if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); } if (lcond) { return new EqualConstantCondition((Condition) l, r); } else { return new EqualConstantCondition((Condition) r, l); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
return new EqualConstantCondition((Condition) r, l); | return new EqualConstantCondition((Macro) r, l); | public final Object build(BuildContext pc) throws BuildException { Object l, r; l = _l.build(pc); r = _r.build(pc); boolean lcond = (l instanceof Condition); boolean rcond = (r instanceof Condition); if (!lcond && !rcond) { if ((l == null) || (r == null)) { return (l == r) ? Boolean.TRUE : Boolean.FALSE; } else { return (l.equals(r)) ? Boolean.TRUE : Boolean.FALSE; } } if (lcond && rcond) { return new EqualCondition((Condition) l, (Condition) r); } if (lcond) { return new EqualConstantCondition((Condition) l, r); } else { return new EqualConstantCondition((Condition) r, l); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
EqualConstantCondition(Condition l, Object r) { _l = l; _r = r; } | EqualConstantCondition(Macro l, Object r) { _l = l; _r = r; } | EqualConstantCondition(Condition l, Object r) { _l = l; _r = r; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
try { left = _l.evaluate(context); } catch (Exception e) { left = null; } | try { left = _l.evaluate(context); } catch (Exception e) { left = null; } | public final boolean test(Object context) { Object left; try { left = _l.evaluate(context); } catch (Exception e) { left = null; } if ((left == null) || (_r == null)) { return (left == _r); } return left.equals(_r); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/4e82bcbfa0293596ccebd7abff0c093e9937d6ba/EqualConditionBuilder.java/buggy/webmacro/src/org/webmacro/engine/EqualConditionBuilder.java |
state.setResult(state.runtime.getObject().getConstant(iVisited.getName())); | state.setResult(state.runtime.getObject().getConstantFrom(iVisited.getName())); | public void execute(EvaluationState state, InstructionContext ctx) { Colon2Node iVisited = (Colon2Node)ctx; Node leftNode = iVisited.getLeftNode(); // TODO: Made this more colon3 friendly because of cpath production // rule in grammar (it is convenient to think of them as the same thing // at a grammar level even though evaluation is). if (leftNode == null) { state.setResult(state.runtime.getObject().getConstant(iVisited.getName())); } else { state.clearResult(); state.addInstruction(ctx, colon2NodeVisitor1); state.addNodeInstruction(iVisited.getLeftNode()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.setResult(((RubyModule) state.getResult()).getConstantAtOrConstantMissing(iVisited.getName())); | state.setResult(((RubyModule) state.getResult()).getConstantFrom(iVisited.getName())); | public void execute(EvaluationState state, InstructionContext ctx) { Colon2Node iVisited = (Colon2Node)ctx; if (state.getResult() instanceof RubyModule) { state.setResult(((RubyModule) state.getResult()).getConstantAtOrConstantMissing(iVisited.getName())); } else { state.setResult(state.getResult().callMethod(iVisited.getName())); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.setResult(state.runtime.getObject().getConstant(iVisited.getName())); | state.setResult(state.runtime.getObject().getConstantFrom(iVisited.getName())); | public void execute(EvaluationState state, InstructionContext ctx) { Colon3Node iVisited = (Colon3Node)ctx; state.setResult(state.runtime.getObject().getConstant(iVisited.getName())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.getThreadContext().getRubyClass().setConstant(iVisited.getName(), state.getResult()); | ((RubyModule)state.getThreadContext().peekCRef().getValue()).setConstant(iVisited.getName(), state.getResult()); | public void execute(EvaluationState state, InstructionContext ctx) { ConstDeclNode iVisited = (ConstDeclNode)ctx; state.getThreadContext().getRubyClass().setConstant(iVisited.getName(), state.getResult()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.setResult(state.getThreadContext().getRubyClass().getConstant(iVisited.getName())); | state.setResult(state.getThreadContext().getConstant(iVisited.getName())); | public void execute(EvaluationState state, InstructionContext ctx) { ConstNode iVisited = (ConstNode)ctx; state.setResult(state.getThreadContext().getRubyClass().getConstant(iVisited.getName())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.getThreadContext().getRubyClass()); | state.getThreadContext().peekCRef()); | public void execute(EvaluationState state, InstructionContext ctx) { DefnNode iVisited = (DefnNode)ctx; RubyModule containingClass = state.getThreadContext().getRubyClass(); if (containingClass == null) { throw state.runtime.newTypeError("No class to add method."); } String name = iVisited.getName(); if (containingClass == state.runtime.getObject() && name.equals("initialize")) { state.runtime.getWarnings().warn("redefining Object#initialize may cause infinite loop"); } Visibility visibility = state.getThreadContext().getCurrentVisibility(); if (name.equals("initialize") || visibility.isModuleFunction()) { visibility = Visibility.PRIVATE; } else if (visibility.isPublic() && containingClass == state.runtime.getObject()) { visibility = iVisited.getVisibility(); } DefaultMethod newMethod = new DefaultMethod(containingClass, iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), visibility, state.getThreadContext().getRubyClass()); iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); containingClass.addMethod(name, newMethod); if (state.getThreadContext().getCurrentVisibility().isModuleFunction()) { containingClass.getSingletonClass().addMethod(name, new WrapperCallable(containingClass.getSingletonClass(), newMethod, Visibility.PUBLIC)); containingClass.callMethod("singleton_method_added", state.runtime.newSymbol(name)); } // 'class << state.self' and 'class << obj' uses defn as opposed to defs if (containingClass.isSingleton()) { ((MetaClass)containingClass).getAttachedObject().callMethod("singleton_method_added", state.runtime.newSymbol(iVisited.getName())); } else { containingClass.callMethod("method_added", state.runtime.newSymbol(name)); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
state.getThreadContext().getRubyClass()); | state.getThreadContext().peekCRef()); | public void execute(EvaluationState state, InstructionContext ctx) { DefsNode iVisited = (DefsNode)ctx; IRubyObject receiver = state.begin(iVisited.getReceiverNode()); if (state.runtime.getSafeLevel() >= 4 && !receiver.isTaint()) { throw state.runtime.newSecurityError("Insecure; can't define singleton method."); } if (receiver.isFrozen()) { throw state.runtime.newFrozenError("object"); } if (! receiver.singletonMethodsAllowed()) { throw state.runtime.newTypeError("can't define singleton method \"" + iVisited.getName() + "\" for " + receiver.getType()); } RubyClass rubyClass = receiver.getSingletonClass(); if (state.runtime.getSafeLevel() >= 4) { ICallable method = (ICallable) rubyClass.getMethods().get(iVisited.getName()); if (method != null) { throw state.runtime.newSecurityError("Redefining method prohibited."); } } DefaultMethod newMethod = new DefaultMethod(rubyClass, iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), Visibility.PUBLIC, state.getThreadContext().getRubyClass()); iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); rubyClass.addMethod(iVisited.getName(), newMethod); receiver.callMethod("singleton_method_added", state.runtime.newSymbol(iVisited.getName())); state.clearResult(); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/EvaluateVisitor.java/buggy/src/org/jruby/evaluator/EvaluateVisitor.java |
public SetDirective(Variable target, Object result) { this.target = target; this.result = result; } | public SetDirective() {} | public SetDirective(Variable target, Object result) { this.target = target; this.result = result; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/b96772967b07b6666a64ce480011c23dd7bdb94b/SetDirective.java/buggy/webmacro/src/org/webmacro/directive/SetDirective.java |
public RubyClass defineClass(String name, RubyClass superClass) { if (superClass == null) { superClass = getClasses().getObjectClass(); } RubyClass newClass = RubyClass.newClass(this, superClass, name); newClass.makeMetaClass(superClass.getMetaClass()); newClass.inheritedBy(superClass); classes.putClass(name, newClass); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/fffe7aa25510c5fa1f975232bea0ef0fd24762d7/Ruby.java/buggy/src/org/jruby/Ruby.java |
||
public RubyClass defineClass(String name, RubyClass superClass) { if (superClass == null) { superClass = getClasses().getObjectClass(); } RubyClass newClass = RubyClass.newClass(this, superClass, name); newClass.makeMetaClass(superClass.getMetaClass()); newClass.inheritedBy(superClass); classes.putClass(name, newClass); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/fffe7aa25510c5fa1f975232bea0ef0fd24762d7/Ruby.java/buggy/src/org/jruby/Ruby.java |
||
public RubyClass defineClass(String name, RubyClass superClass) { if (superClass == null) { superClass = getClasses().getObjectClass(); } RubyClass newClass = RubyClass.newClass(this, superClass, name); newClass.makeMetaClass(superClass.getMetaClass()); newClass.inheritedBy(superClass); classes.putClass(name, newClass); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/fffe7aa25510c5fa1f975232bea0ef0fd24762d7/Ruby.java/buggy/src/org/jruby/Ruby.java |
||
public RubyClass defineClass(String name, RubyClass superClass) { if (superClass == null) { superClass = getClasses().getObjectClass(); } RubyClass newClass = RubyClass.newClass(this, superClass, name); newClass.makeMetaClass(superClass.getMetaClass()); newClass.inheritedBy(superClass); classes.putClass(name, newClass); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/fffe7aa25510c5fa1f975232bea0ef0fd24762d7/Ruby.java/buggy/src/org/jruby/Ruby.java |
||
qf = new QueryFactory(); | protected void setUp() throws Exception { super.setUp(); qf = new QueryFactory(); impl = new PojosImpl(); impl.setQueryFactory( qf ); ProxyFactory factory = new ProxyFactory(impl); factory.addAdvice(new ServiceHandler()); manager = (IPojos) factory.getProxy(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/59b11883b95c926d6706e6d30b4cdb898088683c/PojosConstraintsTest.java/clean/components/server/test/ome/server/utests/PojosConstraintsTest.java |
|
impl.setQueryFactory( qf ); | protected void setUp() throws Exception { super.setUp(); qf = new QueryFactory(); impl = new PojosImpl(); impl.setQueryFactory( qf ); ProxyFactory factory = new ProxyFactory(impl); factory.addAdvice(new ServiceHandler()); manager = (IPojos) factory.getProxy(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/59b11883b95c926d6706e6d30b4cdb898088683c/PojosConstraintsTest.java/clean/components/server/test/ome/server/utests/PojosConstraintsTest.java |
|
t.blowup(false,new PojoOptions().exp(1L).map()); | public void testGetUserImages() throws Exception { T t = new T(ApiUsageException.class){ @Override public void doTest(Object[] arg) { manager.getUserImages((Map)arg[0]); } }; t.blowup(true,new PojoOptions().allExps().map()); t.blowup(false,new PojoOptions().exp(1L).map()); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/59b11883b95c926d6706e6d30b4cdb898088683c/PojosConstraintsTest.java/clean/components/server/test/ome/server/utests/PojosConstraintsTest.java |
|
.addIds(null) | .addIds(Arrays.asList( doesntExist )) | public void test_simple_usage() throws Exception { Long doesntExist = -1L; q= new PojosLoadHierarchyQueryDefinition( new Parameters() .addIds(Arrays.asList( doesntExist )) .addOptions(null) .addClass(Project.class) ); list = (List) iQuery.execute(q); PojoOptions po = new PojoOptions().exp( doesntExist ); q= new PojosLoadHierarchyQueryDefinition( new Parameters() .addIds(null) .addOptions(po.map()) .addClass(Project.class) ); list = (List) iQuery.execute(q); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/0039ef3c66932163f0ec9bfa2b7f37eaa70abe47/LoadContainersQueryTest.java/clean/components/server/test/ome/server/itests/query/LoadContainersQueryTest.java |
active = false; | 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)); initBars(registry, maxT, defaultT, maxZ, defaultZ); initSliders(maxT, defaultT, maxZ, defaultZ); initContainers(); buildGUI(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
|
int maxT = pxsDims.sizeT-1; int maxZ = pxsDims.sizeZ-1; | windowWidth = DEFAULT_WINDOW_SIZE; windowHeight = DEFAULT_WINDOW_SIZE; active = false; int maxT = pxsDims.sizeT-1, maxZ = pxsDims.sizeZ-1; | 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)); initBars(registry, maxT, defaultT, maxZ, defaultZ); initSliders(maxT, defaultT, maxZ, defaultZ); initContainers(); buildGUI(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
void resetLens() { canvas.resetLens(); } | void resetLens() { canvas.resetLens(); } | void resetLens() { canvas.resetLens(); //canvas.repaint(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
int maxZ = sizeZ-1; int maxT = sizeT-1; | int maxZ = sizeZ-1, maxT = sizeT-1; | 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, bZT = false; if (maxT != 0) bT = true; if (maxZ != 0) bZ = true; toolBar.getTField().setEditable(bT); toolBar.getZField().setEditable(bZ); toolBar.getViewer3D().setEnabled(bZ); if (bT || bZ) bZT = true; viewer3DItem.setEnabled(bZ); toolBar.getMovie().setEnabled(bZT); movieItem.setEnabled(bZT); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
int width = 7*(screenSize.width/10); int height = 7*(screenSize.height/10); | int width = 8*(screenSize.width/10); int height = 8*(screenSize.height/10); | private void setWindowSize(int w, int h) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = 7*(screenSize.width/10); int height = 7*(screenSize.height/10); if (w > width) w = width; if (h > height) h = height; setSize(w, h); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
setSize(w, h); | windowWidth = w; windowHeight = h; | private void setWindowSize(int w, int h) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = 7*(screenSize.width/10); int height = 7*(screenSize.height/10); if (w > width) w = width; if (h > height) h = height; setSize(w, h); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/cf83d7e74fdf42d9c4357c3e575c08395991a878/ViewerUIF.java/buggy/SRC/org/openmicroscopy/shoola/agents/viewer/ViewerUIF.java |
ColorMapModel cml = new ColorMapModel(model); ColorMapManager cmm = env.getColorMapManager(); cmm.putColorMapModel(cml); cmm.updateModel(); | public void handle(RequestEvent request, ResponseEvent response) { if(!(request instanceof LoadCategories) || !(response instanceof CategoriesChanged)) { System.err.println("Invalid ACT types for CategoryChangeHandler"); return; } System.err.println("handling complete in CCH"); LoadCategories lc = (LoadCategories)request; CategoriesChanged cc = (CategoriesChanged)response; if(!cc.isDirty()) return; // no changes to be made BrowserEnvironment env = BrowserEnvironment.getInstance(); BrowserManager manager = env.getBrowserManager(); List browserList = manager.getAllBrowsers(); System.err.println("checking browsers"); for(Iterator iter = browserList.iterator(); iter.hasNext();) { UIWrapper wrapper = (UIWrapper)iter.next(); BrowserController controller = wrapper.getController(); BrowserModel model = controller.getBrowserModel(); int browserID = model.getDataset().getID(); if(browserID == cc.getDatasetID()) { System.err.println("found browser"); BrowserAgent agent = env.getBrowserAgent(); model.setCategoryTree(agent.loadCategoryTree(browserID)); model.fireModelUpdated(); } } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/0e4e3c4b5f21d2217fc02b1e6846dac6de60570f/CategoryChangeHandler.java/buggy/SRC/org/openmicroscopy/shoola/agents/browser/events/CategoryChangeHandler.java |
|
else if (!postedAdd) closePresentation(); postedAdd = false; | private void handleAddROICanvas(AddROICanvas response) { if (response.isOnOff()) bringUpPresentation(); else if (!postedAdd) closePresentation(); postedAdd = false; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/5cbb9d6f888b330df5f864404990e547ea4b385a/ROIAgt.java/clean/SRC/org/openmicroscopy/shoola/agents/roi/ROIAgt.java |
|
singletonClass = runtime.getClass("True"); | singletonClass = runtime.getClass("TrueClass"); | private static IRubyObject evalInternal(ThreadContext context, Node node, IRubyObject self) { IRuby runtime = context.getRuntime(); bigloop: do { if (node == null) return runtime.getNil(); switch (node.nodeId) { case NodeTypes.ALIASNODE: { AliasNode iVisited = (AliasNode) node; if (context.getRubyClass() == null) { throw runtime.newTypeError("no class to make alias"); } context.getRubyClass().defineAlias(iVisited.getNewName(), iVisited.getOldName()); context.getRubyClass().callMethod(context, "method_added", runtime.newSymbol(iVisited.getNewName())); return runtime.getNil(); } case NodeTypes.ANDNODE: { BinaryOperatorNode iVisited = (BinaryOperatorNode) node; IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) return result; node = iVisited.getSecondNode(); continue bigloop; } case NodeTypes.ARGSCATNODE: { ArgsCatNode iVisited = (ArgsCatNode) node; IRubyObject args = evalInternal(context, iVisited.getFirstNode(), self); IRubyObject secondArgs = splatValue(evalInternal(context, iVisited.getSecondNode(), self)); RubyArray list = args instanceof RubyArray ? (RubyArray) args : runtime.newArray(args); return list.concat(secondArgs); } // case NodeTypes.ARGSNODE: // EvaluateVisitor.argsNodeVisitor.execute(this, node); // break; // case NodeTypes.ARGUMENTNODE: // EvaluateVisitor.argumentNodeVisitor.execute(this, node); // break; case NodeTypes.ARRAYNODE: { ArrayNode iVisited = (ArrayNode) node; IRubyObject[] array = new IRubyObject[iVisited.size()]; int i = 0; for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node next = (Node) iterator.next(); array[i++] = evalInternal(context, next, self); } return runtime.newArray(array); } // case NodeTypes.ASSIGNABLENODE: // EvaluateVisitor.assignableNodeVisitor.execute(this, node); // break; case NodeTypes.BACKREFNODE: { BackRefNode iVisited = (BackRefNode) node; IRubyObject backref = context.getBackref(); switch (iVisited.getType()) { case '~': return backref; case '&': return RubyRegexp.last_match(backref); case '`': return RubyRegexp.match_pre(backref); case '\'': return RubyRegexp.match_post(backref); case '+': return RubyRegexp.match_last(backref); } break; } case NodeTypes.BEGINNODE: { BeginNode iVisited = (BeginNode) node; node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.BIGNUMNODE: { BignumNode iVisited = (BignumNode) node; return RubyBignum.newBignum(runtime, iVisited.getValue()); } // case NodeTypes.BINARYOPERATORNODE: // EvaluateVisitor.binaryOperatorNodeVisitor.execute(this, node); // break; // case NodeTypes.BLOCKARGNODE: // EvaluateVisitor.blockArgNodeVisitor.execute(this, node); // break; case NodeTypes.BLOCKNODE: { BlockNode iVisited = (BlockNode) node; IRubyObject result = runtime.getNil(); for (Iterator iter = iVisited.iterator(); iter.hasNext();) { result = evalInternal(context, (Node) iter.next(), self); } return result; } case NodeTypes.BLOCKPASSNODE: { BlockPassNode iVisited = (BlockPassNode) node; IRubyObject proc = evalInternal(context, iVisited.getBodyNode(), self); if (proc.isNil()) { context.setNoBlock(); try { return evalInternal(context, iVisited.getIterNode(), self); } finally { context.clearNoBlock(); } } // If not already a proc then we should try and make it one. if (!(proc instanceof RubyProc)) { proc = proc.convertToType("Proc", "to_proc", false); if (!(proc instanceof RubyProc)) { throw runtime.newTypeError("wrong argument type " + proc.getMetaClass().getName() + " (expected Proc)"); } } // TODO: Add safety check for taintedness Block block = (Block) context.getCurrentBlock(); if (block != null) { IRubyObject blockObject = block.getBlockObject(); // The current block is already associated with the proc. No need to create new // block for it. Just eval! if (blockObject != null && blockObject == proc) { try { context.setBlockAvailable(); return evalInternal(context, iVisited.getIterNode(), self); } finally { context.clearBlockAvailable(); } } } context.preBlockPassEval(((RubyProc) proc).getBlock()); try { return evalInternal(context, iVisited.getIterNode(), self); } finally { context.postBlockPassEval(); } } case NodeTypes.BREAKNODE: { BreakNode iVisited = (BreakNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); JumpException je = new JumpException(JumpException.JumpType.BreakJump); je.setPrimaryData(result); je.setSecondaryData(node); throw je; } case NodeTypes.CALLNODE: { CallNode iVisited = (CallNode) node; context.beginCallArgs(); IRubyObject receiver = null; IRubyObject[] args = null; try { receiver = evalInternal(context, iVisited.getReceiverNode(), self); args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } assert receiver.getMetaClass() != null : receiver.getClass().getName(); // If reciever is self then we do the call the same way as vcall CallType callType = (receiver == self ? CallType.VARIABLE : CallType.NORMAL); return receiver.callMethod(context, iVisited.getName(), args, callType); } case NodeTypes.CASENODE: { CaseNode iVisited = (CaseNode) node; IRubyObject expression = null; if (iVisited.getCaseNode() != null) { expression = evalInternal(context, iVisited.getCaseNode(), self); } context.pollThreadEvents(); IRubyObject result = runtime.getNil(); Node firstWhenNode = iVisited.getFirstWhenNode(); while (firstWhenNode != null) { if (!(firstWhenNode instanceof WhenNode)) { node = firstWhenNode; continue bigloop; } WhenNode whenNode = (WhenNode) firstWhenNode; if (whenNode.getExpressionNodes() instanceof ArrayNode) { for (Iterator iter = ((ArrayNode) whenNode.getExpressionNodes()).iterator(); iter .hasNext();) { Node tag = (Node) iter.next(); context.setPosition(tag.getPosition()); if (isTrace(runtime)) { callTraceFunction(context, "line", self); } // Ruby grammar has nested whens in a case body because of // productions case_body and when_args. if (tag instanceof WhenNode) { RubyArray expressions = (RubyArray) evalInternal(context, ((WhenNode) tag) .getExpressionNodes(), self); for (int j = 0; j < expressions.getLength(); j++) { IRubyObject condition = expressions.entry(j); if ((expression != null && condition.callMethod(context, "===", expression) .isTrue()) || (expression == null && condition.isTrue())) { node = ((WhenNode) firstWhenNode).getBodyNode(); continue bigloop; } } continue; } result = evalInternal(context, tag, self); if ((expression != null && result.callMethod(context, "===", expression).isTrue()) || (expression == null && result.isTrue())) { node = whenNode.getBodyNode(); continue bigloop; } } } else { result = evalInternal(context, whenNode.getExpressionNodes(), self); if ((expression != null && result.callMethod(context, "===", expression).isTrue()) || (expression == null && result.isTrue())) { node = ((WhenNode) firstWhenNode).getBodyNode(); continue bigloop; } } context.pollThreadEvents(); firstWhenNode = whenNode.getNextCase(); } return runtime.getNil(); } case NodeTypes.CLASSNODE: { ClassNode iVisited = (ClassNode) node; Node superNode = iVisited.getSuperNode(); RubyClass superClass = superNode == null ? null : (RubyClass) evalInternal(context, superNode, self); Node classNameNode = iVisited.getCPath(); String name = ((INameNode) classNameNode).getName(); RubyModule enclosingClass = getEnclosingModule(context, classNameNode, self); RubyClass rubyClass = enclosingClass.defineOrGetClassUnder(name, superClass); if (context.getWrapper() != null) { rubyClass.extendObject(context.getWrapper()); rubyClass.includeModule(context.getWrapper()); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), rubyClass, self); } case NodeTypes.CLASSVARASGNNODE: { ClassVarAsgnNode iVisited = (ClassVarAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); RubyModule rubyClass = (RubyModule) context.peekCRef().getValue(); if (rubyClass == null) { rubyClass = self.getMetaClass(); } else if (rubyClass.isSingleton()) { rubyClass = (RubyModule) rubyClass.getInstanceVariable("__attached__"); } rubyClass.setClassVar(iVisited.getName(), result); return result; } case NodeTypes.CLASSVARDECLNODE: { ClassVarDeclNode iVisited = (ClassVarDeclNode) node; // FIXME: shouldn't we use cref here? if (context.getRubyClass() == null) { throw runtime.newTypeError("no class/module to define class variable"); } IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); ((RubyModule) context.peekCRef().getValue()).setClassVar(iVisited.getName(), result); return runtime.getNil(); } case NodeTypes.CLASSVARNODE: { ClassVarNode iVisited = (ClassVarNode) node; RubyModule rubyClass = (RubyModule) context.peekCRef().getValue(); if (rubyClass == null) { rubyClass = self.getMetaClass(); } else if (rubyClass.isSingleton()) { rubyClass = (RubyModule)rubyClass.getInstanceVariable("__attached__"); } return rubyClass.getClassVar(iVisited.getName()); } case NodeTypes.COLON2NODE: { Colon2Node iVisited = (Colon2Node) node; Node leftNode = iVisited.getLeftNode(); // TODO: Made this more colon3 friendly because of cpath production // rule in grammar (it is convenient to think of them as the same thing // at a grammar level even though evaluation is). if (leftNode == null) { return runtime.getObject().getConstantFrom(iVisited.getName()); } else { IRubyObject result = evalInternal(context, iVisited.getLeftNode(), self); if (result instanceof RubyModule) { return ((RubyModule) result).getConstantFrom(iVisited.getName()); } else { return result.callMethod(context, iVisited.getName()); } } } case NodeTypes.COLON3NODE: { Colon3Node iVisited = (Colon3Node) node; return runtime.getObject().getConstantFrom(iVisited.getName()); } case NodeTypes.CONSTDECLNODE: { ConstDeclNode iVisited = (ConstDeclNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); IRubyObject module; if (iVisited.getPathNode() != null) { module = evalInternal(context, iVisited.getPathNode(), self); } else { // FIXME: why do we check RubyClass and then use CRef? if (context.getRubyClass() == null) { // TODO: wire into new exception handling mechanism throw runtime.newTypeError("no class/module to define constant"); } module = (RubyModule) context.peekCRef().getValue(); } // FIXME: shouldn't we use the result of this set in setResult? ((RubyModule) module).setConstant(iVisited.getName(), result); return result; } case NodeTypes.CONSTNODE: { ConstNode iVisited = (ConstNode) node; return context.getConstant(iVisited.getName()); } case NodeTypes.DASGNNODE: { DAsgnNode iVisited = (DAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // System.out.println("DSetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth() + " and set " + result); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } case NodeTypes.DEFINEDNODE: { DefinedNode iVisited = (DefinedNode) node; String definition = getDefinition(context, iVisited.getExpressionNode(), self); if (definition != null) { return runtime.newString(definition); } else { return runtime.getNil(); } } case NodeTypes.DEFNNODE: { DefnNode iVisited = (DefnNode) node; RubyModule containingClass = context.getRubyClass(); if (containingClass == null) { throw runtime.newTypeError("No class to add method."); } String name = iVisited.getName(); if (containingClass == runtime.getObject() && name.equals("initialize")) { runtime.getWarnings().warn("redefining Object#initialize may cause infinite loop"); } Visibility visibility = context.getCurrentVisibility(); if (name.equals("initialize") || visibility.isModuleFunction()) { visibility = Visibility.PRIVATE; } DefaultMethod newMethod = new DefaultMethod(containingClass, iVisited.getScope(), iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), visibility, context.peekCRef()); if (iVisited.getBodyNode() != null) { iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); } containingClass.addMethod(name, newMethod); if (context.getCurrentVisibility().isModuleFunction()) { containingClass.getSingletonClass().addMethod( name, new WrapperCallable(containingClass.getSingletonClass(), newMethod, Visibility.PUBLIC)); containingClass.callMethod(context, "singleton_method_added", runtime.newSymbol(name)); } // 'class << state.self' and 'class << obj' uses defn as opposed to defs if (containingClass.isSingleton()) { ((MetaClass) containingClass).getAttachedObject().callMethod( context, "singleton_method_added", runtime.newSymbol(iVisited.getName())); } else { containingClass.callMethod(context, "method_added", runtime.newSymbol(name)); } return runtime.getNil(); } case NodeTypes.DEFSNODE: { DefsNode iVisited = (DefsNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); if (runtime.getSafeLevel() >= 4 && !receiver.isTaint()) { throw runtime.newSecurityError("Insecure; can't define singleton method."); } if (receiver.isFrozen()) { throw runtime.newFrozenError("object"); } if (!receiver.singletonMethodsAllowed()) { throw runtime.newTypeError("can't define singleton method \"" + iVisited.getName() + "\" for " + receiver.getType()); } RubyClass rubyClass = receiver.getSingletonClass(); if (runtime.getSafeLevel() >= 4) { ICallable method = (ICallable) rubyClass.getMethods().get(iVisited.getName()); if (method != null) { throw runtime.newSecurityError("Redefining method prohibited."); } } DefaultMethod newMethod = new DefaultMethod(rubyClass, iVisited.getScope(), iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), Visibility.PUBLIC, context.peekCRef()); if (iVisited.getBodyNode() != null) { iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); } rubyClass.addMethod(iVisited.getName(), newMethod); receiver.callMethod(context, "singleton_method_added", runtime.newSymbol(iVisited.getName())); return runtime.getNil(); } case NodeTypes.DOTNODE: { DotNode iVisited = (DotNode) node; return RubyRange.newRange(runtime, evalInternal(context, iVisited.getBeginNode(), self), evalInternal(context, iVisited .getEndNode(), self), iVisited.isExclusive()); } case NodeTypes.DREGEXPNODE: { DRegexpNode iVisited = (DRegexpNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return RubyRegexp.newRegexp(runtime, sb.toString(), iVisited.getOptions(), null); } case NodeTypes.DSTRNODE: { DStrNode iVisited = (DStrNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return runtime.newString(sb.toString()); } case NodeTypes.DSYMBOLNODE: { DSymbolNode iVisited = (DSymbolNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.getNode().iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return runtime.newSymbol(sb.toString()); } case NodeTypes.DVARNODE: { DVarNode iVisited = (DVarNode) node; // System.out.println("DGetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth()); IRubyObject obj = context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()); // FIXME: null check is removable once we figure out how to assign to unset named block args return obj == null ? runtime.getNil() : obj; } case NodeTypes.DXSTRNODE: { DXStrNode iVisited = (DXStrNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return self.callMethod(context, "`", runtime.newString(sb.toString())); } case NodeTypes.ENSURENODE: { EnsureNode iVisited = (EnsureNode) node; // save entering the try if there's nothing to ensure if (iVisited.getEnsureNode() != null) { IRubyObject result = runtime.getNil(); try { result = evalInternal(context, iVisited.getBodyNode(), self); } finally { evalInternal(context, iVisited.getEnsureNode(), self); } return result; } node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.EVSTRNODE: { EvStrNode iVisited = (EvStrNode) node; node = iVisited.getBody(); continue bigloop; } case NodeTypes.FALSENODE: { context.pollThreadEvents(); return runtime.getFalse(); } case NodeTypes.FCALLNODE: { FCallNode iVisited = (FCallNode) node; context.beginCallArgs(); IRubyObject[] args; try { args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } return self.callMethod(context, iVisited.getName(), args, CallType.FUNCTIONAL); } case NodeTypes.FIXNUMNODE: { FixnumNode iVisited = (FixnumNode) node; return runtime.newFixnum(iVisited.getValue()); } case NodeTypes.FLIPNODE: { FlipNode iVisited = (FlipNode) node; IRubyObject result = runtime.getNil(); if (iVisited.isExclusive()) { if (!context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()).isTrue()) { result = evalInternal(context, iVisited.getBeginNode(), self).isTrue() ? runtime.getFalse() : runtime.getTrue(); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } else { if (evalInternal(context, iVisited.getEndNode(), self).isTrue()) { context.getCurrentScope().setValue(iVisited.getIndex(), runtime.getFalse(), iVisited.getDepth()); } return runtime.getTrue(); } } else { if (!context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()).isTrue()) { if (evalInternal(context, iVisited.getBeginNode(), self).isTrue()) { context.getCurrentScope().setValue( iVisited.getIndex(), evalInternal(context, iVisited.getEndNode(), self).isTrue() ? runtime.getFalse() : runtime.getTrue(), iVisited.getDepth()); return runtime.getTrue(); } else { return runtime.getFalse(); } } else { if (evalInternal(context, iVisited.getEndNode(), self).isTrue()) { context.getCurrentScope().setValue(iVisited.getIndex(), runtime.getFalse(), iVisited.getDepth()); } return runtime.getTrue(); } } } case NodeTypes.FLOATNODE: { FloatNode iVisited = (FloatNode) node; return RubyFloat.newFloat(runtime, iVisited.getValue()); } case NodeTypes.FORNODE: { ForNode iVisited = (ForNode) node; // For nodes do not have to create an addition scope so we just pass null context.preForLoopEval(Block.createBlock(iVisited.getVarNode(), null, iVisited.getCallable(), self)); try { while (true) { try { ISourcePosition position = context.getPosition(); context.beginCallArgs(); IRubyObject recv = null; try { recv = evalInternal(context, iVisited.getIterNode(), self); } finally { context.setPosition(position); context.endCallArgs(); } return recv.callMethod(context, "each", IRubyObject.NULL_ARRAY, CallType.NORMAL); } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.RETRY: // do nothing, allow loop to retry break; default: throw je; } } } } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.BREAK: IRubyObject breakValue = (IRubyObject) je.getPrimaryData(); return breakValue == null ? runtime.getNil() : breakValue; default: throw je; } } finally { context.postForLoopEval(); } } case NodeTypes.GLOBALASGNNODE: { GlobalAsgnNode iVisited = (GlobalAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); runtime.getGlobalVariables().set(iVisited.getName(), result); return result; } case NodeTypes.GLOBALVARNODE: { GlobalVarNode iVisited = (GlobalVarNode) node; return runtime.getGlobalVariables().get(iVisited.getName()); } case NodeTypes.HASHNODE: { HashNode iVisited = (HashNode) node; Map hash = null; if (iVisited.getListNode() != null) { hash = new HashMap(iVisited.getListNode().size() / 2); for (Iterator iterator = iVisited.getListNode().iterator(); iterator.hasNext();) { // insert all nodes in sequence, hash them in the final instruction // KEY IRubyObject key = evalInternal(context, (Node) iterator.next(), self); IRubyObject value = evalInternal(context, (Node) iterator.next(), self); hash.put(key, value); } } if (hash == null) { return RubyHash.newHash(runtime); } return RubyHash.newHash(runtime, hash, runtime.getNil()); } case NodeTypes.IFNODE: { IfNode iVisited = (IfNode) node; IRubyObject result = evalInternal(context, iVisited.getCondition(), self); if (result.isTrue()) { node = iVisited.getThenBody(); continue bigloop; } else { node = iVisited.getElseBody(); continue bigloop; } } case NodeTypes.INSTASGNNODE: { InstAsgnNode iVisited = (InstAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); self.setInstanceVariable(iVisited.getName(), result); return result; } case NodeTypes.INSTVARNODE: { InstVarNode iVisited = (InstVarNode) node; IRubyObject variable = self.getInstanceVariable(iVisited.getName()); return variable == null ? runtime.getNil() : variable; } // case NodeTypes.ISCOPINGNODE: // EvaluateVisitor.iScopingNodeVisitor.execute(this, node); // break; case NodeTypes.ITERNODE: { IterNode iVisited = (IterNode) node; context.preIterEval(Block.createBlock(iVisited.getVarNode(), new DynamicScope(iVisited.getScope(), context.getCurrentScope()), iVisited.getCallable(), self)); try { while (true) { try { context.setBlockAvailable(); return evalInternal(context, iVisited.getIterNode(), self); } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.RETRY: // allow loop to retry break; default: throw je; } } finally { context.clearBlockAvailable(); } } } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.BREAK: IRubyObject breakValue = (IRubyObject) je.getPrimaryData(); return breakValue == null ? runtime.getNil() : breakValue; default: throw je; } } finally { context.postIterEval(); } } case NodeTypes.LOCALASGNNODE: { LocalAsgnNode iVisited = (LocalAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // System.out.println("LSetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth() + " and set " + result); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } case NodeTypes.LOCALVARNODE: { LocalVarNode iVisited = (LocalVarNode) node; //System.out.println("DGetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth()); IRubyObject result = context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()); return result == null ? runtime.getNil() : result; } case NodeTypes.MATCH2NODE: { Match2Node iVisited = (Match2Node) node; IRubyObject recv = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = evalInternal(context, iVisited.getValueNode(), self); return ((RubyRegexp) recv).match(value); } case NodeTypes.MATCH3NODE: { Match3Node iVisited = (Match3Node) node; IRubyObject recv = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = evalInternal(context, iVisited.getValueNode(), self); if (value instanceof RubyString) { return ((RubyRegexp) recv).match(value); } else { return value.callMethod(context, "=~", recv); } } case NodeTypes.MATCHNODE: { MatchNode iVisited = (MatchNode) node; return ((RubyRegexp) evalInternal(context, iVisited.getRegexpNode(), self)).match2(); } case NodeTypes.MODULENODE: { ModuleNode iVisited = (ModuleNode) node; Node classNameNode = iVisited.getCPath(); String name = ((INameNode) classNameNode).getName(); RubyModule enclosingModule = getEnclosingModule(context, classNameNode, self); if (enclosingModule == null) { throw runtime.newTypeError("no outer class/module"); } RubyModule module; if (enclosingModule == runtime.getObject()) { module = runtime.getOrCreateModule(name); } else { module = enclosingModule.defineModuleUnder(name); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), module, self); } case NodeTypes.MULTIPLEASGNNODE: { MultipleAsgnNode iVisited = (MultipleAsgnNode) node; return AssignmentVisitor.assign(context, self, iVisited, evalInternal(context, iVisited.getValueNode(), self), false); } case NodeTypes.NEWLINENODE: { NewlineNode iVisited = (NewlineNode) node; // something in here is used to build up ruby stack trace... context.setPosition(iVisited.getPosition()); if (isTrace(runtime)) { callTraceFunction(context, "line", self); } // TODO: do above but not below for additional newline nodes node = iVisited.getNextNode(); continue bigloop; } case NodeTypes.NEXTNODE: { NextNode iVisited = (NextNode) node; context.pollThreadEvents(); IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // now used as an interpreter event JumpException je = new JumpException(JumpException.JumpType.NextJump); je.setPrimaryData(result); je.setSecondaryData(iVisited); //state.setCurrentException(je); throw je; } case NodeTypes.NILNODE: return runtime.getNil(); case NodeTypes.NOTNODE: { NotNode iVisited = (NotNode) node; IRubyObject result = evalInternal(context, iVisited.getConditionNode(), self); return result.isTrue() ? runtime.getFalse() : runtime.getTrue(); } case NodeTypes.NTHREFNODE: { NthRefNode iVisited = (NthRefNode) node; return RubyRegexp.nth_match(iVisited.getMatchNumber(), context.getBackref()); } case NodeTypes.OPASGNANDNODE: { BinaryOperatorNode iVisited = (BinaryOperatorNode) node; // add in reverse order IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) return result; node = iVisited.getSecondNode(); continue bigloop; } case NodeTypes.OPASGNNODE: { OpAsgnNode iVisited = (OpAsgnNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = receiver.callMethod(context, iVisited.getVariableName()); if (iVisited.getOperatorName().equals("||")) { if (value.isTrue()) { return value; } value = evalInternal(context, iVisited.getValueNode(), self); } else if (iVisited.getOperatorName().equals("&&")) { if (!value.isTrue()) { return value; } value = evalInternal(context, iVisited.getValueNode(), self); } else { value = value.callMethod(context, iVisited.getOperatorName(), evalInternal(context, iVisited.getValueNode(), self)); } receiver.callMethod(context, iVisited.getVariableName() + "=", value); context.pollThreadEvents(); return value; } case NodeTypes.OPASGNORNODE: { OpAsgnOrNode iVisited = (OpAsgnOrNode) node; String def = getDefinition(context, iVisited.getFirstNode(), self); IRubyObject result = runtime.getNil(); if (def != null) { result = evalInternal(context, iVisited.getFirstNode(), self); } if (!result.isTrue()) { result = evalInternal(context, iVisited.getSecondNode(), self); } return result; } case NodeTypes.OPELEMENTASGNNODE: { OpElementAsgnNode iVisited = (OpElementAsgnNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject[] args = setupArgs(context, iVisited.getArgsNode(), self); IRubyObject firstValue = receiver.callMethod(context, "[]", args); if (iVisited.getOperatorName().equals("||")) { if (firstValue.isTrue()) { return firstValue; } firstValue = evalInternal(context, iVisited.getValueNode(), self); } else if (iVisited.getOperatorName().equals("&&")) { if (!firstValue.isTrue()) { return firstValue; } firstValue = evalInternal(context, iVisited.getValueNode(), self); } else { firstValue = firstValue.callMethod(context, iVisited.getOperatorName(), evalInternal(context, iVisited .getValueNode(), self)); } IRubyObject[] expandedArgs = new IRubyObject[args.length + 1]; System.arraycopy(args, 0, expandedArgs, 0, args.length); expandedArgs[expandedArgs.length - 1] = firstValue; return receiver.callMethod(context, "[]=", expandedArgs); } case NodeTypes.OPTNNODE: { OptNNode iVisited = (OptNNode) node; IRubyObject result = runtime.getNil(); while (RubyKernel.gets(runtime.getTopSelf(), IRubyObject.NULL_ARRAY).isTrue()) { loop: while (true) { // Used for the 'redo' command try { result = evalInternal(context, iVisited.getBodyNode(), self); break; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: // do nothing, this iteration restarts break; case JumpType.NEXT: // recheck condition break loop; case JumpType.BREAK: // end loop return (IRubyObject) je.getPrimaryData(); default: throw je; } } } } return result; } case NodeTypes.ORNODE: { OrNode iVisited = (OrNode) node; IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) { result = evalInternal(context, iVisited.getSecondNode(), self); } return result; } // case NodeTypes.POSTEXENODE: // EvaluateVisitor.postExeNodeVisitor.execute(this, node); // break; case NodeTypes.REDONODE: { context.pollThreadEvents(); // now used as an interpreter event JumpException je = new JumpException(JumpException.JumpType.RedoJump); je.setSecondaryData(node); throw je; } case NodeTypes.REGEXPNODE: { RegexpNode iVisited = (RegexpNode) node; // FIXME: don't pass null return RubyRegexp.newRegexp(runtime, iVisited.getPattern(), null); } case NodeTypes.RESCUEBODYNODE: { RescueBodyNode iVisited = (RescueBodyNode) node; node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.RESCUENODE: { RescueNode iVisited = (RescueNode)node; RescuedBlock : while (true) { try { // Execute rescue block IRubyObject result = evalInternal(context, iVisited.getBodyNode(), self); // If no exception is thrown execute else block if (iVisited.getElseNode() != null) { if (iVisited.getRescueNode() == null) { runtime.getWarnings().warn(iVisited.getElseNode().getPosition(), "else without rescue is useless"); } result = evalInternal(context, iVisited.getElseNode(), self); } return result; } catch (RaiseException raiseJump) { RubyException raisedException = raiseJump.getException(); // TODO: Rubicon TestKernel dies without this line. A cursory glance implies we // falsely set $! to nil and this sets it back to something valid. This should // get fixed at the same time we address bug #1296484. runtime.getGlobalVariables().set("$!", raisedException); RescueBodyNode rescueNode = iVisited.getRescueNode(); while (rescueNode != null) { Node exceptionNodes = rescueNode.getExceptionNodes(); ListNode exceptionNodesList; if (exceptionNodes instanceof SplatNode) { exceptionNodesList = (ListNode) evalInternal(context, exceptionNodes, self); } else { exceptionNodesList = (ListNode) exceptionNodes; } if (isRescueHandled(context, raisedException, exceptionNodesList, self)) { try { return evalInternal(context, rescueNode, self); } catch (JumpException je) { if (je.getJumpType() == JumpException.JumpType.RetryJump) { // should be handled in the finally block below //state.runtime.getGlobalVariables().set("$!", state.runtime.getNil()); //state.threadContext.setRaisedException(null); continue RescuedBlock; } else { throw je; } } } rescueNode = rescueNode.getOptRescueNode(); } // no takers; bubble up throw raiseJump; } finally { // clear exception when handled or retried runtime.getGlobalVariables().set("$!", runtime.getNil()); } } } case NodeTypes.RETRYNODE: { context.pollThreadEvents(); JumpException je = new JumpException(JumpException.JumpType.RetryJump); throw je; } case NodeTypes.RETURNNODE: { ReturnNode iVisited = (ReturnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); JumpException je = new JumpException(JumpException.JumpType.ReturnJump); je.setPrimaryData(iVisited.getTarget()); je.setSecondaryData(result); je.setTertiaryData(iVisited); throw je; } case NodeTypes.ROOTNODE: { RootNode iVisited = (RootNode) node; DynamicScope scope = iVisited.getScope(); // Serialization killed our dynamic scope. We can just create an empty one // since serialization cannot serialize an eval (which is the only thing // which is capable of having a non-empty dynamic scope). if (scope == null) { scope = new DynamicScope(iVisited.getStaticScope(), null); } // Each root node has a top-level scope that we need to push context.preRootNode(scope); // FIXME: Wire up BEGIN and END nodes try { return eval(context, iVisited.getBodyNode(), self); } finally { context.postRootNode(); } } case NodeTypes.SCLASSNODE: { SClassNode iVisited = (SClassNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); RubyClass singletonClass; if (receiver.isNil()) { singletonClass = runtime.getNilClass(); } else if (receiver == runtime.getTrue()) { singletonClass = runtime.getClass("True"); } else if (receiver == runtime.getFalse()) { singletonClass = runtime.getClass("False"); } else { if (runtime.getSafeLevel() >= 4 && !receiver.isTaint()) { throw runtime.newSecurityError("Insecure: can't extend object."); } singletonClass = receiver.getSingletonClass(); } if (context.getWrapper() != null) { singletonClass.extendObject(context.getWrapper()); singletonClass.includeModule(context.getWrapper()); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), singletonClass, self); } case NodeTypes.SELFNODE: return self; case NodeTypes.SPLATNODE: { SplatNode iVisited = (SplatNode) node; return splatValue(evalInternal(context, iVisited.getValue(), self)); } //// case NodeTypes.STARNODE: //// EvaluateVisitor.starNodeVisitor.execute(this, node); //// break; case NodeTypes.STRNODE: { StrNode iVisited = (StrNode) node; return runtime.newString(iVisited.getValue()); } case NodeTypes.SUPERNODE: { SuperNode iVisited = (SuperNode) node; if (context.getFrameLastClass() == null) { throw runtime.newNameError("Superclass method '" + context.getFrameLastFunc() + "' disabled."); } context.beginCallArgs(); IRubyObject[] args = null; try { args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } return context.callSuper(args); } case NodeTypes.SVALUENODE: { SValueNode iVisited = (SValueNode) node; return aValueSplat(evalInternal(context, iVisited.getValue(), self)); } case NodeTypes.SYMBOLNODE: { SymbolNode iVisited = (SymbolNode) node; return runtime.newSymbol(iVisited.getName()); } case NodeTypes.TOARYNODE: { ToAryNode iVisited = (ToAryNode) node; return aryToAry(evalInternal(context, iVisited.getValue(), self)); } case NodeTypes.TRUENODE: { context.pollThreadEvents(); return runtime.getTrue(); } case NodeTypes.UNDEFNODE: { UndefNode iVisited = (UndefNode) node; if (context.getRubyClass() == null) { throw runtime .newTypeError("No class to undef method '" + iVisited.getName() + "'."); } context.getRubyClass().undef(iVisited.getName()); return runtime.getNil(); } case NodeTypes.UNTILNODE: { UntilNode iVisited = (UntilNode) node; IRubyObject result = runtime.getNil(); while (!(result = evalInternal(context, iVisited.getConditionNode(), self)).isTrue()) { loop: while (true) { // Used for the 'redo' command try { result = evalInternal(context, iVisited.getBodyNode(), self); break loop; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: continue; case JumpType.NEXT: break loop; case JumpType.BREAK: return (IRubyObject) je.getPrimaryData(); default: throw je; } } } } return result; } case NodeTypes.VALIASNODE: { VAliasNode iVisited = (VAliasNode) node; runtime.getGlobalVariables().alias(iVisited.getNewName(), iVisited.getOldName()); return runtime.getNil(); } case NodeTypes.VCALLNODE: { VCallNode iVisited = (VCallNode) node; return self.callMethod(context, iVisited.getName(), IRubyObject.NULL_ARRAY, CallType.VARIABLE); } case NodeTypes.WHENNODE: assert false; return null; case NodeTypes.WHILENODE: { WhileNode iVisited = (WhileNode) node; IRubyObject result = runtime.getNil(); boolean firstTest = iVisited.evaluateAtStart(); while (!firstTest || (result = evalInternal(context, iVisited.getConditionNode(), self)).isTrue()) { firstTest = true; loop: while (true) { // Used for the 'redo' command try { evalInternal(context, iVisited.getBodyNode(), self); break loop; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: continue; case JumpType.NEXT: break loop; case JumpType.BREAK: return result; default: throw je; } } } } return result; } case NodeTypes.XSTRNODE: { XStrNode iVisited = (XStrNode) node; return self.callMethod(context, "`", runtime.newString(iVisited.getValue())); } case NodeTypes.YIELDNODE: { YieldNode iVisited = (YieldNode) node; IRubyObject result = evalInternal(context, iVisited.getArgsNode(), self); if (iVisited.getArgsNode() == null) { result = null; } return context.yieldCurrentBlock(result, null, null, iVisited.getCheckState()); } case NodeTypes.ZARRAYNODE: { return runtime.newArray(); } case NodeTypes.ZSUPERNODE: { if (context.getFrameLastClass() == null) { throw runtime.newNameError("superclass method '" + context.getFrameLastFunc() + "' disabled"); } return context.callSuper(context.getFrameArgs()); } } } while (true); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/78ea4e1a09765b065cbaed6fdff38f911b4f1dd1/EvaluationState.java/clean/src/org/jruby/evaluator/EvaluationState.java |
singletonClass = runtime.getClass("False"); | singletonClass = runtime.getClass("FalseClass"); | private static IRubyObject evalInternal(ThreadContext context, Node node, IRubyObject self) { IRuby runtime = context.getRuntime(); bigloop: do { if (node == null) return runtime.getNil(); switch (node.nodeId) { case NodeTypes.ALIASNODE: { AliasNode iVisited = (AliasNode) node; if (context.getRubyClass() == null) { throw runtime.newTypeError("no class to make alias"); } context.getRubyClass().defineAlias(iVisited.getNewName(), iVisited.getOldName()); context.getRubyClass().callMethod(context, "method_added", runtime.newSymbol(iVisited.getNewName())); return runtime.getNil(); } case NodeTypes.ANDNODE: { BinaryOperatorNode iVisited = (BinaryOperatorNode) node; IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) return result; node = iVisited.getSecondNode(); continue bigloop; } case NodeTypes.ARGSCATNODE: { ArgsCatNode iVisited = (ArgsCatNode) node; IRubyObject args = evalInternal(context, iVisited.getFirstNode(), self); IRubyObject secondArgs = splatValue(evalInternal(context, iVisited.getSecondNode(), self)); RubyArray list = args instanceof RubyArray ? (RubyArray) args : runtime.newArray(args); return list.concat(secondArgs); } // case NodeTypes.ARGSNODE: // EvaluateVisitor.argsNodeVisitor.execute(this, node); // break; // case NodeTypes.ARGUMENTNODE: // EvaluateVisitor.argumentNodeVisitor.execute(this, node); // break; case NodeTypes.ARRAYNODE: { ArrayNode iVisited = (ArrayNode) node; IRubyObject[] array = new IRubyObject[iVisited.size()]; int i = 0; for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node next = (Node) iterator.next(); array[i++] = evalInternal(context, next, self); } return runtime.newArray(array); } // case NodeTypes.ASSIGNABLENODE: // EvaluateVisitor.assignableNodeVisitor.execute(this, node); // break; case NodeTypes.BACKREFNODE: { BackRefNode iVisited = (BackRefNode) node; IRubyObject backref = context.getBackref(); switch (iVisited.getType()) { case '~': return backref; case '&': return RubyRegexp.last_match(backref); case '`': return RubyRegexp.match_pre(backref); case '\'': return RubyRegexp.match_post(backref); case '+': return RubyRegexp.match_last(backref); } break; } case NodeTypes.BEGINNODE: { BeginNode iVisited = (BeginNode) node; node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.BIGNUMNODE: { BignumNode iVisited = (BignumNode) node; return RubyBignum.newBignum(runtime, iVisited.getValue()); } // case NodeTypes.BINARYOPERATORNODE: // EvaluateVisitor.binaryOperatorNodeVisitor.execute(this, node); // break; // case NodeTypes.BLOCKARGNODE: // EvaluateVisitor.blockArgNodeVisitor.execute(this, node); // break; case NodeTypes.BLOCKNODE: { BlockNode iVisited = (BlockNode) node; IRubyObject result = runtime.getNil(); for (Iterator iter = iVisited.iterator(); iter.hasNext();) { result = evalInternal(context, (Node) iter.next(), self); } return result; } case NodeTypes.BLOCKPASSNODE: { BlockPassNode iVisited = (BlockPassNode) node; IRubyObject proc = evalInternal(context, iVisited.getBodyNode(), self); if (proc.isNil()) { context.setNoBlock(); try { return evalInternal(context, iVisited.getIterNode(), self); } finally { context.clearNoBlock(); } } // If not already a proc then we should try and make it one. if (!(proc instanceof RubyProc)) { proc = proc.convertToType("Proc", "to_proc", false); if (!(proc instanceof RubyProc)) { throw runtime.newTypeError("wrong argument type " + proc.getMetaClass().getName() + " (expected Proc)"); } } // TODO: Add safety check for taintedness Block block = (Block) context.getCurrentBlock(); if (block != null) { IRubyObject blockObject = block.getBlockObject(); // The current block is already associated with the proc. No need to create new // block for it. Just eval! if (blockObject != null && blockObject == proc) { try { context.setBlockAvailable(); return evalInternal(context, iVisited.getIterNode(), self); } finally { context.clearBlockAvailable(); } } } context.preBlockPassEval(((RubyProc) proc).getBlock()); try { return evalInternal(context, iVisited.getIterNode(), self); } finally { context.postBlockPassEval(); } } case NodeTypes.BREAKNODE: { BreakNode iVisited = (BreakNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); JumpException je = new JumpException(JumpException.JumpType.BreakJump); je.setPrimaryData(result); je.setSecondaryData(node); throw je; } case NodeTypes.CALLNODE: { CallNode iVisited = (CallNode) node; context.beginCallArgs(); IRubyObject receiver = null; IRubyObject[] args = null; try { receiver = evalInternal(context, iVisited.getReceiverNode(), self); args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } assert receiver.getMetaClass() != null : receiver.getClass().getName(); // If reciever is self then we do the call the same way as vcall CallType callType = (receiver == self ? CallType.VARIABLE : CallType.NORMAL); return receiver.callMethod(context, iVisited.getName(), args, callType); } case NodeTypes.CASENODE: { CaseNode iVisited = (CaseNode) node; IRubyObject expression = null; if (iVisited.getCaseNode() != null) { expression = evalInternal(context, iVisited.getCaseNode(), self); } context.pollThreadEvents(); IRubyObject result = runtime.getNil(); Node firstWhenNode = iVisited.getFirstWhenNode(); while (firstWhenNode != null) { if (!(firstWhenNode instanceof WhenNode)) { node = firstWhenNode; continue bigloop; } WhenNode whenNode = (WhenNode) firstWhenNode; if (whenNode.getExpressionNodes() instanceof ArrayNode) { for (Iterator iter = ((ArrayNode) whenNode.getExpressionNodes()).iterator(); iter .hasNext();) { Node tag = (Node) iter.next(); context.setPosition(tag.getPosition()); if (isTrace(runtime)) { callTraceFunction(context, "line", self); } // Ruby grammar has nested whens in a case body because of // productions case_body and when_args. if (tag instanceof WhenNode) { RubyArray expressions = (RubyArray) evalInternal(context, ((WhenNode) tag) .getExpressionNodes(), self); for (int j = 0; j < expressions.getLength(); j++) { IRubyObject condition = expressions.entry(j); if ((expression != null && condition.callMethod(context, "===", expression) .isTrue()) || (expression == null && condition.isTrue())) { node = ((WhenNode) firstWhenNode).getBodyNode(); continue bigloop; } } continue; } result = evalInternal(context, tag, self); if ((expression != null && result.callMethod(context, "===", expression).isTrue()) || (expression == null && result.isTrue())) { node = whenNode.getBodyNode(); continue bigloop; } } } else { result = evalInternal(context, whenNode.getExpressionNodes(), self); if ((expression != null && result.callMethod(context, "===", expression).isTrue()) || (expression == null && result.isTrue())) { node = ((WhenNode) firstWhenNode).getBodyNode(); continue bigloop; } } context.pollThreadEvents(); firstWhenNode = whenNode.getNextCase(); } return runtime.getNil(); } case NodeTypes.CLASSNODE: { ClassNode iVisited = (ClassNode) node; Node superNode = iVisited.getSuperNode(); RubyClass superClass = superNode == null ? null : (RubyClass) evalInternal(context, superNode, self); Node classNameNode = iVisited.getCPath(); String name = ((INameNode) classNameNode).getName(); RubyModule enclosingClass = getEnclosingModule(context, classNameNode, self); RubyClass rubyClass = enclosingClass.defineOrGetClassUnder(name, superClass); if (context.getWrapper() != null) { rubyClass.extendObject(context.getWrapper()); rubyClass.includeModule(context.getWrapper()); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), rubyClass, self); } case NodeTypes.CLASSVARASGNNODE: { ClassVarAsgnNode iVisited = (ClassVarAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); RubyModule rubyClass = (RubyModule) context.peekCRef().getValue(); if (rubyClass == null) { rubyClass = self.getMetaClass(); } else if (rubyClass.isSingleton()) { rubyClass = (RubyModule) rubyClass.getInstanceVariable("__attached__"); } rubyClass.setClassVar(iVisited.getName(), result); return result; } case NodeTypes.CLASSVARDECLNODE: { ClassVarDeclNode iVisited = (ClassVarDeclNode) node; // FIXME: shouldn't we use cref here? if (context.getRubyClass() == null) { throw runtime.newTypeError("no class/module to define class variable"); } IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); ((RubyModule) context.peekCRef().getValue()).setClassVar(iVisited.getName(), result); return runtime.getNil(); } case NodeTypes.CLASSVARNODE: { ClassVarNode iVisited = (ClassVarNode) node; RubyModule rubyClass = (RubyModule) context.peekCRef().getValue(); if (rubyClass == null) { rubyClass = self.getMetaClass(); } else if (rubyClass.isSingleton()) { rubyClass = (RubyModule)rubyClass.getInstanceVariable("__attached__"); } return rubyClass.getClassVar(iVisited.getName()); } case NodeTypes.COLON2NODE: { Colon2Node iVisited = (Colon2Node) node; Node leftNode = iVisited.getLeftNode(); // TODO: Made this more colon3 friendly because of cpath production // rule in grammar (it is convenient to think of them as the same thing // at a grammar level even though evaluation is). if (leftNode == null) { return runtime.getObject().getConstantFrom(iVisited.getName()); } else { IRubyObject result = evalInternal(context, iVisited.getLeftNode(), self); if (result instanceof RubyModule) { return ((RubyModule) result).getConstantFrom(iVisited.getName()); } else { return result.callMethod(context, iVisited.getName()); } } } case NodeTypes.COLON3NODE: { Colon3Node iVisited = (Colon3Node) node; return runtime.getObject().getConstantFrom(iVisited.getName()); } case NodeTypes.CONSTDECLNODE: { ConstDeclNode iVisited = (ConstDeclNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); IRubyObject module; if (iVisited.getPathNode() != null) { module = evalInternal(context, iVisited.getPathNode(), self); } else { // FIXME: why do we check RubyClass and then use CRef? if (context.getRubyClass() == null) { // TODO: wire into new exception handling mechanism throw runtime.newTypeError("no class/module to define constant"); } module = (RubyModule) context.peekCRef().getValue(); } // FIXME: shouldn't we use the result of this set in setResult? ((RubyModule) module).setConstant(iVisited.getName(), result); return result; } case NodeTypes.CONSTNODE: { ConstNode iVisited = (ConstNode) node; return context.getConstant(iVisited.getName()); } case NodeTypes.DASGNNODE: { DAsgnNode iVisited = (DAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // System.out.println("DSetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth() + " and set " + result); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } case NodeTypes.DEFINEDNODE: { DefinedNode iVisited = (DefinedNode) node; String definition = getDefinition(context, iVisited.getExpressionNode(), self); if (definition != null) { return runtime.newString(definition); } else { return runtime.getNil(); } } case NodeTypes.DEFNNODE: { DefnNode iVisited = (DefnNode) node; RubyModule containingClass = context.getRubyClass(); if (containingClass == null) { throw runtime.newTypeError("No class to add method."); } String name = iVisited.getName(); if (containingClass == runtime.getObject() && name.equals("initialize")) { runtime.getWarnings().warn("redefining Object#initialize may cause infinite loop"); } Visibility visibility = context.getCurrentVisibility(); if (name.equals("initialize") || visibility.isModuleFunction()) { visibility = Visibility.PRIVATE; } DefaultMethod newMethod = new DefaultMethod(containingClass, iVisited.getScope(), iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), visibility, context.peekCRef()); if (iVisited.getBodyNode() != null) { iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); } containingClass.addMethod(name, newMethod); if (context.getCurrentVisibility().isModuleFunction()) { containingClass.getSingletonClass().addMethod( name, new WrapperCallable(containingClass.getSingletonClass(), newMethod, Visibility.PUBLIC)); containingClass.callMethod(context, "singleton_method_added", runtime.newSymbol(name)); } // 'class << state.self' and 'class << obj' uses defn as opposed to defs if (containingClass.isSingleton()) { ((MetaClass) containingClass).getAttachedObject().callMethod( context, "singleton_method_added", runtime.newSymbol(iVisited.getName())); } else { containingClass.callMethod(context, "method_added", runtime.newSymbol(name)); } return runtime.getNil(); } case NodeTypes.DEFSNODE: { DefsNode iVisited = (DefsNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); if (runtime.getSafeLevel() >= 4 && !receiver.isTaint()) { throw runtime.newSecurityError("Insecure; can't define singleton method."); } if (receiver.isFrozen()) { throw runtime.newFrozenError("object"); } if (!receiver.singletonMethodsAllowed()) { throw runtime.newTypeError("can't define singleton method \"" + iVisited.getName() + "\" for " + receiver.getType()); } RubyClass rubyClass = receiver.getSingletonClass(); if (runtime.getSafeLevel() >= 4) { ICallable method = (ICallable) rubyClass.getMethods().get(iVisited.getName()); if (method != null) { throw runtime.newSecurityError("Redefining method prohibited."); } } DefaultMethod newMethod = new DefaultMethod(rubyClass, iVisited.getScope(), iVisited.getBodyNode(), (ArgsNode) iVisited.getArgsNode(), Visibility.PUBLIC, context.peekCRef()); if (iVisited.getBodyNode() != null) { iVisited.getBodyNode().accept(new CreateJumpTargetVisitor(newMethod)); } rubyClass.addMethod(iVisited.getName(), newMethod); receiver.callMethod(context, "singleton_method_added", runtime.newSymbol(iVisited.getName())); return runtime.getNil(); } case NodeTypes.DOTNODE: { DotNode iVisited = (DotNode) node; return RubyRange.newRange(runtime, evalInternal(context, iVisited.getBeginNode(), self), evalInternal(context, iVisited .getEndNode(), self), iVisited.isExclusive()); } case NodeTypes.DREGEXPNODE: { DRegexpNode iVisited = (DRegexpNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return RubyRegexp.newRegexp(runtime, sb.toString(), iVisited.getOptions(), null); } case NodeTypes.DSTRNODE: { DStrNode iVisited = (DStrNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return runtime.newString(sb.toString()); } case NodeTypes.DSYMBOLNODE: { DSymbolNode iVisited = (DSymbolNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.getNode().iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return runtime.newSymbol(sb.toString()); } case NodeTypes.DVARNODE: { DVarNode iVisited = (DVarNode) node; // System.out.println("DGetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth()); IRubyObject obj = context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()); // FIXME: null check is removable once we figure out how to assign to unset named block args return obj == null ? runtime.getNil() : obj; } case NodeTypes.DXSTRNODE: { DXStrNode iVisited = (DXStrNode) node; StringBuffer sb = new StringBuffer(); for (Iterator iterator = iVisited.iterator(); iterator.hasNext();) { Node iterNode = (Node) iterator.next(); sb.append(evalInternal(context, iterNode, self).toString()); } return self.callMethod(context, "`", runtime.newString(sb.toString())); } case NodeTypes.ENSURENODE: { EnsureNode iVisited = (EnsureNode) node; // save entering the try if there's nothing to ensure if (iVisited.getEnsureNode() != null) { IRubyObject result = runtime.getNil(); try { result = evalInternal(context, iVisited.getBodyNode(), self); } finally { evalInternal(context, iVisited.getEnsureNode(), self); } return result; } node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.EVSTRNODE: { EvStrNode iVisited = (EvStrNode) node; node = iVisited.getBody(); continue bigloop; } case NodeTypes.FALSENODE: { context.pollThreadEvents(); return runtime.getFalse(); } case NodeTypes.FCALLNODE: { FCallNode iVisited = (FCallNode) node; context.beginCallArgs(); IRubyObject[] args; try { args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } return self.callMethod(context, iVisited.getName(), args, CallType.FUNCTIONAL); } case NodeTypes.FIXNUMNODE: { FixnumNode iVisited = (FixnumNode) node; return runtime.newFixnum(iVisited.getValue()); } case NodeTypes.FLIPNODE: { FlipNode iVisited = (FlipNode) node; IRubyObject result = runtime.getNil(); if (iVisited.isExclusive()) { if (!context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()).isTrue()) { result = evalInternal(context, iVisited.getBeginNode(), self).isTrue() ? runtime.getFalse() : runtime.getTrue(); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } else { if (evalInternal(context, iVisited.getEndNode(), self).isTrue()) { context.getCurrentScope().setValue(iVisited.getIndex(), runtime.getFalse(), iVisited.getDepth()); } return runtime.getTrue(); } } else { if (!context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()).isTrue()) { if (evalInternal(context, iVisited.getBeginNode(), self).isTrue()) { context.getCurrentScope().setValue( iVisited.getIndex(), evalInternal(context, iVisited.getEndNode(), self).isTrue() ? runtime.getFalse() : runtime.getTrue(), iVisited.getDepth()); return runtime.getTrue(); } else { return runtime.getFalse(); } } else { if (evalInternal(context, iVisited.getEndNode(), self).isTrue()) { context.getCurrentScope().setValue(iVisited.getIndex(), runtime.getFalse(), iVisited.getDepth()); } return runtime.getTrue(); } } } case NodeTypes.FLOATNODE: { FloatNode iVisited = (FloatNode) node; return RubyFloat.newFloat(runtime, iVisited.getValue()); } case NodeTypes.FORNODE: { ForNode iVisited = (ForNode) node; // For nodes do not have to create an addition scope so we just pass null context.preForLoopEval(Block.createBlock(iVisited.getVarNode(), null, iVisited.getCallable(), self)); try { while (true) { try { ISourcePosition position = context.getPosition(); context.beginCallArgs(); IRubyObject recv = null; try { recv = evalInternal(context, iVisited.getIterNode(), self); } finally { context.setPosition(position); context.endCallArgs(); } return recv.callMethod(context, "each", IRubyObject.NULL_ARRAY, CallType.NORMAL); } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.RETRY: // do nothing, allow loop to retry break; default: throw je; } } } } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.BREAK: IRubyObject breakValue = (IRubyObject) je.getPrimaryData(); return breakValue == null ? runtime.getNil() : breakValue; default: throw je; } } finally { context.postForLoopEval(); } } case NodeTypes.GLOBALASGNNODE: { GlobalAsgnNode iVisited = (GlobalAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); runtime.getGlobalVariables().set(iVisited.getName(), result); return result; } case NodeTypes.GLOBALVARNODE: { GlobalVarNode iVisited = (GlobalVarNode) node; return runtime.getGlobalVariables().get(iVisited.getName()); } case NodeTypes.HASHNODE: { HashNode iVisited = (HashNode) node; Map hash = null; if (iVisited.getListNode() != null) { hash = new HashMap(iVisited.getListNode().size() / 2); for (Iterator iterator = iVisited.getListNode().iterator(); iterator.hasNext();) { // insert all nodes in sequence, hash them in the final instruction // KEY IRubyObject key = evalInternal(context, (Node) iterator.next(), self); IRubyObject value = evalInternal(context, (Node) iterator.next(), self); hash.put(key, value); } } if (hash == null) { return RubyHash.newHash(runtime); } return RubyHash.newHash(runtime, hash, runtime.getNil()); } case NodeTypes.IFNODE: { IfNode iVisited = (IfNode) node; IRubyObject result = evalInternal(context, iVisited.getCondition(), self); if (result.isTrue()) { node = iVisited.getThenBody(); continue bigloop; } else { node = iVisited.getElseBody(); continue bigloop; } } case NodeTypes.INSTASGNNODE: { InstAsgnNode iVisited = (InstAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); self.setInstanceVariable(iVisited.getName(), result); return result; } case NodeTypes.INSTVARNODE: { InstVarNode iVisited = (InstVarNode) node; IRubyObject variable = self.getInstanceVariable(iVisited.getName()); return variable == null ? runtime.getNil() : variable; } // case NodeTypes.ISCOPINGNODE: // EvaluateVisitor.iScopingNodeVisitor.execute(this, node); // break; case NodeTypes.ITERNODE: { IterNode iVisited = (IterNode) node; context.preIterEval(Block.createBlock(iVisited.getVarNode(), new DynamicScope(iVisited.getScope(), context.getCurrentScope()), iVisited.getCallable(), self)); try { while (true) { try { context.setBlockAvailable(); return evalInternal(context, iVisited.getIterNode(), self); } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.RETRY: // allow loop to retry break; default: throw je; } } finally { context.clearBlockAvailable(); } } } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.BREAK: IRubyObject breakValue = (IRubyObject) je.getPrimaryData(); return breakValue == null ? runtime.getNil() : breakValue; default: throw je; } } finally { context.postIterEval(); } } case NodeTypes.LOCALASGNNODE: { LocalAsgnNode iVisited = (LocalAsgnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // System.out.println("LSetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth() + " and set " + result); context.getCurrentScope().setValue(iVisited.getIndex(), result, iVisited.getDepth()); return result; } case NodeTypes.LOCALVARNODE: { LocalVarNode iVisited = (LocalVarNode) node; //System.out.println("DGetting: " + iVisited.getName() + " at index " + iVisited.getIndex() + " and at depth " + iVisited.getDepth()); IRubyObject result = context.getCurrentScope().getValue(iVisited.getIndex(), iVisited.getDepth()); return result == null ? runtime.getNil() : result; } case NodeTypes.MATCH2NODE: { Match2Node iVisited = (Match2Node) node; IRubyObject recv = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = evalInternal(context, iVisited.getValueNode(), self); return ((RubyRegexp) recv).match(value); } case NodeTypes.MATCH3NODE: { Match3Node iVisited = (Match3Node) node; IRubyObject recv = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = evalInternal(context, iVisited.getValueNode(), self); if (value instanceof RubyString) { return ((RubyRegexp) recv).match(value); } else { return value.callMethod(context, "=~", recv); } } case NodeTypes.MATCHNODE: { MatchNode iVisited = (MatchNode) node; return ((RubyRegexp) evalInternal(context, iVisited.getRegexpNode(), self)).match2(); } case NodeTypes.MODULENODE: { ModuleNode iVisited = (ModuleNode) node; Node classNameNode = iVisited.getCPath(); String name = ((INameNode) classNameNode).getName(); RubyModule enclosingModule = getEnclosingModule(context, classNameNode, self); if (enclosingModule == null) { throw runtime.newTypeError("no outer class/module"); } RubyModule module; if (enclosingModule == runtime.getObject()) { module = runtime.getOrCreateModule(name); } else { module = enclosingModule.defineModuleUnder(name); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), module, self); } case NodeTypes.MULTIPLEASGNNODE: { MultipleAsgnNode iVisited = (MultipleAsgnNode) node; return AssignmentVisitor.assign(context, self, iVisited, evalInternal(context, iVisited.getValueNode(), self), false); } case NodeTypes.NEWLINENODE: { NewlineNode iVisited = (NewlineNode) node; // something in here is used to build up ruby stack trace... context.setPosition(iVisited.getPosition()); if (isTrace(runtime)) { callTraceFunction(context, "line", self); } // TODO: do above but not below for additional newline nodes node = iVisited.getNextNode(); continue bigloop; } case NodeTypes.NEXTNODE: { NextNode iVisited = (NextNode) node; context.pollThreadEvents(); IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); // now used as an interpreter event JumpException je = new JumpException(JumpException.JumpType.NextJump); je.setPrimaryData(result); je.setSecondaryData(iVisited); //state.setCurrentException(je); throw je; } case NodeTypes.NILNODE: return runtime.getNil(); case NodeTypes.NOTNODE: { NotNode iVisited = (NotNode) node; IRubyObject result = evalInternal(context, iVisited.getConditionNode(), self); return result.isTrue() ? runtime.getFalse() : runtime.getTrue(); } case NodeTypes.NTHREFNODE: { NthRefNode iVisited = (NthRefNode) node; return RubyRegexp.nth_match(iVisited.getMatchNumber(), context.getBackref()); } case NodeTypes.OPASGNANDNODE: { BinaryOperatorNode iVisited = (BinaryOperatorNode) node; // add in reverse order IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) return result; node = iVisited.getSecondNode(); continue bigloop; } case NodeTypes.OPASGNNODE: { OpAsgnNode iVisited = (OpAsgnNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject value = receiver.callMethod(context, iVisited.getVariableName()); if (iVisited.getOperatorName().equals("||")) { if (value.isTrue()) { return value; } value = evalInternal(context, iVisited.getValueNode(), self); } else if (iVisited.getOperatorName().equals("&&")) { if (!value.isTrue()) { return value; } value = evalInternal(context, iVisited.getValueNode(), self); } else { value = value.callMethod(context, iVisited.getOperatorName(), evalInternal(context, iVisited.getValueNode(), self)); } receiver.callMethod(context, iVisited.getVariableName() + "=", value); context.pollThreadEvents(); return value; } case NodeTypes.OPASGNORNODE: { OpAsgnOrNode iVisited = (OpAsgnOrNode) node; String def = getDefinition(context, iVisited.getFirstNode(), self); IRubyObject result = runtime.getNil(); if (def != null) { result = evalInternal(context, iVisited.getFirstNode(), self); } if (!result.isTrue()) { result = evalInternal(context, iVisited.getSecondNode(), self); } return result; } case NodeTypes.OPELEMENTASGNNODE: { OpElementAsgnNode iVisited = (OpElementAsgnNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); IRubyObject[] args = setupArgs(context, iVisited.getArgsNode(), self); IRubyObject firstValue = receiver.callMethod(context, "[]", args); if (iVisited.getOperatorName().equals("||")) { if (firstValue.isTrue()) { return firstValue; } firstValue = evalInternal(context, iVisited.getValueNode(), self); } else if (iVisited.getOperatorName().equals("&&")) { if (!firstValue.isTrue()) { return firstValue; } firstValue = evalInternal(context, iVisited.getValueNode(), self); } else { firstValue = firstValue.callMethod(context, iVisited.getOperatorName(), evalInternal(context, iVisited .getValueNode(), self)); } IRubyObject[] expandedArgs = new IRubyObject[args.length + 1]; System.arraycopy(args, 0, expandedArgs, 0, args.length); expandedArgs[expandedArgs.length - 1] = firstValue; return receiver.callMethod(context, "[]=", expandedArgs); } case NodeTypes.OPTNNODE: { OptNNode iVisited = (OptNNode) node; IRubyObject result = runtime.getNil(); while (RubyKernel.gets(runtime.getTopSelf(), IRubyObject.NULL_ARRAY).isTrue()) { loop: while (true) { // Used for the 'redo' command try { result = evalInternal(context, iVisited.getBodyNode(), self); break; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: // do nothing, this iteration restarts break; case JumpType.NEXT: // recheck condition break loop; case JumpType.BREAK: // end loop return (IRubyObject) je.getPrimaryData(); default: throw je; } } } } return result; } case NodeTypes.ORNODE: { OrNode iVisited = (OrNode) node; IRubyObject result = evalInternal(context, iVisited.getFirstNode(), self); if (!result.isTrue()) { result = evalInternal(context, iVisited.getSecondNode(), self); } return result; } // case NodeTypes.POSTEXENODE: // EvaluateVisitor.postExeNodeVisitor.execute(this, node); // break; case NodeTypes.REDONODE: { context.pollThreadEvents(); // now used as an interpreter event JumpException je = new JumpException(JumpException.JumpType.RedoJump); je.setSecondaryData(node); throw je; } case NodeTypes.REGEXPNODE: { RegexpNode iVisited = (RegexpNode) node; // FIXME: don't pass null return RubyRegexp.newRegexp(runtime, iVisited.getPattern(), null); } case NodeTypes.RESCUEBODYNODE: { RescueBodyNode iVisited = (RescueBodyNode) node; node = iVisited.getBodyNode(); continue bigloop; } case NodeTypes.RESCUENODE: { RescueNode iVisited = (RescueNode)node; RescuedBlock : while (true) { try { // Execute rescue block IRubyObject result = evalInternal(context, iVisited.getBodyNode(), self); // If no exception is thrown execute else block if (iVisited.getElseNode() != null) { if (iVisited.getRescueNode() == null) { runtime.getWarnings().warn(iVisited.getElseNode().getPosition(), "else without rescue is useless"); } result = evalInternal(context, iVisited.getElseNode(), self); } return result; } catch (RaiseException raiseJump) { RubyException raisedException = raiseJump.getException(); // TODO: Rubicon TestKernel dies without this line. A cursory glance implies we // falsely set $! to nil and this sets it back to something valid. This should // get fixed at the same time we address bug #1296484. runtime.getGlobalVariables().set("$!", raisedException); RescueBodyNode rescueNode = iVisited.getRescueNode(); while (rescueNode != null) { Node exceptionNodes = rescueNode.getExceptionNodes(); ListNode exceptionNodesList; if (exceptionNodes instanceof SplatNode) { exceptionNodesList = (ListNode) evalInternal(context, exceptionNodes, self); } else { exceptionNodesList = (ListNode) exceptionNodes; } if (isRescueHandled(context, raisedException, exceptionNodesList, self)) { try { return evalInternal(context, rescueNode, self); } catch (JumpException je) { if (je.getJumpType() == JumpException.JumpType.RetryJump) { // should be handled in the finally block below //state.runtime.getGlobalVariables().set("$!", state.runtime.getNil()); //state.threadContext.setRaisedException(null); continue RescuedBlock; } else { throw je; } } } rescueNode = rescueNode.getOptRescueNode(); } // no takers; bubble up throw raiseJump; } finally { // clear exception when handled or retried runtime.getGlobalVariables().set("$!", runtime.getNil()); } } } case NodeTypes.RETRYNODE: { context.pollThreadEvents(); JumpException je = new JumpException(JumpException.JumpType.RetryJump); throw je; } case NodeTypes.RETURNNODE: { ReturnNode iVisited = (ReturnNode) node; IRubyObject result = evalInternal(context, iVisited.getValueNode(), self); JumpException je = new JumpException(JumpException.JumpType.ReturnJump); je.setPrimaryData(iVisited.getTarget()); je.setSecondaryData(result); je.setTertiaryData(iVisited); throw je; } case NodeTypes.ROOTNODE: { RootNode iVisited = (RootNode) node; DynamicScope scope = iVisited.getScope(); // Serialization killed our dynamic scope. We can just create an empty one // since serialization cannot serialize an eval (which is the only thing // which is capable of having a non-empty dynamic scope). if (scope == null) { scope = new DynamicScope(iVisited.getStaticScope(), null); } // Each root node has a top-level scope that we need to push context.preRootNode(scope); // FIXME: Wire up BEGIN and END nodes try { return eval(context, iVisited.getBodyNode(), self); } finally { context.postRootNode(); } } case NodeTypes.SCLASSNODE: { SClassNode iVisited = (SClassNode) node; IRubyObject receiver = evalInternal(context, iVisited.getReceiverNode(), self); RubyClass singletonClass; if (receiver.isNil()) { singletonClass = runtime.getNilClass(); } else if (receiver == runtime.getTrue()) { singletonClass = runtime.getClass("True"); } else if (receiver == runtime.getFalse()) { singletonClass = runtime.getClass("False"); } else { if (runtime.getSafeLevel() >= 4 && !receiver.isTaint()) { throw runtime.newSecurityError("Insecure: can't extend object."); } singletonClass = receiver.getSingletonClass(); } if (context.getWrapper() != null) { singletonClass.extendObject(context.getWrapper()); singletonClass.includeModule(context.getWrapper()); } return evalClassDefinitionBody(context, iVisited.getScope(), iVisited.getBodyNode(), singletonClass, self); } case NodeTypes.SELFNODE: return self; case NodeTypes.SPLATNODE: { SplatNode iVisited = (SplatNode) node; return splatValue(evalInternal(context, iVisited.getValue(), self)); } //// case NodeTypes.STARNODE: //// EvaluateVisitor.starNodeVisitor.execute(this, node); //// break; case NodeTypes.STRNODE: { StrNode iVisited = (StrNode) node; return runtime.newString(iVisited.getValue()); } case NodeTypes.SUPERNODE: { SuperNode iVisited = (SuperNode) node; if (context.getFrameLastClass() == null) { throw runtime.newNameError("Superclass method '" + context.getFrameLastFunc() + "' disabled."); } context.beginCallArgs(); IRubyObject[] args = null; try { args = setupArgs(context, iVisited.getArgsNode(), self); } finally { context.endCallArgs(); } return context.callSuper(args); } case NodeTypes.SVALUENODE: { SValueNode iVisited = (SValueNode) node; return aValueSplat(evalInternal(context, iVisited.getValue(), self)); } case NodeTypes.SYMBOLNODE: { SymbolNode iVisited = (SymbolNode) node; return runtime.newSymbol(iVisited.getName()); } case NodeTypes.TOARYNODE: { ToAryNode iVisited = (ToAryNode) node; return aryToAry(evalInternal(context, iVisited.getValue(), self)); } case NodeTypes.TRUENODE: { context.pollThreadEvents(); return runtime.getTrue(); } case NodeTypes.UNDEFNODE: { UndefNode iVisited = (UndefNode) node; if (context.getRubyClass() == null) { throw runtime .newTypeError("No class to undef method '" + iVisited.getName() + "'."); } context.getRubyClass().undef(iVisited.getName()); return runtime.getNil(); } case NodeTypes.UNTILNODE: { UntilNode iVisited = (UntilNode) node; IRubyObject result = runtime.getNil(); while (!(result = evalInternal(context, iVisited.getConditionNode(), self)).isTrue()) { loop: while (true) { // Used for the 'redo' command try { result = evalInternal(context, iVisited.getBodyNode(), self); break loop; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: continue; case JumpType.NEXT: break loop; case JumpType.BREAK: return (IRubyObject) je.getPrimaryData(); default: throw je; } } } } return result; } case NodeTypes.VALIASNODE: { VAliasNode iVisited = (VAliasNode) node; runtime.getGlobalVariables().alias(iVisited.getNewName(), iVisited.getOldName()); return runtime.getNil(); } case NodeTypes.VCALLNODE: { VCallNode iVisited = (VCallNode) node; return self.callMethod(context, iVisited.getName(), IRubyObject.NULL_ARRAY, CallType.VARIABLE); } case NodeTypes.WHENNODE: assert false; return null; case NodeTypes.WHILENODE: { WhileNode iVisited = (WhileNode) node; IRubyObject result = runtime.getNil(); boolean firstTest = iVisited.evaluateAtStart(); while (!firstTest || (result = evalInternal(context, iVisited.getConditionNode(), self)).isTrue()) { firstTest = true; loop: while (true) { // Used for the 'redo' command try { evalInternal(context, iVisited.getBodyNode(), self); break loop; } catch (JumpException je) { switch (je.getJumpType().getTypeId()) { case JumpType.REDO: continue; case JumpType.NEXT: break loop; case JumpType.BREAK: return result; default: throw je; } } } } return result; } case NodeTypes.XSTRNODE: { XStrNode iVisited = (XStrNode) node; return self.callMethod(context, "`", runtime.newString(iVisited.getValue())); } case NodeTypes.YIELDNODE: { YieldNode iVisited = (YieldNode) node; IRubyObject result = evalInternal(context, iVisited.getArgsNode(), self); if (iVisited.getArgsNode() == null) { result = null; } return context.yieldCurrentBlock(result, null, null, iVisited.getCheckState()); } case NodeTypes.ZARRAYNODE: { return runtime.newArray(); } case NodeTypes.ZSUPERNODE: { if (context.getFrameLastClass() == null) { throw runtime.newNameError("superclass method '" + context.getFrameLastFunc() + "' disabled"); } return context.callSuper(context.getFrameArgs()); } } } while (true); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/78ea4e1a09765b065cbaed6fdff38f911b4f1dd1/EvaluationState.java/clean/src/org/jruby/evaluator/EvaluationState.java |
if (commandline.assumePrinting) { | if (commandline.isAssumePrinting()) { | private static Node getParsedScript(Ruby runtime, Reader reader, String filename) { Node result = runtime.parse(reader, filename); if (commandline.assumePrinting) { result = new ParserSupport().appendPrintToBlock(result); } if (commandline.assumeLoop) { result = new ParserSupport().appendWhileLoopToBlock(result, commandline.processLineEnds, commandline.sDoSplit); } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
if (commandline.assumeLoop) { result = new ParserSupport().appendWhileLoopToBlock(result, commandline.processLineEnds, commandline.sDoSplit); | if (commandline.isAssumeLoop()) { result = new ParserSupport().appendWhileLoopToBlock(result, commandline.isProcessLineEnds(), commandline.isSplit()); | private static Node getParsedScript(Ruby runtime, Reader reader, String filename) { Node result = runtime.parse(reader, filename); if (commandline.assumePrinting) { result = new ParserSupport().appendPrintToBlock(result); } if (commandline.assumeLoop) { result = new ParserSupport().appendWhileLoopToBlock(result, commandline.processLineEnds, commandline.sDoSplit); } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
IRubyObject argumentArray = runtime.newArray(JavaUtil.convertJavaArrayToRuby(runtime, commandline.scriptArguments)); runtime.setVerbose(runtime.newBoolean(commandline.verbose)); | IRubyObject argumentArray = runtime.newArray(JavaUtil.convertJavaArrayToRuby(runtime, commandline.getScriptArguments())); runtime.setVerbose(runtime.newBoolean(commandline.isVerbose())); | private static void initializeRuntime(final Ruby runtime, String filename) { IRubyObject argumentArray = runtime.newArray(JavaUtil.convertJavaArrayToRuby(runtime, commandline.scriptArguments)); runtime.setVerbose(runtime.newBoolean(commandline.verbose)); defineGlobalVERBOSE(runtime); runtime.getObject().setConstant("$VERBOSE", commandline.verbose ? runtime.getTrue() : runtime.getNil()); 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.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argumentArray)); // TODO this is a fake cause we have no real process number in Java runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(runtime.hashCode()))); runtime.defineVariable(new RubyGlobal.StringGlobalVariable(runtime, "$0", runtime.newString(filename))); runtime.getLoadService().init(commandline.loadPaths()); Iterator iter = commandline.requiredLibraries().iterator(); while (iter.hasNext()) { String scriptName = (String) iter.next(); RubyKernel.require(runtime.getTopSelf(), runtime.newString(scriptName)); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
commandline.verbose ? runtime.getTrue() : runtime.getNil()); | commandline.isVerbose() ? runtime.getTrue() : runtime.getNil()); | private static void initializeRuntime(final Ruby runtime, String filename) { IRubyObject argumentArray = runtime.newArray(JavaUtil.convertJavaArrayToRuby(runtime, commandline.scriptArguments)); runtime.setVerbose(runtime.newBoolean(commandline.verbose)); defineGlobalVERBOSE(runtime); runtime.getObject().setConstant("$VERBOSE", commandline.verbose ? runtime.getTrue() : runtime.getNil()); 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.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argumentArray)); // TODO this is a fake cause we have no real process number in Java runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(runtime.hashCode()))); runtime.defineVariable(new RubyGlobal.StringGlobalVariable(runtime, "$0", runtime.newString(filename))); runtime.getLoadService().init(commandline.loadPaths()); Iterator iter = commandline.requiredLibraries().iterator(); while (iter.hasNext()) { String scriptName = (String) iter.next(); RubyKernel.require(runtime.getTopSelf(), runtime.newString(scriptName)); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
defineGlobal(runtime, "$-p", commandline.assumePrinting); defineGlobal(runtime, "$-n", commandline.assumeLoop); defineGlobal(runtime, "$-a", commandline.sDoSplit); defineGlobal(runtime, "$-l", commandline.processLineEnds); | defineGlobal(runtime, "$-p", commandline.isAssumePrinting()); defineGlobal(runtime, "$-n", commandline.isAssumeLoop()); defineGlobal(runtime, "$-a", commandline.isSplit()); defineGlobal(runtime, "$-l", commandline.isProcessLineEnds()); | private static void initializeRuntime(final Ruby runtime, String filename) { IRubyObject argumentArray = runtime.newArray(JavaUtil.convertJavaArrayToRuby(runtime, commandline.scriptArguments)); runtime.setVerbose(runtime.newBoolean(commandline.verbose)); defineGlobalVERBOSE(runtime); runtime.getObject().setConstant("$VERBOSE", commandline.verbose ? runtime.getTrue() : runtime.getNil()); 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.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argumentArray)); // TODO this is a fake cause we have no real process number in Java runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(runtime.hashCode()))); runtime.defineVariable(new RubyGlobal.StringGlobalVariable(runtime, "$0", runtime.newString(filename))); runtime.getLoadService().init(commandline.loadPaths()); Iterator iter = commandline.requiredLibraries().iterator(); while (iter.hasNext()) { String scriptName = (String) iter.next(); RubyKernel.require(runtime.getTopSelf(), runtime.newString(scriptName)); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
if (commandline.showVersion) { | if (commandline.isShowVersion()) { | public static void main(String[] args) { commandline = new CommandlineParser(args); if (commandline.showVersion) { showVersion(); } if (! commandline.shouldRunInterpreter()) { return; } long now = -1; if (commandline.isBenchmarking) { now = System.currentTimeMillis(); } int status = runInterpreter(commandline.getScriptSource(), commandline.displayedFileName()); if (commandline.isBenchmarking) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } // Only do an explicit exit if the interpreter has had an error. We // do not want to exit on non-errors since the interpreter may have // started background threads (ala samples/swing2.rb) if (status != 0) { System.exit(status); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
if (commandline.isBenchmarking) { | if (commandline.isBenchmarking()) { | public static void main(String[] args) { commandline = new CommandlineParser(args); if (commandline.showVersion) { showVersion(); } if (! commandline.shouldRunInterpreter()) { return; } long now = -1; if (commandline.isBenchmarking) { now = System.currentTimeMillis(); } int status = runInterpreter(commandline.getScriptSource(), commandline.displayedFileName()); if (commandline.isBenchmarking) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } // Only do an explicit exit if the interpreter has had an error. We // do not want to exit on non-errors since the interpreter may have // started background threads (ala samples/swing2.rb) if (status != 0) { System.exit(status); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
if (commandline.isBenchmarking) { | if (commandline.isBenchmarking()) { | public static void main(String[] args) { commandline = new CommandlineParser(args); if (commandline.showVersion) { showVersion(); } if (! commandline.shouldRunInterpreter()) { return; } long now = -1; if (commandline.isBenchmarking) { now = System.currentTimeMillis(); } int status = runInterpreter(commandline.getScriptSource(), commandline.displayedFileName()); if (commandline.isBenchmarking) { System.out.println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); } // Only do an explicit exit if the interpreter has had an error. We // do not want to exit on non-errors since the interpreter may have // started background threads (ala samples/swing2.rb) if (status != 0) { System.exit(status); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7fc9704f263fb0e26619a38cdcd58fae7692e4da/Main.java/clean/src/org/jruby/Main.java |
public RubyArray singleton_methods() { | public RubyArray singleton_methods(IRubyObject[] args) { boolean all = true; if(checkArgumentCount(args,0,1) == 1) { all = args[0].isTrue(); } | public RubyArray singleton_methods() { RubyArray result = getRuntime().newArray(); for (RubyClass type = getMetaClass(); type != null && type instanceof MetaClass; type = type.getSuperClass()) { for (Iterator iter = type.getMethods().entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); ICallable method = (ICallable) entry.getValue(); // We do not want to capture cached methods if (method.getImplementationClass() != type) { continue; } RubyString methodName = getRuntime().newString((String) entry.getKey()); if (method.getVisibility().isPublic() && ! result.includes(methodName)) { result.append(methodName); } } } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7a32a4636ecb1df6caaf05de241ff89fc6fd721a/RubyObject.java/clean/src/org/jruby/RubyObject.java |
for (RubyClass type = getMetaClass(); type != null && type instanceof MetaClass; | for (RubyClass type = getMetaClass(); type != null && ((type instanceof MetaClass) || (all && type.isIncluded())); | public RubyArray singleton_methods() { RubyArray result = getRuntime().newArray(); for (RubyClass type = getMetaClass(); type != null && type instanceof MetaClass; type = type.getSuperClass()) { for (Iterator iter = type.getMethods().entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); ICallable method = (ICallable) entry.getValue(); // We do not want to capture cached methods if (method.getImplementationClass() != type) { continue; } RubyString methodName = getRuntime().newString((String) entry.getKey()); if (method.getVisibility().isPublic() && ! result.includes(methodName)) { result.append(methodName); } } } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7a32a4636ecb1df6caaf05de241ff89fc6fd721a/RubyObject.java/clean/src/org/jruby/RubyObject.java |
if (method.getImplementationClass() != type) { | if (method.getImplementationClass() != type && !(all && type.isIncluded())) { | public RubyArray singleton_methods() { RubyArray result = getRuntime().newArray(); for (RubyClass type = getMetaClass(); type != null && type instanceof MetaClass; type = type.getSuperClass()) { for (Iterator iter = type.getMethods().entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); ICallable method = (ICallable) entry.getValue(); // We do not want to capture cached methods if (method.getImplementationClass() != type) { continue; } RubyString methodName = getRuntime().newString((String) entry.getKey()); if (method.getVisibility().isPublic() && ! result.includes(methodName)) { result.append(methodName); } } } return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/7a32a4636ecb1df6caaf05de241ff89fc6fd721a/RubyObject.java/clean/src/org/jruby/RubyObject.java |
_tools = null; | public Context(final Broker broker) { _broker = broker; _bean = null; _tools = null; _toolbox = null; _locals = null; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
|
_locals = null; | public Context(final Broker broker) { _broker = broker; _bean = null; _tools = null; _toolbox = null; _locals = null; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
|
public void clear() { if (_tools != null) { _tools.clear(); _tools = null; } if (_locals != null) { _locals.clear(); _locals = null; } _bean = null; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
||
protected Object clone() { | public Object clone() { Context c = null; | protected Object clone() { try { return super.clone(); } catch (CloneNotSupportedException cnse) { return null; } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
return super.clone(); } catch (CloneNotSupportedException cnse) { return null; | c = (Context) super.clone(); } catch (CloneNotSupportedException e) { | protected Object clone() { try { return super.clone(); } catch (CloneNotSupportedException cnse) { return null; } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
c._localState = null; c._beanState = null; c._state = 0; c._locals = null; c._bean = null; return c; | protected Object clone() { try { return super.clone(); } catch (CloneNotSupportedException cnse) { return null; } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
|
Object res = get(names[0]); if (names.length == 1) { return res; } return PropertyOperator.getProperty(this,get(names[0]),names,1); | return getLocal(names); | public final Object getProperty(final Object[] names) throws PropertyException, InvalidContextException { if (names.length == 0) { return null; } else if (_bean == null) { Object res = get(names[0]); if (names.length == 1) { return res; } return PropertyOperator.getProperty(this,get(names[0]),names,1); } else { return PropertyOperator.getProperty(this,_bean,names); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
final public Object getTool(String name) | final public Object getTool(Object name) | final public Object getTool(String name) throws InvalidContextException { try { if (_toolbox == null) { return null; } Object ret = (_tools != null) ? _tools.get(name) : null; if (ret == null) { ContextTool tool = (ContextTool) _toolbox.get(name); if (tool != null) { if (_tools == null) { _tools = new HashMap(); } ret = tool.init(this); _tools.put(name,ret); } } return ret; } catch (ClassCastException ce) { throw new InvalidContextException("Tool" + name + " does not implement the ContextTool interface!"); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
if (names.length == 1) { put(names[0], value); return true; } return PropertyOperator.setProperty(this,get(names[0]),names,1,value); | return setLocal(names, value); | final public boolean setProperty(final Object[] names, final Object value) throws PropertyException, InvalidContextException { if (names.length == 0) { return false; } else if (_bean == null) { if (names.length == 1) { put(names[0], value); return true; } return PropertyOperator.setProperty(this,get(names[0]),names,1,value); } else { return PropertyOperator.setProperty(this,_bean,names,value); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/78a66b349748346624878ff04bb72f314bdac97c/Context.java/buggy/webmacro/src/org/webmacro/Context.java |
public void setPaneIndex(int index); | public void setPaneIndex(int index, ImageDisplay node); | public void setPaneIndex(int index); | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/b4992016524102ee0a5c7465d4cc7a94e9ffce2d/ClipBoard.java/clean/SRC/org/openmicroscopy/shoola/agents/hiviewer/clipboard/ClipBoard.java |
histogramPanel = new HistogramPanel(mini, maxi, start, end, yStart, yEnd, histogramData); | histogramPanel = new HistogramPanel(manager, mini, maxi, start, end, yStart, yEnd, histogramData); | HistogramDialog(QuantumPaneManager control, int mini, int maxi, int start, int end, PixelsStatsEntry[] histogramData) { super(control.getReferenceFrame(), "Histogram", true); manager = new HistogramDialogManager(this, control); int yStart, yEnd; yStart = manager.convertRealIntoGraphics(start); yEnd = manager.convertRealIntoGraphics(end); histogramPanel = new HistogramPanel(mini, maxi, start, end, yStart, yEnd, histogramData); manager.initRectangles(yStart, yEnd); manager.attachListeners(); buildGUI(); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/83f676753e39a506a8cb86c443c49fa697ec99eb/HistogramDialog.java/buggy/SRC/org/openmicroscopy/shoola/agents/rnd/pane/HistogramDialog.java |
if (list.size() == 0) | if (list.size() == 0) { | public void saveRenderingSettings(int pixelsID, int imageID, RenderingDef rDef) throws DSOutOfServiceException, DSAccessException { UserDetails uc = registry.getDataManagementService().getUserDetails(); Criteria c = ImageMapper.buildRenderingSettingsCriteria( STSMapper.IMAGE_GRANULARITY, imageID, uc.getUserID()); List list = (List) gateway.retrieveListSTSData("RenderingSettings", c); //List of renderingSettings to save in DB. List l = new ArrayList(); if (list != null) { if (list.size() == 0) //nothing previously saved by the user. l = saveRSFirstTime(imageID, rDef); else l = saveRS(rDef, list); gateway.updateAttributes(l); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/c622334a979ccc7cf4d7a06543d34a9976a98145/STSAdapter.java/clean/SRC/org/openmicroscopy/shoola/env/data/STSAdapter.java |
else l = saveRS(rDef, list); | gateway.annotateAttributesData(l); } else l = saveRS(rDef, list); | public void saveRenderingSettings(int pixelsID, int imageID, RenderingDef rDef) throws DSOutOfServiceException, DSAccessException { UserDetails uc = registry.getDataManagementService().getUserDetails(); Criteria c = ImageMapper.buildRenderingSettingsCriteria( STSMapper.IMAGE_GRANULARITY, imageID, uc.getUserID()); List list = (List) gateway.retrieveListSTSData("RenderingSettings", c); //List of renderingSettings to save in DB. List l = new ArrayList(); if (list != null) { if (list.size() == 0) //nothing previously saved by the user. l = saveRSFirstTime(imageID, rDef); else l = saveRS(rDef, list); gateway.updateAttributes(l); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/c622334a979ccc7cf4d7a06543d34a9976a98145/STSAdapter.java/clean/SRC/org/openmicroscopy/shoola/env/data/STSAdapter.java |
menu.add(new JMenuItem( controller.getAction(HiViewerControl.VIEW_CGCI))); | private JMenu createViewMenu() { JMenu menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); //menu.add(new JMenuItem(controller.getAction(HiViewerControl.VIEW_PDI))); menu.add(new JMenuItem( controller.getAction(HiViewerControl.VIEW_CGCI))); //menu.add(new JSeparator(JSeparator.HORIZONTAL)); JCheckBoxMenuItem item = new JCheckBoxMenuItem(); item.setSelected(false); item.setText(TreeViewAction.NAME); item.setAction(controller.getAction(HiViewerControl.TREE_VIEW)); //menu.add(item); item = new JCheckBoxMenuItem(); item.setSelected(true); item.setAction(controller.getAction(HiViewerControl.CLIPBOARD_VIEW)); item.setText(ClipBoardViewAction.NAME); //menu.add(item); item = new JCheckBoxMenuItem(); item.setSelected(model.isTitleBarVisible()); item.setAction(controller.getAction(HiViewerControl.SHOW_TITLEBAR)); menu.add(item); //item = new JCheckBoxMenuItem(); //item.setSelected(model.isRollOver()); //item.setAction(controller.getAction(HiViewerControl.ROLL_OVER)); //menu.add(item); menu.add(new JSeparator(SwingConstants.HORIZONTAL)); JMenuItem mi = new JMenuItem( controller.getAction(HiViewerControl.ZOOM_IN)); mi.setText(ZoomInAction.NAME); menu.add(mi); mi = new JMenuItem(controller.getAction(HiViewerControl.ZOOM_OUT)); mi.setText(ZoomOutAction.NAME); menu.add(mi); mi = new JMenuItem(controller.getAction(HiViewerControl.ZOOM_FIT)); mi.setText(ZoomFitAction.NAME); menu.add(mi); menu.add(new JSeparator(SwingConstants.HORIZONTAL)); menu.add(createLayoutMenu()); return menu; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ea7509babe2344eb702969105eb77096cc5b6bcf/HiViewerWin.java/buggy/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerWin.java |
|
return cBase; | return (RubyModule)getRubyFrame().getCbase().getClassValue(); | public RubyModule getCBase() { return cBase; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/b3fad11fe9fed3c3b955874e822c0e093e06dfc8/Ruby.java/buggy/org/jruby/Ruby.java |
this.cBase = cBase; | getRubyFrame().getCbase().setClassValue(cBase); | public void setCBase(RubyModule cBase) { this.cBase = cBase; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/b3fad11fe9fed3c3b955874e822c0e093e06dfc8/Ruby.java/buggy/org/jruby/Ruby.java |
private void processQueue() { // reference queue is sychronized, so no need to do it ourself Node node; while ((node = (Node)queue.poll()) != null) { int hash = (node.hash & 0x7FFFFFFF) % tab.length; Node last=null; synchronized (locks[hash]) { if (!node.cleaned) { Node current = tab[hash]; while (current != null) { // clear other expired weak refs, too, to // prevent the same lock of being taken // more than once. if (current == node) { if (last == null) { tab[hash] = current.next; } else { last.next = current.next; } current.cleaned = true; break; } last = current; current = current.next; } } } } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/8a0f4a517aef2a2415967033ec13a7af56a3d52a/SimpleIdentityMap.java/buggy/webmacro/src/org/webmacro/util/SimpleIdentityMap.java |
||
private void onClick(MouseEvent me, boolean released) { Point p = me.getPoint(); JTree tree = getSelectedTree(); int row = tree.getRowForLocation(p.x, p.y); if (row != -1) { if (me.getClickCount() == 1) { model.setClickPoint(p); if (me.isPopupTrigger()) controller.showPopupMenu(); //if (!released) controller.onClick(); } else if (me.getClickCount() == 2 && released) { model.viewDataObject(); } } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/38a31e9c570bc8c0bbfb871c8b12b0e52420f22c/BrowserUI.java/clean/SRC/org/openmicroscopy/shoola/agents/treeviewer/browser/BrowserUI.java |
||
if (value.isKindOf(runtime.getClass("JavaProxy"))) { | if (value.isKindOf(runtime.getClasses().getClass("JavaProxy"))) { | public IRubyObject setValue(IRubyObject value) { runtime.getLoadService().require("java"); if (value.isKindOf(runtime.getClass("JavaProxy"))) { value = value.getInstanceVariable("java_object"); } value = Java.primitive_to_java(value, value); bean.bean = JavaUtil.convertArgument(value, bean.type); return value; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/b131c179820af614acbf465c63fa6656693f4c1c/JRubyEngine.java/clean/src/org/jruby/javasupport/bsf/JRubyEngine.java |
if (value.isKindOf(runtime.getClass("JavaProxy"))) { | if (value.isKindOf(runtime.getClasses().getClass("JavaProxy"))) { | private Object convertToJava(IRubyObject value, Class type) { runtime.getLoadService().require("java"); if (value.isKindOf(runtime.getClass("JavaProxy"))) { value = value.getInstanceVariable("java_object"); } value = Java.primitive_to_java(value, value); return JavaUtil.convertArgument(value, type); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/b131c179820af614acbf465c63fa6656693f4c1c/JRubyEngine.java/clean/src/org/jruby/javasupport/bsf/JRubyEngine.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/ZSuperNode.java/clean/org/jruby/nodes/ZSuperNode.java |
List argsList = ruby.getRubyFrame().getArgs(); RubyObject[] argsObj = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); | RubyPointer args = (RubyPointer)ruby.getRubyFrame().getArgs(); | public RubyObject eval(Ruby ruby, RubyObject self) { // TMP_PROTECT; if (ruby.getRubyFrame().getLastClass() == null) { throw new RubyNameException("superclass method '" + ruby.getRubyFrame().getLastFunc().toName() + "' disabled"); } List argsList = ruby.getRubyFrame().getArgs(); RubyObject[] argsObj = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); ruby.getIter().push(ruby.getIter().getIter() != RubyIter.ITER_NOT ? RubyIter.ITER_PRE : RubyIter.ITER_NOT); RubyObject result = ruby.getRubyFrame().getLastClass().getSuperClass().call( ruby.getRubyFrame().getSelf(), ruby.getRubyFrame().getLastFunc(), argsObj, 3); ruby.getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f629550c5947df9c1dbe414645f3dc76bcb70df4/ZSuperNode.java/clean/org/jruby/nodes/ZSuperNode.java |
ruby.getRubyFrame().getLastFunc(), argsObj, 3); | ruby.getRubyFrame().getLastFunc(), args, 3); | public RubyObject eval(Ruby ruby, RubyObject self) { // TMP_PROTECT; if (ruby.getRubyFrame().getLastClass() == null) { throw new RubyNameException("superclass method '" + ruby.getRubyFrame().getLastFunc().toName() + "' disabled"); } List argsList = ruby.getRubyFrame().getArgs(); RubyObject[] argsObj = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); ruby.getIter().push(ruby.getIter().getIter() != RubyIter.ITER_NOT ? RubyIter.ITER_PRE : RubyIter.ITER_NOT); RubyObject result = ruby.getRubyFrame().getLastClass().getSuperClass().call( ruby.getRubyFrame().getSelf(), ruby.getRubyFrame().getLastFunc(), argsObj, 3); ruby.getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f629550c5947df9c1dbe414645f3dc76bcb70df4/ZSuperNode.java/clean/org/jruby/nodes/ZSuperNode.java |
if (model.getTreeView() == null) return; model.showTreeView(!model.getTreeView().isDisplay()); | TreeView treeView = model.createTreeView(); model.showTreeView(!treeView.isDisplay()); | public void actionPerformed(ActionEvent e) { if (model.getTreeView() == null) return; model.showTreeView(!model.getTreeView().isDisplay()); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/ea7509babe2344eb702969105eb77096cc5b6bcf/TreeViewAction.java/buggy/SRC/org/openmicroscopy/shoola/agents/hiviewer/actions/TreeViewAction.java |
} else if (descriptor.getPropertyType().isAssignableFrom(QName[].class)) { String name = descriptor.getName(); MutablePropertyValues propertyValues = bd.getPropertyValues(); PropertyValue propertyValue = propertyValues.getPropertyValue(name); if (propertyValue != null) { Object value = propertyValue.getValue(); if (value instanceof List) { List values = (List) value; List newValues = new ManagedList(); for (Iterator iter = values.iterator(); iter.hasNext();) { Object v = iter.next(); if (v instanceof String) { newValues.add(createQName(element, (String) v)); } else { newValues.add(v); } } propertyValues.removePropertyValue(propertyValue); propertyValues.addPropertyValue(name, newValues); } } | public static void coerceNamespaceAwarePropertyValues(AbstractBeanDefinition bd, Element element, PropertyDescriptor[] descriptors, int i) { PropertyDescriptor descriptor = descriptors[i]; if (descriptor.getPropertyType().isAssignableFrom(QName.class)) { String name = descriptor.getName(); MutablePropertyValues propertyValues = bd.getPropertyValues(); PropertyValue propertyValue = propertyValues.getPropertyValue(name); if (propertyValue != null) { Object value = propertyValue.getValue(); if (value instanceof String) { propertyValues.removePropertyValue(propertyValue); propertyValues.addPropertyValue(name, createQName(element, (String) value)); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/9f84d66432421d859c75d97009aa7e3b50bb9b82/QNameHelper.java/buggy/spring/src/main/java/org/xbean/spring/context/impl/QNameHelper.java |
|
thumbnailLoaded = false; | protected EditorModel(TreeViewer parentModel, int editorType, DataObject hierarchyObject, TreeImageDisplay parent) { if (parentModel == null) throw new NullPointerException("No parent model."); if (editorType != Editor.CREATE_EDITOR && editorType != Editor.PROPERTIES_EDITOR) throw new IllegalArgumentException("editor not supported."); if (hierarchyObject == null) throw new IllegalArgumentException("No Data object."); state = Editor.NEW; this.editorType = editorType; this.parentModel = parentModel; this.hierarchyObject = hierarchyObject; if (editorType == Editor.CREATE_EDITOR) this.parent = parent; else this.parent = null; annotated = false; } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/464efde90db6bc5095c0a7e5952f51ad0f37ca86/EditorModel.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/editors/EditorModel.java |
|
private void createMenuBar() { menuBar = new JToolBar(); menuBar.setBorder(null); menuBar.setRollover(true); menuBar.setFloatable(false); JButton button = new JButton( controller.getAction(BrowserControl.BACKWARD_NAV)); button.setBorderPainted(false); //menuBar.add(button); button = new JButton(controller.getAction(BrowserControl.FORWARD_NAV)); //menuBar.add(button); //menuBar.add(new JSeparator(SwingConstants.VERTICAL)); ButtonGroup group = new ButtonGroup(); JToggleButton b = new JToggleButton(); group.add(b); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); b.setSelected(true); b.setAction(controller.getAction(BrowserControl.SORT)); menuBar.add(b); b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE)); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); group.add(b); //b.setBorderPainted(false); menuBar.add(b); button = new JButton(controller.getAction(BrowserControl.FILTER_MENU)); button.addMouseListener((FilterMenuAction) controller.getAction(BrowserControl.FILTER_MENU)); button.setBorderPainted(false); menuBar.add(button); menuBar.add(new JSeparator(SwingConstants.VERTICAL)); button = new JButton(controller.getAction(BrowserControl.COLLAPSE)); button.setBorderPainted(false); menuBar.add(button); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/146920a8791fff71320ced0f240b9d8f3d319a13/BrowserUI.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/browser/BrowserUI.java |
||
private void createMenuBar() { menuBar = new JToolBar(); menuBar.setBorder(null); menuBar.setRollover(true); menuBar.setFloatable(false); JButton button = new JButton( controller.getAction(BrowserControl.BACKWARD_NAV)); button.setBorderPainted(false); //menuBar.add(button); button = new JButton(controller.getAction(BrowserControl.FORWARD_NAV)); //menuBar.add(button); //menuBar.add(new JSeparator(SwingConstants.VERTICAL)); ButtonGroup group = new ButtonGroup(); JToggleButton b = new JToggleButton(); group.add(b); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); b.setSelected(true); b.setAction(controller.getAction(BrowserControl.SORT)); menuBar.add(b); b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE)); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); group.add(b); //b.setBorderPainted(false); menuBar.add(b); button = new JButton(controller.getAction(BrowserControl.FILTER_MENU)); button.addMouseListener((FilterMenuAction) controller.getAction(BrowserControl.FILTER_MENU)); button.setBorderPainted(false); menuBar.add(button); menuBar.add(new JSeparator(SwingConstants.VERTICAL)); button = new JButton(controller.getAction(BrowserControl.COLLAPSE)); button.setBorderPainted(false); menuBar.add(button); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/146920a8791fff71320ced0f240b9d8f3d319a13/BrowserUI.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/browser/BrowserUI.java |
||
private void createMenuBar() { menuBar = new JToolBar(); menuBar.setBorder(null); menuBar.setRollover(true); menuBar.setFloatable(false); JButton button = new JButton( controller.getAction(BrowserControl.BACKWARD_NAV)); button.setBorderPainted(false); //menuBar.add(button); button = new JButton(controller.getAction(BrowserControl.FORWARD_NAV)); //menuBar.add(button); //menuBar.add(new JSeparator(SwingConstants.VERTICAL)); ButtonGroup group = new ButtonGroup(); JToggleButton b = new JToggleButton(); group.add(b); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); b.setSelected(true); b.setAction(controller.getAction(BrowserControl.SORT)); menuBar.add(b); b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE)); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); group.add(b); //b.setBorderPainted(false); menuBar.add(b); button = new JButton(controller.getAction(BrowserControl.FILTER_MENU)); button.addMouseListener((FilterMenuAction) controller.getAction(BrowserControl.FILTER_MENU)); button.setBorderPainted(false); menuBar.add(button); menuBar.add(new JSeparator(SwingConstants.VERTICAL)); button = new JButton(controller.getAction(BrowserControl.COLLAPSE)); button.setBorderPainted(false); menuBar.add(button); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/146920a8791fff71320ced0f240b9d8f3d319a13/BrowserUI.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/browser/BrowserUI.java |
||
partialButton = new JToggleButton( controller.getAction(BrowserControl.PARTIAL_NAME)); partialButton.setBorderPainted(true); menuBar.add(partialButton); | private void createMenuBar() { menuBar = new JToolBar(); menuBar.setBorder(null); menuBar.setRollover(true); menuBar.setFloatable(false); JButton button = new JButton( controller.getAction(BrowserControl.BACKWARD_NAV)); button.setBorderPainted(false); //menuBar.add(button); button = new JButton(controller.getAction(BrowserControl.FORWARD_NAV)); //menuBar.add(button); //menuBar.add(new JSeparator(SwingConstants.VERTICAL)); ButtonGroup group = new ButtonGroup(); JToggleButton b = new JToggleButton(); group.add(b); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); b.setSelected(true); b.setAction(controller.getAction(BrowserControl.SORT)); menuBar.add(b); b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE)); //UIUtilities.unifiedButtonLookAndFeel(b); b.setBorderPainted(true); group.add(b); //b.setBorderPainted(false); menuBar.add(b); button = new JButton(controller.getAction(BrowserControl.FILTER_MENU)); button.addMouseListener((FilterMenuAction) controller.getAction(BrowserControl.FILTER_MENU)); button.setBorderPainted(false); menuBar.add(button); menuBar.add(new JSeparator(SwingConstants.VERTICAL)); button = new JButton(controller.getAction(BrowserControl.COLLAPSE)); button.setBorderPainted(false); menuBar.add(button); } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/146920a8791fff71320ced0f240b9d8f3d319a13/BrowserUI.java/buggy/SRC/org/openmicroscopy/shoola/agents/treeviewer/browser/BrowserUI.java |
|
public static File createTempFile(String prefix, String suffix) throws IOException { File file = File.createTempFile(prefix, suffix); | public static File createTempFile(String prefix, String suffix, File directory) throws IOException { File file = File.createTempFile(prefix, suffix, directory); | public static File createTempFile(String prefix, String suffix) throws IOException { File file = File.createTempFile(prefix, suffix); return new NormalizedFile(file.getPath()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/c506a9979e35512d57d5f29f0d18b3da14ef2919/NormalizedFile.java/buggy/src/org/jruby/util/NormalizedFile.java |
Object[] args = (Object[]) argsBuilder.buildAsArray(bc); | Object[] args = argsBuilder.buildAsArray(bc); | public Object build(BuildContext bc) throws BuildException { MacroDefinition md = bc.getMacro(name); if (md == null) throw new BuildException("No such macro " + name); Object[] args = (Object[]) argsBuilder.buildAsArray(bc); return md.expand(args, bc); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/67f3bf2b9347218e8efc5ecece60bb5f03730152/MacroBuilder.java/clean/webmacro/src/org/webmacro/engine/MacroBuilder.java |
if (descriptor.getPropertyType() == null) { return; } | public static void coerceNamespaceAwarePropertyValues(AbstractBeanDefinition bd, Element element, PropertyDescriptor[] descriptors, int i) { PropertyDescriptor descriptor = descriptors[i]; if (descriptor.getPropertyType().isAssignableFrom(QName.class)) { String name = descriptor.getName(); MutablePropertyValues propertyValues = bd.getPropertyValues(); PropertyValue propertyValue = propertyValues.getPropertyValue(name); if (propertyValue != null) { Object value = propertyValue.getValue(); if (value instanceof String) { propertyValues.removePropertyValue(propertyValue); propertyValues.addPropertyValue(name, createQName(element, (String) value)); } } } else if (descriptor.getPropertyType().isAssignableFrom(QName[].class)) { String name = descriptor.getName(); MutablePropertyValues propertyValues = bd.getPropertyValues(); PropertyValue propertyValue = propertyValues.getPropertyValue(name); if (propertyValue != null) { Object value = propertyValue.getValue(); if (value instanceof List) { List values = (List) value; List newValues = new ManagedList(); for (Iterator iter = values.iterator(); iter.hasNext();) { Object v = iter.next(); if (v instanceof String) { newValues.add(createQName(element, (String) v)); } else { newValues.add(v); } } propertyValues.removePropertyValue(propertyValue); propertyValues.addPropertyValue(name, newValues); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/7aefc79bab6c2fcfbc4fd52754e4f36f5daf79f5/QNameHelper.java/buggy/spring/src/main/java/org/xbean/spring/context/impl/QNameHelper.java |
|
module.defineModuleFunction("trap", callbackFactory.getOptSingletonMethod("trap")); | public static RubyModule createKernelModule(IRuby runtime) { RubyModule module = runtime.defineModule("Kernel"); CallbackFactory callbackFactory = runtime.callbackFactory(RubyKernel.class); module.defineModuleFunction("Array", callbackFactory.getSingletonMethod("new_array", IRubyObject.class)); module.defineModuleFunction("Float", callbackFactory.getSingletonMethod("new_float", IRubyObject.class)); module.defineModuleFunction("Integer", callbackFactory.getSingletonMethod("new_integer", IRubyObject.class)); module.defineModuleFunction("String", callbackFactory.getSingletonMethod("new_string", IRubyObject.class)); module.defineModuleFunction("`", callbackFactory.getSingletonMethod("backquote", IRubyObject.class)); // TODO: Implement Kernel#abort module.defineModuleFunction("at_exit", callbackFactory.getSingletonMethod("at_exit")); module.defineModuleFunction("autoload", callbackFactory.getSingletonMethod("autoload", IRubyObject.class, IRubyObject.class)); // TODO: Implement Kernel#autoload? // TODO: Implement Kernel#binding module.defineModuleFunction("block_given?", callbackFactory.getSingletonMethod("block_given")); // TODO: Implement Kernel#callcc module.defineModuleFunction("caller", callbackFactory.getOptSingletonMethod("caller")); module.defineModuleFunction("catch", callbackFactory.getSingletonMethod("rbCatch", IRubyObject.class)); module.defineModuleFunction("chomp", callbackFactory.getOptSingletonMethod("chomp")); module.defineModuleFunction("chomp!", callbackFactory.getOptSingletonMethod("chomp_bang")); module.defineModuleFunction("chop", callbackFactory.getSingletonMethod("chop")); module.defineModuleFunction("chop!", callbackFactory.getSingletonMethod("chop_bang")); module.defineModuleFunction("eval", callbackFactory.getOptSingletonMethod("eval")); // TODO: Implement Kernel#exec module.defineModuleFunction("exit", callbackFactory.getOptSingletonMethod("exit")); // TODO: Implement Kernel#exit! module.defineModuleFunction("fail", callbackFactory.getOptSingletonMethod("raise")); // TODO: Implement Kernel#fork module.defineModuleFunction("format", callbackFactory.getOptSingletonMethod("sprintf")); module.defineModuleFunction("gets", callbackFactory.getOptSingletonMethod("gets")); module.defineModuleFunction("global_variables", callbackFactory.getSingletonMethod("global_variables")); module.defineModuleFunction("gsub", callbackFactory.getOptSingletonMethod("gsub")); module.defineModuleFunction("gsub!", callbackFactory.getOptSingletonMethod("gsub_bang")); // TODO: Add deprecation to Kernel#iterator? (maybe formal deprecation mech.) module.defineAlias("iterator?", "block_given?"); module.defineModuleFunction("lambda", callbackFactory.getSingletonMethod("proc")); module.defineModuleFunction("load", callbackFactory.getOptSingletonMethod("load")); module.defineModuleFunction("local_variables", callbackFactory.getSingletonMethod("local_variables")); module.defineModuleFunction("loop", callbackFactory.getSingletonMethod("loop")); // Note: method_missing is documented as being in Object, but ruby appears to stick it in Kernel. module.defineModuleFunction("method_missing", callbackFactory.getOptSingletonMethod("method_missing")); module.defineModuleFunction("open", callbackFactory.getOptSingletonMethod("open")); module.defineModuleFunction("p", callbackFactory.getOptSingletonMethod("p")); module.defineModuleFunction("print", callbackFactory.getOptSingletonMethod("print")); module.defineModuleFunction("printf", callbackFactory.getOptSingletonMethod("printf")); module.defineModuleFunction("proc", callbackFactory.getSingletonMethod("proc")); // TODO: implement Kernel#putc module.defineModuleFunction("puts", callbackFactory.getOptSingletonMethod("puts")); module.defineAlias("raise", "fail"); module.defineModuleFunction("rand", callbackFactory.getOptSingletonMethod("rand")); module.defineModuleFunction("readline", callbackFactory.getOptSingletonMethod("readline")); module.defineModuleFunction("readlines", callbackFactory.getOptSingletonMethod("readlines")); module.defineModuleFunction("require", callbackFactory.getSingletonMethod("require", IRubyObject.class)); module.defineModuleFunction("scan", callbackFactory.getSingletonMethod("scan", IRubyObject.class)); // TODO: Implement Kernel#select module.defineModuleFunction("set_trace_func", callbackFactory.getSingletonMethod("set_trace_func", IRubyObject.class)); module.defineModuleFunction("sleep", callbackFactory.getSingletonMethod("sleep", IRubyObject.class)); module.defineModuleFunction("split", callbackFactory.getOptSingletonMethod("split")); module.defineAlias("sprintf", "format"); module.defineModuleFunction("srand", callbackFactory.getOptSingletonMethod("srand")); module.defineModuleFunction("sub", callbackFactory.getOptSingletonMethod("sub")); module.defineModuleFunction("sub!", callbackFactory.getOptSingletonMethod("sub_bang")); // Skipping: Kernel#syscall (too system dependent) module.defineModuleFunction("system", callbackFactory.getOptSingletonMethod("system")); // TODO: Implement Kernel#test (partial impl) module.defineModuleFunction("throw", callbackFactory.getOptSingletonMethod("rbThrow")); // TODO: Implement Kernel#trace_var // TODO: Implement Kernel#trap // TODO: Implement Kernel#untrace_var // TODO: Implement Kernel#warn // Defined p411 Pickaxe 2nd ed. module.defineModuleFunction("singleton_method_added", callbackFactory.getSingletonMethod("singleton_method_added", IRubyObject.class)); return module; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/RubyKernel.java/clean/src/org/jruby/RubyKernel.java |
|
IRuby runtime = recv.getRuntime(); JumpException je = new JumpException(JumpException.JumpType.ThrowJump); String tag = args[0].asSymbol(); IRubyObject value = args.length > 1 ? args[1] : recv.getRuntime().getNil(); RubyException nameException = new RubyException(runtime, runtime.getClass("NameError"), "uncaught throw '" + tag + '\''); je.setPrimaryData(tag); je.setSecondaryData(value); je.setTertiaryData(nameException); | IRuby runtime = recv.getRuntime(); JumpException je = new JumpException(JumpException.JumpType.ThrowJump); String tag = args[0].asSymbol(); IRubyObject value = args.length > 1 ? args[1] : recv.getRuntime().getNil(); RubyException nameException = new RubyException(runtime, runtime.getClass("NameError"), "uncaught throw '" + tag + '\''); je.setPrimaryData(tag); je.setSecondaryData(value); je.setTertiaryData(nameException); | public static IRubyObject rbThrow(IRubyObject recv, IRubyObject[] args) { IRuby runtime = recv.getRuntime(); JumpException je = new JumpException(JumpException.JumpType.ThrowJump); String tag = args[0].asSymbol(); IRubyObject value = args.length > 1 ? args[1] : recv.getRuntime().getNil(); RubyException nameException = new RubyException(runtime, runtime.getClass("NameError"), "uncaught throw '" + tag + '\''); je.setPrimaryData(tag); je.setSecondaryData(value); je.setTertiaryData(nameException); throw je; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/RubyKernel.java/clean/src/org/jruby/RubyKernel.java |
public RubyClass newSubClass(String name, RubyModule parent) { return new IntegerMetaClass(name, this, parent); | public RubyClass newSubClass(String name, SinglyLinkedList parentCRef) { return new IntegerMetaClass(name, this, parentCRef); | public RubyClass newSubClass(String name, RubyModule parent) { return new IntegerMetaClass(name, this, parent); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/IntegerMetaClass.java/buggy/src/org/jruby/runtime/builtin/meta/IntegerMetaClass.java |
password = JOptionPane.showInputDialog(null, "Enter Room Password", "Need Password", JOptionPane.QUESTION_MESSAGE); | password = JOptionPane.showInputDialog(null, Res.getString("message.enter.room.password"), Res.getString("title.password"), JOptionPane.QUESTION_MESSAGE); | public static void autoJoinConferenceRoom(final String roomName, String roomJID, String password) { ChatManager chatManager = SparkManager.getChatManager(); final MultiUserChat groupChat = new MultiUserChat(SparkManager.getConnection(), roomJID); LocalPreferences pref = SettingsManager.getLocalPreferences(); final String nickname = pref.getNickname().trim(); try { GroupChatRoom chatRoom = (GroupChatRoom)chatManager.getChatContainer().getChatRoom(roomJID); MultiUserChat muc = chatRoom.getMultiUserChat(); if (!muc.isJoined()) { joinRoom(muc, nickname, password); } chatManager.getChatContainer().activateChatRoom(chatRoom); return; } catch (ChatRoomNotFoundException e) { } final GroupChatRoom room = new GroupChatRoom(groupChat); room.setTabTitle(roomName); if (requiresPassword(roomJID) && password == null) { password = JOptionPane.showInputDialog(null, "Enter Room Password", "Need Password", JOptionPane.QUESTION_MESSAGE); if (!ModelUtil.hasLength(password)) { return; } } final List errors = new ArrayList(); final String userPassword = password; final SwingWorker startChat = new SwingWorker() { public Object construct() { if (!groupChat.isJoined()) { int groupChatCounter = 0; while (true) { groupChatCounter++; String joinName = nickname; if (groupChatCounter > 1) { joinName = joinName + groupChatCounter; } if (groupChatCounter < 10) { try { if (ModelUtil.hasLength(userPassword)) { groupChat.join(joinName, userPassword); } else { groupChat.join(joinName); } break; } catch (XMPPException ex) { int code = 0; if (ex.getXMPPError() != null) { code = ex.getXMPPError().getCode(); } if (code == 0) { errors.add("No response from server."); } else if (code == 401) { errors.add("The password did not match the room's password."); } else if (code == 403) { errors.add("You have been banned from this room."); } else if (code == 404) { errors.add("The room you are trying to enter does not exist."); } else if (code == 407) { errors.add("You are not a member of this room.\nThis room requires you to be a member to join."); } else if (code != 409) { break; } } } else { break; } } } return "ok"; } public void finished() { if (errors.size() > 0) { String error = (String)errors.get(0); JOptionPane.showMessageDialog(SparkManager.getMainWindow(), error, "Unable to join the room at this time.", JOptionPane.ERROR_MESSAGE); return; } else if (groupChat.isJoined()) { ChatManager chatManager = SparkManager.getChatManager(); chatManager.getChatContainer().addChatRoom(room); chatManager.getChatContainer().activateChatRoom(room); } else { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Unable to join the room.", "Error", JOptionPane.ERROR_MESSAGE); return; } } }; startChat.start(); } | 52006 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52006/19e17d68c2c9589c1eea9caba87ba9f18813b1c4/ConferenceUtils.java/buggy/src/java/org/jivesoftware/spark/ui/conferences/ConferenceUtils.java |
Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); | initArgs(); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); | addArg("--datafile"); addArg(dataFile); } addArg("--destination"); addArg(this.destDir.getAbsolutePath()); addArg("--format"); addArg(format); if (srcDir != null) { addArg("--basedir"); addArg(srcDir); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); | handleFilesets(); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); | saveArgs(); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
throw new BuildException("Error generating report. See messages above."); | throw new BuildException("Error running reports. See messages above."); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
unInitArgs(); | public void execute() throws BuildException { Header.print(System.out); getJava().createArg().setValue("--format"); getJava().createArg().setValue(format); if (dataFile != null) { getJava().createArg().setValue("--datafile"); getJava().createArg().setValue(dataFile); } getJava().createArg().setValue("--destination"); getJava().createArg().setValue(destDir.toString()); getJava().createArg().setValue("--source"); getJava().createArg().setValue(src.toString()); if (getJava().executeJava() != 0) { throw new BuildException("Error generating report. See messages above."); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
|
public void setDataFile(String dataFile) { | public void setDataFile(String dataFile) { | public void setDataFile(String dataFile) { this.dataFile = dataFile; } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
public void setDestDir(File destDir) { | public void setDestDir(File destDir) { | public void setDestDir(File destDir) { this.destDir = destDir; } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
public void setFormat(String format) { | public void setFormat(String format) { | public void setFormat(String format) { this.format = format; } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
public void setSrcDir(Path srcDir) { if (src == null) { src = srcDir; } else { src.append(srcDir); } | public void setSrcDir(String dir) { srcDir = dir; | public void setSrcDir(Path srcDir) { if (src == null) { src = srcDir; } else { src.append(srcDir); } } | 50197 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50197/12464e2c222b85c4fe40070c50e015403ce5acfe/ReportTask.java/clean/cobertura/src/net/sourceforge/cobertura/ant/ReportTask.java |
public static IRubyObject exit(IRubyObject recv, IRubyObject args[]) { int status = 0; if (args.length > 0) { status = RubyNumeric.fix2int(args[0]); } System.exit(status); return recv.getRuntime().getNil(); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d9317e0eeee3391f47aa759e650cc97132b1f4f7/KernelModule.java/clean/org/jruby/KernelModule.java |
||
System.exit(status); return recv.getRuntime().getNil(); | throw new SystemExit(recv.getRuntime(), status); | public static IRubyObject exit(IRubyObject recv, IRubyObject args[]) { int status = 0; if (args.length > 0) { status = RubyNumeric.fix2int(args[0]); } System.exit(status); return recv.getRuntime().getNil(); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/d9317e0eeee3391f47aa759e650cc97132b1f4f7/KernelModule.java/clean/org/jruby/KernelModule.java |
public void propertyChange(PropertyChangeEvent pce) { String propName = pce.getPropertyName(); if (Browser.POPUP_POINT_PROPERTY.equals(propName)) { Browser browser = model.getBrowser(); if (browser == null) return; ImageDisplay d = browser.getLastSelectedDisplay(); Point p = browser.getPopupPoint(); if (d != null && p != null) view.showPopup(d, p); } else if (Browser.THUMB_SELECTED_PROPERTY.equals(propName)) { ImageNode d = (ImageNode) pce.getNewValue(); if (d != null) ThumbWinManager.display(d, model); } else if (Browser.SELECTED_DISPLAY_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; Browser browser = model.getBrowser(); if (browser == null) return; ImageDisplay d = browser.getLastSelectedDisplay(); treeView.accept(new SelectedNodeVisitor(treeView, d)); } else if (TreeView.TREE_POPUP_POINT_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; //tree shouldn't be null Point p = treeView.getPopupPoint(); if (p != null) view.showPopup(((JComponent) pce.getNewValue()), p); } else if (TreeView.CLOSE_PROPERTY.equals(propName)) { model.showTreeView(false); } else if (TreeView.TREE_SELECTED_DISPLAY_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; //tree shouldn't be null Browser browser = model.getBrowser(); ImageDisplay img = (ImageDisplay) pce.getNewValue(); if (img != null) { if (!(img.equals(browser.getLastSelectedDisplay()))) browser.setSelectedDisplay(img); } else browser.setSelectedDisplay(img); } else if (HiViewer.SCROLL_TO_NODE_PROPERTY.equals(propName)) { scrollToNode((ImageDisplay) pce.getNewValue()); } else if (Browser.ANNOTATED_NODE_PROPERTY.equals(propName)) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); model.getClipBoard().setSelectedPane(ClipBoard.ANNOTATION_PANE, n); model.getBrowser().setSelectedDisplay(n); } else if (Browser.CLASSIFIED_NODE_PROPERTY.equals(propName)) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); model.getClipBoard().setSelectedPane(ClipBoard.CLASSIFICATION_PANE, n); model.getBrowser().setSelectedDisplay(n); } else if (Browser.ROLL_OVER_PROPERTY.equals(propName)) { if (model.isRollOver()) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); if (n instanceof ImageNode) ThumbWinManager.rollOverDisplay((ImageNode) n, model.getBrowser()); else ThumbWinManager.rollOverDisplay(null, model.getBrowser()); } } else if (TreeView.REMOVE_ROLL_OVER_PROPERTY.equals(propName) || ClipBoard.REMOVE_ROLL_OVER_PROPERTY.equals(propName)) { if (model.isRollOver()) { ThumbWinManager.rollOverDisplay(null, model.getBrowser()); } } else if (propName.equals(DataHandler.ANNOTATED_PROPERTY)) { if (view.getDataHandler() == null) return; //TODO: refresh view.discardDataHandler(); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/39bb6f0c93c9752d3daacd9753b8402e6d393a78/HiViewerControl.java/buggy/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerControl.java |
||
} | } else if (propName.equals(DataHandler.CLASSIFIED_PROPERTY)) { if (view.getDataHandler() == null) return; view.discardDataHandler(); } | public void propertyChange(PropertyChangeEvent pce) { String propName = pce.getPropertyName(); if (Browser.POPUP_POINT_PROPERTY.equals(propName)) { Browser browser = model.getBrowser(); if (browser == null) return; ImageDisplay d = browser.getLastSelectedDisplay(); Point p = browser.getPopupPoint(); if (d != null && p != null) view.showPopup(d, p); } else if (Browser.THUMB_SELECTED_PROPERTY.equals(propName)) { ImageNode d = (ImageNode) pce.getNewValue(); if (d != null) ThumbWinManager.display(d, model); } else if (Browser.SELECTED_DISPLAY_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; Browser browser = model.getBrowser(); if (browser == null) return; ImageDisplay d = browser.getLastSelectedDisplay(); treeView.accept(new SelectedNodeVisitor(treeView, d)); } else if (TreeView.TREE_POPUP_POINT_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; //tree shouldn't be null Point p = treeView.getPopupPoint(); if (p != null) view.showPopup(((JComponent) pce.getNewValue()), p); } else if (TreeView.CLOSE_PROPERTY.equals(propName)) { model.showTreeView(false); } else if (TreeView.TREE_SELECTED_DISPLAY_PROPERTY.equals(propName)) { TreeView treeView = model.getTreeView(); if (treeView == null) return; //tree shouldn't be null Browser browser = model.getBrowser(); ImageDisplay img = (ImageDisplay) pce.getNewValue(); if (img != null) { if (!(img.equals(browser.getLastSelectedDisplay()))) browser.setSelectedDisplay(img); } else browser.setSelectedDisplay(img); } else if (HiViewer.SCROLL_TO_NODE_PROPERTY.equals(propName)) { scrollToNode((ImageDisplay) pce.getNewValue()); } else if (Browser.ANNOTATED_NODE_PROPERTY.equals(propName)) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); model.getClipBoard().setSelectedPane(ClipBoard.ANNOTATION_PANE, n); model.getBrowser().setSelectedDisplay(n); } else if (Browser.CLASSIFIED_NODE_PROPERTY.equals(propName)) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); model.getClipBoard().setSelectedPane(ClipBoard.CLASSIFICATION_PANE, n); model.getBrowser().setSelectedDisplay(n); } else if (Browser.ROLL_OVER_PROPERTY.equals(propName)) { if (model.isRollOver()) { ImageDisplay n = (ImageDisplay) pce.getNewValue(); if (n instanceof ImageNode) ThumbWinManager.rollOverDisplay((ImageNode) n, model.getBrowser()); else ThumbWinManager.rollOverDisplay(null, model.getBrowser()); } } else if (TreeView.REMOVE_ROLL_OVER_PROPERTY.equals(propName) || ClipBoard.REMOVE_ROLL_OVER_PROPERTY.equals(propName)) { if (model.isRollOver()) { ThumbWinManager.rollOverDisplay(null, model.getBrowser()); } } else if (propName.equals(DataHandler.ANNOTATED_PROPERTY)) { if (view.getDataHandler() == null) return; //TODO: refresh view.discardDataHandler(); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/39bb6f0c93c9752d3daacd9753b8402e6d393a78/HiViewerControl.java/buggy/SRC/org/openmicroscopy/shoola/agents/hiviewer/view/HiViewerControl.java |
public static void main(String args[]) throws IOException, MalformedPatternException { int n = Integer.parseInt(args[0]); LinkedList lines = new LinkedList(); try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line; while ((line = in.readLine()) != null) { lines.addLast(line); } in.close(); } catch (IOException e) { System.err.println(e); return; } String regex = "(?: ^ | [^\\d\\(]) # must be preceeded by non-digit\n" + "(?: # area code is 3 digits\n" + " \\((\\d\\d\\d)\\) # match 1: with parens\n" + "| # or\n" + " (\\d\\d\\d) # match 2: without parens\n" + ") # if match1 then match right paren\n" + "[ ] # area code followed by one space\n" + "(\\d\\d\\d) # match 3: prefix of 3 digits\n" + "[ -] # separator is either space or dash\n" + "(\\d\\d\\d\\d) # match 4: last 4 digits\n" + "(?:\\D|$) # must be followed by a non-digit\n"; PatternMatcher matcher = new Perl5Matcher(); PatternCompiler compiler = new Perl5Compiler(); Pattern pattern = null; try { pattern = compiler.compile(regex, Perl5Compiler.EXTENDED_MASK); } catch(MalformedPatternException e) { System.err.println("Bad pattern."); System.err.println(e.getMessage()); System.exit(1); } for (int i = 0; i < n; i++) { LinkedList phones = new LinkedList(); for (ListIterator li = lines.listIterator(); li.hasNext();) { String line = (String)li.next(); if (matcher.contains(line, pattern)) { MatchResult match = matcher.getMatch(); String num = ""; if (match.group(1) != null) { num = "(" + match.group(1) + ") " + match.group(3) + "-" + match.group(4); } else { num = "(" + match.group(2) + ") " + match.group(3) + "-" + match.group(4); } phones.addLast(num); } } if (i == (n - 1)) { int count = 1; for (ListIterator li = phones.listIterator(); li.hasNext();) { String num = (String)li.next(); System.out.println(count++ + ": " + num); } } } } | 53330 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/53330/eb6c850277407b38bcaefb81155941da0f27b849/regexmatch.java/buggy/tests/shootout/java-start/regexmatch.java |
||
double domainMinScreenX = (domainMin/domainGlobalMax)*width; double domainMaxScreenX = (domainMax/domainGlobalMax)*width; | double domainMinScreenX = ((domainMin-domainGlobalMin)/ (domainGlobalMax-domainGlobalMin))*width; double domainMaxScreenX = ((domainMax-domainGlobalMin)/ (domainGlobalMax-domainGlobalMin))*width; | public void paintComponent(Graphics og) { super.paintComponent(og); Graphics2D g = (Graphics2D) og; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); double width = getWidth(); double height = getHeight(); g.setColor(FILLCOLOUR); g.fillRect(1, 1, (int) width-1, (int) height-1); g.setColor(BORDERCOLOUR); g.setStroke(STROKE2); g.drawRect(0, 0, (int) width-1, (int) height-1); g.drawImage(histogramImage.getImage(), 0, 0, (int) width-1, (int) height-1, null); double codomainMin = model.getCodomainStart(); double codomainMax = model.getCodomainEnd(); double domainGlobalMax = model.getGlobalMax(); double domainMin = model.getWindowStart(); double domainMax = model.getWindowEnd(); double domainMinScreenX = (domainMin/domainGlobalMax)*width; double domainMaxScreenX = (domainMax/domainGlobalMax)*width; double codomainMinScreenY = ((255-codomainMin)/255.0f)*height; double codomainMaxScreenY = ((255-codomainMax)/255.0f)*height; double domainRangeScreen = domainMaxScreenX-domainMinScreenX; double codomainRangeScreen = codomainMinScreenY-codomainMaxScreenY; g.setColor(GREYCOLOUR); g.fillRect(0, 0, (int) domainMinScreenX+1, (int) height); g.fillRect((int) domainMaxScreenX-1, 0, (int) width, (int) height); g.fillRect(0, 0, (int) domainMinScreenX, (int) height); g.fillRect((int) domainMaxScreenX, 0, (int) width, (int) height); g.fillRect(0, 0, (int) width, (int) codomainMaxScreenY); g.fillRect(0, (int) codomainMinScreenY, (int) width, (int) height); String family = model.getFamily(); double coeff = model.getCurveCoefficient(); double a = 0; if (family.equals(RendererModel.LINEAR)) a = codomainRangeScreen/domainRangeScreen; else if (family.equals(RendererModel.POLYNOMIAL)) a = codomainRangeScreen/Math.pow(domainRangeScreen, coeff); else if (family.equals(RendererModel.EXPONENTIAL)) a = codomainRangeScreen/Math.exp(Math.pow(domainRangeScreen, coeff)); else if (family.equals(RendererModel.LOGARITHMIC)) { if (domainRangeScreen <= 1) domainRangeScreen = 1; a = codomainRangeScreen/Math.log(domainRangeScreen); } double b = codomainMinScreenY; double currentX = domainMinScreenX-1; double currentY = b; double oldX, oldY; g.setColor(model.getChannelColor(model.getSelectedChannel())); g.setStroke(STROKE1_5); for (double x = 1; x < domainRangeScreen; x += 1) { oldX = currentX; oldY = currentY; currentX = x+domainMinScreenX-1; if (family.equals(RendererModel.LINEAR)) currentY = b-a*x; else if (family.equals(RendererModel.EXPONENTIAL)) currentY = b-a*Math.exp(Math.pow(x, coeff)); else if (family.equals(RendererModel.POLYNOMIAL)) currentY = b-a*Math.pow(x, coeff); else if (family.equals(RendererModel.LOGARITHMIC)) currentY = b-a*Math.log(x); g.drawLine((int) oldX, (int) oldY, (int) currentX, (int) currentY); } } | 54698 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/54698/04901a2ad1d2803c9892af547b391655856cae83/GraphicsPaneUI.java/buggy/SRC/org/openmicroscopy/shoola/agents/imviewer/rnd/GraphicsPaneUI.java |
showImages(); | showImages(); break; case IMAGES_SELECTION: bringSelector(e); break; | public void actionPerformed(ActionEvent e) { int index = -1; try { index = Integer.parseInt(e.getActionCommand()); 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/DatasetImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/dataset/DatasetImagesDiffPaneManager.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/DatasetImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/dataset/DatasetImagesDiffPaneManager.java |
|
case DatasetImagesDiffPane.IMAGES_USED: images = control.getImagesInUserDatasetsDiff(); break; | private void showImages() { int selectedIndex = view.selections.getSelectedIndex(); if (selectedIndex != selectionIndex) { selectionIndex = selectedIndex; List images = null; switch (selectedIndex) { case DatasetImagesDiffPane.IMAGES_IMPORTED: images = control.getImagesDiff(); break; case DatasetImagesDiffPane.IMAGES_USED: images = control.getImagesInUserDatasetsDiff(); break; case DatasetImagesDiffPane.IMAGES_GROUP: images = control.getImagesInUserGroupDiff(); break; case DatasetImagesDiffPane.IMAGES_SYSTEM: images = control.getImagesInSystemDiff(); 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/DatasetImagesDiffPaneManager.java/clean/SRC/org/openmicroscopy/shoola/agents/datamng/editors/dataset/DatasetImagesDiffPaneManager.java |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.