bugged
stringlengths 6
599k
| fixed
stringlengths 6
40.8M
| __index_level_0__
int64 0
3.24M
|
---|---|---|
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setLeavesViews(Set nodes, TreeImageSet parent) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,073 |
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setLeavesViews(Set nodes) { DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,074 |
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,075 |
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setLeavesViews(Set nodes) { TreeImageDisplay node = model.getLastSelectedDisplay(); DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); if (node instanceof TreeImageNode) return; node.removeAllChildren(); node.setChildrenLoaded(Boolean.TRUE); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) node.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(node, sorter.sort(nodes), dtm); } else buildEmptyNode(node); dtm.reload(node); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,076 |
void setViews(Set nodes, boolean reload) { DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); TreeImageDisplay root = (TreeImageDisplay) dtm.getRoot(); root.removeAllChildren(); root.setChildrenLoaded(Boolean.TRUE); dtm.reload(); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) root.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(root, sorter.sort(nodes), (DefaultTreeModel) treeDisplay.getModel()); } else buildEmptyNode(root); if (reload) dtm.reload(); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setViews(Set nodes, boolean reload) { DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); TreeImageDisplay root = (TreeImageDisplay) dtm.getRoot(); root.removeAllChildren(); root.setChildrenLoaded(Boolean.TRUE); dtm.reload(); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) root.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(root, sorter.sort(nodes), (DefaultTreeModel) treeDisplay.getModel()); if (!reload) reload = reloadRoot; reloadRoot = true; } else buildEmptyNode(root); if (reload) dtm.reload(); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,077 |
void setViews(Set nodes, boolean reload) { DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); TreeImageDisplay root = (TreeImageDisplay) dtm.getRoot(); root.removeAllChildren(); root.setChildrenLoaded(Boolean.TRUE); dtm.reload(); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) root.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(root, sorter.sort(nodes), (DefaultTreeModel) treeDisplay.getModel()); } else buildEmptyNode(root); if (reload) dtm.reload(); if (!model.isMainTree()) loadGoIntoTree(); }
|
void setViews(Set nodes, boolean reload) { DefaultTreeModel dtm = (DefaultTreeModel) treeDisplay.getModel(); TreeImageDisplay root = (TreeImageDisplay) dtm.getRoot(); root.removeAllChildren(); root.setChildrenLoaded(Boolean.TRUE); dtm.reload(); if (nodes.size() != 0) { Iterator i = nodes.iterator(); while (i.hasNext()) root.addChildDisplay((TreeImageDisplay) i.next()) ; buildTreeNode(root, sorter.sort(nodes), (DefaultTreeModel) treeDisplay.getModel()); } else buildEmptyNode(root); if (reload) dtm.reload(root); if (!model.isMainTree()) loadGoIntoTree(); }
| 3,239,078 |
private Note createNoteFromElement(Element el, Note parent) { if (!el.getName().equals("note")) { throw new KoalaException("Koala Notes could not build a document from file '" + file.getName() + "': expected a note element but got a " + el.getName() + "."); } String name = el.getAttributeValue("name"); String text = el.getAttributeValue("text"); Note n = new Note(name, parent, text); List<Element> es = (List<Element>) el.getChildren(); for (Element childElement : es) { createNoteFromElement(childElement, n); } return n; }
|
private Note createNoteFromElement(Element el, Note parent) { if (!el.getName().equals("note")) { throw new KoalaException("Koala Notes could not build a document from file '" + file.getName() + "': expected a note element but got a " + el.getName() + "."); } String name = el.getAttributeValue("name"); String text = el.getAttributeValue("text"); Note n = new Note(name, parent, text); List<Element> es = (List<Element>) el.getChildren(); for (Element childElement : es) { createNoteFromElement(childElement, n); } return n; }
| 3,239,079 |
public SourcePosition() { this("", -1); }
|
public SourcePosition() { this("", 0); }
| 3,239,080 |
public void initCoreClasses() { objectClass = defineBootClass("Object", null); moduleClass = defineBootClass("Module", objectClass); classClass = defineBootClass("Class", moduleClass); RubyClass metaClass = objectClass.makeMetaClass(classClass); metaClass = moduleClass.makeMetaClass(metaClass); metaClass = classClass.makeMetaClass(metaClass); kernelModule = RubyKernel.createKernelModule(ruby); objectClass.includeModule(kernelModule); objectClass.definePrivateMethod("initialize", CallbackFactory.getNilMethod()); classClass.definePrivateMethod("inherited", CallbackFactory.getNilMethod()); RubyObject.createObjectClass(objectClass); RubyClass.createClassClass(classClass); RubyModule.createModuleClass(moduleClass); symbolClass = RubySymbol.createSymbolClass(ruby); nilClass = RubyNil.createNilClass(ruby); falseClass = RubyBoolean.createFalseClass(ruby); trueClass = RubyBoolean.createTrueClass(ruby); comparableModule = RubyComparable.createComparable(ruby); enumerableModule = RubyEnumerable.createEnumerableModule(ruby); precisionModule = RubyPrecision.createPrecisionModule(ruby); numericClass = RubyNumeric.createNumericClass(ruby); integerClass = RubyInteger.createIntegerClass(ruby); fixnumClass = RubyFixnum.createFixnumClass(ruby); bignumClass = RubyBignum.createBignumClass(ruby); floatClass = RubyFloat.createFloatClass(ruby); stringClass = RubyString.createStringClass(ruby); regExpClass = RubyRegexp.createRegexpClass(ruby); matchDataClass = RubyMatchData.createMatchDataClass(ruby); arrayClass = RubyArray.createArrayClass(ruby); hashClass = RubyHash.createHashClass(ruby); rangeClass = RubyRange.createRangeClass(ruby); javaModule = RubyJava.createJavaModule(ruby); javaObjectClass = RubyJavaObject.createJavaObjectClass(ruby); javaInterfaceClass = RubyJavaInterface.createJavaInterfaceClass(ruby); ioClass = RubyIO.createIOClass(ruby); fileClass = RubyFile.createFileClass(ruby); dirClass = RubyDir.createDirClass(ruby); exceptionClass = RubyException.createExceptionClass(ruby); methodClass = RubyMethod.createMethodClass(ruby); procClass = RubyProc.createProcClass(ruby); objectSpaceModule = RubyObjectSpace.createObjectSpaceModule(ruby); marshalModule = RubyMarshal.createMarshalModule(ruby); mathModule = RubyMath.createMathModule(ruby); timeClass = RubyTime.createTimeClass(ruby); structClass = RubyStruct.createStructClass(ruby); }
|
public void initCoreClasses() { objectClass = defineBootClass("Object", null); moduleClass = defineBootClass("Module", objectClass); classClass = defineBootClass("Class", moduleClass); RubyClass metaClass = objectClass.makeMetaClass(classClass); metaClass = moduleClass.makeMetaClass(metaClass); metaClass = classClass.makeMetaClass(metaClass); kernelModule = RubyKernel.createKernelModule(ruby); objectClass.includeModule(kernelModule); objectClass.definePrivateMethod("initialize", CallbackFactory.getNilMethod()); classClass.definePrivateMethod("inherited", CallbackFactory.getNilMethod()); RubyObject.createObjectClass(objectClass); RubyClass.createClassClass(classClass); RubyModule.createModuleClass(moduleClass); symbolClass = RubySymbol.createSymbolClass(ruby); nilClass = RubyNil.createNilClass(ruby); falseClass = RubyBoolean.createFalseClass(ruby); trueClass = RubyBoolean.createTrueClass(ruby); comparableModule = RubyComparable.createComparable(ruby); enumerableModule = RubyEnumerable.createEnumerableModule(ruby); precisionModule = RubyPrecision.createPrecisionModule(ruby); numericClass = RubyNumeric.createNumericClass(ruby); integerClass = RubyInteger.createIntegerClass(ruby); fixnumClass = RubyFixnum.createFixnumClass(ruby); bignumClass = RubyBignum.createBignumClass(ruby); floatClass = RubyFloat.createFloatClass(ruby); stringClass = RubyString.createStringClass(ruby); regExpClass = RubyRegexp.createRegexpClass(ruby); matchDataClass = RubyMatchData.createMatchDataClass(ruby); arrayClass = RubyArray.createArrayClass(ruby); hashClass = RubyHash.createHashClass(ruby); rangeClass = RubyRange.createRangeClass(ruby); javaModule = RubyJava.createJavaModule(ruby); javaObjectClass = RubyJavaObject.createJavaObjectClass(ruby); javaInterfaceClass = RubyJavaInterface.createJavaInterfaceClass(ruby); ioClass = RubyIO.createIOClass(ruby); fileClass = RubyFile.createFileClass(ruby); dirClass = RubyDir.createDirClass(ruby); exceptionClass = RubyException.createExceptionClass(ruby); methodClass = RubyMethod.createMethodClass(ruby); procClass = RubyProc.createProcClass(ruby); objectSpaceModule = RubyObjectSpace.createObjectSpaceModule(ruby); marshalModule = RubyMarshal.createMarshalModule(ruby); mathModule = RubyMath.createMathModule(ruby); timeClass = RubyTime.createTimeClass(ruby); structClass = RubyStruct.createStructClass(ruby); }
| 3,239,081 |
public void changePermissions(final IObject iObject, final Permissions perms) { AdminAction action = new AdminAction(){ public void runAsAdmin() { IObject copy = iQuery.get(iObject.getClass(), iObject.getId()); Permissions p = new Permissions(perms); // FIXME ticket:215 copy.getDetails().setPermissions(p); iUpdate.saveObject(copy); } }; getSecuritySystem().runAsAdmin(action); }
|
public void changePermissions(final IObject iObject, final Permissions perms) { AdminAction action = new AdminAction(){ public void runAsAdmin() { Permissions p = new Permissions(perms); // FIXME ticket:215 copy.getDetails().setPermissions(p); iUpdate.saveObject(copy); } }; getSecuritySystem().runAsAdmin(action); }
| 3,239,082 |
public void runAsAdmin() { IObject copy = iQuery.get(iObject.getClass(), iObject.getId()); Permissions p = new Permissions(perms); // FIXME ticket:215 copy.getDetails().setPermissions(p); iUpdate.saveObject(copy); }
|
public void runAsAdmin() { Permissions p = new Permissions(perms); // FIXME ticket:215 copy.getDetails().setPermissions(p); iUpdate.saveObject(copy); }
| 3,239,083 |
public void setUp() { ruby = Ruby.getDefaultInstance(null); rubyObject = new RubyObject(ruby, ruby.getClasses().getObjectClass()); }
|
public void setUp() { ruby = Ruby.getDefaultInstance(null); rubyObject = ruby.getFactory().newObject(ruby.getClasses().getObjectClass()); }
| 3,239,084 |
void initialize(TreeViewerControl controller, TreeViewerModel model) { this.controller = controller; this.model = model; IconManager icons = IconManager.getInstance(); statusBar = new StatusBar(icons.getIcon(IconManager.STATUS_INFO)); statusBar.addPropertyChangeListener(controller); toolBar = new ToolBar(controller); //popupMenu = new PopupMenu(controller); loadingWin = new LoadingWindow(this); loadingWin.addPropertyChangeListener(controller); initComponents(); configureDisplayButtons(); setJMenuBar(createMenuBar()); buildGUI(); controller.attachUIListeners(tabs); }
|
void initialize(TreeViewerControl controller, TreeViewerModel model) { this.controller = controller; this.model = model; IconManager icons = IconManager.getInstance(); statusBar = new StatusBar(icons.getIcon(IconManager.STATUS_INFO)); statusBar.addPropertyChangeListener(controller); toolBar = new ToolBar(controller); //popupMenu = new PopupMenu(controller); loadingWin = new LoadingWindow(this); loadingWin.addPropertyChangeListener(controller); initComponents(); configureDisplayButtons(); setJMenuBar(createMenuBar()); buildGUI(); controller.attachUIListeners(tabs); }
| 3,239,085 |
void onStateChanged(boolean b) { tabs.setEnabled(b); }
|
void onStateChanged(boolean b) { tabs.setEnabled(b); }
| 3,239,086 |
public void runAnn(String name, Class c){ // Class, Set<Container>, Map //q = PojosQueryBuilder.buildAnnsQuery(c,po.map()); m.remove("exp"); // unused n = name;go(); }
|
private void runAnn(String name, Class c){ // Class, Set<Container>, Map //q = PojosQueryBuilder.buildAnnsQuery(c,po.map()); m.remove("exp"); // unused n = name;go(); }
| 3,239,087 |
public void runFind(String name, Class c){ // Class, Set<Image>, options //q = PojosQueryBuilder.buildFindQuery(c,po.map()); n = name;go(); }
|
private void runFind(String name, Class c){ // Class, Set<Image>, options //q = PojosQueryBuilder.buildFindQuery(c,po.map()); n = name;go(); }
| 3,239,088 |
public void runGet(String name, Class c){ // Class, Set<Container>, Map //q = PojosQueryBuilder.buildGetQuery(c,po.map()); n = name;go(); }
|
private void runGet(String name, Class c){ // Class, Set<Container>, Map //q = PojosQueryBuilder.buildGetQuery(c,po.map()); n = name;go(); }
| 3,239,089 |
public void runLoad(String name, Class c){ // Class, Set<Container>, options //q = PojosQueryBuilder.buildLoadQuery(c,false,po.map()); n = name;go(); }
|
private void runLoad(String name, Class c){ // Class, Set<Container>, options //q = PojosQueryBuilder.buildLoadQuery(c,false,po.map()); n = name;go(); }
| 3,239,090 |
public void runPaths(String name, String algorithm){ // Set<Image>, Algorithm options //q = PojosQueryBuilder.buildPathsQuery(algorithm,po.map()); n = name;go(); }
|
private void runPaths(String name, String algorithm){ // Set<Image>, Algorithm options //q = PojosQueryBuilder.buildPathsQuery(algorithm,po.map()); n = name;go(); }
| 3,239,091 |
public void setRoiOnOff(boolean b) { roiOnOff = b; if (!roiOnOff) presentation.removeFromLayer(); else { paintDrawing(); presentation.addToLayer(); presentation.resetLens(); } }
|
public void setRoiOnOff(boolean b) { roiOnOff = b; if (!roiOnOff) presentation.removeFromLayer(); else { paintDrawing(); presentation.addToLayer(); presentation.resetLens(); } }
| 3,239,093 |
public void setRoiOnOff(boolean b) { roiOnOff = b; if (!roiOnOff) presentation.removeFromLayer(); else { paintDrawing(); presentation.addToLayer(); presentation.resetLens(); } }
|
public void setRoiOnOff(boolean b) { roiOnOff = b; if (!roiOnOff) presentation.removeFromLayer(); else { paintDrawing(); presentation.addCanvasToLayer(); presentation.resetLens(); } }
| 3,239,094 |
public void showDialog(JDialog dialog) { UIUtilities.centerAndShow(dialog); }
|
public void showDialog(JDialog dialog) { UIUtilities.centerAndShow(dialog); }
| 3,239,096 |
public void showInspector() { if (imageInspector == null) imageInspector = new ImageInspector(this, presentation.getCanvas(), magFactor); UIUtilities.centerAndShow(imageInspector); if (roiOnOff) abstraction.addRoiCanvas(false); }
|
public void showInspector() { if (imageInspector == null) imageInspector = new ImageInspector(this, presentation.getCanvas(), magFactor); UIUtilities.centerAndShow(imageInspector); if (roiOnOff) imageInspector.getManager().setLensEnabled(false); }
| 3,239,097 |
public void showRendering() { abstraction.showRendering(); }
|
public void showRendering() { abstraction.showRendering(); }
| 3,239,098 |
public RubyClass newSubClass(String name, RubyModule parentModule) { RubyClass newClass = new RubyClass(getRuntime(), getRuntime().getClasses().getClassClass(), this, parentModule, name); newClass.makeMetaClass(getMetaClass()); newClass.inheritedBy(this); getRuntime().getClasses().putClass(name, newClass); return newClass; }
|
public RubyClass newSubClass(String name, RubyModule parentModule) { Ruby runtime = getRuntime(); RubyClass newClass = new RubyClass(runtime, runtime.getClasses().getClassClass(), this, parentModule, name); newClass.makeMetaClass(getMetaClass()); newClass.inheritedBy(this); getRuntime().getClasses().putClass(name, newClass); return newClass; }
| 3,239,099 |
public RubyClass newSubClass(String name, RubyModule parentModule) { RubyClass newClass = new RubyClass(getRuntime(), getRuntime().getClasses().getClassClass(), this, parentModule, name); newClass.makeMetaClass(getMetaClass()); newClass.inheritedBy(this); getRuntime().getClasses().putClass(name, newClass); return newClass; }
|
public RubyClass newSubClass(String name, RubyModule parentModule) { RubyClass newClass = new RubyClass(getRuntime(), getRuntime().getClasses().getClassClass(), this, parentModule, name); newClass.makeMetaClass(getMetaClass()); newClass.inheritedBy(this); runtime.getClasses().putClass(name, newClass, parentModule); return newClass; }
| 3,239,100 |
public IObject fillIObject( IObject obj, ReverseModelMapper mapper) { if ( obj instanceof Experimenter) { Experimenter e = (Experimenter) obj; if (super.fill(e)) { e.setFirstName(this.getFirstName()); e.setLastName(this.getLastName()); e.setEmail(this.getEmail()); e.setInstitution(this.getInstitution()); if (this.getGroups() != null) { for (Iterator it = this.getGroups().iterator(); it.hasNext();) { GroupData g = (GroupData) it.next(); e.linkExperimenterGroup((ExperimenterGroup) mapper.map(g)); } } } return e; } else { throw new IllegalArgumentException( "ExperimenterData can only fill Experimenter."); } }
|
public IObject fillIObject( IObject obj, ReverseModelMapper mapper) { if ( obj instanceof Experimenter) { Experimenter e = (Experimenter) obj; if (super.fill(e)) { e.setFirstName(this.getFirstName()); e.setLastName(this.getLastName()); e.setEmail(this.getEmail()); e.setInstitution(this.getInstitution()); if (this.getGroups() != null) { for (Iterator it = this.getGroups().iterator(); it.hasNext();) { GroupData g = (GroupData) it.next(); e.linkExperimenterGroup((ExperimenterGroup) mapper.map(g)); } } } return e; } else { throw new IllegalArgumentException( "ExperimenterData can only fill Experimenter."); } }
| 3,239,102 |
void annotateAttributesData(List attributes) throws DSOutOfServiceException, DSAccessException { try { System.err.println(attributes.get(0)); getAnnotationManager().annotateAttributes(attributes); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } }
|
void annotateAttributesData(List attributes) throws DSOutOfServiceException, DSAccessException { try { System.err.println(attributes.get(0)); getAnnotationManager().annotateAttributes(attributes); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } }
| 3,239,103 |
Object retrieveData(Class dto, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieve(dto, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
|
Object retrieveData(Class dto, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieve(dto, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
| 3,239,104 |
Object retrieveListSTSData(String semanticTypeName, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieveList(semanticTypeName, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
|
Object retrieveListSTSData(String semanticTypeName, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieveList(semanticTypeName, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
| 3,239,105 |
Object retrieveSTSData(String semanticTypeName, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieve(semanticTypeName, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
|
Object retrieveSTSData(String semanticTypeName, Criteria c) throws DSOutOfServiceException, DSAccessException { Object retVal; try { retVal = getDataFactory().retrieve(semanticTypeName, c); } catch (RemoteConnectionException rce) { throw new DSOutOfServiceException("Can't connect to OMEDS", rce); } catch (RemoteAuthenticationException rae) { throw new DSOutOfServiceException("Not logged in", rae); } catch (RemoteServerErrorException rsee) { rsee.printStackTrace(); throw new DSAccessException("Can't load data", rsee); } return retVal; }
| 3,239,106 |
public ImagePlate(Integer attributeId, String well, Integer sample, org.openmicroscopy.omero.model.Image image, org.openmicroscopy.omero.model.ModuleExecution moduleExecution) { this.attributeId = attributeId; this.well = well; this.sample = sample; this.image = image; this.moduleExecution = moduleExecution; }
|
public ImagePlate(Integer attributeId, String well, Integer sample, org.openmicroscopy.omero.model.Image image, org.openmicroscopy.omero.model.ModuleExecution moduleExecution) { this.attributeId = attributeId; this.well = well; this.sample = sample; this.image = image; this.moduleExecution = moduleExecution; }
| 3,239,107 |
public static RubyClass createRangeClass(Ruby ruby) { return new RangeDefinition(ruby).getType(); }
|
public static RubyClass createRangeClass(Ruby ruby) { RubyClass result = ruby.defineClass("Range", ruby.getClasses().getObjectClass()); CallbackFactory callbackFactory = ruby.callbackFactory(); result.includeModule(ruby.getClasses().getEnumerableModule()); result.defineMethod("==", callbackFactory.getMethod(RubyRange.class, "equal", IRubyObject.class)); result.defineMethod("===", callbackFactory.getMethod(RubyRange.class, "op_eqq", IRubyObject.class)); result.defineMethod("begin", callbackFactory.getMethod(RubyRange.class, "first")); result.defineMethod("each", callbackFactory.getMethod(RubyRange.class, "each")); result.defineMethod("end", callbackFactory.getMethod(RubyRange.class, "last")); result.defineMethod("exclude_end?", callbackFactory.getMethod(RubyRange.class, "exclude_end_p")); result.defineMethod("first", callbackFactory.getMethod(RubyRange.class, "first")); result.defineMethod("initialize", callbackFactory.getOptMethod(RubyRange.class, "initialize")); result.defineMethod("inspect", callbackFactory.getMethod(RubyRange.class, "inspect")); result.defineMethod("last", callbackFactory.getMethod(RubyRange.class, "last")); result.defineMethod("length", callbackFactory.getMethod(RubyRange.class, "length")); result.defineMethod("size", callbackFactory.getMethod(RubyRange.class, "length")); result.defineMethod("to_s", callbackFactory.getMethod(RubyRange.class, "inspect")); return result; }
| 3,239,108 |
public RubyString join(RubyString sep) { StringBuffer buf = new StringBuffer(); int length = getLength(); if (length == 0) { getRuntime().newString(""); } boolean taint = isTaint() || sep.isTaint(); RubyString str; IRubyObject tmp = null; for (long i = 0; i < length; i++) { tmp = entry(i); taint |= tmp.isTaint(); if (tmp instanceof RubyString) { // do nothing } else if (tmp instanceof RubyArray) { tmp = ((RubyArray) tmp).join(sep); } else { tmp = RubyString.objAsString(tmp); } if (i > 0 && !sep.isNil()) { buf.append(sep.getValue()); } buf.append(((RubyString)tmp).getValue()); } str = RubyString.newString(getRuntime(), buf.toString()); str.setTaint(taint); return str; }
|
public RubyString join(RubyString sep) { StringBuffer buf = new StringBuffer(); int length = getLength(); if (length == 0) { getRuntime().newString(""); } boolean taint = isTaint() || sep.isTaint(); RubyString str; IRubyObject tmp = null; for (long i = 0; i < length; i++) { tmp = entry(i); taint |= tmp.isTaint(); if (tmp instanceof RubyString) { // do nothing } else if (tmp instanceof RubyArray) { tmp = ((RubyArray) tmp).join(sep); } else { tmp = RubyString.objAsString(tmp); } if (i > 0 && !sep.isNil()) { buf.append(sep.toString()); } buf.append(((RubyString)tmp).getValue()); } str = RubyString.newString(getRuntime(), buf.toString()); str.setTaint(taint); return str; }
| 3,239,109 |
public RubyString join(RubyString sep) { StringBuffer buf = new StringBuffer(); int length = getLength(); if (length == 0) { getRuntime().newString(""); } boolean taint = isTaint() || sep.isTaint(); RubyString str; IRubyObject tmp = null; for (long i = 0; i < length; i++) { tmp = entry(i); taint |= tmp.isTaint(); if (tmp instanceof RubyString) { // do nothing } else if (tmp instanceof RubyArray) { tmp = ((RubyArray) tmp).join(sep); } else { tmp = RubyString.objAsString(tmp); } if (i > 0 && !sep.isNil()) { buf.append(sep.getValue()); } buf.append(((RubyString)tmp).getValue()); } str = RubyString.newString(getRuntime(), buf.toString()); str.setTaint(taint); return str; }
|
public RubyString join(RubyString sep) { StringBuffer buf = new StringBuffer(); int length = getLength(); if (length == 0) { getRuntime().newString(""); } boolean taint = isTaint() || sep.isTaint(); RubyString str; IRubyObject tmp = null; for (long i = 0; i < length; i++) { tmp = entry(i); taint |= tmp.isTaint(); if (tmp instanceof RubyString) { // do nothing } else if (tmp instanceof RubyArray) { tmp = ((RubyArray) tmp).join(sep); } else { tmp = RubyString.objAsString(tmp); } if (i > 0 && !sep.isNil()) { buf.append(sep.getValue()); } buf.append(((RubyString)tmp).toString()); } str = RubyString.newString(getRuntime(), buf.toString()); str.setTaint(taint); return str; }
| 3,239,110 |
private void callInits() { classes = new RubyClasses(this); classes.initCoreClasses(); exceptions = new RubyExceptions(this); exceptions.initDefaultExceptionClasses(); rubyTopSelf = new RubyObject(this, classes.getObjectClass()); /*rubyTopSelf.defineSingletonMethod("to_s", new RubyCallbackMethod() { public RubyObject execute(RubyObject recv, RubyObject[] args, Ruby ruby) { return RubyString.m_newString(ruby, "main"); } });*/ createFixnumCache(); }
|
private void callInits() { classes = new RubyClasses(this); classes.initCoreClasses(); exceptions = new RubyExceptions(this); exceptions.initDefaultExceptionClasses(); rubyTopSelf = new RubyObject(this, classes.getObjectClass()); /*rubyTopSelf.defineSingletonMethod("to_s", new RubyCallbackMethod() { public RubyObject execute(RubyObject recv, RubyObject[] args, Ruby ruby) { return RubyString.m_newString(ruby, "main"); } });*/ }
| 3,239,111 |
public RubyObject iterate(Callback iterateMethod, RubyObject data1, Callback blockMethod, RubyObject data2) { Node node = new NodeFactory(this).newIFunc(blockMethod, data2); // VALUE self = ruby_top_self; getIter().push(RubyIter.ITER_PRE); getBlock().push(null, node, getRubyTopSelf()); try { while (true) { try { return iterateMethod.execute(data1, null, this); } catch (BreakException bExcptn) { return getNil(); } catch (ReturnException rExcptn) { return rExcptn.getReturnValue(); } catch (RetryException rExcptn) { } } } finally { getIter().pop(); getBlock().pop(); } }
|
public RubyObject iterate(Callback iterateMethod, RubyObject data1, Callback blockMethod, RubyObject data2) { Node node = new NodeFactory(this).newIFunc(blockMethod, data2); // VALUE self = ruby_top_self; getIter().push(RubyIter.ITER_PRE); getBlock().push(null, node, getRubyTopSelf()); try { while (true) { try { return iterateMethod.execute(data1, null, this); } catch (BreakJump bExcptn) { return getNil(); } catch (ReturnException rExcptn) { return rExcptn.getReturnValue(); } catch (RetryException rExcptn) { } } } finally { getIter().pop(); getBlock().pop(); } }
| 3,239,112 |
public String toString() { StringBuffer sb = new StringBuffer(); sb.append("("); for (int i = 0; i < _content.length; i++) { if (i != 0) { sb.append(", "); } sb.append(_content[i].toString()); } sb.append(")"); return sb.toString(); }
|
public String toString() { StringBuffer sb = new StringBuffer(); sb.append("("); for (int i = 0; i < _content.length; i++) { if (i != 0) { sb.append(", "); } sb.append(_content[i] == null ? "null" : _content[i].toString()); } sb.append(")"); return sb.toString(); }
| 3,239,113 |
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
|
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
| 3,239,114 |
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
|
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
| 3,239,115 |
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
|
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
| 3,239,116 |
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
|
private BufferedImage createBufferedImage(RGBBuffer buf, int sizeX, int sizeY) { RGBByteBuffer j2DBuf = new RGBByteBuffer(buf, sizeX, sizeY); BandedSampleModel csm = new BandedSampleModel(DataBuffer.TYPE_BYTE, sizeX, sizeY, 3); BufferedImage image = new BufferedImage(sizeX, sizeY, BufferedImage.TYPE_INT_RGB); image.setData(Raster.createWritableRaster(csm, j2DBuf, null)); return image; /* Unfortunately, the following creates "CUSTOM" buffered images which with some VM's cannot be used in the ImagingLib. Nasty. ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); WritableRaster r = Raster.createWritableRaster(csm, j2DBuf, null); return new BufferedImage(cm, r, false, null); */ }
| 3,239,117 |
private BufferedImage createScaledImage(Pixels pixels, RenderingDef def, Integer sizeX, Integer sizeY) { // Original sizes and thumbnail metadata int origSizeX = pixels.getSizeX(); int origSizeY = pixels.getSizeY(); // Retrieve our rendered data and translate to a buffered image initializeRenderingEngine(pixels); PlaneDef pd = new PlaneDef(PlaneDef.XY, re.getDefaultT()); pd.setZ(re.getDefaultZ()); RGBBuffer buf = re.render(pd); BufferedImage image = createBufferedImage(buf, origSizeX, origSizeY); // Finally, scale our image using scaling factors (percentage). log.info("Setting xScale factor: " + sizeX + "/" + origSizeX); float xScale = (float) sizeX / origSizeX; log.info("Setting yScale factor: " + sizeX + "/" + origSizeX); float yScale = (float) sizeY / origSizeY; return iScale.scaleBufferedImage(image, xScale, yScale); }
|
private BufferedImage createScaledImage(Pixels pixels, RenderingDef def, Integer sizeX, Integer sizeY) { // Original sizes and thumbnail metadata int origSizeX = pixels.getSizeX(); int origSizeY = pixels.getSizeY(); // Retrieve our rendered data and translate to a buffered image initializeRenderingEngine(pixels); PlaneDef pd = new PlaneDef(PlaneDef.XY, re.getDefaultT()); pd.setZ(re.getDefaultZ()); RGBBuffer buf = re.render(pd); BufferedImage image = createBufferedImage(buf, origSizeX, origSizeY); // Finally, scale our image using scaling factors (percentage). log.info("Setting xScale factor: " + sizeX + "/" + origSizeX); float xScale = (float) sizeX / origSizeX; log.info("Setting yScale factor: " + sizeX + "/" + origSizeX); float yScale = (float) sizeY / origSizeY; return iScale.scaleBufferedImage(image, xScale, yScale); }
| 3,239,118 |
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
|
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && (y > getSizeY() - 1 || y < 0)) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
| 3,239,119 |
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
|
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && (z > getSizeZ() - 1 || z < 0)) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
| 3,239,120 |
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
|
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && (c > getSizeC() - 1 || c < 0)) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
| 3,239,121 |
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && t > getSizeT()) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
|
private void checkBounds(Integer y, Integer z, Integer c, Integer t) throws DimensionsOutOfBoundsException { if (y != null && y > getSizeY()) throw new DimensionsOutOfBoundsException("Y '" + y + "' greater than height '" + getSizeY() + "'."); if (z != null && z > getSizeZ()) throw new DimensionsOutOfBoundsException("Z '" + z + "' greater than height '" + getSizeZ() + "'."); if (c != null && c > getSizeC()) throw new DimensionsOutOfBoundsException("C '" + c + "' greater than height '" + getSizeC() + "'."); if (t != null && (t > getSizeT() - 1 || t < 0)) throw new DimensionsOutOfBoundsException("T '" + t + "' greater than height '" + getSizeT() + "'."); }
| 3,239,122 |
public RubyFixnum hash() { return RubyFixnum.newFixnum(getRuby(), symbol.hashCode()); }
|
public RubyFixnum hash() { return id(); }
| 3,239,123 |
public IRubyObject insert(RubyNumeric index, IRubyObject[] args) { // ruby does not bother to bounds check index, if no elements are // to be added. if (args != null && args.length == 0) { return this; } // too negative of an offset will throw an IndexError long offset = index.getLongValue(); if (offset < 0 && getLength() + offset < 0) { throw new IndexError(getRuntime(), "index " + (getLength() + offset) + " out of array"); } // An offset larger than the current length will pad with nils // to length if (offset > getLength()) { long difference = offset - getLength(); IRubyObject nil = getRuntime().getNil(); for (long i = 0; i < difference; i++) { list.add(nil); } } if (offset < 0) { offset += getLength() + 1; } for (int i = 0; i < args.length; i++) { list.add((int) (offset + i), args[i]); } return this; }
|
public IRubyObject insert(RubyNumeric index, IRubyObject[] args) { // ruby does not bother to bounds check index, if no elements are // to be added. if (args == null || args.length == 0) { return this; } // too negative of an offset will throw an IndexError long offset = index.getLongValue(); if (offset < 0 && getLength() + offset < 0) { throw new IndexError(getRuntime(), "index " + (getLength() + offset) + " out of array"); } // An offset larger than the current length will pad with nils // to length if (offset > getLength()) { long difference = offset - getLength(); IRubyObject nil = getRuntime().getNil(); for (long i = 0; i < difference; i++) { list.add(nil); } } if (offset < 0) { offset += getLength() + 1; } for (int i = 0; i < args.length; i++) { list.add((int) (offset + i), args[i]); } return this; }
| 3,239,124 |
public void unmarshal(HttpMethodBase response, HttpChannel context) throws ImageServiceException, IOException { //Make sure we actually got a binary stream. checkStatusCode(response); checkContentType(response, MIME_TYPE); //Read the stream into buffer. readResponseStream(response.getResponseBodyAsStream(), buffer, context.getBlockSize()); }
|
public void unmarshal(HttpMethod response, HttpChannel context) throws ImageServiceException, IOException { //Make sure we actually got a binary stream. checkStatusCode(response); checkContentType(response, MIME_TYPE); //Read the stream into buffer. readResponseStream(response.getResponseBodyAsStream(), buffer, context.getBlockSize()); }
| 3,239,125 |
public void create() { super.create(); delegate = (RenderingEngine) applicationContext.getBean( RenderingEngine.class.getName()); }
|
public void create() { super.create(); delegate = (RenderingEngine) applicationContext.getBean( RenderingEngine.class.getName()); }
| 3,239,127 |
public Object invoke( InvocationContext context ) throws Exception { return wrap( context, "&renderService" ); }
|
public Object invoke( InvocationContext context ) throws Exception { return wrap( context, RenderingEngine.class ); }
| 3,239,128 |
public static RubyClass createFixnumClass(Ruby ruby) { RubyClass fixnumClass = ruby.defineClass("Fixnum", ruby.getClasses().getIntegerClass()); fixnumClass.includeModule(ruby.getClasses().getPrecisionModule()); fixnumClass.defineSingletonMethod("induced_from", CallbackFactory.getSingletonMethod(RubyFixnum.class, "induced_from", RubyObject.class)); fixnumClass.defineMethod("to_f", CallbackFactory.getMethod(RubyFixnum.class, "to_f")); fixnumClass.defineMethod("to_s", CallbackFactory.getMethod(RubyFixnum.class, "to_s")); fixnumClass.defineMethod("to_str", CallbackFactory.getMethod(RubyFixnum.class, "to_s")); fixnumClass.defineMethod("taint", CallbackFactory.getSelfMethod(0)); fixnumClass.defineMethod("freeze", CallbackFactory.getSelfMethod(0)); fixnumClass.defineMethod("<<", CallbackFactory.getMethod(RubyFixnum.class, "op_lshift", RubyObject.class)); fixnumClass.defineMethod(">>", CallbackFactory.getMethod(RubyFixnum.class, "op_rshift", RubyObject.class)); fixnumClass.defineMethod("+", CallbackFactory.getMethod(RubyFixnum.class, "op_plus", RubyObject.class)); fixnumClass.defineMethod("-", CallbackFactory.getMethod(RubyFixnum.class, "op_minus", RubyObject.class)); fixnumClass.defineMethod("*", CallbackFactory.getMethod(RubyFixnum.class, "op_mul", RubyObject.class)); fixnumClass.defineMethod("/", CallbackFactory.getMethod(RubyFixnum.class, "op_div", RubyObject.class)); fixnumClass.defineMethod("%", CallbackFactory.getMethod(RubyFixnum.class, "op_mod", RubyObject.class)); fixnumClass.defineMethod("**", CallbackFactory.getMethod(RubyFixnum.class, "op_pow", RubyObject.class)); fixnumClass.defineMethod("==", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("eql?", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("equal?", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("<=>", CallbackFactory.getMethod(RubyFixnum.class, "op_cmp", RubyObject.class)); fixnumClass.defineMethod(">", CallbackFactory.getMethod(RubyFixnum.class, "op_gt", RubyObject.class)); fixnumClass.defineMethod(">=", CallbackFactory.getMethod(RubyFixnum.class, "op_ge", RubyObject.class)); fixnumClass.defineMethod("<", CallbackFactory.getMethod(RubyFixnum.class, "op_lt", RubyObject.class)); fixnumClass.defineMethod("<=", CallbackFactory.getMethod(RubyFixnum.class, "op_le", RubyObject.class)); fixnumClass.defineMethod("&", CallbackFactory.getMethod(RubyFixnum.class, "op_and", RubyObject.class)); fixnumClass.defineMethod("|", CallbackFactory.getMethod(RubyFixnum.class, "op_or", RubyInteger.class)); fixnumClass.defineMethod("^", CallbackFactory.getMethod(RubyFixnum.class, "op_xor", RubyInteger.class)); fixnumClass.defineMethod("size", CallbackFactory.getMethod(RubyFixnum.class, "size")); fixnumClass.defineMethod("[]", CallbackFactory.getMethod(RubyFixnum.class, "aref", RubyInteger.class)); return fixnumClass; }
|
public static RubyClass createFixnumClass(Ruby ruby) { RubyClass fixnumClass = ruby.defineClass("Fixnum", ruby.getClasses().getIntegerClass()); fixnumClass.includeModule(ruby.getClasses().getPrecisionModule()); fixnumClass.defineSingletonMethod("induced_from", CallbackFactory.getSingletonMethod(RubyFixnum.class, "induced_from", RubyObject.class)); fixnumClass.defineMethod("to_f", CallbackFactory.getMethod(RubyFixnum.class, "to_f")); fixnumClass.defineMethod("to_s", CallbackFactory.getMethod(RubyFixnum.class, "to_s")); fixnumClass.defineMethod("to_str", CallbackFactory.getMethod(RubyFixnum.class, "to_s")); fixnumClass.defineMethod("taint", CallbackFactory.getSelfMethod(0)); fixnumClass.defineMethod("freeze", CallbackFactory.getSelfMethod(0)); fixnumClass.defineMethod("<<", CallbackFactory.getMethod(RubyFixnum.class, "op_lshift", RubyObject.class)); fixnumClass.defineMethod(">>", CallbackFactory.getMethod(RubyFixnum.class, "op_rshift", RubyObject.class)); fixnumClass.defineMethod("+", CallbackFactory.getMethod(RubyFixnum.class, "op_plus", RubyObject.class)); fixnumClass.defineMethod("-", CallbackFactory.getMethod(RubyFixnum.class, "op_minus", RubyObject.class)); fixnumClass.defineMethod("*", CallbackFactory.getMethod(RubyFixnum.class, "op_mul", RubyObject.class)); fixnumClass.defineMethod("/", CallbackFactory.getMethod(RubyFixnum.class, "op_div", RubyObject.class)); fixnumClass.defineMethod("%", CallbackFactory.getMethod(RubyFixnum.class, "op_mod", RubyObject.class)); fixnumClass.defineMethod("**", CallbackFactory.getMethod(RubyFixnum.class, "op_pow", RubyObject.class)); fixnumClass.defineMethod("==", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("eql?", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("equal?", CallbackFactory.getMethod(RubyFixnum.class, "op_equal", RubyObject.class)); fixnumClass.defineMethod("<=>", CallbackFactory.getMethod(RubyFixnum.class, "op_cmp", RubyObject.class)); fixnumClass.defineMethod(">", CallbackFactory.getMethod(RubyFixnum.class, "op_gt", RubyObject.class)); fixnumClass.defineMethod(">=", CallbackFactory.getMethod(RubyFixnum.class, "op_ge", RubyObject.class)); fixnumClass.defineMethod("<", CallbackFactory.getMethod(RubyFixnum.class, "op_lt", RubyObject.class)); fixnumClass.defineMethod("<=", CallbackFactory.getMethod(RubyFixnum.class, "op_le", RubyObject.class)); fixnumClass.defineMethod("&", CallbackFactory.getMethod(RubyFixnum.class, "op_and", RubyObject.class)); fixnumClass.defineMethod("|", CallbackFactory.getMethod(RubyFixnum.class, "op_or", RubyInteger.class)); fixnumClass.defineMethod("^", CallbackFactory.getMethod(RubyFixnum.class, "op_xor", RubyInteger.class)); fixnumClass.defineMethod("size", CallbackFactory.getMethod(RubyFixnum.class, "size")); fixnumClass.defineMethod("[]", CallbackFactory.getMethod(RubyFixnum.class, "aref", RubyInteger.class)); return fixnumClass; }
| 3,239,129 |
public RubyBoolean equal(RubyObject obj) { return RubyBoolean.newBoolean(ruby, obj instanceof RubyFixnum && ((RubyFixnum)obj).getLongValue() == getLongValue()); }
|
public RubyBoolean equal(RubyObject obj) { return RubyBoolean.newBoolean(ruby, obj instanceof RubyFixnum && ((RubyFixnum)obj).getLongValue() == getLongValue()); }
| 3,239,130 |
public IRubyObject evalUnder(RubyModule under, IRubyObject src, IRubyObject file, IRubyObject line) { /* if (ruby_safe_level >= 4) { Check_Type(src, T_STRING); } else { Check_SafeStr(src); } */ return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { return args[0].eval( args[1], self.getRuntime().getNil(), ((RubyString) args[2]).getValue(), RubyNumeric.fix2int(args[3])); } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this, src, file, line }); }
|
public IRubyObject evalUnder(RubyModule under, IRubyObject src, IRubyObject file, IRubyObject line) { /* if (ruby_safe_level >= 4) { Check_Type(src, T_STRING); } else { Check_SafeStr(src); } */ return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { return args[0].eval( args[1], self.getRuntime().getNil(), ((RubyString) args[2]).getValue(), RubyNumeric.fix2int(args[3])); } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this, src, file, line }); }
| 3,239,132 |
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { return args[0].eval( args[1], self.getRuntime().getNil(), ((RubyString) args[2]).getValue(), RubyNumeric.fix2int(args[3])); }
|
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { return args[0].eval( args[1], self.getRuntime().getNil(), ((RubyString) args[2]).getValue(), RubyNumeric.fix2int(args[3])); }
| 3,239,133 |
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
|
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
| 3,239,134 |
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
|
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { IRubyObject valueInYield = args[0]; IRubyObject selfInYield = args[0]; return context.yield(valueInYield, selfInYield, context.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
| 3,239,135 |
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
|
private IRubyObject yieldUnder(RubyModule under) { return under.executeUnder(new Callback() { public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { currentBlock.getFrame().setNamespace(savedNamespace); currentBlock.getScope().setVisibility(savedVisibility); } } public Arity getArity() { return Arity.optional(); } }, new IRubyObject[] { this }); }
| 3,239,136 |
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } }
|
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } }
| 3,239,137 |
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } }
|
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { IRubyObject valueInYield = args[0]; IRubyObject selfInYield = args[0]; return context.yield(valueInYield, selfInYield, context.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } }
| 3,239,138 |
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { runtime.getBlockStack().setCurrent(savedBlock); } }
|
public IRubyObject execute(IRubyObject self, IRubyObject[] args) { // Fixme: What good is this copying, when it is referenced frame and scope objects // that are modified here? Some other modifications? Block savedBlock = runtime.getBlockStack().getCurrent().cloneBlock(); Namespace ns = runtime.getCurrentFrame().getNamespace(); runtime.getBlockStack().getCurrent().getFrame().setNamespace(ns); runtime.getBlockStack().getCurrent().getScope().setVisibility(Visibility.PUBLIC); try { return runtime.yield(args[0], args[0], runtime.getRubyClass(), false); } finally { currentBlock.getFrame().setNamespace(savedNamespace); currentBlock.getScope().setVisibility(savedVisibility); } }
| 3,239,139 |
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; RubyClass superClass = getSuperClassFromNode(context, iVisited.getSuperNode(), 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 def = new DefinedVisitor(runtime).getDefinition(iVisited.getExpressionNode()); if (def != null) { return runtime.newString(def); } 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 = new DefinedVisitor(runtime).getDefinition(iVisited.getFirstNode()); 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); }
|
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 def = new DefinedVisitor(runtime).getDefinition(iVisited.getExpressionNode()); if (def != null) { return runtime.newString(def); } 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 = new DefinedVisitor(runtime).getDefinition(iVisited.getFirstNode()); 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); }
| 3,239,140 |
public String toString(){ return "AnalysisChainLink"+(analysisChainLinkId==null ? ":Hash"+this.hashCode() : ":"+analysisChainLinkId); }
|
public String toString(){ return "AnalysisChainLink"+(analysisChainLinkId==null ? ":Hash_"+this.hashCode() : ":Id_"+analysisChainLinkId); }
| 3,239,141 |
protected void setUp() throws Exception { DataSource dataSource = (DataSource) factory.ctx.getBean("dataSource"); data = new OMEData(); data.setDataSource(dataSource); psrv = factory.getPojosService(); q = factory.getQueryService(); u = factory.getUpdateService(); mapper = new Model2PojosMapper(); reverse = new ReverseModelMapper(); }
|
protected void setUp() throws Exception { DataSource dataSource = (DataSource) factory.ctx.getBean("dataSource"); data = new OMEData(); data.setDataSource(dataSource); psrv = factory.getPojosService(); q = factory.getQueryService(); u = factory.getUpdateService(); mapper = new Model2PojosMapper(); reverse = new ReverseModelMapper(); }
| 3,239,142 |
public void testAndForTheFunOfItLetsGetTheREWorking() throws Exception { Pixels pix = (Pixels) q.getByClass(Pixels.class).get(0); IPixels pixDB = factory.getPixelsService(); PixelsService pixFS = new PixelsService( PixelsService.ROOT_DEFAULT); PixelBuffer pixBF = pixFS.createPixelBuffer(pix); StatsFactory sf = new StatsFactory(); PixelsStats pixST = sf.compute(pix,pixBF); // TODO RenderingEngine re = factory.getRenderingService(); Renderer r = new Renderer(pix,null,pixBF,pixST); PlaneDef pd = new PlaneDef(0,0); pd.setX(0); pd.setY(0); pd.setZ(0); r.render(pd); }
|
public void testAndForTheFunOfItLetsGetTheREWorking() throws Exception { Pixels pix = (Pixels) iQuery.getByClass(Pixels.class).get(0); IPixels pixDB = factory.getPixelsService(); PixelsService pixFS = new PixelsService( PixelsService.ROOT_DEFAULT); PixelBuffer pixBF = pixFS.createPixelBuffer(pix); StatsFactory sf = new StatsFactory(); PixelsStats pixST = sf.compute(pix,pixBF); // TODO RenderingEngine re = factory.getRenderingService(); Renderer r = new Renderer(pix,null,pixBF,pixST); PlaneDef pd = new PlaneDef(0,0); pd.setX(0); pd.setY(0); pd.setZ(0); r.render(pd); }
| 3,239,143 |
public void testAndSaveSomtheingWithParents() throws Exception { DatasetData dd = simpleDatasetData(); Set dss = new HashSet(); dss.add(dd); imgData = simpleImageData(); imgData.setDatasets(dss); img = (Image) reverse.map(imgData); img = (Image) u.saveAndReturnObject(img); assertTrue("It better have a dataset link", img.getDatasetLinks().size()>0); ILink link = (ILink) img.getDatasetLinks().iterator().next(); ds = (Dataset) link.getParent(); Long id = ds.getId(); // another copy Image img2 = (Image) q.queryUnique( "select i from Image i " + "left outer join fetch i.datasetLinks " + "where i.id = ?", new Object[]{img.getId()}); assertTrue("It better have a dataset link too", img2.getDatasetLinks().size()>0); ILink link2 = (ILink) img2.getDatasetLinks().iterator().next(); Dataset ds2 = (Dataset) link2.getParent(); assertTrue("And the ids have to be the same",id.equals(ds2.getId())); }
|
public void testAndSaveSomtheingWithParents() throws Exception { DatasetData dd = simpleDatasetData(); Set dss = new HashSet(); dss.add(dd); imgData = simpleImageData(); imgData.setDatasets(dss); img = (Image) reverse.map(imgData); img = (Image) iUpdate.saveAndReturnObject(img); assertTrue("It better have a dataset link", img.getDatasetLinks().size()>0); ILink link = (ILink) img.getDatasetLinks().iterator().next(); ds = (Dataset) link.getParent(); Long id = ds.getId(); // another copy Image img2 = (Image) q.queryUnique( "select i from Image i " + "left outer join fetch i.datasetLinks " + "where i.id = ?", new Object[]{img.getId()}); assertTrue("It better have a dataset link too", img2.getDatasetLinks().size()>0); ILink link2 = (ILink) img2.getDatasetLinks().iterator().next(); Dataset ds2 = (Dataset) link2.getParent(); assertTrue("And the ids have to be the same",id.equals(ds2.getId())); }
| 3,239,144 |
public void testAndSaveSomtheingWithParents() throws Exception { DatasetData dd = simpleDatasetData(); Set dss = new HashSet(); dss.add(dd); imgData = simpleImageData(); imgData.setDatasets(dss); img = (Image) reverse.map(imgData); img = (Image) u.saveAndReturnObject(img); assertTrue("It better have a dataset link", img.getDatasetLinks().size()>0); ILink link = (ILink) img.getDatasetLinks().iterator().next(); ds = (Dataset) link.getParent(); Long id = ds.getId(); // another copy Image img2 = (Image) q.queryUnique( "select i from Image i " + "left outer join fetch i.datasetLinks " + "where i.id = ?", new Object[]{img.getId()}); assertTrue("It better have a dataset link too", img2.getDatasetLinks().size()>0); ILink link2 = (ILink) img2.getDatasetLinks().iterator().next(); Dataset ds2 = (Dataset) link2.getParent(); assertTrue("And the ids have to be the same",id.equals(ds2.getId())); }
|
public void testAndSaveSomtheingWithParents() throws Exception { DatasetData dd = simpleDatasetData(); Set dss = new HashSet(); dss.add(dd); imgData = simpleImageData(); imgData.setDatasets(dss); img = (Image) reverse.map(imgData); img = (Image) u.saveAndReturnObject(img); assertTrue("It better have a dataset link", img.getDatasetLinks().size()>0); ILink link = (ILink) img.getDatasetLinks().iterator().next(); ds = (Dataset) link.getParent(); Long id = ds.getId(); // another copy Image img2 = (Image) iQuery.queryUnique( "select i from Image i " + "left outer join fetch i.datasetLinks " + "where i.id = ?", new Object[]{img.getId()}); assertTrue("It better have a dataset link too", img2.getDatasetLinks().size()>0); ILink link2 = (ILink) img2.getDatasetLinks().iterator().next(); Dataset ds2 = (Dataset) link2.getParent(); assertTrue("And the ids have to be the same",id.equals(ds2.getId())); }
| 3,239,145 |
public void testGetSomethingThatsAlwaysThere() throws Exception { List l = q.getListByExample(new Experimenter()); assertTrue("Root has to exist.",l.size()>0); Experimenter exp = (Experimenter) l.get(0); assertNotNull("Must have an id",exp.getId()); assertNotNull("And a name",exp.getFirstName()); // Now let's try to map it. ExperimenterData expData = (ExperimenterData) mapper.map((Experimenter)l.get(0)); assertNotNull("And something should still be there",expData); assertTrue("And it should have an id",expData.getId()>-1); assertNotNull("And various other things",expData.getFirstName()); }
|
public void testGetSomethingThatsAlwaysThere() throws Exception { List l = iQuery.getListByExample(new Experimenter()); assertTrue("Root has to exist.",l.size()>0); Experimenter exp = (Experimenter) l.get(0); assertNotNull("Must have an id",exp.getId()); assertNotNull("And a name",exp.getFirstName()); // Now let's try to map it. ExperimenterData expData = (ExperimenterData) mapper.map((Experimenter)l.get(0)); assertNotNull("And something should still be there",expData); assertTrue("And it should have an id",expData.getId()>-1); assertNotNull("And various other things",expData.getFirstName()); }
| 3,239,146 |
public void testLetsTryToLinkTwoThingsTogether() throws Exception { imgData = simpleImageData(); dsData = simpleDatasetData(); img = (Image) reverse.map(imgData); ds = (Dataset) reverse.map(dsData); DatasetImageLink link = new DatasetImageLink(); link.link(ds,img); ILink test = psrv.link(new ILink[]{link},null)[0]; assertNotNull("ILink should be there",test); }
|
public void testLetsTryToLinkTwoThingsTogether() throws Exception { imgData = simpleImageData(); dsData = simpleDatasetData(); img = (Image) reverse.map(imgData); ds = (Dataset) reverse.map(dsData); DatasetImageLink link = new DatasetImageLink(); link.link(ds,img); ILink test = iPojos.link(new ILink[]{link},null)[0]; assertNotNull("ILink should be there",test); }
| 3,239,147 |
public void testNowLetsTryToSaveSomething() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); img = (Image) psrv.createDataObject(img,null); assertNotNull("We should get something back",img); assertNotNull("Should have an id",img.getId()); Image img2 = (Image) q.getById(Image.class,img.getId().longValue()); assertNotNull("And we should be able to find it again.",img2); }
|
public void testNowLetsTryToSaveSomething() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); img = (Image) iPojos.createDataObject(img,null); assertNotNull("We should get something back",img); assertNotNull("Should have an id",img.getId()); Image img2 = (Image) q.getById(Image.class,img.getId().longValue()); assertNotNull("And we should be able to find it again.",img2); }
| 3,239,148 |
public void testNowLetsTryToSaveSomething() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); img = (Image) psrv.createDataObject(img,null); assertNotNull("We should get something back",img); assertNotNull("Should have an id",img.getId()); Image img2 = (Image) q.getById(Image.class,img.getId().longValue()); assertNotNull("And we should be able to find it again.",img2); }
|
public void testNowLetsTryToSaveSomething() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); img = (Image) psrv.createDataObject(img,null); assertNotNull("We should get something back",img); assertNotNull("Should have an id",img.getId()); Image img2 = (Image) iQuery.getById(Image.class,img.getId().longValue()); assertNotNull("And we should be able to find it again.",img2); }
| 3,239,149 |
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) psrv.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); psrv.deleteDataObject(img,null); img = (Image) q.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
|
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) iPojos.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); psrv.deleteDataObject(img,null); img = (Image) q.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
| 3,239,150 |
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) psrv.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); psrv.deleteDataObject(img,null); img = (Image) q.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
|
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) psrv.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); iPojos.deleteDataObject(img,null); img = (Image) q.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
| 3,239,151 |
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) psrv.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); psrv.deleteDataObject(img,null); img = (Image) q.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
|
public void testNowOnToSavingAndDeleting() throws Exception { imgData = simpleImageData(); img = (Image) reverse.map(imgData); assertNull("Image doesn't have an id.",img.getId()); img = (Image) psrv.createDataObject(img,null); assertNotNull("Presto change-o, now it does.",img.getId()); psrv.deleteDataObject(img,null); img = (Image) iQuery.getById(Image.class,img.getId().longValue()); assertNull("we should have deleted it ",img); }
| 3,239,152 |
final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 33; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); }
|
final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 33; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); }
| 3,239,153 |
final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 33; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 33; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); }
|
final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[33]; for (int i = 0; i < 35; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 2; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 35; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.addElement(jj_expentry); } } int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.elementAt(i); } return new ParseException(token, exptokseq, tokenImage); }
| 3,239,154 |
public DefaultRubyParser() { this.support = new ParserSupport(); this.lexer = new RubyYaccLexer(); // lame this.lexer.setParserSupport(support); }
|
public DefaultRubyParser() { this.support = new ParserSupport(); this.lexer = new RubyYaccLexer(); // lame this.lexer.setParserSupport(support); }
| 3,239,156 |
private ISourcePosition getPosition(ISourcePositionHolder start) { if (start != null) { return lexer.getPosition(start.getPosition()); } return lexer.getPosition(null); }
|
private ISourcePosition getPosition(ISourcePositionHolder start) { if (start != null) { return lexer.getPosition(start.getPosition()); } return lexer.getPosition(null); }
| 3,239,157 |
public static void main(String args[]) throws IOException { //@START int n = Integer.parseInt(args[0]); String hello = "hello\n"; StringBuffer stringBuffer = new StringBuffer(32); for (int i=0; i<n; i++) { stringBuffer.append(hello); } System.out.println(stringBuffer.length()); //@END }
|
public static void main(String args[]) throws IOException { //@START int n = Integer.parseInt(args[0]); String hello = "hello\n"; StringBuffer stringBuffer = new StringBuffer(32); for (int i=0; i<n; i++) { stringBuffer.append(hello); } System.out.println(stringBuffer.length()); //@END }
| 3,239,159 |
public ChatRoom createConferenceRoom(String roomName, String serviceName) { final MultiUserChat chatRoom = new MultiUserChat(SparkManager.getConnection(), roomName + "@" + serviceName); final GroupChatRoom room = new GroupChatRoom(chatRoom); try { ChatPreferences chatPref = (ChatPreferences)SparkManager.getPreferenceManager().getPreferenceData(ChatPreference.NAMESPACE); chatRoom.create(chatPref.getNickname()); // Send an empty room configuration form which indicates that we want // an instant room chatRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT)); } catch (XMPPException e1) { Log.error("Unable to send conference room chat configuration form.", e1); return null; } getChatContainer().addChatRoom(room); return room; }
|
public ChatRoom createConferenceRoom(String roomName, String serviceName) { final MultiUserChat chatRoom = new MultiUserChat(SparkManager.getConnection(), roomName + "@" + serviceName); final GroupChatRoom room = new GroupChatRoom(chatRoom); try { ChatPreferences chatPref = (ChatPreferences)SparkManager.getPreferenceManager().getPreferenceData(ChatPreference.NAMESPACE); chatRoom.create(chatPref.getNickname()); // Send an empty room configuration form which indicates that we want // an instant room chatRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT)); } catch (XMPPException e1) { Log.error("Unable to send conference room chat configuration form.", e1); return null; } getChatContainer().addChatRoom(room); return room; }
| 3,239,160 |
private void initCoreClasses() { ObjectMetaClass objectMetaClass = new ObjectMetaClass(this); objectMetaClass.initializeClass(); objectClass = objectMetaClass; objectClass.setConstant("Object", objectClass); RubyClass moduleClass = new ModuleMetaClass(this, objectClass); objectClass.setConstant("Module", moduleClass); RubyClass classClass = new RubyClass(this, null /* Would be Class if it could */, moduleClass, null, "Class"); objectClass.setConstant("Class", classClass); // I don't think the containment is correct here (parent cref) RubyClass metaClass = objectClass.makeMetaClass(classClass, objectMetaClass.getCRef()); metaClass = moduleClass.makeMetaClass(metaClass, objectMetaClass.getCRef()); metaClass = classClass.makeMetaClass(metaClass, objectMetaClass.getCRef()); ((ObjectMetaClass) moduleClass).initializeBootstrapClass(); kernelModule = RubyKernel.createKernelModule(this); objectClass.includeModule(kernelModule); RubyClass.createClassClass(classClass); nilClass = RubyNil.createNilClass(this); // We cannot define this constant until nil itself was made objectClass.defineConstant("NIL", getNil()); // Pre-create the core classes we know we will get referenced by starting up the runtime. RubyBoolean.createFalseClass(this); RubyBoolean.createTrueClass(this); RubyComparable.createComparable(this); RubyEnumerable.createEnumerableModule(this); stringClass = new StringMetaClass(this); stringClass.initializeClass(); new SymbolMetaClass(this).initializeClass(); RubyThreadGroup.createThreadGroupClass(this); RubyThread.createThreadClass(this); RubyException.createExceptionClass(this); RubyPrecision.createPrecisionModule(this); new NumericMetaClass(this).initializeClass(); new IntegerMetaClass(this).initializeClass(); fixnumClass = new FixnumMetaClass(this); fixnumClass.initializeClass(); new HashMetaClass(this).initializeClass(); new IOMetaClass(this).initializeClass(); new ArrayMetaClass(this).initializeClass(); Java.createJavaModule(this); RubyClass structClass = RubyStruct.createStructClass(this); tmsStruct = RubyStruct.newInstance(structClass, new IRubyObject[] { newString("Tms"), newSymbol("utime"), newSymbol("stime"), newSymbol("cutime"), newSymbol("cstime")}); RubyFloat.createFloatClass(this); new BignumMetaClass(this).initializeClass(); new BindingMetaClass(this).initializeClass(); RubyMath.createMathModule(this); // depends on all numeric types RubyRegexp.createRegexpClass(this); RubyRange.createRangeClass(this); RubyObjectSpace.createObjectSpaceModule(this); RubyGC.createGCModule(this); new ProcMetaClass(this).initializeClass(); RubyMethod.createMethodClass(this); RubyMatchData.createMatchDataClass(this); RubyMarshal.createMarshalModule(this); RubyDir.createDirClass(this); RubyFileTest.createFileTestModule(this); new FileMetaClass(this).initializeClass(); // depends on IO, FileTest RubyProcess.createProcessModule(this); new TimeMetaClass(this).initializeClass(); RubyUnboundMethod.defineUnboundMethodClass(this); RubyClass exceptionClass = getClass("Exception"); RubyClass standardError = defineClass("StandardError", exceptionClass); RubyClass runtimeError = defineClass("RuntimeError", standardError); RubyClass ioError = defineClass("IOError", standardError); RubyClass scriptError = defineClass("ScriptError", exceptionClass); RubyClass nameError = RubyNameError.createNameErrorClass(this, standardError); RubyClass rangeError = defineClass("RangeError", standardError); defineClass("SystemExit", exceptionClass); defineClass("Fatal", exceptionClass); defineClass("Interrupt", exceptionClass); defineClass("SignalException", exceptionClass); defineClass("TypeError", standardError); defineClass("ArgumentError", standardError); defineClass("IndexError", standardError); defineClass("SyntaxError", scriptError); defineClass("LoadError", scriptError); defineClass("NotImplementedError", scriptError); defineClass("NoMethodError", nameError); defineClass("SecurityError", standardError); defineClass("NoMemoryError", exceptionClass); defineClass("RegexpError", standardError); defineClass("EOFError", ioError); defineClass("LocalJumpError", standardError); defineClass("ThreadError", standardError); defineClass("SystemStackError", exceptionClass); defineClass("ZeroDivisionError", standardError); // FIXME: Actually this somewhere defineClass("FloatDomainError", rangeError); NativeException.createClass(this, runtimeError); systemCallError = defineClass("SystemCallError", standardError); errnoModule = defineModule("Errno"); initErrnoErrors(); }
|
private void initCoreClasses() { ObjectMetaClass objectMetaClass = new ObjectMetaClass(this); objectMetaClass.initializeClass(); objectClass = objectMetaClass; objectClass.setConstant("Object", objectClass); RubyClass moduleClass = new ModuleMetaClass(this, objectClass); objectClass.setConstant("Module", moduleClass); RubyClass classClass = new RubyClass(this, null /* Would be Class if it could */, moduleClass, null, "Class"); objectClass.setConstant("Class", classClass); // I don't think the containment is correct here (parent cref) RubyClass metaClass = objectClass.makeMetaClass(classClass, objectMetaClass.getCRef()); metaClass = moduleClass.makeMetaClass(metaClass, objectMetaClass.getCRef()); metaClass = classClass.makeMetaClass(metaClass, objectMetaClass.getCRef()); ((ObjectMetaClass) moduleClass).initializeBootstrapClass(); kernelModule = RubyKernel.createKernelModule(this); objectClass.includeModule(kernelModule); RubyClass.createClassClass(classClass); nilClass = RubyNil.createNilClass(this); // We cannot define this constant until nil itself was made objectClass.defineConstant("NIL", getNil()); // Pre-create the core classes we know we will get referenced by starting up the runtime. RubyBoolean.createFalseClass(this); RubyBoolean.createTrueClass(this); RubyComparable.createComparable(this); RubyEnumerable.createEnumerableModule(this); stringClass = new StringMetaClass(this); stringClass.initializeClass(); new SymbolMetaClass(this).initializeClass(); RubyThreadGroup.createThreadGroupClass(this); RubyThread.createThreadClass(this); RubyException.createExceptionClass(this); RubyPrecision.createPrecisionModule(this); new NumericMetaClass(this).initializeClass(); new IntegerMetaClass(this).initializeClass(); fixnumClass = new FixnumMetaClass(this); fixnumClass.initializeClass(); new HashMetaClass(this).initializeClass(); new IOMetaClass(this).initializeClass(); new ArrayMetaClass(this).initializeClass(); Java.createJavaModule(this); RubyClass structClass = RubyStruct.createStructClass(this); tmsStruct = RubyStruct.newInstance(structClass, new IRubyObject[] { newString("Tms"), newSymbol("utime"), newSymbol("stime"), newSymbol("cutime"), newSymbol("cstime")}); RubyFloat.createFloatClass(this); new BignumMetaClass(this).initializeClass(); new BindingMetaClass(this).initializeClass(); RubyMath.createMathModule(this); // depends on all numeric types RubyRegexp.createRegexpClass(this); RubyRange.createRangeClass(this); RubyObjectSpace.createObjectSpaceModule(this); RubyGC.createGCModule(this); new ProcMetaClass(this).initializeClass(); RubyMethod.createMethodClass(this); RubyMatchData.createMatchDataClass(this); RubyMarshal.createMarshalModule(this); RubyDir.createDirClass(this); RubyFileTest.createFileTestModule(this); new FileMetaClass(this).initializeClass(); // depends on IO, FileTest RubyProcess.createProcessModule(this); new TimeMetaClass(this).initializeClass(); RubyUnboundMethod.defineUnboundMethodClass(this); RubyClass exceptionClass = getClass("Exception"); RubyClass standardError = defineClass("StandardError", exceptionClass); RubyClass runtimeError = defineClass("RuntimeError", standardError); RubyClass ioError = defineClass("IOError", standardError); RubyClass scriptError = defineClass("ScriptError", exceptionClass); RubyClass nameError = RubyNameError.createNameErrorClass(this, standardError); RubyClass rangeError = defineClass("RangeError", standardError); defineClass("SystemExit", exceptionClass); defineClass("Fatal", exceptionClass); defineClass("Interrupt", exceptionClass); defineClass("SignalException", exceptionClass); defineClass("TypeError", standardError); defineClass("ArgumentError", standardError); defineClass("IndexError", standardError); defineClass("SyntaxError", scriptError); defineClass("LoadError", scriptError); defineClass("NotImplementedError", scriptError); defineClass("NoMethodError", nameError); defineClass("SecurityError", standardError); defineClass("NoMemoryError", exceptionClass); defineClass("RegexpError", standardError); defineClass("EOFError", ioError); defineClass("LocalJumpError", standardError); defineClass("ThreadError", standardError); defineClass("SystemStackError", exceptionClass); defineClass("ZeroDivisionError", standardError); // FIXME: Actually this somewhere defineClass("FloatDomainError", rangeError); NativeException.createClass(this, runtimeError); systemCallError = defineClass("SystemCallError", standardError); errnoModule = defineModule("Errno"); initErrnoErrors(); }
| 3,239,161 |
public ZlibInflate(IRubyObject caller) { super(); flater = new Inflater(true); collected = new StringBuffer(); runtime = caller.getRuntime(); }
|
public ZlibInflate(IRubyObject caller) { super(); flater = new Inflater(false); collected = new StringBuffer(); runtime = caller.getRuntime(); }
| 3,239,163 |
public JContactItemField(List items) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); popup = new JWindow(new JFrame()); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
|
public JContactItemField(List items, Window parentWindow) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); popup = new JWindow(new JFrame()); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
| 3,239,164 |
public JContactItemField(List items) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); popup = new JWindow(new JFrame()); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
|
public JContactItemField(List items) { setLayout(new BorderLayout()); this.items = items; add(textField, BorderLayout.CENTER); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { char ch = keyEvent.getKeyChar(); if (validateChar(ch)) { showPopupMenu(); } if (ch == KeyEvent.VK_ENTER) { int index = list.getSelectedIndex(); if (index >= 0) { ContactItem selection = (ContactItem)list.getSelectedValue(); textField.setText(selection.getNickname()); popup.setVisible(false); } } if (ch == KeyEvent.VK_ESCAPE) { popup.setVisible(false); } dispatchEvent(keyEvent); } public void keyPressed(KeyEvent e) { if (isArrowKey(e)) { list.dispatchEvent(e); } } }); list.addKeyListener(this); addKeyListener(this); popup = new JWindow(parentWindow); popup.getContentPane().add(new JScrollPane(list)); list.setCellRenderer(new PopupRenderer()); }
| 3,239,165 |
public boolean validateChar(char ch) { if (!Character.isLetterOrDigit(ch) && ch != '@' && ch != '-' && ch != '_' && ch != '.' && ch != ',' && ch != ' ' && ch != KeyEvent.VK_BACK_SPACE && ch != KeyEvent.CTRL_DOWN_MASK && ch != KeyEvent.CTRL_MASK) { return false; } return true; }
|
public boolean validateChar(char ch) { if (!Character.isLetterOrDigit(ch) && ch != '@' && ch != '-' && ch != '_' && ch != '.' && ch != ',' && ch != ' ' && ch != KeyEvent.VK_BACK_SPACE && ch != KeyEvent.CTRL_DOWN_MASK && ch != KeyEvent.CTRL_MASK) { return false; } return true; }
| 3,239,166 |
public boolean validateChars(String text) { if (!ModelUtil.hasLength(text)) { return false; } for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (!Character.isLetterOrDigit(ch) && ch != '@' && ch != '-' && ch != '_' && ch != '.' && ch != ',' && ch != ' ') { return false; } } return true; }
|
public boolean validateChars(String text) { if (!ModelUtil.hasLength(text)) { return false; } for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (!Character.isLetterOrDigit(ch) && ch != '@' && ch != '-' && ch != '_' && ch != '.' && ch != ',' && ch != ' ') { return false; } } return true; }
| 3,239,167 |
public static double parseElement(Attribute attribute, String elementName) throws IllegalArgumentException { if(attribute == null || elementName == null) { throw new IllegalArgumentException("Null parameters at " + "AbstractHeatMapMode.parseElement(Attribute,String)"); } int index = 0; while((index = elementName.indexOf(".")) != -1) { String child = elementName.substring(0,index); attribute = attribute.getAttributeElement(child); elementName = elementName.substring(index+1); } try { System.err.println(attribute); double val = attribute.getDoubleElement(elementName).doubleValue(); return val; } catch(NullPointerException npe) { throw new IllegalArgumentException("Invalid element parsed: "+ elementName); } catch(ClassCastException cce) { throw new IllegalArgumentException("Non-numeric element parsed."); } }
|
public static double parseElement(Attribute attribute, String elementName) throws IllegalArgumentException { if(attribute == null || elementName == null) { throw new IllegalArgumentException("Null parameters at " + "AbstractHeatMapMode.parseElement(Attribute,String)"); } int index = 0; while((index = elementName.indexOf(".")) != -1) { String child = elementName.substring(0,index); attribute = attribute.getAttributeElement(child); elementName = elementName.substring(index+1); } try { double val = attribute.getDoubleElement(elementName).doubleValue(); return val; } catch(NullPointerException npe) { throw new IllegalArgumentException("Invalid element parsed: "+ elementName); } catch(ClassCastException cce) { throw new IllegalArgumentException("Non-numeric element parsed."); } }
| 3,239,168 |
public LensComponent(JFrame parent, BufferedImage planeImage) { lensModel = new LensModel(planeImage); zoomWindow = new ZoomWindow(parent, this); lens = new LensUI(this, LENS_DEFAULT_WIDTH, LENS_DEFAULT_HEIGHT); lensController = new LensController(lensModel , lens, zoomWindow); lensModel.setWidth(LENS_DEFAULT_WIDTH); lensModel.setHeight(LENS_DEFAULT_HEIGHT); lensModel.setImageZoomFactor(1.0f); lens.addController(lensController); lens.setLensColour(lensModel.getLensPreferredColour()); zoomWindow.addController(lensController); menu = new LensMenu(this); lens.setPopupMenu(menu.getPopupMenu()); zoomWindow.setMenu(menu.getMenubar()); }
|
public LensComponent(JFrame parent, BufferedImage planeImage) { lensModel = new LensModel(planeImage); zoomWindow = new ZoomWindow(parent, this); lens = new LensUI(this, LENS_DEFAULT_WIDTH, LENS_DEFAULT_HEIGHT); lensController = new LensController(lensModel , lens, zoomWindow); lensModel.setWidth(LENS_DEFAULT_WIDTH); lensModel.setHeight(LENS_DEFAULT_HEIGHT); lensModel.setImageZoomFactor(1.0f); lens.addController(lensController); lens.setLensColour(lensModel.getLensPreferredColour()); zoomWindow.addController(lensController); menu = new LensMenu(this); lens.setPopupMenu(menu.getPopupMenu()); zoomWindow.setMenu(menu.getMenubar()); }
| 3,239,169 |
public void setLensSize(int lensSize) { switch (lensSize) { case LensAction.LENSDEFAULTSIZE: lensController.setLensSize(LensComponent.LENS_DEFAULT_WIDTH, LensComponent.LENS_DEFAULT_HEIGHT); break; case LensAction.LENS40x40: lensController.setLensSize(40, 40); break; case LensAction.LENS50x50: lensController.setLensSize(50, 50); break; case LensAction.LENS60x60: lensController.setLensSize(60, 60); break; case LensAction.LENS70x70: lensController.setLensSize(70, 70); break; case LensAction.LENS80x80: lensController.setLensSize(80, 80); break; case LensAction.LENS90x90: lensController.setLensSize(90, 90); break; case LensAction.LENS100x100: lensController.setLensSize(100, 100); break; case LensAction.LENS120x120: lensController.setLensSize(120, 120); break; case LensAction.LENS150x150: lensController.setLensSize(150, 150); break; default: throw new IllegalArgumentException("Index not supported."); } }
|
void setLensSize(int lensSize) { switch (lensSize) { case LensAction.LENSDEFAULTSIZE: lensController.setLensSize(LensComponent.LENS_DEFAULT_WIDTH, LensComponent.LENS_DEFAULT_HEIGHT); break; case LensAction.LENS40x40: lensController.setLensSize(40, 40); break; case LensAction.LENS50x50: lensController.setLensSize(50, 50); break; case LensAction.LENS60x60: lensController.setLensSize(60, 60); break; case LensAction.LENS70x70: lensController.setLensSize(70, 70); break; case LensAction.LENS80x80: lensController.setLensSize(80, 80); break; case LensAction.LENS90x90: lensController.setLensSize(90, 90); break; case LensAction.LENS100x100: lensController.setLensSize(100, 100); break; case LensAction.LENS120x120: lensController.setLensSize(120, 120); break; case LensAction.LENS150x150: lensController.setLensSize(150, 150); break; default: throw new IllegalArgumentException("Index not supported."); } }
| 3,239,170 |
protected void initializeClass() { defineMethod("quo", Arity.singleArgument()); defineMethod("to_f", Arity.noArguments()); defineMethod("to_i", Arity.noArguments()); defineMethod("to_s", Arity.noArguments()); defineMethod("taint", Arity.noArguments()); defineMethod("freeze", Arity.noArguments()); defineMethod("<<", Arity.singleArgument(), "op_lshift"); defineMethod(">>", Arity.singleArgument(), "op_rshift"); defineMethod("+", Arity.singleArgument(), "op_plus"); defineMethod("-", Arity.singleArgument(), "op_minus"); defineMethod("*", Arity.singleArgument(), "op_mul"); defineMethod("/", Arity.singleArgument(), "op_div"); defineAlias("div", "/"); defineMethod("%", Arity.singleArgument(), "op_mod"); defineMethod("**", Arity.singleArgument(), "op_pow"); defineMethod("&", Arity.singleArgument(), "op_and"); defineMethod("|", Arity.singleArgument(), "op_or"); defineMethod("^", Arity.singleArgument(), "op_xor"); defineMethod("size", Arity.noArguments()); defineMethod("[]", Arity.singleArgument(), "aref"); defineMethod("hash", Arity.noArguments()); defineMethod("id2name", Arity.noArguments()); defineMethod("~", Arity.noArguments(), "invert"); defineMethod("id", Arity.noArguments()); defineSingletonMethod("induced_from", Arity.singleArgument(), "induced_from"); }
|
protected void initializeClass() { defineMethod("quo", Arity.singleArgument()); defineMethod("to_f", Arity.noArguments()); defineMethod("to_i", Arity.noArguments()); defineMethod("to_s", Arity.noArguments()); defineMethod("taint", Arity.noArguments()); defineMethod("freeze", Arity.noArguments()); defineMethod("<<", Arity.singleArgument(), "op_lshift"); defineMethod(">>", Arity.singleArgument(), "op_rshift"); defineMethod("+", Arity.singleArgument(), "op_plus"); defineMethod("-", Arity.singleArgument(), "op_minus"); defineMethod("*", Arity.singleArgument(), "op_mul"); defineMethod("/", Arity.singleArgument(), "op_div"); defineAlias("div", "/"); defineMethod("%", Arity.singleArgument(), "op_mod"); defineMethod("**", Arity.singleArgument(), "op_pow"); defineMethod("&", Arity.singleArgument(), "op_and"); defineMethod("|", Arity.singleArgument(), "op_or"); defineMethod("^", Arity.singleArgument(), "op_xor"); defineMethod("size", Arity.noArguments()); defineMethod("[]", Arity.singleArgument(), "aref"); defineMethod("hash", Arity.noArguments()); defineMethod("id2name", Arity.noArguments()); defineMethod("~", Arity.noArguments(), "invert"); defineMethod("id", Arity.noArguments()); defineSingletonMethod("induced_from", Arity.singleArgument(), "induced_from"); }
| 3,239,172 |
public IRubyObject read(IRubyObject[] args) { try { String buf = args.length > 0 ? handler.read(RubyNumeric.fix2int(args[0])) : handler.getsEntireStream(); return buf == null ? getRuntime().newString("") : getRuntime().newString(buf); } catch (IOHandler.BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } catch (IOException e) { throw getRuntime().newIOError(e.getMessage()); } }
|
public IRubyObject read(IRubyObject[] args) { try { String buf = args.length > 0 ? handler.read(RubyNumeric.fix2int(args[0])) : handler.getsEntireStream(); if (buf == null) { if (args.length > 0) { return getRuntime().getNil(); } return getRuntime().newString(""); } return getRuntime().newString(buf); } catch (IOHandler.BadDescriptorException e) { throw getRuntime().newErrnoEBADFError(); } catch (IOException e) { throw getRuntime().newIOError(e.getMessage()); } }
| 3,239,173 |
protected DataLoader createHierarchyLoader() { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids); } return null; }
|
protected DataLoader createHierarchyLoader(boolean refresh) { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids); } return null; }
| 3,239,174 |
protected DataLoader createHierarchyLoader() { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids); } return null; }
|
protected DataLoader createHierarchyLoader() { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids, refresh); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids); } return null; }
| 3,239,175 |
protected DataLoader createHierarchyLoader() { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids); } return null; }
|
protected DataLoader createHierarchyLoader() { Set ids = new HashSet(images.size()); Iterator i = images.iterator(); while (i.hasNext()) ids.add(new Long(((ImageData) i.next()).getId())); switch (type) { case HiViewer.PDI_HIERARCHY: return new PDILoader(component, ids); case HiViewer.CGCI_HIERARCHY: return new CGCILoader(component, ids, refresh); } return null; }
| 3,239,176 |
private void handleDisplayROI(DisplayROI response) { if (response.getDrawingCanvas() != null) { //close window if (control.getDrawingCanvas() == null) control.setDrawingCanvas(response.getDrawingCanvas()); if (presentation == null) buildPresentation(); presentation.deIconify(); } else removePresentation(); }
|
private void handleDisplayROI(DisplayROI response) { if (response.getDrawingCanvas() != null) { //close window if (control.getDrawingCanvas() == null) control.setDrawingCanvas(response.getDrawingCanvas()); if (presentation == null) buildPresentation(); presentation.deIconify(); } else removePresentation(); }
| 3,239,178 |
private void handleDisplayROI(DisplayROI response) { if (response.getDrawingCanvas() != null) { //close window if (control.getDrawingCanvas() == null) control.setDrawingCanvas(response.getDrawingCanvas()); if (presentation == null) buildPresentation(); presentation.deIconify(); } else removePresentation(); }
|
private void handleDisplayROI(DisplayROI response) { if (response.getDrawingCanvas() != null) { //close window if (control.getDrawingCanvas() == null) control.setDrawingCanvas(response.getDrawingCanvas()); if (presentation == null) buildPresentation(); presentation.deIconify(); }
| 3,239,179 |
public void commit() { LocalPreferences pref = SettingsManager.getLocalPreferences(); pref.setTimeDisplayedInChat(panel.getShowTime()); pref.setSpellCheckerEnabled(panel.isSpellCheckerOn()); pref.setChatRoomNotifications(panel.isGroupChatNotificationsOn()); pref.setHideChatHistory(panel.isChatHistoryHidden()); SettingsManager.saveSettings(); // Do not commit if not changed. if (ModelUtil.hasLength(panel.getPassword()) && ModelUtil.hasLength(panel.getConfirmationPassword())) { try { SparkManager.getConnection().getAccountManager().changePassword(panel.getPassword()); } catch (XMPPException passwordEx) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Unable to change password. Please see your server admin.", "Password Change Error", JOptionPane.ERROR_MESSAGE); Log.error("Unable to change password", passwordEx); } } }
|
public void commit() { LocalPreferences pref = SettingsManager.getLocalPreferences(); pref.setTimeDisplayedInChat(panel.getShowTime()); pref.setSpellCheckerEnabled(panel.isSpellCheckerOn()); pref.setChatRoomNotifications(panel.isGroupChatNotificationsOn()); pref.setChatHistoryEnabled(!panel.isChatHistoryHidden()); SettingsManager.saveSettings(); // Do not commit if not changed. if (ModelUtil.hasLength(panel.getPassword()) && ModelUtil.hasLength(panel.getConfirmationPassword())) { try { SparkManager.getConnection().getAccountManager().changePassword(panel.getPassword()); } catch (XMPPException passwordEx) { JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Unable to change password. Please see your server admin.", "Password Change Error", JOptionPane.ERROR_MESSAGE); Log.error("Unable to change password", passwordEx); } } }
| 3,239,180 |
public void load() { SwingWorker thread = new SwingWorker() { LocalPreferences pref; public Object construct() { pref = SettingsManager.getLocalPreferences(); return pref; } public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = pref.isHideChatHistory(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); } }; thread.start(); }
|
public void load() { SwingWorker thread = new SwingWorker() { LocalPreferences pref; public Object construct() { pref = SettingsManager.getLocalPreferences(); return pref; } public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = !pref.isChatHistoryEnabled(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); } }; thread.start(); }
| 3,239,181 |
public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = pref.isHideChatHistory(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); }
|
public void finished() { String nickname = pref.getDefaultNickname(); if (nickname == null) { nickname = SparkManager.getSessionManager().getUsername(); } boolean showTime = pref.isTimeDisplayedInChat(); boolean spellCheckerOn = pref.isSpellCheckerEnabled(); boolean notificationsOn = pref.isChatRoomNotificationsOn(); boolean chatHistoryHidden = !pref.isChatHistoryEnabled(); panel.setShowTime(showTime); panel.setSpellCheckerOn(spellCheckerOn); panel.setGroupChatNotificationsOn(notificationsOn); panel.setChatHistoryHidden(chatHistoryHidden); }
| 3,239,182 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.