diff options
author | murphy <murphy@rubychan.de> | 2010-04-14 23:59:03 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2010-04-14 23:59:03 +0000 |
commit | 200144dd009d33ff8334be24d0fb2cc91b3a87ab (patch) | |
tree | f46c939cd01b8d4165b5d9f3444c20e072b51408 /test/scanners/java | |
parent | 612a14e17bdae5dbb5b13cdceec797523725cbbe (diff) | |
download | coderay-200144dd009d33ff8334be24d0fb2cc91b3a87ab.tar.gz |
Moving scanner tests into separate repository. The repository can be reached at http://svn.rubychan.de/coderay-scanner-tests/trunk.
Diffstat (limited to 'test/scanners/java')
-rw-r--r-- | test/scanners/java/example.expected.raydebug | 12 | ||||
-rw-r--r-- | test/scanners/java/example.in.java | 12 | ||||
-rw-r--r-- | test/scanners/java/jruby.expected.raydebug | 51193 | ||||
-rw-r--r-- | test/scanners/java/jruby.in.java | 51193 | ||||
-rw-r--r-- | test/scanners/java/suite.rb | 4 |
5 files changed, 0 insertions, 102414 deletions
diff --git a/test/scanners/java/example.expected.raydebug b/test/scanners/java/example.expected.raydebug deleted file mode 100644 index 58e847d..0000000 --- a/test/scanners/java/example.expected.raydebug +++ /dev/null @@ -1,12 +0,0 @@ -keyword(package) namespace(pl.silvermedia.ws)operator(;) -keyword(import) include(java.util.List)operator(;) - -keyword(import) include(javax.jws.WebParam)operator(;) -keyword(import) include(javax.jws.WebService)operator(;) - -annotation(@WebService) -directive(public) type(interface) class(ContactUsService) operator({) - pre_type(List)operator(<)ident(Message)operator(>) ident(getMessages)operator(()operator(\))operator(;) - ident(Message) ident(getFirstMessage)operator(()operator(\))operator(;) - type(void) ident(postMessage)operator(()annotation(@WebParam)operator(()ident(name) operator(=) string<delimiter(")content(message)delimiter(")>operator(\)) ident(Message) ident(message)operator(\))operator(;) -operator(}) diff --git a/test/scanners/java/example.in.java b/test/scanners/java/example.in.java deleted file mode 100644 index 7aa6ce1..0000000 --- a/test/scanners/java/example.in.java +++ /dev/null @@ -1,12 +0,0 @@ -package pl.silvermedia.ws; -import java.util.List; - -import javax.jws.WebParam; -import javax.jws.WebService; - -@WebService -public interface ContactUsService { - List<Message> getMessages(); - Message getFirstMessage(); - void postMessage(@WebParam(name = "message") Message message); -} diff --git a/test/scanners/java/jruby.expected.raydebug b/test/scanners/java/jruby.expected.raydebug deleted file mode 100644 index ece5b90..0000000 --- a/test/scanners/java/jruby.expected.raydebug +++ /dev/null @@ -1,51193 +0,0 @@ -keyword(package) namespace(org.jruby)operator(;) - -directive(public) type(enum) ident(CompatVersion) operator({) - - ident(RUBY1_8)operator(,) ident(RUBY1_9)operator(,) ident(BOTH)operator(;) - - directive(public) directive(static) ident(CompatVersion) ident(getVersionFromString)operator(()pre_type(String) ident(compatString)operator(\)) operator({) - keyword(if) operator(()ident(compatString)operator(.)ident(equalsIgnoreCase)operator(()string<delimiter(")content(RUBY1_8)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(compatString)operator(.)ident(equalsIgnoreCase)operator(()string<delimiter(")content(RUBY1_9)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(;) - operator(}) keyword(else) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Damian Steer <pldms@mac.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -comment(/** - * An almost entirely useless interface for those objects that we _really_ want - * to finalise. - * - * @author pldms - * - */) -directive(public) type(interface) class(Finalizable) operator({) - directive(public) type(void) ident(finalize)operator(()operator(\))operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) -comment(/** - * Error numbers. - * @fixme - * this interface is a big hack defining a bunch of arbitrary valor as system call error numbers - * this is actually because I need them but will probably need to be changed to something smarter - * sooner or later. - * The purpose of this class it to help implement the Errno module which in turn in needed by rubicon. - * @author Benoit Cerrina - **/) -directive(public) type(interface) class(IErrno) -operator({) - type(int) ident(EPERM) operator(=) integer(1)operator(;) - type(int) ident(ENOENT) operator(=) integer(2)operator(;) - type(int) ident(ESRCH) operator(=) integer(3)operator(;) - type(int) ident(EINTR) operator(=) integer(4)operator(;) - type(int) ident(EIO) operator(=) integer(5)operator(;) - type(int) ident(ENXIO) operator(=) integer(6)operator(;) - type(int) ident(E2BIG) operator(=) integer(7)operator(;) - type(int) ident(ENOEXEC) operator(=) integer(8)operator(;) - type(int) ident(EBADF) operator(=) integer(9)operator(;) - type(int) ident(ECHILD) operator(=) integer(10)operator(;) - type(int) ident(EDEADLK) operator(=) integer(11)operator(;) - type(int) ident(ENOMEM) operator(=) integer(12)operator(;) - type(int) ident(EACCES) operator(=) integer(13)operator(;) - type(int) ident(EFAULT) operator(=) integer(14)operator(;) - type(int) ident(ENOTBLK) operator(=) integer(15)operator(;) - type(int) ident(EBUSY) operator(=) integer(16)operator(;) - type(int) ident(EEXIST) operator(=) integer(17)operator(;) - type(int) ident(EXDEV) operator(=) integer(18)operator(;) - type(int) ident(ENODEV) operator(=) integer(19)operator(;) - type(int) ident(ENOTDIR) operator(=) integer(20)operator(;) - type(int) ident(EISDIR) operator(=) integer(21)operator(;) - type(int) ident(EINVAL) operator(=) integer(22)operator(;) - type(int) ident(ENFILE) operator(=) integer(23)operator(;) - type(int) ident(EMFILE) operator(=) integer(24)operator(;) - type(int) ident(ENOTTY) operator(=) integer(25)operator(;) - type(int) ident(ETXTBSY) operator(=) integer(26)operator(;) - type(int) ident(EFBIG) operator(=) integer(27)operator(;) - type(int) ident(ENOSPC) operator(=) integer(28)operator(;) - type(int) ident(ESPIPE) operator(=) integer(29)operator(;) - type(int) ident(EROFS) operator(=) integer(30)operator(;) - type(int) ident(EMLINK) operator(=) integer(31)operator(;) - type(int) ident(EPIPE) operator(=) integer(32)operator(;) - type(int) ident(EDOM) operator(=) integer(33)operator(;) - type(int) ident(ERANGE) operator(=) integer(34)operator(;) - type(int) ident(EWOULDBLOCK) operator(=) integer(35)operator(;) - type(int) ident(EAGAIN) operator(=) integer(35)operator(;) - type(int) ident(EINPROGRESS) operator(=) integer(36)operator(;) - type(int) ident(EALREADY) operator(=) integer(37)operator(;) - type(int) ident(ENOTSOCK) operator(=) integer(38)operator(;) - type(int) ident(EDESTADDRREQ) operator(=) integer(39)operator(;) - type(int) ident(EMSGSIZE) operator(=) integer(40)operator(;) - type(int) ident(EPROTOTYPE) operator(=) integer(41)operator(;) - type(int) ident(ENOPROTOOPT) operator(=) integer(42)operator(;) - type(int) ident(EPROTONOSUPPORT) operator(=) integer(43)operator(;) - type(int) ident(ESOCKTNOSUPPORT) operator(=) integer(44)operator(;) - type(int) ident(EOPNOTSUPP) operator(=) integer(45)operator(;) - type(int) ident(EPFNOSUPPORT) operator(=) integer(46)operator(;) - type(int) ident(EAFNOSUPPORT) operator(=) integer(47)operator(;) - type(int) ident(EADDRINUSE) operator(=) integer(48)operator(;) - type(int) ident(EADDRNOTAVAIL) operator(=) integer(49)operator(;) - type(int) ident(ENETDOWN) operator(=) integer(50)operator(;) - type(int) ident(ENETUNREACH) operator(=) integer(51)operator(;) - type(int) ident(ENETRESET) operator(=) integer(52)operator(;) - type(int) ident(ECONNABORTED) operator(=) integer(53)operator(;) - type(int) ident(ECONNRESET) operator(=) integer(54)operator(;) - type(int) ident(ENOBUFS) operator(=) integer(55)operator(;) - type(int) ident(EISCONN) operator(=) integer(56)operator(;) - type(int) ident(ENOTCONN) operator(=) integer(57)operator(;) - type(int) ident(ESHUTDOWN) operator(=) integer(58)operator(;) - type(int) ident(ETOOMANYREFS) operator(=) integer(59)operator(;) - type(int) ident(ETIMEDOUT) operator(=) integer(60)operator(;) - type(int) ident(ECONNREFUSED) operator(=) integer(61)operator(;) - type(int) ident(ELOOP) operator(=) integer(62)operator(;) - type(int) ident(ENAMETOOLONG) operator(=) integer(63)operator(;) - type(int) ident(EHOSTDOWN) operator(=) integer(64)operator(;) - type(int) ident(EHOSTUNREACH) operator(=) integer(65)operator(;) - type(int) ident(ENOTEMPTY) operator(=) integer(66)operator(;) - type(int) ident(EUSERS) operator(=) integer(68)operator(;) - type(int) ident(EDQUOT) operator(=) integer(69)operator(;) - type(int) ident(ESTALE) operator(=) integer(70)operator(;) - type(int) ident(EREMOTE) operator(=) integer(71)operator(;) - type(int) ident(ENOLCK) operator(=) integer(77)operator(;) - type(int) ident(ENOSYS) operator(=) integer(78)operator(;) - type(int) ident(EOVERFLOW) operator(=) integer(84)operator(;) - type(int) ident(EIDRM) operator(=) integer(90)operator(;) - type(int) ident(ENOMSG) operator(=) integer(91)operator(;) - type(int) ident(EILSEQ) operator(=) integer(92)operator(;) - type(int) ident(EBADMSG) operator(=) integer(94)operator(;) - type(int) ident(EMULTIHOP) operator(=) integer(95)operator(;) - type(int) ident(ENODATA) operator(=) integer(96)operator(;) - type(int) ident(ENOLINK) operator(=) integer(97)operator(;) - type(int) ident(ENOSR) operator(=) integer(98)operator(;) - type(int) ident(ENOSTR) operator(=) integer(99)operator(;) - type(int) ident(EPROTO) operator(=) integer(100)operator(;) - type(int) ident(ETIME) operator(=) integer(101)operator(;) - type(int) ident(EOPNOTSUPP_DARWIN) operator(=) integer(102)operator(;) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) - -comment(/** - * This class is used to provide an intermediate superclass for modules and classes that include - * other modules. It inserts itself as the immediate superClass of the includer, but defers all - * module methods to the actual superclass. Multiple of these intermediate superclasses can be - * added for multiple included modules. - * - * This allows the normal superclass-based searches (searchMethod, getConstant, etc\) to traverse - * the superclass ancestors as normal while the included modules do not actually show up in - * direct inheritance traversal. - * - * @see org.jruby.RubyModule - */) -directive(public) directive(final) type(class) class(IncludedModuleWrapper) directive(extends) ident(RubyClass) operator({) - directive(private) directive(final) ident(RubyModule) ident(delegate)operator(;) - - directive(public) ident(IncludedModuleWrapper)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(RubyModule) ident(delegate)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(superClass)operator(,) pre_constant(false)operator(\))operator(;) - local_variable(this)operator(.)ident(delegate) operator(=) ident(delegate)operator(;) - local_variable(this)operator(.)ident(metaClass) operator(=) ident(delegate)operator(.)ident(metaClass)operator(;) - operator(}) - - comment(/** - * Overridden newIncludeClass implementation to allow attaching future includes to the correct module - * (i.e. the one to which this is attached\) - * - * @see org.jruby.RubyModule#newIncludeClass(RubyClass\) - */) - annotation(@Override) - directive(public) ident(IncludedModuleWrapper) ident(newIncludeClass)operator(()ident(RubyClass) ident(superClass)operator(\)) operator({) - ident(IncludedModuleWrapper) ident(includedModule) operator(=) keyword(new) ident(IncludedModuleWrapper)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(superClass)operator(,) ident(getNonIncludedClass)operator(()operator(\))operator(\))operator(;) - - comment(// include its parent (and in turn that module's parents\)) - keyword(if) operator(()ident(getSuperClass)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(includedModule)operator(.)ident(includeModule)operator(()ident(getSuperClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(includedModule)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isModule)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isClass)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isIncluded)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(setMetaClass)operator(()ident(RubyClass) ident(newRubyClass)operator(\)) operator({) - keyword(throw) keyword(new) exception(UnsupportedOperationException)operator(()string<delimiter(")content(An included class is only a wrapper for a module)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) ident(DynamicMethod)operator(>) ident(getMethods)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(getMethods)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(addMethod)operator(()pre_type(String) ident(name)operator(,) ident(DynamicMethod) ident(method)operator(\)) operator({) - keyword(throw) keyword(new) exception(UnsupportedOperationException)operator(()string<delimiter(")content(An included class is only a wrapper for a module)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setMethods)operator(()pre_type(Map) ident(newMethods)operator(\)) operator({) - keyword(throw) keyword(new) exception(UnsupportedOperationException)operator(()string<delimiter(")content(An included class is only a wrapper for a module)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(String) ident(getName)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(getName)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyModule) ident(getNonIncludedClass)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyClass) ident(getRealClass)operator(()operator(\)) operator({) - keyword(return) ident(getSuperClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(boolean) ident(isSame)operator(()ident(RubyModule) ident(module)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(isSame)operator(()ident(module)operator(\))operator(;) - operator(}) - - comment(/** - * We don't want to reveal ourselves to Ruby code, so delegate this - * operation. - */) - annotation(@Override) - directive(public) ident(IRubyObject) ident(id)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(id)operator(()operator(\))operator(;) - operator(}) - - comment(//) - comment(// VARIABLE TABLE METHODS - pass to delegate) - comment(//) - - annotation(@Override) - directive(protected) type(boolean) ident(variableTableContains)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(boolean) ident(variableTableFastContains)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableFetch)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableFastFetch)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableStore)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableFastStore)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableRemove)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(VariableTableEntry)type([]) ident(variableTableGetTable)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableGetTable)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(int) ident(variableTableGetSize)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableGetSize)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(void) ident(variableTableSync)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(vars)operator(\)) operator({) - ident(delegate)operator(.)ident(variableTableSync)operator(()ident(vars)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableReadLocked)operator(()ident(VariableTableEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableReadLocked)operator(()ident(entry)operator(\))operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Override) - annotation(@Deprecated) comment(// born deprecated) - directive(protected) pre_type(Map) ident(variableTableGetMap)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableGetMap)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Override) - annotation(@Deprecated) comment(// born deprecated) - directive(protected) pre_type(Map) ident(variableTableGetMap)operator(()pre_type(Map) ident(map)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(variableTableGetMap)operator(()ident(map)operator(\))operator(;) - operator(}) - - comment(//) - comment(// CONSTANT TABLE METHODS - pass to delegate) - comment(//) - - annotation(@Override) - directive(protected) type(boolean) ident(constantTableContains)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(boolean) ident(constantTableFastContains)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(constantTableFetch)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(constantTableFastFetch)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(constantTableStore)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - comment(// FIXME: legal here? may want UnsupportedOperationException) - keyword(return) ident(delegate)operator(.)ident(constantTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(constantTableFastStore)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - comment(// FIXME: legal here? may want UnsupportedOperationException) - keyword(return) ident(delegate)operator(.)ident(constantTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(constantTableRemove)operator(()pre_type(String) ident(name)operator(\)) operator({) - comment(// this _is_ legal (when removing an undef\)) - keyword(return) ident(delegate)operator(.)ident(constantTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(ConstantTableEntry)type([]) ident(constantTableGetTable)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableGetTable)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(int) ident(constantTableGetSize)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableGetSize)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(protected) type(void) ident(constantTableSync)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(vars)operator(\)) operator({) - comment(// FIXME: legal here? may want UnsupportedOperationException) - ident(delegate)operator(.)ident(constantTableSync)operator(()ident(vars)operator(\))operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Override) - annotation(@Deprecated) comment(// born deprecated) - directive(protected) pre_type(Map) ident(constantTableGetMap)operator(()operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableGetMap)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Override) - annotation(@Deprecated) comment(// born deprecated) - directive(protected) pre_type(Map) ident(constantTableGetMap)operator(()pre_type(Map) ident(map)operator(\)) operator({) - keyword(return) ident(delegate)operator(.)ident(constantTableGetMap)operator(()ident(map)operator(\))operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Charles Nutter <charles.o.nutter@sun.com> - * Copyright (C\) 2008 MenTaLguY <mental@rydia.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.applet.Applet)operator(;) -keyword(import) include(java.awt.BorderLayout)operator(;) -keyword(import) include(java.awt.Color)operator(;) -keyword(import) include(java.awt.Container)operator(;) -keyword(import) include(java.awt.EventQueue)operator(;) -keyword(import) include(java.awt.Font)operator(;) -keyword(import) include(java.awt.Insets)operator(;) -keyword(import) include(java.awt.Graphics)operator(;) -keyword(import) include(java.awt.GraphicsConfiguration)operator(;) -keyword(import) include(java.awt.GraphicsEnvironment)operator(;) -keyword(import) include(java.awt.image.VolatileImage)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.PrintStream)operator(;) -keyword(import) include(java.net.URL)operator(;) -keyword(import) include(java.util.Arrays)operator(;) - -keyword(import) include(java.lang.reflect.InvocationTargetException)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.demo.TextAreaReadline)operator(;) -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(javax.swing.JScrollPane)operator(;) -keyword(import) include(javax.swing.JTextPane)operator(;) - -comment(/** - * @author <a href="mailto:mental@rydia.net">MenTaLguY</a> - * - * The JRubyApplet class provides a simple way to write Java applets using - * JRuby without needing to create a custom Java applet class. At applet - * initialization time, JRubyApplet starts up a JRuby runtime, then evaluates - * the scriptlet given as the "eval" applet parameter. - * - * The Java applet instance is available to the Ruby script as - * JRUBY_APPLET; the script can define callbacks for applet start, stop, - * and destroy by passing blocks to JRUBY_APPLET.on_start, - * JRUBY_APPLET.on_stop, and JRUBY_APPLET.on_destroy, respectively. - * - * Ruby code can install a custom paint callback using JRUBY_APPLET.on_paint - * (the Graphics2D object is passed as an argument to the callback\). By - * default, JRubyApplet painting is double-buffered, but you can select - * single-buffered painting via JRUBY_APPLET.double_buffered = false. - * - * The applet's background color can be set via JRUBY_APPLET.background_color=. - * You may want to set it to nil if you're not using double-buffering, so that - * no background color will be drawn (your own paint code is then responsible - * for filling the area\). - * - * Beyond these things, you should be able to use JRuby's Java integration - * to do whatever you would do in Java with the applet instance. - * - */) -directive(public) type(class) class(JRubyApplet) directive(extends) pre_type(Applet) operator({) - directive(private) ident(Ruby) ident(runtime)operator(;) - directive(private) type(boolean) ident(doubleBuffered) operator(=) pre_constant(true)operator(;) - directive(private) pre_type(Color) ident(backgroundColor) operator(=) pre_type(Color)operator(.)ident(WHITE)operator(;) - directive(private) ident(RubyProc) ident(startProc)operator(;) - directive(private) ident(RubyProc) ident(stopProc)operator(;) - directive(private) ident(RubyProc) ident(destroyProc)operator(;) - directive(private) ident(RubyProc) ident(paintProc)operator(;) - directive(private) pre_type(Graphics) ident(priorGraphics)operator(;) - directive(private) ident(IRubyObject) ident(wrappedGraphics)operator(;) - directive(private) pre_type(VolatileImage) ident(backBuffer)operator(;) - directive(private) pre_type(Graphics) ident(backBufferGraphics)operator(;) - directive(private) ident(Facade) ident(facade)operator(;) - - directive(private) type(interface) class(Facade) operator({) - directive(public) pre_type(InputStream) ident(getInputStream)operator(()operator(\))operator(;) - directive(public) pre_type(PrintStream) ident(getOutputStream)operator(()operator(\))operator(;) - directive(public) pre_type(PrintStream) ident(getErrorStream)operator(()operator(\))operator(;) - directive(public) type(void) ident(attach)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Applet) ident(applet)operator(\))operator(;) - directive(public) type(void) ident(destroy)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(RubyProc) ident(blockToProc)operator(()ident(Ruby) ident(runtime)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(RubyProc) ident(proc) operator(=) ident(block)operator(.)ident(getProcObject)operator(()operator(\))operator(;) - keyword(if) operator(()ident(proc) operator(==) pre_constant(null)operator(\)) operator({) - ident(proc) operator(=) ident(RubyProc)operator(.)ident(newProc)operator(()ident(runtime)operator(,) ident(block)operator(,) ident(block)operator(.)ident(type)operator(\))operator(;) - operator(}) - keyword(return) ident(proc)operator(;) - operator(}) keyword(else) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) - - directive(private) type(boolean) ident(getBooleanParameter)operator(()pre_type(String) ident(name)operator(,) type(boolean) ident(defaultValue)operator(\)) operator({) - pre_type(String) ident(value) operator(=) ident(getParameter)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(() ident(value) operator(!=) pre_constant(null) operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(equals)operator(()string<delimiter(")content(true)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(defaultValue)operator(;) - operator(}) - operator(}) - - directive(private) pre_type(InputStream) ident(getCodeResourceAsStream)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(name) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - keyword(try) operator({) - directive(final) pre_type(URL) ident(directURL) operator(=) keyword(new) pre_type(URL)operator(()ident(getCodeBase)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - keyword(return) ident(directURL)operator(.)ident(openStream)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - operator(}) - keyword(return) ident(JRubyApplet)operator(.)ident(class)operator(.)ident(getClassLoader)operator(()operator(\))operator(.)ident(getResourceAsStream)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(safeInvokeAndWait)operator(()pre_type(Runnable) ident(runnable)operator(\)) directive(throws) exception(InvocationTargetException)operator(,) exception(InterruptedException) operator({) - keyword(if) operator(()pre_type(EventQueue)operator(.)ident(isDispatchThread)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(runnable)operator(.)ident(run)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) exception(InvocationTargetException)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - pre_type(EventQueue)operator(.)ident(invokeAndWait)operator(()ident(runnable)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(RubyMethods) operator({) - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(on_start)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(JRubyApplet) ident(applet) operator(=) operator(()ident(JRubyApplet)operator(\))ident(recv)operator(.)ident(dataGetStruct)operator(()operator(\))operator(;) - directive(synchronized) operator(()ident(applet)operator(\)) operator({) - ident(applet)operator(.)ident(startProc) operator(=) ident(blockToProc)operator(()ident(applet)operator(.)ident(runtime)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(on_stop)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(JRubyApplet) ident(applet) operator(=) operator(()ident(JRubyApplet)operator(\))ident(recv)operator(.)ident(dataGetStruct)operator(()operator(\))operator(;) - directive(synchronized) operator(()ident(applet)operator(\)) operator({) - ident(applet)operator(.)ident(stopProc) operator(=) ident(blockToProc)operator(()ident(applet)operator(.)ident(runtime)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(on_destroy)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(JRubyApplet) ident(applet) operator(=) operator(()ident(JRubyApplet)operator(\))ident(recv)operator(.)ident(dataGetStruct)operator(()operator(\))operator(;) - directive(synchronized) operator(()ident(applet)operator(\)) operator({) - ident(applet)operator(.)ident(destroyProc) operator(=) ident(blockToProc)operator(()ident(applet)operator(.)ident(runtime)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(on_paint)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(JRubyApplet) ident(applet) operator(=) operator(()ident(JRubyApplet)operator(\))ident(recv)operator(.)ident(dataGetStruct)operator(()operator(\))operator(;) - directive(synchronized) operator(()ident(applet)operator(\)) operator({) - ident(applet)operator(.)ident(paintProc) operator(=) ident(blockToProc)operator(()ident(applet)operator(.)ident(runtime)operator(,) ident(block)operator(\))operator(;) - ident(applet)operator(.)ident(repaint)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(init)operator(()operator(\)) operator({) - local_variable(super)operator(.)ident(init)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(getBooleanParameter)operator(()string<delimiter(")content(jruby.console)delimiter(")>operator(,) pre_constant(false)operator(\))operator(\)) operator({) - ident(facade) operator(=) keyword(new) ident(ConsoleFacade)operator(()ident(getParameter)operator(()string<delimiter(")content(jruby.banner)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(facade) operator(=) keyword(new) ident(TrivialFacade)operator(()operator(\))operator(;) - operator(}) - - directive(synchronized) operator(()local_variable(this)operator(\)) operator({) - keyword(if) operator(()ident(runtime) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - directive(final) ident(RubyInstanceConfig) ident(config) operator(=) keyword(new) ident(RubyInstanceConfig)operator(()operator(\)) operator({)operator({) - ident(setInput)operator(()ident(facade)operator(.)ident(getInputStream)operator(()operator(\))operator(\))operator(;) - ident(setOutput)operator(()ident(facade)operator(.)ident(getOutputStream)operator(()operator(\))operator(\))operator(;) - ident(setError)operator(()ident(facade)operator(.)ident(getErrorStream)operator(()operator(\))operator(\))operator(;) - ident(setObjectSpaceEnabled)operator(()ident(getBooleanParameter)operator(()string<delimiter(")content(jruby.objectspace)delimiter(")>operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(})operator(})operator(;) - ident(Ruby)operator(.)ident(setSecurityRestricted)operator(()pre_constant(true)operator(\))operator(;) - ident(runtime) operator(=) ident(Ruby)operator(.)ident(newInstance)operator(()ident(config)operator(\))operator(;) - operator(}) - - directive(final) pre_type(String) ident(scriptName) operator(=) ident(getParameter)operator(()string<delimiter(")content(jruby.script)delimiter(")>operator(\))operator(;) - directive(final) pre_type(InputStream) ident(scriptStream) operator(=) ident(getCodeResourceAsStream)operator(()ident(scriptName)operator(\))operator(;) - directive(final) pre_type(String) ident(evalString) operator(=) ident(getParameter)operator(()string<delimiter(")content(jruby.eval)delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - directive(final) ident(JRubyApplet) ident(applet) operator(=) local_variable(this)operator(;) - ident(safeInvokeAndWait)operator(()keyword(new) pre_type(Runnable)operator(()operator(\)) operator({) - directive(public) type(void) ident(run)operator(()operator(\)) operator({) - ident(applet)operator(.)ident(setLayout)operator(()keyword(new) pre_type(BorderLayout)operator(()operator(\))operator(\))operator(;) - ident(applet)operator(.)ident(facade)operator(.)ident(attach)operator(()ident(applet)operator(.)ident(runtime)operator(,) ident(applet)operator(\))operator(;) - keyword(if) operator(()ident(scriptStream) operator(!=) pre_constant(null)operator(\)) operator({) - ident(applet)operator(.)ident(runtime)operator(.)ident(runFromMain)operator(()ident(scriptStream)operator(,) ident(scriptName)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(evalString) operator(!=) pre_constant(null)operator(\)) operator({) - ident(applet)operator(.)ident(runtime)operator(.)ident(evalScriptlet)operator(()ident(evalString)operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(e)operator(\)) operator({) - operator(}) keyword(catch) operator(()exception(InvocationTargetException) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Error running script)delimiter(")>operator(,) ident(e)operator(.)ident(getCause)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(invokeCallback)operator(()directive(final) ident(RubyProc) ident(proc)operator(,) directive(final) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(proc) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return)operator(;) - operator(}) - directive(final) ident(Ruby) ident(runtime) operator(=) local_variable(this)operator(.)ident(runtime)operator(;) - keyword(try) operator({) - ident(safeInvokeAndWait)operator(()keyword(new) pre_type(Runnable)operator(()operator(\)) operator({) - directive(public) type(void) ident(run)operator(()operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(proc)operator(.)ident(call)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(e)operator(\)) operator({) - operator(}) keyword(catch) operator(()exception(InvocationTargetException) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Ruby callback failed)delimiter(")>operator(,) ident(e)operator(.)ident(getCause)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(synchronized) type(void) ident(setBackgroundColor)operator(()pre_type(Color) ident(color)operator(\)) operator({) - ident(backgroundColor) operator(=) ident(color)operator(;) - ident(repaint)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(synchronized) pre_type(Color) ident(getBackgroundColor)operator(()operator(\)) operator({) - keyword(return) ident(backgroundColor)operator(;) - operator(}) - - directive(public) directive(synchronized) type(boolean) ident(isDoubleBuffered)operator(()operator(\)) operator({) - keyword(return) ident(doubleBuffered)operator(;) - operator(}) - - directive(public) directive(synchronized) type(void) ident(setDoubleBuffered)operator(()type(boolean) ident(shouldBuffer)operator(\)) operator({) - ident(doubleBuffered) operator(=) ident(shouldBuffer)operator(;) - ident(repaint)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) directive(synchronized) type(void) ident(start)operator(()operator(\)) operator({) - local_variable(super)operator(.)ident(start)operator(()operator(\))operator(;) - ident(invokeCallback)operator(()ident(startProc)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)operator(})operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) directive(synchronized) type(void) ident(stop)operator(()operator(\)) operator({) - ident(invokeCallback)operator(()ident(stopProc)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)operator(})operator(\))operator(;) - local_variable(super)operator(.)ident(stop)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) directive(synchronized) type(void) ident(destroy)operator(()operator(\)) operator({) - keyword(try) operator({) - ident(invokeCallback)operator(()ident(destroyProc)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)operator(})operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(facade)operator(.)ident(destroy)operator(()operator(\))operator(;) - directive(final) ident(Ruby) ident(runtime) operator(=) local_variable(this)operator(.)ident(runtime)operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) pre_constant(null)operator(;) - ident(startProc) operator(=) pre_constant(null)operator(;) - ident(stopProc) operator(=) pre_constant(null)operator(;) - ident(destroyProc) operator(=) pre_constant(null)operator(;) - ident(paintProc) operator(=) pre_constant(null)operator(;) - ident(priorGraphics) operator(=) pre_constant(null)operator(;) - ident(wrappedGraphics) operator(=) pre_constant(null)operator(;) - ident(runtime)operator(.)ident(tearDown)operator(()operator(\))operator(;) - local_variable(super)operator(.)ident(destroy)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(update)operator(()pre_type(Graphics) ident(g)operator(\)) operator({) - ident(paint)operator(()ident(g)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) directive(synchronized) type(void) ident(paint)operator(()pre_type(Graphics) ident(g)operator(\)) operator({) - keyword(if) operator(()ident(doubleBuffered)operator(\)) operator({) - ident(paintBuffered)operator(()ident(g)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(paintUnbuffered)operator(()ident(g)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(synchronized) type(void) ident(paintBuffered)operator(()pre_type(Graphics) ident(g)operator(\)) operator({) - keyword(do) operator({) - pre_type(GraphicsConfiguration) ident(config) operator(=) ident(getGraphicsConfiguration)operator(()operator(\))operator(;) - type(int) ident(width) operator(=) ident(getWidth)operator(()operator(\))operator(;) - type(int) ident(height) operator(=) ident(getHeight)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backBuffer) operator(==) pre_constant(null) operator(||) ident(width) operator(!=) ident(backBuffer)operator(.)ident(getWidth)operator(()operator(\)) operator(||) ident(height) operator(!=) ident(backBuffer)operator(.)ident(getHeight)operator(()operator(\)) operator(||) ident(backBuffer)operator(.)ident(validate)operator(()ident(config)operator(\)) operator(==) pre_type(VolatileImage)operator(.)ident(IMAGE_INCOMPATIBLE)operator(\)) operator({) - keyword(if) operator(()ident(backBuffer) operator(!=) pre_constant(null)operator(\)) operator({) - ident(backBufferGraphics)operator(.)ident(dispose)operator(()operator(\))operator(;) - ident(backBufferGraphics) operator(=) pre_constant(null)operator(;) - ident(backBuffer)operator(.)ident(flush)operator(()operator(\))operator(;) - ident(backBuffer) operator(=) pre_constant(null)operator(;) - operator(}) - ident(backBuffer) operator(=) ident(config)operator(.)ident(createCompatibleVolatileImage)operator(()ident(width)operator(,) ident(height)operator(\))operator(;) - ident(backBufferGraphics) operator(=) ident(backBuffer)operator(.)ident(createGraphics)operator(()operator(\))operator(;) - operator(}) - ident(backBufferGraphics)operator(.)ident(setClip)operator(()ident(g)operator(.)ident(getClip)operator(()operator(\))operator(\))operator(;) - ident(paintUnbuffered)operator(()ident(backBufferGraphics)operator(\))operator(;) - ident(g)operator(.)ident(drawImage)operator(()ident(backBuffer)operator(,) integer(0)operator(,) integer(0)operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(while) operator(()ident(backBuffer)operator(.)ident(contentsLost)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(synchronized) type(void) ident(paintUnbuffered)operator(()pre_type(Graphics) ident(g)operator(\)) operator({) - keyword(if) operator(()ident(backgroundColor) operator(!=) pre_constant(null)operator(\)) operator({) - ident(g)operator(.)ident(setColor)operator(()ident(backgroundColor)operator(\))operator(;) - ident(g)operator(.)ident(fillRect)operator(()integer(0)operator(,) integer(0)operator(,) ident(getWidth)operator(()operator(\))operator(,) ident(getHeight)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(paintProc) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(priorGraphics) operator(!=) ident(g)operator(\)) operator({) - ident(wrappedGraphics) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToUsableRubyObject)operator(()ident(runtime)operator(,) ident(g)operator(\))operator(;) - ident(priorGraphics) operator(=) ident(g)operator(;) - operator(}) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(paintProc)operator(.)ident(call)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(wrappedGraphics)operator(})operator(\))operator(;) - operator(}) - local_variable(super)operator(.)ident(paint)operator(()ident(g)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(class) class(TrivialFacade) directive(implements) ident(Facade) operator({) - directive(public) ident(TrivialFacade)operator(()operator(\)) operator({)operator(}) - directive(public) pre_type(InputStream) ident(getInputStream)operator(()operator(\)) operator({) keyword(return) pre_type(System)operator(.)ident(in)operator(;) operator(}) - directive(public) pre_type(PrintStream) ident(getOutputStream)operator(()operator(\)) operator({) keyword(return) pre_type(System)operator(.)ident(out)operator(;) operator(}) - directive(public) pre_type(PrintStream) ident(getErrorStream)operator(()operator(\)) operator({) keyword(return) pre_type(System)operator(.)ident(err)operator(;) operator(}) - directive(public) type(void) ident(attach)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Applet) ident(applet)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(wrappedApplet) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToUsableRubyObject)operator(()ident(runtime)operator(,) ident(applet)operator(\))operator(;) - ident(wrappedApplet)operator(.)ident(dataWrapStruct)operator(()ident(applet)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(JRUBY_APPLET)delimiter(")>operator(,) ident(wrappedApplet)operator(\))operator(;) - ident(wrappedApplet)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyMethods)operator(.)ident(class)operator(\))operator(;) - operator(}) - directive(public) type(void) ident(destroy)operator(()operator(\)) operator({)operator(}) - operator(}) - - directive(private) directive(static) type(class) class(ConsoleFacade) directive(implements) ident(Facade) operator({) - directive(private) pre_type(JTextPane) ident(textPane)operator(;) - directive(private) pre_type(JScrollPane) ident(scrollPane)operator(;) - directive(private) ident(TextAreaReadline) ident(adaptor)operator(;) - directive(private) pre_type(InputStream) ident(inputStream)operator(;) - directive(private) pre_type(PrintStream) ident(outputStream)operator(;) - directive(private) pre_type(PrintStream) ident(errorStream)operator(;) - - directive(public) ident(ConsoleFacade)operator(()pre_type(String) ident(bannerText)operator(\)) operator({) - ident(textPane) operator(=) keyword(new) pre_type(JTextPane)operator(()operator(\))operator(;) - ident(textPane)operator(.)ident(setMargin)operator(()keyword(new) pre_type(Insets)operator(()integer(4)operator(,) integer(4)operator(,) integer(0)operator(,) integer(4)operator(\))operator(\))operator(;) - ident(textPane)operator(.)ident(setCaretColor)operator(()keyword(new) pre_type(Color)operator(()hex(0xa4)operator(,) hex(0x00)operator(,) hex(0x00)operator(\))operator(\))operator(;) - ident(textPane)operator(.)ident(setBackground)operator(()keyword(new) pre_type(Color)operator(()hex(0xf2)operator(,) hex(0xf2)operator(,) hex(0xf2)operator(\))operator(\))operator(;) - ident(textPane)operator(.)ident(setForeground)operator(()keyword(new) pre_type(Color)operator(()hex(0xa4)operator(,) hex(0x00)operator(,) hex(0x00)operator(\))operator(\))operator(;) - - pre_type(Font) ident(font) operator(=) ident(findFont)operator(()string<delimiter(")content(Monospaced)delimiter(")>operator(,) pre_type(Font)operator(.)ident(PLAIN)operator(,) integer(14)operator(,) - keyword(new) pre_type(String)type([]) operator({)string<delimiter(")content(Monaco)delimiter(")>operator(,) string<delimiter(")content(Andale Mono)delimiter(")>operator(})operator(\))operator(;) - - ident(textPane)operator(.)ident(setFont)operator(()ident(font)operator(\))operator(;) - - ident(scrollPane) operator(=) keyword(new) pre_type(JScrollPane)operator(()ident(textPane)operator(\))operator(;) - ident(scrollPane)operator(.)ident(setDoubleBuffered)operator(()pre_constant(true)operator(\))operator(;) - keyword(if) operator(() ident(bannerText) operator(!=) pre_constant(null) operator(\)) operator({) - ident(bannerText) operator(=) string<delimiter(")content( )delimiter(")> operator(+) ident(bannerText) operator(+) string<delimiter(")content( )char(\\n)char(\\n)delimiter(")>operator(;) - operator(}) - ident(adaptor) operator(=) keyword(new) ident(TextAreaReadline)operator(()ident(textPane)operator(,) ident(bannerText)operator(\))operator(;) - ident(inputStream) operator(=) ident(adaptor)operator(.)ident(getInputStream)operator(()operator(\))operator(;) - ident(outputStream) operator(=) keyword(new) pre_type(PrintStream)operator(()ident(adaptor)operator(.)ident(getOutputStream)operator(()operator(\))operator(\))operator(;) - ident(errorStream) operator(=) keyword(new) pre_type(PrintStream)operator(()ident(adaptor)operator(.)ident(getOutputStream)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getInputStream)operator(()operator(\)) operator({) keyword(return) ident(inputStream)operator(;) operator(}) - directive(public) pre_type(PrintStream) ident(getOutputStream)operator(()operator(\)) operator({) keyword(return) ident(outputStream)operator(;) operator(}) - directive(public) pre_type(PrintStream) ident(getErrorStream)operator(()operator(\)) operator({) keyword(return) ident(errorStream)operator(;) operator(}) - - directive(public) type(void) ident(attach)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Applet) ident(applet)operator(\)) operator({) - ident(adaptor)operator(.)ident(hookIntoRuntime)operator(()ident(runtime)operator(\))operator(;) - ident(applet)operator(.)ident(add)operator(()ident(scrollPane)operator(\))operator(;) - ident(applet)operator(.)ident(validate)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(destroy)operator(()operator(\)) operator({) - pre_type(Container) ident(parent) operator(=) ident(scrollPane)operator(.)ident(getParent)operator(()operator(\))operator(;) - ident(adaptor)operator(.)ident(shutdown)operator(()operator(\))operator(;) - keyword(if) operator(()ident(parent) operator(!=) pre_constant(null)operator(\)) operator({) - ident(parent)operator(.)ident(remove)operator(()ident(scrollPane)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) pre_type(Font) ident(findFont)operator(()pre_type(String) ident(otherwise)operator(,) type(int) ident(style)operator(,) type(int) ident(size)operator(,) pre_type(String)type([]) ident(families)operator(\)) operator({) - pre_type(String)type([]) ident(fonts) operator(=) pre_type(GraphicsEnvironment)operator(.)ident(getLocalGraphicsEnvironment)operator(()operator(\))operator(.)ident(getAvailableFontFamilyNames)operator(()operator(\))operator(;) - pre_type(Arrays)operator(.)ident(sort)operator(()ident(fonts)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(families)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()pre_type(Arrays)operator(.)ident(binarySearch)operator(()ident(fonts)operator(,) ident(families)operator([)ident(i)operator(])operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(return) keyword(new) pre_type(Font)operator(()ident(families)operator([)ident(i)operator(])operator(,) ident(style)operator(,) ident(size)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) keyword(new) pre_type(Font)operator(()ident(otherwise)operator(,) ident(style)operator(,) ident(size)operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.BufferedWriter)operator(;) -keyword(import) include(java.io.OutputStreamWriter)operator(;) - -keyword(import) include(java.net.InetAddress)operator(;) -keyword(import) include(java.net.Socket)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -directive(public) type(class) class(JRubyClient) directive(extends) ident(JRubyService) operator({) - directive(public) ident(JRubyClient)operator(()pre_type(String)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - pre_type(Configuration) ident(conf) operator(=) keyword(new) pre_type(Configuration)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Starting client with port )delimiter(")> operator(+) ident(conf)operator(.)ident(getPort)operator(()operator(\)) operator(+) string<delimiter(")content(, key )delimiter(")> operator(+) ident(conf)operator(.)ident(getKey)operator(()operator(\)) operator(+) string<delimiter(")content( and command )delimiter(")> operator(+) ident(conf)operator(.)ident(getCommand)operator(()operator(\))operator(\))operator(;) - operator(}) - pre_type(Socket) ident(socket) operator(=) keyword(new) pre_type(Socket)operator(()pre_type(InetAddress)operator(.)ident(getLocalHost)operator(()operator(\))operator(,) ident(conf)operator(.)ident(getPort)operator(()operator(\))operator(\))operator(;) - pre_type(BufferedWriter) ident(writer) operator(=) keyword(new) pre_type(BufferedWriter)operator(()keyword(new) pre_type(OutputStreamWriter)operator(()ident(socket)operator(.)ident(getOutputStream)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(if)operator(()ident(conf)operator(.)ident(terminate)operator(()operator(\))operator(\)) operator({) - ident(writer)operator(.)ident(write)operator(()ident(CMD_TERM) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(conf)operator(.)ident(getKey)operator(()operator(\)) operator(+) string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(conf)operator(.)ident(noMore)operator(()operator(\))operator(\)) operator({) - ident(writer)operator(.)ident(write)operator(()ident(CMD_NO_MORE) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(conf)operator(.)ident(getKey)operator(()operator(\)) operator(+) string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(writer)operator(.)ident(write)operator(()ident(CMD_START) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(conf)operator(.)ident(getKey)operator(()operator(\)) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(conf)operator(.)ident(getCommand)operator(()operator(\)) operator(+) string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - operator(}) - ident(writer)operator(.)ident(flush)operator(()operator(\))operator(;) - ident(writer)operator(.)ident(close)operator(()operator(\))operator(;) - ident(socket)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(main)operator(()pre_type(String)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - keyword(new) ident(JRubyClient)operator(()ident(args)operator(\))operator(;) - operator(}) -operator(})comment(// JRubyClient) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.BufferedReader)operator(;) -keyword(import) include(java.io.InputStreamReader)operator(;) - -keyword(import) include(java.net.InetAddress)operator(;) -keyword(import) include(java.net.InetSocketAddress)operator(;) -keyword(import) include(java.net.ServerSocket)operator(;) -keyword(import) include(java.net.Socket)operator(;) - -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -directive(public) type(class) class(JRubyServer) directive(extends) ident(JRubyService) operator({) - directive(private) pre_type(Configuration) ident(conf)operator(;) - - directive(private) type(boolean) ident(stillStarting) operator(=) pre_constant(true)operator(;) - - directive(private) ident(JRubyServer)operator(()pre_type(String)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(conf) operator(=) keyword(new) pre_type(Configuration)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Starting server with port )delimiter(")> operator(+) ident(conf)operator(.)ident(getPort)operator(()operator(\)) operator(+) string<delimiter(")content( and key )delimiter(")> operator(+) ident(conf)operator(.)ident(getKey)operator(()operator(\))operator(\))operator(;) - operator(}) - pre_type(ServerSocket) ident(server) operator(=) keyword(new) pre_type(ServerSocket)operator(()operator(\))operator(;) - ident(server)operator(.)ident(bind)operator(()keyword(new) pre_type(InetSocketAddress)operator(()pre_type(InetAddress)operator(.)ident(getLocalHost)operator(()operator(\))operator(,)ident(conf)operator(.)ident(getPort)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(while)operator(()pre_constant(true)operator(\)) operator({) - pre_type(Thread) ident(t1) operator(=) keyword(new) pre_type(Thread)operator(()keyword(new) pre_type(Handler)operator(()ident(server)operator(.)ident(accept)operator(()operator(\))operator(\))operator(\))operator(;) - ident(t1)operator(.)ident(setDaemon)operator(()pre_constant(true)operator(\))operator(;) - ident(t1)operator(.)ident(start)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(class) class(Handler) directive(implements) pre_type(Runnable) operator({) - directive(private) pre_type(Socket) ident(socket)operator(;) - - directive(public) pre_type(Handler)operator(()pre_type(Socket) ident(socket)operator(\)) operator({) - local_variable(this)operator(.)ident(socket) operator(=) ident(socket)operator(;) - operator(}) - - directive(public) type(void) ident(run)operator(()operator(\)) operator({) - keyword(try) operator({) - pre_type(BufferedReader) ident(rr) operator(=) keyword(new) pre_type(BufferedReader)operator(()keyword(new) pre_type(InputStreamReader)operator(()local_variable(this)operator(.)ident(socket)operator(.)ident(getInputStream)operator(()operator(\))operator(\))operator(\))operator(;) - pre_type(String) ident(command) operator(=) ident(rr)operator(.)ident(readLine)operator(()operator(\))operator(;) - ident(rr)operator(.)ident(close)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(socket)operator(.)ident(close)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(socket) operator(=) pre_constant(null)operator(;) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Got command: )delimiter(")> operator(+) ident(command)operator(\))operator(;) - operator(}) - pre_type(String)type([]) ident(cmds) operator(=) ident(command)operator(.)ident(split)operator(()string<delimiter(")content( )delimiter(")>operator(,) integer(3)operator(\))operator(;) - keyword(if)operator(()ident(cmds)operator([)integer(1)operator(])operator(.)ident(equals)operator(()ident(conf)operator(.)ident(getKey)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(if)operator(()ident(cmds)operator([)integer(0)operator(])operator(.)ident(equals)operator(()ident(CMD_TERM)operator(\))operator(\)) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Terminating hard)delimiter(")>operator(\))operator(;) - operator(}) - pre_type(System)operator(.)ident(exit)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(cmds)operator([)integer(0)operator(])operator(.)ident(equals)operator(()ident(CMD_NO_MORE)operator(\))operator(\)) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Accepting no more START)delimiter(")>operator(\))operator(;) - operator(}) - ident(stillStarting) operator(=) pre_constant(false)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(cmds)operator([)integer(0)operator(])operator(.)ident(equals)operator(()ident(CMD_START)operator(\))operator(\)) operator({) - keyword(if)operator(()ident(stillStarting)operator(\)) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Doing START on command )delimiter(")> operator(+) ident(cmds)operator([)integer(2)operator(])operator(\))operator(;) - operator(}) - keyword(new) ident(Main)operator(()operator(\))operator(.)ident(run)operator(()ident(intoCommandArguments)operator(()ident(cmds)operator([)integer(2)operator(])operator(.)ident(trim)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Not doing START anymore, invalid command)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Unrecognized command)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - keyword(if)operator(()ident(conf)operator(.)ident(isDebug)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Invalid key)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - operator(}) - operator(}) - - directive(protected) directive(static) pre_type(String)type([]) ident(intoCommandArguments)operator(()pre_type(String) ident(str)operator(\)) operator({) - pre_type(List)operator(<)pre_type(String)operator(>) ident(args) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - type(boolean) ident(inSingle) operator(=) pre_constant(false)operator(;) - type(int) ident(contentStart) operator(=) operator(-)integer(1)operator(;) - - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(,)ident(j)operator(=)ident(str)operator(.)ident(length)operator(()operator(\))operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - keyword(if)operator(()ident(str)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')content( )delimiter(')> operator(&&) operator(!)ident(inSingle) operator(&&) ident(contentStart) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(args)operator(.)ident(add)operator(()ident(str)operator(.)ident(substring)operator(()ident(contentStart)operator(,)ident(i)operator(\))operator(\))operator(;) - ident(contentStart) operator(=) operator(-)integer(1)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if)operator(()ident(str)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')content( )delimiter(')>operator(\)) operator({) - keyword(continue)operator(;) - operator(}) - keyword(if)operator(()ident(str)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')char(\\')delimiter(')> operator(&&) operator(!)ident(inSingle)operator(\)) operator({) - ident(inSingle) operator(=) pre_constant(true)operator(;) - ident(contentStart) operator(=) ident(i)operator(+)integer(1)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if)operator(()ident(str)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')char(\\')delimiter(')>operator(\)) operator({) - ident(inSingle) operator(=) pre_constant(false)operator(;) - ident(args)operator(.)ident(add)operator(()ident(str)operator(.)ident(substring)operator(()ident(contentStart)operator(,)ident(i)operator(\))operator(\))operator(;) - ident(contentStart) operator(=) operator(-)integer(1)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if)operator(()ident(contentStart) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(contentStart) operator(=) ident(i)operator(;) - operator(}) - operator(}) - keyword(if)operator(()ident(contentStart) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(args)operator(.)ident(add)operator(()ident(str)operator(.)ident(substring)operator(()ident(contentStart)operator(\))operator(\))operator(;) - operator(}) - keyword(return) operator(()pre_type(String)type([])operator(\))ident(args)operator(.)ident(toArray)operator(()keyword(new) pre_type(String)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(main)operator(()pre_type(String)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - keyword(new) ident(JRubyServer)operator(()ident(args)operator(\))operator(;) - operator(}) -operator(})comment(// JRubyServer) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -directive(public) directive(abstract) type(class) class(JRubyService) operator({) - directive(protected) directive(static) type(class) class(Configuration) operator({) - directive(private) directive(final) directive(static) type(int) ident(DEFAULT_PORT) operator(=) integer(19222)operator(;) - - directive(private) pre_type(String) ident(key)operator(;) - directive(private) type(int) ident(port) operator(=) ident(DEFAULT_PORT)operator(;) - directive(private) type(boolean) ident(terminate)operator(;) - directive(private) type(boolean) ident(noMore)operator(;) - directive(private) type(boolean) ident(debug)operator(;) - directive(private) pre_type(String) ident(command)operator(;) - - directive(public) pre_type(Configuration)operator(()pre_type(String) ident(args)operator(\)) operator({) - type(int) ident(i)operator(=)integer(0)operator(;) - type(int) ident(stop)operator(;) - ident(loop)operator(:) keyword(for)operator(()type(int) ident(j)operator(=)ident(args)operator(.)ident(length)operator(()operator(\))operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - keyword(if)operator(()ident(args)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')content(-)delimiter(')> operator(&&) ident(i)operator(+)integer(1) operator(<) ident(j)operator(\)) operator({) - keyword(switch)operator(()ident(args)operator(.)ident(charAt)operator(()operator(++)ident(i)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(k)delimiter(')>operator(:) - ident(stop) operator(=) ident(args)operator(.)ident(indexOf)operator(()string<delimiter(")content( )delimiter(")>operator(,) operator(()operator(++)ident(i)operator(\)) operator(+) integer(1)operator(\))operator(;) - keyword(if)operator(()ident(stop) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(stop) operator(=) ident(args)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - ident(key) operator(=) ident(args)operator(.)ident(substring)operator(()ident(i)operator(,) ident(stop)operator(\))operator(.)ident(trim)operator(()operator(\))operator(;) - ident(i) operator(=) ident(stop)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(p)delimiter(')>operator(:) - ident(stop) operator(=) ident(args)operator(.)ident(indexOf)operator(()string<delimiter(")content( )delimiter(")>operator(,) operator(()operator(++)ident(i)operator(\)) operator(+) integer(1)operator(\))operator(;) - keyword(if)operator(()ident(stop) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(stop) operator(=) ident(args)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - ident(port) operator(=) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(args)operator(.)ident(substring)operator(()ident(i)operator(,) ident(stop)operator(\))operator(.)ident(trim)operator(()operator(\))operator(\))operator(;) - ident(i) operator(=) ident(stop)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(t)delimiter(')>operator(:) - ident(terminate) operator(=) pre_constant(true)operator(;) - ident(i)operator(++)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(n)delimiter(')>operator(:) - ident(noMore) operator(=) pre_constant(true)operator(;) - ident(i)operator(++)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(d)delimiter(')>operator(:) - ident(debug) operator(=) pre_constant(true)operator(;) - ident(i)operator(++)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) comment(// handle everything after -- as arguments to the jruby process) - ident(i)operator(++)operator(;) - keyword(break) ident(loop)operator(;) - keyword(default)operator(:) - ident(i)operator(--)operator(;) - keyword(break) ident(loop)operator(;) - operator(}) - operator(}) keyword(else) keyword(if)operator(()ident(args)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(!=) string<delimiter(')content( )delimiter(')>operator(\)) operator({) - keyword(break) ident(loop)operator(;) - operator(}) - operator(}) - keyword(if)operator(()ident(i)operator(<)ident(args)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(command) operator(=) ident(args)operator(.)ident(substring)operator(()ident(i)operator(\))operator(.)ident(trim)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) pre_type(String) ident(getKey)operator(()operator(\)) operator({) - keyword(return) ident(key)operator(;) - operator(}) - - directive(public) type(int) ident(getPort)operator(()operator(\)) operator({) - keyword(return) ident(port)operator(;) - operator(}) - - directive(public) type(boolean) ident(terminate)operator(()operator(\)) operator({) - keyword(return) ident(terminate)operator(;) - operator(}) - - directive(public) type(boolean) ident(noMore)operator(()operator(\)) operator({) - keyword(return) ident(noMore)operator(;) - operator(}) - - directive(public) type(boolean) ident(isDebug)operator(()operator(\)) operator({) - keyword(return) ident(debug)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getCommand)operator(()operator(\)) operator({) - keyword(return) ident(command)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) directive(final) pre_type(String) ident(CMD_START) operator(=) string<delimiter(")content(START)delimiter(")>operator(;) - directive(public) directive(static) directive(final) pre_type(String) ident(CMD_NO_MORE) operator(=) string<delimiter(")content(NO_MORE)delimiter(")>operator(;) - directive(public) directive(static) directive(final) pre_type(String) ident(CMD_TERM) operator(=) string<delimiter(")content(TERM)delimiter(")>operator(;) -operator(})comment(// JRubyService) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2006 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Kiel Hodges <jruby-devel@selfsosoft.com> - * Copyright (C\) 2005 Jason Voegele <jason@jvoegele.com> - * Copyright (C\) 2005 Tim Azzopardi <tim@tigerfive.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.PrintStream)operator(;) - -keyword(import) include(org.jruby.exceptions.MainExitException)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.exceptions.ThreadKill)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.SafePropertyAccessor)operator(;) -keyword(import) include(org.jruby.util.SimpleSampler)operator(;) - -comment(/** - * Class used to launch the interpreter. - * This is the main class as defined in the jruby.mf manifest. - * It is very basic and does not support yet the same array of switches - * as the C interpreter. - * Usage: java -jar jruby.jar [switches] [rubyfile.rb] [arguments] - * -e 'command' one line of script. Several -e's allowed. Omit [programfile] - * @author jpetersen - */) -directive(public) type(class) class(Main) operator({) - directive(private) type(boolean) ident(hasPrintedUsage) operator(=) pre_constant(false)operator(;) - directive(private) directive(final) ident(RubyInstanceConfig) ident(config)operator(;) - - directive(public) ident(Main)operator(()ident(RubyInstanceConfig) ident(config)operator(\)) operator({) - local_variable(this)operator(.)ident(config) operator(=) ident(config)operator(;) - operator(}) - - directive(public) ident(Main)operator(()directive(final) pre_type(InputStream) ident(in)operator(,) directive(final) pre_type(PrintStream) ident(out)operator(,) directive(final) pre_type(PrintStream) ident(err)operator(\)) operator({) - local_variable(this)operator(()keyword(new) ident(RubyInstanceConfig)operator(()operator(\))operator({)operator({) - ident(setInput)operator(()ident(in)operator(\))operator(;) - ident(setOutput)operator(()ident(out)operator(\))operator(;) - ident(setError)operator(()ident(err)operator(\))operator(;) - operator(})operator(})operator(\))operator(;) - operator(}) - - directive(public) ident(Main)operator(()operator(\)) operator({) - local_variable(this)operator(()keyword(new) ident(RubyInstanceConfig)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(main)operator(()pre_type(String)type([]) ident(args)operator(\)) operator({) - ident(Main) ident(main) operator(=) keyword(new) ident(Main)operator(()operator(\))operator(;) - - keyword(try) operator({) - type(int) ident(status) operator(=) ident(main)operator(.)ident(run)operator(()ident(args)operator(\))operator(;) - keyword(if) operator(()ident(status) operator(!=) integer(0)operator(\)) operator({) - pre_type(System)operator(.)ident(exit)operator(()ident(status)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(re)operator(\)) operator({) - keyword(throw) ident(re)operator(;) - operator(}) keyword(catch) operator(()pre_type(Throwable) ident(t)operator(\)) operator({) - comment(// print out as a nice Ruby backtrace) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()ident(ThreadContext)operator(.)ident(createRawBacktraceStringFromThrowable)operator(()ident(t)operator(\))operator(\))operator(;) - pre_type(System)operator(.)ident(exit)operator(()integer(1)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(int) ident(run)operator(()pre_type(String)type([]) ident(args)operator(\)) operator({) - keyword(try) operator({) - ident(config)operator(.)ident(processArguments)operator(()ident(args)operator(\))operator(;) - keyword(return) ident(run)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(MainExitException) ident(mee)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(mee)operator(.)ident(isAborted)operator(()operator(\))operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(println)operator(()ident(mee)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(mee)operator(.)ident(isUsageError)operator(()operator(\))operator(\)) operator({) - ident(printUsage)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(mee)operator(.)ident(getStatus)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(OutOfMemoryError) ident(oome)operator(\)) operator({) - comment(// produce a nicer error since Rubyists aren't used to seeing this) - pre_type(System)operator(.)ident(gc)operator(()operator(\))operator(;) - - pre_type(String) ident(memoryMax) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.memory.max)delimiter(")>operator(\))operator(;) - pre_type(String) ident(message) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(if) operator(()ident(memoryMax) operator(!=) pre_constant(null)operator(\)) operator({) - ident(message) operator(=) string<delimiter(")content( of )delimiter(")> operator(+) ident(memoryMax)operator(;) - operator(}) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error: Your application used more memory than the safety cap)delimiter(")> operator(+) ident(message) operator(+) string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Specify -J-Xmx####m to increase it (#### = cap size in MB\).)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(getVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Exception trace follows:)delimiter(")>operator(\))operator(;) - ident(oome)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Specify -w for full OutOfMemoryError stack trace)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) integer(1)operator(;) - operator(}) keyword(catch) operator(()exception(StackOverflowError) ident(soe)operator(\)) operator({) - comment(// produce a nicer error since Rubyists aren't used to seeing this) - pre_type(System)operator(.)ident(gc)operator(()operator(\))operator(;) - - pre_type(String) ident(stackMax) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.stack.max)delimiter(")>operator(\))operator(;) - pre_type(String) ident(message) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(if) operator(()ident(stackMax) operator(!=) pre_constant(null)operator(\)) operator({) - ident(message) operator(=) string<delimiter(")content( of )delimiter(")> operator(+) ident(stackMax)operator(;) - operator(}) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error: Your application used more stack memory than the safety cap)delimiter(")> operator(+) ident(message) operator(+) string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Specify -J-Xss####k to increase it (#### = cap size in KB\).)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(getVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Exception trace follows:)delimiter(")>operator(\))operator(;) - ident(soe)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Specify -w for full StackOverflowError stack trace)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) integer(1)operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedClassVersionError) ident(ucve)operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error: Some library (perhaps JRuby\) was built with a later JVM version.)delimiter(")>operator(\))operator(;) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Please use libraries built with the version you intend to use or an earlier one.)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(getVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Exception trace follows:)delimiter(")>operator(\))operator(;) - ident(ucve)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Specify -w for full UnsupportedClassVersionError stack trace)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) integer(1)operator(;) - operator(}) keyword(catch) operator(()ident(ThreadKill) ident(kill)operator(\)) operator({) - keyword(return) integer(0)operator(;) - operator(}) - operator(}) - - directive(public) type(int) ident(run)operator(()operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isShowVersion)operator(()operator(\))operator(\)) operator({) - ident(showVersion)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(config)operator(.)ident(isShowCopyright)operator(()operator(\))operator(\)) operator({) - ident(showCopyright)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(config)operator(.)ident(shouldRunInterpreter)operator(()operator(\)) operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(shouldPrintUsage)operator(()operator(\))operator(\)) operator({) - ident(printUsage)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(config)operator(.)ident(shouldPrintProperties)operator(()operator(\))operator(\)) operator({) - ident(printProperties)operator(()operator(\))operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - pre_type(InputStream) ident(in) operator(=) ident(config)operator(.)ident(getScriptSource)operator(()operator(\))operator(;) - pre_type(String) ident(filename) operator(=) ident(config)operator(.)ident(displayedFileName)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(Ruby)operator(.)ident(newInstance)operator(()ident(config)operator(\))operator(;) - - comment(// set thread context JRuby classloader here, for the main thread) - keyword(try) operator({) - pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\))operator(.)ident(setContextClassLoader)operator(()ident(runtime)operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(SecurityException) ident(se)operator(\)) operator({) - comment(// can't set TC classloader) - keyword(if) operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(WARNING: Security restrictions disallowed setting context classloader for main thread.)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(in) operator(==) pre_constant(null)operator(\)) operator({) - comment(// no script to run, return success below) - operator(}) keyword(else) keyword(if) operator(()ident(config)operator(.)ident(isShouldCheckSyntax)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(parseFromMain)operator(()ident(in)operator(,) ident(filename)operator(\))operator(;) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(println)operator(()string<delimiter(")content(Syntax OK)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - type(long) ident(now) operator(=) operator(-)integer(1)operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isBenchmarking)operator(()operator(\))operator(\)) operator({) - ident(now) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(config)operator(.)ident(isSamplingEnabled)operator(()operator(\))operator(\)) operator({) - ident(SimpleSampler)operator(.)ident(startSampleThread)operator(()operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(runtime)operator(.)ident(runFromMain)operator(()ident(in)operator(,) ident(filename)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(tearDown)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(isBenchmarking)operator(()operator(\))operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(println)operator(()string<delimiter(")content(Runtime: )delimiter(")> operator(+) operator(()pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(-) ident(now)operator(\)) operator(+) string<delimiter(")content( ms)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(config)operator(.)ident(isSamplingEnabled)operator(()operator(\))operator(\)) operator({) - ident(org)operator(.)ident(jruby)operator(.)ident(util)operator(.)ident(SimpleSampler)operator(.)ident(report)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(rj)operator(\)) operator({) - ident(RubyException) ident(raisedException) operator(=) ident(rj)operator(.)ident(getException)operator(()operator(\))operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getSystemExit)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(raisedException)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(status) operator(=) ident(raisedException)operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(status)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(status) operator(!=) pre_constant(null) operator(&&) operator(!)ident(status)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(status)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(printError)operator(()ident(raisedException)operator(\))operator(;) - keyword(return) integer(1)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - directive(private) type(void) ident(showVersion)operator(()operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(print)operator(()ident(config)operator(.)ident(getVersionString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(showCopyright)operator(()operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(print)operator(()ident(config)operator(.)ident(getCopyrightString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(printUsage)operator(()operator(\)) operator({) - keyword(if) operator(()operator(!)ident(hasPrintedUsage)operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(print)operator(()ident(config)operator(.)ident(getBasicUsageHelp)operator(()operator(\))operator(\))operator(;) - ident(hasPrintedUsage) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(printProperties)operator(()operator(\)) operator({) - ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(.)ident(print)operator(()ident(config)operator(.)ident(getPropertyHelp)operator(()operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.ref.SoftReference)operator(;) - -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -directive(public) directive(final) type(class) class(MetaClass) directive(extends) ident(RubyClass) operator({) - - directive(private) pre_type(SoftReference)operator(<)ident(IRubyObject)operator(>) ident(attached) operator(=) keyword(new) pre_type(SoftReference)operator(<)ident(IRubyObject)operator(>)operator(()pre_constant(null)operator(\))operator(;) - - comment(/** NEWOBJ (in RubyObject#getSingletonClassClone(\)\) - * - */) - directive(public) ident(MetaClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) pre_constant(null)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_class_boot (for MetaClasses\) (in makeMetaClass(RubyClass\)\) - * - */) - directive(public) ident(MetaClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(superClass)operator(,) pre_constant(false)operator(\))operator(;) - ident(index) operator(=) ident(superClass)operator(.)ident(index)operator(;) comment(// use same ClassIndex as metaclass, since we're technically still of that type) - operator(}) - - directive(public) type(boolean) ident(isSingleton)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - comment(/** - * If an object uses an anonymous class 'class << obj', then this grabs the original - * metaclass and not the one that get injected as a result of 'class << obj'. - */) - directive(public) ident(RubyClass) ident(getRealClass)operator(()operator(\)) operator({) - keyword(return) ident(superClass)operator(.)ident(getRealClass)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(final) ident(IRubyObject) ident(allocate)operator(()operator(\))operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't create instance of virtual class)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getAttached)operator(()operator(\)) operator({) - keyword(return) ident(attached)operator(.)ident(get)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setAttached)operator(()ident(IRubyObject) ident(attached)operator(\)) operator({) - local_variable(this)operator(.)ident(attached) operator(=) keyword(new) pre_type(SoftReference)operator(<)ident(IRubyObject)operator(>)operator(()ident(attached)operator(\))operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2005 David Corbin <dcorbin@users.sourceforge.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.PrintStream)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.javasupport.Java)operator(;) -keyword(import) include(org.jruby.javasupport.JavaObject)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyClass)operator(()ident(name) operator(=) string<delimiter(")content(NativeException)delimiter(")>operator(,) ident(parent) operator(=) string<delimiter(")content(RuntimeError)delimiter(")>operator(\)) -directive(public) type(class) class(NativeException) directive(extends) ident(RubyException) operator({) - - directive(private) directive(final) pre_type(Throwable) ident(cause)operator(;) - directive(public) directive(static) directive(final) pre_type(String) ident(CLASS_NAME) operator(=) string<delimiter(")content(NativeException)delimiter(")>operator(;) - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - - directive(public) ident(NativeException)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(Throwable) ident(cause)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) ident(cause)operator(.)ident(getClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(cause)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - local_variable(this)operator(.)ident(cause) operator(=) ident(cause)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(baseClass)operator(\)) operator({) - comment(// FIXME: If NativeException is expected to be used from Ruby code, it should provide) - comment(// a real allocator to be used. Otherwise Class.new will fail, as will marshalling. JRUBY-415) - ident(RubyClass) ident(exceptionClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()ident(CLASS_NAME)operator(,) ident(baseClass)operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - - ident(exceptionClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(NativeException)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(exceptionClass)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(cause)operator(()ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(Java)operator(.)ident(wrap)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(JavaObject)operator(.)ident(wrap)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(cause)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(backtrace)operator(()operator(\)) operator({) - ident(IRubyObject) ident(rubyTrace) operator(=) local_variable(super)operator(.)ident(backtrace)operator(()operator(\))operator(;) - keyword(if) operator(()ident(rubyTrace)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(rubyTrace)operator(;) - operator(}) - ident(RubyArray) ident(array) operator(=) operator(()ident(RubyArray)operator(\)) ident(rubyTrace)operator(.)ident(dup)operator(()operator(\))operator(;) - pre_type(StackTraceElement)type([]) ident(stackTrace) operator(=) ident(cause)operator(.)ident(getStackTrace)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(stackTrace)operator(.)ident(length) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - pre_type(StackTraceElement) ident(element) operator(=) ident(stackTrace)operator([)ident(i)operator(])operator(;) - pre_type(String) ident(className) operator(=) ident(element)operator(.)ident(getClassName)operator(()operator(\))operator(;) - pre_type(String) ident(line) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(element)operator(.)ident(getFileName)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(line) operator(=) ident(className) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(element)operator(.)ident(getLineNumber)operator(()operator(\)) operator(+) string<delimiter(")content(:in `)delimiter(")> operator(+) ident(element)operator(.)ident(getMethodName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(;) - operator(}) keyword(else) operator({) - type(int) ident(index) operator(=) ident(className)operator(.)ident(lastIndexOf)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - pre_type(String) ident(packageName) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(index) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(packageName) operator(=) string<delimiter(")delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(packageName) operator(=) ident(className)operator(.)ident(substring)operator(()integer(0)operator(,) ident(index)operator(\)) operator(+) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) - ident(line) operator(=) ident(packageName)operator(.)ident(replace)operator(()string<delimiter(")content(.)delimiter(")>operator(,) string<delimiter(")content(/)delimiter(")>operator(\)) operator(+) ident(element)operator(.)ident(getFileName)operator(()operator(\)) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(element)operator(.)ident(getLineNumber)operator(()operator(\)) operator(+) string<delimiter(")content(:in `)delimiter(")> operator(+) ident(element)operator(.)ident(getMethodName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(;) - operator(}) - ident(RubyString) ident(string) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(line)operator(\))operator(;) - ident(array)operator(.)ident(unshift)operator(()ident(string)operator(\))operator(;) - operator(}) - keyword(return) ident(array)operator(;) - operator(}) - - directive(public) type(void) ident(printBacktrace)operator(()pre_type(PrintStream) ident(errorStream)operator(\)) operator({) - local_variable(super)operator(.)ident(printBacktrace)operator(()ident(errorStream)operator(\))operator(;) - ident(errorStream)operator(.)ident(println)operator(()string<delimiter(")content(Complete Java stackTrace)delimiter(")>operator(\))operator(;) - ident(cause)operator(.)ident(printStackTrace)operator(()ident(errorStream)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Throwable) ident(getCause)operator(()operator(\)) operator({) - keyword(return) ident(cause)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -directive(public) type(interface) class(Profile) operator({) - ident(Profile) ident(ALL) operator(=) keyword(new) ident(Profile)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(allowBuiltin)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowClass)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowModule)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowLoad)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowRequire)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - operator(})operator(;) - ident(Profile) ident(DEBUG_ALLOW) operator(=) keyword(new) ident(Profile)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(allowBuiltin)operator(()pre_type(String) ident(name)operator(\)) operator({) pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(allowBuiltin()delimiter(")>operator(+)ident(name)operator(+)string<delimiter(")content(\))delimiter(")>operator(\))operator(;) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowClass)operator(()pre_type(String) ident(name)operator(\)) operator({) pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(allowClass()delimiter(")>operator(+)ident(name)operator(+)string<delimiter(")content(\))delimiter(")>operator(\))operator(;) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowModule)operator(()pre_type(String) ident(name)operator(\)) operator({) pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(allowModule()delimiter(")>operator(+)ident(name)operator(+)string<delimiter(")content(\))delimiter(")>operator(\))operator(;) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowLoad)operator(()pre_type(String) ident(name)operator(\)) operator({) pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(allowLoad()delimiter(")>operator(+)ident(name)operator(+)string<delimiter(")content(\))delimiter(")>operator(\))operator(;) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowRequire)operator(()pre_type(String) ident(name)operator(\)) operator({) pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(allowRequire()delimiter(")>operator(+)ident(name)operator(+)string<delimiter(")content(\))delimiter(")>operator(\))operator(;) keyword(return) pre_constant(true)operator(;) operator(}) - operator(})operator(;) - ident(Profile) ident(NO_FILE_CLASS) operator(=) keyword(new) ident(Profile)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(allowBuiltin)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowClass)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) operator(!)ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(File)delimiter(")>operator(\))operator(;) operator(}) - directive(public) type(boolean) ident(allowModule)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowLoad)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - directive(public) type(boolean) ident(allowRequire)operator(()pre_type(String) ident(name)operator(\)) operator({) keyword(return) pre_constant(true)operator(;) operator(}) - operator(})operator(;) - ident(Profile) ident(ANY) operator(=) ident(ALL)operator(;) - ident(Profile) ident(DEFAULT) operator(=) ident(ALL)operator(;) - - type(boolean) ident(allowBuiltin)operator(()pre_type(String) ident(name)operator(\))operator(;) - type(boolean) ident(allowClass)operator(()pre_type(String) ident(name)operator(\))operator(;) - type(boolean) ident(allowModule)operator(()pre_type(String) ident(name)operator(\))operator(;) - type(boolean) ident(allowLoad)operator(()pre_type(String) ident(name)operator(\))operator(;) - type(boolean) ident(allowRequire)operator(()pre_type(String) ident(name)operator(\))operator(;) -operator(})comment(// Profile) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2006 Michael Studman <codehaus@michaelstudman.com> - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * Copyright (C\) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.ByteArrayInputStream)operator(;) -keyword(import) include(java.io.File)operator(;) -keyword(import) include(java.io.FileDescriptor)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.PrintStream)operator(;) -keyword(import) include(java.io.UnsupportedEncodingException)operator(;) -keyword(import) include(java.lang.ref.WeakReference)operator(;) -keyword(import) include(java.lang.reflect.Field)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.Collections)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Hashtable)operator(;) -keyword(import) include(java.util.IdentityHashMap)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(java.util.Random)operator(;) -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(java.util.Stack)operator(;) -keyword(import) include(java.util.Vector)operator(;) -keyword(import) include(java.util.WeakHashMap)operator(;) -keyword(import) include(java.util.concurrent.ConcurrentHashMap)operator(;) -keyword(import) include(java.util.concurrent.ExecutorService)operator(;) -keyword(import) include(java.util.concurrent.Executors)operator(;) -keyword(import) include(java.util.concurrent.SynchronousQueue)operator(;) -keyword(import) include(java.util.concurrent.ThreadFactory)operator(;) -keyword(import) include(java.util.concurrent.ThreadPoolExecutor)operator(;) -keyword(import) include(java.util.concurrent.TimeUnit)operator(;) -keyword(import) include(java.util.concurrent.atomic.AtomicInteger)operator(;) - -keyword(import) include(org.joda.time.DateTimeZone)operator(;) -keyword(import) include(org.jruby.ast.Node)operator(;) -keyword(import) include(org.jruby.ast.executable.RubiniusRunner)operator(;) -keyword(import) include(org.jruby.ast.executable.Script)operator(;) -keyword(import) include(org.jruby.ast.executable.YARVCompiledRunner)operator(;) -keyword(import) include(org.jruby.common.RubyWarnings)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.compiler.ASTCompiler)operator(;) -keyword(import) include(org.jruby.compiler.ASTInspector)operator(;) -keyword(import) include(org.jruby.compiler.JITCompiler)operator(;) -keyword(import) include(org.jruby.compiler.NotCompilableException)operator(;) -keyword(import) include(org.jruby.compiler.impl.StandardASMCompiler)operator(;) -keyword(import) include(org.jruby.compiler.yarv.StandardYARVCompiler)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.ext.JRubyPOSIXHandler)operator(;) -keyword(import) include(org.jruby.ext.LateLoadingLibrary)operator(;) -keyword(import) include(org.jruby.ext.posix.POSIX)operator(;) -keyword(import) include(org.jruby.ext.posix.POSIXFactory)operator(;) -keyword(import) include(org.jruby.internal.runtime.GlobalVariables)operator(;) -keyword(import) include(org.jruby.internal.runtime.ThreadService)operator(;) -keyword(import) include(org.jruby.internal.runtime.ValueAccessor)operator(;) -keyword(import) include(org.jruby.javasupport.JavaSupport)operator(;) -keyword(import) include(org.jruby.management.BeanManager)operator(;) -keyword(import) include(org.jruby.management.ClassCache)operator(;) -keyword(import) include(org.jruby.management.Config)operator(;) -keyword(import) include(org.jruby.parser.Parser)operator(;) -keyword(import) include(org.jruby.parser.ParserConfiguration)operator(;) -keyword(import) include(org.jruby.runtime.Binding)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CacheMap)operator(;) -keyword(import) include(org.jruby.runtime.CallSite)operator(;) -keyword(import) include(org.jruby.runtime.CallbackFactory)operator(;) -keyword(import) include(org.jruby.runtime.DynamicScope)operator(;) -keyword(import) include(org.jruby.runtime.EventHook)operator(;) -keyword(import) include(org.jruby.runtime.GlobalVariable)operator(;) -keyword(import) include(org.jruby.runtime.IAccessor)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ObjectSpace)operator(;) -keyword(import) include(org.jruby.runtime.RubyEvent)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.load.Library)operator(;) -keyword(import) include(org.jruby.runtime.load.LoadService)operator(;) -keyword(import) include(org.jruby.util.BuiltinScript)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.IOInputStream)operator(;) -keyword(import) include(org.jruby.util.IOOutputStream)operator(;) -keyword(import) include(org.jruby.util.JRubyClassLoader)operator(;) -keyword(import) include(org.jruby.util.JavaNameMangler)operator(;) -keyword(import) include(org.jruby.util.KCode)operator(;) -keyword(import) include(org.jruby.util.SafePropertyAccessor)operator(;) -keyword(import) include(org.jruby.util.collections.WeakHashSet)operator(;) -keyword(import) include(org.jruby.util.io.ChannelDescriptor)operator(;) - -comment(/** - * The Ruby object represents the top-level of a JRuby "instance" in a given VM. - * JRuby supports spawning multiple instances in the same JVM. Generally, objects - * created under these instances are tied to a given runtime, for such details - * as identity and type, because multiple Ruby instances means there are - * multiple instances of each class. This means that in multi-runtime mode - * (or really, multi-VM mode, where each JRuby instance is a ruby "VM"\), objects - * generally can't be transported across runtimes without marshaling. - * - * This class roots everything that makes the JRuby runtime function, and - * provides a number of utility methods for constructing global types and - * accessing global runtime structures. - */) -directive(public) directive(final) type(class) class(Ruby) operator({) - comment(/** - * Returns a new instance of the JRuby runtime configured with defaults. - * - * @return the JRuby runtime - * @see org.jruby.RubyInstanceConfig - */) - directive(public) directive(static) ident(Ruby) ident(newInstance)operator(()operator(\)) operator({) - keyword(return) ident(newInstance)operator(()keyword(new) ident(RubyInstanceConfig)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Returns a new instance of the JRuby runtime configured as specified. - * - * @param config The instance configuration - * @return The JRuby runtime - * @see org.jruby.RubyInstanceConfig - */) - directive(public) directive(static) ident(Ruby) ident(newInstance)operator(()ident(RubyInstanceConfig) ident(config)operator(\)) operator({) - ident(Ruby) ident(ruby) operator(=) keyword(new) ident(Ruby)operator(()ident(config)operator(\))operator(;) - ident(ruby)operator(.)ident(init)operator(()operator(\))operator(;) - keyword(return) ident(ruby)operator(;) - operator(}) - - comment(/** - * Returns a new instance of the JRuby runtime configured with the given - * input, output and error streams and otherwise default configuration - * (except where specified system properties alter defaults\). - * - * @param in the custom input stream - * @param out the custom output stream - * @param err the custom error stream - * @return the JRuby runtime - * @see org.jruby.RubyInstanceConfig - */) - directive(public) directive(static) ident(Ruby) ident(newInstance)operator(()pre_type(InputStream) ident(in)operator(,) pre_type(PrintStream) ident(out)operator(,) pre_type(PrintStream) ident(err)operator(\)) operator({) - ident(RubyInstanceConfig) ident(config) operator(=) keyword(new) ident(RubyInstanceConfig)operator(()operator(\))operator(;) - ident(config)operator(.)ident(setInput)operator(()ident(in)operator(\))operator(;) - ident(config)operator(.)ident(setOutput)operator(()ident(out)operator(\))operator(;) - ident(config)operator(.)ident(setError)operator(()ident(err)operator(\))operator(;) - keyword(return) ident(newInstance)operator(()ident(config)operator(\))operator(;) - operator(}) - - comment(/** - * Create and initialize a new JRuby runtime. The properties of the - * specified RubyInstanceConfig will be used to determine various JRuby - * runtime characteristics. - * - * @param config The configuration to use for the new instance - * @see org.jruby.RubyInstanceConfig - */) - directive(private) ident(Ruby)operator(()ident(RubyInstanceConfig) ident(config)operator(\)) operator({) - local_variable(this)operator(.)ident(config) operator(=) ident(config)operator(;) - local_variable(this)operator(.)ident(threadService) operator(=) keyword(new) ident(ThreadService)operator(()local_variable(this)operator(\))operator(;) - keyword(if)operator(()ident(config)operator(.)ident(isSamplingEnabled)operator(()operator(\))operator(\)) operator({) - ident(org)operator(.)ident(jruby)operator(.)ident(util)operator(.)ident(SimpleSampler)operator(.)ident(registerThreadContext)operator(()ident(threadService)operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) - - local_variable(this)operator(.)ident(in) operator(=) ident(config)operator(.)ident(getInput)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(out) operator(=) ident(config)operator(.)ident(getOutput)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(err) operator(=) ident(config)operator(.)ident(getError)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(objectSpaceEnabled) operator(=) ident(config)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(profile) operator(=) ident(config)operator(.)ident(getProfile)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(currentDirectory) operator(=) ident(config)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(kcode) operator(=) ident(config)operator(.)ident(getKCode)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(beanManager) operator(=) keyword(new) ident(BeanManager)operator(()local_variable(this)operator(,) ident(config)operator(.)ident(isManagementEnabled)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(jitCompiler) operator(=) keyword(new) ident(JITCompiler)operator(()local_variable(this)operator(\))operator(;) - - local_variable(this)operator(.)ident(beanManager)operator(.)ident(register)operator(()keyword(new) ident(Config)operator(()local_variable(this)operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(beanManager)operator(.)ident(register)operator(()keyword(new) ident(ClassCache)operator(()local_variable(this)operator(\))operator(\))operator(;) - - local_variable(this)operator(.)ident(cacheMap) operator(=) keyword(new) ident(CacheMap)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** - * Evaluates a script under the current scope (perhaps the top-level - * scope\) and returns the result (generally the last value calculated\). - * This version goes straight into the interpreter, bypassing compilation - * and runtime preparation typical to normal script runs. - * - * @param script The scriptlet to run - * @returns The result of the eval - */) - directive(public) ident(IRubyObject) ident(evalScriptlet)operator(()pre_type(String) ident(script)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - ident(Node) ident(node) operator(=) ident(parseEval)operator(()ident(script)operator(,) string<delimiter(")content(<script>)delimiter(")>operator(,) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(,) integer(0)operator(\))operator(;) - - keyword(try) operator({) - keyword(return) ident(node)operator(.)ident(interpret)operator(()local_variable(this)operator(,) ident(context)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(throw) ident(newLocalJumpError)operator(()string<delimiter(")content(return)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(unexpected return)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - keyword(throw) ident(newLocalJumpError)operator(()string<delimiter(")content(break)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(unexpected break)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(RedoJump) ident(rj)operator(\)) operator({) - keyword(throw) ident(newLocalJumpError)operator(()string<delimiter(")content(redo)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(unexpected redo)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Parse and execute the specified script - * This differs from the other methods in that it accepts a string-based script and - * parses and runs it as though it were loaded at a command-line. This is the preferred - * way to start up a new script when calling directly into the Ruby object (which is - * generally *dis*couraged. - * - * @param script The contents of the script to run as a normal, root script - * @return The last value of the script - */) - directive(public) ident(IRubyObject) ident(executeScript)operator(()pre_type(String) ident(script)operator(,) pre_type(String) ident(filename)operator(\)) operator({) - type(byte)type([]) ident(bytes)operator(;) - - keyword(try) operator({) - ident(bytes) operator(=) ident(script)operator(.)ident(getBytes)operator(()ident(KCode)operator(.)ident(NONE)operator(.)ident(getKCode)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedEncodingException) ident(e)operator(\)) operator({) - ident(bytes) operator(=) ident(script)operator(.)ident(getBytes)operator(()operator(\))operator(;) - operator(}) - - ident(Node) ident(node) operator(=) ident(parseInline)operator(()keyword(new) pre_type(ByteArrayInputStream)operator(()ident(bytes)operator(\))operator(,) ident(filename)operator(,) pre_constant(null)operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - pre_type(String) ident(oldFile) operator(=) ident(context)operator(.)ident(getFile)operator(()operator(\))operator(;) - type(int) ident(oldLine) operator(=) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(context)operator(.)ident(setFile)operator(()ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\))operator(\))operator(;) - ident(context)operator(.)ident(setLine)operator(()ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getStartLine)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runNormally)operator(()ident(node)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(setFile)operator(()ident(oldFile)operator(\))operator(;) - ident(context)operator(.)ident(setLine)operator(()ident(oldLine)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Run the script contained in the specified input stream, using the - * specified filename as the name of the script being executed. The stream - * will be read fully before being parsed and executed. The given filename - * will be used for the ruby $PROGRAM_NAME and $0 global variables in this - * runtime. - * - * This method is intended to be called once per runtime, generally from - * Main or from main-like top-level entry points. - * - * As part of executing the script loaded from the input stream, various - * RubyInstanceConfig properties will be used to determine whether to - * compile the script before execution or run with various wrappers (for - * looping, printing, and so on, see jruby -help\). - * - * @param inputStream The InputStream from which to read the script contents - * @param filename The filename to use when parsing, and for $PROGRAM_NAME - * and $0 ruby global variables. - */) - directive(public) type(void) ident(runFromMain)operator(()pre_type(InputStream) ident(inputStream)operator(,) pre_type(String) ident(filename)operator(\)) operator({) - ident(IAccessor) ident(d) operator(=) keyword(new) ident(ValueAccessor)operator(()ident(newString)operator(()ident(filename)operator(\))operator(\))operator(;) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(define)operator(()string<delimiter(")content($PROGRAM_NAME)delimiter(")>operator(,) ident(d)operator(\))operator(;) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(define)operator(()string<delimiter(")content($0)delimiter(")>operator(,) ident(d)operator(\))operator(;) - - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) ident(config)operator(.)ident(getOptionGlobals)operator(()operator(\))operator(.)ident(entrySet)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(Map)operator(.)ident(Entry) ident(entry) operator(=) operator(()pre_type(Map)operator(.)ident(Entry)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - pre_type(Object) ident(value) operator(=) ident(entry)operator(.)ident(getValue)operator(()operator(\))operator(;) - ident(IRubyObject) ident(varvalue)operator(;) - keyword(if) operator(()ident(value) operator(!=) pre_constant(null)operator(\)) operator({) - ident(varvalue) operator(=) ident(newString)operator(()ident(value)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(varvalue) operator(=) ident(getTrue)operator(()operator(\))operator(;) - operator(}) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($)delimiter(")> operator(+) ident(entry)operator(.)ident(getKey)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) ident(varvalue)operator(\))operator(;) - operator(}) - - - keyword(if)operator(()ident(config)operator(.)ident(isYARVEnabled)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isShowBytecode)operator(()operator(\))operator(\)) pre_type(System)operator(.)ident(err)operator(.)ident(print)operator(()string<delimiter(")content(error: bytecode printing only works with JVM bytecode)delimiter(")>operator(\))operator(;) - keyword(new) ident(YARVCompiledRunner)operator(()local_variable(this)operator(,) ident(inputStream)operator(,) ident(filename)operator(\))operator(.)ident(run)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(config)operator(.)ident(isRubiniusEnabled)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isShowBytecode)operator(()operator(\))operator(\)) pre_type(System)operator(.)ident(err)operator(.)ident(print)operator(()string<delimiter(")content(error: bytecode printing only works with JVM bytecode)delimiter(")>operator(\))operator(;) - keyword(new) ident(RubiniusRunner)operator(()local_variable(this)operator(,) ident(inputStream)operator(,) ident(filename)operator(\))operator(.)ident(run)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(Node) ident(scriptNode) operator(=) ident(parseFromMain)operator(()ident(inputStream)operator(,) ident(filename)operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - pre_type(String) ident(oldFile) operator(=) ident(context)operator(.)ident(getFile)operator(()operator(\))operator(;) - type(int) ident(oldLine) operator(=) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(context)operator(.)ident(setFile)operator(()ident(scriptNode)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\))operator(\))operator(;) - ident(context)operator(.)ident(setLine)operator(()ident(scriptNode)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getStartLine)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(isAssumePrinting)operator(()operator(\)) operator(||) ident(config)operator(.)ident(isAssumeLoop)operator(()operator(\))operator(\)) operator({) - ident(runWithGetsLoop)operator(()ident(scriptNode)operator(,) ident(config)operator(.)ident(isAssumePrinting)operator(()operator(\))operator(,) ident(config)operator(.)ident(isProcessLineEnds)operator(()operator(\))operator(,) - ident(config)operator(.)ident(isSplit)operator(()operator(\))operator(,) ident(config)operator(.)ident(isYARVCompileEnabled)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runNormally)operator(()ident(scriptNode)operator(,) ident(config)operator(.)ident(isYARVCompileEnabled)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(setFile)operator(()ident(oldFile)operator(\))operator(;) - ident(context)operator(.)ident(setLine)operator(()ident(oldLine)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** - * Parse the script contained in the given input stream, using the given - * filename as the name of the script, and return the root Node. This - * is used to verify that the script syntax is valid, for jruby -c. The - * current scope (generally the top-level scope\) is used as the parent - * scope for parsing. - * - * @param inputStream The input stream from which to read the script - * @param filename The filename to use for parsing - * @returns The root node of the parsed script - */) - directive(public) ident(Node) ident(parseFromMain)operator(()pre_type(InputStream) ident(inputStream)operator(,) pre_type(String) ident(filename)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isInlineScript)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(parseInline)operator(()ident(inputStream)operator(,) ident(filename)operator(,) ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentScope)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(parseFile)operator(()ident(inputStream)operator(,) ident(filename)operator(,) ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentScope)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Run the given script with a "while gets; end" loop wrapped around it. - * This is primarily used for the -n command-line flag, to allow writing - * a short script that processes input lines using the specified code. - * - * @param scriptNode The root node of the script to execute - * @param printing Whether $_ should be printed after each loop (as in the - * -p command-line flag\) - * @param processLineEnds Whether line endings should be processed by - * setting $\\ to $/ and <code>chop!</code>ing every line read - * @param split Whether to split each line read using <code>String#split</code> - * @param yarvCompile Whether to compile the target script to YARV (Ruby 1.9\) - * bytecode before executing. - * @return The result of executing the specified script - */) - directive(public) ident(IRubyObject) ident(runWithGetsLoop)operator(()ident(Node) ident(scriptNode)operator(,) type(boolean) ident(printing)operator(,) type(boolean) ident(processLineEnds)operator(,) type(boolean) ident(split)operator(,) type(boolean) ident(yarvCompile)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - ident(Script) ident(script) operator(=) pre_constant(null)operator(;) - ident(YARVCompiledRunner) ident(runner) operator(=) pre_constant(null)operator(;) - type(boolean) ident(compile) operator(=) ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompileMode)operator(()operator(\))operator(.)ident(shouldPrecompileCLI)operator(()operator(\))operator(;) - keyword(if) operator(()ident(compile) operator(||) operator(!)ident(yarvCompile)operator(\)) operator({) - ident(script) operator(=) ident(tryCompile)operator(()ident(scriptNode)operator(\))operator(;) - keyword(if) operator(()ident(compile) operator(&&) ident(script) operator(==) pre_constant(null)operator(\)) operator({) - comment(// terminate; tryCompile will have printed out an error and we're done) - keyword(return) ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(yarvCompile)operator(\)) operator({) - ident(runner) operator(=) ident(tryCompileYarv)operator(()ident(scriptNode)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(processLineEnds)operator(\)) operator({) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($)char(\\\\)delimiter(")>operator(,) ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(while) operator(()ident(RubyKernel)operator(.)ident(gets)operator(()ident(context)operator(,) ident(getTopSelf)operator(()operator(\))operator(,) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(loop)operator(:) keyword(while) operator(()pre_constant(true)operator(\)) operator({) comment(// Used for the 'redo' command) - keyword(try) operator({) - keyword(if) operator(()ident(processLineEnds)operator(\)) operator({) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($_)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(chop!)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(split)operator(\)) operator({) - ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($F)delimiter(")>operator(,) ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($_)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(split)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(script) operator(!=) pre_constant(null)operator(\)) operator({) - ident(runScript)operator(()ident(script)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(runner) operator(!=) pre_constant(null)operator(\)) operator({) - ident(runYarv)operator(()ident(runner)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runInterpreter)operator(()ident(scriptNode)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(printing)operator(\)) ident(RubyKernel)operator(.)ident(print)operator(()ident(context)operator(,) ident(getKernel)operator(()operator(\))operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($_)delimiter(")>operator(\))operator(})operator(\))operator(;) - keyword(break) ident(loop)operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(RedoJump) ident(rj)operator(\)) operator({) - comment(// do nothing, this iteration restarts) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(NextJump) ident(nj)operator(\)) operator({) - comment(// recheck condition) - keyword(break) ident(loop)operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - comment(// end loop) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - keyword(return) ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Run the specified script without any of the loop-processing wrapper - * code. - * - * @param scriptNode The root node of the script to be executed - * @param yarvCompile Whether to compile the script to YARV (Ruby 1.9\) - * bytecode before execution - * @return The result of executing the script - */) - directive(public) ident(IRubyObject) ident(runNormally)operator(()ident(Node) ident(scriptNode)operator(,) type(boolean) ident(yarvCompile)operator(\)) operator({) - ident(Script) ident(script) operator(=) pre_constant(null)operator(;) - ident(YARVCompiledRunner) ident(runner) operator(=) pre_constant(null)operator(;) - type(boolean) ident(compile) operator(=) ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompileMode)operator(()operator(\))operator(.)ident(shouldPrecompileCLI)operator(()operator(\))operator(;) - type(boolean) ident(forceCompile) operator(=) ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompileMode)operator(()operator(\))operator(.)ident(shouldPrecompileAll)operator(()operator(\))operator(;) - keyword(if) operator(()ident(yarvCompile)operator(\)) operator({) - ident(runner) operator(=) ident(tryCompileYarv)operator(()ident(scriptNode)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(compile)operator(\)) operator({) - ident(script) operator(=) ident(tryCompile)operator(()ident(scriptNode)operator(\))operator(;) - keyword(if) operator(()ident(forceCompile) operator(&&) ident(script) operator(==) pre_constant(null)operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error, could not compile; pass -J-Djruby.jit.logging.verbose=true for more details)delimiter(")>operator(\))operator(;) - keyword(return) ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(script) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isShowBytecode)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(nilObject)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runScript)operator(()ident(script)operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(runner) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(runYarv)operator(()ident(runner)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isShowBytecode)operator(()operator(\))operator(\)) pre_type(System)operator(.)ident(err)operator(.)ident(print)operator(()string<delimiter(")content(error: bytecode printing only works with JVM bytecode)delimiter(")>operator(\))operator(;) - keyword(return) ident(runInterpreter)operator(()ident(scriptNode)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(Script) ident(tryCompile)operator(()ident(Node) ident(node)operator(\)) operator({) - keyword(return) ident(tryCompile)operator(()ident(node)operator(,) keyword(new) ident(JRubyClassLoader)operator(()ident(getJRubyClassLoader)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(Script) ident(tryCompile)operator(()ident(Node) ident(node)operator(,) ident(JRubyClassLoader) ident(classLoader)operator(\)) operator({) - ident(Script) ident(script) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - pre_type(String) ident(filename) operator(=) ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\))operator(;) - pre_type(String) ident(classname) operator(=) ident(JavaNameMangler)operator(.)ident(mangledFilenameForStartupClasspath)operator(()ident(filename)operator(\))operator(;) - - ident(ASTInspector) ident(inspector) operator(=) keyword(new) ident(ASTInspector)operator(()operator(\))operator(;) - ident(inspector)operator(.)ident(inspect)operator(()ident(node)operator(\))operator(;) - - ident(StandardASMCompiler) ident(asmCompiler) operator(=) keyword(new) ident(StandardASMCompiler)operator(()ident(classname)operator(,) ident(filename)operator(\))operator(;) - ident(ASTCompiler) ident(compiler) operator(=) keyword(new) ident(ASTCompiler)operator(()operator(\))operator(;) - keyword(if) operator(()ident(config)operator(.)ident(isShowBytecode)operator(()operator(\))operator(\)) operator({) - ident(compiler)operator(.)ident(compileRoot)operator(()ident(node)operator(,) ident(asmCompiler)operator(,) ident(inspector)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(\))operator(;) - ident(asmCompiler)operator(.)ident(dumpClass)operator(()pre_type(System)operator(.)ident(out)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(compiler)operator(.)ident(compileRoot)operator(()ident(node)operator(,) ident(asmCompiler)operator(,) ident(inspector)operator(,) pre_constant(true)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - ident(script) operator(=) operator(()ident(Script)operator(\))ident(asmCompiler)operator(.)ident(loadClass)operator(()ident(classLoader)operator(\))operator(.)ident(newInstance)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(config)operator(.)ident(isJitLogging)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(compiled: )delimiter(")> operator(+) ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(NotCompilableException) ident(nce)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isJitLoggingVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error -- Not compileable: )delimiter(")> operator(+) ident(nce)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - ident(nce)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(ClassNotFoundException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isJitLoggingVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error -- Not compileable: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - ident(e)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(InstantiationException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isJitLoggingVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error -- Not compileable: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - ident(e)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(IllegalAccessException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isJitLoggingVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error -- Not compileable: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - ident(e)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()pre_type(Throwable) ident(t)operator(\)) operator({) - keyword(if) operator(()ident(config)operator(.)ident(isJitLoggingVerbose)operator(()operator(\))operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(could not compile: )delimiter(")> operator(+) ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\)) operator(+) string<delimiter(")content( because of: )char(\\")delimiter(")> operator(+) ident(t)operator(.)ident(getMessage)operator(()operator(\)) operator(+) string<delimiter(")char(\\")delimiter(")>operator(\))operator(;) - ident(t)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(script)operator(;) - operator(}) - - directive(private) ident(YARVCompiledRunner) ident(tryCompileYarv)operator(()ident(Node) ident(node)operator(\)) operator({) - keyword(try) operator({) - ident(StandardYARVCompiler) ident(compiler) operator(=) keyword(new) ident(StandardYARVCompiler)operator(()local_variable(this)operator(\))operator(;) - ident(ASTCompiler)operator(.)ident(getYARVCompiler)operator(()operator(\))operator(.)ident(compile)operator(()ident(node)operator(,) ident(compiler)operator(\))operator(;) - ident(org)operator(.)ident(jruby)operator(.)ident(lexer)operator(.)ident(yacc)operator(.)ident(ISourcePosition) ident(p) operator(=) ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(;) - keyword(if)operator(()ident(p) operator(==) pre_constant(null) operator(&&) ident(node) keyword(instanceof) ident(org)operator(.)ident(jruby)operator(.)ident(ast)operator(.)ident(RootNode)operator(\)) operator({) - ident(p) operator(=) operator(()operator(()ident(org)operator(.)ident(jruby)operator(.)ident(ast)operator(.)ident(RootNode)operator(\))ident(node)operator(\))operator(.)ident(getBodyNode)operator(()operator(\))operator(.)ident(getPosition)operator(()operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(YARVCompiledRunner)operator(()local_variable(this)operator(,)ident(compiler)operator(.)ident(getInstructionSequence)operator(()string<delimiter(")content(<main>)delimiter(")>operator(,)ident(p)operator(.)ident(getFile)operator(()operator(\))operator(,)string<delimiter(")content(toplevel)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(NotCompilableException) ident(nce)operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error -- Not compileable: )delimiter(")> operator(+) ident(nce)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(runScript)operator(()ident(Script) ident(script)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(try) operator({) - keyword(return) ident(script)operator(.)ident(load)operator(()ident(context)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(runYarv)operator(()ident(YARVCompiledRunner) ident(runner)operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(runner)operator(.)ident(run)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(runInterpreter)operator(()ident(Node) ident(scriptNode)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(assert) ident(scriptNode) operator(!=) pre_constant(null) operator(:) string<delimiter(")content(scriptNode is not null)delimiter(")>operator(;) - - keyword(try) operator({) - keyword(return) ident(scriptNode)operator(.)ident(interpret)operator(()local_variable(this)operator(,) ident(context)operator(,) ident(getTopSelf)operator(()operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(BeanManager) ident(getBeanManager)operator(()operator(\)) operator({) - keyword(return) ident(beanManager)operator(;) - operator(}) - - directive(public) ident(JITCompiler) ident(getJITCompiler)operator(()operator(\)) operator({) - keyword(return) ident(jitCompiler)operator(;) - operator(}) - - comment(/** - * @deprecated use #newInstance(\) - */) - directive(public) directive(static) ident(Ruby) ident(getDefaultInstance)operator(()operator(\)) operator({) - keyword(return) ident(newInstance)operator(()operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) ident(Ruby) ident(getCurrentInstance)operator(()operator(\)) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) type(void) ident(setCurrentInstance)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - operator(}) - - directive(public) type(int) ident(allocSymbolId)operator(()operator(\)) operator({) - keyword(return) ident(symbolLastId)operator(.)ident(incrementAndGet)operator(()operator(\))operator(;) - operator(}) - directive(public) type(int) ident(allocModuleId)operator(()operator(\)) operator({) - keyword(return) ident(moduleLastId)operator(.)ident(incrementAndGet)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the module with the given name from the Object namespace. - * - * @param name The name of the module - * @return The module or null if not found - */) - directive(public) ident(RubyModule) ident(getModule)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) operator(()ident(RubyModule)operator(\)) ident(objectClass)operator(.)ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the module with the given name from the Object namespace. The - * module name must be an interned string, but this method will be faster - * than the non-interned version. - * - * @param internedName The name of the module; <em>must</em> be an interned String - * @return The module or null if not found - */) - directive(public) ident(RubyModule) ident(fastGetModule)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) operator(()ident(RubyModule)operator(\)) ident(objectClass)operator(.)ident(fastGetConstantAt)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the class with the given name from the Object namespace. - * - * @param name The name of the class - * @return The class - */) - directive(public) ident(RubyClass) ident(getClass)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(objectClass)operator(.)ident(getClass)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the class with the given name from the Object namespace. The - * module name must be an interned string, but this method will be faster - * than the non-interned version. - * - * @param internedName the name of the class; <em>must</em> be an interned String! - * @return - */) - directive(public) ident(RubyClass) ident(fastGetClass)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(return) ident(objectClass)operator(.)ident(fastGetClass)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * Define a new class under the Object namespace. Roughly equivalent to - * rb_define_class in MRI. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @return The new class - */) - directive(public) ident(RubyClass) ident(defineClass)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(\)) operator({) - keyword(return) ident(defineClassUnder)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(allocator)operator(,) ident(objectClass)operator(\))operator(;) - operator(}) - - comment(/** - * A variation of defineClass that allows passing in an array of subplementary - * call sites for improving dynamic invocation performance. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @return The new class - */) - directive(public) ident(RubyClass) ident(defineClass)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(,) ident(CallSite)type([]) ident(callSites)operator(\)) operator({) - keyword(return) ident(defineClassUnder)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(allocator)operator(,) ident(objectClass)operator(,) ident(callSites)operator(\))operator(;) - operator(}) - - comment(/** - * Define a new class with the given name under the given module or class - * namespace. Roughly equivalent to rb_define_class_under in MRI. - * - * If the name specified is already bound, its value will be returned if: - * * It is a class - * * No new superclass is being defined - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @param parent The namespace under which to define the new class - * @return The new class - */) - directive(public) ident(RubyClass) ident(defineClassUnder)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(,) ident(RubyModule) ident(parent)operator(\)) operator({) - keyword(return) ident(defineClassUnder)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(allocator)operator(,) ident(parent)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - comment(/** - * A variation of defineClassUnder that allows passing in an array of - * supplementary call sites to improve dynamic invocation. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @param parent The namespace under which to define the new class - * @param callSites The array of call sites to add - * @return The new class - */) - directive(public) ident(RubyClass) ident(defineClassUnder)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(,) ident(RubyModule) ident(parent)operator(,) ident(CallSite)type([]) ident(callSites)operator(\)) operator({) - ident(IRubyObject) ident(classObj) operator(=) ident(parent)operator(.)ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - - keyword(if) operator(()ident(classObj) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(classObj) keyword(instanceof) ident(RubyClass)operator(\))operator(\)) keyword(throw) ident(newTypeError)operator(()ident(name) operator(+) string<delimiter(")content( is not a class)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(klazz) operator(=) operator(()ident(RubyClass)operator(\))ident(classObj)operator(;) - keyword(if) operator(()ident(klazz)operator(.)ident(getSuperClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(superClass)operator(\)) operator({) - keyword(throw) ident(newNameError)operator(()ident(name) operator(+) string<delimiter(")content( is already defined)delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - comment(// If we define a class in Ruby, but later want to allow it to be defined in Java,) - comment(// the allocator needs to be updated) - keyword(if) operator(()ident(klazz)operator(.)ident(getAllocator)operator(()operator(\)) operator(!=) ident(allocator)operator(\)) operator({) - ident(klazz)operator(.)ident(setAllocator)operator(()ident(allocator)operator(\))operator(;) - operator(}) - keyword(return) ident(klazz)operator(;) - operator(}) - - type(boolean) ident(parentIsObject) operator(=) ident(parent) operator(==) ident(objectClass)operator(;) - - keyword(if) operator(()ident(superClass) operator(==) pre_constant(null)operator(\)) operator({) - pre_type(String) ident(className) operator(=) ident(parentIsObject) operator(?) ident(name) operator(:) ident(parent)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(;) - ident(warnings)operator(.)ident(warn)operator(()ident(ID)operator(.)ident(NO_SUPER_CLASS)operator(,) string<delimiter(")content(no super class for `)delimiter(")> operator(+) ident(className) operator(+) string<delimiter(")content(', Object assumed)delimiter(")>operator(,) ident(className)operator(\))operator(;) - - ident(superClass) operator(=) ident(objectClass)operator(;) - operator(}) - - keyword(return) ident(RubyClass)operator(.)ident(newClass)operator(()local_variable(this)operator(,) ident(superClass)operator(,) ident(name)operator(,) ident(allocator)operator(,) ident(parent)operator(,) operator(!)ident(parentIsObject)operator(,) ident(callSites)operator(\))operator(;) - operator(}) - - comment(/** - * Define a new module under the Object namespace. Roughly equivalent to - * rb_define_module in MRI. - * - * @param name The name of the new module - * @returns The new module - */) - directive(public) ident(RubyModule) ident(defineModule)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(defineModuleUnder)operator(()ident(name)operator(,) ident(objectClass)operator(\))operator(;) - operator(}) - - comment(/** - * Define a new module with the given name under the given module or - * class namespace. Roughly equivalent to rb_define_module_under in MRI. - * - * @param name The name of the new module - * @param parent The class or module namespace under which to define the - * module - * @returns The new module - */) - directive(public) ident(RubyModule) ident(defineModuleUnder)operator(()pre_type(String) ident(name)operator(,) ident(RubyModule) ident(parent)operator(\)) operator({) - ident(IRubyObject) ident(moduleObj) operator(=) ident(parent)operator(.)ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - - type(boolean) ident(parentIsObject) operator(=) ident(parent) operator(==) ident(objectClass)operator(;) - - keyword(if) operator(()ident(moduleObj) operator(!=) pre_constant(null) operator(\)) operator({) - keyword(if) operator(()ident(moduleObj)operator(.)ident(isModule)operator(()operator(\))operator(\)) keyword(return) operator(()ident(RubyModule)operator(\))ident(moduleObj)operator(;) - - keyword(if) operator(()ident(parentIsObject)operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(()ident(moduleObj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( is not a module)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(newTypeError)operator(()ident(parent)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(moduleObj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( is not a module)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(RubyModule)operator(.)ident(newModule)operator(()local_variable(this)operator(,) ident(name)operator(,) ident(parent)operator(,) operator(!)ident(parentIsObject)operator(\))operator(;) - operator(}) - - comment(/** - * From Object, retrieve the named module. If it doesn't exist a - * new module is created. - * - * @param name The name of the module - * @returns The existing or new module - */) - directive(public) ident(RubyModule) ident(getOrCreateModule)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(IRubyObject) ident(module) operator(=) ident(objectClass)operator(.)ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(module) operator(==) pre_constant(null)operator(\)) operator({) - ident(module) operator(=) ident(defineModule)operator(()ident(name)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) operator({) - keyword(throw) ident(newSecurityError)operator(()string<delimiter(")content(Extending module prohibited.)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)ident(module)operator(.)ident(isModule)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(()ident(name) operator(+) string<delimiter(")content( is not a Module)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()ident(RubyModule)operator(\)) ident(module)operator(;) - operator(}) - - - comment(/** - * Retrieve the current safe level. - * - * @see org.jruby.Ruby#setSaveLevel - */) - directive(public) type(int) ident(getSafeLevel)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(safeLevel)operator(;) - operator(}) - - - comment(/** - * Set the current safe level: - * - * 0 - strings from streams/environment/ARGV are tainted (default\) - * 1 - no dangerous operation by tainted value - * 2 - process/file operations prohibited - * 3 - all generated objects are tainted - * 4 - no global (non-tainted\) variable modification/no direct output - * - * The safe level is set using $SAFE in Ruby code. It is not particularly - * well supported in JRuby. - */) - directive(public) type(void) ident(setSafeLevel)operator(()type(int) ident(safeLevel)operator(\)) operator({) - local_variable(this)operator(.)ident(safeLevel) operator(=) ident(safeLevel)operator(;) - operator(}) - - directive(public) ident(KCode) ident(getKCode)operator(()operator(\)) operator({) - keyword(return) ident(kcode)operator(;) - operator(}) - - directive(public) type(void) ident(setKCode)operator(()ident(KCode) ident(kcode)operator(\)) operator({) - local_variable(this)operator(.)ident(kcode) operator(=) ident(kcode)operator(;) - operator(}) - - directive(public) type(void) ident(secure)operator(()type(int) ident(level)operator(\)) operator({) - keyword(if) operator(()ident(level) operator(<=) ident(safeLevel)operator(\)) operator({) - keyword(throw) ident(newSecurityError)operator(()string<delimiter(")content(Insecure operation ')delimiter(")> operator(+) ident(getCurrentContext)operator(()operator(\))operator(.)ident(getFrameName)operator(()operator(\)) operator(+) string<delimiter(")content(' at level )delimiter(")> operator(+) ident(safeLevel)operator(\))operator(;) - operator(}) - operator(}) - - comment(// FIXME moved this here to get what's obviously a utility method out of IRubyObject.) - comment(// perhaps security methods should find their own centralized home at some point.) - directive(public) type(void) ident(checkSafeString)operator(()ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(if) operator(()ident(getSafeLevel)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(object)operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(ThreadContext) ident(tc) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(if) operator(()ident(tc)operator(.)ident(getFrameName)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(newSecurityError)operator(()string<delimiter(")content(Insecure operation - )delimiter(")> operator(+) ident(tc)operator(.)ident(getFrameName)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(throw) ident(newSecurityError)operator(()string<delimiter(")content(Insecure operation: -r)delimiter(")>operator(\))operator(;) - operator(}) - ident(secure)operator(()integer(4)operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(object) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(() - string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(object)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( (expected String\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_define_global_const - * - */) - directive(public) type(void) ident(defineGlobalConstant)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(objectClass)operator(.)ident(defineConstant)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(isClassDefined)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(getModule)operator(()ident(name)operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - - comment(/** - * A ThreadFactory for when we're using pooled threads; we want to create - * the threads with daemon = true so they don't keep us from shutting down. - */) - directive(public) directive(static) type(class) class(DaemonThreadFactory) directive(implements) pre_type(ThreadFactory) operator({) - directive(public) pre_type(Thread) ident(newThread)operator(()pre_type(Runnable) ident(runnable)operator(\)) operator({) - pre_type(Thread) ident(thread) operator(=) keyword(new) pre_type(Thread)operator(()ident(runnable)operator(\))operator(;) - ident(thread)operator(.)ident(setDaemon)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(thread)operator(;) - operator(}) - operator(}) - - comment(/** - * This method is called immediately after constructing the Ruby instance. - * The main thread is prepared for execution, all core classes and libraries - * are initialized, and any libraries required on the command line are - * loaded. - */) - directive(private) type(void) ident(init)operator(()operator(\)) operator({) - comment(// Get the main threadcontext (gets constructed for us\)) - ident(ThreadContext) ident(tc) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - ident(safeLevel) operator(=) ident(config)operator(.)ident(getSafeLevel)operator(()operator(\))operator(;) - - comment(// Construct key services) - ident(loadService) operator(=) ident(config)operator(.)ident(createLoadService)operator(()local_variable(this)operator(\))operator(;) - ident(posix) operator(=) ident(POSIXFactory)operator(.)ident(getPOSIX)operator(()keyword(new) ident(JRubyPOSIXHandler)operator(()local_variable(this)operator(\))operator(,) ident(RubyInstanceConfig)operator(.)ident(nativeEnabled)operator(\))operator(;) - ident(javaSupport) operator(=) keyword(new) ident(JavaSupport)operator(()local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(RubyInstanceConfig)operator(.)ident(POOLING_ENABLED)operator(\)) operator({) - pre_type(Executors)operator(.)ident(newCachedThreadPool)operator(()operator(\))operator(;) - ident(executor) operator(=) keyword(new) pre_type(ThreadPoolExecutor)operator(() - ident(RubyInstanceConfig)operator(.)ident(POOL_MIN)operator(,) - ident(RubyInstanceConfig)operator(.)ident(POOL_MAX)operator(,) - ident(RubyInstanceConfig)operator(.)ident(POOL_TTL)operator(,) - pre_type(TimeUnit)operator(.)ident(SECONDS)operator(,) - keyword(new) pre_type(SynchronousQueue)operator(<)pre_type(Runnable)operator(>)operator(()operator(\))operator(,) - keyword(new) ident(DaemonThreadFactory)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// initialize the root of the class hierarchy completely) - ident(initRoot)operator(()ident(tc)operator(\))operator(;) - - comment(// Construct the top-level execution frame and scope for the main thread) - ident(tc)operator(.)ident(prepareTopLevel)operator(()ident(objectClass)operator(,) ident(topSelf)operator(\))operator(;) - - comment(// Initialize all the core classes) - ident(bootstrap)operator(()operator(\))operator(;) - - comment(// Create global constants and variables) - ident(RubyGlobal)operator(.)ident(createGlobals)operator(()ident(tc)operator(,) local_variable(this)operator(\))operator(;) - - comment(// Prepare LoadService and load path) - ident(getLoadService)operator(()operator(\))operator(.)ident(init)operator(()ident(config)operator(.)ident(loadPaths)operator(()operator(\))operator(\))operator(;) - - comment(// initialize builtin libraries) - ident(initBuiltins)operator(()operator(\))operator(;) - - comment(// Require in all libraries specified on command line) - keyword(for) operator(()pre_type(String) ident(scriptName) operator(:) ident(config)operator(.)ident(requiredLibraries)operator(()operator(\))operator(\)) operator({) - ident(RubyKernel)operator(.)ident(require)operator(()ident(getTopSelf)operator(()operator(\))operator(,) ident(newString)operator(()ident(scriptName)operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(bootstrap)operator(()operator(\)) operator({) - ident(initCore)operator(()operator(\))operator(;) - ident(initExceptions)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(initRoot)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - comment(// Bootstrap the top of the hierarchy) - ident(objectClass) operator(=) ident(RubyClass)operator(.)ident(createBootstrapClass)operator(()local_variable(this)operator(,) string<delimiter(")content(Object)delimiter(")>operator(,) pre_constant(null)operator(,) ident(RubyObject)operator(.)ident(OBJECT_ALLOCATOR)operator(\))operator(;) - ident(moduleClass) operator(=) ident(RubyClass)operator(.)ident(createBootstrapClass)operator(()local_variable(this)operator(,) string<delimiter(")content(Module)delimiter(")>operator(,) ident(objectClass)operator(,) ident(RubyModule)operator(.)ident(MODULE_ALLOCATOR)operator(\))operator(;) - ident(classClass) operator(=) ident(RubyClass)operator(.)ident(createBootstrapClass)operator(()local_variable(this)operator(,) string<delimiter(")content(Class)delimiter(")>operator(,) ident(moduleClass)operator(,) ident(RubyClass)operator(.)ident(CLASS_ALLOCATOR)operator(\))operator(;) - - ident(objectClass)operator(.)ident(setMetaClass)operator(()ident(classClass)operator(\))operator(;) - ident(moduleClass)operator(.)ident(setMetaClass)operator(()ident(classClass)operator(\))operator(;) - ident(classClass)operator(.)ident(setMetaClass)operator(()ident(classClass)operator(\))operator(;) - - ident(RubyClass) ident(metaClass)operator(;) - ident(metaClass) operator(=) ident(objectClass)operator(.)ident(makeMetaClass)operator(()ident(classClass)operator(\))operator(;) - ident(metaClass) operator(=) ident(moduleClass)operator(.)ident(makeMetaClass)operator(()ident(metaClass)operator(\))operator(;) - ident(metaClass) operator(=) ident(classClass)operator(.)ident(makeMetaClass)operator(()ident(metaClass)operator(\))operator(;) - - ident(RubyObject)operator(.)ident(createObjectClass)operator(()local_variable(this)operator(,) ident(objectClass)operator(\))operator(;) - ident(RubyModule)operator(.)ident(createModuleClass)operator(()local_variable(this)operator(,) ident(moduleClass)operator(\))operator(;) - ident(RubyClass)operator(.)ident(createClassClass)operator(()local_variable(this)operator(,) ident(classClass)operator(\))operator(;) - - comment(// set constants now that they're initialized) - ident(objectClass)operator(.)ident(setConstant)operator(()string<delimiter(")content(Object)delimiter(")>operator(,) ident(objectClass)operator(\))operator(;) - ident(objectClass)operator(.)ident(setConstant)operator(()string<delimiter(")content(Class)delimiter(")>operator(,) ident(classClass)operator(\))operator(;) - ident(objectClass)operator(.)ident(setConstant)operator(()string<delimiter(")content(Module)delimiter(")>operator(,) ident(moduleClass)operator(\))operator(;) - - comment(// Initialize Kernel and include into Object) - ident(RubyKernel)operator(.)ident(createKernelModule)operator(()local_variable(this)operator(\))operator(;) - ident(objectClass)operator(.)ident(includeModule)operator(()ident(kernelModule)operator(\))operator(;) - - comment(// Initialize the "dummy" class used as a marker) - ident(dummyClass) operator(=) keyword(new) ident(RubyClass)operator(()local_variable(this)operator(\))operator(;) - ident(dummyClass)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - - comment(// Object is ready, create top self) - ident(topSelf) operator(=) ident(TopSelfFactory)operator(.)ident(createTopSelf)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(initCore)operator(()operator(\)) operator({) - comment(// Pre-create all the core classes potentially referenced during startup) - ident(RubyNil)operator(.)ident(createNilClass)operator(()local_variable(this)operator(\))operator(;) - ident(RubyBoolean)operator(.)ident(createFalseClass)operator(()local_variable(this)operator(\))operator(;) - ident(RubyBoolean)operator(.)ident(createTrueClass)operator(()local_variable(this)operator(\))operator(;) - - ident(nilObject) operator(=) keyword(new) ident(RubyNil)operator(()local_variable(this)operator(\))operator(;) - ident(falseObject) operator(=) keyword(new) ident(RubyBoolean)operator(()local_variable(this)operator(,) pre_constant(false)operator(\))operator(;) - ident(trueObject) operator(=) keyword(new) ident(RubyBoolean)operator(()local_variable(this)operator(,) pre_constant(true)operator(\))operator(;) - - ident(RubyComparable)operator(.)ident(createComparable)operator(()local_variable(this)operator(\))operator(;) - ident(RubyEnumerable)operator(.)ident(createEnumerableModule)operator(()local_variable(this)operator(\))operator(;) - ident(RubyString)operator(.)ident(createStringClass)operator(()local_variable(this)operator(\))operator(;) - ident(RubySymbol)operator(.)ident(createSymbolClass)operator(()local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(ThreadGroup)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyThreadGroup)operator(.)ident(createThreadGroupClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Thread)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyThread)operator(.)ident(createThreadClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Exception)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyException)operator(.)ident(createExceptionClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Precision)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyPrecision)operator(.)ident(createPrecisionModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Numeric)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyNumeric)operator(.)ident(createNumericClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Integer)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyInteger)operator(.)ident(createIntegerClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Fixnum)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyFixnum)operator(.)ident(createFixnumClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(config)operator(.)ident(getCompatVersion)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) operator({) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Complex)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyComplex)operator(.)ident(createComplexClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Rational)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyRational)operator(.)ident(createRationalClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Hash)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyHash)operator(.)ident(createHashClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Array)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyArray)operator(.)ident(createArrayClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Float)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyFloat)operator(.)ident(createFloatClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Bignum)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyBignum)operator(.)ident(createBignumClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - ident(ioClass) operator(=) ident(RubyIO)operator(.)ident(createIOClass)operator(()local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Struct)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyStruct)operator(.)ident(createStructClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Tms)delimiter(")>operator(\))operator(\)) operator({) - ident(tmsStruct) operator(=) ident(RubyStruct)operator(.)ident(newInstance)operator(()ident(structClass)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(newString)operator(()string<delimiter(")content(Tms)delimiter(")>operator(\))operator(,) ident(newSymbol)operator(()string<delimiter(")content(utime)delimiter(")>operator(\))operator(,) ident(newSymbol)operator(()string<delimiter(")content(stime)delimiter(")>operator(\))operator(,) ident(newSymbol)operator(()string<delimiter(")content(cutime)delimiter(")>operator(\))operator(,) ident(newSymbol)operator(()string<delimiter(")content(cstime)delimiter(")>operator(\))operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Binding)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyBinding)operator(.)ident(createBindingClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - comment(// Math depends on all numeric types) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Math)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyMath)operator(.)ident(createMathModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Regexp)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyRegexp)operator(.)ident(createRegexpClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Range)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyRange)operator(.)ident(createRangeClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(ObjectSpace)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyObjectSpace)operator(.)ident(createObjectSpaceModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(GC)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyGC)operator(.)ident(createGCModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Proc)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyProc)operator(.)ident(createProcClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Method)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyMethod)operator(.)ident(createMethodClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(MatchData)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyMatchData)operator(.)ident(createMatchDataClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Marshal)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyMarshal)operator(.)ident(createMarshalModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Dir)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyDir)operator(.)ident(createDirClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(FileTest)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyFileTest)operator(.)ident(createFileTestModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - comment(// depends on IO, FileTest) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(File)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyFile)operator(.)ident(createFileClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(File::Stat)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyFileStat)operator(.)ident(createFileStatClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Process)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyProcess)operator(.)ident(createProcessModule)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Time)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyTime)operator(.)ident(createTimeClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(UnboundMethod)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyUnboundMethod)operator(.)ident(defineUnboundMethodClass)operator(()local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Data)delimiter(")>operator(\))operator(\)) operator({) - ident(defineClass)operator(()string<delimiter(")content(Data)delimiter(")>operator(,) ident(objectClass)operator(,) ident(objectClass)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(isSecurityRestricted)operator(()operator(\))operator(\)) operator({) - comment(// Signal uses sun.misc.* classes, this is not allowed) - comment(// in the security-sensitive environments) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Signal)delimiter(")>operator(\))operator(\)) operator({) - ident(RubySignal)operator(.)ident(createSignal)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(Continuation)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyContinuation)operator(.)ident(createContinuation)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(initExceptions)operator(()operator(\)) operator({) - ident(standardError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(StandardError)delimiter(")>operator(,) ident(exceptionClass)operator(\))operator(;) - ident(runtimeError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(RuntimeError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(ioError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(IOError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(scriptError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(ScriptError)delimiter(")>operator(,) ident(exceptionClass)operator(\))operator(;) - ident(rangeError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(RangeError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(signalException) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(SignalException)delimiter(")>operator(,) ident(exceptionClass)operator(\))operator(;) - - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(NameError)delimiter(")>operator(\))operator(\)) operator({) - ident(nameError) operator(=) ident(RubyNameError)operator(.)ident(createNameErrorClass)operator(()local_variable(this)operator(,) ident(standardError)operator(\))operator(;) - ident(nameErrorMessage) operator(=) ident(RubyNameError)operator(.)ident(createNameErrorMessageClass)operator(()local_variable(this)operator(,) ident(nameError)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(NoMethodError)delimiter(")>operator(\))operator(\)) operator({) - ident(noMethodError) operator(=) ident(RubyNoMethodError)operator(.)ident(createNoMethodErrorClass)operator(()local_variable(this)operator(,) ident(nameError)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(SystemExit)delimiter(")>operator(\))operator(\)) operator({) - ident(systemExit) operator(=) ident(RubySystemExit)operator(.)ident(createSystemExitClass)operator(()local_variable(this)operator(,) ident(exceptionClass)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(LocalJumpError)delimiter(")>operator(\))operator(\)) operator({) - ident(localJumpError) operator(=) ident(RubyLocalJumpError)operator(.)ident(createLocalJumpErrorClass)operator(()local_variable(this)operator(,) ident(standardError)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(NativeException)delimiter(")>operator(\))operator(\)) operator({) - ident(nativeException) operator(=) ident(NativeException)operator(.)ident(createClass)operator(()local_variable(this)operator(,) ident(runtimeError)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(profile)operator(.)ident(allowClass)operator(()string<delimiter(")content(SystemCallError)delimiter(")>operator(\))operator(\)) operator({) - ident(systemCallError) operator(=) ident(RubySystemCallError)operator(.)ident(createSystemCallErrorClass)operator(()local_variable(this)operator(,) ident(standardError)operator(\))operator(;) - operator(}) - - ident(fatal) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(Fatal)delimiter(")>operator(,) ident(exceptionClass)operator(\))operator(;) - ident(interrupt) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(Interrupt)delimiter(")>operator(,) ident(signalException)operator(\))operator(;) - ident(typeError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(TypeError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(argumentError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(indexError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(IndexError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(syntaxError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(SyntaxError)delimiter(")>operator(,) ident(scriptError)operator(\))operator(;) - ident(loadError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(LoadError)delimiter(")>operator(,) ident(scriptError)operator(\))operator(;) - ident(notImplementedError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(NotImplementedError)delimiter(")>operator(,) ident(scriptError)operator(\))operator(;) - ident(securityError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(SecurityError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(noMemoryError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(NoMemoryError)delimiter(")>operator(,) ident(exceptionClass)operator(\))operator(;) - ident(regexpError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(RegexpError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(eofError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(EOFError)delimiter(")>operator(,) ident(ioError)operator(\))operator(;) - ident(threadError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(ThreadError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(concurrencyError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(ConcurrencyError)delimiter(")>operator(,) ident(threadError)operator(\))operator(;) - ident(systemStackError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(SystemStackError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(zeroDivisionError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(ZeroDivisionError)delimiter(")>operator(,) ident(standardError)operator(\))operator(;) - ident(floatDomainError) operator(=) ident(defineClassIfAllowed)operator(()string<delimiter(")content(FloatDomainError)delimiter(")>operator(,) ident(rangeError)operator(\))operator(;) - - ident(initErrno)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(RubyClass) ident(defineClassIfAllowed)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(\)) operator({) - comment(// TODO: should probably apply the null object pattern for a) - comment(// non-allowed class, rather than null) - keyword(if) operator(()ident(superClass) operator(!=) pre_constant(null) operator(&&) ident(profile)operator(.)ident(allowClass)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(defineClass)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(superClass)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(private) pre_type(Map)operator(<)pre_type(Integer)operator(,) ident(RubyClass)operator(>) ident(errnos) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(Integer)operator(,) ident(RubyClass)operator(>)operator(()operator(\))operator(;) - - directive(public) ident(RubyClass) ident(getErrno)operator(()type(int) ident(n)operator(\)) operator({) - keyword(return) ident(errnos)operator(.)ident(get)operator(()ident(n)operator(\))operator(;) - operator(}) - - comment(/** - * Create module Errno's Variables. We have this method since Errno does not have it's - * own java class. - */) - directive(private) type(void) ident(initErrno)operator(()operator(\)) operator({) - keyword(if) operator(()ident(profile)operator(.)ident(allowModule)operator(()string<delimiter(")content(Errno)delimiter(")>operator(\))operator(\)) operator({) - ident(errnoModule) operator(=) ident(defineModule)operator(()string<delimiter(")content(Errno)delimiter(")>operator(\))operator(;) - - pre_type(Field)type([]) ident(fields) operator(=) ident(IErrno)operator(.)ident(class)operator(.)ident(getFields)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(fields)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(try) operator({) - ident(createSysErr)operator(()ident(fields)operator([)ident(i)operator(])operator(.)ident(getInt)operator(()ident(IErrno)operator(.)ident(class)operator(\))operator(,) ident(fields)operator([)ident(i)operator(])operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IllegalAccessException) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Someone defined a non-public constant in IErrno.java)delimiter(")>operator(,) ident(e)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - comment(/** - * Creates a system error. - * @param i the error code (will probably use a java exception instead\) - * @param name of the error to define. - **/) - directive(private) type(void) ident(createSysErr)operator(()type(int) ident(i)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(if)operator(()ident(profile)operator(.)ident(allowClass)operator(()ident(name)operator(\))operator(\)) operator({) - ident(RubyClass) ident(errno) operator(=) ident(getErrno)operator(()operator(\))operator(.)ident(defineClassUnder)operator(()ident(name)operator(,) ident(systemCallError)operator(,) ident(systemCallError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(errnos)operator(.)ident(put)operator(()ident(i)operator(,) ident(errno)operator(\))operator(;) - ident(errno)operator(.)ident(defineConstant)operator(()string<delimiter(")content(Errno)delimiter(")>operator(,) ident(newFixnum)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(initBuiltins)operator(()operator(\)) operator({) - ident(addLazyBuiltin)operator(()string<delimiter(")content(java.rb)delimiter(")>operator(,) string<delimiter(")content(java)delimiter(")>operator(,) string<delimiter(")content(org.jruby.javasupport.Java)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(jruby.rb)delimiter(")>operator(,) string<delimiter(")content(jruby)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.JRubyLibrary)delimiter(")>operator(\))operator(;) - - ident(addLazyBuiltin)operator(()string<delimiter(")content(minijava.rb)delimiter(")>operator(,) string<delimiter(")content(minijava)delimiter(")>operator(,) string<delimiter(")content(org.jruby.java.MiniJava)delimiter(")>operator(\))operator(;) - - ident(addLazyBuiltin)operator(()string<delimiter(")content(jruby/ext.rb)delimiter(")>operator(,) string<delimiter(")content(jruby/ext)delimiter(")>operator(,) string<delimiter(")content(org.jruby.RubyJRuby$ExtLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(jruby/type.rb)delimiter(")>operator(,) string<delimiter(")content(jruby/type)delimiter(")>operator(,) string<delimiter(")content(org.jruby.RubyJRuby$TypeLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(iconv.so)delimiter(")>operator(,) string<delimiter(")content(iconv)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.IConvLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(nkf.so)delimiter(")>operator(,) string<delimiter(")content(nkf)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.NKFLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(stringio.so)delimiter(")>operator(,) string<delimiter(")content(stringio)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.StringIOLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(strscan.so)delimiter(")>operator(,) string<delimiter(")content(strscan)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.StringScannerLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(zlib.so)delimiter(")>operator(,) string<delimiter(")content(zlib)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.ZlibLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(yaml_internal.rb)delimiter(")>operator(,) string<delimiter(")content(yaml_internal)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.YamlLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(enumerator.so)delimiter(")>operator(,) string<delimiter(")content(enumerator)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.EnumeratorLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(generator_internal.rb)delimiter(")>operator(,) string<delimiter(")content(generator_internal)delimiter(")>operator(,) string<delimiter(")content(org.jruby.ext.Generator$Service)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(readline.so)delimiter(")>operator(,) string<delimiter(")content(readline)delimiter(")>operator(,) string<delimiter(")content(org.jruby.ext.Readline$Service)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(thread.so)delimiter(")>operator(,) string<delimiter(")content(thread)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.ThreadLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest.so)delimiter(")>operator(,) string<delimiter(")content(digest)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest.rb)delimiter(")>operator(,) string<delimiter(")content(digest)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest/md5.so)delimiter(")>operator(,) string<delimiter(")content(digest/md5)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary$MD5)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest/rmd160.so)delimiter(")>operator(,) string<delimiter(")content(digest/rmd160)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary$RMD160)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest/sha1.so)delimiter(")>operator(,) string<delimiter(")content(digest/sha1)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary$SHA1)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(digest/sha2.so)delimiter(")>operator(,) string<delimiter(")content(digest/sha2)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.DigestLibrary$SHA2)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(bigdecimal.so)delimiter(")>operator(,) string<delimiter(")content(bigdecimal)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.BigDecimalLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(io/wait.so)delimiter(")>operator(,) string<delimiter(")content(io/wait)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.IOWaitLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(etc.so)delimiter(")>operator(,) string<delimiter(")content(etc)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.EtcLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(weakref.rb)delimiter(")>operator(,) string<delimiter(")content(weakref)delimiter(")>operator(,) string<delimiter(")content(org.jruby.ext.WeakRef$WeakRefLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(socket.so)delimiter(")>operator(,) string<delimiter(")content(socket)delimiter(")>operator(,) string<delimiter(")content(org.jruby.ext.socket.RubySocket$Service)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(rbconfig.rb)delimiter(")>operator(,) string<delimiter(")content(rbconfig)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.RbConfigLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(jruby/serialization.rb)delimiter(")>operator(,) string<delimiter(")content(serialization)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.JRubySerializationLibrary)delimiter(")>operator(\))operator(;) - ident(addLazyBuiltin)operator(()string<delimiter(")content(ffi.so)delimiter(")>operator(,) string<delimiter(")content(ffi)delimiter(")>operator(,) string<delimiter(")content(org.jruby.ext.ffi.Factory$Service)delimiter(")>operator(\))operator(;) - keyword(if)operator(()ident(RubyInstanceConfig)operator(.)ident(NATIVE_NET_PROTOCOL)operator(\)) operator({) - ident(addLazyBuiltin)operator(()string<delimiter(")content(net/protocol.rb)delimiter(")>operator(,) string<delimiter(")content(net/protocol)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.NetProtocolBufferedIOLibrary)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(config)operator(.)ident(getCompatVersion)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) operator({) - ident(addLazyBuiltin)operator(()string<delimiter(")content(fiber.so)delimiter(")>operator(,) string<delimiter(")content(fiber)delimiter(")>operator(,) string<delimiter(")content(org.jruby.libraries.FiberLibrary)delimiter(")>operator(\))operator(;) - operator(}) - - ident(addBuiltinIfAllowed)operator(()string<delimiter(")content(openssl.so)delimiter(")>operator(,) keyword(new) ident(Library)operator(()operator(\)) operator({) - directive(public) type(void) ident(load)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(wrap)operator(\)) directive(throws) exception(IOException) operator({) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(jruby/openssl/stub)delimiter(")>operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - pre_type(String)type([]) ident(builtins) operator(=) operator({)string<delimiter(")content(fcntl)delimiter(")>operator(,) string<delimiter(")content(yaml)delimiter(")>operator(,) string<delimiter(")content(yaml/syck)delimiter(")>operator(,) string<delimiter(")content(jsignal)delimiter(")> operator(})operator(;) - keyword(for) operator(()pre_type(String) ident(library) operator(:) ident(builtins)operator(\)) operator({) - ident(addBuiltinIfAllowed)operator(()ident(library) operator(+) string<delimiter(")content(.rb)delimiter(")>operator(,) keyword(new) ident(BuiltinScript)operator(()ident(library)operator(\))operator(\))operator(;) - operator(}) - - ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(builtin/core_ext/symbol)delimiter(")>operator(\))operator(;) - - ident(RubyKernel)operator(.)ident(autoload)operator(()ident(topSelf)operator(,) ident(newSymbol)operator(()string<delimiter(")content(Java)delimiter(")>operator(\))operator(,) ident(newString)operator(()string<delimiter(")content(java)delimiter(")>operator(\))operator(\))operator(;) - - ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(enumerator)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(addLazyBuiltin)operator(()pre_type(String) ident(name)operator(,) pre_type(String) ident(shortName)operator(,) pre_type(String) ident(className)operator(\)) operator({) - ident(addBuiltinIfAllowed)operator(()ident(name)operator(,) keyword(new) ident(LateLoadingLibrary)operator(()ident(shortName)operator(,) ident(className)operator(,) ident(getJRubyClassLoader)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(addBuiltinIfAllowed)operator(()pre_type(String) ident(name)operator(,) ident(Library) ident(lib)operator(\)) operator({) - keyword(if)operator(()ident(profile)operator(.)ident(allowBuiltin)operator(()ident(name)operator(\))operator(\)) operator({) - ident(loadService)operator(.)ident(addBuiltinLibrary)operator(()ident(name)operator(,)ident(lib)operator(\))operator(;) - operator(}) - operator(}) - - pre_type(Object) ident(getRespondToMethod)operator(()operator(\)) operator({) - keyword(return) ident(respondToMethod)operator(;) - operator(}) - - type(void) ident(setRespondToMethod)operator(()pre_type(Object) ident(rtm)operator(\)) operator({) - local_variable(this)operator(.)ident(respondToMethod) operator(=) ident(rtm)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(getObjectToYamlMethod)operator(()operator(\)) operator({) - keyword(return) ident(objectToYamlMethod)operator(;) - operator(}) - - type(void) ident(setObjectToYamlMethod)operator(()pre_type(Object) ident(otym)operator(\)) operator({) - local_variable(this)operator(.)ident(objectToYamlMethod) operator(=) ident(otym)operator(;) - operator(}) - - comment(/** - * Retrieve mappings of cached methods to where they have been cached. When a cached - * method needs to be invalidated this map can be used to remove all places it has been - * cached. - * - * @return the mappings of where cached methods have been stored - */) - directive(public) ident(CacheMap) ident(getCacheMap)operator(()operator(\)) operator({) - keyword(return) ident(cacheMap)operator(;) - operator(}) - - comment(/** Getter for property rubyTopSelf. - * @return Value of property rubyTopSelf. - */) - directive(public) ident(IRubyObject) ident(getTopSelf)operator(()operator(\)) operator({) - keyword(return) ident(topSelf)operator(;) - operator(}) - - directive(public) type(void) ident(setCurrentDirectory)operator(()pre_type(String) ident(dir)operator(\)) operator({) - ident(currentDirectory) operator(=) ident(dir)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getCurrentDirectory)operator(()operator(\)) operator({) - keyword(return) ident(currentDirectory)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getEtc)operator(()operator(\)) operator({) - keyword(return) ident(etcModule)operator(;) - operator(}) - - directive(public) type(void) ident(setEtc)operator(()ident(RubyModule) ident(etcModule)operator(\)) operator({) - local_variable(this)operator(.)ident(etcModule) operator(=) ident(etcModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getObject)operator(()operator(\)) operator({) - keyword(return) ident(objectClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getModule)operator(()operator(\)) operator({) - keyword(return) ident(moduleClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getClassClass)operator(()operator(\)) operator({) - keyword(return) ident(classClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getKernel)operator(()operator(\)) operator({) - keyword(return) ident(kernelModule)operator(;) - operator(}) - type(void) ident(setKernel)operator(()ident(RubyModule) ident(kernelModule)operator(\)) operator({) - local_variable(this)operator(.)ident(kernelModule) operator(=) ident(kernelModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getDummy)operator(()operator(\)) operator({) - keyword(return) ident(dummyClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getComparable)operator(()operator(\)) operator({) - keyword(return) ident(comparableModule)operator(;) - operator(}) - type(void) ident(setComparable)operator(()ident(RubyModule) ident(comparableModule)operator(\)) operator({) - local_variable(this)operator(.)ident(comparableModule) operator(=) ident(comparableModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNumeric)operator(()operator(\)) operator({) - keyword(return) ident(numericClass)operator(;) - operator(}) - type(void) ident(setNumeric)operator(()ident(RubyClass) ident(numericClass)operator(\)) operator({) - local_variable(this)operator(.)ident(numericClass) operator(=) ident(numericClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFloat)operator(()operator(\)) operator({) - keyword(return) ident(floatClass)operator(;) - operator(}) - type(void) ident(setFloat)operator(()ident(RubyClass) ident(floatClass)operator(\)) operator({) - local_variable(this)operator(.)ident(floatClass) operator(=) ident(floatClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getInteger)operator(()operator(\)) operator({) - keyword(return) ident(integerClass)operator(;) - operator(}) - type(void) ident(setInteger)operator(()ident(RubyClass) ident(integerClass)operator(\)) operator({) - local_variable(this)operator(.)ident(integerClass) operator(=) ident(integerClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFixnum)operator(()operator(\)) operator({) - keyword(return) ident(fixnumClass)operator(;) - operator(}) - type(void) ident(setFixnum)operator(()ident(RubyClass) ident(fixnumClass)operator(\)) operator({) - local_variable(this)operator(.)ident(fixnumClass) operator(=) ident(fixnumClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getComplex)operator(()operator(\)) operator({) - keyword(return) ident(complexClass)operator(;) - operator(}) - type(void) ident(setComplex)operator(()ident(RubyClass) ident(complexClass)operator(\)) operator({) - local_variable(this)operator(.)ident(complexClass) operator(=) ident(complexClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRational)operator(()operator(\)) operator({) - keyword(return) ident(rationalClass)operator(;) - operator(}) - type(void) ident(setRational)operator(()ident(RubyClass) ident(rationalClass)operator(\)) operator({) - local_variable(this)operator(.)ident(rationalClass) operator(=) ident(rationalClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getEnumerable)operator(()operator(\)) operator({) - keyword(return) ident(enumerableModule)operator(;) - operator(}) - type(void) ident(setEnumerable)operator(()ident(RubyModule) ident(enumerableModule)operator(\)) operator({) - local_variable(this)operator(.)ident(enumerableModule) operator(=) ident(enumerableModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getEnumerator)operator(()operator(\)) operator({) - keyword(return) ident(enumeratorClass)operator(;) - operator(}) - type(void) ident(setEnumerator)operator(()ident(RubyClass) ident(enumeratorClass)operator(\)) operator({) - local_variable(this)operator(.)ident(enumeratorClass) operator(=) ident(enumeratorClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getString)operator(()operator(\)) operator({) - keyword(return) ident(stringClass)operator(;) - operator(}) - type(void) ident(setString)operator(()ident(RubyClass) ident(stringClass)operator(\)) operator({) - local_variable(this)operator(.)ident(stringClass) operator(=) ident(stringClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSymbol)operator(()operator(\)) operator({) - keyword(return) ident(symbolClass)operator(;) - operator(}) - type(void) ident(setSymbol)operator(()ident(RubyClass) ident(symbolClass)operator(\)) operator({) - local_variable(this)operator(.)ident(symbolClass) operator(=) ident(symbolClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getArray)operator(()operator(\)) operator({) - keyword(return) ident(arrayClass)operator(;) - operator(}) - type(void) ident(setArray)operator(()ident(RubyClass) ident(arrayClass)operator(\)) operator({) - local_variable(this)operator(.)ident(arrayClass) operator(=) ident(arrayClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getHash)operator(()operator(\)) operator({) - keyword(return) ident(hashClass)operator(;) - operator(}) - type(void) ident(setHash)operator(()ident(RubyClass) ident(hashClass)operator(\)) operator({) - local_variable(this)operator(.)ident(hashClass) operator(=) ident(hashClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRange)operator(()operator(\)) operator({) - keyword(return) ident(rangeClass)operator(;) - operator(}) - type(void) ident(setRange)operator(()ident(RubyClass) ident(rangeClass)operator(\)) operator({) - local_variable(this)operator(.)ident(rangeClass) operator(=) ident(rangeClass)operator(;) - operator(}) - - comment(/** Returns the "true" instance from the instance pool. - * @return The "true" instance. - */) - directive(public) ident(RubyBoolean) ident(getTrue)operator(()operator(\)) operator({) - keyword(return) ident(trueObject)operator(;) - operator(}) - - comment(/** Returns the "false" instance from the instance pool. - * @return The "false" instance. - */) - directive(public) ident(RubyBoolean) ident(getFalse)operator(()operator(\)) operator({) - keyword(return) ident(falseObject)operator(;) - operator(}) - - comment(/** Returns the "nil" singleton instance. - * @return "nil" - */) - directive(public) ident(IRubyObject) ident(getNil)operator(()operator(\)) operator({) - keyword(return) ident(nilObject)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNilClass)operator(()operator(\)) operator({) - keyword(return) ident(nilClass)operator(;) - operator(}) - type(void) ident(setNilClass)operator(()ident(RubyClass) ident(nilClass)operator(\)) operator({) - local_variable(this)operator(.)ident(nilClass) operator(=) ident(nilClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getTrueClass)operator(()operator(\)) operator({) - keyword(return) ident(trueClass)operator(;) - operator(}) - type(void) ident(setTrueClass)operator(()ident(RubyClass) ident(trueClass)operator(\)) operator({) - local_variable(this)operator(.)ident(trueClass) operator(=) ident(trueClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFalseClass)operator(()operator(\)) operator({) - keyword(return) ident(falseClass)operator(;) - operator(}) - type(void) ident(setFalseClass)operator(()ident(RubyClass) ident(falseClass)operator(\)) operator({) - local_variable(this)operator(.)ident(falseClass) operator(=) ident(falseClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getProc)operator(()operator(\)) operator({) - keyword(return) ident(procClass)operator(;) - operator(}) - type(void) ident(setProc)operator(()ident(RubyClass) ident(procClass)operator(\)) operator({) - local_variable(this)operator(.)ident(procClass) operator(=) ident(procClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getBinding)operator(()operator(\)) operator({) - keyword(return) ident(bindingClass)operator(;) - operator(}) - type(void) ident(setBinding)operator(()ident(RubyClass) ident(bindingClass)operator(\)) operator({) - local_variable(this)operator(.)ident(bindingClass) operator(=) ident(bindingClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getMethod)operator(()operator(\)) operator({) - keyword(return) ident(methodClass)operator(;) - operator(}) - type(void) ident(setMethod)operator(()ident(RubyClass) ident(methodClass)operator(\)) operator({) - local_variable(this)operator(.)ident(methodClass) operator(=) ident(methodClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getUnboundMethod)operator(()operator(\)) operator({) - keyword(return) ident(unboundMethodClass)operator(;) - operator(}) - type(void) ident(setUnboundMethod)operator(()ident(RubyClass) ident(unboundMethodClass)operator(\)) operator({) - local_variable(this)operator(.)ident(unboundMethodClass) operator(=) ident(unboundMethodClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getMatchData)operator(()operator(\)) operator({) - keyword(return) ident(matchDataClass)operator(;) - operator(}) - type(void) ident(setMatchData)operator(()ident(RubyClass) ident(matchDataClass)operator(\)) operator({) - local_variable(this)operator(.)ident(matchDataClass) operator(=) ident(matchDataClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRegexp)operator(()operator(\)) operator({) - keyword(return) ident(regexpClass)operator(;) - operator(}) - type(void) ident(setRegexp)operator(()ident(RubyClass) ident(regexpClass)operator(\)) operator({) - local_variable(this)operator(.)ident(regexpClass) operator(=) ident(regexpClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getTime)operator(()operator(\)) operator({) - keyword(return) ident(timeClass)operator(;) - operator(}) - type(void) ident(setTime)operator(()ident(RubyClass) ident(timeClass)operator(\)) operator({) - local_variable(this)operator(.)ident(timeClass) operator(=) ident(timeClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getMath)operator(()operator(\)) operator({) - keyword(return) ident(mathModule)operator(;) - operator(}) - type(void) ident(setMath)operator(()ident(RubyModule) ident(mathModule)operator(\)) operator({) - local_variable(this)operator(.)ident(mathModule) operator(=) ident(mathModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getMarshal)operator(()operator(\)) operator({) - keyword(return) ident(marshalModule)operator(;) - operator(}) - type(void) ident(setMarshal)operator(()ident(RubyModule) ident(marshalModule)operator(\)) operator({) - local_variable(this)operator(.)ident(marshalModule) operator(=) ident(marshalModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getBignum)operator(()operator(\)) operator({) - keyword(return) ident(bignumClass)operator(;) - operator(}) - type(void) ident(setBignum)operator(()ident(RubyClass) ident(bignumClass)operator(\)) operator({) - local_variable(this)operator(.)ident(bignumClass) operator(=) ident(bignumClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getDir)operator(()operator(\)) operator({) - keyword(return) ident(dirClass)operator(;) - operator(}) - type(void) ident(setDir)operator(()ident(RubyClass) ident(dirClass)operator(\)) operator({) - local_variable(this)operator(.)ident(dirClass) operator(=) ident(dirClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFile)operator(()operator(\)) operator({) - keyword(return) ident(fileClass)operator(;) - operator(}) - type(void) ident(setFile)operator(()ident(RubyClass) ident(fileClass)operator(\)) operator({) - local_variable(this)operator(.)ident(fileClass) operator(=) ident(fileClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFileStat)operator(()operator(\)) operator({) - keyword(return) ident(fileStatClass)operator(;) - operator(}) - type(void) ident(setFileStat)operator(()ident(RubyClass) ident(fileStatClass)operator(\)) operator({) - local_variable(this)operator(.)ident(fileStatClass) operator(=) ident(fileStatClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getFileTest)operator(()operator(\)) operator({) - keyword(return) ident(fileTestModule)operator(;) - operator(}) - type(void) ident(setFileTest)operator(()ident(RubyModule) ident(fileTestModule)operator(\)) operator({) - local_variable(this)operator(.)ident(fileTestModule) operator(=) ident(fileTestModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getIO)operator(()operator(\)) operator({) - keyword(return) ident(ioClass)operator(;) - operator(}) - type(void) ident(setIO)operator(()ident(RubyClass) ident(ioClass)operator(\)) operator({) - local_variable(this)operator(.)ident(ioClass) operator(=) ident(ioClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getThread)operator(()operator(\)) operator({) - keyword(return) ident(threadClass)operator(;) - operator(}) - type(void) ident(setThread)operator(()ident(RubyClass) ident(threadClass)operator(\)) operator({) - local_variable(this)operator(.)ident(threadClass) operator(=) ident(threadClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getThreadGroup)operator(()operator(\)) operator({) - keyword(return) ident(threadGroupClass)operator(;) - operator(}) - type(void) ident(setThreadGroup)operator(()ident(RubyClass) ident(threadGroupClass)operator(\)) operator({) - local_variable(this)operator(.)ident(threadGroupClass) operator(=) ident(threadGroupClass)operator(;) - operator(}) - - directive(public) ident(RubyThreadGroup) ident(getDefaultThreadGroup)operator(()operator(\)) operator({) - keyword(return) ident(defaultThreadGroup)operator(;) - operator(}) - type(void) ident(setDefaultThreadGroup)operator(()ident(RubyThreadGroup) ident(defaultThreadGroup)operator(\)) operator({) - local_variable(this)operator(.)ident(defaultThreadGroup) operator(=) ident(defaultThreadGroup)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getContinuation)operator(()operator(\)) operator({) - keyword(return) ident(continuationClass)operator(;) - operator(}) - type(void) ident(setContinuation)operator(()ident(RubyClass) ident(continuationClass)operator(\)) operator({) - local_variable(this)operator(.)ident(continuationClass) operator(=) ident(continuationClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getStructClass)operator(()operator(\)) operator({) - keyword(return) ident(structClass)operator(;) - operator(}) - type(void) ident(setStructClass)operator(()ident(RubyClass) ident(structClass)operator(\)) operator({) - local_variable(this)operator(.)ident(structClass) operator(=) ident(structClass)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getTmsStruct)operator(()operator(\)) operator({) - keyword(return) ident(tmsStruct)operator(;) - operator(}) - type(void) ident(setTmsStruct)operator(()ident(RubyClass) ident(tmsStruct)operator(\)) operator({) - local_variable(this)operator(.)ident(tmsStruct) operator(=) ident(tmsStruct)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getPasswdStruct)operator(()operator(\)) operator({) - keyword(return) ident(passwdStruct)operator(;) - operator(}) - type(void) ident(setPasswdStruct)operator(()ident(RubyClass) ident(passwdStruct)operator(\)) operator({) - local_variable(this)operator(.)ident(passwdStruct) operator(=) ident(passwdStruct)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getGroupStruct)operator(()operator(\)) operator({) - keyword(return) ident(groupStruct)operator(;) - operator(}) - type(void) ident(setGroupStruct)operator(()ident(RubyClass) ident(groupStruct)operator(\)) operator({) - local_variable(this)operator(.)ident(groupStruct) operator(=) ident(groupStruct)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getGC)operator(()operator(\)) operator({) - keyword(return) ident(gcModule)operator(;) - operator(}) - type(void) ident(setGC)operator(()ident(RubyModule) ident(gcModule)operator(\)) operator({) - local_variable(this)operator(.)ident(gcModule) operator(=) ident(gcModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getObjectSpaceModule)operator(()operator(\)) operator({) - keyword(return) ident(objectSpaceModule)operator(;) - operator(}) - type(void) ident(setObjectSpaceModule)operator(()ident(RubyModule) ident(objectSpaceModule)operator(\)) operator({) - local_variable(this)operator(.)ident(objectSpaceModule) operator(=) ident(objectSpaceModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getProcess)operator(()operator(\)) operator({) - keyword(return) ident(processModule)operator(;) - operator(}) - type(void) ident(setProcess)operator(()ident(RubyModule) ident(processModule)operator(\)) operator({) - local_variable(this)operator(.)ident(processModule) operator(=) ident(processModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getProcStatus)operator(()operator(\)) operator({) - keyword(return) ident(procStatusClass)operator(;) - operator(}) - type(void) ident(setProcStatus)operator(()ident(RubyClass) ident(procStatusClass)operator(\)) operator({) - local_variable(this)operator(.)ident(procStatusClass) operator(=) ident(procStatusClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getProcUID)operator(()operator(\)) operator({) - keyword(return) ident(procUIDModule)operator(;) - operator(}) - type(void) ident(setProcUID)operator(()ident(RubyModule) ident(procUIDModule)operator(\)) operator({) - local_variable(this)operator(.)ident(procUIDModule) operator(=) ident(procUIDModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getProcGID)operator(()operator(\)) operator({) - keyword(return) ident(procGIDModule)operator(;) - operator(}) - type(void) ident(setProcGID)operator(()ident(RubyModule) ident(procGIDModule)operator(\)) operator({) - local_variable(this)operator(.)ident(procGIDModule) operator(=) ident(procGIDModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getProcSysModule)operator(()operator(\)) operator({) - keyword(return) ident(procSysModule)operator(;) - operator(}) - type(void) ident(setProcSys)operator(()ident(RubyModule) ident(procSysModule)operator(\)) operator({) - local_variable(this)operator(.)ident(procSysModule) operator(=) ident(procSysModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getPrecision)operator(()operator(\)) operator({) - keyword(return) ident(precisionModule)operator(;) - operator(}) - type(void) ident(setPrecision)operator(()ident(RubyModule) ident(precisionModule)operator(\)) operator({) - local_variable(this)operator(.)ident(precisionModule) operator(=) ident(precisionModule)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getErrno)operator(()operator(\)) operator({) - keyword(return) ident(errnoModule)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getException)operator(()operator(\)) operator({) - keyword(return) ident(exceptionClass)operator(;) - operator(}) - type(void) ident(setException)operator(()ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - local_variable(this)operator(.)ident(exceptionClass) operator(=) ident(exceptionClass)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNameError)operator(()operator(\)) operator({) - keyword(return) ident(nameError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNameErrorMessage)operator(()operator(\)) operator({) - keyword(return) ident(nameErrorMessage)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNoMethodError)operator(()operator(\)) operator({) - keyword(return) ident(noMethodError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSignalException)operator(()operator(\)) operator({) - keyword(return) ident(signalException)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRangeError)operator(()operator(\)) operator({) - keyword(return) ident(rangeError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSystemExit)operator(()operator(\)) operator({) - keyword(return) ident(systemExit)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getLocalJumpError)operator(()operator(\)) operator({) - keyword(return) ident(localJumpError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNativeException)operator(()operator(\)) operator({) - keyword(return) ident(nativeException)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSystemCallError)operator(()operator(\)) operator({) - keyword(return) ident(systemCallError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFatal)operator(()operator(\)) operator({) - keyword(return) ident(fatal)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getInterrupt)operator(()operator(\)) operator({) - keyword(return) ident(interrupt)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getTypeError)operator(()operator(\)) operator({) - keyword(return) ident(typeError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getArgumentError)operator(()operator(\)) operator({) - keyword(return) ident(argumentError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getIndexError)operator(()operator(\)) operator({) - keyword(return) ident(indexError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSyntaxError)operator(()operator(\)) operator({) - keyword(return) ident(syntaxError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getStandardError)operator(()operator(\)) operator({) - keyword(return) ident(standardError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRuntimeError)operator(()operator(\)) operator({) - keyword(return) ident(runtimeError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getIOError)operator(()operator(\)) operator({) - keyword(return) ident(ioError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getLoadError)operator(()operator(\)) operator({) - keyword(return) ident(loadError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNotImplementedError)operator(()operator(\)) operator({) - keyword(return) ident(notImplementedError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSecurityError)operator(()operator(\)) operator({) - keyword(return) ident(securityError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getNoMemoryError)operator(()operator(\)) operator({) - keyword(return) ident(noMemoryError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRegexpError)operator(()operator(\)) operator({) - keyword(return) ident(regexpError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getEOFError)operator(()operator(\)) operator({) - keyword(return) ident(eofError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getThreadError)operator(()operator(\)) operator({) - keyword(return) ident(threadError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getConcurrencyError)operator(()operator(\)) operator({) - keyword(return) ident(concurrencyError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getSystemStackError)operator(()operator(\)) operator({) - keyword(return) ident(systemStackError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getZeroDivisionError)operator(()operator(\)) operator({) - keyword(return) ident(zeroDivisionError)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getFloatDomainError)operator(()operator(\)) operator({) - keyword(return) ident(floatDomainError)operator(;) - operator(}) - - directive(private) ident(RubyHash) ident(charsetMap)operator(;) - directive(public) ident(RubyHash) ident(getCharsetMap)operator(()operator(\)) operator({) - keyword(if) operator(()ident(charsetMap) operator(==) pre_constant(null)operator(\)) ident(charsetMap) operator(=) keyword(new) ident(RubyHash)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(charsetMap)operator(;) - operator(}) - - comment(/** Getter for property isVerbose. - * @return Value of property isVerbose. - */) - directive(public) ident(IRubyObject) ident(getVerbose)operator(()operator(\)) operator({) - keyword(return) ident(verbose)operator(;) - operator(}) - - comment(/** Setter for property isVerbose. - * @param verbose New value of property isVerbose. - */) - directive(public) type(void) ident(setVerbose)operator(()ident(IRubyObject) ident(verbose)operator(\)) operator({) - local_variable(this)operator(.)ident(verbose) operator(=) ident(verbose)operator(;) - operator(}) - - comment(/** Getter for property isDebug. - * @return Value of property isDebug. - */) - directive(public) ident(IRubyObject) ident(getDebug)operator(()operator(\)) operator({) - keyword(return) ident(debug)operator(;) - operator(}) - - comment(/** Setter for property isDebug. - * @param debug New value of property isDebug. - */) - directive(public) type(void) ident(setDebug)operator(()ident(IRubyObject) ident(debug)operator(\)) operator({) - local_variable(this)operator(.)ident(debug) operator(=) ident(debug)operator(;) - operator(}) - - directive(public) ident(JavaSupport) ident(getJavaSupport)operator(()operator(\)) operator({) - keyword(return) ident(javaSupport)operator(;) - operator(}) - - directive(public) directive(static) pre_type(ClassLoader) ident(getClassLoader)operator(()operator(\)) operator({) - comment(// we try to get the classloader that loaded JRuby, falling back on System) - pre_type(ClassLoader) ident(loader) operator(=) ident(Ruby)operator(.)ident(class)operator(.)ident(getClassLoader)operator(()operator(\))operator(;) - keyword(if) operator(()ident(loader) operator(==) pre_constant(null)operator(\)) operator({) - ident(loader) operator(=) pre_type(ClassLoader)operator(.)ident(getSystemClassLoader)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(loader)operator(;) - operator(}) - - directive(public) directive(synchronized) ident(JRubyClassLoader) ident(getJRubyClassLoader)operator(()operator(\)) operator({) - comment(// FIXME: Get rid of laziness and handle restricted access elsewhere) - keyword(if) operator(()operator(!)ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\)) operator(&&) ident(jrubyClassLoader) operator(==) pre_constant(null)operator(\)) operator({) - ident(jrubyClassLoader) operator(=) keyword(new) ident(JRubyClassLoader)operator(()ident(config)operator(.)ident(getLoader)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(jrubyClassLoader)operator(;) - operator(}) - - comment(/** Defines a global variable - */) - directive(public) type(void) ident(defineVariable)operator(()directive(final) ident(GlobalVariable) ident(variable)operator(\)) operator({) - ident(globalVariables)operator(.)ident(define)operator(()ident(variable)operator(.)ident(name)operator(()operator(\))operator(,) keyword(new) ident(IAccessor)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(variable)operator(.)ident(get)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(setValue)operator(()ident(IRubyObject) ident(newValue)operator(\)) operator({) - keyword(return) ident(variable)operator(.)ident(set)operator(()ident(newValue)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - comment(/** defines a readonly global variable - * - */) - directive(public) type(void) ident(defineReadonlyVariable)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(globalVariables)operator(.)ident(defineReadonly)operator(()ident(name)operator(,) keyword(new) ident(ValueAccessor)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parseFile)operator(()pre_type(InputStream) ident(in)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(\)) operator({) - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) ident(in)operator(,) ident(scope)operator(,) keyword(new) ident(ParserConfiguration)operator(()integer(0)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parseInline)operator(()pre_type(InputStream) ident(in)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(\)) operator({) - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) ident(in)operator(,) ident(scope)operator(,) keyword(new) ident(ParserConfiguration)operator(()integer(0)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parseEval)operator(()pre_type(String) ident(content)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(,) type(int) ident(lineNumber)operator(\)) operator({) - type(byte)type([]) ident(bytes)operator(;) - - keyword(try) operator({) - ident(bytes) operator(=) ident(content)operator(.)ident(getBytes)operator(()ident(KCode)operator(.)ident(NONE)operator(.)ident(getKCode)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedEncodingException) ident(e)operator(\)) operator({) - ident(bytes) operator(=) ident(content)operator(.)ident(getBytes)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) keyword(new) pre_type(ByteArrayInputStream)operator(()ident(bytes)operator(\))operator(,) ident(scope)operator(,) - keyword(new) ident(ParserConfiguration)operator(()ident(lineNumber)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parse)operator(()pre_type(String) ident(content)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(,) type(int) ident(lineNumber)operator(,) - type(boolean) ident(extraPositionInformation)operator(\)) operator({) - type(byte)type([]) ident(bytes)operator(;) - - keyword(try) operator({) - ident(bytes) operator(=) ident(content)operator(.)ident(getBytes)operator(()ident(KCode)operator(.)ident(NONE)operator(.)ident(getKCode)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedEncodingException) ident(e)operator(\)) operator({) - ident(bytes) operator(=) ident(content)operator(.)ident(getBytes)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) keyword(new) pre_type(ByteArrayInputStream)operator(()ident(bytes)operator(\))operator(,) ident(scope)operator(,) - keyword(new) ident(ParserConfiguration)operator(()ident(lineNumber)operator(,) ident(extraPositionInformation)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parseEval)operator(()ident(ByteList) ident(content)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(,) type(int) ident(lineNumber)operator(\)) operator({) - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) ident(content)operator(,) ident(scope)operator(,) keyword(new) ident(ParserConfiguration)operator(()ident(lineNumber)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Node) ident(parse)operator(()ident(ByteList) ident(content)operator(,) pre_type(String) ident(file)operator(,) ident(DynamicScope) ident(scope)operator(,) type(int) ident(lineNumber)operator(,) - type(boolean) ident(extraPositionInformation)operator(\)) operator({) - keyword(return) ident(parser)operator(.)ident(parse)operator(()ident(file)operator(,) ident(content)operator(,) ident(scope)operator(,) - keyword(new) ident(ParserConfiguration)operator(()ident(lineNumber)operator(,) ident(extraPositionInformation)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - - directive(public) ident(ThreadService) ident(getThreadService)operator(()operator(\)) operator({) - keyword(return) ident(threadService)operator(;) - operator(}) - - directive(public) ident(ThreadContext) ident(getCurrentContext)operator(()operator(\)) operator({) - keyword(return) ident(threadService)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Returns the loadService. - * @return ILoadService - */) - directive(public) ident(LoadService) ident(getLoadService)operator(()operator(\)) operator({) - keyword(return) ident(loadService)operator(;) - operator(}) - - directive(public) ident(RubyWarnings) ident(getWarnings)operator(()operator(\)) operator({) - keyword(return) ident(warnings)operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getErrorStream)operator(()operator(\)) operator({) - comment(// FIXME: We can't guarantee this will always be a RubyIO...so the old code here is not safe) - comment(/*java.io.OutputStream os = ((RubyIO\) getGlobalVariables(\).get("$stderr"\)\).getOutStream(\); - if(null != os\) { - return new PrintStream(os\); - } else { - return new PrintStream(new org.jruby.util.SwallowingOutputStream(\)\); - }*/) - keyword(return) keyword(new) pre_type(PrintStream)operator(()keyword(new) ident(IOOutputStream)operator(()ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stderr)delimiter(")>operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getInputStream)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(IOInputStream)operator(()ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stdin)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getOutputStream)operator(()operator(\)) operator({) - keyword(return) keyword(new) pre_type(PrintStream)operator(()keyword(new) ident(IOOutputStream)operator(()ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stdout)delimiter(")>operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getClassFromPath)operator(()pre_type(String) ident(path)operator(\)) operator({) - ident(RubyModule) ident(c) operator(=) ident(getObject)operator(()operator(\))operator(;) - keyword(if) operator(()ident(path)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0) operator(||) ident(path)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(#)delimiter(')>operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(()string<delimiter(")content(can't retrieve anonymous class )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - type(int) ident(pbeg) operator(=) integer(0)operator(,) ident(p) operator(=) integer(0)operator(;) - keyword(for)operator(()type(int) ident(l)operator(=)ident(path)operator(.)ident(length)operator(()operator(\))operator(;) ident(p)operator(<)ident(l)operator(;) operator(\)) operator({) - keyword(while)operator(()ident(p)operator(<)ident(l) operator(&&) ident(path)operator(.)ident(charAt)operator(()ident(p)operator(\)) operator(!=) string<delimiter(')content(:)delimiter(')>operator(\)) operator({) - ident(p)operator(++)operator(;) - operator(}) - pre_type(String) ident(str) operator(=) ident(path)operator(.)ident(substring)operator(()ident(pbeg)operator(,) ident(p)operator(\))operator(;) - - keyword(if)operator(()ident(p)operator(<)ident(l) operator(&&) ident(path)operator(.)ident(charAt)operator(()ident(p)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')>operator(\)) operator({) - keyword(if)operator(()ident(p)operator(+)integer(1) operator(<) ident(l) operator(&&) ident(path)operator(.)ident(charAt)operator(()ident(p)operator(+)integer(1)operator(\)) operator(!=) string<delimiter(')content(:)delimiter(')>operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(()string<delimiter(")content(undefined class/module )delimiter(")> operator(+) ident(path)operator(.)ident(substring)operator(()ident(pbeg)operator(,)ident(p)operator(\))operator(\))operator(;) - operator(}) - ident(p) operator(+=) integer(2)operator(;) - ident(pbeg) operator(=) ident(p)operator(;) - operator(}) - - ident(IRubyObject) ident(cc) operator(=) ident(c)operator(.)ident(getConstant)operator(()ident(str)operator(\))operator(;) - keyword(if)operator(()operator(!)operator(()ident(cc) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(newTypeError)operator(()string<delimiter(")delimiter(")> operator(+) ident(path) operator(+) string<delimiter(")content( does not refer to class/module)delimiter(")>operator(\))operator(;) - operator(}) - ident(c) operator(=) operator(()ident(RubyModule)operator(\))ident(cc)operator(;) - operator(}) - keyword(return) ident(c)operator(;) - operator(}) - - comment(/** Prints an error with backtrace to the error stream. - * - * MRI: eval.c - error_print(\) - * - */) - directive(public) type(void) ident(printError)operator(()ident(RubyException) ident(excp)operator(\)) operator({) - keyword(if) operator(()ident(excp) operator(==) pre_constant(null) operator(||) ident(excp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backtrace) operator(=) ident(excp)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(backtrace)delimiter(")>operator(\))operator(;) - - pre_type(PrintStream) ident(errorStream) operator(=) ident(getErrorStream)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backtrace)operator(.)ident(isNil)operator(()operator(\)) operator(||) operator(!)operator(()ident(backtrace) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getFile)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(context)operator(.)ident(getFile)operator(()operator(\)) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(context)operator(.)ident(getLine)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()operator(()operator(()ident(RubyArray)operator(\)) ident(backtrace)operator(\))operator(.)ident(getLength)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(printErrorPos)operator(()ident(context)operator(,) ident(errorStream)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(mesg) operator(=) operator(()operator(()ident(RubyArray)operator(\)) ident(backtrace)operator(\))operator(.)ident(first)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(mesg)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(printErrorPos)operator(()ident(context)operator(,) ident(errorStream)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(mesg)operator(\))operator(;) - operator(}) - operator(}) - - ident(RubyClass) ident(type) operator(=) ident(excp)operator(.)ident(getMetaClass)operator(()operator(\))operator(;) - pre_type(String) ident(info) operator(=) ident(excp)operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(type) operator(==) ident(getRuntimeError)operator(()operator(\)) operator(&&) operator(()ident(info) operator(==) pre_constant(null) operator(||) ident(info)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\))operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")content(: unhandled exception)char(\\n)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(String) ident(path) operator(=) ident(type)operator(.)ident(getName)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(info)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")content(: )delimiter(")> operator(+) ident(path) operator(+) string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(path)operator(.)ident(startsWith)operator(()string<delimiter(")content(#)delimiter(")>operator(\))operator(\)) operator({) - ident(path) operator(=) pre_constant(null)operator(;) - operator(}) - - pre_type(String) ident(tail) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(info)operator(.)ident(indexOf)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(tail) operator(=) ident(info)operator(.)ident(substring)operator(()ident(info)operator(.)ident(indexOf)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\)) operator(+) integer(1)operator(\))operator(;) - ident(info) operator(=) ident(info)operator(.)ident(substring)operator(()integer(0)operator(,) ident(info)operator(.)ident(indexOf)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")content(: )delimiter(")> operator(+) ident(info)operator(\))operator(;) - - keyword(if) operator(()ident(path) operator(!=) pre_constant(null)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")content( ()delimiter(")> operator(+) ident(path) operator(+) string<delimiter(")content(\))char(\\n)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(tail) operator(!=) pre_constant(null)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(tail) operator(+) string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - ident(excp)operator(.)ident(printBacktrace)operator(()ident(errorStream)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(printErrorPos)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(PrintStream) ident(errorStream)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getFile)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getFrameName)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(context)operator(.)ident(getFile)operator(()operator(\)) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(\))operator(;) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")content(:in ')delimiter(")> operator(+) ident(context)operator(.)ident(getFrameName)operator(()operator(\)) operator(+) string<delimiter(')char(\\')delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(context)operator(.)ident(getLine)operator(()operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(context)operator(.)ident(getFile)operator(()operator(\)) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(errorStream)operator(.)ident(print)operator(()ident(context)operator(.)ident(getFile)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(void) ident(loadFile)operator(()pre_type(String) ident(scriptName)operator(,) pre_type(InputStream) ident(in)operator(,) type(boolean) ident(wrap)operator(\)) operator({) - ident(IRubyObject) ident(self) operator(=) ident(wrap) operator(?) ident(TopSelfFactory)operator(.)ident(createTopSelf)operator(()local_variable(this)operator(\)) operator(:) ident(getTopSelf)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(String) ident(file) operator(=) ident(context)operator(.)ident(getFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(secure)operator(()integer(4)operator(\))operator(;) comment(/* should alter global state */) - - ident(context)operator(.)ident(setFile)operator(()ident(scriptName)operator(\))operator(;) - ident(context)operator(.)ident(preNodeEval)operator(()ident(objectClass)operator(,) ident(self)operator(,) ident(scriptName)operator(\))operator(;) - - ident(parseFile)operator(()ident(in)operator(,) ident(scriptName)operator(,) pre_constant(null)operator(\))operator(.)ident(interpret)operator(()local_variable(this)operator(,) ident(context)operator(,) ident(self)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return)operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postNodeEval)operator(()operator(\))operator(;) - ident(context)operator(.)ident(setFile)operator(()ident(file)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(compileAndLoadFile)operator(()pre_type(String) ident(filename)operator(,) pre_type(InputStream) ident(in)operator(,) type(boolean) ident(wrap)operator(\)) operator({) - ident(IRubyObject) ident(self) operator(=) ident(wrap) operator(?) ident(TopSelfFactory)operator(.)ident(createTopSelf)operator(()local_variable(this)operator(\)) operator(:) ident(getTopSelf)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(String) ident(file) operator(=) ident(context)operator(.)ident(getFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(secure)operator(()integer(4)operator(\))operator(;) comment(/* should alter global state */) - - ident(context)operator(.)ident(setFile)operator(()ident(filename)operator(\))operator(;) - ident(context)operator(.)ident(preNodeEval)operator(()ident(objectClass)operator(,) ident(self)operator(,) ident(filename)operator(\))operator(;) - - ident(Node) ident(scriptNode) operator(=) ident(parseFile)operator(()ident(in)operator(,) ident(filename)operator(,) pre_constant(null)operator(\))operator(;) - - ident(Script) ident(script) operator(=) ident(tryCompile)operator(()ident(scriptNode)operator(,) keyword(new) ident(JRubyClassLoader)operator(()ident(jrubyClassLoader)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(script) operator(==) pre_constant(null)operator(\)) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Error, could not compile; pass -J-Djruby.jit.logging.verbose=true for more details)delimiter(")>operator(\))operator(;) - operator(}) - - ident(runScript)operator(()ident(script)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return)operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postNodeEval)operator(()operator(\))operator(;) - ident(context)operator(.)ident(setFile)operator(()ident(file)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(loadScript)operator(()ident(Script) ident(script)operator(\)) operator({) - ident(IRubyObject) ident(self) operator(=) ident(getTopSelf)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(secure)operator(()integer(4)operator(\))operator(;) comment(/* should alter global state */) - - ident(context)operator(.)ident(preNodeEval)operator(()ident(objectClass)operator(,) ident(self)operator(\))operator(;) - - ident(script)operator(.)ident(load)operator(()ident(context)operator(,) ident(self)operator(,) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return)operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postNodeEval)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(class) class(CallTraceFuncHook) directive(extends) ident(EventHook) operator({) - directive(private) ident(RubyProc) ident(traceFunc)operator(;) - - directive(public) type(void) ident(setTraceFunc)operator(()ident(RubyProc) ident(traceFunc)operator(\)) operator({) - local_variable(this)operator(.)ident(traceFunc) operator(=) ident(traceFunc)operator(;) - operator(}) - - directive(public) type(void) ident(eventHandler)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(eventName)operator(,) pre_type(String) ident(file)operator(,) type(int) ident(line)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(type)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(context)operator(.)ident(isWithinTrace)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(file) operator(==) pre_constant(null)operator(\)) ident(file) operator(=) string<delimiter(")content((ruby\))delimiter(")>operator(;) - keyword(if) operator(()ident(type) operator(==) pre_constant(null)operator(\)) ident(type) operator(=) ident(getFalse)operator(()operator(\))operator(;) - - ident(RubyBinding) ident(binding) operator(=) ident(RubyBinding)operator(.)ident(newBinding)operator(()ident(Ruby)operator(.)ident(this)operator(\))operator(;) - - ident(context)operator(.)ident(preTrace)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(traceFunc)operator(.)ident(call)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) - ident(newString)operator(()ident(eventName)operator(\))operator(,) comment(// event name) - ident(newString)operator(()ident(file)operator(\))operator(,) comment(// filename) - ident(newFixnum)operator(()ident(line)operator(\))operator(,) comment(// line numbers should be 1-based) - ident(name) operator(!=) pre_constant(null) operator(?) ident(newSymbol)operator(()ident(name)operator(\)) operator(:) ident(getNil)operator(()operator(\))operator(,) - ident(binding)operator(,) - ident(type) - operator(})operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(boolean) ident(isInterestedInEvent)operator(()ident(RubyEvent) ident(event)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(CallTraceFuncHook) ident(callTraceFuncHook) operator(=) keyword(new) ident(CallTraceFuncHook)operator(()operator(\))operator(;) - - directive(public) type(void) ident(addEventHook)operator(()ident(EventHook) ident(hook)operator(\)) operator({) - ident(eventHooks)operator(.)ident(add)operator(()ident(hook)operator(\))operator(;) - ident(hasEventHooks) operator(=) pre_constant(true)operator(;) - operator(}) - - directive(public) type(void) ident(removeEventHook)operator(()ident(EventHook) ident(hook)operator(\)) operator({) - ident(eventHooks)operator(.)ident(remove)operator(()ident(hook)operator(\))operator(;) - ident(hasEventHooks) operator(=) operator(!)ident(eventHooks)operator(.)ident(isEmpty)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setTraceFunction)operator(()ident(RubyProc) ident(traceFunction)operator(\)) operator({) - ident(removeEventHook)operator(()ident(callTraceFuncHook)operator(\))operator(;) - - keyword(if) operator(()ident(traceFunction) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - ident(callTraceFuncHook)operator(.)ident(setTraceFunc)operator(()ident(traceFunction)operator(\))operator(;) - ident(addEventHook)operator(()ident(callTraceFuncHook)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(callEventHooks)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyEvent) ident(event)operator(,) pre_type(String) ident(file)operator(,) type(int) ident(line)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(type)operator(\)) operator({) - keyword(for) operator(()ident(EventHook) ident(eventHook) operator(:) ident(eventHooks)operator(\)) operator({) - keyword(if) operator(()ident(eventHook)operator(.)ident(isInterestedInEvent)operator(()ident(event)operator(\))operator(\)) operator({) - ident(eventHook)operator(.)ident(event)operator(()ident(context)operator(,) ident(event)operator(,) ident(file)operator(,) ident(line)operator(,) ident(name)operator(,) ident(type)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(boolean) ident(hasEventHooks)operator(()operator(\)) operator({) - keyword(return) ident(hasEventHooks)operator(;) - operator(}) - - directive(public) ident(GlobalVariables) ident(getGlobalVariables)operator(()operator(\)) operator({) - keyword(return) ident(globalVariables)operator(;) - operator(}) - - comment(// For JSR 223 support: see http://scripting.java.net/) - directive(public) type(void) ident(setGlobalVariables)operator(()ident(GlobalVariables) ident(globalVariables)operator(\)) operator({) - local_variable(this)operator(.)ident(globalVariables) operator(=) ident(globalVariables)operator(;) - operator(}) - - directive(public) ident(CallbackFactory) ident(callbackFactory)operator(()pre_type(Class)operator(<)operator(?)operator(>) ident(type)operator(\)) operator({) - keyword(return) ident(CallbackFactory)operator(.)ident(createFactory)operator(()local_variable(this)operator(,) ident(type)operator(\))operator(;) - operator(}) - - comment(/** - * Push block onto exit stack. When runtime environment exits - * these blocks will be evaluated. - * - * @return the element that was pushed onto stack - */) - directive(public) ident(IRubyObject) ident(pushExitBlock)operator(()ident(RubyProc) ident(proc)operator(\)) operator({) - ident(atExitBlocks)operator(.)ident(push)operator(()ident(proc)operator(\))operator(;) - keyword(return) ident(proc)operator(;) - operator(}) - - comment(// use this for JRuby-internal finalizers) - directive(public) type(void) ident(addInternalFinalizer)operator(()ident(Finalizable) ident(finalizer)operator(\)) operator({) - directive(synchronized) operator(()ident(internalFinalizersMutex)operator(\)) operator({) - keyword(if) operator(()ident(internalFinalizers) operator(==) pre_constant(null)operator(\)) operator({) - ident(internalFinalizers) operator(=) keyword(new) pre_type(WeakHashMap)operator(<)ident(Finalizable)operator(,) pre_type(Object)operator(>)operator(()operator(\))operator(;) - operator(}) - ident(internalFinalizers)operator(.)ident(put)operator(()ident(finalizer)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - operator(}) - - comment(// this method is for finalizers registered via ObjectSpace) - directive(public) type(void) ident(addFinalizer)operator(()ident(Finalizable) ident(finalizer)operator(\)) operator({) - directive(synchronized) operator(()ident(finalizersMutex)operator(\)) operator({) - keyword(if) operator(()ident(finalizers) operator(==) pre_constant(null)operator(\)) operator({) - ident(finalizers) operator(=) keyword(new) pre_type(WeakHashMap)operator(<)ident(Finalizable)operator(,) pre_type(Object)operator(>)operator(()operator(\))operator(;) - operator(}) - ident(finalizers)operator(.)ident(put)operator(()ident(finalizer)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(removeInternalFinalizer)operator(()ident(Finalizable) ident(finalizer)operator(\)) operator({) - directive(synchronized) operator(()ident(internalFinalizersMutex)operator(\)) operator({) - keyword(if) operator(()ident(internalFinalizers) operator(!=) pre_constant(null)operator(\)) operator({) - ident(internalFinalizers)operator(.)ident(remove)operator(()ident(finalizer)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(void) ident(removeFinalizer)operator(()ident(Finalizable) ident(finalizer)operator(\)) operator({) - directive(synchronized) operator(()ident(finalizersMutex)operator(\)) operator({) - keyword(if) operator(()ident(finalizers) operator(!=) pre_constant(null)operator(\)) operator({) - ident(finalizers)operator(.)ident(remove)operator(()ident(finalizer)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** - * Make sure Kernel#at_exit procs get invoked on runtime shutdown. - * This method needs to be explicitly called to work properly. - * I thought about using finalize(\), but that did not work and I - * am not sure the runtime will be at a state to run procs by the - * time Ruby is going away. This method can contain any other - * things that need to be cleaned up at shutdown. - */) - directive(public) type(void) ident(tearDown)operator(()operator(\)) operator({) - type(int) ident(status) operator(=) integer(0)operator(;) - - keyword(while) operator(()operator(!)ident(atExitBlocks)operator(.)ident(empty)operator(()operator(\))operator(\)) operator({) - ident(RubyProc) ident(proc) operator(=) ident(atExitBlocks)operator(.)ident(pop)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(proc)operator(.)ident(call)operator(()ident(getCurrentContext)operator(()operator(\))operator(,) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(rj)operator(\)) operator({) - ident(RubyException) ident(raisedException) operator(=) ident(rj)operator(.)ident(getException)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(getSystemExit)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(raisedException)operator(\))operator(\)) operator({) - ident(status) operator(=) integer(1)operator(;) - ident(printError)operator(()ident(raisedException)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(statusObj) operator(=) ident(raisedException)operator(.)ident(callMethod)operator(() - ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(status)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(statusObj) operator(!=) pre_constant(null) operator(&&) operator(!)ident(statusObj)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(status) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(statusObj)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - keyword(if) operator(()ident(finalizers) operator(!=) pre_constant(null)operator(\)) operator({) - directive(synchronized) operator(()ident(finalizers)operator(\)) operator({) - keyword(for) operator(()pre_type(Iterator)operator(<)ident(Finalizable)operator(>) ident(finalIter) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Finalizable)operator(>)operator(()ident(finalizers)operator(.)ident(keySet)operator(()operator(\))operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(finalIter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(finalIter)operator(.)ident(next)operator(()operator(\))operator(.)ident(finalize)operator(()operator(\))operator(;) - ident(finalIter)operator(.)ident(remove)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(synchronized) operator(()ident(internalFinalizersMutex)operator(\)) operator({) - keyword(if) operator(()ident(internalFinalizers) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()pre_type(Iterator)operator(<)ident(Finalizable)operator(>) ident(finalIter) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Finalizable)operator(>)operator(() - ident(internalFinalizers)operator(.)ident(keySet)operator(()operator(\))operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(finalIter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(finalIter)operator(.)ident(next)operator(()operator(\))operator(.)ident(finalize)operator(()operator(\))operator(;) - ident(finalIter)operator(.)ident(remove)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - ident(getThreadService)operator(()operator(\))operator(.)ident(disposeCurrentThread)operator(()operator(\))operator(;) - - ident(getBeanManager)operator(()operator(\))operator(.)ident(unregisterCompiler)operator(()operator(\))operator(;) - ident(getBeanManager)operator(()operator(\))operator(.)ident(unregisterConfig)operator(()operator(\))operator(;) - ident(getBeanManager)operator(()operator(\))operator(.)ident(unregisterClassCache)operator(()operator(\))operator(;) - ident(getBeanManager)operator(()operator(\))operator(.)ident(unregisterMethodCache)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(status) operator(!=) integer(0)operator(\)) operator({) - keyword(throw) ident(newSystemExit)operator(()ident(status)operator(\))operator(;) - operator(}) - operator(}) - - comment(// new factory methods ------------------------------------------------------------------------) - - directive(public) ident(RubyArray) ident(newEmptyArray)operator(()operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newEmptyArray)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArrayLight)operator(()operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArrayLight)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(,) ident(object)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()ident(IRubyObject) ident(car)operator(,) ident(IRubyObject) ident(cdr)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(,) ident(car)operator(,) ident(cdr)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()ident(IRubyObject)type([]) ident(objects)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(,) ident(objects)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArrayNoCopy)operator(()ident(IRubyObject)type([]) ident(objects)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArrayNoCopy)operator(()local_variable(this)operator(,) ident(objects)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArrayNoCopyLight)operator(()ident(IRubyObject)type([]) ident(objects)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArrayNoCopyLight)operator(()local_variable(this)operator(,) ident(objects)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(list)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(,) ident(list)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(newArray)operator(()type(int) ident(size)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()local_variable(this)operator(,) ident(size)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyBoolean) ident(newBoolean)operator(()type(boolean) ident(value)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()local_variable(this)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFileStat) ident(newFileStat)operator(()pre_type(String) ident(filename)operator(,) type(boolean) ident(lstat)operator(\)) operator({) - keyword(return) ident(RubyFileStat)operator(.)ident(newFileStat)operator(()local_variable(this)operator(,) ident(filename)operator(,) ident(lstat)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFileStat) ident(newFileStat)operator(()pre_type(FileDescriptor) ident(descriptor)operator(\)) operator({) - keyword(return) ident(RubyFileStat)operator(.)ident(newFileStat)operator(()local_variable(this)operator(,) ident(descriptor)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFixnum) ident(newFixnum)operator(()type(long) ident(value)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()local_variable(this)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFixnum) ident(newFixnum)operator(()type(int) ident(value)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()local_variable(this)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFloat) ident(newFloat)operator(()type(double) ident(value)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()local_variable(this)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNumeric) ident(newNumeric)operator(()operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(newNumeric)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyProc) ident(newProc)operator(()ident(Block)operator(.)ident(Type) ident(type)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(type) operator(!=) ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA) operator(&&) ident(block)operator(.)ident(getProcObject)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(block)operator(.)ident(getProcObject)operator(()operator(\))operator(;) - - ident(RubyProc) ident(proc) operator(=) ident(RubyProc)operator(.)ident(newProc)operator(()local_variable(this)operator(,) ident(type)operator(\))operator(;) - - ident(proc)operator(.)ident(callInit)operator(()ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(block)operator(\))operator(;) - - keyword(return) ident(proc)operator(;) - operator(}) - - directive(public) ident(RubyProc) ident(newBlockPassProc)operator(()ident(Block)operator(.)ident(Type) ident(type)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(type) operator(!=) ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA) operator(&&) ident(block)operator(.)ident(getProcObject)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(block)operator(.)ident(getProcObject)operator(()operator(\))operator(;) - - ident(RubyProc) ident(proc) operator(=) ident(RubyProc)operator(.)ident(newProc)operator(()local_variable(this)operator(,) ident(type)operator(\))operator(;) - ident(proc)operator(.)ident(initialize)operator(()ident(getCurrentContext)operator(()operator(\))operator(,) ident(block)operator(\))operator(;) - - keyword(return) ident(proc)operator(;) - operator(}) - - directive(public) ident(RubyBinding) ident(newBinding)operator(()operator(\)) operator({) - keyword(return) ident(RubyBinding)operator(.)ident(newBinding)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyBinding) ident(newBinding)operator(()pre_type(Binding) ident(binding)operator(\)) operator({) - keyword(return) ident(RubyBinding)operator(.)ident(newBinding)operator(()local_variable(this)operator(,) ident(binding)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyString) ident(newString)operator(()operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()local_variable(this)operator(,) keyword(new) ident(ByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyString) ident(newString)operator(()pre_type(String) ident(string)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()local_variable(this)operator(,) ident(string)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyString) ident(newString)operator(()ident(ByteList) ident(byteList)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()local_variable(this)operator(,) ident(byteList)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) ident(RubyString) ident(newStringShared)operator(()ident(ByteList) ident(byteList)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newStringShared)operator(()local_variable(this)operator(,) ident(byteList)operator(\))operator(;) - operator(}) - - directive(public) ident(RubySymbol) ident(newSymbol)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(symbolTable)operator(.)ident(getSymbol)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Faster than {@link #newSymbol(String\)} if you already have an interned - * name String. Don't intern your string just to call this version - the - * overhead of interning will more than wipe out any benefit from the faster - * lookup. - * - * @param internedName the symbol name, <em>must</em> be interned! if in - * doubt, call {@link #newSymbol(String\)} instead. - * @return the symbol for name - */) - directive(public) ident(RubySymbol) ident(fastNewSymbol)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - - keyword(return) ident(symbolTable)operator(.)ident(fastGetSymbol)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyTime) ident(newTime)operator(()type(long) ident(milliseconds)operator(\)) operator({) - keyword(return) ident(RubyTime)operator(.)ident(newTime)operator(()local_variable(this)operator(,) ident(milliseconds)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newRuntimeError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getRuntimeError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newArgumentError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getArgumentError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newArgumentError)operator(()type(int) ident(got)operator(,) type(int) ident(expected)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getArgumentError)operator(()operator(\))operator(,) string<delimiter(")content(wrong # of arguments()delimiter(")> operator(+) ident(got) operator(+) string<delimiter(")content( for )delimiter(")> operator(+) ident(expected) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEBADFError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EBADF)delimiter(")>operator(\))operator(,) string<delimiter(")content(Bad file descriptor)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoENOPROTOOPTError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ENOPROTOOPT)delimiter(")>operator(\))operator(,) string<delimiter(")content(Protocol not available)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEPIPEError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EPIPE)delimiter(")>operator(\))operator(,) string<delimiter(")content(Broken pipe)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoECONNREFUSEDError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ECONNREFUSED)delimiter(")>operator(\))operator(,) string<delimiter(")content(Connection refused)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoECONNRESETError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ECONNRESET)delimiter(")>operator(\))operator(,) string<delimiter(")content(Connection reset by peer)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEADDRINUSEError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EADDRINUSE)delimiter(")>operator(\))operator(,) string<delimiter(")content(Address in use)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEINVALError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EINVAL)delimiter(")>operator(\))operator(,) string<delimiter(")content(Invalid file)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoENOENTError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ENOENT)delimiter(")>operator(\))operator(,) string<delimiter(")content(File not found)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEACCESError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EACCES)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEAGAINError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EAGAIN)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEISDirError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EISDIR)delimiter(")>operator(\))operator(,) string<delimiter(")content(Is a directory)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoESPIPEError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ESPIPE)delimiter(")>operator(\))operator(,) string<delimiter(")content(Illegal seek)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEBADFError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EBADF)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEINVALError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EINVAL)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoENOTDIRError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ENOTDIR)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoENOTSOCKError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ENOTSOCK)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoENOENTError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ENOENT)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoESPIPEError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ESPIPE)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEEXISTError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EEXIST)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoEDOMError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(EDOM)delimiter(")>operator(\))operator(,) string<delimiter(")content(Domain error - )delimiter(")> operator(+) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newErrnoECHILDError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getErrno)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(ECHILD)delimiter(")>operator(\))operator(,) string<delimiter(")content(No child processes)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newIndexError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getIndexError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newSecurityError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getSecurityError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newSystemCallError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getSystemCallError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newTypeError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getTypeError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newThreadError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getThreadError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newConcurrencyError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getConcurrencyError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newSyntaxError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getSyntaxError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newRegexpError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getRegexpError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newRangeError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getRangeError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newNotImplementedError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getNotImplementedError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newInvalidEncoding)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(fastGetClass)operator(()string<delimiter(")content(Iconv)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(InvalidEncoding)delimiter(")>operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newNoMethodError)operator(()pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(args)operator(\)) operator({) - keyword(return) keyword(new) ident(RaiseException)operator(()keyword(new) ident(RubyNoMethodError)operator(()local_variable(this)operator(,) ident(getNoMethodError)operator(()operator(\))operator(,) ident(message)operator(,) ident(name)operator(,) ident(args)operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newNameError)operator(()pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(newNameError)operator(()ident(message)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newNameError)operator(()pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(,) pre_type(Throwable) ident(origException)operator(\)) operator({) - keyword(return) ident(newNameError)operator(()ident(message)operator(,) ident(name)operator(,) ident(origException)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newNameError)operator(()pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(,) pre_type(Throwable) ident(origException)operator(,) type(boolean) ident(printWhenVerbose)operator(\)) operator({) - keyword(if) operator(()ident(printWhenVerbose) operator(&&) ident(origException) operator(!=) pre_constant(null) operator(&&) local_variable(this)operator(.)ident(getVerbose)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(origException)operator(.)ident(printStackTrace)operator(()ident(getErrorStream)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(RaiseException)operator(()keyword(new) ident(RubyNameError)operator(() - local_variable(this)operator(,) ident(getNameError)operator(()operator(\))operator(,) ident(message)operator(,) ident(name)operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newLocalJumpError)operator(()pre_type(String) ident(reason)operator(,) ident(IRubyObject) ident(exitValue)operator(,) pre_type(String) ident(message)operator(\)) operator({) - keyword(return) keyword(new) ident(RaiseException)operator(()keyword(new) ident(RubyLocalJumpError)operator(()local_variable(this)operator(,) ident(getLocalJumpError)operator(()operator(\))operator(,) ident(message)operator(,) ident(reason)operator(,) ident(exitValue)operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newRedoLocalJumpError)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(RaiseException)operator(()keyword(new) ident(RubyLocalJumpError)operator(()local_variable(this)operator(,) ident(getLocalJumpError)operator(()operator(\))operator(,) string<delimiter(")content(unexpected redo)delimiter(")>operator(,) string<delimiter(")content(redo)delimiter(")>operator(,) ident(getNil)operator(()operator(\))operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newLoadError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getLoadError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newFrozenError)operator(()pre_type(String) ident(objectType)operator(\)) operator({) - comment(// TODO: Should frozen error have its own distinct class? If not should more share?) - keyword(return) ident(newRaiseException)operator(()ident(getTypeError)operator(()operator(\))operator(,) string<delimiter(")content(can't modify frozen )delimiter(")> operator(+) ident(objectType)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newSystemStackError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getSystemStackError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newSystemExit)operator(()type(int) ident(status)operator(\)) operator({) - keyword(return) keyword(new) ident(RaiseException)operator(()ident(RubySystemExit)operator(.)ident(newInstance)operator(()local_variable(this)operator(,) ident(status)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newIOError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getIOError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newStandardError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getStandardError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newIOErrorFromException)operator(()exception(IOException) ident(ioe)operator(\)) operator({) - comment(// TODO: this is kinda gross) - keyword(if)operator(()ident(ioe)operator(.)ident(getMessage)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(ioe)operator(.)ident(getMessage)operator(()operator(\))operator(.)ident(equals)operator(()string<delimiter(")content(Broken pipe)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(ioe)operator(.)ident(getMessage)operator(()operator(\))operator(.)ident(equals)operator(()string<delimiter(")content(Connection reset by peer)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(newErrnoECONNRESETError)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(newRaiseException)operator(()ident(getIOError)operator(()operator(\))operator(,) ident(ioe)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getIOError)operator(()operator(\))operator(,) string<delimiter(")content(IO Error)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(RaiseException) ident(newTypeError)operator(()ident(IRubyObject) ident(receivedObject)operator(,) ident(RubyClass) ident(expectedType)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getTypeError)operator(()operator(\))operator(,) string<delimiter(")content(wrong argument type )delimiter(")> operator(+) - ident(receivedObject)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected )delimiter(")> operator(+) ident(expectedType) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newEOFError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getEOFError)operator(()operator(\))operator(,) string<delimiter(")content(End of file reached)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newEOFError)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getEOFError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newZeroDivisionError)operator(()operator(\)) operator({) - keyword(return) ident(newRaiseException)operator(()ident(getZeroDivisionError)operator(()operator(\))operator(,) string<delimiter(")content(divided by 0)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(RaiseException) ident(newFloatDomainError)operator(()pre_type(String) ident(message)operator(\))operator({) - keyword(return) ident(newRaiseException)operator(()ident(getFloatDomainError)operator(()operator(\))operator(,) ident(message)operator(\))operator(;) - operator(}) - - comment(/** - * @param exceptionClass - * @param message - * @return - */) - directive(private) ident(RaiseException) ident(newRaiseException)operator(()ident(RubyClass) ident(exceptionClass)operator(,) pre_type(String) ident(message)operator(\)) operator({) - ident(RaiseException) ident(re) operator(=) keyword(new) ident(RaiseException)operator(()local_variable(this)operator(,) ident(exceptionClass)operator(,) ident(message)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) ident(re)operator(;) - operator(}) - - - directive(public) ident(RubySymbol)operator(.)ident(SymbolTable) ident(getSymbolTable)operator(()operator(\)) operator({) - keyword(return) ident(symbolTable)operator(;) - operator(}) - - directive(public) type(void) ident(setStackTraces)operator(()type(int) ident(stackTraces)operator(\)) operator({) - local_variable(this)operator(.)ident(stackTraces) operator(=) ident(stackTraces)operator(;) - operator(}) - - directive(public) type(int) ident(getStackTraces)operator(()operator(\)) operator({) - keyword(return) ident(stackTraces)operator(;) - operator(}) - - directive(public) type(void) ident(setRandomSeed)operator(()type(long) ident(randomSeed)operator(\)) operator({) - local_variable(this)operator(.)ident(randomSeed) operator(=) ident(randomSeed)operator(;) - operator(}) - - directive(public) type(long) ident(getRandomSeed)operator(()operator(\)) operator({) - keyword(return) ident(randomSeed)operator(;) - operator(}) - - directive(public) pre_type(Random) ident(getRandom)operator(()operator(\)) operator({) - keyword(return) ident(random)operator(;) - operator(}) - - directive(public) ident(ObjectSpace) ident(getObjectSpace)operator(()operator(\)) operator({) - keyword(return) ident(objectSpace)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(Integer)operator(,) pre_type(WeakReference)operator(<)ident(ChannelDescriptor)operator(>)operator(>) ident(getDescriptors)operator(()operator(\)) operator({) - keyword(return) ident(descriptors)operator(;) - operator(}) - - directive(public) type(long) ident(incrementRandomSeedSequence)operator(()operator(\)) operator({) - keyword(return) ident(randomSeedSequence)operator(++)operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getIn)operator(()operator(\)) operator({) - keyword(return) ident(in)operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getOut)operator(()operator(\)) operator({) - keyword(return) ident(out)operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getErr)operator(()operator(\)) operator({) - keyword(return) ident(err)operator(;) - operator(}) - - directive(public) type(boolean) ident(isGlobalAbortOnExceptionEnabled)operator(()operator(\)) operator({) - keyword(return) ident(globalAbortOnExceptionEnabled)operator(;) - operator(}) - - directive(public) type(void) ident(setGlobalAbortOnExceptionEnabled)operator(()type(boolean) ident(enable)operator(\)) operator({) - ident(globalAbortOnExceptionEnabled) operator(=) ident(enable)operator(;) - operator(}) - - directive(public) type(boolean) ident(isDoNotReverseLookupEnabled)operator(()operator(\)) operator({) - keyword(return) ident(doNotReverseLookupEnabled)operator(;) - operator(}) - - directive(public) type(void) ident(setDoNotReverseLookupEnabled)operator(()type(boolean) ident(b)operator(\)) operator({) - ident(doNotReverseLookupEnabled) operator(=) ident(b)operator(;) - operator(}) - - directive(private) pre_type(ThreadLocal)operator(<)pre_type(Map)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>)operator(>) ident(inspect) operator(=) keyword(new) pre_type(ThreadLocal)operator(<)pre_type(Map)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>)operator(>)operator(()operator(\))operator(;) - directive(public) type(void) ident(registerInspecting)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - pre_type(Map)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>) ident(val) operator(=) ident(inspect)operator(.)ident(get)operator(()operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) ident(inspect)operator(.)ident(set)operator(()ident(val) operator(=) keyword(new) pre_type(IdentityHashMap)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>)operator(()operator(\))operator(\))operator(;) - ident(val)operator(.)ident(put)operator(()ident(obj)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(isInspecting)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - pre_type(Map)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>) ident(val) operator(=) ident(inspect)operator(.)ident(get)operator(()operator(\))operator(;) - keyword(return) ident(val) operator(==) pre_constant(null) operator(?) pre_constant(false) operator(:) ident(val)operator(.)ident(containsKey)operator(()ident(obj)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(unregisterInspecting)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - pre_type(Map)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>) ident(val) operator(=) ident(inspect)operator(.)ident(get)operator(()operator(\))operator(;) - keyword(if) operator(()ident(val) operator(!=) pre_constant(null) operator(\)) ident(val)operator(.)ident(remove)operator(()ident(obj)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(isObjectSpaceEnabled)operator(()operator(\)) operator({) - keyword(return) ident(objectSpaceEnabled)operator(;) - operator(}) - - comment(// The method is intentionally not public, since it typically should) - comment(// not be used outside of the core.) - comment(/* package-private */) type(void) ident(setObjectSpaceEnabled)operator(()type(boolean) ident(objectSpaceEnabled)operator(\)) operator({) - local_variable(this)operator(.)ident(objectSpaceEnabled) operator(=) ident(objectSpaceEnabled)operator(;) - operator(}) - - directive(public) type(long) ident(getStartTime)operator(()operator(\)) operator({) - keyword(return) ident(startTime)operator(;) - operator(}) - - directive(public) ident(Profile) ident(getProfile)operator(()operator(\)) operator({) - keyword(return) ident(profile)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getJRubyHome)operator(()operator(\)) operator({) - keyword(return) ident(config)operator(.)ident(getJRubyHome)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setJRubyHome)operator(()pre_type(String) ident(home)operator(\)) operator({) - ident(config)operator(.)ident(setJRubyHome)operator(()ident(home)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyInstanceConfig) ident(getInstanceConfig)operator(()operator(\)) operator({) - keyword(return) ident(config)operator(;) - operator(}) - - comment(/** GET_VM_STATE_VERSION */) - directive(public) type(long) ident(getGlobalState)operator(()operator(\)) operator({) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - keyword(return) ident(globalState)operator(;) - operator(}) - operator(}) - - comment(/** INC_VM_STATE_VERSION */) - directive(public) type(void) ident(incGlobalState)operator(()operator(\)) operator({) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - ident(globalState) operator(=) operator(()ident(globalState)operator(+)integer(1)operator(\)) operator(&) hex(0x8fffffff)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(boolean) ident(isSecurityRestricted)operator(()operator(\)) operator({) - keyword(return) ident(securityRestricted)operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(setSecurityRestricted)operator(()type(boolean) ident(restricted)operator(\)) operator({) - ident(securityRestricted) operator(=) ident(restricted)operator(;) - operator(}) - - directive(public) ident(POSIX) ident(getPosix)operator(()operator(\)) operator({) - keyword(return) ident(posix)operator(;) - operator(}) - - directive(public) type(void) ident(setRecordSeparatorVar)operator(()ident(GlobalVariable) ident(recordSeparatorVar)operator(\)) operator({) - local_variable(this)operator(.)ident(recordSeparatorVar) operator(=) ident(recordSeparatorVar)operator(;) - operator(}) - - directive(public) ident(GlobalVariable) ident(getRecordSeparatorVar)operator(()operator(\)) operator({) - keyword(return) ident(recordSeparatorVar)operator(;) - operator(}) - - directive(public) pre_type(Set)operator(<)ident(Script)operator(>) ident(getJittedMethods)operator(()operator(\)) operator({) - keyword(return) ident(jittedMethods)operator(;) - operator(}) - - directive(public) pre_type(ExecutorService) ident(getExecutor)operator(()operator(\)) operator({) - keyword(return) ident(executor)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) ident(DateTimeZone)operator(>) ident(getLocalTimezoneCache)operator(()operator(\)) operator({) - keyword(return) ident(localTimeZoneCache)operator(;) - operator(}) - - directive(private) directive(final) ident(CacheMap) ident(cacheMap)operator(;) - directive(private) directive(final) ident(ThreadService) ident(threadService)operator(;) - directive(private) pre_type(Hashtable)operator(<)pre_type(Object)operator(,) pre_type(Object)operator(>) ident(runtimeInformation)operator(;) - - directive(private) ident(POSIX) ident(posix)operator(;) - - directive(private) type(int) ident(stackTraces) operator(=) integer(0)operator(;) - - directive(private) ident(ObjectSpace) ident(objectSpace) operator(=) keyword(new) ident(ObjectSpace)operator(()operator(\))operator(;) - - directive(private) directive(final) ident(RubySymbol)operator(.)ident(SymbolTable) ident(symbolTable) operator(=) keyword(new) ident(RubySymbol)operator(.)ident(SymbolTable)operator(()local_variable(this)operator(\))operator(;) - directive(private) pre_type(Map)operator(<)pre_type(Integer)operator(,) pre_type(WeakReference)operator(<)ident(ChannelDescriptor)operator(>)operator(>) ident(descriptors) operator(=) keyword(new) pre_type(ConcurrentHashMap)operator(<)pre_type(Integer)operator(,) pre_type(WeakReference)operator(<)ident(ChannelDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - directive(private) type(long) ident(randomSeed) operator(=) integer(0)operator(;) - directive(private) type(long) ident(randomSeedSequence) operator(=) integer(0)operator(;) - directive(private) pre_type(Random) ident(random) operator(=) keyword(new) pre_type(Random)operator(()operator(\))operator(;) - - directive(private) pre_type(List)operator(<)ident(EventHook)operator(>) ident(eventHooks) operator(=) keyword(new) pre_type(Vector)operator(<)ident(EventHook)operator(>)operator(()operator(\))operator(;) - directive(private) type(boolean) ident(hasEventHooks)operator(;) - directive(private) type(boolean) ident(globalAbortOnExceptionEnabled) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(doNotReverseLookupEnabled) operator(=) pre_constant(false)operator(;) - directive(private) directive(volatile) type(boolean) ident(objectSpaceEnabled)operator(;) - - directive(private) directive(final) pre_type(Set)operator(<)ident(Script)operator(>) ident(jittedMethods) operator(=) pre_type(Collections)operator(.)ident(synchronizedSet)operator(()keyword(new) ident(WeakHashSet)operator(<)ident(Script)operator(>)operator(()operator(\))operator(\))operator(;) - - directive(private) directive(static) pre_type(ThreadLocal)operator(<)ident(Ruby)operator(>) ident(currentRuntime) operator(=) keyword(new) pre_type(ThreadLocal)operator(<)ident(Ruby)operator(>)operator(()operator(\))operator(;) - - directive(private) type(long) ident(globalState) operator(=) integer(1)operator(;) - - directive(private) type(int) ident(safeLevel) operator(=) operator(-)integer(1)operator(;) - - comment(// Default objects) - directive(private) ident(IRubyObject) ident(topSelf)operator(;) - directive(private) ident(RubyNil) ident(nilObject)operator(;) - directive(private) ident(RubyBoolean) ident(trueObject)operator(;) - directive(private) ident(RubyBoolean) ident(falseObject)operator(;) - directive(public) directive(final) ident(RubyFixnum)type([]) ident(fixnumCache) operator(=) keyword(new) ident(RubyFixnum)operator([)integer(256)operator(])operator(;) - - directive(private) ident(IRubyObject) ident(verbose)operator(;) - directive(private) ident(IRubyObject) ident(debug)operator(;) - - directive(private) ident(RubyThreadGroup) ident(defaultThreadGroup)operator(;) - - comment(/** - * All the core classes we keep hard references to. These are here largely - * so that if someone redefines String or Array we won't start blowing up - * creating strings and arrays internally. They also provide much faster - * access than going through normal hash lookup on the Object class. - */) - directive(private) ident(RubyClass) - ident(objectClass)operator(,) ident(moduleClass)operator(,) ident(classClass)operator(,) ident(nilClass)operator(,) ident(trueClass)operator(,) - ident(falseClass)operator(,) ident(numericClass)operator(,) ident(floatClass)operator(,) ident(integerClass)operator(,) ident(fixnumClass)operator(,) - ident(complexClass)operator(,) ident(rationalClass)operator(,) ident(enumeratorClass)operator(,) - ident(arrayClass)operator(,) ident(hashClass)operator(,) ident(rangeClass)operator(,) ident(stringClass)operator(,) ident(symbolClass)operator(,) - ident(procClass)operator(,) ident(bindingClass)operator(,) ident(methodClass)operator(,) ident(unboundMethodClass)operator(,) - ident(matchDataClass)operator(,) ident(regexpClass)operator(,) ident(timeClass)operator(,) ident(bignumClass)operator(,) ident(dirClass)operator(,) - ident(fileClass)operator(,) ident(fileStatClass)operator(,) ident(ioClass)operator(,) ident(threadClass)operator(,) ident(threadGroupClass)operator(,) - ident(continuationClass)operator(,) ident(structClass)operator(,) ident(tmsStruct)operator(,) ident(passwdStruct)operator(,) - ident(groupStruct)operator(,) ident(procStatusClass)operator(,) ident(exceptionClass)operator(,) ident(runtimeError)operator(,) ident(ioError)operator(,) - ident(scriptError)operator(,) ident(nameError)operator(,) ident(nameErrorMessage)operator(,) ident(noMethodError)operator(,) ident(signalException)operator(,) - ident(rangeError)operator(,) ident(dummyClass)operator(,) ident(systemExit)operator(,) ident(localJumpError)operator(,) ident(nativeException)operator(,) - ident(systemCallError)operator(,) ident(fatal)operator(,) ident(interrupt)operator(,) ident(typeError)operator(,) ident(argumentError)operator(,) ident(indexError)operator(,) - ident(syntaxError)operator(,) ident(standardError)operator(,) ident(loadError)operator(,) ident(notImplementedError)operator(,) ident(securityError)operator(,) ident(noMemoryError)operator(,) - ident(regexpError)operator(,) ident(eofError)operator(,) ident(threadError)operator(,) ident(concurrencyError)operator(,) ident(systemStackError)operator(,) ident(zeroDivisionError)operator(,) ident(floatDomainError)operator(;) - - comment(/** - * All the core modules we keep direct references to, for quick access and - * to ensure they remain available. - */) - directive(private) ident(RubyModule) - ident(kernelModule)operator(,) ident(comparableModule)operator(,) ident(enumerableModule)operator(,) ident(mathModule)operator(,) - ident(marshalModule)operator(,) ident(etcModule)operator(,) ident(fileTestModule)operator(,) ident(gcModule)operator(,) - ident(objectSpaceModule)operator(,) ident(processModule)operator(,) ident(procUIDModule)operator(,) ident(procGIDModule)operator(,) - ident(procSysModule)operator(,) ident(precisionModule)operator(,) ident(errnoModule)operator(;) - - comment(// record separator var, to speed up io ops that use it) - directive(private) ident(GlobalVariable) ident(recordSeparatorVar)operator(;) - - comment(// former java.lang.System concepts now internalized for MVM) - directive(private) pre_type(String) ident(currentDirectory)operator(;) - - directive(private) type(long) ident(startTime) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - - directive(private) ident(RubyInstanceConfig) ident(config)operator(;) - - directive(private) pre_type(InputStream) ident(in)operator(;) - directive(private) pre_type(PrintStream) ident(out)operator(;) - directive(private) pre_type(PrintStream) ident(err)operator(;) - - comment(// Java support) - directive(private) ident(JavaSupport) ident(javaSupport)operator(;) - directive(private) ident(JRubyClassLoader) ident(jrubyClassLoader)operator(;) - - comment(// Management/monitoring) - directive(private) ident(BeanManager) ident(beanManager)operator(;) - - comment(// Compilation) - directive(private) directive(final) ident(JITCompiler) ident(jitCompiler)operator(;) - - comment(// Note: this field and the following static initializer) - comment(// must be located be in this order!) - directive(private) directive(volatile) directive(static) type(boolean) ident(securityRestricted) operator(=) pre_constant(false)operator(;) - directive(static) operator({) - keyword(if) operator(()ident(SafePropertyAccessor)operator(.)ident(isSecurityProtected)operator(()string<delimiter(")content(jruby.reflection)delimiter(")>operator(\))operator(\)) operator({) - comment(// can't read non-standard properties) - ident(securityRestricted) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - pre_type(SecurityManager) ident(sm) operator(=) pre_type(System)operator(.)ident(getSecurityManager)operator(()operator(\))operator(;) - keyword(if) operator(()ident(sm) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(sm)operator(.)ident(checkCreateClassLoader)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(SecurityException) ident(se)operator(\)) operator({) - comment(// can't create custom classloaders) - ident(securityRestricted) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - directive(private) pre_type(Parser) ident(parser) operator(=) keyword(new) pre_type(Parser)operator(()local_variable(this)operator(\))operator(;) - - directive(private) ident(LoadService) ident(loadService)operator(;) - directive(private) ident(GlobalVariables) ident(globalVariables) operator(=) keyword(new) ident(GlobalVariables)operator(()local_variable(this)operator(\))operator(;) - directive(private) ident(RubyWarnings) ident(warnings) operator(=) keyword(new) ident(RubyWarnings)operator(()local_variable(this)operator(\))operator(;) - - comment(// Contains a list of all blocks (as Procs\) that should be called when) - comment(// the runtime environment exits.) - directive(private) pre_type(Stack)operator(<)ident(RubyProc)operator(>) ident(atExitBlocks) operator(=) keyword(new) pre_type(Stack)operator(<)ident(RubyProc)operator(>)operator(()operator(\))operator(;) - - directive(private) ident(Profile) ident(profile)operator(;) - - directive(private) ident(KCode) ident(kcode) operator(=) ident(KCode)operator(.)ident(NONE)operator(;) - - comment(// Atomic integers for symbol and method IDs) - directive(private) pre_type(AtomicInteger) ident(symbolLastId) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(128)operator(\))operator(;) - directive(private) pre_type(AtomicInteger) ident(moduleLastId) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(0)operator(\))operator(;) - - directive(private) pre_type(Object) ident(respondToMethod)operator(;) - directive(private) pre_type(Object) ident(objectToYamlMethod)operator(;) - - directive(private) pre_type(Map)operator(<)pre_type(String)operator(,) ident(DateTimeZone)operator(>) ident(localTimeZoneCache) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,)ident(DateTimeZone)operator(>)operator(()operator(\))operator(;) - comment(/** - * A list of "external" finalizers (the ones, registered via ObjectSpace\), - * weakly referenced, to be executed on tearDown. - */) - directive(private) pre_type(Map)operator(<)ident(Finalizable)operator(,) pre_type(Object)operator(>) ident(finalizers)operator(;) - - comment(/** - * A list of JRuby-internal finalizers, weakly referenced, - * to be executed on tearDown. - */) - directive(private) pre_type(Map)operator(<)ident(Finalizable)operator(,) pre_type(Object)operator(>) ident(internalFinalizers)operator(;) - - comment(// mutex that controls modifications of user-defined finalizers) - directive(private) directive(final) pre_type(Object) ident(finalizersMutex) operator(=) keyword(new) pre_type(Object)operator(()operator(\))operator(;) - - comment(// mutex that controls modifications of internal finalizers) - directive(private) directive(final) pre_type(Object) ident(internalFinalizersMutex) operator(=) keyword(new) pre_type(Object)operator(()operator(\))operator(;) - - comment(// A thread pool to use for executing this runtime's Ruby threads) - directive(private) pre_type(ExecutorService) ident(executor)operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.FrameField)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -directive(public) type(class) class(RubyArgsFile) operator({) - directive(private) directive(static) directive(final) type(class) class(ArgsFileData) operator({) - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - directive(public) ident(ArgsFileData)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(currentFile)operator(;) - directive(public) type(int) ident(currentLineNumber)operator(;) - directive(public) type(boolean) ident(startedProcessing) operator(=) pre_constant(false)operator(;) - directive(public) type(boolean) ident(finishedProcessing) operator(=) pre_constant(false)operator(;) - - directive(public) type(boolean) ident(nextArgsFile)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(finishedProcessing)operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - ident(RubyArray) ident(args) operator(=) operator(()ident(RubyArray)operator(\))ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($*)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(getLength)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(startedProcessing)operator(\)) operator({) - ident(currentFile) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stdin)delimiter(")>operator(\))operator(;) - operator(()operator(()ident(RubyString)operator(\)) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($FILENAME)delimiter(")>operator(\))operator(\))operator(.)ident(setValue)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(-)delimiter(')>operator(})operator(\))operator(\))operator(;) - ident(currentLineNumber) operator(=) integer(0)operator(;) - ident(startedProcessing) operator(=) pre_constant(true)operator(;) - keyword(return) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - ident(finishedProcessing) operator(=) pre_constant(true)operator(;) - keyword(return) pre_constant(false)operator(;) - operator(}) - operator(}) - - ident(IRubyObject) ident(arg) operator(=) ident(args)operator(.)ident(shift)operator(()operator(\))operator(;) - ident(RubyString) ident(filename) operator(=) operator(()ident(RubyString)operator(\))operator(()operator(()ident(RubyObject)operator(\))ident(arg)operator(\))operator(.)ident(to_s)operator(()operator(\))operator(;) - ident(ByteList) ident(filenameBytes) operator(=) ident(filename)operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(()operator(()ident(RubyString)operator(\)) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($FILENAME)delimiter(")>operator(\))operator(\))operator(.)ident(setValue)operator(()ident(filenameBytes)operator(\))operator(;) - - keyword(if) operator(()ident(filenameBytes)operator(.)ident(length)operator(()operator(\)) operator(==) integer(1) operator(&&) ident(filenameBytes)operator(.)ident(get)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(-)delimiter(')>operator(\)) operator({) - ident(currentFile) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stdin)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(currentFile) operator(=) ident(RubyFile)operator(.)ident(open)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,) - keyword(new) ident(IRubyObject)type([]) operator({)ident(filename)operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - ident(startedProcessing) operator(=) pre_constant(true)operator(;) - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(public) directive(static) ident(ArgsFileData) ident(getDataFrom)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) operator(()ident(ArgsFileData)operator(\))ident(recv)operator(.)ident(dataGetStruct)operator(()operator(\))operator(;) - keyword(if)operator(()ident(data) operator(==) pre_constant(null)operator(\)) operator({) - ident(data) operator(=) keyword(new) ident(ArgsFileData)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(recv)operator(.)ident(dataWrapStruct)operator(()ident(data)operator(\))operator(;) - operator(}) - keyword(return) ident(data)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(void) ident(setCurrentLineNumber)operator(()ident(IRubyObject) ident(recv)operator(,) type(int) ident(newLineNumber)operator(\)) operator({) - ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(.)ident(currentLineNumber) operator(=) ident(newLineNumber)operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(initArgsFile)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyObject) ident(argsFile) operator(=) keyword(new) ident(RubyObject)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(.)ident(extend_object)operator(()ident(argsFile)operator(\))operator(;) - - ident(runtime)operator(.)ident(defineReadonlyVariable)operator(()string<delimiter(")content($<)delimiter(")>operator(,) ident(argsFile)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(ARGF)delimiter(")>operator(,) ident(argsFile)operator(\))operator(;) - - ident(RubyClass) ident(argfClass) operator(=) ident(argsFile)operator(.)ident(getMetaClass)operator(()operator(\))operator(;) - ident(argfClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyArgsFile)operator(.)ident(class)operator(\))operator(;) - ident(runtime)operator(.)ident(defineReadonlyVariable)operator(()string<delimiter(")content($FILENAME)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(-)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(fileno)delimiter(")>operator(,) string<delimiter(")content(to_i)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(fileno)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - - keyword(if) operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\)) ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(fileno)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_io)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(to_io)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - - keyword(if) operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(data)operator(.)ident(currentFile)operator(;) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(internalGets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(line) operator(=) ident(data)operator(.)ident(currentFile)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(gets)delimiter(")>operator(,) ident(args)operator(\))operator(;) - - keyword(while) operator(()ident(line) keyword(instanceof) ident(RubyNil)operator(\)) operator({) - ident(data)operator(.)ident(currentFile)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(close)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - ident(data)operator(.)ident(currentFile) operator(=) pre_constant(null)operator(;) - keyword(return) ident(line)operator(;) - operator(}) - ident(line) operator(=) ident(data)operator(.)ident(currentFile)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(gets)delimiter(")>operator(,) ident(args)operator(\))operator(;) - operator(}) - - ident(data)operator(.)ident(currentLineNumber)operator(++)operator(;) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($.)delimiter(")>operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(data)operator(.)ident(currentLineNumber)operator(\))operator(\))operator(;) - - keyword(return) ident(line)operator(;) - operator(}) - - comment(// ARGF methods) - - comment(/** Read a line. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gets)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(result)operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** Read a line. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readline)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(readline)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(line)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(readlines)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject)type([]) ident(separatorArgument)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNilClass)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(args)operator([)integer(0)operator(])operator(\)) operator(&&) - operator(!)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(separatorArgument) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(args)operator([)integer(0)operator(]) operator(})operator(;) - operator(}) keyword(else) operator({) - ident(separatorArgument) operator(=) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(;) - operator(}) - - ident(RubyArray) ident(result) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(line)operator(;) - keyword(while) operator(()operator(!) operator(()ident(line) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(separatorArgument)operator(\))operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(line)operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_byte)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_byte)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject) ident(bt)operator(;) - - keyword(while)operator(()operator(!)operator(()ident(bt) operator(=) ident(getc)operator(()ident(context)operator(,) ident(recv)operator(\))operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(bt)operator(\))operator(;) - operator(}) - - keyword(return) ident(recv)operator(;) - operator(}) - - comment(/** Invoke a block for each line. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_line)delimiter(")>operator(,) ident(alias) operator(=) operator({)string<delimiter(")content(each)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_line)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject) ident(nextLine) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - - keyword(while) operator(()operator(!)ident(nextLine)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(nextLine)operator(\))operator(;) - ident(nextLine) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(file)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(file)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(data)operator(.)ident(currentFile)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(skip)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(skip)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - ident(data)operator(.)ident(currentFile) operator(=) pre_constant(null)operator(;) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(close)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(;) - operator(}) - ident(data)operator(.)ident(currentFile) operator(=) pre_constant(null)operator(;) - ident(data)operator(.)ident(currentLineNumber) operator(=) integer(0)operator(;) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed?)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(closed_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(closed_p)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(binmode)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(binmode)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(binmode)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(lineno)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(.)ident(currentLineNumber)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tell)delimiter(")>operator(,) ident(alias) operator(=) operator({)string<delimiter(")content(pos)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(tell)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream to tell)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(pos)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rewind)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rewind)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream to rewind)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(rewind)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(eof)delimiter(")>operator(,) string<delimiter(")content(eof?)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eof)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if) operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - keyword(return) operator(()operator(()ident(RubyIO)operator(\)) ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(eof_p)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(set_pos)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(offset)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream to set position)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(pos_set)operator(()ident(context)operator(,) ident(offset)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seek)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(seek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no stream to seek)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(seek)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(set_lineno)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(line)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - ident(data)operator(.)ident(currentLineNumber) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(line)operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readchar)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(readchar)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(IRubyObject) ident(c) operator(=) ident(getc)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - - keyword(if)operator(()ident(c)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(c)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getc)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - ident(IRubyObject) ident(bt)operator(;) - keyword(while)operator(()pre_constant(true)operator(\)) operator({) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)operator(()ident(data)operator(.)ident(currentFile) keyword(instanceof) ident(RubyFile)operator(\))operator(\)) operator({) - ident(bt) operator(=) ident(data)operator(.)ident(currentFile)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(getc)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(bt) operator(=) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(getc)operator(()operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(bt)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(data)operator(.)ident(currentFile) operator(=) pre_constant(null)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(return) ident(bt)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ArgsFileData) ident(data) operator(=) ident(ArgsFileData)operator(.)ident(getDataFrom)operator(()ident(recv)operator(\))operator(;) - ident(IRubyObject) ident(tmp)operator(,) ident(str)operator(,) ident(length)operator(;) - type(long) ident(len) operator(=) integer(0)operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(length) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(str) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) keyword(else) operator({) - ident(str) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(length) operator(=) ident(str) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(if)operator(()operator(!)ident(length)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(len) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(length)operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(str) operator(=) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(modify)operator(()operator(\))operator(;) - operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()integer(0)operator(\))operator(;) - ident(args)operator([)integer(1)operator(]) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(while)operator(()pre_constant(true)operator(\)) operator({) - keyword(if)operator(()ident(data)operator(.)ident(currentFile) operator(==) pre_constant(null) operator(&&) operator(!)ident(data)operator(.)ident(nextArgsFile)operator(()ident(context)operator(\))operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - keyword(if)operator(()operator(!)operator(()ident(data)operator(.)ident(currentFile) keyword(instanceof) ident(RubyIO)operator(\))operator(\)) operator({) - ident(tmp) operator(=) ident(data)operator(.)ident(currentFile)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(read)delimiter(")>operator(,) ident(args)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(tmp) operator(=) operator(()operator(()ident(RubyIO)operator(\))ident(data)operator(.)ident(currentFile)operator(\))operator(.)ident(read)operator(()ident(args)operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(str) operator(=) ident(tmp)operator(;) - operator(}) keyword(else) keyword(if)operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(append)operator(()ident(tmp)operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(length)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(data)operator(.)ident(currentFile) operator(=) pre_constant(null)operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(args)operator(.)ident(length) operator(>=) integer(1)operator(\)) operator({) - keyword(if)operator(()operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(<) ident(len)operator(\)) operator({) - ident(len) operator(-=) operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - ident(args)operator([)integer(0)operator(]) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(len)operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) - keyword(return) ident(str)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(filename)delimiter(")>operator(,) ident(alias) operator(=) operator({)string<delimiter(")content(path)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(RubyString) ident(filename)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) operator(()ident(RubyString)operator(\)) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($FILENAME)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(to_s)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(ARGF)delimiter(")>operator(\))operator(;) - operator(}) -operator(}) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Ola Bini <Ola.Bini@ki.se> - * Copyright (C\) 2006 Daniel Steer <damian.steer@hp.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.reflect.Array)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.Arrays)operator(;) -keyword(import) include(java.util.Collection)operator(;) -keyword(import) include(java.util.Comparator)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.ListIterator)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.Pack)operator(;) - -comment(/** - * The implementation of the built-in class Array in Ruby. - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Array)delimiter(")>operator(\)) -directive(public) type(class) class(RubyArray) directive(extends) ident(RubyObject) directive(implements) pre_type(List) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createArrayClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(arrayc) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Array)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ARRAY_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setArray)operator(()ident(arrayc)operator(\))operator(;) - ident(arrayc)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(ARRAY)operator(;) - ident(arrayc)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyArray)operator(;) - operator(}) - operator(})operator(;) - - ident(arrayc)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - ident(arrayc)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyArray)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(arrayc)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(ARRAY_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(ARRAY)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(concurrentModification)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newConcurrencyError)operator(()string<delimiter(")content(Detected invalid array contents due to unsynchronized modifications with concurrent users)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_ary_s_create - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(create)operator(()ident(IRubyObject) ident(klass)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) operator(()ident(RubyArray)operator(\)) operator(()operator(()ident(RubyClass)operator(\)) ident(klass)operator(\))operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(arr)operator(.)ident(callInit)operator(()ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(block)operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(arr)operator(.)ident(alloc)operator(()ident(args)operator(.)ident(length)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(arr)operator(.)ident(values)operator(,) integer(0)operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - ident(arr)operator(.)ident(realLength) operator(=) ident(args)operator(.)ident(length)operator(;) - operator(}) - keyword(return) ident(arr)operator(;) - operator(}) - - comment(/** rb_ary_new2 - * - */) - directive(public) directive(static) directive(final) ident(RubyArray) ident(newArray)operator(()directive(final) ident(Ruby) ident(runtime)operator(,) directive(final) type(long) ident(len)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(len)operator(\))operator(;) - operator(}) - directive(public) directive(static) directive(final) ident(RubyArray) ident(newArrayLight)operator(()directive(final) ident(Ruby) ident(runtime)operator(,) directive(final) type(long) ident(len)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(len)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_new - * - */) - directive(public) directive(static) directive(final) ident(RubyArray) ident(newArray)operator(()directive(final) ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_new - * - */) - directive(public) directive(static) directive(final) ident(RubyArray) ident(newArrayLight)operator(()directive(final) ident(Ruby) ident(runtime)operator(\)) operator({) - comment(/* Ruby arrays default to holding 16 elements, so we create an - * ArrayList of the same size if we're not told otherwise - */) - ident(RubyArray) ident(arr) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) pre_constant(false)operator(\))operator(;) - ident(arr)operator(.)ident(alloc)operator(()ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(obj) operator(})operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArrayLight)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(obj) operator(})operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_assoc_new - * - */) - directive(public) directive(static) ident(RubyArray) ident(newArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(car)operator(,) ident(IRubyObject) ident(cdr)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(car)operator(,) ident(cdr) operator(})operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newEmptyArray)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(NULL_ARRAY)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_new4, rb_ary_new3 - * - */) - directive(public) directive(static) ident(RubyArray) ident(newArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(arr)operator(.)ident(values)operator(,) integer(0)operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - ident(arr)operator(.)ident(realLength) operator(=) ident(args)operator(.)ident(length)operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArrayNoCopy)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(args)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArrayNoCopy)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) type(int) ident(begin)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(args)operator(,) ident(begin)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArrayNoCopyLight)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) pre_constant(false)operator(\))operator(;) - ident(arr)operator(.)ident(values) operator(=) ident(args)operator(;) - ident(arr)operator(.)ident(realLength) operator(=) ident(args)operator(.)ident(length)operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(newArray)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Collection) ident(collection)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(collection)operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - ident(collection)operator(.)ident(toArray)operator(()ident(arr)operator(.)ident(values)operator(\))operator(;) - ident(arr)operator(.)ident(realLength) operator(=) ident(arr)operator(.)ident(values)operator(.)ident(length)operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - directive(public) directive(static) directive(final) type(int) ident(ARRAY_DEFAULT_SIZE) operator(=) integer(16)operator(;) - - comment(// volatile to ensure that initial nil-fill is visible to other threads) - directive(private) directive(volatile) ident(IRubyObject)type([]) ident(values)operator(;) - - directive(private) directive(static) directive(final) type(int) ident(TMPLOCK_ARR_F) operator(=) integer(1) operator(<)operator(<) integer(9)operator(;) - directive(private) directive(static) directive(final) type(int) ident(TMPLOCK_OR_FROZEN_ARR_F) operator(=) ident(TMPLOCK_ARR_F) operator(|) ident(FROZEN_F)operator(;) - - directive(private) directive(volatile) type(boolean) ident(isShared) operator(=) pre_constant(false)operator(;) - directive(private) type(int) ident(begin) operator(=) integer(0)operator(;) - directive(private) type(int) ident(realLength) operator(=) integer(0)operator(;) - - comment(/* - * plain internal array assignment - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(vals)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - ident(values) operator(=) ident(vals)operator(;) - ident(realLength) operator(=) ident(vals)operator(.)ident(length)operator(;) - operator(}) - - comment(/* - * plain internal array assignment - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(vals)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(,) ident(objectSpace)operator(\))operator(;) - ident(values) operator(=) ident(vals)operator(;) - ident(realLength) operator(=) ident(vals)operator(.)ident(length)operator(;) - operator(}) - - comment(/* - * plain internal array assignment - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(vals)operator(,) type(int) ident(begin)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(values) operator(=) ident(vals)operator(;) - local_variable(this)operator(.)ident(begin) operator(=) ident(begin)operator(;) - local_variable(this)operator(.)ident(realLength) operator(=) ident(vals)operator(.)ident(length) operator(-) ident(begin)operator(;) - local_variable(this)operator(.)ident(isShared) operator(=) pre_constant(true)operator(;) - operator(}) - - comment(/* rb_ary_new2 - * just allocates the internal array - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(length)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - ident(checkLength)operator(()ident(length)operator(\))operator(;) - ident(alloc)operator(()operator(()type(int)operator(\)) ident(length)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(length)operator(,) type(boolean) ident(objectspace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(,) ident(objectspace)operator(\))operator(;) - ident(checkLength)operator(()ident(length)operator(\))operator(;) - ident(alloc)operator(()operator(()type(int)operator(\))ident(length)operator(\))operator(;) - operator(}) - - comment(/* rb_ary_new3, rb_ary_new4 - * allocates the internal array of size length and copies the 'length' elements - */) - directive(public) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(length)operator(,) ident(IRubyObject)type([]) ident(vals)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - ident(checkLength)operator(()ident(length)operator(\))operator(;) - type(int) ident(ilength) operator(=) operator(()type(int)operator(\)) ident(length)operator(;) - ident(alloc)operator(()ident(ilength)operator(\))operator(;) - keyword(if) operator(()ident(ilength) operator(>) integer(0) operator(&&) ident(vals)operator(.)ident(length) operator(>) integer(0)operator(\)) pre_type(System)operator(.)ident(arraycopy)operator(()ident(vals)operator(,) integer(0)operator(,) ident(values)operator(,) integer(0)operator(,) ident(ilength)operator(\))operator(;) - - ident(realLength) operator(=) ident(ilength)operator(;) - operator(}) - - comment(/* NEWOBJ and OBJSETUP equivalent - * fastest one, for shared arrays, optional objectspace - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(,) ident(objectSpace)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - ident(alloc)operator(()ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - ident(alloc)operator(()ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - operator(}) - - comment(/* Array constructors taking the MetaClass to fulfil MRI Array subclass behaviour - * - */) - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) type(int) ident(length)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - ident(alloc)operator(()ident(length)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) type(long) ident(length)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - ident(checkLength)operator(()ident(length)operator(\))operator(;) - ident(alloc)operator(()operator(()type(int)operator(\))ident(length)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) type(long) ident(length)operator(,) type(boolean) ident(objectspace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(objectspace)operator(\))operator(;) - ident(checkLength)operator(()ident(length)operator(\))operator(;) - ident(alloc)operator(()operator(()type(int)operator(\))ident(length)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(objectSpace)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyArray)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) ident(RubyArray) ident(original)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - ident(realLength) operator(=) ident(original)operator(.)ident(realLength)operator(;) - ident(alloc)operator(()ident(realLength)operator(\))operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(original)operator(.)ident(values)operator(,) ident(original)operator(.)ident(begin)operator(,) ident(values)operator(,) integer(0)operator(,) ident(realLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(final) ident(IRubyObject)type([]) ident(reserve)operator(()type(int) ident(length)operator(\)) operator({) - directive(final) ident(IRubyObject)type([]) ident(arr) operator(=) keyword(new) ident(IRubyObject)operator([)ident(length)operator(])operator(;) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(arr)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(alloc)operator(()type(int) ident(length)operator(\)) operator({) - directive(final) ident(IRubyObject)type([]) ident(newValues) operator(=) keyword(new) ident(IRubyObject)operator([)ident(length)operator(])operator(;) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(newValues)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - ident(values) operator(=) ident(newValues)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(realloc)operator(()type(int) ident(newLength)operator(\)) operator({) - ident(IRubyObject)type([]) ident(reallocated) operator(=) keyword(new) ident(IRubyObject)operator([)ident(newLength)operator(])operator(;) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(reallocated)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) integer(0)operator(,) ident(reallocated)operator(,) integer(0)operator(,) ident(newLength) operator(>) ident(realLength) operator(?) ident(realLength) operator(:) ident(newLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(values) operator(=) ident(reallocated)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(checkLength)operator(()type(long) ident(length)operator(\)) operator({) - keyword(if) operator(()ident(length) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative array size (or size too big\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(length) operator(>=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(array size too big)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Getter for property list. - * @return Value of property list. - */) - directive(public) pre_type(List) ident(getList)operator(()operator(\)) operator({) - keyword(return) pre_type(Arrays)operator(.)ident(asList)operator(()ident(toJavaArray)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(int) ident(getLength)operator(()operator(\)) operator({) - keyword(return) ident(realLength)operator(;) - operator(}) - - directive(public) ident(IRubyObject)type([]) ident(toJavaArray)operator(()operator(\)) operator({) - ident(IRubyObject)type([]) ident(copy) operator(=) ident(reserve)operator(()ident(realLength)operator(\))operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) ident(begin)operator(,) ident(copy)operator(,) integer(0)operator(,) ident(realLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(copy)operator(;) - operator(}) - - directive(public) ident(IRubyObject)type([]) ident(toJavaArrayUnsafe)operator(()operator(\)) operator({) - keyword(return) operator(!)ident(isShared) operator(?) ident(values) operator(:) ident(toJavaArray)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject)type([]) ident(toJavaArrayMaybeUnsafe)operator(()operator(\)) operator({) - keyword(return) operator(()operator(!)ident(isShared) operator(&&) ident(begin) operator(==) integer(0) operator(&&) ident(values)operator(.)ident(length) operator(==) ident(realLength)operator(\)) operator(?) ident(values) operator(:) ident(toJavaArray)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_make_shared - * - */) - directive(private) directive(final) ident(RubyArray) ident(makeShared)operator(()type(int) ident(beg)operator(,) type(int) ident(len)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) ident(makeShared)operator(()ident(beg)operator(,) ident(len)operator(,) ident(klass)operator(,) ident(klass)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_make_shared - * - */) - directive(private) directive(final) ident(RubyArray) ident(makeShared)operator(()type(int) ident(beg)operator(,) type(int) ident(len)operator(,) ident(RubyClass) ident(klass)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - ident(RubyArray) ident(sharedArray) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(klass)operator(,) ident(objectSpace)operator(\))operator(;) - ident(isShared) operator(=) pre_constant(true)operator(;) - ident(sharedArray)operator(.)ident(values) operator(=) ident(values)operator(;) - ident(sharedArray)operator(.)ident(isShared) operator(=) pre_constant(true)operator(;) - ident(sharedArray)operator(.)ident(begin) operator(=) ident(beg)operator(;) - ident(sharedArray)operator(.)ident(realLength) operator(=) ident(len)operator(;) - keyword(return) ident(sharedArray)operator(;) - operator(}) - - comment(/** rb_ary_modify_check - * - */) - directive(private) directive(final) type(void) ident(modifyCheck)operator(()operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(TMPLOCK_OR_FROZEN_ARR_F)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(FROZEN_F)operator(\)) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFrozenError)operator(()string<delimiter(")content(array)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(TMPLOCK_ARR_F)operator(\)) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't modify array during iteration)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't modify array)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_modify - * - */) - directive(private) directive(final) type(void) ident(modify)operator(()operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isShared)operator(\)) operator({) - ident(IRubyObject)type([]) ident(vals) operator(=) ident(reserve)operator(()ident(realLength)operator(\))operator(;) - ident(isShared) operator(=) pre_constant(false)operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) ident(begin)operator(,) ident(vals)operator(,) integer(0)operator(,) ident(realLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(begin) operator(=) integer(0)operator(;) - ident(values) operator(=) ident(vals)operator(;) - operator(}) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** rb_ary_initialize - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(0)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(argc) operator(=) ident(args)operator(.)ident(length)operator(;) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(argc) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - ident(realLength) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(BLOCK_UNUSED)operator(,) string<delimiter(")content(given block not used)delimiter(")>operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(if) operator(()ident(argc) operator(==) integer(1) operator(&&) operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(val)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(replace)operator(()ident(val)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - type(long) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative array size)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(len) operator(>=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(array size too big)delimiter(")>operator(\))operator(;) - - type(int) ident(ilen) operator(=) operator(()type(int)operator(\)) ident(len)operator(;) - - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(ilen) operator(>) ident(values)operator(.)ident(length)operator(\)) ident(values) operator(=) ident(reserve)operator(()ident(ilen)operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(argc) operator(==) integer(2)operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(BLOCK_BEATS_DEFAULT_VALUE)operator(,) string<delimiter(")content(block supersedes default value argument)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(ilen)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(store)operator(()ident(i)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) ident(i)operator(\))operator(\))operator(\))operator(;) - ident(realLength) operator(=) ident(i) operator(+) integer(1)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(try) operator({) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(values)operator(,) integer(0)operator(,) ident(ilen)operator(,) operator(()ident(argc) operator(==) integer(2)operator(\)) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(realLength) operator(=) ident(ilen)operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_initialize_copy - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(initialize_copy)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility)operator(=)pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(orig)operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(replace)operator(()ident(orig)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_replace - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(replace)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(replace)operator(()ident(IRubyObject) ident(orig)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - ident(RubyArray) ident(origArr) operator(=) ident(orig)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(orig)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(origArr)operator(.)ident(isShared) operator(=) pre_constant(true)operator(;) - ident(isShared) operator(=) pre_constant(true)operator(;) - ident(values) operator(=) ident(origArr)operator(.)ident(values)operator(;) - ident(realLength) operator(=) ident(origArr)operator(.)ident(realLength)operator(;) - ident(begin) operator(=) ident(origArr)operator(.)ident(begin)operator(;) - - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(join)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($,)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - - directive(public) type(boolean) ident(includes)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(item)operator(\)) operator({) - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(value)operator(;) - keyword(try) operator({) - ident(value) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(value)operator(,) ident(item)operator(\))operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** rb_ary_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(int) ident(h) operator(=) ident(realLength)operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(h) operator(=) operator(()ident(h) operator(<)operator(<) integer(1)operator(\)) operator(|) operator(()ident(h) operator(<) integer(0) operator(?) integer(1) operator(:) integer(0)operator(\))operator(;) - directive(final) ident(IRubyObject) ident(value)operator(;) - keyword(try) operator({) - ident(value) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - ident(h) operator(^=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(value)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(HASH)operator(,) string<delimiter(")content(hash)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(h)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_store - * - */) - directive(public) directive(final) ident(IRubyObject) ident(store)operator(()type(long) ident(index)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(index) operator(<) integer(0)operator(\)) operator({) - ident(index) operator(+=) ident(realLength)operator(;) - keyword(if) operator(()ident(index) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) operator(()ident(index) operator(-) ident(realLength)operator(\)) operator(+) string<delimiter(")content( out of array)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(index) operator(>=) ident(realLength)operator(\)) operator({) - keyword(if) operator(()ident(index) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - type(long) ident(newLength) operator(=) ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(;) - - keyword(if) operator(()ident(newLength) operator(<) ident(ARRAY_DEFAULT_SIZE)operator(\)) ident(newLength) operator(=) ident(ARRAY_DEFAULT_SIZE)operator(;) - - ident(newLength) operator(+=) ident(index)operator(;) - keyword(if) operator(()ident(index) operator(>=) pre_type(Integer)operator(.)ident(MAX_VALUE) operator(||) ident(newLength) operator(>=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(index too big)delimiter(")>operator(\))operator(;) - operator(}) - ident(realloc)operator(()operator(()type(int)operator(\)) ident(newLength)operator(\))operator(;) - operator(}) - - ident(realLength) operator(=) operator(()type(int)operator(\)) ident(index) operator(+) integer(1)operator(;) - operator(}) - - keyword(try) operator({) - ident(values)operator([)operator(()type(int)operator(\)) ident(index)operator(]) operator(=) ident(value)operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** rb_ary_elt - * - */) - directive(private) directive(final) ident(IRubyObject) ident(elt)operator(()type(long) ident(offset)operator(\)) operator({) - keyword(if) operator(()ident(offset) operator(<) integer(0) operator(||) ident(offset) operator(>=) ident(realLength)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(try) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) operator(()type(int)operator(\))ident(offset)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_entry - * - */) - directive(public) directive(final) ident(IRubyObject) ident(entry)operator(()type(long) ident(offset)operator(\)) operator({) - keyword(return) operator(()ident(offset) operator(<) integer(0) operator(\)) operator(?) ident(elt)operator(()ident(offset) operator(+) ident(realLength)operator(\)) operator(:) ident(elt)operator(()ident(offset)operator(\))operator(;) - operator(}) - - - comment(/** rb_ary_entry - * - */) - directive(public) directive(final) ident(IRubyObject) ident(entry)operator(()type(int) ident(offset)operator(\)) operator({) - keyword(return) operator(()ident(offset) operator(<) integer(0) operator(\)) operator(?) ident(elt)operator(()ident(offset) operator(+) ident(realLength)operator(\)) operator(:) ident(elt)operator(()ident(offset)operator(\))operator(;) - operator(}) - - directive(public) directive(final) ident(IRubyObject) ident(eltInternal)operator(()type(int) ident(offset)operator(\)) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) ident(offset)operator(])operator(;) - operator(}) - - directive(public) directive(final) ident(IRubyObject) ident(eltInternalSet)operator(()type(int) ident(offset)operator(,) ident(IRubyObject) ident(item)operator(\)) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) ident(offset)operator(]) operator(=) ident(item)operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(fetch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(fetch)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(fetch)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_ary_fetch - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fetch)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(fetch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(long) ident(index) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - - keyword(if) operator(()ident(index) operator(<) integer(0)operator(\)) ident(index) operator(+=) ident(realLength)operator(;) - keyword(if) operator(()ident(index) operator(<) integer(0) operator(||) ident(index) operator(>=) ident(realLength)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(arg0)operator(\))operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(index) operator(+) string<delimiter(")content( out of array)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(try) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) operator(()type(int)operator(\)) ident(index)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_fetch - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fetch)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(fetch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(BLOCK_BEATS_DEFAULT_VALUE)operator(,) string<delimiter(")content(block supersedes default value argument)delimiter(")>operator(\))operator(;) - - type(long) ident(index) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - - keyword(if) operator(()ident(index) operator(<) integer(0)operator(\)) ident(index) operator(+=) ident(realLength)operator(;) - keyword(if) operator(()ident(index) operator(<) integer(0) operator(||) ident(index) operator(>=) ident(realLength)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(arg0)operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - - keyword(try) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) operator(()type(int)operator(\)) ident(index)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_to_ary - * - */) - directive(private) directive(static) ident(RubyArray) ident(aryToAry)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubyArray)operator(\)) keyword(return) operator(()ident(RubyArray)operator(\)) ident(obj)operator(;) - - keyword(if) operator(()ident(obj)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_ary)delimiter(")>operator(\))operator(\)) keyword(return) ident(obj)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - - ident(RubyArray) ident(arr) operator(=) keyword(new) ident(RubyArray)operator(()ident(obj)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) comment(// possibly should not in object space) - ident(arr)operator(.)ident(alloc)operator(()integer(1)operator(\))operator(;) - ident(arr)operator(.)ident(values)operator([)integer(0)operator(]) operator(=) ident(obj)operator(;) - ident(arr)operator(.)ident(realLength) operator(=) integer(1)operator(;) - keyword(return) ident(arr)operator(;) - operator(}) - - comment(/** rb_ary_splice - * - */) - directive(private) directive(final) type(void) ident(splice)operator(()type(long) ident(beg)operator(,) type(long) ident(len)operator(,) ident(IRubyObject) ident(rpl)operator(\)) operator({) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(negative length ()delimiter(")> operator(+) ident(len) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(+=) ident(realLength)operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(-=) ident(realLength)operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(beg) operator(+) string<delimiter(")content( out of array)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(final) ident(RubyArray) ident(rplArr)operator(;) - directive(final) type(int) ident(rlen)operator(;) - - keyword(if) operator(()ident(rpl) operator(==) pre_constant(null) operator(||) ident(rpl)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(rplArr) operator(=) pre_constant(null)operator(;) - ident(rlen) operator(=) integer(0)operator(;) - operator(}) keyword(else) operator({) - ident(rplArr) operator(=) ident(aryToAry)operator(()ident(rpl)operator(\))operator(;) - ident(rlen) operator(=) ident(rplArr)operator(.)ident(realLength)operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(>=) ident(realLength)operator(\)) operator({) - ident(len) operator(=) ident(beg) operator(+) ident(rlen)operator(;) - - keyword(if) operator(()ident(len) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - type(int) ident(tryNewLength) operator(=) ident(values)operator(.)ident(length) operator(+) operator(()ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(\))operator(;) - ident(realloc)operator(()ident(len) operator(>) ident(tryNewLength) operator(?) operator(()type(int)operator(\))ident(len) operator(:) ident(tryNewLength)operator(\))operator(;) - operator(}) - - ident(realLength) operator(=) operator(()type(int)operator(\)) ident(len)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(realLength)operator(\)) ident(len) operator(=) ident(realLength) operator(-) ident(beg)operator(;) - - type(long) ident(alen) operator(=) ident(realLength) operator(+) ident(rlen) operator(-) ident(len)operator(;) - keyword(if) operator(()ident(alen) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - type(int) ident(tryNewLength) operator(=) ident(values)operator(.)ident(length) operator(+) operator(()ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(\))operator(;) - ident(realloc)operator(()ident(alen) operator(>) ident(tryNewLength) operator(?) operator(()type(int)operator(\))ident(alen) operator(:) ident(tryNewLength)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(len) operator(!=) ident(rlen)operator(\)) operator({) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) operator(()type(int)operator(\)) operator(()ident(beg) operator(+) ident(len)operator(\))operator(,) ident(values)operator(,) operator(()type(int)operator(\)) ident(beg) operator(+) ident(rlen)operator(,) ident(realLength) operator(-) operator(()type(int)operator(\)) operator(()ident(beg) operator(+) ident(len)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(realLength) operator(=) operator(()type(int)operator(\)) ident(alen)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(rlen) operator(>) integer(0)operator(\)) operator({) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(rplArr)operator(.)ident(values)operator(,) ident(rplArr)operator(.)ident(begin)operator(,) ident(values)operator(,) operator(()type(int)operator(\)) ident(beg)operator(,) ident(rlen)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** rb_ary_splice - * - */) - directive(private) directive(final) type(void) ident(spliceOne)operator(()type(long) ident(beg)operator(,) type(long) ident(len)operator(,) ident(IRubyObject) ident(rpl)operator(\)) operator({) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(negative length ()delimiter(")> operator(+) ident(len) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(+=) ident(realLength)operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(-=) ident(realLength)operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(beg) operator(+) string<delimiter(")content( out of array)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(>=) ident(realLength)operator(\)) operator({) - ident(len) operator(=) ident(beg) operator(+) integer(1)operator(;) - - keyword(if) operator(()ident(len) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - type(int) ident(tryNewLength) operator(=) ident(values)operator(.)ident(length) operator(+) operator(()ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(\))operator(;) - ident(realloc)operator(()ident(len) operator(>) ident(tryNewLength) operator(?) operator(()type(int)operator(\))ident(len) operator(:) ident(tryNewLength)operator(\))operator(;) - operator(}) - - ident(realLength) operator(=) operator(()type(int)operator(\)) ident(len)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(realLength)operator(\)) ident(len) operator(=) ident(realLength) operator(-) ident(beg)operator(;) - - type(int) ident(alen) operator(=) ident(realLength) operator(+) integer(1) operator(-) operator(()type(int)operator(\))ident(len)operator(;) - keyword(if) operator(()ident(alen) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - type(int) ident(tryNewLength) operator(=) ident(values)operator(.)ident(length) operator(+) operator(()ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(\))operator(;) - ident(realloc)operator(()ident(alen) operator(>) ident(tryNewLength) operator(?) ident(alen) operator(:) ident(tryNewLength)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(len) operator(!=) integer(1)operator(\)) operator({) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) operator(()type(int)operator(\)) operator(()ident(beg) operator(+) ident(len)operator(\))operator(,) ident(values)operator(,) operator(()type(int)operator(\)) ident(beg) operator(+) integer(1)operator(,) ident(realLength) operator(-) operator(()type(int)operator(\)) operator(()ident(beg) operator(+) ident(len)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(realLength) operator(=) ident(alen)operator(;) - operator(}) - operator(}) - - keyword(try) operator({) - ident(values)operator([)operator(()type(int)operator(\))ident(beg)operator(]) operator(=) ident(rpl)operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(insert)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_insert - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(insert)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_insert - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(insert)operator(()ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - type(long) ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg1)operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(==) operator(-)integer(1)operator(\)) ident(pos) operator(=) ident(realLength)operator(;) - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) ident(pos)operator(++)operator(;) - - ident(spliceOne)operator(()ident(pos)operator(,) integer(0)operator(,) ident(arg2)operator(\))operator(;) comment(// rb_ary_new4) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_insert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(insert)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(insert)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) keyword(return) local_variable(this)operator(;) - - type(long) ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(==) operator(-)integer(1)operator(\)) ident(pos) operator(=) ident(realLength)operator(;) - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) ident(pos)operator(++)operator(;) - - ident(RubyArray) ident(inserted) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - ident(inserted)operator(.)ident(values) operator(=) ident(args)operator(;) - ident(inserted)operator(.)ident(begin) operator(=) integer(1)operator(;) - ident(inserted)operator(.)ident(realLength) operator(=) ident(args)operator(.)ident(length) operator(-) integer(1)operator(;) - - ident(splice)operator(()ident(pos)operator(,) integer(0)operator(,) ident(inserted)operator(\))operator(;) comment(// rb_ary_new4) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_dup - * - */) - directive(public) directive(final) ident(RubyArray) ident(aryDup)operator(()operator(\)) operator({) - ident(RubyArray) ident(dup) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(;) - ident(dup)operator(.)ident(flags) operator(|=) ident(flags) operator(&) ident(TAINTED_F)operator(;) comment(// from DUP_SETUP) - comment(// rb_copy_generic_ivar from DUP_SETUP here ...unlikely..) - keyword(return) ident(dup)operator(;) - operator(}) - - comment(/** rb_ary_transpose - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(transpose)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(transpose)operator(()operator(\)) operator({) - ident(RubyArray) ident(tmp)operator(,) ident(result) operator(=) pre_constant(null)operator(;) - - type(int) ident(alen) operator(=) ident(realLength)operator(;) - keyword(if) operator(()ident(alen) operator(==) integer(0)operator(\)) keyword(return) ident(aryDup)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(elen) operator(=) operator(-)integer(1)operator(;) - type(int) ident(end) operator(=) ident(begin) operator(+) ident(alen)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(end)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(tmp) operator(=) ident(elt)operator(()ident(i)operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - keyword(if) operator(()ident(elen) operator(<) integer(0)operator(\)) operator({) - ident(elen) operator(=) ident(tmp)operator(.)ident(realLength)operator(;) - ident(result) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(elen)operator(\))operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(elen)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(store)operator(()ident(j)operator(,) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(alen)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(elen) operator(!=) ident(tmp)operator(.)ident(realLength)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIndexError)operator(()string<delimiter(")content(element size differs ()delimiter(")> operator(+) ident(tmp)operator(.)ident(realLength) - operator(+) string<delimiter(")content( should be )delimiter(")> operator(+) ident(elen) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(elen)operator(;) ident(j)operator(++)operator(\)) operator({) - operator(()operator(()ident(RubyArray)operator(\)) ident(result)operator(.)ident(elt)operator(()ident(j)operator(\))operator(\))operator(.)ident(store)operator(()ident(i) operator(-) ident(begin)operator(,) ident(tmp)operator(.)ident(elt)operator(()ident(j)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_values_at (internal\) - * - */) - directive(private) directive(final) ident(IRubyObject) ident(values_at)operator(()type(long) ident(olen)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyArray) ident(result) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(entry)operator(()operator(()operator(()ident(RubyFixnum)operator(\))ident(args)operator([)ident(i)operator(])operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - - type(long) ident(beglen)type([])operator(;) - keyword(if) operator(()operator(!)operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyRange)operator(\))operator(\)) operator({) - operator(}) keyword(else) keyword(if) operator(()operator(()ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(args)operator([)ident(i)operator(])operator(\))operator(.)ident(begLen)operator(()ident(olen)operator(,) integer(0)operator(\))operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(continue)operator(;) - operator(}) keyword(else) operator({) - type(int) ident(beg) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(0)operator(])operator(;) - type(int) ident(len) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(1)operator(])operator(;) - type(int) ident(end) operator(=) ident(begin) operator(+) ident(len)operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) ident(begin)operator(;) ident(j) operator(<) ident(end)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(entry)operator(()ident(j) operator(+) ident(beg)operator(\))operator(\))operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) - ident(result)operator(.)ident(append)operator(()ident(entry)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_values_at - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(values_at)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(values_at)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(values_at)operator(()ident(realLength)operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_subseq - * - */) - directive(public) ident(IRubyObject) ident(subseq)operator(()type(long) ident(beg)operator(,) type(long) ident(len)operator(\)) operator({) - keyword(if) operator(()ident(beg) operator(>) ident(realLength) operator(||) ident(beg) operator(<) integer(0) operator(||) ident(len) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(realLength)operator(\)) operator({) - ident(len) operator(=) ident(realLength) operator(-) ident(beg)operator(;) - - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) ident(len) operator(=) integer(0)operator(;) - operator(}) - - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) keyword(return) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) integer(0)operator(\))operator(;) - - keyword(return) ident(makeShared)operator(()ident(begin) operator(+) operator(()type(int)operator(\)) ident(beg)operator(,) operator(()type(int)operator(\)) ident(len)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_subseq - * - */) - directive(public) ident(IRubyObject) ident(subseqLight)operator(()type(long) ident(beg)operator(,) type(long) ident(len)operator(\)) operator({) - keyword(if) operator(()ident(beg) operator(>) ident(realLength) operator(||) ident(beg) operator(<) integer(0) operator(||) ident(len) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(realLength)operator(\)) operator({) - ident(len) operator(=) ident(realLength) operator(-) ident(beg)operator(;) - - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) ident(len) operator(=) integer(0)operator(;) - operator(}) - - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) keyword(return) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - - keyword(return) ident(makeShared)operator(()ident(begin) operator(+) operator(()type(int)operator(\)) ident(beg)operator(,) operator(()type(int)operator(\)) ident(len)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_length - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(length)delimiter(")>operator(,) ident(alias) operator(=) string<delimiter(")content(size)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(length)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(realLength)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_push - specialized rb_ary_store - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(append)operator(()ident(IRubyObject) ident(item)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) ident(values)operator(.)ident(length)operator(\)) operator({) - keyword(if) operator(()ident(realLength) operator(==) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(index too big)delimiter(")>operator(\))operator(;) - - type(long) ident(newLength) operator(=) ident(values)operator(.)ident(length) operator(+) operator(()ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(\))operator(;) - keyword(if) operator(() ident(newLength) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE) operator(\)) operator({) - ident(newLength) operator(=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(;) - operator(})keyword(else) keyword(if) operator(() ident(newLength) operator(<) ident(ARRAY_DEFAULT_SIZE) operator(\)) operator({) - ident(newLength) operator(=) ident(ARRAY_DEFAULT_SIZE)operator(;) - operator(}) - - ident(realloc)operator(()operator(()type(int)operator(\)) ident(newLength)operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(values)operator([)ident(realLength)operator(++)operator(]) operator(=) ident(item)operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_push_m - * FIXME: Whis is this named "push_m"? - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(push)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(push_m)operator(()ident(IRubyObject)type([]) ident(items)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(items)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(append)operator(()ident(items)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_pop - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pop)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pop)operator(()operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(isShared)operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(values)operator([)ident(begin) operator(+) operator(--)ident(realLength)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(index) operator(=) ident(begin) operator(+) operator(--)ident(realLength)operator(;) - keyword(try) operator({) - directive(final) ident(IRubyObject) ident(obj) operator(=) ident(values)operator([)ident(index)operator(])operator(;) - ident(values)operator([)ident(index)operator(]) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** rb_ary_shift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(shift)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(shift)operator(()operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - directive(final) ident(IRubyObject) ident(obj)operator(;) - keyword(try) operator({) - ident(obj) operator(=) ident(values)operator([)ident(begin)operator(])operator(;) - ident(values)operator([)ident(begin)operator(]) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(isShared) operator(=) pre_constant(true)operator(;) - - ident(begin)operator(++)operator(;) - ident(realLength)operator(--)operator(;) - - keyword(return) ident(obj)operator(;) - operator(}) - - comment(/** rb_ary_unshift - * - */) - directive(public) ident(RubyArray) ident(unshift)operator(()ident(IRubyObject) ident(item)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) ident(values)operator(.)ident(length)operator(\)) operator({) - type(int) ident(newLength) operator(=) ident(values)operator(.)ident(length) operator(>)operator(>) integer(1)operator(;) - keyword(if) operator(()ident(newLength) operator(<) ident(ARRAY_DEFAULT_SIZE)operator(\)) ident(newLength) operator(=) ident(ARRAY_DEFAULT_SIZE)operator(;) - - ident(newLength) operator(+=) ident(values)operator(.)ident(length)operator(;) - ident(realloc)operator(()ident(newLength)operator(\))operator(;) - operator(}) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) integer(0)operator(,) ident(values)operator(,) integer(1)operator(,) ident(realLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - - ident(realLength)operator(++)operator(;) - ident(values)operator([)integer(0)operator(]) operator(=) ident(item)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_unshift_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(unshift)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(unshift_m)operator(()ident(IRubyObject)type([]) ident(items)operator(\)) operator({) - type(long) ident(len) operator(=) ident(realLength)operator(;) - - keyword(if) operator(()ident(items)operator(.)ident(length) operator(==) integer(0)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(store)operator(()ident(len) operator(+) ident(items)operator(.)ident(length) operator(-) integer(1)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - - keyword(try) operator({) - comment(// it's safe to use zeroes here since modified by store(\)) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) integer(0)operator(,) ident(values)operator(,) ident(items)operator(.)ident(length)operator(,) operator(()type(int)operator(\)) ident(len)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(items)operator(,) integer(0)operator(,) ident(values)operator(,) integer(0)operator(,) ident(items)operator(.)ident(length)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_includes - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(include?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(include_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(item)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(includes)operator(()ident(context)operator(,) ident(item)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_frozen_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(frozen?)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyBoolean) ident(frozen_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isFrozen)operator(()operator(\)) operator(||) operator(()ident(flags) operator(&) ident(TMPLOCK_ARR_F)operator(\)) operator(!=) integer(0)operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(aref)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(aref)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_ary_aref - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content([])delimiter(")>operator(,) string<delimiter(")content(slice)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyFixnum)operator(\)) keyword(return) ident(entry)operator(()operator(()operator(()ident(RubyFixnum)operator(\))ident(arg0)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubySymbol)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Symbol as array index)delimiter(")>operator(\))operator(;) - - type(long)type([]) ident(beglen)operator(;) - keyword(if) operator(()operator(!)operator(()ident(arg0) keyword(instanceof) ident(RubyRange)operator(\))operator(\)) operator({) - operator(}) keyword(else) keyword(if) operator(()operator(()ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(arg0)operator(\))operator(.)ident(begLen)operator(()ident(realLength)operator(,) integer(0)operator(\))operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(subseq)operator(()ident(beglen)operator([)integer(0)operator(])operator(,) ident(beglen)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(entry)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_aref - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content([])delimiter(")>operator(,) string<delimiter(")content(slice)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubySymbol)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Symbol as array index)delimiter(")>operator(\))operator(;) - - type(long) ident(beg) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) ident(beg) operator(+=) ident(realLength)operator(;) - - keyword(return) ident(subseq)operator(()ident(beg)operator(,) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg1)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(aset)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(2)operator(:) - keyword(return) ident(aset)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) integer(3)operator(:) - keyword(return) ident(aset)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(default)operator(:) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments ()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+) string<delimiter(")content( for 2\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_aset - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(aset)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(store)operator(()operator(()operator(()ident(RubyFixnum)operator(\))ident(arg0)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(,) ident(arg1)operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRange)operator(\)) operator({) - type(long)type([]) ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(arg0)operator(\))operator(.)ident(begLen)operator(()ident(realLength)operator(,) integer(1)operator(\))operator(;) - ident(splice)operator(()ident(beglen)operator([)integer(0)operator(])operator(,) ident(beglen)operator([)integer(1)operator(])operator(,) ident(arg1)operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubySymbol)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Symbol as array index)delimiter(")>operator(\))operator(;) - - ident(store)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(,) ident(arg1)operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - - comment(/** rb_ary_aset - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(aset)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubySymbol)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Symbol as array index)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(arg1) keyword(instanceof) ident(RubySymbol)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Symbol as subarray length)delimiter(")>operator(\))operator(;) - ident(splice)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(,) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg1)operator(\))operator(,) ident(arg2)operator(\))operator(;) - keyword(return) ident(arg2)operator(;) - operator(}) - - comment(/** rb_ary_at - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(at)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(at)operator(()ident(IRubyObject) ident(pos)operator(\)) operator({) - keyword(return) ident(entry)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(pos)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_concat - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(concat)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(concat)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(obj)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(ary)operator(.)ident(realLength) operator(>) integer(0)operator(\)) ident(splice)operator(()ident(realLength)operator(,) integer(0)operator(,) ident(ary)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** inspect_ary - * - */) - directive(private) ident(IRubyObject) ident(inspectAry)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(ByteList) ident(buffer) operator(=) keyword(new) ident(ByteList)operator(()operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content([)delimiter(')>operator(\))operator(;) - type(boolean) ident(tainted) operator(=) ident(isTaint)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(>) integer(0)operator(\)) ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(,)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content( )delimiter(')>operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(inspect)operator(()ident(context)operator(,) ident(values)operator([)ident(begin) operator(+) ident(i)operator(])operator(\))operator(;) - keyword(if) operator(()ident(str)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(tainted) operator(=) pre_constant(true)operator(;) - ident(buffer)operator(.)ident(append)operator(()ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(])delimiter(')>operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buffer)operator(\))operator(;) - keyword(if) operator(()ident(tainted)operator(\)) ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_ary_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content([])delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content([...])delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(inspectAry)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(first)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(first)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(first)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_ary_first - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(first)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(first)operator(()operator(\)) operator({) - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(values)operator([)ident(begin)operator(])operator(;) - operator(}) - - comment(/** rb_ary_first - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(first)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(first)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - type(long) ident(n) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(>) ident(realLength)operator(\)) operator({) - ident(n) operator(=) ident(realLength)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(n) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative array size (or size too big\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(makeShared)operator(()ident(begin)operator(,) operator(()type(int)operator(\)) ident(n)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(last)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(last)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(last)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_ary_last - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(last)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(last)operator(()operator(\)) operator({) - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(values)operator([)ident(begin) operator(+) ident(realLength) operator(-) integer(1)operator(])operator(;) - operator(}) - - comment(/** rb_ary_last - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(last)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(last)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - type(long) ident(n) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(>) ident(realLength)operator(\)) operator({) - ident(n) operator(=) ident(realLength)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(n) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative array size (or size too big\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(makeShared)operator(()ident(begin) operator(+) ident(realLength) operator(-) operator(()type(int)operator(\)) ident(n)operator(,) operator(()type(int)operator(\)) ident(n)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getArray)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_each - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(begin) operator(+) ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_each_index - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_index)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_index)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_reverse_each - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reverse_each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(reverse_each)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(len) operator(=) ident(realLength)operator(;) - - keyword(while)operator(()ident(len)operator(--) operator(>) integer(0)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(begin) operator(+) ident(len)operator(])operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(<) ident(len)operator(\)) ident(len) operator(=) ident(realLength)operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(inspectJoin)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyArray) ident(tmp)operator(,) ident(IRubyObject) ident(sep)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - comment(// If already inspecting, there is no need to register/unregister again.) - keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) operator({) - keyword(return) ident(tmp)operator(.)ident(join)operator(()ident(context)operator(,) ident(sep)operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(runtime)operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(tmp)operator(.)ident(join)operator(()ident(context)operator(,) ident(sep)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_ary_join - * - */) - directive(public) ident(RubyString) ident(join)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(sep)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) integer(0)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - type(boolean) ident(taint) operator(=) ident(isTaint)operator(()operator(\)) operator(||) ident(sep)operator(.)ident(isTaint)operator(()operator(\))operator(;) - - type(long) ident(len) operator(=) integer(1)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(value)operator(;) - keyword(try) operator({) - ident(value) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(tmp) operator(=) ident(value)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - ident(len) operator(+=) ident(tmp)operator(.)ident(isNil)operator(()operator(\)) operator(?) integer(10) operator(:) operator(()operator(()ident(RubyString)operator(\)) ident(tmp)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - - ident(RubyString) ident(strSep) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()operator(!)ident(sep)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(sep) operator(=) ident(strSep) operator(=) ident(sep)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(len) operator(+=) ident(strSep)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(*) operator(()ident(realLength) operator(-) integer(1)operator(\))operator(;) - operator(}) - - ident(ByteList) ident(buf) operator(=) keyword(new) ident(ByteList)operator(()operator(()type(int)operator(\))ident(len)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(tmp)operator(;) - keyword(try) operator({) - ident(tmp) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(tmp) keyword(instanceof) ident(RubyString)operator(\)) operator({) - comment(// do nothing) - operator(}) keyword(else) keyword(if) operator(()ident(tmp) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()ident(tmp)operator(\))operator(\)) operator({) - ident(tmp) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content([...])delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(tmp) operator(=) ident(inspectJoin)operator(()ident(context)operator(,) operator(()ident(RubyArray)operator(\))ident(tmp)operator(,) ident(sep)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(tmp) operator(=) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(tmp)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(i) operator(>) ident(begin) operator(&&) operator(!)ident(sep)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(buf)operator(.)ident(append)operator(()ident(strSep)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - - ident(buf)operator(.)ident(append)operator(()ident(tmp)operator(.)ident(asString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(tmp)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(taint) operator(=) pre_constant(true)operator(;) - operator(}) - - ident(RubyString) ident(result) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(buf)operator(\))operator(;) - - keyword(if) operator(()ident(taint)operator(\)) ident(result)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_ary_join_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(join)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyString) ident(join_m)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(int) ident(argc) operator(=) ident(args)operator(.)ident(length)operator(;) - ident(IRubyObject) ident(sep) operator(=) operator(()ident(argc) operator(==) integer(1)operator(\)) operator(?) ident(args)operator([)integer(0)operator(]) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($,)delimiter(")>operator(\))operator(;) - - keyword(return) ident(join)operator(()ident(context)operator(,) ident(sep)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_to_a - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - keyword(if)operator(()ident(getMetaClass)operator(()operator(\)) operator(!=) ident(getRuntime)operator(()operator(\))operator(.)ident(getArray)operator(()operator(\))operator(\)) operator({) - ident(RubyArray) ident(dup) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\))operator(;) - - ident(isShared) operator(=) pre_constant(true)operator(;) - ident(dup)operator(.)ident(isShared) operator(=) pre_constant(true)operator(;) - ident(dup)operator(.)ident(values) operator(=) ident(values)operator(;) - ident(dup)operator(.)ident(realLength) operator(=) ident(realLength)operator(;) - ident(dup)operator(.)ident(begin) operator(=) ident(begin)operator(;) - - keyword(return) ident(dup)operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_ary)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_ary)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyArray) ident(convertToArray)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(checkArrayType)operator(()operator(\))operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_equal - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(obj)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)ident(obj)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_ary)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(obj)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_ary)delimiter(")>operator(\))operator(,) local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - ident(RubyArray) ident(ary) operator(=) operator(()ident(RubyArray)operator(\)) ident(obj)operator(;) - keyword(if) operator(()ident(realLength) operator(!=) ident(ary)operator(.)ident(realLength)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(long) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(equalInternal)operator(()ident(context)operator(,) ident(elt)operator(()ident(i)operator(\))operator(,) ident(ary)operator(.)ident(elt)operator(()ident(i)operator(\))operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_eql - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(obj)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - ident(RubyArray) ident(ary) operator(=) operator(()ident(RubyArray)operator(\)) ident(obj)operator(;) - - keyword(if) operator(()ident(realLength) operator(!=) ident(ary)operator(.)ident(realLength)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(eqlInternal)operator(()ident(context)operator(,) ident(elt)operator(()ident(i)operator(\))operator(,) ident(ary)operator(.)ident(elt)operator(()ident(i)operator(\))operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_compact_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(compact!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(compact_bang)operator(()operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(p) operator(=) integer(0)operator(;) - type(int) ident(t) operator(=) integer(0)operator(;) - type(int) ident(end) operator(=) ident(p) operator(+) ident(realLength)operator(;) - - keyword(while) operator(()ident(t) operator(<) ident(end)operator(\)) operator({) - keyword(if) operator(()ident(values)operator([)ident(t)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(t)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(values)operator([)ident(p)operator(++)operator(]) operator(=) ident(values)operator([)ident(t)operator(++)operator(])operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(realLength) operator(==) ident(p)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(realloc)operator(()ident(p)operator(\))operator(;) - ident(realLength) operator(=) ident(p)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_compact - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(compact)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(compact)operator(()operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(aryDup)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(compact_bang)operator(()operator(\))operator(;) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_empty_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(empty?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(empty_p)operator(()operator(\)) operator({) - keyword(return) ident(realLength) operator(==) integer(0) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_clear - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clear)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rb_clear)operator(()operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - keyword(if)operator(()ident(isShared)operator(\)) operator({) - ident(alloc)operator(()ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - ident(isShared) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(values)operator(.)ident(length) operator(>) ident(ARRAY_DEFAULT_SIZE) operator(<)operator(<) integer(1)operator(\))operator({) - ident(alloc)operator(()ident(ARRAY_DEFAULT_SIZE) operator(<)operator(<) integer(1)operator(\))operator(;) - operator(}) keyword(else) operator({) - directive(final) type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - keyword(try) operator({) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(values)operator(,) ident(begin)operator(,) ident(begin) operator(+) ident(realLength)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - - ident(begin) operator(=) integer(0)operator(;) - ident(realLength) operator(=) integer(0)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_fill - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fill)delimiter(")>operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(fill)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject) ident(item) operator(=) pre_constant(null)operator(;) - ident(IRubyObject) ident(begObj) operator(=) pre_constant(null)operator(;) - ident(IRubyObject) ident(lenObj) operator(=) pre_constant(null)operator(;) - type(int) ident(argc) operator(=) ident(args)operator(.)ident(length)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(0)operator(,) integer(2)operator(\))operator(;) - ident(item) operator(=) pre_constant(null)operator(;) - ident(begObj) operator(=) ident(argc) operator(>) integer(0) operator(?) ident(args)operator([)integer(0)operator(]) operator(:) pre_constant(null)operator(;) - ident(lenObj) operator(=) ident(argc) operator(>) integer(1) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) pre_constant(null)operator(;) - ident(argc)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(1)operator(,) integer(3)operator(\))operator(;) - ident(item) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(begObj) operator(=) ident(argc) operator(>) integer(1) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) pre_constant(null)operator(;) - ident(lenObj) operator(=) ident(argc) operator(>) integer(2) operator(?) ident(args)operator([)integer(2)operator(]) operator(:) pre_constant(null)operator(;) - operator(}) - - type(int) ident(beg) operator(=) integer(0)operator(,) ident(end) operator(=) integer(0)operator(,) ident(len) operator(=) integer(0)operator(;) - keyword(switch) operator(()ident(argc)operator(\)) operator({) - keyword(case) integer(1)operator(:) - ident(beg) operator(=) integer(0)operator(;) - ident(len) operator(=) ident(realLength)operator(;) - keyword(break)operator(;) - keyword(case) integer(2)operator(:) - keyword(if) operator(()ident(begObj) keyword(instanceof) ident(RubyRange)operator(\)) operator({) - type(long)type([]) ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(begObj)operator(\))operator(.)ident(begLen)operator(()ident(realLength)operator(,) integer(1)operator(\))operator(;) - ident(beg) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(0)operator(])operator(;) - ident(len) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(1)operator(])operator(;) - keyword(break)operator(;) - operator(}) - comment(/* fall through */) - keyword(case) integer(3)operator(:) - ident(beg) operator(=) ident(begObj)operator(.)ident(isNil)operator(()operator(\)) operator(?) integer(0) operator(:) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(begObj)operator(\))operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(=) ident(realLength) operator(+) ident(beg)operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) ident(beg) operator(=) integer(0)operator(;) - operator(}) - ident(len) operator(=) operator(()ident(lenObj) operator(==) pre_constant(null) operator(||) ident(lenObj)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator(?) ident(realLength) operator(-) ident(beg) operator(:) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(lenObj)operator(\))operator(;) - comment(// TODO: In MRI 1.9, an explicit check for negative length is) - comment(// added here. IndexError is raised when length is negative.) - comment(// See [ruby-core:12953] for more details.) - comment(//) - comment(// New note: This is actually under re-evaluation,) - comment(// see [ruby-core:17483].) - keyword(break)operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - comment(// See [ruby-core:17483]) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(if) operator(()ident(len) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE) operator(-) ident(beg)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument too big)delimiter(")>operator(\))operator(;) - operator(}) - - ident(end) operator(=) ident(beg) operator(+) ident(len)operator(;) - keyword(if) operator(()ident(end) operator(>) ident(realLength)operator(\)) operator({) - keyword(if) operator(()ident(end) operator(>=) ident(values)operator(.)ident(length)operator(\)) ident(realloc)operator(()ident(end)operator(\))operator(;) - - ident(realLength) operator(=) ident(end)operator(;) - operator(}) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(beg)operator(;) ident(i) operator(<) ident(end)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(i) operator(>=) ident(realLength)operator(\)) keyword(break)operator(;) - keyword(try) operator({) - ident(values)operator([)ident(i)operator(]) operator(=) ident(v)operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(len) operator(>) integer(0)operator(\)) operator({) - keyword(try) operator({) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(values)operator(,) ident(beg)operator(,) ident(beg) operator(+) ident(len)operator(,) ident(item)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_index - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(index)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(,) ident(obj)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(i) operator(-) ident(begin)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_rindex - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rindex)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(rindex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(i) operator(=) ident(realLength)operator(;) - - keyword(while) operator(()ident(i)operator(--) operator(>) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(>) ident(realLength)operator(\)) operator({) - ident(i) operator(=) ident(realLength)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(values)operator([)ident(begin) operator(+) ident(i)operator(])operator(,) ident(obj)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_indexes - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(indexes)delimiter(")>operator(,) string<delimiter(")content(indices)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(indexes)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(Array#indexes is deprecated; use Array#values_at)delimiter(")>operator(,) string<delimiter(")content(Array#indexes)delimiter(")>operator(,) string<delimiter(")content(Array#values_at)delimiter(")>operator(\))operator(;) - - ident(RubyArray) ident(ary) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - - ident(IRubyObject)type([]) ident(arefArgs) operator(=) keyword(new) ident(IRubyObject)operator([)integer(1)operator(])operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(arefArgs)operator([)integer(0)operator(]) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - ident(ary)operator(.)ident(append)operator(()ident(aref)operator(()ident(arefArgs)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_reverse_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reverse!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(reverse_bang)operator(()operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - directive(final) type(int) ident(realLength) operator(=) local_variable(this)operator(.)ident(realLength)operator(;) - directive(final) ident(IRubyObject)type([]) ident(values) operator(=) local_variable(this)operator(.)ident(values)operator(;) - keyword(try) operator({) - keyword(if) operator(()ident(realLength) operator(>) integer(1)operator(\)) operator({) - type(int) ident(p1) operator(=) integer(0)operator(;) - type(int) ident(p2) operator(=) ident(p1) operator(+) ident(realLength) operator(-) integer(1)operator(;) - - keyword(while) operator(()ident(p1) operator(<) ident(p2)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(tmp) operator(=) ident(values)operator([)ident(p1)operator(])operator(;) - ident(values)operator([)ident(p1)operator(++)operator(]) operator(=) ident(values)operator([)ident(p2)operator(])operator(;) - ident(values)operator([)ident(p2)operator(--)operator(]) operator(=) ident(tmp)operator(;) - operator(}) - operator(}) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_reverse_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reverse)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(reverse)operator(()operator(\)) operator({) - keyword(return) ident(aryDup)operator(()operator(\))operator(.)ident(reverse_bang)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_collect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(collect)delimiter(")>operator(,) string<delimiter(")content(map)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(collect)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(;) - - ident(RubyArray) ident(collect) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(realLength)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(collect)operator(.)ident(append)operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(collect)operator(;) - operator(}) - - comment(/** rb_ary_collect_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(collect!)delimiter(")>operator(,) string<delimiter(")content(map!)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(collect_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,) ident(len) operator(=) ident(realLength)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(store)operator(()ident(i)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(begin) operator(+) ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_select - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(select)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(realLength)operator(\))operator(;) - - keyword(if) operator(()ident(isShared)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) ident(result)operator(.)ident(append)operator(()ident(elt)operator(()ident(i) operator(-) ident(begin)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) ident(result)operator(.)ident(append)operator(()ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_ary_delete - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(delete)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(item)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(i2) operator(=) integer(0)operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i1) operator(=) integer(0)operator(;) ident(i1) operator(<) ident(realLength)operator(;) ident(i1)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(e) operator(=) ident(values)operator([)ident(begin) operator(+) ident(i1)operator(])operator(;) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(e)operator(,) ident(item)operator(\))operator(\)) keyword(continue)operator(;) - keyword(if) operator(()ident(i1) operator(!=) ident(i2)operator(\)) ident(store)operator(()ident(i2)operator(,) ident(e)operator(\))operator(;) - ident(i2)operator(++)operator(;) - operator(}) - - keyword(if) operator(()ident(realLength) operator(==) ident(i2)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(item)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - directive(final) type(int) ident(realLength) operator(=) local_variable(this)operator(.)ident(realLength)operator(;) - directive(final) type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - directive(final) ident(IRubyObject)type([]) ident(values) operator(=) local_variable(this)operator(.)ident(values)operator(;) - keyword(if) operator(()ident(realLength) operator(>) ident(i2)operator(\)) operator({) - keyword(try) operator({) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(values)operator(,) ident(begin) operator(+) ident(i2)operator(,) ident(begin) operator(+) ident(realLength)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(realLength) operator(=) ident(i2)operator(;) - keyword(if) operator(()ident(i2) operator(<)operator(<) integer(1) operator(<) ident(values)operator(.)ident(length) operator(&&) ident(values)operator(.)ident(length) operator(>) ident(ARRAY_DEFAULT_SIZE)operator(\)) ident(realloc)operator(()ident(i2) operator(<)operator(<) integer(1)operator(\))operator(;) - operator(}) - - keyword(return) ident(item)operator(;) - operator(}) - - comment(/** rb_ary_delete_at - * - */) - directive(private) directive(final) ident(IRubyObject) ident(delete_at)operator(()type(int) ident(pos)operator(\)) operator({) - type(int) ident(len) operator(=) ident(realLength)operator(;) - - keyword(if) operator(()ident(pos) operator(>=) ident(len)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) ident(pos) operator(+=) ident(len)operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(modify)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(obj) operator(=) ident(values)operator([)ident(pos)operator(])operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) ident(pos) operator(+) integer(1)operator(,) ident(values)operator(,) ident(pos)operator(,) ident(len) operator(-) operator(()ident(pos) operator(+) integer(1)operator(\))operator(\))operator(;) - ident(values)operator([)ident(realLength)operator(-)integer(1)operator(]) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(realLength)operator(--)operator(;) - - keyword(return) ident(obj)operator(;) - operator(}) - - comment(/** rb_ary_delete_at_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete_at)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(delete_at)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(delete_at)operator(()operator(()type(int)operator(\)) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(obj)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_reject_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reject)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(reject)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(aryDup)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(reject_bang)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_reject_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reject!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(reject_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(i2) operator(=) integer(0)operator(;) - ident(modify)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i1) operator(=) integer(0)operator(;) ident(i1) operator(<) ident(realLength)operator(;) ident(i1)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(values)operator([)ident(i1)operator(])operator(;) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(v)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(continue)operator(;) - - keyword(if) operator(()ident(i1) operator(!=) ident(i2)operator(\)) ident(store)operator(()ident(i2)operator(,) ident(v)operator(\))operator(;) - ident(i2)operator(++)operator(;) - operator(}) - keyword(if) operator(()ident(realLength) operator(==) ident(i2)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(i2) operator(<) ident(realLength)operator(\)) operator({) - keyword(try) operator({) - pre_type(Arrays)operator(.)ident(fill)operator(()ident(values)operator(,) ident(i2)operator(,) ident(realLength)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(realLength) operator(=) ident(i2)operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_delete_if - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete_if)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(delete_if)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(reject_bang)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_zip - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zip)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(zip)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(args)operator([)ident(i)operator(]) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToArray)operator(()operator(\))operator(;) - operator(}) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyArray) ident(tmp) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(args)operator(.)ident(length) operator(+) integer(1)operator(\))operator(;) - ident(tmp)operator(.)ident(append)operator(()ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(args)operator(.)ident(length)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(tmp)operator(.)ident(append)operator(()operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)ident(j)operator(])operator(\))operator(.)ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(tmp)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - type(int) ident(len) operator(=) ident(realLength)operator(;) - ident(RubyArray) ident(result) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(len)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyArray) ident(tmp) operator(=) keyword(new) ident(RubyArray)operator(()ident(runtime)operator(,) ident(args)operator(.)ident(length) operator(+) integer(1)operator(\))operator(;) - ident(tmp)operator(.)ident(append)operator(()ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(args)operator(.)ident(length)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(tmp)operator(.)ident(append)operator(()operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)ident(j)operator(])operator(\))operator(.)ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - ident(result)operator(.)ident(append)operator(()ident(tmp)operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_ary_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(RubyArray) ident(ary2) operator(=) ident(obj)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - - type(int) ident(len) operator(=) ident(realLength)operator(;) - - keyword(if) operator(()ident(len) operator(>) ident(ary2)operator(.)ident(realLength)operator(\)) ident(len) operator(=) ident(ary2)operator(.)ident(realLength)operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(elt)operator(()ident(i)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(ary2)operator(.)ident(elt)operator(()ident(i)operator(\))operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(v) keyword(instanceof) ident(RubyFixnum)operator(\)) operator(||) operator(()operator(()ident(RubyFixnum)operator(\)) ident(v)operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(!=) integer(0)operator(\)) keyword(return) ident(v)operator(;) - operator(}) - ident(len) operator(=) ident(realLength) operator(-) ident(ary2)operator(.)ident(realLength)operator(;) - - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(>) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(slice_bang)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(slice_bang)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_ary_slice_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(slice!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRange)operator(\)) operator({) - type(long)type([]) ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(arg0)operator(\))operator(.)ident(begLen)operator(()ident(realLength)operator(,) integer(1)operator(\))operator(;) - type(long) ident(pos) operator(=) ident(beglen)operator([)integer(0)operator(])operator(;) - type(long) ident(len) operator(=) ident(beglen)operator([)integer(1)operator(])operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) ident(pos) operator(=) ident(realLength) operator(+) ident(pos)operator(;) - - ident(arg0) operator(=) ident(subseq)operator(()ident(pos)operator(,) ident(len)operator(\))operator(;) - ident(splice)operator(()ident(pos)operator(,) ident(len)operator(,) pre_constant(null)operator(\))operator(;) - keyword(return) ident(arg0)operator(;) - operator(}) - keyword(return) ident(delete_at)operator(()operator(()type(int)operator(\)) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_ary_slice_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(slice!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - type(long) ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - type(long) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg1)operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) ident(pos) operator(=) ident(realLength) operator(+) ident(pos)operator(;) - - ident(arg1) operator(=) ident(subseq)operator(()ident(pos)operator(,) ident(len)operator(\))operator(;) - ident(splice)operator(()ident(pos)operator(,) ident(len)operator(,) pre_constant(null)operator(\))operator(;) - - keyword(return) ident(arg1)operator(;) - operator(}) - - comment(/** rb_ary_assoc - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(assoc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(assoc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(v) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) operator(()ident(RubyArray)operator(\))ident(v)operator(;) - keyword(if) operator(()ident(arr)operator(.)ident(realLength) operator(>) integer(0) operator(&&) ident(equalInternal)operator(()ident(context)operator(,) ident(arr)operator(.)ident(values)operator([)ident(arr)operator(.)ident(begin)operator(])operator(,) ident(key)operator(\))operator(\)) keyword(return) ident(arr)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_ary_rassoc - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rassoc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(rassoc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(values)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(v) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) operator(()ident(RubyArray)operator(\))ident(v)operator(;) - keyword(if) operator(()ident(arr)operator(.)ident(realLength) operator(>) integer(1) operator(&&) ident(equalInternal)operator(()ident(context)operator(,) ident(arr)operator(.)ident(values)operator([)ident(arr)operator(.)ident(begin) operator(+) integer(1)operator(])operator(,) ident(value)operator(\))operator(\)) keyword(return) ident(arr)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** flatten - * - */) - directive(private) directive(final) type(int) ident(flatten)operator(()ident(ThreadContext) ident(context)operator(,) type(int) ident(index)operator(,) ident(RubyArray) ident(ary2)operator(,) ident(RubyArray) ident(memo)operator(\)) operator({) - type(int) ident(i) operator(=) ident(index)operator(;) - type(int) ident(n)operator(;) - type(int) ident(lim) operator(=) ident(index) operator(+) ident(ary2)operator(.)ident(realLength)operator(;) - - ident(IRubyObject) ident(id) operator(=) ident(ary2)operator(.)ident(id)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(memo)operator(.)ident(includes)operator(()ident(context)operator(,) ident(id)operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(tried to flatten recursive array)delimiter(")>operator(\))operator(;) - - ident(memo)operator(.)ident(append)operator(()ident(id)operator(\))operator(;) - ident(splice)operator(()ident(index)operator(,) integer(1)operator(,) ident(ary2)operator(\))operator(;) - keyword(while) operator(()ident(i) operator(<) ident(lim)operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(elt)operator(()ident(i)operator(\))operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(n) operator(=) ident(flatten)operator(()ident(context)operator(,) ident(i)operator(,) operator(()ident(RubyArray)operator(\)) ident(tmp)operator(,) ident(memo)operator(\))operator(;) - ident(i) operator(+=) ident(n)operator(;) - ident(lim) operator(+=) ident(n)operator(;) - operator(}) - ident(i)operator(++)operator(;) - operator(}) - ident(memo)operator(.)ident(pop)operator(()operator(\))operator(;) - keyword(return) ident(lim) operator(-) ident(index) operator(-) integer(1)operator(;) comment(/* returns number of increased items */) - operator(}) - - comment(/** rb_ary_flatten_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flatten!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(flatten_bang)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(int) ident(i) operator(=) integer(0)operator(;) - ident(RubyArray) ident(memo) operator(=) pre_constant(null)operator(;) - - keyword(while) operator(()ident(i) operator(<) ident(realLength)operator(\)) operator({) - ident(IRubyObject) ident(ary2) operator(=) ident(values)operator([)ident(begin) operator(+) ident(i)operator(])operator(;) - ident(IRubyObject) ident(tmp) operator(=) ident(ary2)operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(memo) operator(==) pre_constant(null)operator(\)) operator({) - ident(memo) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - ident(memo)operator(.)ident(values) operator(=) ident(reserve)operator(()ident(ARRAY_DEFAULT_SIZE)operator(\))operator(;) - operator(}) - - ident(i) operator(+=) ident(flatten)operator(()ident(context)operator(,) ident(i)operator(,) operator(()ident(RubyArray)operator(\)) ident(tmp)operator(,) ident(memo)operator(\))operator(;) - operator(}) - ident(i)operator(++)operator(;) - operator(}) - keyword(if) operator(()ident(memo) operator(==) pre_constant(null)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_flatten - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flatten)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(flatten)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(aryDup)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(flatten_bang)operator(()ident(context)operator(\))operator(;) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_nitems - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nitems)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nitems)operator(()operator(\)) operator({) - type(int) ident(n) operator(=) integer(0)operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(values)operator([)ident(i)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(n)operator(++)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(n)operator(\))operator(;) - operator(}) - - comment(/** rb_ary_plus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(RubyArray) ident(y) operator(=) ident(obj)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - type(int) ident(len) operator(=) ident(realLength) operator(+) ident(y)operator(.)ident(realLength)operator(;) - ident(RubyArray) ident(z) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(len)operator(\))operator(;) - keyword(try) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) ident(begin)operator(,) ident(z)operator(.)ident(values)operator(,) integer(0)operator(,) ident(realLength)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(y)operator(.)ident(values)operator(,) ident(y)operator(.)ident(begin)operator(,) ident(z)operator(.)ident(values)operator(,) ident(realLength)operator(,) ident(y)operator(.)ident(realLength)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - ident(z)operator(.)ident(realLength) operator(=) ident(len)operator(;) - keyword(return) ident(z)operator(;) - operator(}) - - comment(/** rb_ary_times - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_times)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(times)operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(times)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(join)operator(()ident(context)operator(,) ident(tmp)operator(\))operator(;) - - type(long) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(times)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) keyword(return) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) integer(0)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative argument)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()pre_type(Long)operator(.)ident(MAX_VALUE) operator(/) ident(len) operator(<) ident(realLength)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument too big)delimiter(")>operator(\))operator(;) - operator(}) - - ident(len) operator(*=) ident(realLength)operator(;) - - ident(RubyArray) ident(ary2) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(len)operator(\))operator(;) - ident(ary2)operator(.)ident(realLength) operator(=) operator(()type(int)operator(\)) ident(len)operator(;) - - keyword(try) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i) operator(+=) ident(realLength)operator(\)) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) ident(begin)operator(,) ident(ary2)operator(.)ident(values)operator(,) ident(i)operator(,) ident(realLength)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(ArrayIndexOutOfBoundsException) ident(e)operator(\)) operator({) - ident(concurrentModification)operator(()operator(\))operator(;) - operator(}) - - ident(ary2)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - - keyword(return) ident(ary2)operator(;) - operator(}) - - comment(/** ary_make_hash - * - */) - directive(private) directive(final) ident(RubyHash) ident(makeHash)operator(()ident(RubyArray) ident(ary2)operator(\)) operator({) - ident(RubyHash) ident(hash) operator(=) keyword(new) ident(RubyHash)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(hash)operator(.)ident(fastASet)operator(()ident(values)operator([)ident(i)operator(])operator(,) ident(NEVER)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(ary2) operator(!=) pre_constant(null)operator(\)) operator({) - ident(begin) operator(=) ident(ary2)operator(.)ident(begin)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(ary2)operator(.)ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(hash)operator(.)ident(fastASet)operator(()ident(ary2)operator(.)ident(values)operator([)ident(i)operator(])operator(,) ident(NEVER)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(hash)operator(;) - operator(}) - - comment(/** rb_ary_uniq_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(uniq!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(uniq_bang)operator(()operator(\)) operator({) - ident(RubyHash) ident(hash) operator(=) ident(makeHash)operator(()pre_constant(null)operator(\))operator(;) - - keyword(if) operator(()ident(realLength) operator(==) ident(hash)operator(.)ident(size)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - type(int) ident(j) operator(=) integer(0)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(elt)operator(()ident(i)operator(\))operator(;) - keyword(if) operator(()ident(hash)operator(.)ident(fastDelete)operator(()ident(v)operator(\))operator(\)) ident(store)operator(()ident(j)operator(++)operator(,) ident(v)operator(\))operator(;) - operator(}) - ident(realLength) operator(=) ident(j)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_ary_uniq - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(uniq)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(uniq)operator(()operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(aryDup)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(uniq_bang)operator(()operator(\))operator(;) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_diff - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_diff)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyHash) ident(hash) operator(=) ident(other)operator(.)ident(convertToArray)operator(()operator(\))operator(.)ident(makeHash)operator(()pre_constant(null)operator(\))operator(;) - ident(RubyArray) ident(ary3) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(hash)operator(.)ident(fastARef)operator(()ident(values)operator([)ident(i)operator(])operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(continue)operator(;) - ident(ary3)operator(.)ident(append)operator(()ident(elt)operator(()ident(i) operator(-) ident(begin)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(ary3)operator(;) - operator(}) - - comment(/** rb_ary_and - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_and)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyArray) ident(ary2) operator(=) ident(other)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(RubyHash) ident(hash) operator(=) ident(ary2)operator(.)ident(makeHash)operator(()pre_constant(null)operator(\))operator(;) - ident(RubyArray) ident(ary3) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(realLength) operator(<) ident(ary2)operator(.)ident(realLength) operator(?) ident(realLength) operator(:) ident(ary2)operator(.)ident(realLength)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(elt)operator(()ident(i)operator(\))operator(;) - keyword(if) operator(()ident(hash)operator(.)ident(fastDelete)operator(()ident(v)operator(\))operator(\)) ident(ary3)operator(.)ident(append)operator(()ident(v)operator(\))operator(;) - operator(}) - - keyword(return) ident(ary3)operator(;) - operator(}) - - comment(/** rb_ary_or - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_or)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyArray) ident(ary2) operator(=) ident(other)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(RubyHash) ident(set) operator(=) ident(makeHash)operator(()ident(ary2)operator(\))operator(;) - - ident(RubyArray) ident(ary3) operator(=) keyword(new) ident(RubyArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(realLength) operator(+) ident(ary2)operator(.)ident(realLength)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(elt)operator(()ident(i)operator(\))operator(;) - keyword(if) operator(()ident(set)operator(.)ident(fastDelete)operator(()ident(v)operator(\))operator(\)) ident(ary3)operator(.)ident(append)operator(()ident(v)operator(\))operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(ary2)operator(.)ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(ary2)operator(.)ident(elt)operator(()ident(i)operator(\))operator(;) - keyword(if) operator(()ident(set)operator(.)ident(fastDelete)operator(()ident(v)operator(\))operator(\)) ident(ary3)operator(.)ident(append)operator(()ident(v)operator(\))operator(;) - operator(}) - keyword(return) ident(ary3)operator(;) - operator(}) - - comment(/** rb_ary_sort - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sort)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(sort)operator(()ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(aryDup)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(sort_bang)operator(()ident(block)operator(\))operator(;) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_ary_sort_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sort!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(sort_bang)operator(()ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - keyword(if) operator(()ident(realLength) operator(>) integer(1)operator(\)) operator({) - ident(flags) operator(|=) ident(TMPLOCK_ARR_F)operator(;) - keyword(try) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - pre_type(Arrays)operator(.)ident(sort)operator(()ident(values)operator(,) integer(0)operator(,) ident(realLength)operator(,) keyword(new) ident(BlockComparator)operator(()ident(block)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(Arrays)operator(.)ident(sort)operator(()ident(values)operator(,) integer(0)operator(,) ident(realLength)operator(,) keyword(new) ident(DefaultComparator)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(flags) operator(&=) operator(~)ident(TMPLOCK_ARR_F)operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(final) type(class) class(BlockComparator) directive(implements) pre_type(Comparator) operator({) - directive(private) ident(Block) ident(block)operator(;) - - directive(public) ident(BlockComparator)operator(()ident(Block) ident(block)operator(\)) operator({) - local_variable(this)operator(.)ident(block) operator(=) ident(block)operator(;) - operator(}) - - directive(public) type(int) ident(compare)operator(()pre_type(Object) ident(o1)operator(,) pre_type(Object) ident(o2)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(obj1) operator(=) operator(()ident(IRubyObject)operator(\)) ident(o1)operator(;) - ident(IRubyObject) ident(obj2) operator(=) operator(()ident(IRubyObject)operator(\)) ident(o2)operator(;) - ident(IRubyObject) ident(ret) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(obj1)operator(,) ident(obj2)operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(true)operator(\))operator(;) - type(int) ident(n) operator(=) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(context)operator(,) ident(ret)operator(,) ident(obj1)operator(,) ident(obj2)operator(\))operator(;) - comment(//TODO: ary_sort_check should be done here) - keyword(return) ident(n)operator(;) - operator(}) - operator(}) - - directive(static) directive(final) type(class) class(DefaultComparator) directive(implements) pre_type(Comparator) operator({) - directive(public) type(int) ident(compare)operator(()pre_type(Object) ident(o1)operator(,) pre_type(Object) ident(o2)operator(\)) operator({) - keyword(if) operator(()ident(o1) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(o2) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(compareFixnums)operator(()ident(o1)operator(,) ident(o2)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(o1) keyword(instanceof) ident(RubyString) operator(&&) ident(o2) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyString)operator(\)) ident(o1)operator(\))operator(.)ident(op_cmp)operator(()operator(()ident(RubyString)operator(\)) ident(o2)operator(\))operator(;) - operator(}) - comment(//TODO: ary_sort_check should be done here) - keyword(return) ident(compareOthers)operator(()operator(()ident(IRubyObject)operator(\))ident(o1)operator(,) operator(()ident(IRubyObject)operator(\))ident(o2)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(compareFixnums)operator(()pre_type(Object) ident(o1)operator(,) pre_type(Object) ident(o2)operator(\)) operator({) - type(long) ident(a) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(o1)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(b) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(o2)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(a) operator(>) ident(b)operator(\)) operator({) - keyword(return) integer(1)operator(;) - operator(}) - keyword(if) operator(()ident(a) operator(<) ident(b)operator(\)) operator({) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - directive(private) type(int) ident(compareOthers)operator(()ident(IRubyObject) ident(o1)operator(,) ident(IRubyObject) ident(o2)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(o1)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(ret) operator(=) ident(o1)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(o2)operator(\))operator(;) - type(int) ident(n) operator(=) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(context)operator(,) ident(ret)operator(,) ident(o1)operator(,) ident(o2)operator(\))operator(;) - comment(//TODO: ary_sort_check should be done here) - keyword(return) ident(n)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyArray) ident(array)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) exception(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(array)operator(\))operator(;) - ident(output)operator(.)ident(writeInt)operator(()ident(array)operator(.)ident(getList)operator(()operator(\))operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(array)operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(output)operator(.)ident(dumpObject)operator(()operator(()ident(IRubyObject)operator(\)) ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyArray) ident(result) operator(=) ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - type(int) ident(size) operator(=) ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(size)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * @see org.jruby.util.Pack#pack - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pack)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyString) ident(pack)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(RubyString) ident(iFmt) operator(=) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - keyword(return) ident(Pack)operator(.)ident(pack)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) ident(iFmt)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) pre_type(List)operator(.)ident(class)operator(;) - operator(}) - - comment(// Satisfy java.util.List interface (for Java integration\)) - directive(public) type(int) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(realLength)operator(;) - operator(}) - - directive(public) type(boolean) ident(isEmpty)operator(()operator(\)) operator({) - keyword(return) ident(realLength) operator(==) integer(0)operator(;) - operator(}) - - directive(public) type(boolean) ident(contains)operator(()pre_type(Object) ident(element)operator(\)) operator({) - keyword(return) ident(indexOf)operator(()ident(element)operator(\)) operator(!=) operator(-)integer(1)operator(;) - operator(}) - - directive(public) pre_type(Object)type([]) ident(toArray)operator(()operator(\)) operator({) - pre_type(Object)type([]) ident(array) operator(=) keyword(new) pre_type(Object)operator([)ident(realLength)operator(])operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(array)operator([)ident(i) operator(-) ident(begin)operator(]) operator(=) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(values)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(array)operator(;) - operator(}) - - directive(public) pre_type(Object)type([]) ident(toArray)operator(()directive(final) pre_type(Object)type([]) ident(arg)operator(\)) operator({) - pre_type(Object)type([]) ident(array) operator(=) ident(arg)operator(;) - keyword(if) operator(()ident(array)operator(.)ident(length) operator(<) ident(realLength)operator(\)) operator({) - pre_type(Class) ident(type) operator(=) ident(array)operator(.)ident(getClass)operator(()operator(\))operator(.)ident(getComponentType)operator(()operator(\))operator(;) - ident(array) operator(=) operator(()pre_type(Object)type([])operator(\)) pre_type(Array)operator(.)ident(newInstance)operator(()ident(type)operator(,) ident(realLength)operator(\))operator(;) - operator(}) - type(int) ident(length) operator(=) ident(realLength) operator(-) ident(begin)operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(array)operator([)ident(i)operator(]) operator(=) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(values)operator([)ident(i) operator(+) ident(begin)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(array)operator(;) - operator(}) - - directive(public) type(boolean) ident(add)operator(()pre_type(Object) ident(element)operator(\)) operator({) - ident(append)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(\))operator(;) - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(public) type(boolean) ident(remove)operator(()pre_type(Object) ident(element)operator(\)) operator({) - ident(IRubyObject) ident(deleted) operator(=) ident(delete)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - keyword(return) ident(deleted)operator(.)ident(isNil)operator(()operator(\)) operator(?) pre_constant(false) operator(:) pre_constant(true)operator(;) comment(// TODO: is this correct ?) - operator(}) - - directive(public) type(boolean) ident(containsAll)operator(()pre_type(Collection) ident(c)operator(\)) operator({) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(c)operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - keyword(if) operator(()ident(indexOf)operator(()ident(iter)operator(.)ident(next)operator(()operator(\))operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(public) type(boolean) ident(addAll)operator(()pre_type(Collection) ident(c)operator(\)) operator({) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(c)operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(add)operator(()ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) operator(!)ident(c)operator(.)ident(isEmpty)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(addAll)operator(()type(int) ident(index)operator(,) pre_type(Collection) ident(c)operator(\)) operator({) - pre_type(Iterator) ident(iter) operator(=) ident(c)operator(.)ident(iterator)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(index)operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(add)operator(()ident(i)operator(,) ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) operator(!)ident(c)operator(.)ident(isEmpty)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(removeAll)operator(()pre_type(Collection) ident(c)operator(\)) operator({) - type(boolean) ident(listChanged) operator(=) pre_constant(false)operator(;) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(c)operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - keyword(if) operator(()ident(remove)operator(()ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(\)) operator({) - ident(listChanged) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - keyword(return) ident(listChanged)operator(;) - operator(}) - - directive(public) type(boolean) ident(retainAll)operator(()pre_type(Collection) ident(c)operator(\)) operator({) - type(boolean) ident(listChanged) operator(=) pre_constant(false)operator(;) - - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(Object) ident(element) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(c)operator(.)ident(contains)operator(()ident(element)operator(\))operator(\)) operator({) - ident(remove)operator(()ident(element)operator(\))operator(;) - ident(listChanged) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - keyword(return) ident(listChanged)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(get)operator(()type(int) ident(index)operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()operator(()ident(IRubyObject)operator(\)) ident(elt)operator(()ident(index)operator(\))operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(set)operator(()type(int) ident(index)operator(,) pre_type(Object) ident(element)operator(\)) operator({) - keyword(return) ident(store)operator(()ident(index)operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(\))operator(;) - operator(}) - - comment(// TODO: make more efficient by not creating IRubyArray[]) - directive(public) type(void) ident(add)operator(()type(int) ident(index)operator(,) pre_type(Object) ident(element)operator(\)) operator({) - ident(insert)operator(()keyword(new) ident(IRubyObject)type([])operator({)ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(index)operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(})operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(remove)operator(()type(int) ident(index)operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(delete_at)operator(()ident(index)operator(\))operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(public) type(int) ident(indexOf)operator(()pre_type(Object) ident(element)operator(\)) operator({) - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - - keyword(if) operator(()ident(element) operator(!=) pre_constant(null)operator(\)) operator({) - ident(IRubyObject) ident(convertedElement) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin)operator(;) ident(i) operator(<) ident(begin) operator(+) ident(realLength)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(convertedElement)operator(.)ident(equals)operator(()ident(values)operator([)ident(i)operator(])operator(\))operator(\)) operator({) - keyword(return) ident(i)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - - directive(public) type(int) ident(lastIndexOf)operator(()pre_type(Object) ident(element)operator(\)) operator({) - type(int) ident(begin) operator(=) local_variable(this)operator(.)ident(begin)operator(;) - - keyword(if) operator(()ident(element) operator(!=) pre_constant(null)operator(\)) operator({) - ident(IRubyObject) ident(convertedElement) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(element)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(begin) operator(+) ident(realLength) operator(-) integer(1)operator(;) ident(i) operator(>=) ident(begin)operator(;) ident(i)operator(--)operator(\)) operator({) - keyword(if) operator(()ident(convertedElement)operator(.)ident(equals)operator(()ident(values)operator([)ident(i)operator(])operator(\))operator(\)) operator({) - keyword(return) ident(i)operator(;) - operator(}) - operator(}) - operator(}) - - keyword(return) operator(-)integer(1)operator(;) - operator(}) - - directive(public) type(class) class(RubyArrayConversionIterator) directive(implements) pre_type(Iterator) operator({) - directive(protected) type(int) ident(index) operator(=) integer(0)operator(;) - directive(protected) type(int) ident(last) operator(=) operator(-)integer(1)operator(;) - - directive(public) type(boolean) ident(hasNext)operator(()operator(\)) operator({) - keyword(return) ident(index) operator(<) ident(realLength)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(next)operator(()operator(\)) operator({) - ident(IRubyObject) ident(element) operator(=) ident(elt)operator(()ident(index)operator(\))operator(;) - ident(last) operator(=) ident(index)operator(++)operator(;) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(element)operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(remove)operator(()operator(\)) operator({) - keyword(if) operator(()ident(last) operator(==) operator(-)integer(1)operator(\)) keyword(throw) keyword(new) exception(IllegalStateException)operator(()operator(\))operator(;) - - ident(delete_at)operator(()ident(last)operator(\))operator(;) - keyword(if) operator(()ident(last) operator(<) ident(index)operator(\)) ident(index)operator(--)operator(;) - - ident(last) operator(=) operator(-)integer(1)operator(;) - - operator(}) - operator(}) - - directive(public) pre_type(Iterator) ident(iterator)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArrayConversionIterator)operator(()operator(\))operator(;) - operator(}) - - directive(final) type(class) class(RubyArrayConversionListIterator) directive(extends) ident(RubyArrayConversionIterator) directive(implements) pre_type(ListIterator) operator({) - directive(public) ident(RubyArrayConversionListIterator)operator(()operator(\)) operator({) - operator(}) - - directive(public) ident(RubyArrayConversionListIterator)operator(()type(int) ident(index)operator(\)) operator({) - local_variable(this)operator(.)ident(index) operator(=) ident(index)operator(;) - operator(}) - - directive(public) type(boolean) ident(hasPrevious)operator(()operator(\)) operator({) - keyword(return) ident(index) operator(>=) integer(0)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(previous)operator(()operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()operator(()ident(IRubyObject)operator(\)) ident(elt)operator(()ident(last) operator(=) operator(--)ident(index)operator(\))operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(public) type(int) ident(nextIndex)operator(()operator(\)) operator({) - keyword(return) ident(index)operator(;) - operator(}) - - directive(public) type(int) ident(previousIndex)operator(()operator(\)) operator({) - keyword(return) ident(index) operator(-) integer(1)operator(;) - operator(}) - - directive(public) type(void) ident(set)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(last) operator(==) operator(-)integer(1)operator(\)) keyword(throw) keyword(new) exception(IllegalStateException)operator(()operator(\))operator(;) - - ident(store)operator(()ident(last)operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(obj)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(add)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - ident(insert)operator(()keyword(new) ident(IRubyObject)type([]) operator({) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(index)operator(++)operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(obj)operator(\)) operator(})operator(\))operator(;) - ident(last) operator(=) operator(-)integer(1)operator(;) - operator(}) - operator(}) - - directive(public) pre_type(ListIterator) ident(listIterator)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArrayConversionListIterator)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(ListIterator) ident(listIterator)operator(()type(int) ident(index)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyArrayConversionListIterator)operator(()ident(index)operator(\))operator(;) - operator(}) - - comment(// TODO: list.subList(from, to\).clear(\) is supposed to clear the sublist from the list.) - comment(// How can we support this operation?) - directive(public) pre_type(List) ident(subList)operator(()type(int) ident(fromIndex)operator(,) type(int) ident(toIndex)operator(\)) operator({) - keyword(if) operator(()ident(fromIndex) operator(<) integer(0) operator(||) ident(toIndex) operator(>) ident(size)operator(()operator(\)) operator(||) ident(fromIndex) operator(>) ident(toIndex)operator(\)) operator({) - keyword(throw) keyword(new) exception(IndexOutOfBoundsException)operator(()operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(subList) operator(=) ident(subseq)operator(()ident(fromIndex)operator(,) ident(toIndex) operator(-) ident(fromIndex) operator(+) integer(1)operator(\))operator(;) - - keyword(return) ident(subList)operator(.)ident(isNil)operator(()operator(\)) operator(?) pre_constant(null) operator(:) operator(()pre_type(List)operator(\)) ident(subList)operator(;) - operator(}) - - directive(public) type(void) ident(clear)operator(()operator(\)) operator({) - ident(rb_clear)operator(()operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.math.BigDecimal)operator(;) -keyword(import) include(java.math.BigInteger)operator(;) -keyword(import) include(java.math.MathContext)operator(;) -keyword(import) include(java.math.RoundingMode)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.regex.Matcher)operator(;) -keyword(import) include(java.util.regex.Pattern)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyConstant)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallbackFactory)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(BigDecimal)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Numeric)delimiter(")>operator(\)) -directive(public) type(class) class(RubyBigDecimal) directive(extends) ident(RubyNumeric) operator({) - directive(private) directive(static) directive(final) ident(ObjectAllocator) ident(BIGDECIMAL_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_DOWN) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_DOWN)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_CEILING) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_CEILING)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_UP) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_UP)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_HALF_DOWN) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_HALF_DOWN)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_HALF_EVEN) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_HALF_EVEN)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_HALF_UP) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_HALF_UP)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_FLOOR) operator(=) pre_type(BigDecimal)operator(.)ident(ROUND_FLOOR)operator(;) - - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_POSITIVE_INFINITE)operator(=)integer(3)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_OVERFLOW)operator(=)integer(1)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_POSITIVE_ZERO)operator(=)integer(1)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_ALL)operator(=)integer(255)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_NEGATIVE_FINITE)operator(=)operator(-)integer(2)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_UNDERFLOW)operator(=)integer(4)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_NaN)operator(=)integer(0)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(BASE)operator(=)integer(10000)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(ROUND_MODE)operator(=)integer(256)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_POSITIVE_FINITE)operator(=)integer(2)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_INFINITY)operator(=)integer(1)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_NEGATIVE_INFINITE)operator(=)operator(-)integer(3)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_ZERODIVIDE)operator(=)integer(1)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(SIGN_NEGATIVE_ZERO)operator(=)operator(-)integer(1)operator(;) - annotation(@JRubyConstant) - directive(public) directive(final) directive(static) type(int) ident(EXCEPTION_NaN)operator(=)integer(2)operator(;) - - comment(// Static constants) - directive(private) directive(static) directive(final) pre_type(BigDecimal) ident(TWO) operator(=) keyword(new) pre_type(BigDecimal)operator(()integer(2)operator(\))operator(;) - directive(private) directive(static) directive(final) type(double) ident(SQRT_10) operator(=) float(3.162277660168379332)operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createBigDecimal)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(result) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(,)ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(,) ident(BIGDECIMAL_ALLOCATOR)operator(\))operator(;) - - ident(CallbackFactory) ident(callbackFactory) operator(=) ident(runtime)operator(.)ident(callbackFactory)operator(()ident(RubyBigDecimal)operator(.)ident(class)operator(\))operator(;) - - ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(BigDecimalKernelMethods)operator(.)ident(class)operator(\))operator(;) - - ident(result)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpPrecLimit)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpExceptionMode)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpRoundingMode)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ROUND_HALF_UP)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyBigDecimal)operator(.)ident(class)operator(\))operator(;) - ident(result)operator(.)ident(defineAnnotatedConstants)operator(()ident(RubyBigDecimal)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) type(boolean) ident(isNaN) operator(=) pre_constant(false)operator(;) - directive(private) type(int) ident(infinitySign) operator(=) integer(0)operator(;) - directive(private) type(int) ident(zeroSign) operator(=) integer(0)operator(;) - directive(private) pre_type(BigDecimal) ident(value)operator(;) - - directive(public) pre_type(BigDecimal) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - directive(public) ident(RubyBigDecimal)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyBigDecimal)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(BigDecimal) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - directive(public) directive(static) type(class) class(BigDecimalKernelMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(BigDecimal)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newBigDecimal)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyBigDecimal)operator(.)ident(newBigDecimal)operator(()ident(recv)operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyBigDecimal) ident(newBigDecimal)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(newInstance)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ver)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(ver)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(1.0.1)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_dump)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(dump)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(RubyString) ident(precision) operator(=) ident(RubyString)operator(.)ident(newUnicodeString)operator(()ident(args)operator([)integer(0)operator(])operator(.)ident(getRuntime)operator(()operator(\))operator(,) string<delimiter(")content(0:)delimiter(")>operator(\))operator(;) - ident(RubyString) ident(str) operator(=) local_variable(this)operator(.)ident(asString)operator(()operator(\))operator(;) - keyword(return) ident(precision)operator(.)ident(append)operator(()ident(str)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_load)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBigDecimal) ident(load)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(from)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyBigDecimal) ident(rubyBigDecimal) operator(=) operator(()ident(RubyBigDecimal)operator(\)) operator(()operator(()operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(.)ident(allocate)operator(()operator(\))operator(\))operator(;) - pre_type(String) ident(precisionAndValue) operator(=) ident(from)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(;) - pre_type(String) ident(value) operator(=) ident(precisionAndValue)operator(.)ident(substring)operator(()ident(precisionAndValue)operator(.)ident(indexOf)operator(()string<delimiter(")content(:)delimiter(")>operator(\))operator(+)integer(1)operator(\))operator(;) - ident(rubyBigDecimal)operator(.)ident(value) operator(=) keyword(new) pre_type(BigDecimal)operator(()ident(value)operator(\))operator(;) - keyword(return) ident(rubyBigDecimal)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(double_fig)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(double_fig)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(20)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(limit)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(limit)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyModule) ident(c) operator(=) operator(()ident(RubyModule)operator(\))ident(recv)operator(;) - ident(IRubyObject) ident(nCur) operator(=) ident(c)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpPrecLimit)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(arg) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - keyword(if) operator(()operator(!)ident(arg)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(arg) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(arg)operator(,) ident(runtime)operator(.)ident(getFixnum)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()integer(0) operator(>) operator(()operator(()ident(RubyFixnum)operator(\))ident(arg)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument must be positive)delimiter(")>operator(\))operator(;) - operator(}) - ident(c)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpPrecLimit)delimiter(")>operator(,) ident(arg)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(nCur)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mode)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(mode)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - comment(// FIXME: I doubt any of the constants referenced in this method) - comment(// are ever redefined -- should compare to the known values, rather) - comment(// than do an expensive constant lookup.) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyClass) ident(clazz) operator(=) ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\))operator(;) - ident(RubyModule) ident(c) operator(=) operator(()ident(RubyModule)operator(\))ident(recv)operator(;) - - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(runtime)operator(,) ident(args)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - - ident(IRubyObject) ident(mode) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(IRubyObject) ident(value) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - - keyword(if) operator(()operator(!)operator(()ident(mode) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(mode)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Fixnum\))delimiter(")>operator(\))operator(;) - operator(}) - - type(long) ident(longMode) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(mode)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(EXCEPTION_ALL) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(EXCEPTION_ALL)delimiter(")>operator(\))operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(()ident(longMode) operator(&) ident(EXCEPTION_ALL)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(c)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpExceptionMode)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)operator(()ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator(&&) operator(!)operator(()ident(value) keyword(instanceof) ident(RubyBoolean)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(second argument must be true or false)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyFixnum) ident(currentExceptionMode) operator(=) operator(()ident(RubyFixnum)operator(\))ident(c)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpExceptionMode)delimiter(")>operator(\))operator(;) - ident(RubyFixnum) ident(newExceptionMode) operator(=) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) ident(currentExceptionMode)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - - ident(RubyFixnum) ident(EXCEPTION_INFINITY) operator(=) operator(()ident(RubyFixnum)operator(\))ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(EXCEPTION_INFINITY)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(()ident(longMode) operator(&) ident(EXCEPTION_INFINITY)operator(.)ident(getLongValue)operator(()operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(newExceptionMode) operator(=) operator(()ident(value)operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator(?) operator(()ident(RubyFixnum)operator(\))ident(currentExceptionMode)operator(.)ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(|)delimiter(")>operator(,) ident(EXCEPTION_INFINITY)operator(\)) - operator(:) operator(()ident(RubyFixnum)operator(\))ident(currentExceptionMode)operator(.)ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(&)delimiter(")>operator(,) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) operator(~)operator(()ident(EXCEPTION_INFINITY)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - ident(RubyFixnum) ident(EXCEPTION_NaN) operator(=) operator(()ident(RubyFixnum)operator(\))ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(EXCEPTION_NaN)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(()ident(longMode) operator(&) ident(EXCEPTION_NaN)operator(.)ident(getLongValue)operator(()operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(newExceptionMode) operator(=) operator(()ident(value)operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator(?) operator(()ident(RubyFixnum)operator(\))ident(currentExceptionMode)operator(.)ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(|)delimiter(")>operator(,) ident(EXCEPTION_NaN)operator(\)) - operator(:) operator(()ident(RubyFixnum)operator(\))ident(currentExceptionMode)operator(.)ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(&)delimiter(")>operator(,) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) operator(~)operator(()ident(EXCEPTION_NaN)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(c)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpExceptionMode)delimiter(")>operator(,) ident(newExceptionMode)operator(\))operator(;) - keyword(return) ident(newExceptionMode)operator(;) - operator(}) - - type(long) ident(ROUND_MODE) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_MODE)delimiter(")>operator(\))operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(longMode) operator(==) ident(ROUND_MODE)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(c)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpRoundingMode)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)operator(()ident(value) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(mode)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Fixnum\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyFixnum) ident(roundingMode) operator(=) operator(()ident(RubyFixnum)operator(\))ident(value)operator(;) - keyword(if) operator(()ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_UP)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_DOWN)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_FLOOR)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_CEILING)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_HALF_UP)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_HALF_DOWN)delimiter(")>operator(\)) operator(||) - ident(roundingMode) operator(==) ident(clazz)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ROUND_HALF_EVEN)delimiter(")>operator(\))operator(\)) operator({) - ident(c)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(vpRoundingMode)delimiter(")>operator(,) ident(roundingMode)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(invalid rounding mode)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(c)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpRoundingMode)delimiter(")>operator(\))operator(;) - operator(}) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(first argument for BigDecimal#mode invalid)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) pre_type(RoundingMode) ident(getRoundingMode)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyFixnum) ident(roundingMode) operator(=) operator(()ident(RubyFixnum)operator(\))ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\)) - operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpRoundingMode)delimiter(")>operator(\))operator(;) - keyword(return) pre_type(RoundingMode)operator(.)ident(valueOf)operator(()operator(()type(int)operator(\))ident(roundingMode)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(RubyBigDecimal) ident(getVpValue)operator(()ident(IRubyObject) ident(v)operator(,) type(boolean) ident(must)operator(\)) operator({) - keyword(if)operator(()ident(v) keyword(instanceof) ident(RubyBigDecimal)operator(\)) operator({) - keyword(return) operator(()ident(RubyBigDecimal)operator(\))ident(v)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(v) keyword(instanceof) ident(RubyFixnum) operator(||) ident(v) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - pre_type(String) ident(s) operator(=) ident(v)operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(return) ident(newInstance)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\))operator(,)keyword(new) ident(IRubyObject)type([])operator({)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(s)operator(\))operator(})operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(must)operator(\)) operator({) - pre_type(String) ident(err)operator(;) - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(err) operator(=) ident(inspect)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(err) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseName)operator(()operator(\))operator(;) - operator(}) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(err) operator(+) string<delimiter(")content( can't be coerced into BigDecimal)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(private) directive(final) directive(static) pre_type(Pattern) ident(INFINITY_PATTERN) operator(=) pre_type(Pattern)operator(.)ident(compile)operator(()string<delimiter(")content(^([+-]\)?Infinity$)delimiter(")>operator(\))operator(;) - directive(private) directive(final) directive(static) pre_type(Pattern) ident(NUMBER_PATTERN) - operator(=) pre_type(Pattern)operator(.)ident(compile)operator(()string<delimiter(")content(^([+-]?)char(\\\\)content(d*)char(\\\\)content(.?)char(\\\\)content(d*([eE][+-]?\)?)char(\\\\)content(d*\).*)delimiter(")>operator(\))operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBigDecimal) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - pre_type(BigDecimal) ident(decimal)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(decimal) operator(=) keyword(new) pre_type(BigDecimal)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(String) ident(strValue) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(strValue) operator(=) ident(strValue)operator(.)ident(trim)operator(()operator(\))operator(;) - keyword(if) operator(()string<delimiter(")content(NaN)delimiter(")>operator(.)ident(equals)operator(()ident(strValue)operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - pre_type(Matcher) ident(m) operator(=) ident(INFINITY_PATTERN)operator(.)ident(matcher)operator(()ident(strValue)operator(\))operator(;) - keyword(if) operator(()ident(m)operator(.)ident(matches)operator(()operator(\))operator(\)) operator({) - type(int) ident(sign) operator(=) integer(1)operator(;) - pre_type(String) ident(signGroup) operator(=) ident(m)operator(.)ident(group)operator(()integer(1)operator(\))operator(;) - keyword(if) operator(()string<delimiter(")content(-)delimiter(")>operator(.)ident(equals)operator(()ident(signGroup)operator(\))operator(\)) operator({) - ident(sign) operator(=) operator(-)integer(1)operator(;) - operator(}) - keyword(return) ident(newInfinity)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(sign)operator(\))operator(;) - operator(}) - - comment(// Clean-up string representation so that it could be understood) - comment(// by Java's BigDecimal. Not terribly efficient for now.) - comment(// 1. MRI allows d and D as exponent separators) - ident(strValue) operator(=) ident(strValue)operator(.)ident(replaceFirst)operator(()string<delimiter(")content([dD])delimiter(")>operator(,) string<delimiter(")content(E)delimiter(")>operator(\))operator(;) - comment(// 2. MRI allows underscores anywhere) - ident(strValue) operator(=) ident(strValue)operator(.)ident(replaceAll)operator(()string<delimiter(")content(_)delimiter(")>operator(,) string<delimiter(")delimiter(")>operator(\))operator(;) - comment(// 3. MRI ignores the trailing junk) - ident(strValue) operator(=) ident(NUMBER_PATTERN)operator(.)ident(matcher)operator(()ident(strValue)operator(\))operator(.)ident(replaceFirst)operator(()string<delimiter(")content($1)delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - ident(decimal) operator(=) keyword(new) pre_type(BigDecimal)operator(()ident(strValue)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NumberFormatException) ident(e)operator(\)) operator({) - ident(decimal) operator(=) keyword(new) pre_type(BigDecimal)operator(()integer(0)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(decimal)operator(.)ident(signum)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - comment(// MRI behavior: -0 and +0 are two different things) - keyword(if) operator(()ident(strValue)operator(.)ident(matches)operator(()string<delimiter(")content(^)char(\\\\)content(s*-.*)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(newZero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(-)integer(1)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(newZero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(1)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(decimal)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(RubyBigDecimal) ident(newZero)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(sign)operator(\)) operator({) - ident(RubyBigDecimal) ident(rbd) operator(=) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) pre_type(BigDecimal)operator(.)ident(ZERO)operator(\))operator(;) - keyword(if) operator(()ident(sign) operator(<) integer(0)operator(\)) operator({) - ident(rbd)operator(.)ident(zeroSign) operator(=) operator(-)integer(1)operator(;) - operator(}) keyword(else) operator({) - ident(rbd)operator(.)ident(zeroSign) operator(=) integer(1)operator(;) - operator(}) - keyword(return) ident(rbd)operator(;) - operator(}) - - directive(private) directive(static) ident(RubyBigDecimal) ident(newNaN)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyBigDecimal) ident(rbd) operator(=) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) pre_type(BigDecimal)operator(.)ident(ZERO)operator(\))operator(;) - ident(rbd)operator(.)ident(isNaN) operator(=) pre_constant(true)operator(;) - keyword(return) ident(rbd)operator(;) - operator(}) - - directive(private) directive(static) ident(RubyBigDecimal) ident(newInfinity)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(sign)operator(\)) operator({) - ident(RubyBigDecimal) ident(rbd) operator(=) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) pre_type(BigDecimal)operator(.)ident(ZERO)operator(\))operator(;) - keyword(if) operator(()ident(sign) operator(<) integer(0)operator(\)) operator({) - ident(rbd)operator(.)ident(infinitySign) operator(=) operator(-)integer(1)operator(;) - operator(}) keyword(else) operator({) - ident(rbd)operator(.)ident(infinitySign) operator(=) integer(1)operator(;) - operator(}) - keyword(return) ident(rbd)operator(;) - operator(}) - - directive(private) ident(RubyBigDecimal) ident(setResult)operator(()operator(\)) operator({) - keyword(return) ident(setResult)operator(()integer(0)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyBigDecimal) ident(setResult)operator(()type(int) ident(scale)operator(\)) operator({) - type(int) ident(prec) operator(=) ident(RubyFixnum)operator(.)ident(fix2int)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(BigDecimal)delimiter(")>operator(\))operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(vpPrecLimit)delimiter(")>operator(\))operator(\))operator(;) - type(int) ident(prec2) operator(=) pre_type(Math)operator(.)ident(max)operator(()ident(scale)operator(,)ident(prec)operator(\))operator(;) - keyword(if)operator(()ident(prec2) operator(>) integer(0) operator(&&) local_variable(this)operator(.)ident(value)operator(.)ident(scale)operator(()operator(\)) operator(>) operator(()ident(prec2)operator(-)ident(getExponent)operator(()operator(\))operator(\))operator(\)) operator({) - local_variable(this)operator(.)ident(value) operator(=) local_variable(this)operator(.)ident(value)operator(.)ident(setScale)operator(()ident(prec2)operator(-)ident(getExponent)operator(()operator(\))operator(,)pre_type(BigDecimal)operator(.)ident(ROUND_HALF_UP)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(%)delimiter(")>operator(,) string<delimiter(")content(modulo)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - comment(// TODO: full-precision remainder is 1000x slower than MRI!) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(||) ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(arg)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(arg)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(val)operator(.)ident(isInfinity)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(// Java and MRI definitions of modulo are different.) - pre_type(BigDecimal) ident(modulo) operator(=) ident(value)operator(.)ident(remainder)operator(()ident(val)operator(.)ident(value)operator(\))operator(;) - keyword(if) operator(()ident(modulo)operator(.)ident(signum)operator(()operator(\)) operator(*) ident(val)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - ident(modulo) operator(=) ident(modulo)operator(.)ident(add)operator(()ident(val)operator(.)ident(value)operator(\))operator(;) - operator(}) - - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(modulo)operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remainder)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(remainder)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - comment(// TODO: full-precision remainder is 1000x slower than MRI!) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(||) ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(arg)operator(,)pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(remainder)delimiter(")>operator(,) ident(arg)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(val)operator(.)ident(isInfinity)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(// Java and MRI definitions of remainder are the same.) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(value)operator(.)ident(remainder)operator(()ident(val)operator(.)ident(value)operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(mult2)operator(()ident(context)operator(,) ident(arg)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mult)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(mult2)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(b)operator(,) ident(IRubyObject) ident(n)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(b)operator(,)pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - comment(// TODO: what about n arg?) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(b)operator(\))operator(;) - operator(}) - - type(int) ident(digits) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(n)operator(\))operator(;) - - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(()ident(isInfinity)operator(()operator(\)) operator(&&) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator(||) operator(()ident(isZero)operator(()operator(\)) operator(&&) ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isZero)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator({) - type(int) ident(sign1) operator(=) ident(isZero)operator(()operator(\))operator(?) ident(zeroSign) operator(:) ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - type(int) ident(sign2) operator(=) ident(val)operator(.)ident(isZero)operator(()operator(\)) operator(?) ident(val)operator(.)ident(zeroSign) operator(:) ident(val)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - keyword(return) ident(newZero)operator(()ident(runtime)operator(,) ident(sign1) operator(*) ident(sign2)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - type(int) ident(sign1) operator(=) ident(isInfinity)operator(()operator(\)) operator(?) ident(infinitySign) operator(:) ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - type(int) ident(sign2) operator(=) ident(val)operator(.)ident(isInfinity)operator(()operator(\)) operator(?) ident(val)operator(.)ident(infinitySign) operator(:) ident(val)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - keyword(return) ident(newInfinity)operator(()ident(runtime)operator(,) ident(sign1) operator(*) ident(sign2)operator(\))operator(;) - operator(}) - - pre_type(BigDecimal) ident(res) operator(=) ident(value)operator(.)ident(multiply)operator(()ident(val)operator(.)ident(value)operator(\))operator(;) - keyword(if) operator(()ident(res)operator(.)ident(precision)operator(()operator(\)) operator(>) ident(digits)operator(\)) operator({) - comment(// TODO: rounding mode should not be hard-coded. See #mode.) - ident(res) operator(=) ident(res)operator(.)ident(round)operator(()keyword(new) pre_type(MathContext)operator(()ident(digits)operator(,) pre_type(RoundingMode)operator(.)ident(HALF_UP)operator(\))operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(res)operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(**)delimiter(")>operator(,) string<delimiter(")content(power)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_pow)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(arg) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(arg)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Fixnum\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - type(int) ident(times) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(times) operator(<) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(signum)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// Note: MRI has a very non-trivial way of calculating the precision,) - comment(// so we use very simple approximation here:) - type(int) ident(precision) operator(=) operator(()operator(-)ident(times) operator(+) integer(4)operator(\)) operator(*) operator(()ident(getAllDigits)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(+) integer(4)operator(\))operator(;) - - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(value)operator(.)ident(pow)operator(()ident(times)operator(,) keyword(new) pre_type(MathContext)operator(()ident(precision)operator(,) pre_type(RoundingMode)operator(.)ident(HALF_UP)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(pow)operator(()ident(times)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(b)operator(\)) operator({) - keyword(return) ident(addInternal)operator(()ident(context)operator(,) ident(b)operator(,) string<delimiter(")content(add)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(add)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(add2)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(b)operator(,) ident(IRubyObject) ident(digits)operator(\)) operator({) - keyword(return) ident(addInternal)operator(()ident(context)operator(,) ident(b)operator(,) string<delimiter(")content(add)delimiter(")>operator(,) ident(digits)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addInternal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(b)operator(,) pre_type(String) ident(op)operator(,) ident(IRubyObject) ident(digits)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(prec) operator(=) ident(getPositiveInt)operator(()ident(context)operator(,) ident(digits)operator(\))operator(;) - - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(b)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - comment(// TODO:) - comment(// MRI behavior: Call "+" or "add", depending on the call.) - comment(// But this leads to exceptions when Floats are added. See:) - comment(// http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17374) - comment(// return callCoerced(context, op, b, true\); -- this is MRI behavior.) - comment(// We'll use ours for now, thus providing an ability to add Floats.) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(b)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(res) operator(=) ident(handleAddSpecialValues)operator(()ident(val)operator(\))operator(;) - keyword(if) operator(()ident(res) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(res)operator(;) - operator(}) - pre_type(RoundingMode) ident(roundMode) operator(=) ident(getRoundingMode)operator(()ident(runtime)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(value)operator(.)ident(add)operator(() - ident(val)operator(.)ident(value)operator(,) keyword(new) pre_type(MathContext)operator(()ident(prec)operator(,) ident(roundMode)operator(\))operator(\))operator(\))operator(;) comment(// TODO: why this: .setResult(\);) - operator(}) - - directive(private) type(int) ident(getPositiveInt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(int) ident(value) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument must be positive)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(arg)operator(,) ident(runtime)operator(.)ident(getFixnum)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(handleAddSpecialValues)operator(()ident(RubyBigDecimal) ident(val)operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - comment(// TODO: don't calculate the same value 3 times) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(isInfinity)operator(()operator(\)) operator(?) local_variable(this) operator(:) ident(val)operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(==) integer(0)operator(\)) operator({) - type(int) ident(sign) operator(=) ident(infinitySign) operator(+) ident(val)operator(.)ident(infinitySign)operator(;) - keyword(if) operator(()ident(sign) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(sign)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uplus)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_minus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(arg)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(arg)operator(\))operator(;) - operator(}) - ident(RubyBigDecimal) ident(res) operator(=) ident(handleMinusSpecialValues)operator(()ident(val)operator(\))operator(;) - keyword(if) operator(()ident(res) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(res)operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(value)operator(.)ident(subtract)operator(()ident(val)operator(.)ident(value)operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(sub2)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(b)operator(,) ident(IRubyObject) ident(n)operator(\)) operator({) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(b)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(b)operator(\))operator(;) - operator(}) - ident(RubyBigDecimal) ident(res) operator(=) ident(handleMinusSpecialValues)operator(()ident(val)operator(\))operator(;) - keyword(if) operator(()ident(res) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(res)operator(;) - operator(}) - - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(value)operator(.)ident(subtract)operator(()ident(val)operator(.)ident(value)operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(RubyBigDecimal) ident(handleMinusSpecialValues)operator(()ident(RubyBigDecimal) ident(val)operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// TODO: 3 times calculate the same value below) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(<) integer(0)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(*) ident(val)operator(.)ident(infinitySign) operator(==) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - keyword(if) operator(()ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(val)operator(.)ident(infinitySign) operator(*) operator(-)integer(1)operator(\))operator(;) - operator(}) - type(int) ident(sign) operator(=) ident(infinitySign) operator(+) ident(val)operator(.)ident(infinitySign)operator(;) - keyword(if) operator(()ident(sign) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(sign)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uminus)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(runtime)operator(,) operator(-)ident(infinitySign)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newZero)operator(()ident(runtime)operator(,) operator(-)ident(zeroSign)operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(negate)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(/)delimiter(")>operator(,) string<delimiter(")content(quo)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(op_quo)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - comment(// regular division with some default precision) - comment(// TODO: proper algorithm to set the precision) - keyword(return) ident(op_div)operator(()ident(context)operator(,) ident(other)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(200)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(div)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - comment(// integer division) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(div)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isZero)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - local_variable(this)operator(.)ident(value)operator(.)ident(divideToIntegralValue)operator(()ident(val)operator(.)ident(value)operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(div)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) ident(IRubyObject) ident(digits)operator(\)) operator({) - comment(// TODO: take BigDecimal.mode into account.) - - type(int) ident(scale) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(digits)operator(\))operator(;) - - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) operator(()ident(isZero)operator(()operator(\)) operator(&&) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator({) - type(int) ident(sign1) operator(=) ident(isInfinity)operator(()operator(\)) operator(?) ident(infinitySign) operator(:) ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(sign1) operator(*) ident(val)operator(.)ident(zeroSign)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(&&) operator(!)ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(infinitySign) operator(*) ident(val)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(isInfinity)operator(()operator(\)) operator(&&) ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newZero)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(signum)operator(()operator(\)) operator(*) ident(val)operator(.)ident(infinitySign)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(&&) ident(val)operator(.)ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(scale) operator(==) integer(0)operator(\)) operator({) - comment(// MRI behavior: "If digits is 0, the result is the same as the / operator.") - keyword(return) ident(op_quo)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// TODO: better algorithm to set precision needed) - type(int) ident(prec) operator(=) pre_type(Math)operator(.)ident(max)operator(()integer(200)operator(,) ident(scale)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(value)operator(.)ident(divide)operator(()ident(val)operator(.)ident(value)operator(,) keyword(new) pre_type(MathContext)operator(()ident(prec)operator(,) pre_type(RoundingMode)operator(.)ident(HALF_UP)operator(\))operator(\))operator(\))operator(.)ident(setResult)operator(()ident(scale)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(r)operator(,) type(char) ident(op)operator(\)) operator({) - type(int) ident(e) operator(=) integer(0)operator(;) - ident(RubyBigDecimal) ident(rb) operator(=) ident(getVpValue)operator(()ident(r)operator(,)pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(rb) operator(==) pre_constant(null)operator(\)) operator({) - ident(IRubyObject) ident(ee) operator(=) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,)ident(r)operator(\))operator(;) - keyword(if)operator(()ident(ee)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(e) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(ee)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(|) ident(rb)operator(.)ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(!=) integer(0) operator(||) ident(rb)operator(.)ident(infinitySign) operator(!=) integer(0)operator(\)) operator({) - ident(e) operator(=) ident(infinitySign) operator(-) ident(rb)operator(.)ident(infinitySign)operator(;) - operator(}) keyword(else) operator({) - ident(e) operator(=) ident(value)operator(.)ident(compareTo)operator(()ident(rb)operator(.)ident(value)operator(\))operator(;) - operator(}) - operator(}) - keyword(switch)operator(()ident(op)operator(\)) operator({) - keyword(case) string<delimiter(')content(*)delimiter(')>operator(:) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(e)operator(\))operator(;) - keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(==)integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(!)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(!=)integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(G)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(>=)integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(>) integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(L)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(<=)integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) keyword(return) operator(()ident(e)operator(<) integer(0)operator(\))operator(?)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(:)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(*)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(eql?)delimiter(")>operator(,) string<delimiter(")content(==)delimiter(")>operator(,) string<delimiter(")content(===)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(=)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(<)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(L)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(>)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(cmp)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(')content(G)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(abs)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(runtime)operator(,) integer(1)operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(abs)operator(()operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ceil)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(ceil)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(infinitySign)operator(\))operator(;) - operator(}) - - type(int) ident(n) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(n) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(scale)operator(()operator(\)) operator(>) ident(n)operator(\)) operator({) comment(// rounding neccessary) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(value)operator(.)ident(setScale)operator(()ident(n)operator(,) pre_type(RoundingMode)operator(.)ident(CEILING)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(coerce)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(obj)operator(;) - keyword(if)operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(obj) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(other)operator(,)ident(to_f)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(obj) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(getVpValue)operator(()ident(other)operator(,) pre_constant(true)operator(\))operator(,)local_variable(this)operator(\))operator(;) - operator(}) - keyword(return) ident(obj)operator(;) - operator(}) - - directive(public) type(double) ident(getDoubleValue)operator(()operator(\)) operator({) keyword(return) ident(value)operator(.)ident(doubleValue)operator(()operator(\))operator(;) operator(}) - directive(public) type(long) ident(getLongValue)operator(()operator(\)) operator({) keyword(return) ident(value)operator(.)ident(longValue)operator(()operator(\))operator(;) operator(}) - - directive(public) ident(RubyNumeric) ident(multiplyWith)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyInteger) ident(value)operator(\)) operator({) - keyword(return) operator(()ident(RubyNumeric)operator(\))ident(op_mul)operator(()ident(context)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNumeric) ident(multiplyWith)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFloat) ident(value)operator(\)) operator({) - keyword(return) operator(()ident(RubyNumeric)operator(\))ident(op_mul)operator(()ident(context)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNumeric) ident(multiplyWith)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyBignum) ident(value)operator(\)) operator({) - keyword(return) operator(()ident(RubyNumeric)operator(\))ident(op_mul)operator(()ident(context)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - comment(// TODO: full-precision divmod is 1000x slower than MRI!) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(||) ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(newNaN)operator(()ident(runtime)operator(\))operator(,) ident(newNaN)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - ident(RubyBigDecimal) ident(val) operator(=) ident(getVpValue)operator(()ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(callCoerced)operator(()ident(context)operator(,) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(other)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(val)operator(.)ident(isInfinity)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isNaN)operator(()operator(\)) operator(||) ident(val)operator(.)ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(newNaN)operator(()ident(runtime)operator(\))operator(,) ident(newNaN)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - - comment(// Java and MRI definitions of divmod are different. ) - pre_type(BigDecimal)type([]) ident(divmod) operator(=) ident(value)operator(.)ident(divideAndRemainder)operator(()ident(val)operator(.)ident(value)operator(\))operator(;) - - pre_type(BigDecimal) ident(div) operator(=) ident(divmod)operator([)integer(0)operator(])operator(;) - pre_type(BigDecimal) ident(mod) operator(=) ident(divmod)operator([)integer(1)operator(])operator(;) - - keyword(if) operator(()ident(mod)operator(.)ident(signum)operator(()operator(\)) operator(*) ident(val)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - ident(div) operator(=) ident(div)operator(.)ident(subtract)operator(()pre_type(BigDecimal)operator(.)ident(ONE)operator(\))operator(;) - ident(mod) operator(=) ident(mod)operator(.)ident(add)operator(()ident(val)operator(.)ident(value)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) - keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(div)operator(\))operator(,) - keyword(new) ident(RubyBigDecimal)operator(()ident(runtime)operator(,) ident(mod)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exponent)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(exponent)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getExponent)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(finite?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(finite_p)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(!)ident(isInfinity)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(floor)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(floor)operator(()ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(infinitySign)operator(\))operator(;) - operator(}) - - type(int) ident(n) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(n) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(scale)operator(()operator(\)) operator(>) ident(n)operator(\)) operator({) comment(// rounding neccessary) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(value)operator(.)ident(setScale)operator(()ident(n)operator(,) pre_type(RoundingMode)operator(.)ident(FLOOR)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(frac)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(frac)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(infinitySign)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(value)operator(.)ident(scale)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(value)operator(.)ident(precision)operator(()operator(\)) operator(<) ident(value)operator(.)ident(scale)operator(()operator(\))operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) - - pre_type(BigDecimal) ident(val) operator(=) ident(value)operator(.)ident(subtract)operator(()operator(()operator(()ident(RubyBigDecimal)operator(\))ident(fix)operator(()operator(\))operator(\))operator(.)ident(value)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(val)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(infinite?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(infinite_p)operator(()operator(\)) operator({) - keyword(if) operator(()ident(infinitySign) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(infinitySign)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - pre_type(StringBuilder) ident(val) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<BigDecimal:)delimiter(")>operator(\))operator(.)ident(append)operator(()pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(,)delimiter(")>operator(\))operator(;) - ident(val)operator(.)ident(append)operator(()string<delimiter(")content(')delimiter(")>operator(\))operator(.)ident(append)operator(()local_variable(this)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(')delimiter(")>operator(\))operator(.)ident(append)operator(()string<delimiter(")content(,)delimiter(")>operator(\))operator(;) - - ident(val)operator(.)ident(append)operator(()ident(getSignificantDigits)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(()delimiter(")>operator(\))operator(;) - - type(int) ident(len) operator(=) ident(getAllDigits)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - type(int) ident(pow) operator(=) ident(len) operator(/) integer(4)operator(;) - ident(val)operator(.)ident(append)operator(()operator(()ident(pow) operator(+) integer(1)operator(\)) operator(*) integer(4)operator(\))operator(.)ident(append)operator(()string<delimiter(")content(\))delimiter(")>operator(\))operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(val)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nan?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nan_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isNaN)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nonzero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nonzero_p)operator(()operator(\)) operator({) - keyword(return) ident(isZero)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(precs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(precs)operator(()operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject)type([]) ident(array) operator(=) keyword(new) ident(IRubyObject)operator([)integer(2)operator(])operator(;) - - ident(array)operator([)integer(0)operator(]) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(getSignificantDigits)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - - type(int) ident(len) operator(=) ident(getAllDigits)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - type(int) ident(pow) operator(=) ident(len) operator(/) integer(4)operator(;) - ident(array)operator([)integer(1)operator(]) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()operator(()ident(pow) operator(+) integer(1)operator(\)) operator(*) integer(4)operator(\))operator(;) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(array)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(round)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(round)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(int) ident(scale) operator(=) ident(args)operator(.)ident(length) operator(>) integer(0) operator(?) ident(num2int)operator(()ident(args)operator([)integer(0)operator(])operator(\)) operator(:) integer(0)operator(;) - type(int) ident(mode) operator(=) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator(?) ident(javaRoundingModeFromRubyRoundingMode)operator(()ident(args)operator([)integer(1)operator(])operator(\)) operator(:) pre_type(BigDecimal)operator(.)ident(ROUND_HALF_UP)operator(;) - comment(// JRUBY-914: Java 1.4 BigDecimal does not allow a negative scale, so we have to simulate it) - keyword(if) operator(()ident(scale) operator(<) integer(0)operator(\)) operator({) - comment(// shift the decimal point just to the right of the digit to be rounded to (divide by 10**(abs(scale\)\)\)) - comment(// -1 -> 10's digit, -2 -> 100's digit, etc.) - pre_type(BigDecimal) ident(normalized) operator(=) ident(value)operator(.)ident(movePointRight)operator(()ident(scale)operator(\))operator(;) - comment(// ...round to that digit) - pre_type(BigDecimal) ident(rounded) operator(=) ident(normalized)operator(.)ident(setScale)operator(()integer(0)operator(,)ident(mode)operator(\))operator(;) - comment(// ...and shift the result back to the left (multiply by 10**(abs(scale\)\)\)) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(rounded)operator(.)ident(movePointLeft)operator(()ident(scale)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(setScale)operator(()ident(scale)operator(,) ident(mode)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(//this relies on the Ruby rounding enumerations == Java ones, which they (currently\) all are) - directive(private) type(int) ident(javaRoundingModeFromRubyRoundingMode)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(num2int)operator(()ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sign)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sign)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_NaN)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(infinitySign) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_NEGATIVE_INFINITE)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_POSITIVE_INFINITE)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(zeroSign) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_NEGATIVE_ZERO)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_POSITIVE_ZERO)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(signum)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_NEGATIVE_FINITE)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(SIGN_POSITIVE_FINITE)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(split)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(split)operator(()operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject)type([]) ident(array) operator(=) keyword(new) ident(IRubyObject)operator([)integer(4)operator(])operator(;) - - comment(// sign) - directive(final) ident(RubyFixnum) ident(sign)operator(;) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - ident(sign) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - ident(sign) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(infinitySign)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\))operator({) - ident(sign) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(zeroSign)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(sign) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(signum)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(array)operator([)integer(0)operator(]) operator(=) ident(sign)operator(;) - - comment(// significant digits and exponent) - directive(final) ident(RubyString) ident(digits)operator(;) - directive(final) ident(RubyFixnum) ident(exp)operator(;) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - ident(digits) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(NaN)delimiter(")>operator(\))operator(;) - ident(exp) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - ident(digits) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(Infinity)delimiter(")>operator(\))operator(;) - ident(exp) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\))operator({) - ident(digits) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(0)delimiter(")>operator(\))operator(;) - ident(exp) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// normalize the value) - ident(digits) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(getSignificantDigits)operator(()operator(\))operator(\))operator(;) - ident(exp) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(getExponent)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(array)operator([)integer(1)operator(]) operator(=) ident(digits)operator(;) - ident(array)operator([)integer(3)operator(]) operator(=) ident(exp)operator(;) - - comment(// base) - ident(array)operator([)integer(2)operator(]) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()integer(10)operator(\))operator(;) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(array)operator(\))operator(;) - operator(}) - - comment(// it doesn't handle special cases) - directive(private) pre_type(String) ident(getSignificantDigits)operator(()operator(\)) operator({) - comment(// TODO: no need to calculate every time.) - pre_type(BigDecimal) ident(val) operator(=) ident(value)operator(.)ident(abs)operator(()operator(\))operator(.)ident(stripTrailingZeros)operator(()operator(\))operator(;) - keyword(return) ident(val)operator(.)ident(unscaledValue)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(private) pre_type(String) ident(getAllDigits)operator(()operator(\)) operator({) - comment(// TODO: no need to calculate every time.) - pre_type(BigDecimal) ident(val) operator(=) ident(value)operator(.)ident(abs)operator(()operator(\))operator(;) - keyword(return) ident(val)operator(.)ident(unscaledValue)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - comment(// it doesn't handle special cases) - directive(private) type(int) ident(getExponent)operator(()operator(\)) operator({) - comment(// TODO: no need to calculate every time.) - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) integer(0)operator(;) - operator(}) - pre_type(BigDecimal) ident(val) operator(=) ident(value)operator(.)ident(abs)operator(()operator(\))operator(.)ident(stripTrailingZeros)operator(()operator(\))operator(;) - keyword(return) ident(val)operator(.)ident(precision)operator(()operator(\)) operator(-) ident(val)operator(.)ident(scale)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sqrt)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(sqrt)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFloatDomainError)operator(()string<delimiter(")content((VpSqrt\) SQRT(NaN value\))delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(()ident(isInfinity)operator(()operator(\)) operator(&&) ident(infinitySign) operator(<) integer(0)operator(\)) operator(||) ident(value)operator(.)ident(signum)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFloatDomainError)operator(()string<delimiter(")content((VpSqrt\) SQRT(negative value\))delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\)) operator(&&) ident(infinitySign) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(runtime)operator(,) integer(1)operator(\))operator(;) - operator(}) - - comment(// NOTE: MRI's sqrt precision is limited by 100,) - comment(// but we allow values more than 100.) - type(int) ident(n) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument must be positive)delimiter(")>operator(\))operator(;) - operator(}) - - ident(n) operator(+=) integer(4)operator(;) comment(// just in case, add a bit of extra precision) - - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(bigSqrt)operator(()local_variable(this)operator(.)ident(value)operator(,) keyword(new) pre_type(MathContext)operator(()ident(n)operator(,) pre_type(RoundingMode)operator(.)ident(HALF_UP)operator(\))operator(\))operator(\))operator(.)ident(setResult)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Double)operator(.)ident(NaN)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(infinitySign) operator(<) integer(0) operator(?) pre_type(Double)operator(.)ident(NEGATIVE_INFINITY) operator(:) pre_type(Double)operator(.)ident(POSITIVE_INFINITY)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(zeroSign) operator(<) integer(0) operator(?) operator(-)float(0.0) operator(:) float(0.0)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(doubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_i)delimiter(")>operator(,) string<delimiter(")content(to_int)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(to_int)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(()operator(\)) operator(||) ident(infinitySign) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(try) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(int2fix)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(longValueExact)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ArithmeticException) ident(ae)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(toBigInteger)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) pre_type(String) ident(removeTrailingZeroes)operator(()pre_type(String) ident(in)operator(\)) operator({) - keyword(while)operator(()ident(in)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(in)operator(.)ident(charAt)operator(()ident(in)operator(.)ident(length)operator(()operator(\))operator(-)integer(1)operator(\))operator(==)string<delimiter(')content(0)delimiter(')>operator(\)) operator({) - ident(in) operator(=) ident(in)operator(.)ident(substring)operator(()integer(0)operator(,)ident(in)operator(.)ident(length)operator(()operator(\))operator(-)integer(1)operator(\))operator(;) - operator(}) - keyword(return) ident(in)operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(formatHasLeadingPlus)operator(()pre_type(String) ident(format)operator(\)) operator({) - keyword(return) ident(format)operator(.)ident(startsWith)operator(()string<delimiter(")content(+)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(formatHasLeadingSpace)operator(()pre_type(String) ident(format)operator(\)) operator({) - keyword(return) ident(format)operator(.)ident(startsWith)operator(()string<delimiter(")content( )delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(formatHasFloatingPointNotation)operator(()pre_type(String) ident(format)operator(\)) operator({) - keyword(return) ident(format)operator(.)ident(endsWith)operator(()string<delimiter(")content(F)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(int) ident(formatFractionalDigitGroups)operator(()pre_type(String) ident(format)operator(\)) operator({) - type(int) ident(groups) operator(=) integer(0)operator(;) - pre_type(Pattern) ident(p) operator(=) pre_type(Pattern)operator(.)ident(compile)operator(()string<delimiter(")content(()char(\\\\)content(+| \)?()char(\\\\)content(d+\)(E|F\)?)delimiter(")>operator(\))operator(;) - pre_type(Matcher) ident(m) operator(=) ident(p)operator(.)ident(matcher)operator(()ident(format)operator(\))operator(;) - keyword(if) operator(()ident(m)operator(.)ident(matches)operator(()operator(\))operator(\)) operator({) - ident(groups) operator(=) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(m)operator(.)ident(group)operator(()integer(2)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(groups)operator(;) - operator(}) - - directive(private) type(boolean) ident(hasArg)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(args)operator(.)ident(length) operator(!=) integer(0) operator(&&) operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) pre_type(String) ident(format)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(private) pre_type(String) ident(firstArgument)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(hasArg)operator(()ident(args)operator(\))operator(\)) operator({) - keyword(return) ident(format)operator(()ident(args)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(private) type(boolean) ident(posSpace)operator(()pre_type(String) ident(arg)operator(\)) operator({) - keyword(if) operator(()pre_constant(null) operator(!=) ident(arg)operator(\)) operator({) - keyword(return) ident(formatHasLeadingSpace)operator(()ident(arg)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(private) type(boolean) ident(posSign)operator(()pre_type(String) ident(arg)operator(\)) operator({) - keyword(if) operator(()pre_constant(null) operator(!=) ident(arg)operator(\)) operator({) - keyword(return) ident(formatHasLeadingPlus)operator(()ident(arg)operator(\)) operator(||) ident(posSpace)operator(()ident(arg)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(private) type(boolean) ident(asEngineering)operator(()pre_type(String) ident(arg)operator(\)) operator({) - keyword(if) operator(()pre_constant(null) operator(!=) ident(arg)operator(\)) operator({) - keyword(return) operator(!)ident(formatHasFloatingPointNotation)operator(()ident(arg)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(private) type(int) ident(groups)operator(()pre_type(String) ident(arg)operator(\)) operator({) - keyword(if) operator(()pre_constant(null) operator(!=) ident(arg)operator(\)) operator({) - keyword(return) ident(formatFractionalDigitGroups)operator(()ident(arg)operator(\))operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - directive(private) type(boolean) ident(isZero)operator(()operator(\)) operator({) - keyword(return) operator(!)ident(isNaN)operator(()operator(\)) operator(&&) operator(!)ident(isInfinity)operator(()operator(\)) operator(&&) operator(()ident(value)operator(.)ident(signum)operator(()operator(\)) operator(==) integer(0)operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isNaN)operator(()operator(\)) operator({) - keyword(return) ident(isNaN)operator(;) - operator(}) - - directive(private) type(boolean) ident(isInfinity)operator(()operator(\)) operator({) - keyword(return) ident(infinitySign) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) pre_type(String) ident(unscaledValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(abs)operator(()operator(\))operator(.)ident(unscaledValue)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(engineeringValue)operator(()pre_type(String) ident(arg)operator(\)) operator({) - type(int) ident(exponent) operator(=) ident(getExponent)operator(()operator(\))operator(;) - type(int) ident(signum) operator(=) ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - pre_type(StringBuilder) ident(build) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(build)operator(.)ident(append)operator(()ident(signum) operator(==) operator(-)integer(1) operator(?) string<delimiter(")content(-)delimiter(")> operator(:) operator(()ident(signum) operator(==) integer(1) operator(?) operator(()ident(posSign)operator(()ident(arg)operator(\)) operator(?) operator(()ident(posSpace)operator(()ident(arg)operator(\)) operator(?) string<delimiter(")content( )delimiter(")> operator(:) string<delimiter(")content(+)delimiter(")>operator(\)) operator(:) string<delimiter(")delimiter(")>operator(\)) operator(:) string<delimiter(")delimiter(")>operator(\))operator(\))operator(;) - ident(build)operator(.)ident(append)operator(()string<delimiter(")content(0.)delimiter(")>operator(\))operator(;) - keyword(if) operator(()integer(0) operator(==) ident(groups)operator(()ident(arg)operator(\))operator(\)) operator({) - pre_type(String) ident(s) operator(=) ident(removeTrailingZeroes)operator(()ident(unscaledValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()string<delimiter(")delimiter(")>operator(.)ident(equals)operator(()ident(s)operator(\))operator(\)) operator({) - ident(build)operator(.)ident(append)operator(()string<delimiter(")content(0)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(build)operator(.)ident(append)operator(()ident(s)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(index) operator(=) integer(0)operator(;) - pre_type(String) ident(sep) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(while) operator(()ident(index) operator(<) ident(unscaledValue)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - type(int) ident(next) operator(=) ident(index) operator(+) ident(groups)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(next) operator(>) ident(unscaledValue)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(next) operator(=) ident(unscaledValue)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - ident(build)operator(.)ident(append)operator(()ident(sep)operator(\))operator(.)ident(append)operator(()ident(unscaledValue)operator(()operator(\))operator(.)ident(substring)operator(()ident(index)operator(,) ident(next)operator(\))operator(\))operator(;) - ident(sep) operator(=) string<delimiter(")content( )delimiter(")>operator(;) - ident(index) operator(+=) ident(groups)operator(()ident(arg)operator(\))operator(;) - operator(}) - operator(}) - ident(build)operator(.)ident(append)operator(()string<delimiter(")content(E)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(exponent)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(build)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(floatingPointValue)operator(()pre_type(String) ident(arg)operator(\)) operator({) - pre_type(String) ident(values)type([]) operator(=) ident(value)operator(.)ident(abs)operator(()operator(\))operator(.)ident(stripTrailingZeros)operator(()operator(\))operator(.)ident(toPlainString)operator(()operator(\))operator(.)ident(split)operator(()string<delimiter(")char(\\\\)content(.)delimiter(")>operator(\))operator(;) - pre_type(String) ident(whole) operator(=) string<delimiter(")content(0)delimiter(")>operator(;) - keyword(if) operator(()ident(values)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(whole) operator(=) ident(values)operator([)integer(0)operator(])operator(;) - operator(}) - pre_type(String) ident(after) operator(=) string<delimiter(")content(0)delimiter(")>operator(;) - keyword(if) operator(()ident(values)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(after) operator(=) ident(values)operator([)integer(1)operator(])operator(;) - operator(}) - type(int) ident(signum) operator(=) ident(value)operator(.)ident(signum)operator(()operator(\))operator(;) - pre_type(StringBuilder) ident(build) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(build)operator(.)ident(append)operator(()ident(signum) operator(==) operator(-)integer(1) operator(?) string<delimiter(")content(-)delimiter(")> operator(:) operator(()ident(signum) operator(==) integer(1) operator(?) operator(()ident(posSign)operator(()ident(arg)operator(\)) operator(?) operator(()ident(posSpace)operator(()ident(arg)operator(\)) operator(?) string<delimiter(")content( )delimiter(")> operator(:) string<delimiter(")content(+)delimiter(")>operator(\)) operator(:) string<delimiter(")delimiter(")>operator(\)) operator(:) string<delimiter(")delimiter(")>operator(\))operator(\))operator(;) - keyword(if) operator(()ident(groups)operator(()ident(arg)operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(build)operator(.)ident(append)operator(()ident(whole)operator(\))operator(;) - keyword(if) operator(()pre_constant(null) operator(!=) ident(after)operator(\)) operator({) - ident(build)operator(.)ident(append)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(after)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(index) operator(=) integer(0)operator(;) - pre_type(String) ident(sep) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(while) operator(()ident(index) operator(<) ident(whole)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - type(int) ident(next) operator(=) ident(index) operator(+) ident(groups)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(next) operator(>) ident(whole)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(next) operator(=) ident(whole)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - ident(build)operator(.)ident(append)operator(()ident(sep)operator(\))operator(.)ident(append)operator(()ident(whole)operator(.)ident(substring)operator(()ident(index)operator(,) ident(next)operator(\))operator(\))operator(;) - ident(sep) operator(=) string<delimiter(")content( )delimiter(")>operator(;) - ident(index) operator(+=) ident(groups)operator(()ident(arg)operator(\))operator(;) - operator(}) - keyword(if) operator(()pre_constant(null) operator(!=) ident(after)operator(\)) operator({) - ident(build)operator(.)ident(append)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - ident(index) operator(=) integer(0)operator(;) - ident(sep) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(while) operator(()ident(index) operator(<) ident(after)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - type(int) ident(next) operator(=) ident(index) operator(+) ident(groups)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(next) operator(>) ident(after)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(next) operator(=) ident(after)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - ident(build)operator(.)ident(append)operator(()ident(sep)operator(\))operator(.)ident(append)operator(()ident(after)operator(.)ident(substring)operator(()ident(index)operator(,) ident(next)operator(\))operator(\))operator(;) - ident(sep) operator(=) string<delimiter(")content( )delimiter(")>operator(;) - ident(index) operator(+=) ident(groups)operator(()ident(arg)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(build)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - pre_type(String) ident(arg) operator(=) ident(firstArgument)operator(()ident(args)operator(\))operator(;) - keyword(if) operator(()ident(isNaN)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(NaN)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(infinitySign) operator(!=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(infinitySign) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(-Infinity)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(Infinity)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(isZero)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(zero) operator(=) string<delimiter(")content(0.0)delimiter(")>operator(;) - keyword(if) operator(()ident(zeroSign) operator(<) integer(0)operator(\)) operator({) - ident(zero) operator(=) string<delimiter(")content(-)delimiter(")> operator(+) ident(zero)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(zero)operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(asEngineering)operator(()ident(arg)operator(\))operator(\)) operator({) - keyword(return) ident(engineeringValue)operator(()ident(arg)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(floatingPointValue)operator(()ident(arg)operator(\))operator(;) - operator(}) - operator(}) - - comment(// Note: #fix has only no-arg form, but truncate allows optional parameter.) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(fix)operator(()operator(\)) operator({) - keyword(return) ident(truncate)operator(()ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(truncate)operator(()operator(\)) operator({) - keyword(return) ident(truncate)operator(()ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(truncate)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(isNaN)operator(\)) operator({) - keyword(return) ident(newNaN)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isInfinity)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newInfinity)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(infinitySign)operator(\))operator(;) - operator(}) - - type(int) ident(n) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - - type(int) ident(precision) operator(=) ident(value)operator(.)ident(precision)operator(()operator(\)) operator(-) ident(value)operator(.)ident(scale)operator(()operator(\)) operator(+) ident(n)operator(;) - - keyword(if) operator(()ident(precision) operator(>) integer(0)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(value)operator(.)ident(round)operator(()keyword(new) pre_type(MathContext)operator(()ident(precision)operator(,) pre_type(RoundingMode)operator(.)ident(DOWN)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// TODO: proper sign) - keyword(return) keyword(new) ident(RubyBigDecimal)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(BigDecimal)operator(.)ident(ZERO)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(zero_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isZero)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Returns the correctly rounded square root of a positive - * BigDecimal. This method performs the fast <i>Square Root by - * Coupled Newton Iteration</i> algorithm by Timm Ahrendt, from - * the book "Pi, unleashed" by Jörg Arndt in a neat loop. - * <p> - * The code is based on Frans Lelieveld's code , used here with - * permission. - * - * @param squarD The number to get the root from. - * @param rootMC Precision and rounding mode. - * @return the root of the argument number - * @throws ArithmeticException - * if the argument number is negative - * @throws IllegalArgumentException - * if rootMC has precision 0 - */) - directive(public) directive(static) pre_type(BigDecimal) ident(bigSqrt)operator(()pre_type(BigDecimal) ident(squarD)operator(,) pre_type(MathContext) ident(rootMC)operator(\)) operator({) - comment(// General number and precision checking) - type(int) ident(sign) operator(=) ident(squarD)operator(.)ident(signum)operator(()operator(\))operator(;) - keyword(if) operator(()ident(sign) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(throw) keyword(new) exception(ArithmeticException)operator(()string<delimiter(")content(Square root of a negative number: )delimiter(")> operator(+) ident(squarD)operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(sign) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(squarD)operator(.)ident(round)operator(()ident(rootMC)operator(\))operator(;) - operator(}) - - type(int) ident(prec) operator(=) ident(rootMC)operator(.)ident(getPrecision)operator(()operator(\))operator(;) comment(// the requested precision) - keyword(if) operator(()ident(prec) operator(==) integer(0)operator(\)) operator({) - keyword(throw) keyword(new) exception(IllegalArgumentException)operator(()string<delimiter(")content(Most roots won't have infinite precision = 0)delimiter(")>operator(\))operator(;) - operator(}) - - comment(// Initial precision is that of double numbers 2^63/2 ~ 4E18) - type(int) ident(BITS) operator(=) integer(62)operator(;) comment(// 63-1 an even number of number bits) - type(int) ident(nInit) operator(=) integer(16)operator(;) comment(// precision seems 16 to 18 digits) - pre_type(MathContext) ident(nMC) operator(=) keyword(new) pre_type(MathContext)operator(()integer(18)operator(,) pre_type(RoundingMode)operator(.)ident(HALF_DOWN)operator(\))operator(;) - - comment(// Iteration variables, for the square root x and the reciprocal v) - pre_type(BigDecimal) ident(x) operator(=) pre_constant(null)operator(,) ident(e) operator(=) pre_constant(null)operator(;) comment(// initial x: x0 ~ sqrt(\)) - pre_type(BigDecimal) ident(v) operator(=) pre_constant(null)operator(,) ident(g) operator(=) pre_constant(null)operator(;) comment(// initial v: v0 = 1/(2*x\)) - - comment(// Estimate the square root with the foremost 62 bits of squarD) - pre_type(BigInteger) ident(bi) operator(=) ident(squarD)operator(.)ident(unscaledValue)operator(()operator(\))operator(;) comment(// bi and scale are a tandem) - type(int) ident(biLen) operator(=) ident(bi)operator(.)ident(bitLength)operator(()operator(\))operator(;) - type(int) ident(shift) operator(=) pre_type(Math)operator(.)ident(max)operator(()integer(0)operator(,) ident(biLen) operator(-) ident(BITS) operator(+) operator(()ident(biLen)operator(%)integer(2) operator(==) integer(0) operator(?) integer(0) operator(:) integer(1)operator(\))operator(\))operator(;) comment(// even shift..) - ident(bi) operator(=) ident(bi)operator(.)ident(shiftRight)operator(()ident(shift)operator(\))operator(;) comment(// ..floors to 62 or 63 bit BigInteger) - - type(double) ident(root) operator(=) pre_type(Math)operator(.)ident(sqrt)operator(()ident(bi)operator(.)ident(doubleValue)operator(()operator(\))operator(\))operator(;) - pre_type(BigDecimal) ident(halfBack) operator(=) keyword(new) pre_type(BigDecimal)operator(()pre_type(BigInteger)operator(.)ident(ONE)operator(.)ident(shiftLeft)operator(()ident(shift)operator(/)integer(2)operator(\))operator(\))operator(;) - - type(int) ident(scale) operator(=) ident(squarD)operator(.)ident(scale)operator(()operator(\))operator(;) - keyword(if) operator(()ident(scale) operator(%) integer(2) operator(==) integer(1)operator(\)) operator({) - ident(root) operator(*=) ident(SQRT_10)operator(;) comment(// 5 -> 2, -5 -> -3 need half a scale more..) - operator(}) - ident(scale) operator(=) operator(()type(int)operator(\)) pre_type(Math)operator(.)ident(floor)operator(()ident(scale)operator(/)integer(2)operator(.)operator(\))operator(;) comment(// ..where 100 -> 10 shifts the scale) - - comment(// Initial x - use double root - multiply by halfBack to unshift - set new scale) - ident(x) operator(=) keyword(new) pre_type(BigDecimal)operator(()ident(root)operator(,) ident(nMC)operator(\))operator(;) - ident(x) operator(=) ident(x)operator(.)ident(multiply)operator(()ident(halfBack)operator(,) ident(nMC)operator(\))operator(;) comment(// x0 ~ sqrt(\)) - keyword(if) operator(()ident(scale) operator(!=) integer(0)operator(\)) operator({) - ident(x) operator(=) ident(x)operator(.)ident(movePointLeft)operator(()ident(scale)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(prec) operator(<) ident(nInit)operator(\)) operator({) comment(// for prec 15 root x0 must surely be OK) - keyword(return) ident(x)operator(.)ident(round)operator(()ident(rootMC)operator(\))operator(;) comment(// return small prec roots without iterations) - operator(}) - - comment(// Initial v - the reciprocal) - ident(v) operator(=) pre_type(BigDecimal)operator(.)ident(ONE)operator(.)ident(divide)operator(()ident(TWO)operator(.)ident(multiply)operator(()ident(x)operator(\))operator(,) ident(nMC)operator(\))operator(;) comment(// v0 = 1/(2*x\)) - - comment(// Collect iteration precisions beforehand) - pre_type(List)operator(<)pre_type(Integer)operator(>) ident(nPrecs) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(Integer)operator(>)operator(()operator(\))operator(;) - - keyword(assert) ident(nInit) operator(>) integer(3) operator(:) string<delimiter(")content(Never ending loop!)delimiter(")>operator(;) comment(// assume nInit = 16 <= prec) - - comment(// Let m be the exact digits precision in an earlier! loop) - keyword(for) operator(()type(int) ident(m) operator(=) ident(prec) operator(+) integer(1)operator(;) ident(m) operator(>) ident(nInit)operator(;) ident(m) operator(=) ident(m)operator(/)integer(2) operator(+) operator(()ident(m) operator(>) integer(100) operator(?) integer(1) operator(:) integer(2)operator(\))operator(\)) operator({) - ident(nPrecs)operator(.)ident(add)operator(()ident(m)operator(\))operator(;) - operator(}) - - comment(// The loop of "Square Root by Coupled Newton Iteration") - keyword(for) operator(()type(int) ident(i) operator(=) ident(nPrecs)operator(.)ident(size)operator(()operator(\)) operator(-) integer(1)operator(;) ident(i) operator(>) operator(-)integer(1)operator(;) ident(i)operator(--)operator(\)) operator({) - comment(// Increase precision - next iteration supplies n exact digits) - ident(nMC) operator(=) keyword(new) pre_type(MathContext)operator(()ident(nPrecs)operator(.)ident(get)operator(()ident(i)operator(\))operator(,) operator(()ident(i)operator(%)integer(2) operator(==) integer(1)operator(\)) operator(?) pre_type(RoundingMode)operator(.)ident(HALF_UP) operator(:) - pre_type(RoundingMode)operator(.)ident(HALF_DOWN)operator(\))operator(;) - - comment(// Next x // e = d - x^2) - ident(e) operator(=) ident(squarD)operator(.)ident(subtract)operator(()ident(x)operator(.)ident(multiply)operator(()ident(x)operator(,) ident(nMC)operator(\))operator(,) ident(nMC)operator(\))operator(;) - keyword(if) operator(()ident(i) operator(!=) integer(0)operator(\)) operator({) - ident(x) operator(=) ident(x)operator(.)ident(add)operator(()ident(e)operator(.)ident(multiply)operator(()ident(v)operator(,) ident(nMC)operator(\))operator(\))operator(;) comment(// x += e*v ~ sqrt(\)) - operator(}) keyword(else) operator({) - ident(x) operator(=) ident(x)operator(.)ident(add)operator(()ident(e)operator(.)ident(multiply)operator(()ident(v)operator(,) ident(rootMC)operator(\))operator(,) ident(rootMC)operator(\))operator(;) comment(// root x is ready!) - keyword(break)operator(;) - operator(}) - - comment(// Next v // g = 1 - 2*x*v) - ident(g) operator(=) pre_type(BigDecimal)operator(.)ident(ONE)operator(.)ident(subtract)operator(()ident(TWO)operator(.)ident(multiply)operator(()ident(x)operator(\))operator(.)ident(multiply)operator(()ident(v)operator(,) ident(nMC)operator(\))operator(\))operator(;) - - ident(v) operator(=) ident(v)operator(.)ident(add)operator(()ident(g)operator(.)ident(multiply)operator(()ident(v)operator(,) ident(nMC)operator(\))operator(\))operator(;) comment(// v += g*v ~ 1/2/sqrt(\)) - operator(}) - - keyword(return) ident(x)operator(;) comment(// return sqrt(squarD\) with precision of rootMC) - operator(}) -operator(})comment(// RubyBigdecimal) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.math.BigDecimal)operator(;) -keyword(import) include(java.math.BigInteger)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Bignum)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Integer)delimiter(")>operator(\)) -directive(public) type(class) class(RubyBignum) directive(extends) ident(RubyInteger) operator({) - directive(public) directive(static) ident(RubyClass) ident(createBignumClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(bignum) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Bignum)delimiter(")>operator(,) ident(runtime)operator(.)ident(getInteger)operator(()operator(\))operator(,) - ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setBignum)operator(()ident(bignum)operator(\))operator(;) - ident(bignum)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(BIGNUM)operator(;) - - ident(bignum)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyBignum)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(bignum)operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(BIT_SIZE) operator(=) integer(64)operator(;) - directive(private) directive(static) directive(final) type(long) ident(MAX) operator(=) operator(()integer(1L) operator(<)operator(<) operator(()ident(BIT_SIZE) operator(-) integer(1)operator(\))operator(\)) operator(-) integer(1)operator(;) - directive(private) directive(static) directive(final) pre_type(BigInteger) ident(LONG_MAX) operator(=) pre_type(BigInteger)operator(.)ident(valueOf)operator(()ident(MAX)operator(\))operator(;) - directive(private) directive(static) directive(final) pre_type(BigInteger) ident(LONG_MIN) operator(=) pre_type(BigInteger)operator(.)ident(valueOf)operator(()operator(-)ident(MAX) operator(-) integer(1)operator(\))operator(;) - - directive(private) directive(final) pre_type(BigInteger) ident(value)operator(;) - - directive(public) ident(RubyBignum)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(BigInteger) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getBignum)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(BIGNUM)operator(;) - operator(}) - - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) pre_type(BigInteger)operator(.)ident(class)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBignum) ident(newBignum)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(value)operator(\)) operator({) - keyword(return) ident(newBignum)operator(()ident(runtime)operator(,) pre_type(BigInteger)operator(.)ident(valueOf)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBignum) ident(newBignum)operator(()ident(Ruby) ident(runtime)operator(,) type(double) ident(value)operator(\)) operator({) - keyword(return) ident(newBignum)operator(()ident(runtime)operator(,) keyword(new) pre_type(BigDecimal)operator(()ident(value)operator(\))operator(.)ident(toBigInteger)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBignum) ident(newBignum)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(BigInteger) ident(value)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBignum)operator(()ident(runtime)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBignum) ident(newBignum)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(value)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBignum)operator(()ident(runtime)operator(,) keyword(new) pre_type(BigInteger)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(double) ident(getDoubleValue)operator(()operator(\)) operator({) - keyword(return) ident(big2dbl)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) type(long) ident(getLongValue)operator(()operator(\)) operator({) - keyword(return) ident(big2long)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** Getter for property value. - * @return Value of property value. - */) - directive(public) pre_type(BigInteger) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/* ================ - * Utility Methods - * ================ - */) - - comment(/* If the value will fit in a Fixnum, return one of those. */) - comment(/** rb_big_norm - * - */) - directive(public) directive(static) ident(RubyInteger) ident(bignorm)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(BigInteger) ident(bi)operator(\)) operator({) - keyword(if) operator(()ident(bi)operator(.)ident(compareTo)operator(()ident(LONG_MIN)operator(\)) operator(<) integer(0) operator(||) ident(bi)operator(.)ident(compareTo)operator(()ident(LONG_MAX)operator(\)) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(newBignum)operator(()ident(runtime)operator(,) ident(bi)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(bi)operator(.)ident(longValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big2long - * - */) - directive(public) directive(static) type(long) ident(big2long)operator(()ident(RubyBignum) ident(value)operator(\)) operator({) - pre_type(BigInteger) ident(big) operator(=) ident(value)operator(.)ident(getValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(big)operator(.)ident(compareTo)operator(()ident(LONG_MIN)operator(\)) operator(<) integer(0) operator(||) ident(big)operator(.)ident(compareTo)operator(()ident(LONG_MAX)operator(\)) operator(>) integer(0)operator(\)) operator({) - keyword(throw) ident(value)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(bignum too big to convert into `long')delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(big)operator(.)ident(longValue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_big2dbl - * - */) - directive(public) directive(static) type(double) ident(big2dbl)operator(()ident(RubyBignum) ident(value)operator(\)) operator({) - pre_type(BigInteger) ident(big) operator(=) ident(value)operator(.)ident(getValue)operator(()operator(\))operator(;) - type(double) ident(dbl) operator(=) ident(convertToDouble)operator(()ident(big)operator(\))operator(;) - keyword(if) operator(()ident(dbl) operator(==) pre_type(Double)operator(.)ident(NEGATIVE_INFINITY) operator(||) ident(dbl) operator(==) pre_type(Double)operator(.)ident(POSITIVE_INFINITY)operator(\)) operator({) - ident(value)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(BIGNUM_FROM_FLOAT_RANGE)operator(,) string<delimiter(")content(Bignum out of Float range)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(dbl)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(checkShiftDown)operator(()ident(RubyBignum) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(==) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(value)operator(.)ident(compareTo)operator(()ident(LONG_MIN)operator(\)) operator(<) integer(0) operator(||) ident(value)operator(.)ident(compareTo)operator(()ident(LONG_MAX)operator(\)) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(other)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(>=) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * BigInteger#doubleValue is _really_ slow currently. - * This is faster, and mostly correct (?\) - */) - directive(static) type(double) ident(convertToDouble)operator(()pre_type(BigInteger) ident(bigint)operator(\)) operator({) - type(byte)type([]) ident(arr) operator(=) ident(bigint)operator(.)ident(toByteArray)operator(()operator(\))operator(;) - type(double) ident(res) operator(=) integer(0)operator(;) - type(double) ident(acc) operator(=) integer(1)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(arr)operator(.)ident(length) operator(-) integer(1)operator(;) ident(i) operator(>) integer(0) operator(;) ident(i)operator(--)operator(\)) - operator({) - ident(res) operator(+=) operator(()type(double)operator(\)) operator(()ident(arr)operator([)ident(i)operator(]) operator(&) hex(0xff)operator(\)) operator(*) ident(acc)operator(;) - ident(acc) operator(*=) integer(256)operator(;) - operator(}) - ident(res) operator(+=) operator(()type(double)operator(\)) ident(arr)operator([)integer(0)operator(]) operator(*) ident(acc)operator(;) comment(// final byte sign is significant) - keyword(return) ident(res)operator(;) - operator(}) - - comment(/** rb_int2big - * - */) - directive(public) directive(static) pre_type(BigInteger) ident(fix2big)operator(()ident(RubyFixnum) ident(arg)operator(\)) operator({) - keyword(return) pre_type(BigInteger)operator(.)ident(valueOf)operator(()ident(arg)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** rb_big_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(int) ident(base) operator(=) ident(args)operator(.)ident(length) operator(==) integer(0) operator(?) integer(10) operator(:) ident(num2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(base) operator(<) integer(2) operator(||) ident(base) operator(>) integer(36)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal radix )delimiter(")> operator(+) ident(base)operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(getValue)operator(()operator(\))operator(.)ident(toString)operator(()ident(base)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_coerce - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(coerce)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(getValue)operator(()operator(\))operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Can't coerce )delimiter(")> operator(+) ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( to Bignum)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_big_uminus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uminus)operator(()operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(negate)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_plus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(addFixnum)operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(addBignum)operator(()operator(()ident(RubyBignum)operator(\))ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(addFloat)operator(()operator(()ident(RubyFloat)operator(\))ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(addOther)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addFixnum)operator(()ident(RubyFixnum) ident(other)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(add)operator(()ident(fix2big)operator(()ident(other)operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addBignum)operator(()ident(RubyBignum) ident(other)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(add)operator(()ident(other)operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addFloat)operator(()ident(RubyFloat) ident(other)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big2dbl)operator(()local_variable(this)operator(\)) operator(+) ident(other)operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addOther)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_big_minus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_minus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(subtractFixnum)operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(subtractBignum)operator(()operator(()ident(RubyBignum)operator(\))ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(subtractFloat)operator(()operator(()ident(RubyFloat)operator(\))ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(subtractOther)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractFixnum)operator(()ident(RubyFixnum) ident(other)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(subtract)operator(()ident(fix2big)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractBignum)operator(()ident(RubyBignum) ident(other)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(subtract)operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractFloat)operator(()ident(RubyFloat) ident(other)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big2dbl)operator(()local_variable(this)operator(\)) operator(-) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractOther)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_big_mul - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(multiply)operator(()ident(fix2big)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(multiply)operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big2dbl)operator(()local_variable(this)operator(\)) operator(*) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** - * rb_big_divide. Shared part for both "/" and "div" operations. - */) - directive(private) ident(IRubyObject) ident(op_divide)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) pre_type(String) ident(op)operator(\)) operator({) - keyword(assert) operator(()string<delimiter(")content(/)delimiter(")>operator(.)ident(equals)operator(()ident(op)operator(\)) operator(||) string<delimiter(")content(div)delimiter(")>operator(.)ident(equals)operator(()ident(op)operator(\))operator(\))operator(;) - - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(div) operator(=) ident(big2dbl)operator(()local_variable(this)operator(\)) operator(/) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(if) operator(()string<delimiter(")content(/)delimiter(")>operator(.)ident(equals)operator(()ident(op)operator(\))operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) - ident(big2dbl)operator(()local_variable(this)operator(\)) operator(/) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(dbl2num)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(div)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) ident(op)operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(otherValue)operator(.)ident(equals)operator(()pre_type(BigInteger)operator(.)ident(ZERO)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - pre_type(BigInteger)type([]) ident(results) operator(=) ident(value)operator(.)ident(divideAndRemainder)operator(()ident(otherValue)operator(\))operator(;) - - keyword(if) operator(()operator(()ident(value)operator(.)ident(signum)operator(()operator(\)) operator(*) ident(otherValue)operator(.)ident(signum)operator(()operator(\))operator(\)) operator(==) operator(-)integer(1) operator(&&) ident(results)operator([)integer(1)operator(])operator(.)ident(signum)operator(()operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(results)operator([)integer(0)operator(])operator(.)ident(subtract)operator(()pre_type(BigInteger)operator(.)ident(ONE)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(results)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - comment(/** rb_big_div - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(/)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(op_divide)operator(()ident(context)operator(,) ident(other)operator(,) string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_big_idiv - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(div)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_idiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(op_divide)operator(()ident(context)operator(,) ident(other)operator(,) string<delimiter(")content(div)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_big_divmod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(otherValue)operator(.)ident(equals)operator(()pre_type(BigInteger)operator(.)ident(ZERO)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - pre_type(BigInteger)type([]) ident(results) operator(=) ident(value)operator(.)ident(divideAndRemainder)operator(()ident(otherValue)operator(\))operator(;) - - keyword(if) operator(()operator(()ident(value)operator(.)ident(signum)operator(()operator(\)) operator(*) ident(otherValue)operator(.)ident(signum)operator(()operator(\))operator(\)) operator(==) operator(-)integer(1) operator(&&) ident(results)operator([)integer(1)operator(])operator(.)ident(signum)operator(()operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(results)operator([)integer(0)operator(]) operator(=) ident(results)operator([)integer(0)operator(])operator(.)ident(subtract)operator(()pre_type(BigInteger)operator(.)ident(ONE)operator(\))operator(;) - ident(results)operator([)integer(1)operator(]) operator(=) ident(otherValue)operator(.)ident(add)operator(()ident(results)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(bignorm)operator(()ident(runtime)operator(,) ident(results)operator([)integer(0)operator(])operator(\))operator(,) ident(bignorm)operator(()ident(runtime)operator(,) ident(results)operator([)integer(1)operator(])operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_modulo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(%)delimiter(")>operator(,) string<delimiter(")content(modulo)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(otherValue)operator(.)ident(equals)operator(()pre_type(BigInteger)operator(.)ident(ZERO)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - pre_type(BigInteger) ident(result) operator(=) ident(value)operator(.)ident(mod)operator(()ident(otherValue)operator(.)ident(abs)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(otherValue)operator(.)ident(signum)operator(()operator(\)) operator(==) operator(-)integer(1) operator(&&) ident(result)operator(.)ident(signum)operator(()operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(result) operator(=) ident(otherValue)operator(.)ident(add)operator(()ident(result)operator(\))operator(;) - operator(}) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - - operator(}) - - comment(/** rb_big_remainder - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remainder)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(remainder)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(remainder)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(otherValue)operator(.)ident(equals)operator(()pre_type(BigInteger)operator(.)ident(ZERO)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(remainder)operator(()ident(otherValue)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_quo - - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(quo)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(quo)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big2dbl)operator(()local_variable(this)operator(\)) operator(/) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(quo)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_big_pow - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(**)delimiter(")>operator(,) string<delimiter(")content(power)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_pow)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - type(double) ident(d)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(RubyFixnum) ident(fix) operator(=) operator(()ident(RubyFixnum)operator(\)) ident(other)operator(;) - type(long) ident(fixValue) operator(=) ident(fix)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - comment(// MRI issuses warning here on (RBIGNUM(x\)->len * SIZEOF_BDIGITS * yy > 1024*1024\)) - keyword(if) operator(()operator(()operator(()ident(value)operator(.)ident(bitLength)operator(()operator(\)) operator(+) integer(7)operator(\)) operator(/) integer(8)operator(\)) operator(*) integer(4) operator(*) pre_type(Math)operator(.)ident(abs)operator(()ident(fixValue)operator(\)) operator(>) integer(1024) operator(*) integer(1024)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MAY_BE_TOO_BIG)operator(,) string<delimiter(")content(in a**b, b may be too big)delimiter(")>operator(,) ident(fixValue)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(fixValue) operator(>=) integer(0)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(pow)operator(()operator(()type(int)operator(\)) ident(fixValue)operator(\))operator(\))operator(;) comment(// num2int is also implemented) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(big2dbl)operator(()local_variable(this)operator(\))operator(,) operator(()type(double)operator(\))ident(fixValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(d) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MAY_BE_TOO_BIG)operator(,) string<delimiter(")content(in a**b, b may be too big)delimiter(")>operator(,) ident(d)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(d) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(big2dbl)operator(()local_variable(this)operator(\))operator(,) ident(d)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_pow - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(**)delimiter(")>operator(,) string<delimiter(")content(power)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(op_pow_19)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(other) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - type(double) ident(d)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(RubyFixnum) ident(fix) operator(=) operator(()ident(RubyFixnum)operator(\)) ident(other)operator(;) - type(long) ident(fixValue) operator(=) ident(fix)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(fixValue) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalRaw)operator(()ident(runtime)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - comment(// MRI issuses warning here on (RBIGNUM(x\)->len * SIZEOF_BDIGITS * yy > 1024*1024\)) - keyword(if) operator(()operator(()operator(()ident(value)operator(.)ident(bitLength)operator(()operator(\)) operator(+) integer(7)operator(\)) operator(/) integer(8)operator(\)) operator(*) integer(4) operator(*) pre_type(Math)operator(.)ident(abs)operator(()ident(fixValue)operator(\)) operator(>) integer(1024) operator(*) integer(1024)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MAY_BE_TOO_BIG)operator(,) string<delimiter(")content(in a**b, b may be too big)delimiter(")>operator(,) ident(fixValue)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(fixValue) operator(>=) integer(0)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(runtime)operator(,) ident(value)operator(.)ident(pow)operator(()operator(()type(int)operator(\)) ident(fixValue)operator(\))operator(\))operator(;) comment(// num2int is also implemented) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(big2dbl)operator(()local_variable(this)operator(\))operator(,) operator(()type(double)operator(\))ident(fixValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(if) operator(()ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalRaw)operator(()ident(runtime)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - ident(d) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MAY_BE_TOO_BIG)operator(,) string<delimiter(")content(in a**b, b may be too big)delimiter(")>operator(,) ident(d)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(d) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - operator(}) - keyword(return) ident(RubyNumeric)operator(.)ident(dbl2num)operator(()ident(runtime)operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(big2dbl)operator(()local_variable(this)operator(\))operator(,) ident(d)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_and - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_and)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(other) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(and)operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(and)operator(()ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(&)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_big_or - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_or)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(other) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(or)operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) comment(// no bignorm here needed) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(or)operator(()ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(|)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_big_xor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(^)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_xor)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(other) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(xor)operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(xor)operator(()pre_type(BigInteger)operator(.)ident(valueOf)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(^)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_big_neg - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(~)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_neg)operator(()operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(not)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_lshift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_lshift)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - type(long) ident(shift)operator(;) - type(boolean) ident(neg) operator(=) pre_constant(false)operator(;) - - keyword(for) operator(()operator(;)operator(;)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(shift) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shift) operator(<) integer(0)operator(\)) operator({) - ident(neg) operator(=) pre_constant(true)operator(;) - ident(shift) operator(=) operator(-)ident(shift)operator(;) - operator(}) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(RubyBignum) ident(otherBignum) operator(=) operator(()ident(RubyBignum)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(otherBignum)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(otherBignum)operator(.)ident(checkShiftDown)operator(()local_variable(this)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(tmp)operator(;) - ident(neg) operator(=) pre_constant(true)operator(;) - operator(}) - ident(shift) operator(=) ident(big2long)operator(()ident(otherBignum)operator(\))operator(;) - keyword(break)operator(;) - operator(}) - ident(other) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(neg) operator(?) ident(value)operator(.)ident(shiftRight)operator(()operator(()type(int)operator(\))ident(shift)operator(\)) operator(:) ident(value)operator(.)ident(shiftLeft)operator(()operator(()type(int)operator(\))ident(shift)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_rshift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_rshift)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - type(long) ident(shift)operator(;) - type(boolean) ident(neg) operator(=) pre_constant(false)operator(;) - - keyword(for) operator(()operator(;)operator(;)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(shift) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shift) operator(<) integer(0)operator(\)) operator({) - ident(neg) operator(=) pre_constant(true)operator(;) - ident(shift) operator(=) operator(-)ident(shift)operator(;) - operator(}) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(RubyBignum) ident(otherBignum) operator(=) operator(()ident(RubyBignum)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(otherBignum)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(>=) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(otherBignum)operator(.)ident(checkShiftDown)operator(()local_variable(this)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(tmp)operator(;) - operator(}) keyword(else) operator({) - ident(neg) operator(=) pre_constant(true)operator(;) - operator(}) - ident(shift) operator(=) ident(big2long)operator(()ident(otherBignum)operator(\))operator(;) - keyword(break)operator(;) - operator(}) - ident(other) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(neg) operator(?) ident(value)operator(.)ident(shiftLeft)operator(()operator(()type(int)operator(\))ident(shift)operator(\)) operator(:) ident(value)operator(.)ident(shiftRight)operator(()operator(()type(int)operator(\))ident(shift)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_aref - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyFixnum) ident(op_aref)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(if) operator(()operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(>=) integer(0) operator(||) ident(value)operator(.)ident(signum)operator(()operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - type(long) ident(position) operator(=) ident(num2long)operator(()ident(other)operator(\))operator(;) - keyword(if) operator(()ident(position) operator(<) integer(0) operator(||) ident(position) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(value)operator(.)ident(testBit)operator(()operator(()type(int)operator(\))ident(position)operator(\)) operator(?) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(dbl_cmp)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big2dbl)operator(()local_variable(this)operator(\))operator(,) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(coerceCmp)operator(()ident(context)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(// wow, the only time we can use the java protocol ;\) ) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(compareTo)operator(()ident(otherValue)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_eq - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) pre_type(BigInteger) ident(otherValue)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(otherValue) operator(=) ident(fix2big)operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - ident(otherValue) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(a) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(a)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(a) operator(==) ident(big2dbl)operator(()local_variable(this)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(other)operator(.)ident(op_eqq)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(compareTo)operator(()ident(otherValue)operator(\)) operator(==) integer(0)operator(\))operator(;) - operator(}) - - comment(/** rb_big_eql - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(eql?)delimiter(")>operator(,) string<delimiter(")content(===)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(compareTo)operator(()operator(()operator(()ident(RubyBignum)operator(\))ident(other)operator(\))operator(.)ident(value)operator(\)) operator(==) integer(0) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_big_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_to_f - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_abs - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(abs)operator(()operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(abs)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_big_size - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(size)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(()ident(value)operator(.)ident(bitLength)operator(()operator(\)) operator(+) integer(7)operator(\)) operator(/) integer(8)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyBignum) ident(bignum)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) exception(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(bignum)operator(\))operator(;) - - ident(output)operator(.)ident(write)operator(()ident(bignum)operator(.)ident(value)operator(.)ident(signum)operator(()operator(\)) operator(>=) integer(0) operator(?) string<delimiter(')content(+)delimiter(')> operator(:) string<delimiter(')content(-)delimiter(')>operator(\))operator(;) - - pre_type(BigInteger) ident(absValue) operator(=) ident(bignum)operator(.)ident(value)operator(.)ident(abs)operator(()operator(\))operator(;) - - type(byte)type([]) ident(digits) operator(=) ident(absValue)operator(.)ident(toByteArray)operator(()operator(\))operator(;) - - type(boolean) ident(oddLengthNonzeroStart) operator(=) operator(()ident(digits)operator(.)ident(length) operator(%) integer(2) operator(!=) integer(0) operator(&&) ident(digits)operator([)integer(0)operator(]) operator(!=) integer(0)operator(\))operator(;) - type(int) ident(shortLength) operator(=) ident(digits)operator(.)ident(length) operator(/) integer(2)operator(;) - keyword(if) operator(()ident(oddLengthNonzeroStart)operator(\)) operator({) - ident(shortLength)operator(++)operator(;) - operator(}) - ident(output)operator(.)ident(writeInt)operator(()ident(shortLength)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<=) ident(shortLength) operator(*) integer(2) operator(&&) ident(i) operator(<=) ident(digits)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(output)operator(.)ident(write)operator(()ident(digits)operator([)ident(digits)operator(.)ident(length) operator(-) ident(i)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(oddLengthNonzeroStart)operator(\)) operator({) - comment(// Pad with a 0) - ident(output)operator(.)ident(write)operator(()integer(0)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyNumeric) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) exception(IOException) operator({) - type(boolean) ident(positive) operator(=) ident(input)operator(.)ident(readUnsignedByte)operator(()operator(\)) operator(==) string<delimiter(')content(+)delimiter(')>operator(;) - type(int) ident(shortLength) operator(=) ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(;) - - comment(// BigInteger required a sign byte in incoming array) - type(byte)type([]) ident(digits) operator(=) keyword(new) type(byte)operator([)ident(shortLength) operator(*) integer(2) operator(+) integer(1)operator(])operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) ident(digits)operator(.)ident(length) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(1)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(digits)operator([)ident(i)operator(]) operator(=) ident(input)operator(.)ident(readSignedByte)operator(()operator(\))operator(;) - operator(}) - - pre_type(BigInteger) ident(value) operator(=) keyword(new) pre_type(BigInteger)operator(()ident(digits)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(positive)operator(\)) operator({) - ident(value) operator(=) ident(value)operator(.)ident(negate)operator(()operator(\))operator(;) - operator(}) - - ident(RubyNumeric) ident(result) operator(=) ident(bignorm)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Binding)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Binding)delimiter(")>operator(\)) -directive(public) type(class) class(RubyBinding) directive(extends) ident(RubyObject) operator({) - directive(private) pre_type(Binding) ident(binding)operator(;) - - directive(public) ident(RubyBinding)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(Binding) ident(binding)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - - local_variable(this)operator(.)ident(binding) operator(=) ident(binding)operator(;) - operator(}) - - directive(private) ident(RubyBinding)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(BINDING_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyBinding) ident(instance) operator(=) keyword(new) ident(RubyBinding)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createBindingClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(bindingClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Binding)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(BINDING_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setBinding)operator(()ident(bindingClass)operator(\))operator(;) - - ident(bindingClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyBinding)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(bindingClass)operator(;) - operator(}) - - directive(public) pre_type(Binding) ident(getBinding)operator(()operator(\)) operator({) - keyword(return) ident(binding)operator(;) - operator(}) - - comment(// Proc class) - - directive(public) directive(static) ident(RubyBinding) ident(newBinding)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Binding) ident(binding)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBinding)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getBinding)operator(()operator(\))operator(,) ident(binding)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBinding) ident(newBinding)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - comment(// FIXME: We should be cloning, not reusing: frame, scope, dynvars, and potentially iter/block info) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - pre_type(Binding) ident(binding) operator(=) keyword(new) pre_type(Binding)operator(()ident(frame)operator(,) ident(context)operator(.)ident(getBindingRubyClass)operator(()operator(\))operator(,) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(\))operator(;) - - keyword(return) keyword(new) ident(RubyBinding)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getBinding)operator(()operator(\))operator(,) ident(binding)operator(\))operator(;) - operator(}) - - comment(/** - * Create a binding appropriate for a bare "eval", by using the previous (caller's\) frame and current - * scope. - */) - directive(public) directive(static) ident(RubyBinding) ident(newBindingForEval)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - comment(// This requires some explaining. We use Frame values when executing blocks to fill in ) - comment(// various values in ThreadContext and EvalState.eval like rubyClass, cref, and self.) - comment(// Largely, for an eval that is using the logical binding at a place where the eval is ) - comment(// called we mostly want to use the current frames value for this. Most importantly, ) - comment(// we need that self (JRUBY-858\) at this point. We also need to make sure that returns) - comment(// jump to the right place (which happens to be the previous frame\). Lastly, we do not) - comment(// want the current frames klazz since that will be the klazz represented of self. We) - comment(// want the class right before the eval (well we could use cref class for this too I think\).) - comment(// Once we end up having Frames created earlier I think the logic of stuff like this will) - comment(// be better since we won't be worried about setting Frame to setup other variables/stacks) - comment(// but just making sure Frame itself is correct...) - - pre_type(Frame) ident(previousFrame) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(;) - pre_type(Frame) ident(currentFrame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(currentFrame)operator(.)ident(setKlazz)operator(()ident(previousFrame)operator(.)ident(getKlazz)operator(()operator(\))operator(\))operator(;) - - comment(// Set jump target to whatever the previousTarget thinks is good.) -comment(// currentFrame.setJumpTarget(previousFrame.getJumpTarget(\) != null ? previousFrame.getJumpTarget(\) : previousFrame\);) - - pre_type(Binding) ident(binding) operator(=) keyword(new) pre_type(Binding)operator(()ident(previousFrame)operator(,) ident(context)operator(.)ident(getBindingRubyClass)operator(()operator(\))operator(,) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(return) keyword(new) ident(RubyBinding)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getBinding)operator(()operator(\))operator(,) ident(binding)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - comment(// FIXME: We should be cloning, not reusing: frame, scope, dynvars, and potentially iter/block info) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(binding) operator(=) keyword(new) pre_type(Binding)operator(()ident(frame)operator(,) ident(context)operator(.)ident(getBindingRubyClass)operator(()operator(\))operator(,) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyBinding) ident(otherBinding) operator(=) operator(()ident(RubyBinding)operator(\))ident(other)operator(;) - - ident(binding) operator(=) ident(otherBinding)operator(.)ident(binding)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)operator({)string<delimiter(")content(TrueClass)delimiter(")>operator(,) string<delimiter(")content(FalseClass)delimiter(")>operator(})operator(\)) -directive(public) type(class) class(RubyBoolean) directive(extends) ident(RubyObject) operator({) - - directive(public) ident(RubyBoolean)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) operator(()ident(value) operator(?) ident(runtime)operator(.)ident(getTrueClass)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalseClass)operator(()operator(\))operator(\))operator(,) comment(// Don't initialize with class) - pre_constant(false)operator(\))operator(;) comment(// Don't put in object space) - - keyword(if) operator(()operator(!)ident(value)operator(\)) ident(flags) operator(=) ident(FALSE_F)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(FALSE_F)operator(\)) operator(==) integer(0) operator(?) ident(ClassIndex)operator(.)ident(TRUE) operator(:) ident(ClassIndex)operator(.)ident(FALSE)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyClass) ident(getSingletonClass)operator(()operator(\)) operator({) - keyword(return) ident(metaClass)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) type(boolean)operator(.)ident(class)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createFalseClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(falseClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(FalseClass)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setFalseClass)operator(()ident(falseClass)operator(\))operator(;) - ident(falseClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(FALSE)operator(;) - - ident(falseClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(False)operator(.)ident(class)operator(\))operator(;) - - ident(falseClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - keyword(return) ident(falseClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createTrueClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(trueClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(TrueClass)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setTrueClass)operator(()ident(trueClass)operator(\))operator(;) - ident(trueClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(TRUE)operator(;) - - ident(trueClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(True)operator(.)ident(class)operator(\))operator(;) - - ident(trueClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - keyword(return) ident(trueClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyBoolean) ident(newBoolean)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(value)operator(\)) operator({) - keyword(return) ident(value) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(class) class(False) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_and)operator(()ident(IRubyObject) ident(f)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(f)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_or)operator(()ident(IRubyObject) ident(f)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(oth)operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(f)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(f)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(^)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_xor)operator(()ident(IRubyObject) ident(f)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(oth)operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(f)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(f)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_to_s)operator(()ident(IRubyObject) ident(f)operator(\)) operator({) - keyword(return) ident(f)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(false)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(True) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_and)operator(()ident(IRubyObject) ident(t)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(oth)operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(t) operator(:) ident(t)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_or)operator(()ident(IRubyObject) ident(t)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(t)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(^)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_xor)operator(()ident(IRubyObject) ident(t)operator(,) ident(IRubyObject) ident(oth)operator(\)) operator({) - keyword(return) ident(oth)operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(t)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(t)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_to_s)operator(()ident(IRubyObject) ident(t)operator(\)) operator({) - keyword(return) ident(t)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(true)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) ident(RubyFixnum) ident(id)operator(()operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(FALSE_F)operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) integer(2)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(taint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) type(void) ident(marshalTo)operator(()ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(write)operator(()ident(isTrue)operator(()operator(\)) operator(?) string<delimiter(')content(T)delimiter(')> operator(:) string<delimiter(')content(F)delimiter(')>operator(\))operator(;) - operator(}) -operator(}) - -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.Collection)operator(;) -keyword(import) include(java.util.Collections)operator(;) -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) - -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.JavaMethod)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallSite)operator(;) -keyword(import) include(org.jruby.runtime.CallSite.InlineCachingCallSite)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ObjectMarshal)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.collections.WeakHashSet)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Class)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Module)delimiter(")>operator(\)) -directive(public) type(class) class(RubyClass) directive(extends) ident(RubyModule) operator({) - directive(public) directive(static) directive(final) type(int) ident(CS_IDX_INITIALIZE) operator(=) integer(0)operator(;) - directive(public) directive(static) directive(final) pre_type(String)type([]) ident(CS_NAMES) operator(=) operator({) - string<delimiter(")content(initialize)delimiter(")> - operator(})operator(;) - directive(private) directive(final) ident(CallSite)type([]) ident(baseCallSites) operator(=) keyword(new) ident(CallSite)operator([)ident(CS_NAMES)operator(.)ident(length)operator(])operator(;) - operator({) - keyword(for)operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(CS_NAMES)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(baseCallSites)operator([)ident(i)operator(]) operator(=) keyword(new) ident(InlineCachingCallSite)operator(()ident(CS_NAMES)operator([)ident(i)operator(])operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(CallSite)type([]) ident(extraCallSites)operator(;) - - directive(public) directive(static) type(void) ident(createClassClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(classClass)operator(\)) operator({) - ident(classClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(CLASS)operator(;) - ident(classClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyClass)operator(;) - operator(}) - operator(})operator(;) - - ident(classClass)operator(.)ident(undefineMethod)operator(()string<delimiter(")content(module_function)delimiter(")>operator(\))operator(;) - ident(classClass)operator(.)ident(undefineMethod)operator(()string<delimiter(")content(append_features)delimiter(")>operator(\))operator(;) - ident(classClass)operator(.)ident(undefineMethod)operator(()string<delimiter(")content(extend_object)delimiter(")>operator(\))operator(;) - - ident(classClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyClass)operator(.)ident(class)operator(\))operator(;) - - ident(classClass)operator(.)ident(addMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(,) keyword(new) ident(SpecificArityNew)operator(()ident(classClass)operator(,) pre_type(Visibility)operator(.)ident(PUBLIC)operator(\))operator(\))operator(;) - - comment(// This is a non-standard method; have we decided to start extending Ruby?) - comment(//classClass.defineFastMethod("subclasses", callbackFactory.getFastOptMethod("subclasses"\)\);) - - comment(// FIXME: for some reason this dispatcher causes a VerifyError...) - comment(//classClass.dispatcher = callbackFactory.createDispatcher(classClass\);) - operator(}) - - directive(public) directive(static) directive(final) ident(ObjectAllocator) ident(CLASS_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyClass) ident(clazz) operator(=) keyword(new) ident(RubyClass)operator(()ident(runtime)operator(\))operator(;) - ident(clazz)operator(.)ident(allocator) operator(=) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(;) comment(// Class.allocate object is not allocatable before it is initialized) - keyword(return) ident(clazz)operator(;) - operator(}) - operator(})operator(;) - - directive(public) ident(ObjectAllocator) ident(getAllocator)operator(()operator(\)) operator({) - keyword(return) ident(allocator)operator(;) - operator(}) - - directive(public) type(void) ident(setAllocator)operator(()ident(ObjectAllocator) ident(allocator)operator(\)) operator({) - local_variable(this)operator(.)ident(allocator) operator(=) ident(allocator)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(allocate)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(allocate)operator(()operator(\)) operator({) - keyword(if) operator(()ident(superClass) operator(==) pre_constant(null)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't instantiate uninitialized class)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(allocator)operator(.)ident(allocate)operator(()ident(runtime)operator(,) local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(obj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(getRealClass)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong instance allocation)delimiter(")>operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - directive(public) ident(CallSite)type([]) ident(getBaseCallSites)operator(()operator(\)) operator({) - keyword(return) ident(baseCallSites)operator(;) - operator(}) - - directive(public) ident(CallSite)type([]) ident(getExtraCallSites)operator(()operator(\)) operator({) - keyword(return) ident(extraCallSites)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(CLASS)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isModule)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isClass)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isSingleton)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** boot_defclass - * Create an initial Object meta class before Module and Kernel dependencies have - * squirreled themselves together. - * - * @param runtime we need it - * @return a half-baked meta class for object - */) - directive(public) directive(static) ident(RubyClass) ident(createBootstrapClass)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(\)) operator({) - ident(RubyClass) ident(obj)operator(;) - - keyword(if) operator(()ident(superClass) operator(==) pre_constant(null) operator(\)) operator({) comment(// boot the Object class ) - ident(obj) operator(=) keyword(new) ident(RubyClass)operator(()ident(runtime)operator(\))operator(;) - ident(obj)operator(.)ident(marshal) operator(=) ident(DEFAULT_OBJECT_MARSHAL)operator(;) - operator(}) keyword(else) operator({) comment(// boot the Module and Class classes) - ident(obj) operator(=) keyword(new) ident(RubyClass)operator(()ident(runtime)operator(,) ident(superClass)operator(\))operator(;) - operator(}) - ident(obj)operator(.)ident(setAllocator)operator(()ident(allocator)operator(\))operator(;) - ident(obj)operator(.)ident(setBaseName)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - directive(private) ident(ObjectAllocator) ident(allocator)operator(;) comment(// the default allocator) - directive(protected) ident(ObjectMarshal) ident(marshal)operator(;) - directive(private) pre_type(Set)operator(<)ident(RubyClass)operator(>) ident(subclasses)operator(;) - - comment(/** separate path for MetaClass and IncludedModuleWrapper construction - * (rb_class_boot version for MetaClasses\) - * no marshal, allocator initialization and addSubclass(this\) here! - */) - directive(protected) ident(RubyClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(,) ident(objectSpace)operator(\))operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - local_variable(this)operator(.)ident(superClass) operator(=) ident(superClass)operator(;) comment(// this is the only case it might be null here (in MetaClass construction\)) - operator(}) - - comment(/** used by CLASS_ALLOCATOR (any Class' class will be a Class!\) - * also used to bootstrap Object class - */) - directive(protected) ident(RubyClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - ident(index) operator(=) ident(ClassIndex)operator(.)ident(CLASS)operator(;) - operator(}) - - comment(/** rb_class_boot (for plain Classes\) - * also used to bootstrap Module and Class classes - */) - directive(protected) ident(RubyClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClazz)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(\))operator(;) - ident(superClass) operator(=) ident(superClazz)operator(;) - ident(marshal) operator(=) ident(superClazz)operator(.)ident(marshal)operator(;) comment(// use parent's marshal) - ident(superClazz)operator(.)ident(addSubclass)operator(()local_variable(this)operator(\))operator(;) - - ident(infectBy)operator(()ident(superClass)operator(\))operator(;) - operator(}) - - comment(/** - * A constructor which allows passing in an array of supplementary call sites. - */) - directive(protected) ident(RubyClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClazz)operator(,) ident(CallSite)type([]) ident(extraCallSites)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(\))operator(;) - local_variable(this)operator(.)ident(superClass) operator(=) ident(superClazz)operator(;) - local_variable(this)operator(.)ident(marshal) operator(=) ident(superClazz)operator(.)ident(marshal)operator(;) comment(// use parent's marshal) - ident(superClazz)operator(.)ident(addSubclass)operator(()local_variable(this)operator(\))operator(;) - - local_variable(this)operator(.)ident(extraCallSites) operator(=) ident(extraCallSites)operator(;) - - ident(infectBy)operator(()ident(superClass)operator(\))operator(;) - operator(}) - - comment(/** - * Construct a new class with the given name scoped under Object (global\) - * and with Object as its immediate superclass. - * Corresponds to rb_class_new in MRI. - */) - directive(public) directive(static) ident(RubyClass) ident(newClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(\)) operator({) - keyword(if) operator(()ident(superClass) operator(==) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't make subclass of Class)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(superClass)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't make subclass of virtual class)delimiter(")>operator(\))operator(;) - keyword(return) keyword(new) ident(RubyClass)operator(()ident(runtime)operator(,) ident(superClass)operator(\))operator(;) - operator(}) - - comment(/** - * A variation on newClass that allow passing in an array of supplementary - * call sites to improve dynamic invocation. - */) - directive(public) directive(static) ident(RubyClass) ident(newClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(CallSite)type([]) ident(extraCallSites)operator(\)) operator({) - keyword(if) operator(()ident(superClass) operator(==) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't make subclass of Class)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(superClass)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't make subclass of virtual class)delimiter(")>operator(\))operator(;) - keyword(return) keyword(new) ident(RubyClass)operator(()ident(runtime)operator(,) ident(superClass)operator(,) ident(extraCallSites)operator(\))operator(;) - operator(}) - - comment(/** - * Construct a new class with the given name, allocator, parent class, - * and containing class. If setParent is true, the class's parent will be - * explicitly set to the provided parent (rather than the new class just - * being assigned to a constant in that parent\). - * Corresponds to rb_class_new/rb_define_class_id/rb_name_class/rb_set_class_path - * in MRI. - */) - directive(public) directive(static) ident(RubyClass) ident(newClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(,) pre_type(String) ident(name)operator(,) ident(ObjectAllocator) ident(allocator)operator(,) ident(RubyModule) ident(parent)operator(,) type(boolean) ident(setParent)operator(\)) operator({) - ident(RubyClass) ident(clazz) operator(=) ident(newClass)operator(()ident(runtime)operator(,) ident(superClass)operator(\))operator(;) - ident(clazz)operator(.)ident(setBaseName)operator(()ident(name)operator(\))operator(;) - ident(clazz)operator(.)ident(setAllocator)operator(()ident(allocator)operator(\))operator(;) - ident(clazz)operator(.)ident(makeMetaClass)operator(()ident(superClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(setParent)operator(\)) ident(clazz)operator(.)ident(setParent)operator(()ident(parent)operator(\))operator(;) - ident(parent)operator(.)ident(setConstant)operator(()ident(name)operator(,) ident(clazz)operator(\))operator(;) - ident(clazz)operator(.)ident(inherit)operator(()ident(superClass)operator(\))operator(;) - keyword(return) ident(clazz)operator(;) - operator(}) - - comment(/** - * A variation on newClass that allows passing in an array of supplementary - * call sites to improve dynamic invocation performance. - */) - directive(public) directive(static) ident(RubyClass) ident(newClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(superClass)operator(,) pre_type(String) ident(name)operator(,) ident(ObjectAllocator) ident(allocator)operator(,) ident(RubyModule) ident(parent)operator(,) type(boolean) ident(setParent)operator(,) ident(CallSite)type([]) ident(extraCallSites)operator(\)) operator({) - ident(RubyClass) ident(clazz) operator(=) ident(newClass)operator(()ident(runtime)operator(,) ident(superClass)operator(,) ident(extraCallSites)operator(\))operator(;) - ident(clazz)operator(.)ident(setBaseName)operator(()ident(name)operator(\))operator(;) - ident(clazz)operator(.)ident(setAllocator)operator(()ident(allocator)operator(\))operator(;) - ident(clazz)operator(.)ident(makeMetaClass)operator(()ident(superClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(setParent)operator(\)) ident(clazz)operator(.)ident(setParent)operator(()ident(parent)operator(\))operator(;) - ident(parent)operator(.)ident(setConstant)operator(()ident(name)operator(,) ident(clazz)operator(\))operator(;) - ident(clazz)operator(.)ident(inherit)operator(()ident(superClass)operator(\))operator(;) - keyword(return) ident(clazz)operator(;) - operator(}) - - comment(/** rb_make_metaclass - * - */) - annotation(@Override) - directive(public) ident(RubyClass) ident(makeMetaClass)operator(()ident(RubyClass) ident(superClass)operator(\)) operator({) - keyword(if) operator(()ident(isSingleton)operator(()operator(\))operator(\)) operator({) comment(// could be pulled down to RubyClass in future) - ident(MetaClass) ident(klass) operator(=) keyword(new) ident(MetaClass)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(superClass)operator(\))operator(;) comment(// rb_class_boot) - ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - ident(klass)operator(.)ident(setAttached)operator(()local_variable(this)operator(\))operator(;) - ident(klass)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - ident(klass)operator(.)ident(setSuperClass)operator(()ident(getSuperClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(klass)operator(;) - operator(}) keyword(else) operator({) - keyword(return) local_variable(super)operator(.)ident(makeMetaClass)operator(()ident(superClass)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) type(int) ident(methodIndex)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(invoke)operator(()ident(context)operator(,) ident(self)operator(,) ident(name)operator(,) ident(args)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(notVisibleAndNotMethodMissing)operator(()ident(DynamicMethod) ident(method)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(caller)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - keyword(return) operator(!)ident(method)operator(.)ident(isCallableFrom)operator(()ident(caller)operator(,) ident(callType)operator(\)) operator(&&) operator(!)ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(method_missing)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject)type([]) ident(args)operator(,) ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(assert) ident(args) operator(!=) pre_constant(null)operator(;) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(args)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(assert) ident(args) operator(!=) pre_constant(null)operator(;) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(args)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg)operator(,) ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(CallType) ident(callType)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(CallType) ident(callType)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject)type([]) ident(args)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - keyword(assert) ident(args) operator(!=) pre_constant(null)operator(;) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(args)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(assert) ident(args) operator(!=) pre_constant(null)operator(;) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(args)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(caller) operator(=) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(caller)operator(,) ident(callType)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finvoke)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(shouldCallMethodMissing)operator(()ident(method)operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(shouldCallMethodMissing)operator(()ident(DynamicMethod) ident(method)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(;) - operator(}) - directive(private) type(boolean) ident(shouldCallMethodMissing)operator(()ident(DynamicMethod) ident(method)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(caller)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(isUndefined)operator(()operator(\)) operator(||) ident(notVisibleAndNotMethodMissing)operator(()ident(method)operator(,) ident(name)operator(,) ident(caller)operator(,) ident(callType)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(invokeInherited)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(subclass)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(searchMethod)operator(()string<delimiter(")content(inherited)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) ident(self)operator(,) ident(method)operator(,) string<delimiter(")content(inherited)delimiter(")>operator(,) ident(subclass)operator(,) ident(context)operator(.)ident(getFrameSelf)operator(()operator(\))operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(self)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) string<delimiter(")content(inherited)delimiter(")>operator(,) ident(subclass)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - comment(/** rb_class_new_instance - * - */) - directive(public) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) ident(allocate)operator(()operator(\))operator(;) - ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - comment(// TODO: replace this with a smarter generated invoker that can handle 0-N args) - directive(public) directive(static) type(class) class(SpecificArityNew) directive(extends) ident(JavaMethod) operator({) - directive(public) ident(SpecificArityNew)operator(()ident(RubyModule) ident(implClass)operator(,) pre_type(Visibility) ident(visibility)operator(\)) operator({) - local_variable(super)operator(()ident(implClass)operator(,) ident(visibility)operator(\))operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(cls) operator(=) operator(()ident(RubyClass)operator(\))ident(self)operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(cls)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(cls)operator(.)ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(cls) operator(=) operator(()ident(RubyClass)operator(\))ident(self)operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(cls)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(cls)operator(.)ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(cls) operator(=) operator(()ident(RubyClass)operator(\))ident(self)operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(cls)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(cls)operator(.)ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(cls) operator(=) operator(()ident(RubyClass)operator(\))ident(self)operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(cls)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(cls)operator(.)ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(cls) operator(=) operator(()ident(RubyClass)operator(\))ident(self)operator(;) - ident(IRubyObject) ident(obj) operator(=) ident(cls)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(cls)operator(.)ident(baseCallSites)operator([)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - operator(}) - - comment(/** rb_class_initialize - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(superClass) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(already initialized class)delimiter(")>operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(superObject)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(superObject) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(superObject) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(checkInheritable)operator(()ident(superObject)operator(\))operator(;) - operator(}) - - ident(RubyClass) ident(superClazz) operator(=) operator(()ident(RubyClass)operator(\)) ident(superObject)operator(;) - - ident(superClass) operator(=) ident(superClazz)operator(;) - ident(allocator) operator(=) ident(superClazz)operator(.)ident(allocator)operator(;) - ident(makeMetaClass)operator(()ident(superClazz)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - - ident(marshal) operator(=) ident(superClazz)operator(.)ident(marshal)operator(;) - - ident(superClazz)operator(.)ident(addSubclass)operator(()local_variable(this)operator(\))operator(;) - - local_variable(super)operator(.)ident(initialize)operator(()ident(block)operator(\))operator(;) - - ident(inherit)operator(()ident(superClazz)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_class_init_copy - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\))operator({) - keyword(if) operator(()ident(superClass) operator(!=) pre_constant(null)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(already initialized class)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(original) keyword(instanceof) ident(MetaClass)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't copy singleton class)delimiter(")>operator(\))operator(;) - - local_variable(super)operator(.)ident(initialize_copy)operator(()ident(original)operator(\))operator(;) - ident(allocator) operator(=) operator(()operator(()ident(RubyClass)operator(\))ident(original)operator(\))operator(.)ident(allocator)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(// TODO: Someday, enable.) - comment(// @JRubyMethod(name = "subclasses", optional = 1\)) - directive(public) ident(IRubyObject) ident(subclasses)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(boolean) ident(recursive) operator(=) pre_constant(false)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyBoolean)operator(\)) operator({) - ident(recursive) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Boolean)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(subclasses)operator(()ident(recursive)operator(\))operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Collection) ident(subclasses)operator(()type(boolean) ident(includeDescendants)operator(\)) operator({) - keyword(if) operator(()ident(subclasses) operator(!=) pre_constant(null)operator(\)) operator({) - pre_type(Collection)operator(<)ident(RubyClass)operator(>) ident(mine) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(RubyClass)operator(>)operator(()ident(subclasses)operator(\))operator(;) - keyword(if) operator(()ident(includeDescendants)operator(\)) operator({) - keyword(for) operator(()ident(RubyClass) ident(i)operator(:) ident(subclasses)operator(\)) operator({) - ident(mine)operator(.)ident(addAll)operator(()ident(i)operator(.)ident(subclasses)operator(()ident(includeDescendants)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(mine)operator(;) - operator(}) keyword(else) operator({) - keyword(return) pre_type(Collections)operator(.)ident(EMPTY_LIST)operator(;) - operator(}) - operator(}) - - directive(public) directive(synchronized) type(void) ident(addSubclass)operator(()ident(RubyClass) ident(subclass)operator(\)) operator({) - keyword(if) operator(()ident(subclasses) operator(==) pre_constant(null)operator(\)) ident(subclasses) operator(=) keyword(new) ident(WeakHashSet)operator(<)ident(RubyClass)operator(>)operator(()operator(\))operator(;) - ident(subclasses)operator(.)ident(add)operator(()ident(subclass)operator(\))operator(;) - operator(}) - - directive(public) ident(Ruby) ident(getClassRuntime)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(getRealClass)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inherited)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(inherited)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_class_inherited (reversed semantics!\) - * - */) - directive(public) type(void) ident(inherit)operator(()ident(RubyClass) ident(superClazz)operator(\)) operator({) - keyword(if) operator(()ident(superClazz) operator(==) pre_constant(null)operator(\)) ident(superClazz) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - - ident(superClazz)operator(.)ident(invokeInherited)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(superClazz)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** Return the real super class of this class. - * - * rb_class_superclass - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(superclass)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(superclass)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyClass) ident(superClazz) operator(=) ident(superClass)operator(;) - - keyword(if) operator(()ident(superClazz) operator(==) pre_constant(null)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(uninitialized class)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(isSingleton)operator(()operator(\))operator(\)) ident(superClazz) operator(=) ident(metaClass)operator(;) - keyword(while) operator(()ident(superClazz) operator(!=) pre_constant(null) operator(&&) ident(superClazz)operator(.)ident(isIncluded)operator(()operator(\))operator(\)) ident(superClazz) operator(=) ident(superClazz)operator(.)ident(superClass)operator(;) - - keyword(return) ident(superClazz) operator(!=) pre_constant(null) operator(?) ident(superClazz) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_check_inheritable - * - */) - directive(public) directive(static) type(void) ident(checkInheritable)operator(()ident(IRubyObject) ident(superClass)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(superClass) keyword(instanceof) ident(RubyClass)operator(\))operator(\)) operator({) - keyword(throw) ident(superClass)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(superclass must be a Class ()delimiter(")> operator(+) ident(superClass)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( given\))delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(()operator(()ident(RubyClass)operator(\))ident(superClass)operator(\))operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(superClass)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't make subclass of virtual class)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(final) ident(ObjectMarshal) ident(getMarshal)operator(()operator(\)) operator({) - keyword(return) ident(marshal)operator(;) - operator(}) - - directive(public) directive(final) type(void) ident(setMarshal)operator(()ident(ObjectMarshal) ident(marshal)operator(\)) operator({) - local_variable(this)operator(.)ident(marshal) operator(=) ident(marshal)operator(;) - operator(}) - - directive(public) directive(final) type(void) ident(marshal)operator(()pre_type(Object) ident(obj)operator(,) ident(MarshalStream) ident(marshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(getMarshal)operator(()operator(\))operator(.)ident(marshalTo)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(obj)operator(,) local_variable(this)operator(,) ident(marshalStream)operator(\))operator(;) - operator(}) - - directive(public) directive(final) pre_type(Object) ident(unmarshal)operator(()ident(UnmarshalStream) ident(unmarshalStream)operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) ident(getMarshal)operator(()operator(\))operator(.)ident(unmarshalFrom)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) ident(unmarshalStream)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyClass) ident(clazz)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(clazz)operator(\))operator(;) - ident(output)operator(.)ident(writeString)operator(()ident(MarshalStream)operator(.)ident(getPathFromClass)operator(()ident(clazz)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - pre_type(String) ident(name) operator(=) ident(RubyString)operator(.)ident(byteListToString)operator(()ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(\))operator(;) - ident(RubyClass) ident(result) operator(=) ident(UnmarshalStream)operator(.)ident(getClassFromPath)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(protected) directive(static) directive(final) ident(ObjectMarshal) ident(DEFAULT_OBJECT_MARSHAL) operator(=) keyword(new) ident(ObjectMarshal)operator(()operator(\)) operator({) - directive(public) type(void) ident(marshalTo)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Object) ident(obj)operator(,) ident(RubyClass) ident(type)operator(,) - ident(MarshalStream) ident(marshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(IRubyObject) ident(object) operator(=) operator(()ident(IRubyObject)operator(\))ident(obj)operator(;) - - ident(marshalStream)operator(.)ident(registerLinkTarget)operator(()ident(object)operator(\))operator(;) - ident(marshalStream)operator(.)ident(dumpVariables)operator(()ident(object)operator(.)ident(getVariableList)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(unmarshalFrom)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(,) - ident(UnmarshalStream) ident(unmarshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(IRubyObject) ident(result) operator(=) ident(type)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(defaultVariablesUnmarshal)operator(()ident(result)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - operator(})operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.File)operator(;) -keyword(import) include(java.net.MalformedURLException)operator(;) -keyword(import) include(java.net.URL)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -directive(public) type(class) class(RubyClassPathVariable) directive(extends) ident(RubyObject) operator({) - directive(public) directive(static) type(void) ident(createClassPathVariable)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClassPathVariable) ident(self) operator(=) keyword(new) ident(RubyClassPathVariable)operator(()ident(runtime)operator(\))operator(;) - ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(.)ident(extend_object)operator(()ident(self)operator(\))operator(;) - ident(runtime)operator(.)ident(defineReadonlyVariable)operator(()string<delimiter(")content($CLASSPATH)delimiter(")>operator(,) ident(self)operator(\))operator(;) - - ident(self)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyClassPathVariable)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyClassPathVariable)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(append)delimiter(")>operator(,) string<delimiter(")content(<<)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(append)operator(()ident(IRubyObject) ident(obj)operator(\)) directive(throws) exception(Exception) operator({) - pre_type(String) ident(ss) operator(=) ident(obj)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - pre_type(URL) ident(url) operator(=) ident(getURL)operator(()ident(ss)operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(.)ident(addURL)operator(()ident(url)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) pre_type(URL) ident(getURL)operator(()pre_type(String) ident(target)operator(\)) directive(throws) exception(MalformedURLException) operator({) - keyword(if)operator(()ident(target)operator(.)ident(indexOf)operator(()string<delimiter(")content(://)delimiter(")>operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) keyword(new) pre_type(File)operator(()ident(target)operator(\))operator(.)ident(toURI)operator(()operator(\))operator(.)ident(toURL)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) keyword(new) pre_type(URL)operator(()ident(target)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(size)delimiter(")>operator(,) string<delimiter(")content(length)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(.)ident(getURLs)operator(()operator(\))operator(.)ident(length)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(Block) ident(block)operator(\)) operator({) - pre_type(URL)type([]) ident(urls) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(.)ident(getURLs)operator(()operator(\))operator(;) - ident(ThreadContext) ident(ctx) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(,)ident(j)operator(=)ident(urls)operator(.)ident(length)operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(urls)operator([)ident(i)operator(])operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(to_a)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(to_a)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(;) - operator(}) -operator(})comment(// RubyClassPathVariable) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2006 Thomas E Enebo <enebo@acm.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** Implementation of the Comparable module. - * - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Comparable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyComparable) operator({) - directive(public) directive(static) ident(RubyModule) ident(createComparable)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(comparableModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Comparable)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setComparable)operator(()ident(comparableModule)operator(\))operator(;) - - ident(comparableModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyComparable)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(comparableModule)operator(;) - operator(}) - - comment(/* ================ - * Utility Methods - * ================ - */) - - comment(/** rb_cmpint - * - */) - directive(public) directive(static) type(int) ident(cmpint)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(val)operator(,) ident(IRubyObject) ident(a)operator(,) ident(IRubyObject) ident(b)operator(\)) operator({) - keyword(if) operator(()ident(val)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(cmperr)operator(()ident(a)operator(,) ident(b)operator(\))operator(;) - keyword(if) operator(()ident(val) keyword(instanceof) ident(RubyFixnum)operator(\)) keyword(return) ident(RubyNumeric)operator(.)ident(fix2int)operator(()operator(()ident(RubyFixnum)operator(\)) ident(val)operator(\))operator(;) - keyword(if) operator(()ident(val) keyword(instanceof) ident(RubyBignum)operator(\)) keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(val)operator(\))operator(.)ident(getValue)operator(()operator(\))operator(.)ident(signum)operator(()operator(\)) operator(==) operator(-)integer(1) operator(?) integer(1) operator(:) operator(-)integer(1)operator(;) - - ident(RubyFixnum) ident(zero) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(val)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_GT)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(return) integer(1)operator(;) - keyword(if) operator(()ident(val)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(return) operator(-)integer(1)operator(;) - - keyword(return) integer(0)operator(;) - operator(}) - - comment(/** rb_cmperr - * - */) - directive(public) directive(static) ident(IRubyObject) ident(cmperr)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(target)operator(;) - keyword(if) operator(()ident(other)operator(.)ident(isImmediate)operator(()operator(\)) operator(||) operator(!)operator(()ident(other)operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(other)operator(.)ident(isTrue)operator(()operator(\)) operator(||) ident(other) operator(==) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(\))operator(\)) operator({) - ident(target) operator(=) ident(other)operator(.)ident(inspect)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(target) operator(=) ident(other)operator(.)ident(getType)operator(()operator(\))operator(;) - operator(}) - - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(comparison of )delimiter(")> operator(+) ident(recv)operator(.)ident(getType)operator(()operator(\)) operator(+) string<delimiter(")content( with )delimiter(")> operator(+) ident(target) operator(+) string<delimiter(")content( failed)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/* ================ - * Module Methods - * ================ - */) - - comment(/** cmp_equal (cmp_eq inlined here\) - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(recv) operator(==) ident(other)operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(IRubyObject) ident(result) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(runtime)operator(,) ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(recv)operator(,) ident(other)operator(\)) operator(==) integer(0)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(e)operator(.)ident(getException)operator(()operator(\))operator(.)ident(kind_of_p)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getStandardError)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(e)operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** cmp_gt - * - */) - comment(// <=> may return nil in many circumstances, e.g. 3 <=> NaN ) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(cmperr)operator(()ident(recv)operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(recv)operator(,) ident(other)operator(\)) operator(>) integer(0)operator(\))operator(;) - operator(}) - - comment(/** cmp_ge - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(cmperr)operator(()ident(recv)operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(recv)operator(,) ident(other)operator(\)) operator(>=) integer(0)operator(\))operator(;) - operator(}) - - comment(/** cmp_lt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(cmperr)operator(()ident(recv)operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(recv)operator(,) ident(other)operator(\)) operator(<) integer(0)operator(\))operator(;) - operator(}) - - comment(/** cmp_le - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(cmperr)operator(()ident(recv)operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(recv)operator(,) ident(other)operator(\)) operator(<=) integer(0)operator(\))operator(;) - operator(}) - - comment(/** cmp_between - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(between?)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(between_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(first)operator(,) ident(IRubyObject) ident(second)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(op_lt)operator(()ident(context)operator(,) ident(recv)operator(,) ident(first)operator(\))operator(.)ident(isFalse)operator(()operator(\)) operator(&&) ident(op_gt)operator(()ident(context)operator(,) ident(recv)operator(,) ident(second)operator(\))operator(.)ident(isFalse)operator(()operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.util.Numeric.f_abs)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_abs2)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_add)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_arg)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_conjugate)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_denominator)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_div)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_divmod)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_equal_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_exact_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_expt)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_gt_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_inspect)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_lcm)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_mul)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_negate)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_negative_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_numerator)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_one_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_polar)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_quo)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_scalar_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_sub)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_f)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_i)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_r)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_s)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_xor)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_zero_p)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.Numeric)operator(;) - -comment(/** - * 1.9 complex.c as of revision: 18876 - */) - -annotation(@JRubyClass)operator(()ident(name) operator(=) string<delimiter(")content(Complex)delimiter(")>operator(,) ident(parent) operator(=) string<delimiter(")content(Numeric)delimiter(")>operator(\)) -directive(public) type(class) class(RubyComplex) directive(extends) ident(RubyNumeric) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createComplexClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(complexc) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Complex)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(,) ident(COMPLEX_ALLOCATOR)operator(\))operator(;) comment(// because one can Complex.send(:allocate\)) - ident(runtime)operator(.)ident(setComplex)operator(()ident(complexc)operator(\))operator(;) - - ident(complexc)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(COMPLEX)operator(;) - ident(complexc)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyComplex)operator(;) - operator(}) - operator(})operator(;) - - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(complexc)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(private_class_method)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(allocate)delimiter(")>operator(\))operator(\))operator(;) - - ident(complexc)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyComplex)operator(.)ident(class)operator(\))operator(;) - - pre_type(String)type([])ident(undefined) operator(=) operator({)string<delimiter(")content(<)delimiter(")>operator(,) string<delimiter(")content(<=)delimiter(")>operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) string<delimiter(")content(>)delimiter(")>operator(,) string<delimiter(")content(>=)delimiter(")>operator(,) string<delimiter(")content(between?)delimiter(")>operator(,) string<delimiter(")content(divmod)delimiter(")>operator(,) - string<delimiter(")content(floor)delimiter(")>operator(,) string<delimiter(")content(ceil)delimiter(")>operator(,) string<delimiter(")content(modulo)delimiter(")>operator(,) string<delimiter(")content(round)delimiter(")>operator(,) string<delimiter(")content(step)delimiter(")>operator(,) string<delimiter(")content(truncate)delimiter(")>operator(})operator(;) - - keyword(for) operator(()pre_type(String) ident(undef) operator(:) ident(undefined)operator(\)) operator({) - ident(complexc)operator(.)ident(undefineMethod)operator(()ident(undef)operator(\))operator(;) - operator(}) - - ident(complexc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(I)delimiter(")>operator(,) ident(RubyComplex)operator(.)ident(newComplexConvert)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - - keyword(return) ident(complexc)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(COMPLEX_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(})operator(;) - - comment(/** internal - * - */) - directive(private) ident(RubyComplex)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(real)operator(,) ident(IRubyObject) ident(image)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\))ident(clazz)operator(\))operator(;) - local_variable(this)operator(.)ident(real) operator(=) ident(real)operator(;) - local_variable(this)operator(.)ident(image) operator(=) ident(image)operator(;) - operator(}) - - comment(/** rb_complex_raw - * - */) - directive(static) ident(RubyComplex) ident(newComplexRaw)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(x)operator(,) ident(RubyObject) ident(y)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getComplex)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** rb_complex_raw1 - * - */) - directive(static) ident(RubyComplex) ident(newComplexRaw)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getComplex)operator(()operator(\))operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_complex_new1 - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newComplexCanonicalize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newComplexCanonicalize)operator(()ident(context)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_complex_new - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newComplexCanonicalize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** rb_complex_polar - * - */) - directive(static) ident(IRubyObject) ident(newComplexPolar)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(return) ident(polar)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_complex_new1 - * - */) - directive(static) ident(IRubyObject) ident(newComplex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** f_complex_new2 - * - */) - directive(static) ident(IRubyObject) ident(newComplex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) operator(!)operator(()ident(x) keyword(instanceof) ident(RubyComplex)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_complex_new_bang2 - * - */) - directive(static) ident(RubyComplex) ident(newComplexBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyComplex) operator(&&) ident(y) keyword(instanceof) ident(RubyComplex)operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_complex_new_bang1 - * - */) - directive(public) directive(static) ident(RubyComplex) ident(newComplexBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyComplex)operator(;) - keyword(return) ident(newComplexBang)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(real)operator(;) - directive(private) ident(IRubyObject) ident(image)operator(;) - - ident(IRubyObject) ident(getImage)operator(()operator(\)) operator({) - keyword(return) ident(image)operator(;) - operator(}) - - ident(IRubyObject) ident(getReal)operator(()operator(\)) operator({) - keyword(return) ident(real)operator(;) - operator(}) - - comment(/** m_cos - * - */) - directive(private) directive(static) ident(IRubyObject) ident(m_cos)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(x)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(return) ident(RubyMath)operator(.)ident(cos)operator(()ident(x)operator(,) ident(x)operator(\))operator(;) - ident(RubyComplex) ident(complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(x)operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(RubyMath)operator(.)ident(cos)operator(()ident(x)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(,) ident(RubyMath)operator(.)ident(cosh)operator(()ident(x)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(RubyMath)operator(.)ident(sin)operator(()ident(x)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(\))operator(,) ident(RubyMath)operator(.)ident(sinh)operator(()ident(x)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** m_sin - * - */) - directive(private) directive(static) ident(IRubyObject) ident(m_sin)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(x)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(return) ident(RubyMath)operator(.)ident(sin)operator(()ident(x)operator(,) ident(x)operator(\))operator(;) - ident(RubyComplex) ident(complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(x)operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(RubyMath)operator(.)ident(sin)operator(()ident(x)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(,) ident(RubyMath)operator(.)ident(cosh)operator(()ident(x)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(RubyMath)operator(.)ident(cos)operator(()ident(x)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(,) ident(RubyMath)operator(.)ident(sinh)operator(()ident(x)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** m_sqrt - * - */) - directive(private) directive(static) ident(IRubyObject) ident(m_sqrt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(x)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)ident(f_negative_p)operator(()ident(context)operator(,) ident(x)operator(\))operator(\)) keyword(return) ident(RubyMath)operator(.)ident(sqrt)operator(()ident(x)operator(,) ident(x)operator(\))operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) - ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) - ident(RubyMath)operator(.)ident(sqrt)operator(()ident(x)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(x)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyComplex) ident(complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(x)operator(;) - keyword(if) operator(()ident(f_negative_p)operator(()ident(context)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(\)) operator({) - keyword(return) ident(f_conjugate)operator(()ident(context)operator(,) ident(m_sqrt)operator(()ident(context)operator(,) ident(f_conjugate)operator(()ident(context)operator(,) ident(x)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(a) operator(=) ident(f_abs)operator(()ident(context)operator(,) ident(x)operator(\))operator(;) - ident(IRubyObject) ident(two) operator(=) ident(RubyFixnum)operator(.)ident(two)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) - ident(RubyMath)operator(.)ident(sqrt)operator(()ident(x)operator(,) ident(f_div)operator(()ident(context)operator(,) ident(f_add)operator(()ident(context)operator(,) ident(a)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(,) ident(two)operator(\))operator(\))operator(,) - ident(RubyMath)operator(.)ident(sqrt)operator(()ident(x)operator(,) ident(f_div)operator(()ident(context)operator(,) ident(f_sub)operator(()ident(context)operator(,) ident(a)operator(,) ident(complex)operator(.)ident(real)operator(\))operator(,) ident(two)operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** nucomp_s_new_bang - * - */) - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) keyword(return) ident(newInstanceBang)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(newInstanceBang)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new!)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(real)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(real) keyword(instanceof) ident(RubyNumeric)operator(\))operator(\)) ident(real) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(recv)operator(,) ident(real)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new!)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(real)operator(,) ident(IRubyObject) ident(image)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(real) keyword(instanceof) ident(RubyNumeric)operator(\))operator(\)) ident(real) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(image) keyword(instanceof) ident(RubyNumeric)operator(\))operator(\)) ident(image) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(image)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(recv)operator(,) ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) - - comment(/** nucomp_real_check (might go to bimorphic\) - * - */) - directive(private) directive(static) type(void) ident(realCheck)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(num)operator(\)) operator({) - keyword(switch) operator(()ident(num)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - keyword(break)operator(;) - keyword(default)operator(:) - keyword(if) operator(()operator(!)operator(()ident(num) keyword(instanceof) ident(RubyNumeric) operator(\)) operator(||) operator(!)ident(f_scalar_p)operator(()ident(context)operator(,) ident(num)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(not a real)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** nucomp_s_canonicalize_internal - * - */) - directive(private) directive(static) directive(final) type(boolean) ident(CL_CANNON) operator(=) pre_constant(true)operator(;) - directive(private) directive(static) ident(IRubyObject) ident(canonicalizeInternal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(real)operator(,) ident(IRubyObject) ident(image)operator(\)) operator({) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(image)operator(\)) operator(&&) - operator(()operator(()ident(RubyModule)operator(\))ident(clazz)operator(\))operator(.)ident(fastHasConstant)operator(()string<delimiter(")content(Unify)delimiter(")>operator(\)) operator(&&) - operator(()operator(!)ident(CL_CANNON) operator(||) - operator(()operator(!)operator(()ident(real) keyword(instanceof) ident(RubyFloat)operator(\)) operator(&&) - operator(!)operator(()ident(image) keyword(instanceof) ident(RubyFloat)operator(\))operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(real)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(real)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(&&) - ident(f_scalar_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(real)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(RubyComplex) ident(complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(image)operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) - ident(f_sub)operator(()ident(context)operator(,) ident(real)operator(,) ident(complex)operator(.)ident(image)operator(\))operator(,) - ident(f_add)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) ident(complex)operator(.)ident(real)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(f_scalar_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(RubyComplex) ident(complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(real)operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) - ident(complex)operator(.)ident(real)operator(,) - ident(f_add)operator(()ident(context)operator(,) ident(complex)operator(.)ident(image)operator(,) ident(image)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyComplex) ident(complex1) operator(=) operator(()ident(RubyComplex)operator(\))ident(real)operator(;) - ident(RubyComplex) ident(complex2) operator(=) operator(()ident(RubyComplex)operator(\))ident(image)operator(;) - keyword(return) keyword(new) ident(RubyComplex)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) - ident(f_sub)operator(()ident(context)operator(,) ident(complex1)operator(.)ident(real)operator(,) ident(complex2)operator(.)ident(image)operator(\))operator(,) - ident(f_add)operator(()ident(context)operator(,) ident(complex1)operator(.)ident(image)operator(,) ident(complex2)operator(.)ident(real)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** nucomp_s_new - * - */) - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) keyword(return) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content(rect)delimiter(")>operator(,) string<delimiter(")content(rectangular)delimiter(")>operator(})operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(real)operator(\)) operator({) - ident(realCheck)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(recv)operator(,) ident(real)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content(rect)delimiter(")>operator(,) string<delimiter(")content(rectangular)delimiter(")>operator(})operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(real)operator(,) ident(IRubyObject) ident(image)operator(\)) operator({) - ident(realCheck)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - ident(realCheck)operator(()ident(context)operator(,) ident(image)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(recv)operator(,) ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) - - comment(/** f_complex_polar - * - */) - directive(private) directive(static) ident(IRubyObject) ident(f_complex_polar)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) operator(!)operator(()ident(x) keyword(instanceof) ident(RubyComplex)operator(\)) operator(&&) operator(!)operator(()ident(y) keyword(instanceof) ident(RubyComplex)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(x)operator(,) ident(m_cos)operator(()ident(context)operator(,) ident(y)operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(x)operator(,) ident(m_sin)operator(()ident(context)operator(,) ident(y)operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_s_polar - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(polar)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(polar)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(abs)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(f_complex_polar)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(abs)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - comment(/** rb_Complex1 - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newComplexConvert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newComplexConvert)operator(()ident(context)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_Complex/rb_Complex2 - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newComplexConvert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(return) ident(convert)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** nucomp_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(IRubyObject) ident(nil) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(nil)operator(,) ident(nil)operator(\))operator(;) - operator(}) - - comment(/** nucomp_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(\)) operator({) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(,) ident(IRubyObject) ident(a2)operator(\)) operator({) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(convertCommon)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(,) ident(IRubyObject) ident(a2)operator(\)) operator({) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backref) operator(=) ident(frame)operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backref) operator(!=) pre_constant(null) operator(&&) ident(backref) keyword(instanceof) ident(RubyMatchData)operator(\)) operator(()operator(()ident(RubyMatchData)operator(\))ident(backref)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyString)operator(\)) ident(a1) operator(=) ident(str_to_c_strict)operator(()ident(context)operator(,) ident(a1)operator(\))operator(;) - keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyString)operator(\)) ident(a2) operator(=) ident(str_to_c_strict)operator(()ident(context)operator(,) ident(a2)operator(\))operator(;) - - ident(frame)operator(.)ident(setBackRef)operator(()ident(backref)operator(\))operator(;) - - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(a1Complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(a1)operator(;) - keyword(if) operator(()operator(!)operator(()ident(a1Complex)operator(.)ident(image) keyword(instanceof) ident(RubyFloat)operator(\)) operator(&&) ident(f_zero_p)operator(()ident(context)operator(,) ident(a1Complex)operator(.)ident(image)operator(\))operator(\)) operator({) - ident(a1) operator(=) ident(a1Complex)operator(.)ident(real)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(a2Complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(a2)operator(;) - keyword(if) operator(()operator(!)operator(()ident(a2Complex)operator(.)ident(image) keyword(instanceof) ident(RubyFloat)operator(\)) operator(&&) ident(f_zero_p)operator(()ident(context)operator(,) ident(a2Complex)operator(.)ident(image)operator(\))operator(\)) operator({) - ident(a2) operator(=) ident(a2Complex)operator(.)ident(real)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - keyword(if) operator(()ident(a2)operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(f_zero_p)operator(()ident(context)operator(,) ident(a2)operator(\))operator(\)) keyword(return) ident(a1)operator(;) - operator(}) - keyword(return) ident(a2)operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(\)) operator(:) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - comment(/** nucomp_real - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(real)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(real)operator(()operator(\)) operator({) - keyword(return) ident(real)operator(;) - operator(}) - - comment(/** nucomp_image - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(image)delimiter(")>operator(,) string<delimiter(")content(imag)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(image)operator(()operator(\)) operator({) - keyword(return) ident(image)operator(;) - operator(}) - - comment(/** nucomp_add - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_add)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_add)operator(()ident(context)operator(,) ident(real)operator(,) ident(otherComplex)operator(.)ident(real)operator(\))operator(,) - ident(f_add)operator(()ident(context)operator(,) ident(image)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(f_add)operator(()ident(context)operator(,) ident(real)operator(,) ident(other)operator(\))operator(,) ident(image)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_sub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_sub)operator(()ident(context)operator(,) ident(real)operator(,) ident(otherComplex)operator(.)ident(real)operator(\))operator(,) - ident(f_sub)operator(()ident(context)operator(,) ident(image)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(f_sub)operator(()ident(context)operator(,) ident(real)operator(,) ident(other)operator(\))operator(,) ident(image)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_mul - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - ident(IRubyObject) ident(realp) operator(=) ident(f_sub)operator(()ident(context)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(real)operator(,) ident(otherComplex)operator(.)ident(real)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(image)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(imagep) operator(=) ident(f_add)operator(()ident(context)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(real)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(image)operator(,) ident(otherComplex)operator(.)ident(real)operator(\))operator(\))operator(;) - - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(realp)operator(,) ident(imagep)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(real)operator(,) ident(other)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(image)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_div - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(/)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(real) keyword(instanceof) ident(RubyFloat) operator(||) ident(image) keyword(instanceof) ident(RubyFloat) operator(||) - ident(otherComplex)operator(.)ident(real) keyword(instanceof) ident(RubyFloat) operator(||) ident(otherComplex)operator(.)ident(image) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(IRubyObject) ident(magn) operator(=) ident(RubyMath)operator(.)ident(hypot)operator(()local_variable(this)operator(,) ident(otherComplex)operator(.)ident(real)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(;) - ident(IRubyObject) ident(tmp) operator(=) ident(newComplexBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_quo)operator(()ident(context)operator(,) ident(otherComplex)operator(.)ident(real)operator(,) ident(magn)operator(\))operator(,) - ident(f_quo)operator(()ident(context)operator(,) ident(otherComplex)operator(.)ident(image)operator(,) ident(magn)operator(\))operator(\))operator(;) - keyword(return) ident(f_quo)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(f_conjugate)operator(()ident(context)operator(,) ident(tmp)operator(\))operator(\))operator(,) ident(magn)operator(\))operator(;) - operator(}) - keyword(return) ident(f_quo)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(f_conjugate)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(,) ident(f_abs2)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_quo)operator(()ident(context)operator(,) ident(real)operator(,) ident(other)operator(\))operator(,) - ident(f_quo)operator(()ident(context)operator(,) ident(image)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_fdiv / nucomp_quo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(fdiv)delimiter(")>operator(,) string<delimiter(")content(quo)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(fdiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(complex) operator(=) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_to_f)operator(()ident(context)operator(,) ident(real)operator(\))operator(,) - ident(f_to_f)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(;) - - keyword(return) ident(f_div)operator(()ident(context)operator(,) ident(complex)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_expt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(**)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_expt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(\)) operator({) - keyword(return) ident(newComplexBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyRational) operator(&&) ident(f_one_p)operator(()ident(context)operator(,) ident(f_denominator)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(\)) operator({) - ident(other) operator(=) ident(f_numerator)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(f_polar)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(r) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - ident(IRubyObject) ident(theta) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(;) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - ident(IRubyObject) ident(nr) operator(=) ident(RubyMath)operator(.)ident(exp)operator(()local_variable(this)operator(,) ident(f_sub)operator(()ident(context)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(otherComplex)operator(.)ident(real)operator(,) ident(RubyMath)operator(.)ident(log)operator(()local_variable(this)operator(,) ident(r)operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(otherComplex)operator(.)ident(image)operator(,) ident(theta)operator(\))operator(\))operator(\))operator(;) - ident(IRubyObject) ident(ntheta) operator(=) ident(f_add)operator(()ident(context)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(theta)operator(,) ident(otherComplex)operator(.)ident(real)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(otherComplex)operator(.)ident(image)operator(,) ident(RubyMath)operator(.)ident(log)operator(()local_variable(this)operator(,) ident(r)operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(polar)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(nr)operator(,) ident(ntheta)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyInteger)operator(\)) operator({) - ident(IRubyObject) ident(one) operator(=) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(f_gt_p)operator(()ident(context)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(x) operator(=) local_variable(this)operator(;) - ident(IRubyObject) ident(z) operator(=) ident(x)operator(;) - ident(IRubyObject) ident(n) operator(=) ident(f_sub)operator(()ident(context)operator(,) ident(other)operator(,) ident(one)operator(\))operator(;) - - ident(IRubyObject) ident(two) operator(=) ident(RubyFixnum)operator(.)ident(two)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(while) operator(()operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(n)operator(\))operator(\)) operator({) - - ident(RubyArray) ident(a) operator(=) ident(f_divmod)operator(()ident(context)operator(,) ident(n)operator(,) ident(two)operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - - keyword(while) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(\))operator(\)) operator({) - ident(RubyComplex) ident(xComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(x)operator(;) - ident(x) operator(=) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_sub)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(xComplex)operator(.)ident(real)operator(,) ident(xComplex)operator(.)ident(real)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(xComplex)operator(.)ident(image)operator(,) ident(xComplex)operator(.)ident(image)operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(two)operator(,) ident(xComplex)operator(.)ident(real)operator(\))operator(,) ident(xComplex)operator(.)ident(image)operator(\))operator(\))operator(;) - - ident(n) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - ident(a) operator(=) ident(f_divmod)operator(()ident(context)operator(,) ident(n)operator(,) ident(two)operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - operator(}) - ident(z) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(z)operator(,) ident(x)operator(\))operator(;) - ident(n) operator(=) ident(f_sub)operator(()ident(context)operator(,) ident(n)operator(,) ident(one)operator(\))operator(;) - operator(}) - keyword(return) ident(z)operator(;) - operator(}) - keyword(return) ident(f_expt)operator(()ident(context)operator(,) ident(f_div)operator(()ident(context)operator(,) ident(f_to_r)operator(()ident(context)operator(,) ident(one)operator(\))operator(,) local_variable(this)operator(\))operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(f_polar)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(r) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - ident(IRubyObject) ident(theta) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(;) - keyword(return) ident(f_complex_polar)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(f_expt)operator(()ident(context)operator(,) ident(r)operator(,) ident(other)operator(\))operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(theta)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nucomp_equal_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(otherComplex) operator(=) operator(()ident(RubyComplex)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(f_equal_p)operator(()ident(context)operator(,) ident(real)operator(,) ident(otherComplex)operator(.)ident(real)operator(\)) operator(&&) ident(f_equal_p)operator(()ident(context)operator(,) ident(image)operator(,) ident(otherComplex)operator(.)ident(image)operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(f_equal_p)operator(()ident(context)operator(,) ident(real)operator(,) ident(other)operator(\)) operator(&&) ident(f_zero_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(f_equal_p)operator(()ident(context)operator(,) ident(other)operator(,) local_variable(this)operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_coerce - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(coerce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyNumeric) operator(&&) ident(f_scalar_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(newComplexBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(other)operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( can't be coerced into )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_abs - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(abs)delimiter(")>operator(,) string<delimiter(")content(magnitude)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(abs)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyMath)operator(.)ident(hypot)operator(()local_variable(this)operator(,) ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) - - comment(/** nucomp_abs2 - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs2)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(abs2)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_add)operator(()ident(context)operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(real)operator(,) ident(real)operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) ident(image)operator(,) ident(image)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_arg - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(arg)delimiter(")>operator(,) string<delimiter(")content(angle)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(arg)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyMath)operator(.)ident(atan2)operator(()local_variable(this)operator(,) ident(image)operator(,) ident(real)operator(\))operator(;) - operator(}) - - comment(/** nucomp_polar - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(polar)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(polar)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(f_abs)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(f_arg)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_conjugate - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(conjugate)delimiter(")>operator(,) string<delimiter(")content(conj)delimiter(")>operator(,) string<delimiter(")content(~)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(conjugate)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(real)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_real_p - * - */) - comment(//@JRubyMethod(name = "real?"\)) - directive(public) ident(IRubyObject) ident(real_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_complex_p - * - */) - comment(// @JRubyMethod(name = "complex?"\)) - directive(public) ident(IRubyObject) ident(complex_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_exact_p - * - */) - comment(// @JRubyMethod(name = "exact?"\)) - directive(public) ident(IRubyObject) ident(exact_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) operator(()ident(f_exact_p)operator(()ident(context)operator(,) ident(real)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(&&) ident(f_exact_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_exact_p - * - */) - comment(// @JRubyMethod(name = "inexact?"\)) - directive(public) ident(IRubyObject) ident(inexact_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(exact_p)operator(()ident(context)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_denominator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(denominator)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(demoninator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_lcm)operator(()ident(context)operator(,) ident(f_denominator)operator(()ident(context)operator(,) ident(real)operator(\))operator(,) ident(f_denominator)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_numerator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(numerator)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(numerator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(IRubyObject) ident(cd) operator(=) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(denominator)delimiter(")>operator(\))operator(;) - keyword(return) ident(newComplex)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) - ident(f_numerator)operator(()ident(context)operator(,) ident(real)operator(\))operator(,) - ident(f_div)operator(()ident(context)operator(,) ident(cd)operator(,) ident(f_denominator)operator(()ident(context)operator(,) ident(real)operator(\))operator(\))operator(\))operator(,) - ident(f_mul)operator(()ident(context)operator(,) - ident(f_numerator)operator(()ident(context)operator(,) ident(image)operator(\))operator(,) - ident(f_div)operator(()ident(context)operator(,) ident(cd)operator(,) ident(f_denominator)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** nucomp_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(hash)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_xor)operator(()ident(context)operator(,) ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) - - comment(/** f_signbit - * - */) - directive(private) directive(static) type(boolean) ident(signbit)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(if) operator(()ident(x) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) pre_type(Double)operator(.)ident(doubleToLongBits)operator(()operator(()operator(()ident(RubyFloat)operator(\))ident(x)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\)) operator(<) integer(0)operator(;) - operator(}) - keyword(return) ident(f_negative_p)operator(()ident(context)operator(,) ident(x)operator(\))operator(;) - operator(}) - - comment(/** f_tpositive_p - * - */) - directive(private) directive(static) type(boolean) ident(tpositive_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) operator(!)ident(signbit)operator(()ident(context)operator(,) ident(x)operator(\))operator(;) - operator(}) - - comment(/** nucomp_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(boolean) ident(impos) operator(=) ident(tpositive_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(f_to_s)operator(()ident(context)operator(,) ident(real)operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()ident(impos) operator(?) operator(()type(byte)operator(\))string<delimiter(')content(+)delimiter(')> operator(:) operator(()type(byte)operator(\))string<delimiter(')content(-)delimiter(')>operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()ident(f_to_s)operator(()ident(context)operator(,) ident(f_abs)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(i)delimiter(')>operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** nucomp_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(boolean) ident(impos) operator(=) ident(tpositive_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(;) - ident(RubyString) ident(str) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(()delimiter(')>operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()ident(f_inspect)operator(()ident(context)operator(,) ident(real)operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()ident(impos) operator(?) operator(()type(byte)operator(\))string<delimiter(')content(+)delimiter(')> operator(:) operator(()type(byte)operator(\))string<delimiter(')content(-)delimiter(')>operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()ident(f_inspect)operator(()ident(context)operator(,) ident(f_abs)operator(()ident(context)operator(,) ident(image)operator(\))operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(i)delimiter(')>operator(\))operator(;) - ident(str)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(\))delimiter(')>operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** nucomp_marshal_dump - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(marshal_dump)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(marshal_dump)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(real)operator(,) ident(image)operator(\))operator(;) - operator(}) - - comment(/** nucomp_marshal_load - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(marshal_load)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(marshal_load)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(arg)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(real) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(>) integer(0) operator(?) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(image) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(>) integer(1) operator(?) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** nucomp_scalar_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scalar?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(scalar_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nucomp_to_i - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_i)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(image) keyword(instanceof) ident(RubyFloat) operator(||) operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(f_to_s)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(convertToString)operator(()operator(\)) operator(+) string<delimiter(")content( into Integer)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(f_to_i)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - operator(}) - - comment(/** nucomp_to_f - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(image) keyword(instanceof) ident(RubyFloat) operator(||) operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(f_to_s)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(convertToString)operator(()operator(\)) operator(+) string<delimiter(")content( into Float)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(f_to_f)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - operator(}) - - comment(/** nucomp_to_f - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(image) keyword(instanceof) ident(RubyFloat) operator(||) operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(image)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(f_to_s)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(convertToString)operator(()operator(\)) operator(+) string<delimiter(")content( into Rational)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(f_to_r)operator(()ident(context)operator(,) ident(real)operator(\))operator(;) - operator(}) - - directive(static) ident(RubyArray) ident(str_to_c_internal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(strip)delimiter(")>operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(ByteList) ident(bytes) operator(=) ident(s)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(bytes)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(recv)operator(\))operator(;) - - ident(IRubyObject) ident(sr)operator(,) ident(si)operator(,) ident(re)operator(;) - ident(sr) operator(=) ident(si) operator(=) ident(re) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - type(boolean) ident(po) operator(=) pre_constant(false)operator(;) - ident(IRubyObject) ident(m) operator(=) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(ComplexPatterns)operator(.)ident(comp_pat0)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(match)delimiter(")>operator(,) ident(s)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(sr) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(si) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(two)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(re) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(post_match)delimiter(")>operator(\))operator(;) - ident(po) operator(=) pre_constant(true)operator(;) - operator(}) - - keyword(if) operator(()ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(m) operator(=) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(ComplexPatterns)operator(.)ident(comp_pat1)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(match)delimiter(")>operator(,) ident(s)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(sr) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(si) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(si)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(si) operator(=) ident(runtime)operator(.)ident(newString)operator(()operator(\))operator(;) - ident(IRubyObject) ident(t) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(two)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(t)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(t) operator(=) ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(1)delimiter(')>operator(})operator(\))operator(\))operator(;) - ident(si)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(cat)operator(()ident(t)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(re) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(post_match)delimiter(")>operator(\))operator(;) - ident(po) operator(=) pre_constant(false)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(m) operator(=) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(ComplexPatterns)operator(.)ident(comp_pat2)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(match)delimiter(")>operator(,) ident(s)operator(\))operator(;) - keyword(if) operator(()ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(recv)operator(\))operator(;) - ident(sr) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(two)operator(()ident(runtime)operator(\))operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(si) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(si) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(three)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(t) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(four)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(t)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(t) operator(=) ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(1)delimiter(')>operator(})operator(\))operator(\))operator(;) - ident(si)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(cat)operator(()ident(t)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(re) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(post_match)delimiter(")>operator(\))operator(;) - ident(po) operator(=) pre_constant(false)operator(;) - operator(}) - - ident(IRubyObject) ident(r) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - ident(IRubyObject) ident(i) operator(=) ident(r)operator(;) - - keyword(if) operator(()operator(!)ident(sr)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(sr)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(include?)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(/)delimiter(')>operator(})operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(r) operator(=) ident(f_to_r)operator(()ident(context)operator(,) ident(sr)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(f_gt_p)operator(()ident(context)operator(,) ident(sr)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(count)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(.eE)delimiter(")>operator(\))operator(\))operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(r) operator(=) ident(f_to_f)operator(()ident(context)operator(,) ident(sr)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(r) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(sr)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(si)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(si)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(include?)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(/)delimiter(')>operator(})operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(i) operator(=) ident(f_to_r)operator(()ident(context)operator(,) ident(si)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(f_gt_p)operator(()ident(context)operator(,) ident(si)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(count)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(.eE)delimiter(")>operator(\))operator(\))operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(i) operator(=) ident(f_to_f)operator(()ident(context)operator(,) ident(si)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(i) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(si)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(po) operator(?) ident(newComplexPolar)operator(()ident(context)operator(,) ident(r)operator(,) ident(i)operator(\)) operator(:) ident(newComplexCanonicalize)operator(()ident(context)operator(,) ident(r)operator(,) ident(i)operator(\))operator(,) ident(re)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(str_to_c_strict)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(str_to_c_internal)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - keyword(if) operator(()ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(s) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(;) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Complex: )delimiter(")> operator(+) ident(s)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * Placeholder until/if we can support this - * - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Continuation)delimiter(")>operator(\)) -directive(public) type(class) class(RubyContinuation) operator({) - directive(public) directive(static) type(void) ident(createContinuation)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(cContinuation) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Continuation)delimiter(")>operator(,)ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,)ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cContinuation)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyContinuation)operator(.)ident(class)operator(\))operator(;) - ident(runtime)operator(.)ident(setContinuation)operator(()ident(cContinuation)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(call)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Continuations are not implemented in JRuby and will not work)delimiter(")>operator(\))operator(;) - operator(}) -operator(})comment(// RubyContinuation) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006, 2007 Ola Bini <ola@ologix.com> - * Copyright (C\) 2007 Nick Sieger <nicksieger@gmail.com> - * Copyright (C\) 2008 Vladimir Sizikov <vsizikov@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.security.Provider)operator(;) -keyword(import) include(java.security.MessageDigest)operator(;) -keyword(import) include(java.security.NoSuchAlgorithmException)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) - -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.callback.Callback)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Digest)delimiter(")>operator(\)) -directive(public) type(class) class(RubyDigest) operator({) - directive(private) directive(static) pre_type(Provider) ident(provider) operator(=) pre_constant(null)operator(;) - - directive(public) directive(static) type(void) ident(createDigest)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(try) operator({) - ident(provider) operator(=) operator(()pre_type(Provider)operator(\)) pre_type(Class)operator(.)ident(forName)operator(()string<delimiter(")content(org.bouncycastle.jce.provider.BouncyCastleProvider)delimiter(")>operator(\))operator(.)ident(newInstance)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - comment(// provider is not available) - operator(}) - - ident(RubyModule) ident(mDigest) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigestBase) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Base)delimiter(")>operator(,)ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(Base)operator(.)ident(BASE_ALLOCATOR)operator(\))operator(;) - - ident(cDigestBase)operator(.)ident(defineAnnotatedMethods)operator(()ident(Base)operator(.)ident(class)operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(MessageDigest) ident(createMessageDigest)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(providerName)operator(\)) directive(throws) exception(NoSuchAlgorithmException) operator({) - keyword(if)operator(()ident(provider) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - keyword(return) pre_type(MessageDigest)operator(.)ident(getInstance)operator(()ident(providerName)operator(,) ident(provider)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - comment(// bouncy castle doesn't support algorithm) - operator(}) - operator(}) - comment(// fall back to system JCA providers) - keyword(return) pre_type(MessageDigest)operator(.)ident(getInstance)operator(()ident(providerName)operator(\))operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::MD5)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(MD5) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::RMD160)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(RMD160) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::SHA1)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(SHA1) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::SHA256)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(SHA256) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::SHA384)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(SHA384) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::SHA512)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(SHA512) operator({)operator(}) - - directive(public) directive(static) type(void) ident(createDigestMD5)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(digest.so)delimiter(")>operator(\))operator(;) - ident(RubyModule) ident(mDigest) operator(=) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigestBase) operator(=) ident(mDigest)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Base)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigest_MD5) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(MD5)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_MD5)operator(.)ident(defineFastMethod)operator(()string<delimiter(")content(block_length)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(NO_ARGUMENTS)operator(;) - operator(}) - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(64)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - ident(cDigest_MD5)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(MD5)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(createDigestRMD160)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(digest.so)delimiter(")>operator(\))operator(;) - keyword(if)operator(()ident(provider) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newLoadError)operator(()string<delimiter(")content(RMD160 not supported without BouncyCastle)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyModule) ident(mDigest) operator(=) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigestBase) operator(=) ident(mDigest)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Base)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigest_RMD160) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(RMD160)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_RMD160)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(RIPEMD160)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(createDigestSHA1)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(digest.so)delimiter(")>operator(\))operator(;) - ident(RubyModule) ident(mDigest) operator(=) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigestBase) operator(=) ident(mDigest)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Base)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigest_SHA1) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(SHA1)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_SHA1)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(SHA1)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(createDigestSHA2)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(digest.so)delimiter(")>operator(\))operator(;) - keyword(try) operator({) - ident(createMessageDigest)operator(()ident(runtime)operator(,) string<delimiter(")content(SHA-256)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newLoadError)operator(()string<delimiter(")content(SHA2 not supported)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyModule) ident(mDigest) operator(=) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigestBase) operator(=) ident(mDigest)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Base)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(cDigest_SHA2_256) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(SHA256)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_SHA2_256)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(SHA-256)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyClass) ident(cDigest_SHA2_384) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(SHA384)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_SHA2_384)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(SHA-384)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyClass) ident(cDigest_SHA2_512) operator(=) ident(mDigest)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(SHA512)delimiter(")>operator(,)ident(cDigestBase)operator(,)ident(cDigestBase)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(cDigest_SHA2_512)operator(.)ident(setInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(SHA-512)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Digest::Base)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Base) directive(extends) ident(RubyObject) operator({) - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(BASE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(Base)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(digest)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(s_digest)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) operator(()operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(try) operator({) - pre_type(MessageDigest) ident(md) operator(=) ident(createMessageDigest)operator(()ident(runtime)operator(,) ident(name)operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(md)operator(.)ident(digest)operator(()ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Unsupported digest algorithm ()delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hexdigest)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(s_hexdigest)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) operator(()operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(try) operator({) - pre_type(MessageDigest) ident(md) operator(=) ident(createMessageDigest)operator(()ident(runtime)operator(,) ident(name)operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(ByteList)operator(.)ident(plain)operator(()ident(toHex)operator(()ident(md)operator(.)ident(digest)operator(()ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Unsupported digest algorithm ()delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) pre_type(MessageDigest) ident(algo)operator(;) - directive(private) pre_type(StringBuffer) ident(data)operator(;) - - directive(public) ident(Base)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,)ident(type)operator(\))operator(;) - ident(data) operator(=) keyword(new) pre_type(StringBuffer)operator(()operator(\))operator(;) - - keyword(if)operator(()ident(type) operator(==) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Digest)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Base)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Digest::Base is an abstract class)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(type)operator(.)ident(hasInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(the )delimiter(")> operator(+) ident(type) operator(+) string<delimiter(")content((\) function is unimplemented on this machine)delimiter(")>operator(\))operator(;) - operator(}) - keyword(try) operator({) - ident(setAlgorithm)operator(()ident(type)operator(.)ident(searchInternalModuleVariable)operator(()string<delimiter(")content(metadata)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(the )delimiter(")> operator(+) ident(type) operator(+) string<delimiter(")content((\) function is unimplemented on this machine)delimiter(")>operator(\))operator(;) - operator(}) - - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(0) operator(&&) operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(update)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if)operator(()local_variable(this) operator(==) ident(obj)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(()operator(()ident(RubyObject)operator(\))ident(obj)operator(\))operator(.)ident(checkFrozen)operator(()operator(\))operator(;) - - ident(data) operator(=) keyword(new) pre_type(StringBuffer)operator(()operator(()operator(()ident(Base)operator(\))ident(obj)operator(\))operator(.)ident(data)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - pre_type(String) ident(name) operator(=) operator(()operator(()ident(Base)operator(\))ident(obj)operator(\))operator(.)ident(algo)operator(.)ident(getAlgorithm)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(algo) operator(=) ident(createMessageDigest)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(NoSuchAlgorithmException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Unsupported digest algorithm ()delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(update)delimiter(")>operator(,) string<delimiter(")content(<<)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(update)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(data)operator(.)ident(append)operator(()ident(obj)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(digest)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(digest)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(reset)operator(()operator(\))operator(;) - ident(data)operator(.)ident(append)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(digest) operator(=) ident(getDigest)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(reset)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(digest)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(getDigest)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(digest!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(digest_bang)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - type(byte)type([]) ident(digest) operator(=) ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(;) - ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(digest)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(hexdigest)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(hexdigest)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(reset)operator(()operator(\))operator(;) - ident(data)operator(.)ident(append)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - type(byte)type([]) ident(digest) operator(=) ident(ByteList)operator(.)ident(plain)operator(()ident(toHex)operator(()ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(reset)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(digest)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_s)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(ByteList)operator(.)ident(plain)operator(()ident(toHex)operator(()ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(hexdigest!)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(hexdigest_bang)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - type(byte)type([]) ident(digest) operator(=) ident(ByteList)operator(.)ident(plain)operator(()ident(toHex)operator(()ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(\))operator(\))operator(;) - ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(digest)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(ByteList)operator(.)ident(plain)operator(()string<delimiter(")content(#<)delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(toHex)operator(()ident(algo)operator(.)ident(digest)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(data)operator(\))operator(\))operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(IRubyObject) ident(oth)operator(\)) operator({) - type(boolean) ident(ret) operator(=) local_variable(this) operator(==) ident(oth)operator(;) - keyword(if)operator(()operator(!)ident(ret)operator(\)) operator({) - keyword(if) operator(()ident(oth) keyword(instanceof) ident(Base)operator(\)) operator({) - ident(Base) ident(b) operator(=) operator(()ident(Base)operator(\))ident(oth)operator(;) - ident(ret) operator(=) local_variable(this)operator(.)ident(algo)operator(.)ident(getAlgorithm)operator(()operator(\))operator(.)ident(equals)operator(()ident(b)operator(.)ident(algo)operator(.)ident(getAlgorithm)operator(()operator(\))operator(\)) operator(&&) - local_variable(this)operator(.)ident(getDigest)operator(()operator(\))operator(.)ident(equals)operator(()ident(b)operator(.)ident(getDigest)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(str) operator(=) ident(oth)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(ret) operator(=) local_variable(this)operator(.)ident(to_s)operator(()operator(\))operator(.)ident(equals)operator(()ident(str)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(ret) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(length)delimiter(")>operator(,) string<delimiter(")content(size)delimiter(")>operator(,) string<delimiter(")content(digest_length)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(length)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(algo)operator(.)ident(getDigestLength)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(block_length)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(block_length)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(() - local_variable(this)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( doesn't implement block_length(\))delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(reset)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(reset)operator(()operator(\)) operator({) - ident(algo)operator(.)ident(reset)operator(()operator(\))operator(;) - ident(data) operator(=) keyword(new) pre_type(StringBuffer)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(setAlgorithm)operator(()ident(IRubyObject) ident(algo)operator(\)) directive(throws) exception(NoSuchAlgorithmException) operator({) - local_variable(this)operator(.)ident(algo) operator(=) ident(createMessageDigest)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(algo)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String) ident(toHex)operator(()type(byte)type([]) ident(val)operator(\)) operator({) - pre_type(StringBuilder) ident(out) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(,)ident(j)operator(=)ident(val)operator(.)ident(length)operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - pre_type(String) ident(ve) operator(=) pre_type(Integer)operator(.)ident(toString)operator(()operator(()operator(()operator(()type(int)operator(\))operator(()operator(()type(char)operator(\))ident(val)operator([)ident(i)operator(])operator(\))operator(\)) operator(&) hex(0xFF)operator(\))operator(,)integer(16)operator(\))operator(;) - keyword(if)operator(()ident(ve)operator(.)ident(length)operator(()operator(\)) operator(==) integer(1)operator(\)) operator({) - ident(ve) operator(=) string<delimiter(")content(0)delimiter(")> operator(+) ident(ve)operator(;) - operator(}) - ident(out)operator(.)ident(append)operator(()ident(ve)operator(\))operator(;) - operator(}) - keyword(return) ident(out)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - operator(}) -operator(})comment(// RubyDigest) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.File)operator(;) -keyword(import) include(java.io.FileInputStream)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.ext.posix.util.Platform)operator(;) - -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.Dir)operator(;) -keyword(import) include(org.jruby.util.JRubyFile)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** - * .The Ruby built-in class Dir. - * - * @author jvoegele - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Dir)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyDir) directive(extends) ident(RubyObject) operator({) - comment(// What we passed to the constructor for method 'path') - directive(private) ident(RubyString) ident(path)operator(;) - directive(protected) ident(JRubyFile) ident(dir)operator(;) - directive(private) pre_type(String)type([]) ident(snapshot)operator(;) comment(// snapshot of contents of directory) - directive(private) type(int) ident(pos)operator(;) comment(// current position in directory) - directive(private) type(boolean) ident(isOpen) operator(=) pre_constant(true)operator(;) - - directive(public) ident(RubyDir)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ObjectAllocator) ident(DIR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyDir)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createDirClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(dirClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Dir)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(DIR_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setDir)operator(()ident(dirClass)operator(\))operator(;) - - ident(dirClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - - ident(dirClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyDir)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(dirClass)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(checkDir)operator(()operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: operation on untainted Dir)delimiter(")>operator(\))operator(;) - - ident(testFrozen)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isOpen)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(closed directory)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Creates a new <code>Dir</code>. This method takes a snapshot of the - * contents of the directory at creation time, so changes to the contents - * of the directory will not be reflected during the lifetime of the - * <code>Dir</code> object returned, so a new <code>Dir</code> instance - * must be created to reflect changes to the underlying file system. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject) ident(_newPath)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(RubyString) ident(newPath) operator(=) ident(_newPath)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(checkSafeString)operator(()ident(newPath)operator(\))operator(;) - - pre_type(String) ident(adjustedPath) operator(=) ident(RubyFile)operator(.)ident(adjustRootPathOnWindows)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(newPath)operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(null)operator(\))operator(;) - ident(checkDirIsTwoSlashesOnWindows)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(adjustedPath)operator(\))operator(;) - - ident(dir) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(adjustedPath)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(dir)operator(.)ident(isDirectory)operator(()operator(\))operator(\)) operator({) - ident(dir) operator(=) pre_constant(null)operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()ident(newPath)operator(.)ident(toString)operator(()operator(\)) operator(+) string<delimiter(")content( is not a directory)delimiter(")>operator(\))operator(;) - operator(}) - ident(path) operator(=) ident(newPath)operator(;) - pre_type(List)operator(<)pre_type(String)operator(>) ident(snapshotList) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - ident(snapshotList)operator(.)ident(add)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - ident(snapshotList)operator(.)ident(add)operator(()string<delimiter(")content(..)delimiter(")>operator(\))operator(;) - ident(snapshotList)operator(.)ident(addAll)operator(()ident(getContents)operator(()ident(dir)operator(\))operator(\))operator(;) - ident(snapshot) operator(=) operator(()pre_type(String)type([])operator(\)) ident(snapshotList)operator(.)ident(toArray)operator(()keyword(new) pre_type(String)operator([)ident(snapshotList)operator(.)ident(size)operator(()operator(\))operator(])operator(\))operator(;) - ident(pos) operator(=) integer(0)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - -comment(// ----- Ruby Class Methods ----------------------------------------------------) - - directive(private) directive(static) pre_type(List)operator(<)ident(ByteList)operator(>) ident(dirGlobs)operator(()pre_type(String) ident(cwd)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) type(int) ident(flags)operator(\)) operator({) - pre_type(List)operator(<)ident(ByteList)operator(>) ident(dirs) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(ByteList)operator(>)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(ByteList) ident(globPattern) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(dirs)operator(.)ident(addAll)operator(()ident(Dir)operator(.)ident(push_glob)operator(()ident(cwd)operator(,) ident(globPattern)operator(,) ident(flags)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(dirs)operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(asRubyStringList)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(List)operator(<)ident(ByteList)operator(>) ident(dirs)operator(\)) operator({) - pre_type(List)operator(<)ident(RubyString)operator(>) ident(allFiles) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(RubyString)operator(>)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(ByteList) ident(dir)operator(:) ident(dirs)operator(\)) operator({) - ident(allFiles)operator(.)ident(add)operator(()ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(dir)operator(\))operator(\))operator(;) - operator(}) - - ident(IRubyObject)type([]) ident(tempFileList) operator(=) keyword(new) ident(IRubyObject)operator([)ident(allFiles)operator(.)ident(size)operator(()operator(\))operator(])operator(;) - ident(allFiles)operator(.)ident(toArray)operator(()ident(tempFileList)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newArrayNoCopy)operator(()ident(tempFileList)operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String) ident(getCWD)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(try) operator({) - keyword(return) keyword(new) ident(org)operator(.)ident(jruby)operator(.)ident(util)operator(.)ident(NormalizedFile)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(\))operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest)operator(=)pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - pre_type(List)operator(<)ident(ByteList)operator(>) ident(dirs)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(ByteList) ident(globPattern) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(dirs) operator(=) ident(Dir)operator(.)ident(push_glob)operator(()ident(getCWD)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) ident(globPattern)operator(,) integer(0)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(dirs) operator(=) ident(dirGlobs)operator(()ident(getCWD)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) ident(args)operator(,) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(asRubyStringList)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(dirs)operator(\))operator(;) - operator(}) - - comment(/** - * Returns an array of filenames matching the specified wildcard pattern - * <code>pat</code>. If a block is given, the array is iterated internally - * with each filename is passed to the block in turn. In this case, Nil is - * returned. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(glob)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(glob)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(flags) operator(=) ident(args)operator(.)ident(length) operator(==) integer(2) operator(?) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(1)operator(])operator(\)) operator(:) integer(0)operator(;) - - pre_type(List)operator(<)ident(ByteList)operator(>) ident(dirs)operator(;) - ident(IRubyObject) ident(tmp) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(ByteList) ident(globPattern) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(dirs) operator(=) ident(Dir)operator(.)ident(push_glob)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(globPattern)operator(,) ident(flags)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(dirs) operator(=) ident(dirGlobs)operator(()ident(getCWD)operator(()ident(runtime)operator(\))operator(,) operator(()operator(()ident(RubyArray)operator(\)) ident(tmp)operator(\))operator(.)ident(toJavaArray)operator(()operator(\))operator(,) ident(flags)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(dirs)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(dirs)operator(.)ident(get)operator(()ident(i)operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(asRubyStringList)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(dirs)operator(\))operator(;) - operator(}) - - comment(/** - * @return all entries for this Dir - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(entries)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(entries)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()ident(JavaUtil)operator(.)ident(convertJavaArrayToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(snapshot)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Returns an array containing all of the filenames in the given directory. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(entries)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(entries)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(path)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - pre_type(String) ident(adjustedPath) operator(=) ident(RubyFile)operator(.)ident(adjustRootPathOnWindows)operator(() - ident(runtime)operator(,) ident(path)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(null)operator(\))operator(;) - ident(checkDirIsTwoSlashesOnWindows)operator(()ident(runtime)operator(,) ident(adjustedPath)operator(\))operator(;) - - directive(final) ident(JRubyFile) ident(directory) operator(=) ident(JRubyFile)operator(.)ident(create)operator(() - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(adjustedPath)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(directory)operator(.)ident(isDirectory)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such directory)delimiter(")>operator(\))operator(;) - operator(}) - pre_type(List)operator(<)pre_type(String)operator(>) ident(fileList) operator(=) ident(getContents)operator(()ident(directory)operator(\))operator(;) - ident(fileList)operator(.)ident(add)operator(()integer(0)operator(,) string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - ident(fileList)operator(.)ident(add)operator(()integer(1)operator(,) string<delimiter(")content(..)delimiter(")>operator(\))operator(;) - pre_type(Object)type([]) ident(files) operator(=) ident(fileList)operator(.)ident(toArray)operator(()operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()ident(JavaUtil)operator(.)ident(convertJavaArrayToRuby)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(files)operator(\))operator(\))operator(;) - operator(}) - - comment(// MRI behavior: just plain '//' or '\\\\\\\\' are considered illegal on Windows.) - directive(private) directive(static) type(void) ident(checkDirIsTwoSlashesOnWindows)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS) operator(&&) operator(()string<delimiter(")content(//)delimiter(")>operator(.)ident(equals)operator(()ident(path)operator(\)) operator(||) string<delimiter(")char(\\\\)char(\\\\)delimiter(")>operator(.)ident(equals)operator(()ident(path)operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(Invalid argument - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Changes the current directory to <code>path</code> */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chdir)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chdir)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(path) operator(=) ident(args)operator(.)ident(length) operator(==) integer(1) operator(?) - operator(()ident(RubyString)operator(\)) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\)) operator(:) ident(getHomeDirectoryPath)operator(()ident(context)operator(\))operator(;) - pre_type(String) ident(adjustedPath) operator(=) ident(RubyFile)operator(.)ident(adjustRootPathOnWindows)operator(() - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(path)operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(null)operator(\))operator(;) - ident(checkDirIsTwoSlashesOnWindows)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(adjustedPath)operator(\))operator(;) - ident(JRubyFile) ident(dir) operator(=) ident(getDir)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(adjustedPath)operator(,) pre_constant(true)operator(\))operator(;) - pre_type(String) ident(realPath) operator(=) pre_constant(null)operator(;) - pre_type(String) ident(oldCwd) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(;) - - comment(// We get canonical path to try and flatten the path out.) - comment(// a dir '/subdir/..' should return as '/') - comment(// cnutter: Do we want to flatten path out?) - keyword(try) operator({) - ident(realPath) operator(=) ident(dir)operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - ident(realPath) operator(=) ident(dir)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(result) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - comment(// FIXME: Don't allow multiple threads to do this at once) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setCurrentDirectory)operator(()ident(realPath)operator(\))operator(;) - keyword(try) operator({) - ident(result) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(path)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(dir) operator(=) ident(getDir)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(oldCwd)operator(,) pre_constant(true)operator(\))operator(;) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setCurrentDirectory)operator(()ident(oldCwd)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setCurrentDirectory)operator(()ident(realPath)operator(\))operator(;) - ident(result) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * Changes the root directory (only allowed by super user\). Not available - * on all platforms. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chroot)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chroot)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(path)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(chroot not implemented: chroot is non-portable and is not supported.)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Deletes the directory specified by <code>path</code>. The directory must - * be empty. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(rmdir)delimiter(")>operator(,) string<delimiter(")content(unlink)delimiter(")>operator(,) string<delimiter(")content(delete)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rmdir)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(path)operator(\)) operator({) - ident(JRubyFile) ident(directory) operator(=) ident(getDir)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(path)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(true)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(directory)operator(.)ident(delete)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSystemCallError)operator(()string<delimiter(")content(No such directory)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - comment(/** - * Executes the block once for each file in the directory specified by - * <code>path</code>. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(foreach)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(foreach)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(_path)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(path) operator(=) ident(_path)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(checkSafeString)operator(()ident(path)operator(\))operator(;) - - ident(RubyClass) ident(dirClass) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDir)operator(()operator(\))operator(;) - ident(RubyDir) ident(dir) operator(=) operator(()ident(RubyDir)operator(\)) ident(dirClass)operator(.)ident(newInstance)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(path) operator(})operator(,) ident(block)operator(\))operator(;) - - ident(dir)operator(.)ident(each)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** Returns the current directory. */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(getwd)delimiter(")>operator(,) string<delimiter(")content(pwd)delimiter(")>operator(})operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyString) ident(getwd)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(ruby) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(return) ident(RubyString)operator(.)ident(newUnicodeString)operator(()ident(ruby)operator(,) ident(ruby)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Creates the directory specified by <code>path</code>. Note that the - * <code>mode</code> parameter is provided only to support existing Ruby - * code, and is ignored. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mkdir)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(mkdir)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - pre_type(String) ident(path) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\))operator(;) - - pre_type(File) ident(newDir) operator(=) ident(getDir)operator(()ident(runtime)operator(,) ident(path)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()pre_type(File)operator(.)ident(separatorChar) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - ident(newDir) operator(=) keyword(new) pre_type(File)operator(()ident(newDir)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(;) - operator(}) - - type(int) ident(mode) operator(=) ident(args)operator(.)ident(length) operator(==) integer(2) operator(?) operator(()operator(()type(int)operator(\)) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\)) operator(:) oct(0777)operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(mkdir)operator(()ident(newDir)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(,) ident(mode)operator(\)) operator(<) integer(0)operator(\)) operator({) - comment(// FIXME: This is a system error based on errno) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSystemCallError)operator(()string<delimiter(")content(mkdir failed)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Returns a new directory object for <code>path</code>. If a block is - * provided, a new directory object is passed to the block, which closes the - * directory object before terminating. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(path)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyDir) ident(directory) operator(=) - operator(()ident(RubyDir)operator(\)) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDir)operator(()operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) - keyword(new) ident(IRubyObject)type([]) operator({) ident(path) operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(directory)operator(;) - - keyword(try) operator({) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(directory)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(directory)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - -comment(// ----- Ruby Instance Methods -------------------------------------------------) - - comment(/** - * Closes the directory stream. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - comment(// Make sure any read(\)s after close fail.) - ident(checkDir)operator(()operator(\))operator(;) - - ident(isOpen) operator(=) pre_constant(false)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Executes the block once for each entry in the directory. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(checkDir)operator(()operator(\))operator(;) - - pre_type(String)type([]) ident(contents) operator(=) ident(snapshot)operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(contents)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(contents)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * Returns the current position in the directory. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(tell)delimiter(")>operator(,) string<delimiter(")content(pos)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(tell)operator(()operator(\)) operator({) - ident(checkDir)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(pos)operator(\))operator(;) - operator(}) - - comment(/** - * Moves to a position <code>d</code>. <code>pos</code> must be a value - * returned by <code>tell</code> or 0. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seek)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(seek)operator(()ident(IRubyObject) ident(newPos)operator(\)) operator({) - ident(checkDir)operator(()operator(\))operator(;) - - ident(set_pos)operator(()ident(newPos)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_pos)operator(()ident(IRubyObject) ident(newPos)operator(\)) operator({) - local_variable(this)operator(.)ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(newPos)operator(\))operator(;) - keyword(return) ident(newPos)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(path)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(path)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(checkDir)operator(()operator(\))operator(;) - - keyword(return) ident(path)operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** Returns the next entry from this directory. */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()operator(\)) operator({) - ident(checkDir)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(>=) ident(snapshot)operator(.)ident(length)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(RubyString) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(snapshot)operator([)ident(pos)operator(])operator(\))operator(;) - ident(pos)operator(++)operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** Moves position in this directory to the first entry. */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rewind)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rewind)operator(()operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't close)delimiter(")>operator(\))operator(;) - ident(checkDir)operator(()operator(\))operator(;) - - ident(pos) operator(=) integer(0)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - -comment(// ----- Helper Methods --------------------------------------------------------) - - comment(/** Returns a Java <code>File</code> object for the specified path. If - * <code>path</code> is not a directory, throws <code>IOError</code>. - * - * @param path path for which to return the <code>File</code> object. - * @param mustExist is true the directory must exist. If false it must not. - * @throws IOError if <code>path</code> is not a directory. - */) - directive(protected) directive(static) ident(JRubyFile) ident(getDir)operator(()directive(final) ident(Ruby) ident(runtime)operator(,) directive(final) pre_type(String) ident(path)operator(,) directive(final) type(boolean) ident(mustExist)operator(\)) operator({) - ident(JRubyFile) ident(result) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,)ident(path)operator(\))operator(;) - keyword(if) operator(()ident(mustExist) operator(&&) operator(!)ident(result)operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - type(boolean) ident(isDirectory) operator(=) ident(result)operator(.)ident(isDirectory)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(mustExist) operator(&&) operator(!)ident(isDirectory)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOTDIRError)operator(()ident(path) operator(+) string<delimiter(")content( is not a directory)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)ident(mustExist) operator(&&) ident(isDirectory)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEEXISTError)operator(()string<delimiter(")content(File exists - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * Returns the contents of the specified <code>directory</code> as an - * <code>ArrayList</code> containing the names of the files as Java Strings. - */) - directive(protected) directive(static) pre_type(List)operator(<)pre_type(String)operator(>) ident(getContents)operator(()pre_type(File) ident(directory)operator(\)) operator({) - pre_type(String)type([]) ident(contents) operator(=) ident(directory)operator(.)ident(list)operator(()operator(\))operator(;) - pre_type(List)operator(<)pre_type(String)operator(>) ident(result) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - - comment(// If an IO exception occurs (something odd, but possible\)) - comment(// A directory may return null.) - keyword(if) operator(()ident(contents) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(contents)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(add)operator(()ident(contents)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * Returns the contents of the specified <code>directory</code> as an - * <code>ArrayList</code> containing the names of the files as Ruby Strings. - */) - directive(protected) directive(static) pre_type(List)operator(<)ident(RubyString)operator(>) ident(getContents)operator(()pre_type(File) ident(directory)operator(,) ident(Ruby) ident(runtime)operator(\)) operator({) - pre_type(List)operator(<)ident(RubyString)operator(>) ident(result) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(RubyString)operator(>)operator(()operator(\))operator(;) - pre_type(String)type([]) ident(contents) operator(=) ident(directory)operator(.)ident(list)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(contents)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(add)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(contents)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * Returns the home directory of the specified <code>user</code> on the - * system. If the home directory of the specified user cannot be found, - * an <code>ArgumentError it thrown</code>. - */) - directive(public) directive(static) ident(IRubyObject) ident(getHomeDirectoryPath)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(user)operator(\)) operator({) - comment(/* - * TODO: This version is better than the hackish previous one. Windows - * behavior needs to be defined though. I suppose this version - * could be improved more too. - * TODO: /etc/passwd is also inadequate for MacOSX since it does not - * use /etc/passwd for regular user accounts - */) - - pre_type(String) ident(passwd) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - pre_type(FileInputStream) ident(stream) operator(=) keyword(new) pre_type(FileInputStream)operator(()string<delimiter(")content(/etc/passwd)delimiter(")>operator(\))operator(;) - type(int) ident(totalBytes) operator(=) ident(stream)operator(.)ident(available)operator(()operator(\))operator(;) - type(byte)type([]) ident(bytes) operator(=) keyword(new) type(byte)operator([)ident(totalBytes)operator(])operator(;) - ident(stream)operator(.)ident(read)operator(()ident(bytes)operator(\))operator(;) - ident(stream)operator(.)ident(close)operator(()operator(\))operator(;) - ident(passwd) operator(=) keyword(new) pre_type(String)operator(()ident(bytes)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - pre_type(String)type([]) ident(rows) operator(=) ident(passwd)operator(.)ident(split)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - type(int) ident(rowCount) operator(=) ident(rows)operator(.)ident(length)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(rowCount)operator(;) ident(i)operator(++)operator(\)) operator({) - pre_type(String)type([]) ident(fields) operator(=) ident(rows)operator([)ident(i)operator(])operator(.)ident(split)operator(()string<delimiter(")content(:)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(fields)operator([)integer(0)operator(])operator(.)ident(equals)operator(()ident(user)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(fields)operator([)integer(5)operator(])operator(\))operator(;) - operator(}) - operator(}) - - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(user )delimiter(")> operator(+) ident(user) operator(+) string<delimiter(")content( doesn't exist)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(getHomeDirectoryPath)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyHash) ident(systemHash) operator(=) operator(()ident(RubyHash)operator(\)) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ENV_JAVA)delimiter(")>operator(\))operator(;) - ident(RubyHash) ident(envHash) operator(=) operator(()ident(RubyHash)operator(\)) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ENV)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(home) operator(=) ident(envHash)operator(.)ident(op_aref)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(HOME)delimiter(")>operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(home) operator(==) pre_constant(null) operator(||) ident(home)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(home) operator(=) ident(systemHash)operator(.)ident(op_aref)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(user.home)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(home) operator(==) pre_constant(null) operator(||) ident(home)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(home) operator(=) ident(envHash)operator(.)ident(op_aref)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(LOGDIR)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(home) operator(==) pre_constant(null) operator(||) ident(home)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(user.home/LOGDIR not set)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()ident(RubyString)operator(\)) ident(home)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.Comparator)operator(;) -keyword(import) include(java.util.Arrays)operator(;) -keyword(import) include(java.util.concurrent.atomic.AtomicInteger)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallBlock)operator(;) -keyword(import) include(org.jruby.runtime.BlockCallback)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) - -comment(/** - * The implementation of Ruby's Enumerable module. - */) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyEnumerable) operator({) - - directive(public) directive(static) ident(RubyModule) ident(createEnumerableModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(enumModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Enumerable)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setEnumerable)operator(()ident(enumModule)operator(\))operator(;) - - ident(enumModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyEnumerable)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(enumModule)operator(;) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(callEach)operator(()ident(Ruby) ident(runtime)operator(,) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) - ident(BlockCallback) ident(callback)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(self)operator(,) string<delimiter(")content(each)delimiter(")>operator(,) ident(CallBlock)operator(.)ident(newCallClosure)operator(()ident(self)operator(,) ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(,) - ident(Arity)operator(.)ident(noArguments)operator(()operator(\))operator(,) ident(callback)operator(,) ident(context)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(class) class(ExitIteration) directive(extends) exception(RuntimeException) operator({) - directive(public) pre_type(Throwable) ident(fillInStackTrace)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(first)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(first_0)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - directive(final) ident(IRubyObject)type([]) ident(holder) operator(=) keyword(new) ident(IRubyObject)type([])operator({)ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(})operator(;) - - keyword(try) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(ctx)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#first cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - ident(holder)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - keyword(throw) keyword(new) ident(ExitIteration)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(ExitIteration) ident(ei)operator(\)) operator({)operator(}) - - keyword(return) ident(holder)operator([)integer(0)operator(])operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(first)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(first_1)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(IRubyObject) ident(num)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(if)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(num)operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative index)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(private) type(int) ident(iter) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(num)operator(\))operator(;) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#first cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if)operator(()ident(iter)operator(--) operator(==) integer(0)operator(\)) operator({) - keyword(throw) keyword(new) ident(ExitIteration)operator(()operator(\))operator(;) - operator(}) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(ExitIteration) ident(ei)operator(\)) operator({)operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_a)delimiter(")>operator(,) string<delimiter(")content(entries)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(to_a)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(AppendBlockCallback)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sort)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sort)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(AppendBlockCallback)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(sort_bang)operator(()ident(block)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sort_by)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sort_by)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) comment(// MUST NOT be used across threads) - - keyword(if) operator(()ident(self) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - ident(RubyArray) ident(selfArray) operator(=) operator(()ident(RubyArray)operator(\)) ident(self)operator(;) - directive(final) ident(IRubyObject)type([])type([]) ident(valuesAndCriteria) operator(=) keyword(new) ident(IRubyObject)operator([)ident(selfArray)operator(.)ident(size)operator(()operator(\))operator(])operator([)integer(2)operator(])operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - pre_type(AtomicInteger) ident(i) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(0)operator(\))operator(;) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(IRubyObject)type([]) ident(myVandC) operator(=) ident(valuesAndCriteria)operator([)ident(i)operator(.)ident(getAndIncrement)operator(()operator(\))operator(])operator(;) - ident(myVandC)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - ident(myVandC)operator([)integer(1)operator(]) operator(=) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - pre_type(Arrays)operator(.)ident(sort)operator(()ident(valuesAndCriteria)operator(,) keyword(new) pre_type(Comparator)operator(<)ident(IRubyObject)type([])operator(>)operator(()operator(\)) operator({) - directive(public) type(int) ident(compare)operator(()ident(IRubyObject)type([]) ident(o1)operator(,) ident(IRubyObject)type([]) ident(o2)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(fix2int)operator(()ident(o1)operator([)integer(1)operator(])operator(.)ident(callMethod)operator(()ident(localContext)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(o2)operator([)integer(1)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - ident(IRubyObject) ident(dstArray)type([]) operator(=) keyword(new) ident(IRubyObject)operator([)ident(selfArray)operator(.)ident(size)operator(()operator(\))operator(])operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(dstArray)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(dstArray)operator([)ident(i)operator(]) operator(=) ident(valuesAndCriteria)operator([)ident(i)operator(])operator([)integer(0)operator(])operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newArrayNoCopy)operator(()ident(dstArray)operator(\))operator(;) - operator(}) keyword(else) operator({) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(AppendBlockCallback)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(\))operator(;) - - directive(final) ident(IRubyObject)type([])type([]) ident(valuesAndCriteria) operator(=) keyword(new) ident(IRubyObject)operator([)ident(result)operator(.)ident(size)operator(()operator(\))operator(])operator([)integer(2)operator(])operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(valuesAndCriteria)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(result)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(;) - ident(valuesAndCriteria)operator([)ident(i)operator(])operator([)integer(0)operator(]) operator(=) ident(val)operator(;) - ident(valuesAndCriteria)operator([)ident(i)operator(])operator([)integer(1)operator(]) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(val)operator(\))operator(;) - operator(}) - - pre_type(Arrays)operator(.)ident(sort)operator(()ident(valuesAndCriteria)operator(,) keyword(new) pre_type(Comparator)operator(<)ident(IRubyObject)type([])operator(>)operator(()operator(\)) operator({) - directive(public) type(int) ident(compare)operator(()ident(IRubyObject)type([]) ident(o1)operator(,) ident(IRubyObject)type([]) ident(o2)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(fix2int)operator(()ident(o1)operator([)integer(1)operator(])operator(.)ident(callMethod)operator(()ident(localContext)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(o2)operator([)integer(1)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(valuesAndCriteria)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(eltInternalSet)operator(()ident(i)operator(,) ident(valuesAndCriteria)operator([)ident(i)operator(])operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(grep)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(grep)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(IRubyObject) ident(pattern)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(ctx)operator(.)ident(setRubyFrameDelta)operator(()ident(ctx)operator(.)ident(getRubyFrameDelta)operator(()operator(\))operator(+)integer(2)operator(\))operator(;) - keyword(if) operator(()ident(pattern)operator(.)ident(callMethod)operator(()ident(ctx)operator(,) ident(MethodIndex)operator(.)ident(OP_EQQ)operator(,) string<delimiter(")content(===)delimiter(")>operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(value) operator(=) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(}) - ident(ctx)operator(.)ident(setRubyFrameDelta)operator(()ident(ctx)operator(.)ident(getRubyFrameDelta)operator(()operator(\))operator(-)integer(2)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(pattern)operator(.)ident(callMethod)operator(()ident(ctx)operator(,) ident(MethodIndex)operator(.)ident(OP_EQQ)operator(,) string<delimiter(")content(===)delimiter(")>operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(detect)delimiter(")>operator(,) string<delimiter(")content(find)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(detect)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject) ident(result)type([]) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) pre_constant(null) operator(})operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - ident(IRubyObject) ident(ifnone) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) ident(ifnone) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - - keyword(try) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#detect/find cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(result)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(SpecialJump) ident(sj)operator(\)) operator({) - keyword(return) ident(result)operator([)integer(0)operator(])operator(;) - operator(}) - - keyword(return) ident(ifnone) operator(!=) pre_constant(null) operator(?) ident(ifnone)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(call)delimiter(")>operator(\)) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(select)delimiter(")>operator(,) string<delimiter(")content(find_all)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reject)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(reject)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(collect)delimiter(")>operator(,) string<delimiter(")content(map)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(collect)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(IRubyObject) ident(value) operator(=) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(AppendBlockCallback)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inject)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(inject)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject) ident(result)type([]) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) pre_constant(null) operator(})operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) ident(result)operator([)integer(0)operator(]) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#inject cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - ident(result)operator([)integer(0)operator(]) operator(=) ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(?) - ident(largs)operator([)integer(0)operator(]) operator(:) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(runtime)operator(.)ident(newArray)operator(()ident(result)operator([)integer(0)operator(])operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(true)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(result)operator([)integer(0)operator(])operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(partition)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(partition)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(arr_true) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(arr_false) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - directive(synchronized) operator(()ident(arr_true)operator(\)) operator({) - ident(arr_true)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - directive(synchronized) operator(()ident(arr_false)operator(\)) operator({) - ident(arr_false)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(arr_true)operator(,) ident(arr_false)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(class) class(EachWithIndex) directive(implements) ident(BlockCallback) operator({) - directive(private) type(int) ident(index) operator(=) integer(0)operator(;) - directive(private) directive(final) ident(Block) ident(block)operator(;) - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - - directive(public) ident(EachWithIndex)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(Block) ident(block)operator(\)) operator({) - local_variable(this)operator(.)ident(block) operator(=) ident(block)operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) ident(ctx)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(iargs)operator(,) ident(Block) ident(block)operator(\)) operator({) - local_variable(this)operator(.)ident(block)operator(.)ident(call)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(runtime)operator(.)ident(newArray)operator(()ident(iargs)operator([)integer(0)operator(])operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(index)operator(++)operator(\))operator(\)) operator(})operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_with_index)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_with_index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(self)operator(,) string<delimiter(")content(each)delimiter(")>operator(,) ident(CallBlock)operator(.)ident(newCallClosure)operator(()ident(self)operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getEnumerable)operator(()operator(\))operator(,) - ident(Arity)operator(.)ident(noArguments)operator(()operator(\))operator(,) keyword(new) ident(EachWithIndex)operator(()ident(context)operator(,) ident(block)operator(\))operator(,) ident(context)operator(\))operator(\))operator(;) - - keyword(return) ident(self)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(include?)delimiter(")>operator(,) string<delimiter(")content(member?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(include_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(IRubyObject) ident(arg)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(try) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#include?/member? cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(RubyObject)operator(.)ident(equalInternal)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(,) ident(arg)operator(\))operator(\)) operator({) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(SpecialJump) ident(sj)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(max)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(max)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject) ident(result)type([]) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) pre_constant(null) operator(})operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#max{} cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(||) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(ctx)operator(,) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) - ident(runtime)operator(.)ident(newArray)operator(()ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(\))operator(,) ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(result)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - keyword(if) operator(()ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(||) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(ctx)operator(,) - ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(,) ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(result)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(result)operator([)integer(0)operator(])operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(min)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(min)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject) ident(result)type([]) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) pre_constant(null) operator(})operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#min{} cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(||) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(ctx)operator(,) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) - ident(runtime)operator(.)ident(newArray)operator(()ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(\))operator(,) ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\)) operator(<) integer(0)operator(\)) operator({) - ident(result)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - keyword(if) operator(()ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(||) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(ctx)operator(,) - ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(,) ident(largs)operator([)integer(0)operator(])operator(,) ident(result)operator([)integer(0)operator(])operator(\)) operator(<) integer(0)operator(\)) operator({) - ident(result)operator([)integer(0)operator(]) operator(=) ident(largs)operator([)integer(0)operator(])operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator([)integer(0)operator(]) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(result)operator([)integer(0)operator(])operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(all?)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(all_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#all? cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#all? cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(largs)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(SpecialJump) ident(sj)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(any?)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(any_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(ThreadContext) ident(localContext) operator(=) ident(context)operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#any? cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(localContext) operator(!=) ident(ctx)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(Enumerable#any? cannot be parallelized)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(largs)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(JumpException)operator(.)ident(SPECIAL_JUMP)operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(SpecialJump) ident(sj)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zip)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(zip)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(IRubyObject)type([]) ident(args)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(args)operator([)ident(i)operator(]) operator(=) ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(args)operator([)ident(i)operator(])operator(,) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_A)operator(,) string<delimiter(")content(to_a)delimiter(")>operator(\))operator(;) - operator(}) - - directive(final) type(int) ident(aLen) operator(=) ident(args)operator(.)ident(length) operator(+) integer(1)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - pre_type(AtomicInteger) ident(ix) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(0)operator(\))operator(;) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(RubyArray) ident(array) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(aLen)operator(\))operator(;) - type(int) ident(myIx) operator(=) ident(ix)operator(.)ident(getAndIncrement)operator(()operator(\))operator(;) - ident(array)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,) ident(j) operator(=) ident(args)operator(.)ident(length)operator(;) ident(i) operator(<) ident(j)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)ident(i)operator(])operator(\))operator(.)ident(entry)operator(()ident(myIx)operator(\))operator(\))operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(array)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - directive(final) ident(RubyArray) ident(zip) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - pre_type(AtomicInteger) ident(ix) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(0)operator(\))operator(;) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(RubyArray) ident(array) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(aLen)operator(\))operator(;) - ident(array)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - type(int) ident(myIx) operator(=) ident(ix)operator(.)ident(getAndIncrement)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,) ident(j) operator(=) ident(args)operator(.)ident(length)operator(;) ident(i) operator(<) ident(j)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)ident(i)operator(])operator(\))operator(.)ident(entry)operator(()ident(myIx)operator(\))operator(\))operator(;) - operator(}) - directive(synchronized) operator(()ident(zip)operator(\)) operator({) - ident(zip)operator(.)ident(append)operator(()ident(array)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - keyword(return) ident(zip)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(group_by)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(group_by)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyHash) ident(result) operator(=) keyword(new) ident(RubyHash)operator(()ident(runtime)operator(\))operator(;) - - ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(IRubyObject) ident(key) operator(=) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - directive(synchronized) operator(()ident(result)operator(\)) operator({) - ident(IRubyObject) ident(curr) operator(=) ident(result)operator(.)ident(fastARef)operator(()ident(key)operator(\))operator(;) - - keyword(if) operator(()ident(curr) operator(==) pre_constant(null)operator(\)) operator({) - ident(curr) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(result)operator(.)ident(fastASet)operator(()ident(key)operator(,) ident(curr)operator(\))operator(;) - operator(}) - ident(curr)operator(.)ident(callMethod)operator(()ident(ctx)operator(,) ident(MethodIndex)operator(.)ident(OP_LSHIFT)operator(,) string<delimiter(")content(<<)delimiter(")>operator(,) ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) directive(static) directive(final) type(class) class(AppendBlockCallback) directive(implements) ident(BlockCallback) operator({) - directive(private) ident(Ruby) ident(runtime)operator(;) - directive(private) ident(RubyArray) ident(result)operator(;) - - directive(public) ident(AppendBlockCallback)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyArray) ident(result)operator(\)) operator({) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - local_variable(this)operator(.)ident(result) operator(=) ident(result)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Michael Studman <me@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.BlockCallback)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * Implementation of Ruby's Enumerator module. - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Enumerable::Enumerator)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyEnumerator) directive(extends) ident(RubyObject) operator({) - comment(/** target for each operation */) - directive(private) ident(IRubyObject) ident(object)operator(;) - - comment(/** method to invoke for each operation */) - directive(private) ident(IRubyObject) ident(method)operator(;) - - comment(/** args to each method */) - directive(private) ident(IRubyObject)type([]) ident(methodArgs)operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(ENUMERATOR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyEnumerator)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) type(void) ident(defineEnumerator)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(kernel) operator(=) ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(;) - ident(kernel)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(obj_to_enum)delimiter(")>operator(\))operator(;) - - ident(RubyModule) ident(enm) operator(=) ident(runtime)operator(.)ident(getClassFromPath)operator(()string<delimiter(")content(Enumerable)delimiter(")>operator(\))operator(;) - ident(enm)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(each_with_index)delimiter(")>operator(\))operator(;) - ident(enm)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(each_slice)delimiter(")>operator(\))operator(;) - ident(enm)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(enum_slice)delimiter(")>operator(\))operator(;) - ident(enm)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(each_cons)delimiter(")>operator(\))operator(;) - ident(enm)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(enum_cons)delimiter(")>operator(\))operator(;) - - ident(RubyClass) ident(enmr) operator(=) ident(enm)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Enumerator)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ENUMERATOR_ALLOCATOR)operator(\))operator(;) - - ident(enmr)operator(.)ident(includeModule)operator(()ident(enm)operator(\))operator(;) - - ident(enmr)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(initialize)delimiter(")>operator(\))operator(;) - ident(enmr)operator(.)ident(defineAnnotatedMethod)operator(()ident(RubyEnumerator)operator(.)ident(class)operator(,) string<delimiter(")content(each)delimiter(")>operator(\))operator(;) - - ident(runtime)operator(.)ident(setEnumerator)operator(()ident(enmr)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_enum)delimiter(")>operator(,) string<delimiter(")content(enum_for)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_to_enum)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject)type([]) ident(newArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(args)operator(.)ident(length) operator(+) integer(1)operator(])operator(;) - ident(newArgs)operator([)integer(0)operator(]) operator(=) ident(self)operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(newArgs)operator(,) integer(1)operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getEnumerator)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(new)delimiter(")>operator(,) ident(newArgs)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyEnumerator)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - ident(object) operator(=) ident(method) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(object) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(method) operator(=) ident(args)operator(.)ident(length) operator(>) integer(1) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()string<delimiter(")content(each)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) operator({) - ident(methodArgs) operator(=) keyword(new) ident(IRubyObject)operator([)pre_type(Math)operator(.)ident(max)operator(()integer(0)operator(,) ident(args)operator(.)ident(length) operator(-) integer(2)operator(\))operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(2)operator(,) ident(methodArgs)operator(,) integer(0)operator(,) ident(args)operator(.)ident(length) operator(-) integer(2)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(methodArgs) operator(=) keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * Send current block and supplied args to method on target. According to MRI - * Block may not be given and "each" should just ignore it and call on through to - * underlying method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(object)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(.)ident(asJavaString)operator(()operator(\))operator(,) ident(methodArgs)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(enum_with_index)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_with_index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - ident(IRubyObject) ident(enumerator) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getEnumerator)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(enumerator)operator(,) string<delimiter(")content(new)delimiter(")>operator(,) ident(self)operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()string<delimiter(")content(each_with_index)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_slice)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_slice)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) type(int) ident(size) operator(=) operator(()type(int)operator(\))ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg)operator(\))operator(;) - - keyword(if) operator(()ident(size) operator(<=) integer(0)operator(\)) keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid slice size)delimiter(")>operator(\))operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result)type([]) operator(=) keyword(new) ident(RubyArray)type([])operator({)ident(runtime)operator(.)ident(newArray)operator(()ident(size)operator(\))operator(})operator(;) - - ident(RubyEnumerable)operator(.)ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(result)operator([)integer(0)operator(])operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(result)operator([)integer(0)operator(])operator(.)ident(size)operator(()operator(\)) operator(==) ident(size)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(;) - ident(result)operator([)integer(0)operator(]) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(size)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(if) operator(()ident(result)operator([)integer(0)operator(])operator(.)ident(size)operator(()operator(\)) operator(>) integer(0)operator(\)) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(result)operator([)integer(0)operator(])operator(\))operator(;) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_cons)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_cons)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) type(int) ident(size) operator(=) operator(()type(int)operator(\))ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg)operator(\))operator(;) - - keyword(if) operator(()ident(size) operator(<=) integer(0)operator(\)) keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid size)delimiter(")>operator(\))operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(size)operator(\))operator(;) - - ident(RubyEnumerable)operator(.)ident(callEach)operator(()ident(runtime)operator(,) ident(context)operator(,) ident(self)operator(,) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(largs)operator(,) ident(Block) ident(blk)operator(\)) operator({) - keyword(if) operator(()ident(result)operator(.)ident(size)operator(()operator(\)) operator(==) ident(size)operator(\)) ident(result)operator(.)ident(shift)operator(()operator(\))operator(;) - ident(result)operator(.)ident(append)operator(()ident(largs)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(size)operator(()operator(\)) operator(==) ident(size)operator(\)) ident(block)operator(.)ident(yield)operator(()ident(ctx)operator(,) ident(result)operator(.)ident(aryDup)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(enum_slice)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(enum_slice)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(IRubyObject) ident(enumerator) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getEnumerator)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(enumerator)operator(,) string<delimiter(")content(new)delimiter(")>operator(,) ident(self)operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()string<delimiter(")content(each_slice)delimiter(")>operator(\))operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(enum_cons)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(enum_cons)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(IRubyObject) ident(enumerator) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getEnumerator)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(enumerator)operator(,) string<delimiter(")content(new)delimiter(")>operator(,) ident(self)operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()string<delimiter(")content(each_cons)delimiter(")>operator(\))operator(,) ident(arg)operator(\))operator(;) - operator(}) -operator(}) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.ext.posix.Passwd)operator(;) -keyword(import) include(org.jruby.ext.posix.Group)operator(;) -keyword(import) include(org.jruby.ext.posix.POSIX)operator(;) -keyword(import) include(org.jruby.ext.posix.util.Platform)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Etc)delimiter(")>operator(\)) -directive(public) type(class) class(RubyEtc) operator({) - directive(public) directive(static) ident(RubyModule) ident(createEtcModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(etcModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Etc)delimiter(")>operator(\))operator(;) - - ident(runtime)operator(.)ident(setEtc)operator(()ident(etcModule)operator(\))operator(;) - - ident(etcModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyEtc)operator(.)ident(class)operator(\))operator(;) - - ident(definePasswdStruct)operator(()ident(runtime)operator(\))operator(;) - ident(defineGroupStruct)operator(()ident(runtime)operator(\))operator(;) - - keyword(return) ident(etcModule)operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(definePasswdStruct)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) - ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(Passwd)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(name)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(passwd)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(uid)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(gid)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(gecos)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(dir)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(shell)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(change)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(uclass)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(expire)delimiter(")>operator(\)) - operator(})operator(;) - - ident(runtime)operator(.)ident(setPasswdStruct)operator(()ident(RubyStruct)operator(.)ident(newInstance)operator(()ident(runtime)operator(.)ident(getStructClass)operator(()operator(\))operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(defineGroupStruct)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) - ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(Group)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(name)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(passwd)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(gid)delimiter(")>operator(\))operator(,) - ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(mem)delimiter(")>operator(\)) - operator(})operator(;) - - ident(runtime)operator(.)ident(setGroupStruct)operator(()ident(RubyStruct)operator(.)ident(newInstance)operator(()ident(runtime)operator(.)ident(getStructClass)operator(()operator(\))operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(setupPasswd)operator(()ident(Ruby) ident(runtime)operator(,) ident(Passwd) ident(passwd)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getLoginName)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getPassword)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(passwd)operator(.)ident(getUID)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(passwd)operator(.)ident(getGID)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getGECOS)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getHome)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getShell)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(passwd)operator(.)ident(getPasswdChangeTime)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(passwd)operator(.)ident(getAccessClass)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(passwd)operator(.)ident(getExpire)operator(()operator(\))operator(\)) - - operator(})operator(;) - - keyword(return) ident(RubyStruct)operator(.)ident(newStruct)operator(()ident(runtime)operator(.)ident(getPasswdStruct)operator(()operator(\))operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - - directive(private) directive(static) ident(IRubyObject) ident(setupGroup)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Group) ident(group)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) - ident(runtime)operator(.)ident(newString)operator(()ident(group)operator(.)ident(getName)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()ident(group)operator(.)ident(getPassword)operator(()operator(\))operator(\))operator(,) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(group)operator(.)ident(getGID)operator(()operator(\))operator(\))operator(,) - ident(intoStringArray)operator(()ident(runtime)operator(,) ident(group)operator(.)ident(getMembers)operator(()operator(\))operator(\)) - operator(})operator(;) - - keyword(return) ident(RubyStruct)operator(.)ident(newStruct)operator(()ident(runtime)operator(.)ident(getGroupStruct)operator(()operator(\))operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(intoStringArray)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String)type([]) ident(members)operator(\)) operator({) - ident(IRubyObject)type([]) ident(arr) operator(=) keyword(new) ident(IRubyObject)operator([)ident(members)operator(.)ident(length)operator(])operator(;) - keyword(for)operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i)operator(<)ident(arr)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(arr)operator([)ident(i)operator(]) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(members)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(newArrayNoCopy)operator(()ident(arr)operator(\))operator(;) - operator(}) - - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpwuid)delimiter(")>operator(,) ident(optional)operator(=)integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpwuid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - type(int) ident(uid) operator(=) ident(args)operator(.)ident(length) operator(==) integer(0) operator(?) ident(posix)operator(.)ident(getuid)operator(()operator(\)) operator(:) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - ident(Passwd) ident(pwd) operator(=) ident(posix)operator(.)ident(getpwuid)operator(()ident(uid)operator(\))operator(;) - keyword(if)operator(()ident(pwd) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) comment(// MRI behavior) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't find user for )delimiter(")> operator(+) ident(uid)operator(\))operator(;) - operator(}) - keyword(return) ident(setupPasswd)operator(()ident(runtime)operator(,) ident(pwd)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpwnam)delimiter(")>operator(,) ident(required)operator(=)integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpwnam)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - pre_type(String) ident(nam) operator(=) ident(name)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(Passwd) ident(pwd) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpwnam)operator(()ident(nam)operator(\))operator(;) - keyword(if)operator(()ident(pwd) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) comment(// MRI behavior) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't find user for )delimiter(")> operator(+) ident(nam)operator(\))operator(;) - operator(}) - keyword(return) ident(setupPasswd)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pwd)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(passwd)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(passwd)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - keyword(if)operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(posix)operator(.)ident(setpwent)operator(()operator(\))operator(;) - ident(Passwd) ident(pw)operator(;) - keyword(while)operator(()operator(()ident(pw) operator(=) ident(posix)operator(.)ident(getpwent)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(setupPasswd)operator(()ident(runtime)operator(,) ident(pw)operator(\))operator(\))operator(;) - operator(}) - ident(posix)operator(.)ident(endpwent)operator(()operator(\))operator(;) - operator(}) - - ident(Passwd) ident(pw) operator(=) ident(posix)operator(.)ident(getpwent)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pw) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(setupPasswd)operator(()ident(runtime)operator(,) ident(pw)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getlogin)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getlogin)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - pre_type(String) ident(login) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getlogin)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(login) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(login)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(endpwent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(endpwent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(endpwent)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setpwent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setpwent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setpwent)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpwent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpwent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(Passwd) ident(passwd) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpwent)operator(()operator(\))operator(;) - keyword(if) operator(()ident(passwd) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(setupPasswd)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(passwd)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getgrnam)delimiter(")>operator(,) ident(required)operator(=)integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getgrnam)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - pre_type(String) ident(nam) operator(=) ident(name)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - pre_type(Group) ident(grp) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getgrnam)operator(()ident(nam)operator(\))operator(;) - keyword(if)operator(()ident(grp) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) comment(// MRI behavior) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't find group for )delimiter(")> operator(+) ident(nam)operator(\))operator(;) - operator(}) - keyword(return) ident(setupGroup)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(grp)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getgrgid)delimiter(")>operator(,) ident(optional)operator(=)integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getgrgid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - type(int) ident(gid) operator(=) ident(args)operator(.)ident(length) operator(==) integer(0) operator(?) ident(posix)operator(.)ident(getgid)operator(()operator(\)) operator(:) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - pre_type(Group) ident(gr) operator(=) ident(posix)operator(.)ident(getgrgid)operator(()ident(gid)operator(\))operator(;) - keyword(if)operator(()ident(gr) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) comment(// MRI behavior) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't find group for )delimiter(")> operator(+) ident(gid)operator(\))operator(;) - operator(}) - keyword(return) ident(setupGroup)operator(()ident(runtime)operator(,) ident(gr)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(endgrent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(endgrent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(endgrent)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setgrent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setgrent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setgrent)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(group)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(group)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - keyword(if)operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(posix)operator(.)ident(setgrent)operator(()operator(\))operator(;) - pre_type(Group) ident(gr)operator(;) - keyword(while)operator(()operator(()ident(gr) operator(=) ident(posix)operator(.)ident(getgrent)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(setupGroup)operator(()ident(runtime)operator(,) ident(gr)operator(\))operator(\))operator(;) - operator(}) - ident(posix)operator(.)ident(endgrent)operator(()operator(\))operator(;) - operator(}) - - pre_type(Group) ident(gr) operator(=) ident(posix)operator(.)ident(getgrent)operator(()operator(\))operator(;) - keyword(if) operator(()ident(gr) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(setupGroup)operator(()ident(runtime)operator(,) ident(gr)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getgrent)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getgrent)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Group) ident(gr) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getgrent)operator(()operator(\))operator(;) - keyword(if) operator(()ident(gr) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(setupGroup)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(gr)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 David Corbin <dcorbin@users.sf.net> - * Copyright (C\) 2006 Michael Studman <codehaus@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.PrintStream)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ObjectMarshal)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) -keyword(import) include(org.jruby.runtime.component.VariableEntry)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.SafePropertyAccessor)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Exception)delimiter(")>operator(\)) -directive(public) type(class) class(RubyException) directive(extends) ident(RubyObject) operator({) - directive(private) pre_type(StackTraceElement)type([]) ident(backtraceFrames)operator(;) - directive(private) pre_type(StackTraceElement)type([]) ident(javaStackTrace)operator(;) - directive(private) ident(IRubyObject) ident(backtrace)operator(;) - directive(public) ident(IRubyObject) ident(message)operator(;) - directive(public) directive(static) directive(final) type(int) ident(TRACE_HEAD) operator(=) integer(8)operator(;) - directive(public) directive(static) directive(final) type(int) ident(TRACE_TAIL) operator(=) integer(4)operator(;) - directive(public) directive(static) directive(final) type(int) ident(TRACE_MAX) operator(=) ident(TRACE_HEAD) operator(+) ident(TRACE_TAIL) operator(+) integer(6)operator(;) - - directive(protected) ident(RubyException)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyException)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(String) ident(message)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - - local_variable(this)operator(.)ident(message) operator(=) ident(message) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(newString)operator(()ident(message)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(EXCEPTION_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyException) ident(instance) operator(=) keyword(new) ident(RubyException)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - - comment(// for future compatibility as constructors move toward not accepting metaclass?) - ident(instance)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) directive(final) ident(ObjectMarshal) ident(EXCEPTION_MARSHAL) operator(=) keyword(new) ident(ObjectMarshal)operator(()operator(\)) operator({) - directive(public) type(void) ident(marshalTo)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Object) ident(obj)operator(,) ident(RubyClass) ident(type)operator(,) - ident(MarshalStream) ident(marshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyException) ident(exc) operator(=) operator(()ident(RubyException)operator(\))ident(obj)operator(;) - - ident(marshalStream)operator(.)ident(registerLinkTarget)operator(()ident(exc)operator(\))operator(;) - pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(attrs) operator(=) ident(exc)operator(.)ident(getVariableList)operator(()operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(() - string<delimiter(")content(mesg)delimiter(")>operator(,) ident(exc)operator(.)ident(message) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(exc)operator(.)ident(message)operator(\))operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(bt)delimiter(")>operator(,) ident(exc)operator(.)ident(getBacktrace)operator(()operator(\))operator(\))operator(\))operator(;) - ident(marshalStream)operator(.)ident(dumpVariables)operator(()ident(attrs)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(unmarshalFrom)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(,) - ident(UnmarshalStream) ident(unmarshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyException) ident(exc) operator(=) operator(()ident(RubyException)operator(\))ident(type)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(registerLinkTarget)operator(()ident(exc)operator(\))operator(;) - ident(unmarshalStream)operator(.)ident(defaultVariablesUnmarshal)operator(()ident(exc)operator(\))operator(;) - - ident(exc)operator(.)ident(message) operator(=) ident(exc)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(mesg)delimiter(")>operator(\))operator(;) - ident(exc)operator(.)ident(set_backtrace)operator(()ident(exc)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(bt)delimiter(")>operator(\))operator(\))operator(;) - - keyword(return) ident(exc)operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createExceptionClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(exceptionClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Exception)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(EXCEPTION_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setException)operator(()ident(exceptionClass)operator(\))operator(;) - - ident(exceptionClass)operator(.)ident(setMarshal)operator(()ident(EXCEPTION_MARSHAL)operator(\))operator(;) - ident(exceptionClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyException)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(exceptionClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyException) ident(newException)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(excptnClass)operator(,) pre_type(String) ident(msg)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyException)operator(()ident(runtime)operator(,) ident(excptnClass)operator(,) ident(msg)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setBacktraceFrames)operator(()pre_type(StackTraceElement)type([]) ident(backtraceFrames)operator(\)) operator({) - local_variable(this)operator(.)ident(backtraceFrames) operator(=) ident(backtraceFrames)operator(;) - keyword(if) operator(()ident(TRACE_TYPE) operator(==) ident(RAW) operator(||) - ident(TRACE_TYPE) operator(==) ident(RAW_FILTERED) operator(||) - ident(TRACE_TYPE) operator(==) ident(RUBY_COMPILED) operator(||) - ident(TRACE_TYPE) operator(==) ident(RUBY_HYBRID)operator(\)) operator({) - ident(javaStackTrace) operator(=) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\))operator(.)ident(getStackTrace)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) directive(final) type(int) ident(RAW) operator(=) integer(0)operator(;) - directive(public) directive(static) directive(final) type(int) ident(RAW_FILTERED) operator(=) integer(1)operator(;) - directive(public) directive(static) directive(final) type(int) ident(RUBY_FRAMED) operator(=) integer(2)operator(;) - directive(public) directive(static) directive(final) type(int) ident(RUBY_COMPILED) operator(=) integer(3)operator(;) - directive(public) directive(static) directive(final) type(int) ident(RUBY_HYBRID) operator(=) integer(4)operator(;) - - directive(public) directive(static) directive(final) type(int) ident(TRACE_TYPE)operator(;) - - directive(static) operator({) - pre_type(String) ident(style) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.backtrace.style)delimiter(")>operator(,) string<delimiter(")content(ruby_framed)delimiter(")>operator(\))operator(.)ident(toLowerCase)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(style)operator(.)ident(equals)operator(()string<delimiter(")content(raw)delimiter(")>operator(\))operator(\)) ident(TRACE_TYPE) operator(=) ident(RAW)operator(;) - keyword(else) keyword(if) operator(()ident(style)operator(.)ident(equals)operator(()string<delimiter(")content(raw_filtered)delimiter(")>operator(\))operator(\)) ident(TRACE_TYPE) operator(=) ident(RAW_FILTERED)operator(;) - keyword(else) keyword(if) operator(()ident(style)operator(.)ident(equals)operator(()string<delimiter(")content(ruby_framed)delimiter(")>operator(\))operator(\)) ident(TRACE_TYPE) operator(=) ident(RUBY_FRAMED)operator(;) - keyword(else) keyword(if) operator(()ident(style)operator(.)ident(equals)operator(()string<delimiter(")content(ruby_compiled)delimiter(")>operator(\))operator(\)) ident(TRACE_TYPE) operator(=) ident(RUBY_COMPILED)operator(;) - keyword(else) keyword(if) operator(()ident(style)operator(.)ident(equals)operator(()string<delimiter(")content(ruby_hybrid)delimiter(")>operator(\))operator(\)) ident(TRACE_TYPE) operator(=) ident(RUBY_HYBRID)operator(;) - keyword(else) ident(TRACE_TYPE) operator(=) ident(RUBY_FRAMED)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getBacktrace)operator(()operator(\)) operator({) - keyword(if) operator(()ident(backtrace) operator(==) pre_constant(null)operator(\)) operator({) - ident(initBacktrace)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(backtrace)operator(;) - operator(}) - - directive(public) type(void) ident(initBacktrace)operator(()operator(\)) operator({) - keyword(switch) operator(()ident(TRACE_TYPE)operator(\)) operator({) - keyword(case) ident(RAW)operator(:) - ident(backtrace) operator(=) ident(ThreadContext)operator(.)ident(createRawBacktrace)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(javaStackTrace)operator(,) pre_constant(false)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(RAW_FILTERED)operator(:) - ident(backtrace) operator(=) ident(ThreadContext)operator(.)ident(createRawBacktrace)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(javaStackTrace)operator(,) pre_constant(true)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(RUBY_FRAMED)operator(:) - ident(backtrace) operator(=) ident(backtraceFrames) operator(==) pre_constant(null) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(ThreadContext)operator(.)ident(createBacktraceFromFrames)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(backtraceFrames)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(RUBY_COMPILED)operator(:) - ident(backtrace) operator(=) ident(ThreadContext)operator(.)ident(createRubyCompiledBacktrace)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(javaStackTrace)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(RUBY_HYBRID)operator(:) - ident(backtrace) operator(=) ident(ThreadContext)operator(.)ident(createRubyHybridBacktrace)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(backtraceFrames)operator(,) ident(javaStackTrace)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - keyword(break)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) ident(message) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(backtrace)operator(()operator(\)) operator({) - keyword(return) ident(getBacktrace)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_backtrace)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(backtrace) operator(=) pre_constant(null)operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)ident(isArrayOfStrings)operator(()ident(obj)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(backtrace must be Array of String)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(backtrace) operator(=) operator(()ident(RubyArray)operator(\)) ident(obj)operator(;) - operator(}) - keyword(return) ident(backtrace)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exception)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exception)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyException) ident(exception)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0) operator(:) - keyword(return) local_variable(this)operator(;) - keyword(case) integer(1) operator(:) - keyword(if)operator(()ident(args)operator([)integer(0)operator(]) operator(==) local_variable(this)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - ident(RubyException) ident(ret) operator(=) operator(()ident(RubyException)operator(\))ident(rbClone)operator(()operator(\))operator(;) - ident(ret)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) comment(// This looks wrong, but it's the way MRI does it.) - keyword(return) ident(ret)operator(;) - keyword(default) operator(:) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(Wrong argument count)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if) operator(()ident(message)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - ident(message)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(message)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_str)delimiter(")>operator(,) string<delimiter(")content(message)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(to_str)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** inspects an object and return a kind of debug information - * - *@return A RubyString containing the debug information. - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyModule) ident(rubyClass) operator(=) ident(getMetaClass)operator(()operator(\))operator(;) - ident(RubyString) ident(exception) operator(=) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(exception)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(rubyClass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - pre_type(StringBuilder) ident(sb) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(;) - ident(sb)operator(.)ident(append)operator(()ident(rubyClass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(: )delimiter(")>operator(\))operator(.)ident(append)operator(()ident(exception)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(sb)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(printBacktrace)operator(()pre_type(PrintStream) ident(errorStream)operator(\)) operator({) - ident(IRubyObject) ident(backtrace) operator(=) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(backtrace)delimiter(")>operator(\))operator(;) - type(boolean) ident(debug) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(backtrace)operator(.)ident(isNil)operator(()operator(\)) operator(&&) ident(backtrace) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - ident(IRubyObject)type([]) ident(elements) operator(=) ident(backtrace)operator(.)ident(convertToArray)operator(()operator(\))operator(.)ident(toJavaArray)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(elements)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(stackTraceLine) operator(=) ident(elements)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(stackTraceLine) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(printStackTraceLine)operator(()ident(errorStream)operator(,) ident(stackTraceLine)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(debug) operator(&&) ident(i) operator(==) ident(RubyException)operator(.)ident(TRACE_HEAD) operator(&&) ident(elements)operator(.)ident(length) operator(>) ident(RubyException)operator(.)ident(TRACE_MAX)operator(\)) operator({) - type(int) ident(hiddenLevels) operator(=) ident(elements)operator(.)ident(length) operator(-) ident(RubyException)operator(.)ident(TRACE_HEAD) operator(-) ident(RubyException)operator(.)ident(TRACE_TAIL)operator(;) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")char(\\t)content( ... )delimiter(")> operator(+) ident(hiddenLevels) operator(+) string<delimiter(")content( levels...)char(\\n)delimiter(")>operator(\))operator(;) - ident(i) operator(=) ident(elements)operator(.)ident(length) operator(-) ident(RubyException)operator(.)ident(TRACE_TAIL)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - directive(private) type(void) ident(printStackTraceLine)operator(()pre_type(PrintStream) ident(errorStream)operator(,) ident(IRubyObject) ident(stackTraceLine)operator(\)) operator({) - ident(errorStream)operator(.)ident(print)operator(()string<delimiter(")char(\\t)content(from )delimiter(")> operator(+) ident(stackTraceLine) operator(+) string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isArrayOfStrings)operator(()ident(IRubyObject) ident(backtrace)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(backtrace) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - - ident(IRubyObject)type([]) ident(elements) operator(=) operator(()operator(()ident(RubyArray)operator(\)) ident(backtrace)operator(\))operator(.)ident(toJavaArray)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0) operator(;) ident(i) operator(<) ident(elements)operator(.)ident(length) operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(elements)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyString)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - operator(}) - - keyword(return) pre_constant(true)operator(;) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2003 Joey Gibson <joey@joeygibson.com> - * Copyright (C\) 2004-2007 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2007 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.util.io.OpenFile)operator(;) -keyword(import) include(org.jruby.util.io.ChannelDescriptor)operator(;) -keyword(import) include(java.io.File)operator(;) -keyword(import) include(java.io.FileDescriptor)operator(;) -keyword(import) include(java.io.FileNotFoundException)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.Reader)operator(;) -keyword(import) include(java.nio.channels.Channels)operator(;) -keyword(import) include(java.nio.channels.FileChannel)operator(;) -keyword(import) include(java.nio.channels.FileLock)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.ext.posix.util.Platform)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.io.DirectoryAsFileException)operator(;) -keyword(import) include(org.jruby.util.io.Stream)operator(;) -keyword(import) include(org.jruby.util.io.ChannelStream)operator(;) -keyword(import) include(org.jruby.util.io.ModeFlags)operator(;) -keyword(import) include(org.jruby.util.JRubyFile)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) -keyword(import) include(org.jruby.util.io.BadDescriptorException)operator(;) -keyword(import) include(org.jruby.util.io.FileExistsException)operator(;) -keyword(import) include(org.jruby.util.io.InvalidValueException)operator(;) -keyword(import) include(org.jruby.util.io.PipeException)operator(;) - -comment(/** - * Ruby File class equivalent in java. - **/) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(File)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(IO)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(FileTest)delimiter(")>operator(\)) -directive(public) type(class) class(RubyFile) directive(extends) ident(RubyIO) operator({) - directive(private) directive(static) directive(final) type(long) ident(serialVersionUID) operator(=) integer(1L)operator(;) - - directive(public) directive(static) directive(final) type(int) ident(LOCK_SH) operator(=) integer(1)operator(;) - directive(public) directive(static) directive(final) type(int) ident(LOCK_EX) operator(=) integer(2)operator(;) - directive(public) directive(static) directive(final) type(int) ident(LOCK_NB) operator(=) integer(4)operator(;) - directive(public) directive(static) directive(final) type(int) ident(LOCK_UN) operator(=) integer(8)operator(;) - - directive(private) directive(static) directive(final) type(int) ident(FNM_NOESCAPE) operator(=) integer(1)operator(;) - directive(private) directive(static) directive(final) type(int) ident(FNM_PATHNAME) operator(=) integer(2)operator(;) - directive(private) directive(static) directive(final) type(int) ident(FNM_DOTMATCH) operator(=) integer(4)operator(;) - directive(private) directive(static) directive(final) type(int) ident(FNM_CASEFOLD) operator(=) integer(8)operator(;) - directive(private) directive(static) directive(final) type(int) ident(FNM_SYSCASE)operator(;) - - directive(static) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) - ident(FNM_SYSCASE) operator(=) ident(FNM_CASEFOLD)operator(;) - operator(}) keyword(else) operator({) - ident(FNM_SYSCASE) operator(=) integer(0)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(boolean) ident(startsWithDriveLetterOnWindows)operator(()pre_type(String) ident(path)operator(\)) operator({) - keyword(return) operator(()ident(path) operator(!=) pre_constant(null)operator(\)) - operator(&&) ident(Platform)operator(.)ident(IS_WINDOWS) operator(&&) - operator(()operator(()ident(path)operator(.)ident(length)operator(()operator(\))operator(>)integer(1) operator(&&) ident(path)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator(?) - operator(()ident(path)operator(.)ident(length)operator(()operator(\)) operator(>) integer(2) - operator(&&) ident(isWindowsDriveLetter)operator(()ident(path)operator(.)ident(charAt)operator(()integer(1)operator(\))operator(\)) - operator(&&) ident(path)operator(.)ident(charAt)operator(()integer(2)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')>operator(\)) operator(:) - operator(()ident(path)operator(.)ident(length)operator(()operator(\)) operator(>) integer(1) - operator(&&) ident(isWindowsDriveLetter)operator(()ident(path)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\)) - operator(&&) ident(path)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')>operator(\))operator(\))operator(;) - operator(}) - comment(// adjusts paths started with '/' or '\\\\', on windows.) - directive(static) pre_type(String) ident(adjustRootPathOnWindows)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(,) pre_type(String) ident(dir)operator(\)) operator({) - keyword(if) operator(()ident(path) operator(==) pre_constant(null)operator(\)) keyword(return) ident(path)operator(;) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) - comment(// MRI behavior on Windows: it treats '/' as a root of) - comment(// a current drive (but only if SINGLE slash is present!\):) - comment(// E.g., if current work directory is) - comment(// 'D:/home/directory', then '/' means 'D:/'.) - comment(//) - comment(// Basically, '/path' is treated as a *RELATIVE* path,) - comment(// relative to the current drive. '//path' is treated) - comment(// as absolute one.) - keyword(if) operator(()operator(()ident(path)operator(.)ident(startsWith)operator(()string<delimiter(")content(/)delimiter(")>operator(\)) operator(&&) operator(!)operator(()ident(path)operator(.)ident(length)operator(()operator(\))operator(>)integer(2) operator(&&) ident(path)operator(.)ident(charAt)operator(()integer(2)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')>operator(\))operator(\)) operator(||) ident(path)operator(.)ident(startsWith)operator(()string<delimiter(")char(\\\\)delimiter(")>operator(\))operator(\)) operator({) - keyword(if) operator(()ident(path)operator(.)ident(length)operator(()operator(\)) operator(>) integer(1) operator(&&) operator(()ident(path)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')> operator(||) ident(path)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(\)) operator({) - keyword(return) ident(path)operator(;) - operator(}) - - comment(// First try to use drive letter from supplied dir value,) - comment(// then try current work dir.) - keyword(if) operator(()operator(!)ident(startsWithDriveLetterOnWindows)operator(()ident(dir)operator(\))operator(\)) operator({) - ident(dir) operator(=) ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(dir)operator(.)ident(length)operator(()operator(\)) operator(>=) integer(2)operator(\)) operator({) - ident(path) operator(=) ident(dir)operator(.)ident(substring)operator(()integer(0)operator(,) integer(2)operator(\)) operator(+) ident(path)operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(startsWithDriveLetterOnWindows)operator(()ident(path)operator(\)) operator(&&) ident(path)operator(.)ident(length)operator(()operator(\)) operator(==) integer(2)operator(\)) operator({) - comment(// compensate for missing slash after drive letter on windows) - ident(path) operator(+=) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) - operator(}) - keyword(return) ident(path)operator(;) - operator(}) - - directive(protected) pre_type(String) ident(path)operator(;) - directive(private) pre_type(FileLock) ident(currentLock)operator(;) - - directive(public) ident(RubyFile)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - comment(// XXX This constructor is a hack to implement the __END__ syntax.) - comment(// Converting a reader back into an InputStream doesn't generally work.) - directive(public) ident(RubyFile)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(,) directive(final) pre_type(Reader) ident(reader)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(path)operator(,) keyword(new) pre_type(InputStream)operator(()operator(\)) operator({) - directive(public) type(int) ident(read)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) ident(reader)operator(.)ident(read)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFile)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(,) pre_type(InputStream) ident(in)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(path) operator(=) ident(path)operator(;) - keyword(try) operator({) - local_variable(this)operator(.)ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(runtime)operator(,) keyword(new) ident(ChannelDescriptor)operator(()pre_type(Channels)operator(.)ident(newChannel)operator(()ident(in)operator(\))operator(,) ident(getNewFileno)operator(()operator(\))operator(,) keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(openFile)operator(.)ident(setMode)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getModes)operator(()operator(\))operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(FILE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyFile) ident(instance) operator(=) keyword(new) ident(RubyFile)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - - ident(instance)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(File::Constants)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Constants) operator({)operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createFileClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(fileClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(File)delimiter(")>operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(,) ident(FILE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setFile)operator(()ident(fileClass)operator(\))operator(;) - ident(RubyString) ident(separator) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - ident(fileClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyFile)operator(;) - operator(}) - operator(})operator(;) - - ident(separator)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(fileClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(SEPARATOR)delimiter(")>operator(,) ident(separator)operator(\))operator(;) - ident(fileClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(Separator)delimiter(")>operator(,) ident(separator)operator(\))operator(;) - - keyword(if) operator(()pre_type(File)operator(.)ident(separatorChar) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - ident(RubyString) ident(altSeparator) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")char(\\\\)delimiter(")>operator(\))operator(;) - ident(altSeparator)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(fileClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ALT_SEPARATOR)delimiter(")>operator(,) ident(altSeparator)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(fileClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ALT_SEPARATOR)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(RubyString) ident(pathSeparator) operator(=) ident(runtime)operator(.)ident(newString)operator(()pre_type(File)operator(.)ident(pathSeparator)operator(\))operator(;) - ident(pathSeparator)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(fileClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(PATH_SEPARATOR)delimiter(")>operator(,) ident(pathSeparator)operator(\))operator(;) - - comment(// TODO: why are we duplicating the constants here, and then in) - comment(// File::Constants below? File::Constants is included in IO.) - - comment(// TODO: These were missing, so we're not handling them elsewhere?) - comment(// FIXME: The old value, 32786, didn't match what IOModes expected, so I reference) - comment(// the constant here. THIS MAY NOT BE THE CORRECT VALUE.) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(BINARY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(BINARY)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_NOESCAPE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_NOESCAPE)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_CASEFOLD)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_CASEFOLD)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_SYSCASE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_SYSCASE)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_DOTMATCH)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_DOTMATCH)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_PATHNAME)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_PATHNAME)operator(\))operator(\))operator(;) - - comment(// Create constants for open flags) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(RDONLY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(RDONLY)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(WRONLY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(WRONLY)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(RDWR)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(RDWR)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(CREAT)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(CREAT)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(EXCL)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(EXCL)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(NOCTTY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(NOCTTY)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(TRUNC)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(TRUNC)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(APPEND)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(APPEND)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(NONBLOCK)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(NONBLOCK)operator(\))operator(\))operator(;) - - comment(// Create constants for flock) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_SH)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_SH)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_EX)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_EX)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_NB)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_NB)operator(\))operator(\))operator(;) - ident(fileClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_UN)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_UN)operator(\))operator(\))operator(;) - - comment(// Create Constants class) - ident(RubyModule) ident(constants) operator(=) ident(fileClass)operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(Constants)delimiter(")>operator(\))operator(;) - - comment(// TODO: These were missing, so we're not handling them elsewhere?) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(BINARY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(BINARY)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(SYNC)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()hex(0x1000)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_NOESCAPE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_NOESCAPE)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_CASEFOLD)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_CASEFOLD)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_SYSCASE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_SYSCASE)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_DOTMATCH)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_DOTMATCH)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(FNM_PATHNAME)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(FNM_PATHNAME)operator(\))operator(\))operator(;) - - comment(// Create constants for open flags) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(RDONLY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(RDONLY)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(WRONLY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(WRONLY)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(RDWR)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(RDWR)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(CREAT)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(CREAT)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(EXCL)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(EXCL)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(NOCTTY)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(NOCTTY)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(TRUNC)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(TRUNC)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(APPEND)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(APPEND)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(NONBLOCK)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(ModeFlags)operator(.)ident(NONBLOCK)operator(\))operator(\))operator(;) - - comment(// Create constants for flock) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_SH)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_SH)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_EX)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_EX)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_NB)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_NB)operator(\))operator(\))operator(;) - ident(constants)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(LOCK_UN)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RubyFile)operator(.)ident(LOCK_UN)operator(\))operator(\))operator(;) - - comment(// File::Constants module is included in IO.) - ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(.)ident(includeModule)operator(()ident(constants)operator(\))operator(;) - - ident(runtime)operator(.)ident(getFileTest)operator(()operator(\))operator(.)ident(extend_object)operator(()ident(fileClass)operator(\))operator(;) - - ident(fileClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFile)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(fileClass)operator(;) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - comment(// Make sure any existing lock is released before we try and close the file) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(super)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(flock)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(lockingConstant)operator(\)) operator({) - comment(// TODO: port exact behavior from MRI, and move most locking logic into ChannelDescriptor) - comment(// TODO: for all LOCK_NB cases, return false if they would block) - ident(ChannelDescriptor) ident(descriptor) operator(=) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - - comment(// null channel always succeeds for all locking operations) - keyword(if) operator(()ident(descriptor)operator(.)ident(isNull)operator(()operator(\))operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - pre_type(FileChannel) ident(fileChannel) operator(=) operator(()pre_type(FileChannel)operator(\))ident(descriptor)operator(.)ident(getChannel)operator(()operator(\))operator(;) - type(int) ident(lockMode) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(lockingConstant)operator(\))operator(;) - - comment(// Exclusive locks in Java require the channel to be writable, otherwise) - comment(// an exception is thrown (terminating JRuby execution\).) - comment(// But flock behavior of MRI is that it allows) - comment(// exclusive locks even on non-writable file. So we convert exclusive) - comment(// lock to shared lock if the channel is not writable, to better match) - comment(// the MRI behavior.) - keyword(if) operator(()operator(!)ident(openFile)operator(.)ident(isWritable)operator(()operator(\)) operator(&&) operator(()ident(lockMode) operator(&) ident(LOCK_EX)operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(lockMode) operator(=) operator(()ident(lockMode) operator(^) ident(LOCK_EX)operator(\)) operator(|) ident(LOCK_SH)operator(;) - operator(}) - - keyword(try) operator({) - keyword(switch) operator(()ident(lockMode)operator(\)) operator({) - keyword(case) ident(LOCK_UN)operator(:) - keyword(case) ident(LOCK_UN) operator(|) ident(LOCK_NB)operator(:) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - ident(currentLock) operator(=) pre_constant(null)operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(break)operator(;) - keyword(case) ident(LOCK_EX)operator(:) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - ident(currentLock) operator(=) pre_constant(null)operator(;) - operator(}) - ident(currentLock) operator(=) ident(fileChannel)operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(break)operator(;) - keyword(case) ident(LOCK_EX) operator(|) ident(LOCK_NB)operator(:) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - ident(currentLock) operator(=) pre_constant(null)operator(;) - operator(}) - ident(currentLock) operator(=) ident(fileChannel)operator(.)ident(tryLock)operator(()operator(\))operator(;) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(break)operator(;) - keyword(case) ident(LOCK_SH)operator(:) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - ident(currentLock) operator(=) pre_constant(null)operator(;) - operator(}) - - ident(currentLock) operator(=) ident(fileChannel)operator(.)ident(lock)operator(()integer(0L)operator(,) pre_type(Long)operator(.)ident(MAX_VALUE)operator(,) pre_constant(true)operator(\))operator(;) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(break)operator(;) - keyword(case) ident(LOCK_SH) operator(|) ident(LOCK_NB)operator(:) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentLock)operator(.)ident(release)operator(()operator(\))operator(;) - ident(currentLock) operator(=) pre_constant(null)operator(;) - operator(}) - - ident(currentLock) operator(=) ident(fileChannel)operator(.)ident(tryLock)operator(()integer(0L)operator(,) pre_type(Long)operator(.)ident(MAX_VALUE)operator(,) pre_constant(true)operator(\))operator(;) - keyword(if) operator(()ident(currentLock) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(break)operator(;) - keyword(default)operator(:) - operator(}) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(ioe)operator(.)ident(printStackTrace)operator(()pre_type(System)operator(.)ident(err)operator(\))operator(;) - operator(}) - comment(// Return false here) - operator(}) keyword(catch) operator(()ident(java)operator(.)ident(nio)operator(.)ident(channels)operator(.)ident(OverlappingFileLockException) ident(ioe)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(ioe)operator(.)ident(printStackTrace)operator(()pre_type(System)operator(.)ident(err)operator(\))operator(;) - operator(}) - comment(// Return false here) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(openFile) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(reinitializing File)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0) operator(&&) ident(args)operator(.)ident(length) operator(<) integer(3)operator(\)) operator({) - ident(IRubyObject) ident(fd) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getFixnum)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_INT)operator(,) string<delimiter(")content(to_int)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(fd)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(args)operator([)integer(0)operator(]) operator(=) ident(fd)operator(;) - keyword(return) local_variable(super)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(openFile)operator(()ident(args)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(openFile)operator(()ident(IRubyObject) ident(args)type([])operator(\)) operator({) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(checkSafeString)operator(()ident(filename)operator(\))operator(;) - - ident(path) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getUnicodeValue)operator(()operator(\))operator(;) - - pre_type(String) ident(modeString)operator(;) - ident(ModeFlags) ident(modes)operator(;) - type(int) ident(perm)operator(;) - - keyword(try) operator({) - keyword(if) operator(()operator(()ident(args)operator(.)ident(length) operator(>) integer(1) operator(&&) ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator(||) operator(()ident(args)operator(.)ident(length) operator(>) integer(2) operator(&&) operator(!)ident(args)operator([)integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modeString) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(modes) operator(=) ident(getIOModes)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(modeString)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2) operator(&&) operator(!)ident(args)operator([)integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(perm) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(perm) operator(=) integer(438)operator(;) comment(// 0666) - operator(}) - - ident(sysopenInternal)operator(()ident(path)operator(,) ident(modes)operator(,) ident(perm)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modeString) operator(=) string<delimiter(")content(r)delimiter(")>operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(modeString) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - operator(}) - ident(openInternal)operator(()ident(path)operator(,) ident(modeString)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({)operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) type(void) ident(sysopenInternal)operator(()pre_type(String) ident(path)operator(,) ident(ModeFlags) ident(modes)operator(,) type(int) ident(perm)operator(\)) directive(throws) ident(InvalidValueException) operator({) - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - ident(openFile)operator(.)ident(setPath)operator(()ident(path)operator(\))operator(;) - ident(openFile)operator(.)ident(setMode)operator(()ident(modes)operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - - ident(ChannelDescriptor) ident(descriptor) operator(=) ident(sysopen)operator(()ident(path)operator(,) ident(modes)operator(,) ident(perm)operator(\))operator(;) - ident(openFile)operator(.)ident(setMainStream)operator(()ident(fdopen)operator(()ident(descriptor)operator(,) ident(modes)operator(\))operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(descriptor)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(openInternal)operator(()pre_type(String) ident(path)operator(,) pre_type(String) ident(modeString)operator(\)) directive(throws) ident(InvalidValueException) operator({) - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - ident(openFile)operator(.)ident(setMode)operator(()ident(getIOModes)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(modeString)operator(\))operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - ident(openFile)operator(.)ident(setPath)operator(()ident(path)operator(\))operator(;) - ident(openFile)operator(.)ident(setMainStream)operator(()ident(fopen)operator(()ident(path)operator(,) ident(modeString)operator(\))operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(ChannelDescriptor) ident(sysopen)operator(()pre_type(String) ident(path)operator(,) ident(ModeFlags) ident(modes)operator(,) type(int) ident(perm)operator(\)) directive(throws) ident(InvalidValueException) operator({) - keyword(try) operator({) - ident(ChannelDescriptor) ident(descriptor) operator(=) ident(ChannelDescriptor)operator(.)ident(open)operator(() - ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) - ident(path)operator(,) - ident(modes)operator(,) - ident(perm)operator(,) - ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(\))operator(;) - - comment(// TODO: check if too many open files, GC and try again) - - keyword(return) ident(descriptor)operator(;) - operator(}) keyword(catch) operator(()exception(FileNotFoundException) ident(fnfe)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(DirectoryAsFileException) ident(dafe)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEISDirError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(FileExistsException) ident(fee)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEEXISTError)operator(()string<delimiter(")content(file exists: )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ioe)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(Stream) ident(fopen)operator(()pre_type(String) ident(path)operator(,) pre_type(String) ident(modeString)operator(\)) operator({) - keyword(try) operator({) - ident(Stream) ident(stream) operator(=) ident(ChannelStream)operator(.)ident(fopen)operator(() - ident(getRuntime)operator(()operator(\))operator(,) - ident(path)operator(,) - ident(getIOModes)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(modeString)operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(stream) operator(==) pre_constant(null)operator(\)) operator({) - comment(// TODO) - comment(// if (errno == EMFILE || errno == ENFILE\) {) - comment(// rb_gc(\);) - comment(// file = fopen(fname, mode\);) - comment(// }) - comment(// if (!file\) {) - comment(// rb_sys_fail(fname\);) - comment(// }) - operator(}) - - comment(// Do we need to be in SETVBUF mode for buffering to make sense? This comes up elsewhere.) - comment(// #ifdef USE_SETVBUF) - comment(// if (setvbuf(file, NULL, _IOFBF, 0\) != 0\)) - comment(// rb_warn("setvbuf(\) can't be honoured for %s", fname\);) - comment(// #endif) - comment(// #ifdef __human68k__) - comment(// fmode(file, _IOTEXT\);) - comment(// #endif) - keyword(return) ident(stream)operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(FileNotFoundException) ident(ex)operator(\)) operator({) - comment(// FNFException can be thrown in both cases, when the file) - comment(// is not found, or when permission is denied.) - keyword(if) operator(()ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\)) operator(||) keyword(new) pre_type(File)operator(()ident(path)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEACCESError)operator(() - string<delimiter(")content(Permission denied - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(() - string<delimiter(")content(File not found - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(DirectoryAsFileException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEISDirError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(FileExistsException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEEXISTError)operator(()ident(path)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(chmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(int) ident(mode) operator(=) operator(()type(int)operator(\)) ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(path)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(chmod)operator(()ident(path)operator(,) ident(mode)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(chown)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - type(int) ident(owner) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(arg1)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(owner) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg1)operator(\))operator(;) - operator(}) - - type(int) ident(group) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(arg2)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(group) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg2)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(path)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(chown)operator(()ident(path)operator(,) ident(owner)operator(,) ident(group)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(atime)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(path)operator(,) pre_constant(false)operator(\))operator(.)ident(atime)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(ctime)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(path)operator(,) pre_constant(false)operator(\))operator(.)ident(ctime)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(lchmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(int) ident(mode) operator(=) operator(()type(int)operator(\)) ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(path)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lchmod)operator(()ident(path)operator(,) ident(mode)operator(\))operator(\))operator(;) - operator(}) - - comment(// TODO: this method is not present in MRI!) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(lchown)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - type(int) ident(owner) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(arg1)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(owner) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg1)operator(\))operator(;) - operator(}) - - type(int) ident(group) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(arg2)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(group) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg2)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(path)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lchown)operator(()ident(path)operator(,) ident(owner)operator(,) ident(group)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(lstat)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(path)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(mtime)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(getLastModified)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(path)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(path)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(path)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(stat)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(path)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(truncate)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyInteger) ident(newLength) operator(=) ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(if) operator(()ident(newLength)operator(.)ident(getLongValue)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(invalid argument: )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - keyword(try) operator({) - ident(openFile)operator(.)ident(checkWritable)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(ftruncate)operator(()ident(newLength)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - comment(// Should we do anything?) - operator(}) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(String) ident(toString)operator(()operator(\)) operator({) - keyword(return) string<delimiter(")content(RubyFile()delimiter(")> operator(+) ident(path) operator(+) string<delimiter(")content(, )delimiter(")> operator(+) ident(openFile)operator(.)ident(getMode)operator(()operator(\)) operator(+) string<delimiter(")content(, )delimiter(")> operator(+) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\)) operator(+) string<delimiter(")content(\))delimiter(")>operator(;) - operator(}) - - comment(// TODO: This is also defined in the MetaClass too...Consolidate somewhere.) - directive(private) directive(static) ident(ModeFlags) ident(getModes)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(object)operator(\)) directive(throws) ident(InvalidValueException) operator({) - keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(getIOModes)operator(()ident(runtime)operator(,) operator(()operator(()ident(RubyString)operator(\)) ident(object)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) keyword(new) ident(ModeFlags)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(object)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(Invalid type for modes)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(val) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(val)operator(.)ident(append)operator(()string<delimiter(")content(#<File:)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(path)operator(\))operator(;) - keyword(if)operator(()operator(!)ident(openFile)operator(.)ident(isOpen)operator(()operator(\))operator(\)) operator({) - ident(val)operator(.)ident(append)operator(()string<delimiter(")content( (closed\))delimiter(")>operator(\))operator(;) - operator(}) - ident(val)operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(val)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* File class methods */) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(basename)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - comment(// MRI-compatible basename handling for windows drive letter paths) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) - keyword(if) operator(()ident(name)operator(.)ident(length)operator(()operator(\)) operator(>) integer(1) operator(&&) ident(name)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')> operator(&&) pre_type(Character)operator(.)ident(isLetter)operator(()ident(name)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\))operator(\)) operator({) - keyword(switch) operator(()ident(name)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(case) integer(2)operator(:) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(infectBy)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(3)operator(:) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(name)operator(.)ident(substring)operator(()integer(2)operator(\))operator(\))operator(.)ident(infectBy)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - keyword(switch) operator(()ident(name)operator(.)ident(charAt)operator(()integer(2)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(/)delimiter(')>operator(:) - keyword(case) string<delimiter(')char(\\\\)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(default)operator(:) - comment(// strip c: away from relative-pathed name) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(2)operator(\))operator(;) - keyword(break)operator(;) - operator(}) - keyword(break)operator(;) - operator(}) - operator(}) - operator(}) - - keyword(while) operator(()ident(name)operator(.)ident(length)operator(()operator(\)) operator(>) integer(1) operator(&&) ident(name)operator(.)ident(charAt)operator(()ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(0)operator(,) ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - operator(}) - - comment(// Paths which end in "/" or "\\\\" must be stripped off.) - type(int) ident(slashCount) operator(=) integer(0)operator(;) - type(int) ident(length) operator(=) ident(name)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(length) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - type(char) ident(c) operator(=) ident(name)operator(.)ident(charAt)operator(()ident(i)operator(\))operator(;) - keyword(if) operator(()ident(c) operator(!=) string<delimiter(')content(/)delimiter(')> operator(&&) ident(c) operator(!=) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(slashCount)operator(++)operator(;) - operator(}) - keyword(if) operator(()ident(slashCount) operator(>) integer(0) operator(&&) ident(length) operator(>) integer(1)operator(\)) operator({) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(0)operator(,) ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) ident(slashCount)operator(\))operator(;) - operator(}) - - type(int) ident(index) operator(=) ident(name)operator(.)ident(lastIndexOf)operator(()string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(index) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// XXX actually only on windows...) - ident(index) operator(=) ident(name)operator(.)ident(lastIndexOf)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(/)delimiter(")>operator(\)) operator(&&) ident(index) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()ident(index) operator(+) integer(1)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2)operator(\)) operator({) - pre_type(String) ident(ext) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if) operator(()string<delimiter(")content(.*)delimiter(")>operator(.)ident(equals)operator(()ident(ext)operator(\))operator(\)) operator({) - ident(index) operator(=) ident(name)operator(.)ident(lastIndexOf)operator(()string<delimiter(')content(.)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(index) operator(>) integer(0)operator(\)) operator({) comment(// -1 no match; 0 it is dot file not extension) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(0)operator(,) ident(index)operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(name)operator(.)ident(endsWith)operator(()ident(ext)operator(\))operator(\)) operator({) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(0)operator(,) ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) ident(ext)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(name)operator(\))operator(.)ident(infectBy)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - type(int) ident(count) operator(=) integer(0)operator(;) - ident(RubyInteger) ident(mode) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(filename)operator(,) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(filename)operator(\))operator(;) - operator(}) - - type(boolean) ident(result) operator(=) integer(0) operator(==) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(chmod)operator(()ident(filename)operator(.)ident(toString)operator(()operator(\))operator(,) operator(()type(int)operator(\))ident(mode)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(result)operator(\)) operator({) - ident(count)operator(++)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(count)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(3)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chown)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - type(int) ident(count) operator(=) integer(0)operator(;) - type(int) ident(owner) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(owner) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - type(int) ident(group) operator(=) operator(-)integer(1)operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(group) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(2)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(filename)operator(,) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(filename)operator(\))operator(;) - operator(}) - - type(boolean) ident(result) operator(=) integer(0) operator(==) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(chown)operator(()ident(filename)operator(.)ident(toString)operator(()operator(\))operator(,) ident(owner)operator(,) ident(group)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(\)) operator({) - ident(count)operator(++)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(count)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dirname)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyString) ident(filename) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(arg)operator(\))operator(;) - pre_type(String) ident(jfilename) operator(=) ident(filename)operator(.)ident(toString)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) ident(jfilename)operator(.)ident(replace)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(,) string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - type(int) ident(minPathLength) operator(=) integer(1)operator(;) - type(boolean) ident(trimmedSlashes) operator(=) pre_constant(false)operator(;) - - type(boolean) ident(startsWithDriveLetterOnWindows) operator(=) ident(startsWithDriveLetterOnWindows)operator(()ident(name)operator(\))operator(;) - - keyword(if) operator(()ident(startsWithDriveLetterOnWindows)operator(\)) operator({) - ident(minPathLength) operator(=) integer(3)operator(;) - operator(}) - - keyword(while) operator(()ident(name)operator(.)ident(length)operator(()operator(\)) operator(>) ident(minPathLength) operator(&&) ident(name)operator(.)ident(charAt)operator(()ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(trimmedSlashes) operator(=) pre_constant(true)operator(;) - ident(name) operator(=) ident(name)operator(.)ident(substring)operator(()integer(0)operator(,) ident(name)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - operator(}) - - pre_type(String) ident(result)operator(;) - keyword(if) operator(()ident(startsWithDriveLetterOnWindows) operator(&&) ident(name)operator(.)ident(length)operator(()operator(\)) operator(==) integer(2)operator(\)) operator({) - keyword(if) operator(()ident(trimmedSlashes)operator(\)) operator({) - comment(// C:\\ is returned unchanged) - ident(result) operator(=) ident(jfilename)operator(.)ident(substring)operator(()integer(0)operator(,) integer(3)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) ident(jfilename)operator(.)ident(substring)operator(()integer(0)operator(,) integer(2)operator(\)) operator(+) string<delimiter(')content(.)delimiter(')>operator(;) - operator(}) - operator(}) keyword(else) operator({) - comment(//TODO deal with UNC names) - type(int) ident(index) operator(=) ident(name)operator(.)ident(lastIndexOf)operator(()string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(index) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(if) operator(()ident(startsWithDriveLetterOnWindows)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(jfilename)operator(.)ident(substring)operator(()integer(0)operator(,) integer(2)operator(\)) operator(+) string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(index) operator(==) integer(0)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(startsWithDriveLetterOnWindows) operator(&&) ident(index) operator(==) integer(2)operator(\)) operator({) - comment(// Include additional path separator) - comment(// (so that dirname of "C:\\file.txt" is "C:\\", not "C:"\)) - ident(index)operator(++)operator(;) - operator(}) - - ident(result) operator(=) ident(jfilename)operator(.)ident(substring)operator(()integer(0)operator(,) ident(index)operator(\))operator(;) - operator(}) - - type(char) ident(endChar)operator(;) - comment(// trim trailing slashes) - keyword(while) operator(()ident(result)operator(.)ident(length)operator(()operator(\)) operator(>) ident(minPathLength)operator(\)) operator({) - ident(endChar) operator(=) ident(result)operator(.)ident(charAt)operator(()ident(result)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - keyword(if) operator(()ident(endChar) operator(==) string<delimiter(')content(/)delimiter(')> operator(||) ident(endChar) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - ident(result) operator(=) ident(result)operator(.)ident(substring)operator(()integer(0)operator(,) ident(result)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(result)operator(\))operator(.)ident(infectBy)operator(()ident(filename)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(isWindowsDriveLetter)operator(()type(char) ident(c)operator(\)) operator({) - keyword(return) operator(()ident(c) operator(>=) string<delimiter(')content(a)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(z)delimiter(')>operator(\)) operator(||) operator(()ident(c) operator(>=) string<delimiter(')content(A)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(Z)delimiter(')>operator(\))operator(;) - operator(}) - - - comment(/** - * Returns the extension name of the file. An empty string is returned if - * the filename (not the entire path\) starts or ends with a dot. - * @param recv - * @param arg Path to get extension name of - * @return Extension, including the dot, or an empty string - */) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(extname)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(IRubyObject) ident(baseFilename) operator(=) ident(basename)operator(()ident(context)operator(,) ident(recv)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(arg)operator(})operator(\))operator(;) - pre_type(String) ident(filename) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(baseFilename)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - pre_type(String) ident(result) operator(=) string<delimiter(")delimiter(")>operator(;) - - type(int) ident(dotIndex) operator(=) ident(filename)operator(.)ident(lastIndexOf)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(dotIndex) operator(>) integer(0) operator(&&) ident(dotIndex) operator(!=) operator(()ident(filename)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\))operator(\)) operator({) - comment(// Dot is not at beginning and not at end of filename. ) - ident(result) operator(=) ident(filename)operator(.)ident(substring)operator(()ident(dotIndex)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(result)operator(\))operator(;) - operator(}) - - comment(/** - * Converts a pathname to an absolute pathname. Relative paths are - * referenced from the current working directory of the process unless - * a second argument is given, in which case it will be used as the - * starting point. If the second argument is also relative, it will - * first be converted to an absolute pathname. - * @param recv - * @param args - * @return Resulting absolute path as a String - */) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(expand_path)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - pre_type(String) ident(relativePath) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - type(boolean) ident(isAbsoluteWithFilePrefix) operator(=) ident(relativePath)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\))operator(;) - - pre_type(String) ident(cwd) operator(=) pre_constant(null)operator(;) - - comment(// Handle ~user paths ) - ident(relativePath) operator(=) ident(expandUserPath)operator(()ident(context)operator(,) ident(relativePath)operator(\))operator(;) - - comment(// If there's a second argument, it's the path to which the first ) - comment(// argument is relative.) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2) operator(&&) operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - - pre_type(String) ident(cwdArg) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - comment(// Handle ~user paths.) - ident(cwd) operator(=) ident(expandUserPath)operator(()ident(context)operator(,) ident(cwdArg)operator(\))operator(;) - - ident(cwd) operator(=) ident(adjustRootPathOnWindows)operator(()ident(runtime)operator(,) ident(cwd)operator(,) pre_constant(null)operator(\))operator(;) - - type(boolean) ident(startsWithSlashNotOnWindows) operator(=) operator(()ident(cwd) operator(!=) pre_constant(null)operator(\)) - operator(&&) operator(!)ident(Platform)operator(.)ident(IS_WINDOWS) operator(&&) ident(cwd)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) - operator(&&) ident(cwd)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(;) - - comment(// TODO: better detection when path is absolute or not.) - comment(// If the path isn't absolute, then prepend the current working) - comment(// directory to the path.) - keyword(if) operator(()operator(!)ident(startsWithSlashNotOnWindows) operator(&&) operator(!)ident(startsWithDriveLetterOnWindows)operator(()ident(cwd)operator(\))operator(\)) operator({) - ident(cwd) operator(=) keyword(new) pre_type(File)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(cwd)operator(\))operator(.)ident(getAbsolutePath)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - comment(// If there's no second argument, simply use the working directory ) - comment(// of the runtime.) - ident(cwd) operator(=) ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(;) - operator(}) - - comment(// Something wrong we don't know the cwd...) - comment(// TODO: Is this behavior really desirable? /mov) - keyword(if) operator(()ident(cwd) operator(==) pre_constant(null)operator(\)) keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - comment(/* The counting of slashes that follows is simply a way to adhere to - * Ruby's UNC (or something\) compatibility. When Ruby's expand_path is - * called with "//foo//bar" it will return "//foo/bar". JRuby uses - * java.io.File, and hence returns "/foo/bar". In order to retain - * java.io.File in the lower layers and provide full Ruby - * compatibility, the number of extra slashes must be counted and - * prepended to the result. - */) - - comment(// TODO: special handling on windows for some corner cases) -comment(// if (IS_WINDOWS\) {) -comment(// if (relativePath.startsWith("//"\)\) {) -comment(// if (relativePath.length(\) > 2 && relativePath.charAt(2\) != '/'\) {) -comment(// int nextSlash = relativePath.indexOf('/', 3\);) -comment(// if (nextSlash != -1\) {) -comment(// return runtime.newString() -comment(// relativePath.substring(0, nextSlash\)) -comment(// + canonicalize(relativePath.substring(nextSlash\)\)\);) -comment(// } else {) -comment(// return runtime.newString(relativePath\);) -comment(// }) -comment(// }) -comment(// }) -comment(// }) - - comment(// Find out which string to check.) - pre_type(String) ident(padSlashes) operator(=) string<delimiter(")delimiter(")>operator(;) - keyword(if) operator(()operator(!)ident(Platform)operator(.)ident(IS_WINDOWS)operator(\)) operator({) - keyword(if) operator(()ident(relativePath)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(relativePath)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(padSlashes) operator(=) ident(countSlashes)operator(()ident(relativePath)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(cwd)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(cwd)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(padSlashes) operator(=) ident(countSlashes)operator(()ident(cwd)operator(\))operator(;) - operator(}) - operator(}) - - ident(JRubyFile) ident(path)operator(;) - - keyword(if) operator(()ident(relativePath)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(path) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(relativePath)operator(,) ident(cwd)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(relativePath) operator(=) ident(adjustRootPathOnWindows)operator(()ident(runtime)operator(,) ident(relativePath)operator(,) ident(cwd)operator(\))operator(;) - ident(path) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(cwd)operator(,) ident(relativePath)operator(\))operator(;) - operator(}) - - pre_type(String) ident(tempResult) operator(=) ident(padSlashes) operator(+) ident(canonicalize)operator(()ident(path)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(;) - - keyword(if)operator(()ident(isAbsoluteWithFilePrefix)operator(\)) operator({) - ident(tempResult) operator(=) ident(tempResult)operator(.)ident(substring)operator(()ident(tempResult)operator(.)ident(indexOf)operator(()string<delimiter(")content(file:)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(tempResult)operator(\))operator(;) - operator(}) - - comment(/** - * This method checks a path, and if it starts with ~, then it expands - * the path to the absolute path of the user's home directory. If the - * string does not begin with ~, then the string is simply returned. - * unaltered. - * @param recv - * @param path Path to check - * @return Expanded path - */) - directive(public) directive(static) pre_type(String) ident(expandUserPath)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(path)operator(\)) operator({) - - type(int) ident(pathLength) operator(=) ident(path)operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pathLength) operator(>=) integer(1) operator(&&) ident(path)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(~)delimiter(')>operator(\)) operator({) - comment(// Enebo : Should ~frogger\\\\foo work (it doesnt in linux ruby\)?) - type(int) ident(userEnd) operator(=) ident(path)operator(.)ident(indexOf)operator(()string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - - keyword(if) operator(()ident(userEnd) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(if) operator(()ident(pathLength) operator(==) integer(1)operator(\)) operator({) - comment(// Single '~' as whole path to expand) - ident(path) operator(=) ident(RubyDir)operator(.)ident(getHomeDirectoryPath)operator(()ident(context)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// No directory delimeter. Rest of string is username) - ident(userEnd) operator(=) ident(pathLength)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(userEnd) operator(==) integer(1)operator(\)) operator({) - comment(// '~/...' as path to expand) - ident(path) operator(=) ident(RubyDir)operator(.)ident(getHomeDirectoryPath)operator(()ident(context)operator(\))operator(.)ident(toString)operator(()operator(\)) operator(+) - ident(path)operator(.)ident(substring)operator(()integer(1)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(userEnd) operator(>) integer(1)operator(\))operator({) - comment(// '~user/...' as path to expand) - pre_type(String) ident(user) operator(=) ident(path)operator(.)ident(substring)operator(()integer(1)operator(,) ident(userEnd)operator(\))operator(;) - ident(IRubyObject) ident(dir) operator(=) ident(RubyDir)operator(.)ident(getHomeDirectoryPath)operator(()ident(context)operator(,) ident(user)operator(\))operator(;) - - keyword(if) operator(()ident(dir)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(user )delimiter(")> operator(+) ident(user) operator(+) string<delimiter(")content( does not exist)delimiter(")>operator(\))operator(;) - operator(}) - - ident(path) operator(=) string<delimiter(")delimiter(")> operator(+) ident(dir) operator(+) operator(()ident(pathLength) operator(==) ident(userEnd) operator(?) string<delimiter(")delimiter(")> operator(:) ident(path)operator(.)ident(substring)operator(()ident(userEnd)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(path)operator(;) - operator(}) - - comment(/** - * Returns a string consisting of <code>n-1</code> slashes, where - * <code>n</code> is the number of slashes at the beginning of the input - * string. - * @param stringToCheck - * @return - */) - directive(private) directive(static) pre_type(String) ident(countSlashes)operator(() pre_type(String) ident(stringToCheck) operator(\)) operator({) - - comment(// Count number of extra slashes in the beginning of the string.) - type(int) ident(slashCount) operator(=) integer(0)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(stringToCheck)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(stringToCheck)operator(.)ident(charAt)operator(()ident(i)operator(\)) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(slashCount)operator(++)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - comment(// If there are N slashes, then we want N-1.) - keyword(if) operator(()ident(slashCount) operator(>) integer(0)operator(\)) operator({) - ident(slashCount)operator(--)operator(;) - operator(}) - - comment(// Prepare a string with the same number of redundant slashes so that ) - comment(// we easily can prepend it to the result.) - type(byte)type([]) ident(slashes) operator(=) keyword(new) type(byte)operator([)ident(slashCount)operator(])operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(slashCount)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(slashes)operator([)ident(i)operator(]) operator(=) string<delimiter(')content(/)delimiter(')>operator(;) - operator(}) - keyword(return) keyword(new) pre_type(String)operator(()ident(slashes)operator(\))operator(;) - - operator(}) - - directive(private) directive(static) pre_type(String) ident(canonicalize)operator(()pre_type(String) ident(path)operator(\)) operator({) - keyword(return) ident(canonicalize)operator(()pre_constant(null)operator(,) ident(path)operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String) ident(canonicalize)operator(()pre_type(String) ident(canonicalPath)operator(,) pre_type(String) ident(remaining)operator(\)) operator({) - keyword(if) operator(()ident(remaining) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()string<delimiter(")delimiter(")>operator(.)ident(equals)operator(()ident(canonicalPath)operator(\))operator(\)) operator({) - keyword(return) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - comment(// compensate for missing slash after drive letter on windows) - keyword(if) operator(()ident(startsWithDriveLetterOnWindows)operator(()ident(canonicalPath)operator(\)) - operator(&&) ident(canonicalPath)operator(.)ident(length)operator(()operator(\)) operator(==) integer(2)operator(\)) operator({) - ident(canonicalPath) operator(+=) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) - operator(}) - keyword(return) ident(canonicalPath)operator(;) - operator(}) - - pre_type(String) ident(child)operator(;) - type(int) ident(slash) operator(=) ident(remaining)operator(.)ident(indexOf)operator(()string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(slash) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(child) operator(=) ident(remaining)operator(;) - ident(remaining) operator(=) pre_constant(null)operator(;) - operator(}) keyword(else) operator({) - ident(child) operator(=) ident(remaining)operator(.)ident(substring)operator(()integer(0)operator(,) ident(slash)operator(\))operator(;) - ident(remaining) operator(=) ident(remaining)operator(.)ident(substring)operator(()ident(slash) operator(+) integer(1)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(child)operator(.)ident(equals)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(\)) operator({) - comment(// skip it) - keyword(if) operator(()ident(canonicalPath) operator(!=) pre_constant(null) operator(&&) ident(canonicalPath)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0) operator(\)) ident(canonicalPath) operator(+=) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(child)operator(.)ident(equals)operator(()string<delimiter(")content(..)delimiter(")>operator(\))operator(\)) operator({) - keyword(if) operator(()ident(canonicalPath) operator(==) pre_constant(null)operator(\)) keyword(throw) keyword(new) exception(IllegalArgumentException)operator(()string<delimiter(")content(Cannot have .. at the start of an absolute path)delimiter(")>operator(\))operator(;) - type(int) ident(lastDir) operator(=) ident(canonicalPath)operator(.)ident(lastIndexOf)operator(()string<delimiter(')content(/)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(lastDir) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(if) operator(()ident(startsWithDriveLetterOnWindows)operator(()ident(canonicalPath)operator(\))operator(\)) operator({) - comment(// do nothing, we should not delete the drive letter) - operator(}) keyword(else) operator({) - ident(canonicalPath) operator(=) string<delimiter(")delimiter(")>operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(canonicalPath) operator(=) ident(canonicalPath)operator(.)ident(substring)operator(()integer(0)operator(,) ident(lastDir)operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(canonicalPath) operator(==) pre_constant(null)operator(\)) operator({) - ident(canonicalPath) operator(=) ident(child)operator(;) - operator(}) keyword(else) operator({) - ident(canonicalPath) operator(+=) string<delimiter(")content(/)delimiter(")> operator(+) ident(child)operator(;) - operator(}) - - keyword(return) ident(canonicalize)operator(()ident(canonicalPath)operator(,) ident(remaining)operator(\))operator(;) - operator(}) - - comment(/** - * Returns true if path matches against pattern The pattern is not a regular expression; - * instead it follows rules similar to shell filename globbing. It may contain the following - * metacharacters: - * *: Glob - match any sequence chars (re: .*\). If like begins with '.' then it doesn't. - * ?: Matches a single char (re: .\). - * [set]: Matches a single char in a set (re: [...]\). - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(fnmatch)delimiter(")>operator(,) string<delimiter(")content(fnmatch?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(2)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(fnmatch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(int) ident(flags) operator(=) ident(args)operator(.)ident(length) operator(==) integer(3) operator(?) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(2)operator(])operator(\)) operator(:) integer(0)operator(;) - - ident(ByteList) ident(pattern) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(ByteList) ident(path) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(org)operator(.)ident(jruby)operator(.)ident(util)operator(.)ident(Dir)operator(.)ident(fnmatch)operator(()ident(pattern)operator(.)ident(bytes)operator(,) ident(pattern)operator(.)ident(begin)operator(,) ident(pattern)operator(.)ident(begin)operator(+)ident(pattern)operator(.)ident(realSize)operator(,) - ident(path)operator(.)ident(bytes)operator(,) ident(path)operator(.)ident(begin)operator(,) ident(path)operator(.)ident(begin)operator(+)ident(path)operator(.)ident(realSize)operator(,) ident(flags)operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ftype)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(ftype)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(true)operator(\))operator(.)ident(ftype)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String) ident(inspectJoin)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(RubyArray) ident(parent)operator(,) ident(RubyArray) ident(array)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - comment(// If already inspecting, there is no need to register/unregister again.) - keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()ident(parent)operator(\))operator(\)) keyword(return) ident(join)operator(()ident(context)operator(,) ident(recv)operator(,) ident(array)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(runtime)operator(.)ident(registerInspecting)operator(()ident(parent)operator(\))operator(;) - keyword(return) ident(join)operator(()ident(context)operator(,) ident(recv)operator(,) ident(array)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(unregisterInspecting)operator(()ident(parent)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) ident(RubyString) ident(join)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(RubyArray) ident(ary)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) ident(ary)operator(.)ident(toJavaArray)operator(()operator(\))operator(;) - type(boolean) ident(isTainted) operator(=) pre_constant(false)operator(;) - pre_type(StringBuilder) ident(buffer) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)ident(i)operator(])operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(isTainted) operator(=) pre_constant(true)operator(;) - operator(}) - pre_type(String) ident(element)operator(;) - keyword(if) operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(element) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\)) operator({) - ident(element) operator(=) string<delimiter(")content([...])delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(element) operator(=) ident(inspectJoin)operator(()ident(context)operator(,) ident(recv)operator(,) ident(ary)operator(,) operator(()operator(()ident(RubyArray)operator(\))ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(element) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - ident(chomp)operator(()ident(buffer)operator(\))operator(;) - keyword(if) operator(()ident(i) operator(>) integer(0) operator(&&) operator(!)ident(element)operator(.)ident(startsWith)operator(()string<delimiter(")content(/)delimiter(")>operator(\)) operator(&&) operator(!)ident(element)operator(.)ident(startsWith)operator(()string<delimiter(")char(\\\\)delimiter(")>operator(\))operator(\)) operator({) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - operator(}) - ident(buffer)operator(.)ident(append)operator(()ident(element)operator(\))operator(;) - operator(}) - - ident(RubyString) ident(fixedStr) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buffer)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(fixedStr)operator(.)ident(setTaint)operator(()ident(isTainted)operator(\))operator(;) - keyword(return) ident(fixedStr)operator(;) - operator(}) - - comment(/* - * Fixme: This does not have exact same semantics as RubyArray.join, but they - * probably could be consolidated (perhaps as join(args[], sep, doChomp\)\). - */) - annotation(@JRubyMethod)operator(()ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyString) ident(join)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(join)operator(()ident(context)operator(,) ident(recv)operator(,) ident(RubyArray)operator(.)ident(newArrayNoCopyLight)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(chomp)operator(()pre_type(StringBuilder) ident(buffer)operator(\)) operator({) - type(int) ident(lastIndex) operator(=) ident(buffer)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(;) - - keyword(while) operator(()ident(lastIndex) operator(>=) integer(0) operator(&&) operator(()ident(buffer)operator(.)ident(lastIndexOf)operator(()string<delimiter(")content(/)delimiter(")>operator(\)) operator(==) ident(lastIndex) operator(||) ident(buffer)operator(.)ident(lastIndexOf)operator(()string<delimiter(")char(\\\\)delimiter(")>operator(\)) operator(==) ident(lastIndex)operator(\))operator(\)) operator({) - ident(buffer)operator(.)ident(setLength)operator(()ident(lastIndex)operator(\))operator(;) - ident(lastIndex)operator(--)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lstat)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(lstat)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - pre_type(String) ident(f) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(f)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\)) operator(&&) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(')content(!)delimiter(')>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(f) operator(=) ident(f)operator(.)ident(substring)operator(()integer(5)operator(,) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(")content(!)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(f)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(stat)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(stat)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - pre_type(String) ident(f) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(f)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\)) operator(&&) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(')content(!)delimiter(')>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(f) operator(=) ident(f)operator(.)ident(substring)operator(()integer(5)operator(,) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(")content(!)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(f)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(atime)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(atime)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - pre_type(String) ident(f) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(f)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\)) operator(&&) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(')content(!)delimiter(')>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(f) operator(=) ident(f)operator(.)ident(substring)operator(()integer(5)operator(,) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(")content(!)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(f)operator(,) pre_constant(false)operator(\))operator(.)ident(atime)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ctime)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(ctime)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - pre_type(String) ident(f) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(f)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\)) operator(&&) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(')content(!)delimiter(')>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(f) operator(=) ident(f)operator(.)ident(substring)operator(()integer(5)operator(,) ident(f)operator(.)ident(indexOf)operator(()string<delimiter(")content(!)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(f)operator(,) pre_constant(false)operator(\))operator(.)ident(ctime)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(lchmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - type(int) ident(count) operator(=) integer(0)operator(;) - ident(RubyInteger) ident(mode) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(filename)operator(,) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(filename)operator(\))operator(;) - operator(}) - - type(boolean) ident(result) operator(=) integer(0) operator(==) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lchmod)operator(()ident(filename)operator(.)ident(toString)operator(()operator(\))operator(,) operator(()type(int)operator(\))ident(mode)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(result)operator(\)) operator({) - ident(count)operator(++)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(count)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(3)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(lchown)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(owner) operator(=) operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(0)operator(])operator(\)) operator(:) operator(-)integer(1)operator(;) - type(int) ident(group) operator(=) operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)integer(1)operator(])operator(\)) operator(:) operator(-)integer(1)operator(;) - type(int) ident(count) operator(=) integer(0)operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(2)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(filename)operator(,) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(filename)operator(\))operator(;) - operator(}) - - type(boolean) ident(result) operator(=) integer(0) operator(==) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lchown)operator(()ident(filename)operator(.)ident(toString)operator(()operator(\))operator(,) ident(owner)operator(,) ident(group)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(\)) operator({) - ident(count)operator(++)operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(count)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(link)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(from)operator(,) ident(IRubyObject) ident(to)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyString) ident(fromStr) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(from)operator(\))operator(;) - ident(RubyString) ident(toStr) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(to)operator(\))operator(;) - keyword(try) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(link)operator(() - ident(fromStr)operator(.)ident(toString)operator(()operator(\))operator(,)ident(toStr)operator(.)ident(toString)operator(()operator(\))operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// FIXME: When we get JNA3 we need to properly write this to errno.) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEEXISTError)operator(()string<delimiter(")content(File exists - )delimiter(")> - operator(+) ident(fromStr) operator(+) string<delimiter(")content( or )delimiter(")> operator(+) ident(toStr)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(java)operator(.)ident(lang)operator(.)ident(UnsatisfiedLinkError) ident(ule)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(link(\) function is unimplemented on this machine)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mtime)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(mtime)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - keyword(return) ident(getLastModified)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rename)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(oldName)operator(,) ident(IRubyObject) ident(newName)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyString) ident(oldNameString) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(oldName)operator(\))operator(;) - ident(RubyString) ident(newNameString) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(newName)operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(oldNameString)operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(newNameString)operator(\))operator(;) - ident(JRubyFile) ident(oldFile) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(oldNameString)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(JRubyFile) ident(newFile) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(newNameString)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(oldFile)operator(.)ident(exists)operator(()operator(\)) operator(||) operator(!)ident(newFile)operator(.)ident(getParentFile)operator(()operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(oldNameString) operator(+) - string<delimiter(")content( or )delimiter(")> operator(+) ident(newNameString)operator(\))operator(;) - operator(}) - - ident(JRubyFile) ident(dest) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(newNameString)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(oldFile)operator(.)ident(renameTo)operator(()ident(dest)operator(\))operator(\)) operator({) comment(// rename is successful) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(// rename via Java API call wasn't successful, let's try some tricks, similar to MRI ) - - keyword(if) operator(()ident(newFile)operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(chmod)operator(()ident(newNameString)operator(.)ident(toString)operator(()operator(\))operator(,) oct(0666)operator(\))operator(;) - ident(newFile)operator(.)ident(delete)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(oldFile)operator(.)ident(renameTo)operator(()ident(dest)operator(\))operator(\)) operator({) comment(// try to rename one more time) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - keyword(throw) ident(runtime)operator(.)ident(newErrnoEACCESError)operator(()string<delimiter(")content(Permission denied - )delimiter(")> operator(+) ident(oldNameString) operator(+) string<delimiter(")content( or )delimiter(")> operator(+) - ident(newNameString)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyString) ident(filename) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(arg)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(dirname)operator(()ident(context)operator(,) ident(recv)operator(,) ident(filename)operator(\))operator(,) - ident(basename)operator(()ident(context)operator(,) ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(filename) operator(})operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(symlink)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(from)operator(,) ident(IRubyObject) ident(to)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyString) ident(fromStr) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(from)operator(\))operator(;) - ident(RubyString) ident(toStr) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(to)operator(\))operator(;) - keyword(try) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(symlink)operator(() - ident(fromStr)operator(.)ident(toString)operator(()operator(\))operator(,) ident(toStr)operator(.)ident(toString)operator(()operator(\))operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// FIXME: When we get JNA3 we need to properly write this to errno.) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEEXISTError)operator(()string<delimiter(")content(File exists - )delimiter(")> - operator(+) ident(fromStr) operator(+) string<delimiter(")content( or )delimiter(")> operator(+) ident(toStr)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(java)operator(.)ident(lang)operator(.)ident(UnsatisfiedLinkError) ident(ule)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(symlink(\) function is unimplemented on this machine)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(readlink)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(path)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - pre_type(String) ident(realPath) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(readlink)operator(()ident(path)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(recv)operator(,) ident(path)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(RubyFileTest)operator(.)ident(symlink_p)operator(()ident(recv)operator(,) ident(path)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(invalid argument - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(realPath) operator(==) pre_constant(null)operator(\)) operator({) - comment(//FIXME: When we get JNA3 we need to properly write this to errno.) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(realPath)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(// Can we produce IOError which bypasses a close?) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(truncate)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyString) ident(filename) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(;) comment(// TODO: SafeStringValue here) - ident(RubyInteger) ident(newLength) operator(=) ident(arg2)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(filename)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(() - string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(filename)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(newLength)operator(.)ident(getLongValue)operator(()operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(invalid argument: )delimiter(")> operator(+) ident(filename)operator(\))operator(;) - operator(}) - - ident(IRubyObject)type([]) ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(filename)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(r+)delimiter(")>operator(\)) operator(})operator(;) - ident(RubyFile) ident(file) operator(=) operator(()ident(RubyFile)operator(\)) ident(open)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - ident(file)operator(.)ident(truncate)operator(()ident(context)operator(,) ident(newLength)operator(\))operator(;) - ident(file)operator(.)ident(close)operator(()operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(meta) operator(=) pre_constant(true)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(umask)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(oldMask) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(oldMask) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(umask)operator(()integer(0)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(umask)operator(()ident(oldMask)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(oldMask) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(umask)operator(()operator(()type(int)operator(\)) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(oldMask)operator(\))operator(;) - operator(}) - - comment(/** - * This method does NOT set atime, only mtime, since Java doesn't support anything else. - */) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(2)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(utime)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - comment(// Ignore access_time argument since Java does not support it.) - - type(long) ident(mtime)operator(;) - keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - ident(mtime) operator(=) operator(()operator(()ident(RubyTime)operator(\)) ident(args)operator([)integer(1)operator(])operator(\))operator(.)ident(getJavaDate)operator(()operator(\))operator(.)ident(getTime)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyNumeric)operator(\)) operator({) - ident(mtime) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(1)operator(]) operator(==) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\)) operator({) - ident(mtime) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyTime) ident(time) operator(=) operator(()ident(RubyTime)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(args)operator([)integer(1)operator(])operator(,) ident(runtime)operator(.)ident(getTime)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(NO_INDEX)operator(,)string<delimiter(")content(to_time)delimiter(")>operator(,) pre_constant(true)operator(\))operator(;) - ident(mtime) operator(=) ident(time)operator(.)ident(getJavaDate)operator(()operator(\))operator(.)ident(getTime)operator(()operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(2)operator(,) ident(j) operator(=) ident(args)operator(.)ident(length)operator(;) ident(i) operator(<) ident(j)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyString) ident(filename) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(filename)operator(\))operator(;) - ident(JRubyFile) ident(fileToTouch) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,)ident(filename)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(fileToTouch)operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content( No such file or directory - )char(\\")delimiter(")> operator(+) ident(filename) operator(+) string<delimiter(")char(\\")delimiter(")>operator(\))operator(;) - operator(}) - - ident(fileToTouch)operator(.)ident(setLastModified)operator(()ident(mtime)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(args)operator(.)ident(length) operator(-) integer(2)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(unlink)delimiter(")>operator(,) string<delimiter(")content(delete)delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(unlink)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyString) ident(filename) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(filename)operator(\))operator(;) - ident(JRubyFile) ident(lToDelete) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,)ident(filename)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - type(boolean) ident(isSymlink) operator(=) ident(RubyFileTest)operator(.)ident(symlink_p)operator(()ident(recv)operator(,) ident(filename)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - comment(// Broken symlinks considered by exists(\) as non-existing,) - comment(// so we need to check for symlinks explicitly.) - keyword(if) operator(()operator(!)ident(lToDelete)operator(.)ident(exists)operator(()operator(\)) operator(&&) operator(!)ident(isSymlink)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content( No such file or directory - )char(\\")delimiter(")> operator(+) ident(filename) operator(+) string<delimiter(")char(\\")delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(lToDelete)operator(.)ident(delete)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEACCESError)operator(()string<delimiter(")content(Permission denied - )char(\\")delimiter(")> operator(+) ident(filename) operator(+) string<delimiter(")char(\\")delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(args)operator(.)ident(length)operator(\))operator(;) - operator(}) - - comment(// Fast path since JNA stat is about 10x slower than this) - directive(private) directive(static) ident(IRubyObject) ident(getLastModified)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(runtime)operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(path)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(file)operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) ident(path)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newTime)operator(()ident(file)operator(.)ident(lastModified)operator(()operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.FileDescriptor)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.ext.posix.FileStat)operator(;) -keyword(import) include(org.jruby.ext.posix.util.Platform)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.JRubyFile)operator(;) - -comment(/** - * Implements File::Stat - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(File::Stat)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Comparable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyFileStat) directive(extends) ident(RubyObject) operator({) - directive(private) directive(static) directive(final) type(long) ident(serialVersionUID) operator(=) integer(1L)operator(;) - - directive(private) ident(JRubyFile) ident(file)operator(;) - directive(private) ident(FileStat) ident(stat)operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyFileStat)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createFileStatClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415) - directive(final) ident(RubyClass) ident(fileStatClass) operator(=) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Stat)delimiter(")>operator(,)ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setFileStat)operator(()ident(fileStatClass)operator(\))operator(;) - - ident(fileStatClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Comparable)delimiter(")>operator(\))operator(\))operator(;) - ident(fileStatClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFileStat)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(fileStatClass)operator(;) - operator(}) - - directive(protected) ident(RubyFileStat)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(clazz)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(clazz)operator(\))operator(;) - - operator(}) - - directive(public) directive(static) ident(RubyFileStat) ident(newFileStat)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(filename)operator(,) type(boolean) ident(lstat)operator(\)) operator({) - ident(RubyFileStat) ident(stat) operator(=) keyword(new) ident(RubyFileStat)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getFileStat)operator(()operator(\))operator(\))operator(;) - - ident(stat)operator(.)ident(setup)operator(()ident(filename)operator(,) ident(lstat)operator(\))operator(;) - - keyword(return) ident(stat)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFileStat) ident(newFileStat)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(FileDescriptor) ident(descriptor)operator(\)) operator({) - ident(RubyFileStat) ident(stat) operator(=) keyword(new) ident(RubyFileStat)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getFileStat)operator(()operator(\))operator(\))operator(;) - - ident(stat)operator(.)ident(setup)operator(()ident(descriptor)operator(\))operator(;) - - keyword(return) ident(stat)operator(;) - operator(}) - - directive(private) type(void) ident(setup)operator(()pre_type(FileDescriptor) ident(descriptor)operator(\)) operator({) - ident(stat) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(fstat)operator(()ident(descriptor)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(setup)operator(()pre_type(String) ident(filename)operator(,) type(boolean) ident(lstat)operator(\)) operator({) - keyword(if) operator(()ident(Platform)operator(.)ident(IS_WINDOWS) operator(&&) ident(filename)operator(.)ident(length)operator(()operator(\)) operator(==) integer(2) - operator(&&) ident(filename)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')content(:)delimiter(')> operator(&&) pre_type(Character)operator(.)ident(isLetter)operator(()ident(filename)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\))operator(\)) operator({) - ident(filename) operator(+=) string<delimiter(")content(/)delimiter(")>operator(;) - operator(}) - - ident(file) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(filename)operator(\))operator(;) - - keyword(if) operator(()ident(lstat)operator(\)) operator({) - ident(stat) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lstat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(stat) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject) ident(fname)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(setup)operator(()ident(fname)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(atime)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(atime)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newTime)operator(()ident(stat)operator(.)ident(atime)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(blksize)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(blksize)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(blockSize)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(blockdev?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(blockdev_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isBlockDev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(blocks)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(blocks)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(blocks)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chardev?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(chardev_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isCharDev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(cmp)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyFileStat)operator(\))operator(\)) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - type(long) ident(time1) operator(=) ident(stat)operator(.)ident(mtime)operator(()operator(\))operator(;) - type(long) ident(time2) operator(=) operator(()operator(()ident(RubyFileStat)operator(\)) ident(other)operator(\))operator(.)ident(stat)operator(.)ident(mtime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(time1) operator(==) ident(time2)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(time1) operator(<) ident(time2)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(-)integer(1)operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ctime)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(ctime)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newTime)operator(()ident(stat)operator(.)ident(ctime)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dev)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(dev)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(dev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dev_major)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(devMajor)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(major)operator(()ident(stat)operator(.)ident(dev)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dev_minor)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(devMinor)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(minor)operator(()ident(stat)operator(.)ident(dev)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(directory?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(directory_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isDirectory)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(executable?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(executable_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isExecutable)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(executable_real?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(executableReal_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isExecutableReal)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(file?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(file_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isFile)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ftype)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(ftype)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(stat)operator(.)ident(ftype)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gid)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(gid)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(gid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(grpowned?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(group_owned_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isGroupOwned)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(original) keyword(instanceof) ident(RubyFileStat)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument class)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyFileStat) ident(originalFileStat) operator(=) operator(()ident(RubyFileStat)operator(\)) ident(original)operator(;) - - ident(file) operator(=) ident(originalFileStat)operator(.)ident(file)operator(;) - ident(stat) operator(=) ident(originalFileStat)operator(.)ident(stat)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ino)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(ino)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(ino)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(buf) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content( )delimiter(")>operator(\))operator(;) - comment(// FIXME: Obvious issue that not all platforms can display all attributes. Ugly hacks.) - comment(// Using generic posix library makes pushing inspect behavior into specific system impls) - comment(// rather painful.) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(dev=0x)delimiter(")>operator(\))operator(.)ident(append)operator(()pre_type(Long)operator(.)ident(toHexString)operator(()ident(stat)operator(.)ident(dev)operator(()operator(\))operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(ino=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(ino)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(mode=0)delimiter(")>operator(\))operator(.)ident(append)operator(()pre_type(Integer)operator(.)ident(toOctalString)operator(()ident(stat)operator(.)ident(mode)operator(()operator(\))operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(nlink=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(nlink)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(uid=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(uid)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(gid=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(gid)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(rdev=0x)delimiter(")>operator(\))operator(.)ident(append)operator(()pre_type(Long)operator(.)ident(toHexString)operator(()ident(stat)operator(.)ident(rdev)operator(()operator(\))operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(size=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(st_size)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(blksize=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(blockSize)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - keyword(try) operator({) ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(blocks=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(stat)operator(.)ident(blocks)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({)operator(}) - - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(atime=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(atime)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(mtime=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(mtime)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(ctime=)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(ctime)operator(()operator(\))operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buf)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(uid)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(uid)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(uid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mode)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(mode)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(mode)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mtime)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(mtime)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newTime)operator(()ident(stat)operator(.)ident(mtime)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(mtimeEquals)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(mtime)operator(()operator(\)) operator(==) ident(newFileStat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(other)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(stat)operator(.)ident(mtime)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(mtimeGreaterThan)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(mtime)operator(()operator(\)) operator(>) ident(newFileStat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(other)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(stat)operator(.)ident(mtime)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(mtimeLessThan)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(mtime)operator(()operator(\)) operator(<) ident(newFileStat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(other)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(stat)operator(.)ident(mtime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nlink)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nlink)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(nlink)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(owned?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(owned_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isOwned)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pipe?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pipe_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isNamedPipe)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rdev)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rdev)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(rdev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rdev_major)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rdevMajor)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(major)operator(()ident(stat)operator(.)ident(rdev)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rdev_minor)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rdevMinor)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(minor)operator(()ident(stat)operator(.)ident(rdev)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readable?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(readable_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isReadable)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readable_real?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(readableReal_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isReadableReal)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setgid?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(setgid_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isSetgid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setuid?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(setuid_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isSetuid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(size)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(stat)operator(.)ident(st_size)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(size?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(size_p)operator(()operator(\)) operator({) - type(long) ident(size) operator(=) ident(stat)operator(.)ident(st_size)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(size) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(size)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(socket?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(socket_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isSocket)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sticky?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sticky_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isSticky)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(symlink?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(symlink_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isSymlink)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(writable?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(writable_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isWritable)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(writable_real?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(writableReal_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isWritableReal)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(zero_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(stat)operator(.)ident(isEmpty)operator(()operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) - -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.JRubyFile)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(FileTest)delimiter(")>operator(\)) -directive(public) type(class) class(RubyFileTest) operator({) - directive(public) directive(static) ident(RubyModule) ident(createFileTestModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(fileTestModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(FileTest)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setFileTest)operator(()ident(fileTestModule)operator(\))operator(;) - - ident(fileTestModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFileTest)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(fileTestModule)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(blockdev?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(blockdev_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isBlockDev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chardev?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chardev_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isCharDev)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(directory?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(directory_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isDirectory)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(executable?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(executable_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isExecutable)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(executable_real?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(executable_real_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isExecutableReal)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(exist?)delimiter(")>operator(,) string<delimiter(")content(exists?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exist_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - keyword(if) operator(()ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - keyword(if)operator(()ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\))operator(\)) operator({) - pre_type(String) ident(file) operator(=) ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(.)ident(substring)operator(()integer(5)operator(\))operator(;) - type(int) ident(bang) operator(=) ident(file)operator(.)ident(indexOf)operator(()string<delimiter(')content(!)delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(bang) operator(==) operator(-)integer(1) operator(||) ident(bang) operator(==) ident(file)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - pre_type(String) ident(jar) operator(=) ident(file)operator(.)ident(substring)operator(()integer(0)operator(,) ident(bang)operator(\))operator(;) - pre_type(String) ident(after) operator(=) ident(file)operator(.)ident(substring)operator(()ident(bang) operator(+) integer(2)operator(\))operator(;) - keyword(try) operator({) - ident(java)operator(.)ident(util)operator(.)ident(jar)operator(.)ident(JarFile) ident(jf) operator(=) keyword(new) ident(java)operator(.)ident(util)operator(.)ident(jar)operator(.)ident(JarFile)operator(()ident(jar)operator(\))operator(;) - keyword(if)operator(()ident(jf)operator(.)ident(getJarEntry)operator(()ident(after)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(file)operator(()ident(filename)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(file?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(file_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(filename)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(file)operator(.)ident(isFile)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(grpowned?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(grpowned_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isGroupOwned)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(identical?)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(identical_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename1)operator(,) ident(IRubyObject) ident(filename2)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file1) operator(=) ident(file)operator(()ident(filename1)operator(\))operator(;) - ident(JRubyFile) ident(file2) operator(=) ident(file)operator(()ident(filename2)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file1)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(file2)operator(.)ident(exists)operator(()operator(\)) operator(&&) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file1)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isIdentical)operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file2)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(owned?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(owned_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isOwned)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pipe?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(pipe_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isNamedPipe)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// We use file test since it is faster than a stat; also euid == uid in Java always) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(readable?)delimiter(")>operator(,) string<delimiter(")content(readable_real?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(readable_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(file)operator(.)ident(canRead)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// Not exposed by filetest, but so similiar in nature that it is stored here) - directive(public) directive(static) ident(IRubyObject) ident(rowned_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isROwned)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setgid?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setgid_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isSetgid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setuid?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setuid_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isSetuid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(size)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(size)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(file)operator(.)ident(exists)operator(()operator(\))operator(\)) ident(noFileError)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(file)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(size?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(size_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(file)operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - type(long) ident(length) operator(=) ident(file)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(if) operator(()ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(length)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(socket?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(socket_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isSocket)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sticky?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sticky_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(stat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isSticky)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(symlink?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(symlink_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(try) operator({) - comment(// Note: We can't use file.exists(\) to check whether the symlink) - comment(// exists or not, because that method returns false for existing) - comment(// but broken symlink. So, we try without the existence check,) - comment(// but in the try-catch block.) - comment(// MRI behavior: symlink? on broken symlink should return true.) - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(lstat)operator(()ident(file)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(\))operator(.)ident(isSymlink)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(re)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// We do both writable and writable_real through the same method because) - comment(// in our java process effective and real userid will always be the same.) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(writable?)delimiter(")>operator(,) string<delimiter(")content(writable_real?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(writable_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - keyword(return) ident(filename)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(file)operator(()ident(filename)operator(\))operator(.)ident(canWrite)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(zero_p)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(\)) operator({) - ident(JRubyFile) ident(file) operator(=) ident(file)operator(()ident(filename)operator(\))operator(;) - - keyword(return) ident(filename)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(file)operator(.)ident(exists)operator(()operator(\)) operator(&&) ident(file)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0L)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(JRubyFile) ident(file)operator(()ident(IRubyObject) ident(path)operator(\)) operator({) - pre_type(String) ident(filename) operator(=) ident(path)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(return) ident(JRubyFile)operator(.)ident(create)operator(()ident(path)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(filename)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(noFileError)operator(()ident(IRubyObject) ident(filename)operator(\)) operator({) - keyword(throw) ident(filename)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(No such file or directory - )delimiter(")> operator(+) - ident(filename)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C\) 2006 Antti Karanta <antti.karanta@napa.fi> - * Copyright (C\) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.math.BigInteger)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.java.MiniJava)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.Convert)operator(;) -keyword(import) include(org.jruby.util.Numeric)operator(;) -keyword(import) include(org.jruby.util.TypeCoercer)operator(;) - -comment(/** - * Implementation of the Fixnum class. - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Fixnum)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Integer)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Precision)delimiter(")>operator(\)) -directive(public) type(class) class(RubyFixnum) directive(extends) ident(RubyInteger) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createFixnumClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(fixnum) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Fixnum)delimiter(")>operator(,) ident(runtime)operator(.)ident(getInteger)operator(()operator(\))operator(,) - ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setFixnum)operator(()ident(fixnum)operator(\))operator(;) - ident(fixnum)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(FIXNUM)operator(;) - ident(fixnum)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyFixnum)operator(;) - operator(}) - operator(})operator(;) - - ident(fixnum)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getPrecision)operator(()operator(\))operator(\))operator(;) - - ident(fixnum)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFixnum)operator(.)ident(class)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(runtime)operator(.)ident(fixnumCache)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(runtime)operator(.)ident(fixnumCache)operator([)ident(i)operator(]) operator(=) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) ident(fixnum)operator(,) ident(i) operator(-) integer(128)operator(\))operator(;) - operator(}) - - keyword(return) ident(fixnum)operator(;) - operator(}) - - directive(private) directive(final) type(long) ident(value)operator(;) - directive(private) directive(static) directive(final) type(int) ident(BIT_SIZE) operator(=) integer(64)operator(;) - directive(public) directive(static) directive(final) type(long) ident(SIGN_BIT) operator(=) operator(()integer(1L) operator(<)operator(<) operator(()ident(BIT_SIZE) operator(-) integer(1)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(long) ident(MAX) operator(=) operator(()integer(1L)operator(<)operator(<)operator(()ident(BIT_SIZE) operator(-) integer(1)operator(\))operator(\)) operator(-) integer(1)operator(;) - directive(public) directive(static) directive(final) type(long) ident(MIN) operator(=) operator(-)integer(1) operator(*) ident(MAX) operator(-) integer(1)operator(;) - directive(public) directive(static) directive(final) type(long) ident(MAX_MARSHAL_FIXNUM) operator(=) operator(()integer(1L) operator(<)operator(<) integer(30)operator(\)) operator(-) integer(1)operator(;) comment(// 0x3fff_ffff) - directive(public) directive(static) directive(final) type(long) ident(MIN_MARSHAL_FIXNUM) operator(=) operator(-) operator(()integer(1L) operator(<)operator(<) integer(30)operator(\))operator(;) comment(// -0x4000_0000) - - directive(private) directive(static) ident(IRubyObject) ident(fixCoerce)operator(()ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(do) operator({) - ident(x) operator(=) ident(x)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - operator(}) keyword(while) operator(()operator(!)operator(()ident(x) keyword(instanceof) ident(RubyFixnum)operator(\)) operator(&&) operator(!)operator(()ident(x) keyword(instanceof) ident(RubyBignum)operator(\))operator(\))operator(;) - keyword(return) ident(x)operator(;) - operator(}) - - directive(public) ident(RubyFixnum)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) integer(0)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFixnum)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getFixnum)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - directive(private) ident(RubyFixnum)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klazz)operator(,) type(long) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klazz)operator(,) pre_constant(false)operator(\))operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(FIXNUM)operator(;) - operator(}) - - comment(/** - * short circuit for Fixnum key comparison - */) - annotation(@Override) - directive(public) directive(final) type(boolean) ident(eql)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(other) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(value) operator(==) operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(.)ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyClass) ident(getSingletonClass)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't define singleton)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - comment(// this precision-guessing needs to be thought out more, since in the) - comment(// case of coercing to Object we generally want to get the same type) - comment(// always) -comment(// if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE\) {) -comment(// return byte.class;) -comment(// } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE\) {) -comment(// return short.class;) -comment(// } else if (value >= Character.MIN_VALUE && value <= Character.MAX_VALUE\) {) -comment(// return char.class;) -comment(// } else if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE\) {) -comment(// return int.class;) -comment(// }) - keyword(return) type(long)operator(.)ident(class)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(double) ident(getDoubleValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(long) ident(getLongValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(CACHE_OFFSET) operator(=) integer(128)operator(;) - - directive(public) directive(static) ident(RubyFixnum) ident(newFixnum)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(isInCacheRange)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)operator(()type(int)operator(\)) ident(value) operator(+) ident(CACHE_OFFSET)operator(])operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyFixnum)operator(()ident(runtime)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(isInCacheRange)operator(()type(long) ident(value)operator(\)) operator({) - keyword(return) ident(value) operator(<=) integer(127) operator(&&) ident(value) operator(>=) operator(-)integer(128)operator(;) - operator(}) - - directive(public) ident(RubyFixnum) ident(newFixnum)operator(()type(long) ident(newValue)operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(newValue)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(zero)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(one)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(+) integer(1)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(two)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(+) integer(2)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(three)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(+) integer(3)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(four)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(+) integer(4)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(five)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(+) integer(5)operator(])operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(minus_one)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(fixnumCache)operator([)ident(CACHE_OFFSET) operator(-) integer(1)operator(])operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) directive(final) type(int) ident(hashCode)operator(()operator(\)) operator({) - keyword(return) operator(()type(int)operator(\))operator(()ident(value) operator(^) ident(value) operator(>)operator(>)operator(>) integer(32)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) operator(==) local_variable(this)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(RubyFixnum) ident(num) operator(=) operator(()ident(RubyFixnum)operator(\))ident(other)operator(;) - - keyword(if) operator(()ident(num)operator(.)ident(value) operator(==) ident(value)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** fix_to_s - * - */) - directive(public) ident(RubyString) ident(to_s)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(return) ident(to_s)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(to_s)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(1)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(RubyString) ident(to_s)operator(()operator(\)) operator({) - type(int) ident(base) operator(=) integer(10)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(Convert)operator(.)ident(longToByteList)operator(()ident(value)operator(,) ident(base)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(to_s)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - type(int) ident(base) operator(=) ident(num2int)operator(()ident(arg0)operator(\))operator(;) - keyword(if) operator(()ident(base) operator(<) integer(2) operator(||) ident(base) operator(>) integer(36)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal radix )delimiter(")> operator(+) ident(base)operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(Convert)operator(.)ident(longToByteList)operator(()ident(value)operator(,) ident(base)operator(\))operator(\))operator(;) - operator(}) - - comment(/** fix_id2name - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(id2name)operator(()operator(\)) operator({) - ident(RubySymbol) ident(symbol) operator(=) ident(RubySymbol)operator(.)ident(getSymbolLong)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - - keyword(if) operator(()ident(symbol) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** fix_to_sym - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(to_sym)operator(()operator(\)) operator({) - ident(RubySymbol) ident(symbol) operator(=) ident(RubySymbol)operator(.)ident(getSymbolLong)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - - keyword(return) ident(symbol) operator(!=) pre_constant(null) operator(?) ident(symbol) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** fix_uminus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uminus)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value) operator(==) ident(MIN)operator(\)) operator({) comment(// a gotcha) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(BigInteger)operator(.)ident(valueOf)operator(()ident(value)operator(\))operator(.)ident(negate)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(-)ident(value)operator(\))operator(;) - operator(}) - - comment(/** fix_plus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(addFixnum)operator(()ident(context)operator(,) operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(addOther)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addFixnum)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFixnum) ident(other)operator(\)) operator({) - type(long) ident(otherValue) operator(=) ident(other)operator(.)ident(value)operator(;) - type(long) ident(result) operator(=) ident(value) operator(+) ident(otherValue)operator(;) - keyword(if) operator(()ident(additionOverflowed)operator(()ident(value)operator(,) ident(otherValue)operator(,) ident(result)operator(\))operator(\)) operator({) - keyword(return) ident(addAsBignum)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(additionOverflowed)operator(()type(long) ident(original)operator(,) type(long) ident(other)operator(,) type(long) ident(result)operator(\)) operator({) - keyword(return) operator(()operator(~)operator(()ident(original) operator(^) ident(other)operator(\)) operator(&) operator(()ident(original) operator(^) ident(result)operator(\)) operator(&) ident(SIGN_BIT)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(subtractionOverflowed)operator(()type(long) ident(original)operator(,) type(long) ident(other)operator(,) type(long) ident(result)operator(\)) operator({) - keyword(return) operator(()operator(~)operator(()ident(original) operator(^) operator(~)ident(other)operator(\)) operator(&) operator(()ident(original) operator(^) ident(result)operator(\)) operator(&) ident(SIGN_BIT)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addAsBignum)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFixnum) ident(other)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_plus)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(addOther)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(op_plus)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFloat)operator(()operator(()type(double)operator(\)) ident(value) operator(+) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_minus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_minus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(subtractFixnum)operator(()ident(context)operator(,) operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(subtractOther)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractFixnum)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFixnum) ident(other)operator(\)) operator({) - type(long) ident(otherValue) operator(=) ident(other)operator(.)ident(value)operator(;) - type(long) ident(result) operator(=) ident(value) operator(-) ident(otherValue)operator(;) - keyword(if) operator(()ident(subtractionOverflowed)operator(()ident(value)operator(,) ident(otherValue)operator(,) ident(result)operator(\))operator(\)) operator({) - keyword(return) ident(subtractAsBignum)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractAsBignum)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFixnum) ident(other)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_minus)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subtractOther)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_minus)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFloat)operator(()operator(()type(double)operator(\)) ident(value) operator(-) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_mul - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(otherValue) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - keyword(if) operator(()ident(value) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - type(long) ident(result) operator(=) ident(value) operator(*) ident(otherValue)operator(;) - keyword(if) operator(()ident(result) operator(/) ident(value) operator(!=) ident(otherValue)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(runtime)operator(,) ident(value)operator(\))operator(.)ident(op_mul)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(newFixnum)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(op_mul)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFloat)operator(()operator(()type(double)operator(\)) ident(value) operator(*) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_div - * here is terrible MRI gotcha: - * 1.div 3.0 -> 0 - * 1 / 3.0 -> 0.3333333333333333 - * - * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: - * rb_funcall(x, ruby_frame->orig_func, 1, y\); - * - * also note that RubyFloat doesn't override Numeric.div - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(div)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(div_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(idiv)operator(()ident(context)operator(,) ident(other)operator(,) string<delimiter(")content(div)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(/)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(idiv)operator(()ident(context)operator(,) ident(other)operator(,) string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(odd?)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(odd_p)operator(()operator(\)) operator({) - keyword(if)operator(()ident(value)operator(%)integer(2) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(even?)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(even_p)operator(()operator(\)) operator({) - keyword(if)operator(()ident(value)operator(%)integer(2) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(pred)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(-)integer(1)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(idiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) pre_type(String) ident(method)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(x) operator(=) ident(value)operator(;) - type(long) ident(y) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(y) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - type(long) ident(div) operator(=) ident(x) operator(/) ident(y)operator(;) - type(long) ident(mod) operator(=) ident(x) operator(%) ident(y)operator(;) - - keyword(if) operator(()ident(mod) operator(<) integer(0) operator(&&) ident(y) operator(>) integer(0) operator(||) ident(mod) operator(>) integer(0) operator(&&) ident(y) operator(<) integer(0)operator(\)) operator({) - ident(div) operator(-=) integer(1)operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(div)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) ident(method)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_mod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(%)delimiter(")>operator(,) string<delimiter(")content(modulo)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(op_mod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - comment(// Java / and % are not the same as ruby) - type(long) ident(x) operator(=) ident(value)operator(;) - type(long) ident(y) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(y) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - type(long) ident(mod) operator(=) ident(x) operator(%) ident(y)operator(;) - - keyword(if) operator(()ident(mod) operator(<) integer(0) operator(&&) ident(y) operator(>) integer(0) operator(||) ident(mod) operator(>) integer(0) operator(&&) ident(y) operator(<) integer(0)operator(\)) operator({) - ident(mod) operator(+=) ident(y)operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(mod)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_divmod - * - */) - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(x) operator(=) ident(value)operator(;) - type(long) ident(y) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(y) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - type(long) ident(div) operator(=) ident(x) operator(/) ident(y)operator(;) - type(long) ident(mod) operator(=) ident(x) operator(%) ident(y)operator(;) - - keyword(if) operator(()ident(mod) operator(<) integer(0) operator(&&) ident(y) operator(>) integer(0) operator(||) ident(mod) operator(>) integer(0) operator(&&) ident(y) operator(<) integer(0)operator(\)) operator({) - ident(div) operator(-=) integer(1)operator(;) - ident(mod) operator(+=) ident(y)operator(;) - operator(}) - - ident(IRubyObject) ident(fixDiv) operator(=) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(div)operator(\))operator(;) - ident(IRubyObject) ident(fixMod) operator(=) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(mod)operator(\))operator(;) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(fixDiv)operator(,) ident(fixMod)operator(\))operator(;) - - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_quo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(quo)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(\)) - directive(public) ident(IRubyObject) ident(quo)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()type(double)operator(\)) ident(value) operator(/) operator(()type(double)operator(\)) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(quo)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_pow - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(**)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_pow)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if)operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(b) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(b) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(b) operator(==) integer(1)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - keyword(if) operator(()ident(b) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_pow)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(value)operator(,) ident(b)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(value)operator(,) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\)) - operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_pow - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(**)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(op_pow_19)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(long) ident(a) operator(=) ident(value)operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(b) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(b) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalRaw)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(b) operator(==) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(b) operator(==) integer(1)operator(\)) keyword(return) local_variable(this)operator(;) - - keyword(if) operator(()ident(a) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(b) operator(>) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\)) operator(:) ident(RubyNumeric)operator(.)ident(dbl2num)operator(()ident(runtime)operator(,) float(1.0) operator(/) float(0.0)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(a) operator(==) integer(1)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(a) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(b) operator(%) integer(2) operator(==) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(return) ident(Numeric)operator(.)ident(int_pow)operator(()ident(context)operator(,) ident(a)operator(,) ident(b)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(if) operator(()ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalRaw)operator(()ident(runtime)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(a) operator(==) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(a) operator(==) integer(1)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(a) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(RubyInteger)operator(.)ident(even_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(runtime)operator(,) ident(RubyBignum)operator(.)ident(fix2big)operator(()local_variable(this)operator(\))operator(\))operator(.)ident(op_pow)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(a)operator(,) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - - comment(/** fix_abs - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(abs)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) operator({) - comment(// A gotcha for Long.MIN_VALUE: value = -value) - keyword(if) operator(()ident(value) operator(==) pre_type(Long)operator(.)ident(MIN_VALUE)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(() - ident(getRuntime)operator(()operator(\))operator(,) pre_type(BigInteger)operator(.)ident(valueOf)operator(()ident(value)operator(\))operator(.)ident(negate)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(-)ident(value)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** fix_equal - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(==) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) local_variable(super)operator(.)ident(op_num_equal)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(compareFixnum)operator(()ident(context)operator(,) operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceCmp)operator(()ident(context)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(compareFixnum)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyFixnum) ident(other)operator(\)) operator({) - type(long) ident(otherValue) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - keyword(if) operator(()ident(value) operator(==) ident(otherValue)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(value) operator(>) ident(otherValue)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** fix_gt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(>) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_ge - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(>=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(>=)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_lt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(<) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_le - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(<=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(<=)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** fix_rev - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(~)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_neg)operator(()operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()operator(~)ident(value)operator(\))operator(;) - operator(}) - - comment(/** fix_and - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_and)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum) operator(||) operator(()ident(other) operator(=) ident(fixCoerce)operator(()ident(other)operator(\))operator(\)) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(&) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(op_and)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** fix_or - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_or)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum) operator(||) operator(()ident(other) operator(=) ident(fixCoerce)operator(()ident(other)operator(\))operator(\)) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(|) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(op_or)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** fix_xor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(^)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_xor)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum) operator(||) operator(()ident(other) operator(=) ident(fixCoerce)operator(()ident(other)operator(\))operator(\)) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(^) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - keyword(return) operator(()operator(()ident(RubyBignum)operator(\)) ident(other)operator(\))operator(.)ident(op_xor)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** fix_aref - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if)operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator(&&) operator(!)operator(()operator(()ident(other) operator(=) ident(fixCoerce)operator(()ident(other)operator(\))operator(\)) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - ident(RubyBignum) ident(big) operator(=) operator(()ident(RubyBignum)operator(\)) ident(other)operator(;) - ident(RubyObject) ident(tryFix) operator(=) ident(RubyBignum)operator(.)ident(bignorm)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(big)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(tryFix) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(return) ident(big)operator(.)ident(getValue)operator(()operator(\))operator(.)ident(signum)operator(()operator(\)) operator(==) integer(0) operator(||) ident(value) operator(>=) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - type(long) ident(otherValue) operator(=) ident(fix2long)operator(()ident(other)operator(\))operator(;) - - keyword(if) operator(()ident(otherValue) operator(<) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(BIT_SIZE) operator(-) integer(1) operator(<) ident(otherValue)operator(\)) operator({) - keyword(return) ident(value) operator(<) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) operator(()ident(value) operator(&) operator(()integer(1L) operator(<)operator(<) ident(otherValue)operator(\))operator(\)) operator(==) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** fix_lshift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_lshift)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_lshift)operator(()ident(other)operator(\))operator(;) - - type(long) ident(width) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(return) ident(width) operator(<) integer(0) operator(?) ident(rshift)operator(()operator(-)ident(width)operator(\)) operator(:) ident(lshift)operator(()ident(width)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(lshift)operator(()type(long) ident(width)operator(\)) operator({) - keyword(if) operator(()ident(width) operator(>) ident(BIT_SIZE) operator(-) integer(1) operator(||) operator(()operator(()operator(~)integer(0L) operator(<)operator(<) ident(BIT_SIZE) operator(-) ident(width) operator(-) integer(1)operator(\)) operator(&) ident(value)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_lshift)operator(()ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(width)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(<)operator(<) ident(width)operator(\))operator(;) - operator(}) - - comment(/** fix_rshift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_rshift)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(.)ident(op_rshift)operator(()ident(other)operator(\))operator(;) - - type(long) ident(width) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(width) operator(==) integer(0)operator(\)) keyword(return) local_variable(this)operator(;) - - keyword(return) ident(width) operator(<) integer(0) operator(?) ident(lshift)operator(()operator(-)ident(width)operator(\)) operator(:) ident(rshift)operator(()ident(width)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(rshift)operator(()type(long) ident(width)operator(\)) operator({) - keyword(if) operator(()ident(width) operator(>=) ident(BIT_SIZE) operator(-) integer(1)operator(\)) operator({) - keyword(return) ident(value) operator(<) integer(0) operator(?) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(>)operator(>) ident(width)operator(\))operator(;) - operator(}) - - comment(/** fix_to_f - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(to_f)operator(()operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(()type(double)operator(\)) ident(value)operator(\))operator(;) - operator(}) - - comment(/** fix_size - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()operator(()type(long)operator(\)) operator(()operator(()ident(BIT_SIZE) operator(+) integer(7)operator(\)) operator(/) integer(8)operator(\))operator(\))operator(;) - operator(}) - - comment(/** fix_zero_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(zero_p)operator(()operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(==) integer(0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(id)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value) operator(<=) pre_type(Long)operator(.)ident(MAX_VALUE) operator(/) integer(2) operator(&&) ident(value) operator(>=) pre_type(Long)operator(.)ident(MIN_VALUE) operator(/) integer(2)operator(\)) operator({) - keyword(return) ident(newFixnum)operator(()integer(2) operator(*) ident(value) operator(+) integer(1)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(super)operator(.)ident(id)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(taint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(// Piece of mri rb_to_id) - annotation(@Override) - directive(public) pre_type(String) ident(asJavaString)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(FIXNUMS_NOT_SYMBOLS)operator(,) string<delimiter(")content(do not use Fixnums as Symbols)delimiter(")>operator(\))operator(;) - - comment(// FIXME: I think this chunk is equivalent to MRI id2name (and not our public method ) - comment(// id2name\). Make into method if used more than once. ) - ident(RubySymbol) ident(symbol) operator(=) ident(RubySymbol)operator(.)ident(getSymbolLong)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - - keyword(if) operator(()ident(symbol) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")delimiter(")> operator(+) ident(value) operator(+) string<delimiter(")content( is not a symbol)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFixnum) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - keyword(return) ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* ================ - * Singleton Methods - * ================ - */) - - comment(/** rb_fix_induced_from - * - */) - annotation(@JRubyMethod)operator(()ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(induced_from)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(num2fix)operator(()ident(other)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_java)operator(()operator(\)) operator({) - keyword(return) ident(MiniJava)operator(.)ident(javaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Long)operator(.)ident(valueOf)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(as)operator(()pre_type(Class) ident(javaClass)operator(\)) operator({) - keyword(return) ident(MiniJava)operator(.)ident(javaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(coerceToJavaType)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) ident(javaClass)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(Object) ident(coerceToJavaType)operator(()ident(Ruby) ident(ruby)operator(,) ident(RubyFixnum) ident(self)operator(,) pre_type(Class) ident(javaClass)operator(\)) operator({) - keyword(if) operator(()operator(!)pre_type(Number)operator(.)ident(class)operator(.)ident(isAssignableFrom)operator(()ident(javaClass)operator(\))operator(\)) operator({) - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()ident(javaClass)operator(.)ident(getCanonicalName)operator(()operator(\)) operator(+) string<delimiter(")content( is not a numeric type)delimiter(")>operator(\))operator(;) - operator(}) - - ident(TypeCoercer) ident(coercer) operator(=) ident(JAVA_COERCERS)operator(.)ident(get)operator(()ident(javaClass)operator(\))operator(;) - - keyword(if) operator(()ident(coercer) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()string<delimiter(")content(Cannot coerce Fixnum to )delimiter(")> operator(+) ident(javaClass)operator(.)ident(getCanonicalName)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(coercer)operator(.)ident(coerce)operator(()ident(self)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) pre_type(Map)operator(<)pre_type(Class)operator(,) ident(TypeCoercer)operator(>) ident(JAVA_COERCERS) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(Class)operator(,) ident(TypeCoercer)operator(>)operator(()operator(\))operator(;) - - directive(static) operator({) - ident(TypeCoercer) ident(intCoercer) operator(=) keyword(new) ident(TypeCoercer)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(coerce)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - ident(RubyFixnum) ident(fixnum) operator(=) operator(()ident(RubyFixnum)operator(\))ident(self)operator(;) - - keyword(if) operator(()ident(fixnum)operator(.)ident(value) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(Fixnum )delimiter(")> operator(+) ident(fixnum)operator(.)ident(value) operator(+) string<delimiter(")content( is too large for Java int)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) pre_type(Integer)operator(.)ident(valueOf)operator(()operator(()type(int)operator(\))ident(fixnum)operator(.)ident(value)operator(\))operator(;) - operator(}) - operator(})operator(;) - ident(JAVA_COERCERS)operator(.)ident(put)operator(()type(int)operator(.)ident(class)operator(,) ident(intCoercer)operator(\))operator(;) - ident(JAVA_COERCERS)operator(.)ident(put)operator(()pre_type(Integer)operator(.)ident(class)operator(,) ident(intCoercer)operator(\))operator(;) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Don Schwartz <schwardo@users.sourceforge.net> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.util.Numeric.f_expt)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_mul)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_i)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.frexp)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.ldexp)operator(;) - -keyword(import) include(java.text.DecimalFormat)operator(;) -keyword(import) include(java.text.DecimalFormatSymbols)operator(;) -keyword(import) include(java.util.Locale)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) - -comment(/** - * A representation of a float object - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Float)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Numeric)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Precision)delimiter(")>operator(\)) -directive(public) type(class) class(RubyFloat) directive(extends) ident(RubyNumeric) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createFloatClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(floatc) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Float)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setFloat)operator(()ident(floatc)operator(\))operator(;) - ident(floatc)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(FLOAT)operator(;) - ident(floatc)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyFloat)operator(;) - operator(}) - operator(})operator(;) - - ident(floatc)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - ident(floatc)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getPrecision)operator(()operator(\))operator(\))operator(;) - - comment(// Java Doubles are 64 bit long: ) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ROUNDS)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(1)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(RADIX)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(2)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MANT_DIG)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(53)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(DIG)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(15)operator(\))operator(\))operator(;) - comment(// Double.MAX_EXPONENT since Java 1.6) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MIN_EXP)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) operator(-)integer(1021)operator(\))operator(\))operator(;) - comment(// Double.MAX_EXPONENT since Java 1.6 ) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAX_EXP)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(1024)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MIN_10_EXP)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) operator(-)integer(307)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAX_10_EXP)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(308)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MIN)delimiter(")>operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) pre_type(Double)operator(.)ident(MIN_VALUE)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAX)delimiter(")>operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) pre_type(Double)operator(.)ident(MAX_VALUE)operator(\))operator(\))operator(;) - ident(floatc)operator(.)ident(defineConstant)operator(()string<delimiter(")content(EPSILON)delimiter(")>operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) float(2.2204460492503131e-16)operator(\))operator(\))operator(;) - - ident(floatc)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFloat)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(floatc)operator(;) - operator(}) - - directive(private) directive(final) type(double) ident(value)operator(;) - - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(FLOAT)operator(;) - operator(}) - - directive(public) ident(RubyFloat)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) float(0.0)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFloat)operator(()ident(Ruby) ident(runtime)operator(,) type(double) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getFloat)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - comment(// this needs to be thought out more along with the changes in RubyFixnum) - comment(// since "to Object" coercion will generally want to produce the same) - comment(// type every time) -comment(// if (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE\) {) -comment(// return float.class;) -comment(// }) - keyword(return) type(double)operator(.)ident(class)operator(;) - operator(}) - - comment(/** Getter for property value. - * @return Value of property value. - */) - directive(public) type(double) ident(getValue)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(value)operator(;) - operator(}) - - directive(public) type(double) ident(getDoubleValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - directive(public) type(long) ident(getLongValue)operator(()operator(\)) operator({) - keyword(return) operator(()type(long)operator(\)) ident(value)operator(;) - operator(}) - - directive(public) ident(RubyFloat) ident(convertToFloat)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(protected) type(int) ident(compareValue)operator(()ident(RubyNumeric) ident(other)operator(\)) operator({) - type(double) ident(otherVal) operator(=) ident(other)operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(getValue)operator(()operator(\)) operator(>) ident(otherVal) operator(?) integer(1) operator(:) ident(getValue)operator(()operator(\)) operator(<) ident(otherVal) operator(?) operator(-)integer(1) operator(:) integer(0)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFloat) ident(newFloat)operator(()ident(Ruby) ident(runtime)operator(,) type(double) ident(value)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyFloat)operator(()ident(runtime)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** rb_flo_induced_from - * - */) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(induced_from)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(number)operator(\)) operator({) - keyword(if) operator(()ident(number) keyword(instanceof) ident(RubyFixnum) operator(||) ident(number) keyword(instanceof) ident(RubyBignum) operator(||) ident(number) keyword(instanceof) ident(RubyRational)operator(\)) operator({) - keyword(return) ident(number)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_F)operator(,) string<delimiter(")content(to_f)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(number) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) ident(number)operator(;) - operator(}) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(() - string<delimiter(")content(failed to convert )delimiter(")> operator(+) ident(number)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into Float)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) directive(final) directive(static) pre_type(DecimalFormat) ident(FORMAT) operator(=) keyword(new) pre_type(DecimalFormat)operator(()string<delimiter(")content(##############0.0##############)delimiter(")>operator(,) - keyword(new) pre_type(DecimalFormatSymbols)operator(()pre_type(Locale)operator(.)ident(ENGLISH)operator(\))operator(\))operator(;) - - comment(/** flo_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(<) integer(0) operator(?) string<delimiter(")content(-Infinity)delimiter(")> operator(:) string<delimiter(")content(Infinity)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) string<delimiter(")content(NaN)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(String) ident(val) operator(=) string<delimiter(")delimiter(")>operator(+)ident(value)operator(;) - - keyword(if)operator(()ident(val)operator(.)ident(indexOf)operator(()string<delimiter(')content(E)delimiter(')>operator(\)) operator(!=) operator(-)integer(1)operator(\)) operator({) - pre_type(String) ident(v2) operator(=) ident(FORMAT)operator(.)ident(format)operator(()ident(value)operator(\))operator(;) - type(int) ident(ix) operator(=) ident(v2)operator(.)ident(length)operator(()operator(\))operator(-)integer(1)operator(;) - keyword(while)operator(()ident(v2)operator(.)ident(charAt)operator(()ident(ix)operator(\)) operator(==) string<delimiter(')content(0)delimiter(')> operator(&&) ident(v2)operator(.)ident(charAt)operator(()ident(ix)operator(-)integer(1)operator(\)) operator(!=) string<delimiter(')content(.)delimiter(')>operator(\)) operator({) - ident(ix)operator(--)operator(;) - operator(}) - keyword(if)operator(()ident(ix) operator(>) integer(15) operator(||) string<delimiter(")content(0.0)delimiter(")>operator(.)ident(equals)operator(()ident(v2)operator(.)ident(substring)operator(()integer(0)operator(,)ident(ix)operator(+)integer(1)operator(\))operator(\))operator(\)) operator({) - ident(val) operator(=) ident(val)operator(.)ident(replaceFirst)operator(()string<delimiter(")content(E()char(\\\\)content(d\))delimiter(")>operator(,)string<delimiter(")content(e+$1)delimiter(")>operator(\))operator(.)ident(replaceFirst)operator(()string<delimiter(")content(E-)delimiter(")>operator(,)string<delimiter(")content(e-)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(val) operator(=) ident(v2)operator(.)ident(substring)operator(()integer(0)operator(,)ident(ix)operator(+)integer(1)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(val)operator(\))operator(;) - operator(}) - - comment(/** flo_coerce - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(coerce)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(RubyKernel)operator(.)ident(new_float)operator(()local_variable(this)operator(,) ident(other)operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** flo_uminus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uminus)operator(()operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(-)ident(value)operator(\))operator(;) - operator(}) - - comment(/** flo_plus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(+) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_minus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_minus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(-) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_mul - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(() - ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(*) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_div - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(/)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_fdiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) comment(// don't override Numeric#div !) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(/) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_mod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(%)delimiter(")>operator(,) string<delimiter(")content(modulo)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(y) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - comment(// Modelled after c ruby implementation (java /,% not same as ruby\)) - type(double) ident(x) operator(=) ident(value)operator(;) - - type(double) ident(mod) operator(=) pre_type(Math)operator(.)ident(IEEEremainder)operator(()ident(x)operator(,) ident(y)operator(\))operator(;) - keyword(if) operator(()ident(y) operator(*) ident(mod) operator(<) integer(0)operator(\)) operator({) - ident(mod) operator(+=) ident(y)operator(;) - operator(}) - - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(mod)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_divmod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(y) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(x) operator(=) ident(value)operator(;) - - type(double) ident(mod) operator(=) pre_type(Math)operator(.)ident(IEEEremainder)operator(()ident(x)operator(,) ident(y)operator(\))operator(;) - comment(// MRI behavior:) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(mod)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFloatDomainError)operator(()string<delimiter(")content(NaN)delimiter(")>operator(\))operator(;) - operator(}) - type(double) ident(div) operator(=) pre_type(Math)operator(.)ident(floor)operator(()ident(x) operator(/) ident(y)operator(\))operator(;) - - keyword(if) operator(()ident(y) operator(*) ident(mod) operator(<) integer(0)operator(\)) operator({) - ident(mod) operator(+=) ident(y)operator(;) - operator(}) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(car) operator(=) ident(dbl2num)operator(()ident(runtime)operator(,) ident(div)operator(\))operator(;) - ident(RubyFloat) ident(cdr) operator(=) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) ident(mod)operator(\))operator(;) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(car)operator(,) ident(cdr)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(divmod)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_pow - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(**)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_pow)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(pow)operator(()ident(value)operator(,) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\)) - operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_eq - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(==) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\)) - operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - keyword(default)operator(:) - comment(// Numeric.equal ) - keyword(return) local_variable(super)operator(.)ident(op_num_equal)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(dbl_cmp)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(,) ident(b)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceCmp)operator(()ident(context)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_gt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(!)pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\)) operator(&&) ident(value) operator(>) ident(b)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_ge - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(!)pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\)) operator(&&) ident(value) operator(>=) ident(b)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(>=)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_lt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(!)pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\)) operator(&&) ident(value) operator(<) ident(b)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_le - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyNumeric)operator(\)) ident(other)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(!)pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\)) operator(&&) ident(value) operator(<=) ident(b)operator(\))operator(;) - keyword(default)operator(:) - keyword(return) ident(coerceRelOp)operator(()ident(context)operator(,) string<delimiter(")content(<=)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** flo_eql - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(b) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(other)operator(\))operator(.)ident(value)operator(;) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\)) operator(||) pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(value) operator(==) ident(b)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** flo_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(final) type(int) ident(hashCode)operator(()operator(\)) operator({) - type(long) ident(l) operator(=) pre_type(Double)operator(.)ident(doubleToLongBits)operator(()ident(value)operator(\))operator(;) - keyword(return) operator(()type(int)operator(\))operator(()ident(l) operator(^) ident(l) operator(>)operator(>)operator(>) integer(32)operator(\))operator(;) - operator(}) - - comment(/** flo_fo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** flo_abs - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(abs)operator(()operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(doubleToLongBits)operator(()ident(value)operator(\)) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(abs)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** flo_zero_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(zero_p)operator(()operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(==) float(0.0)operator(\))operator(;) - operator(}) - - comment(/** flo_truncate - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(truncate)delimiter(")>operator(,) string<delimiter(")content(to_i)delimiter(")>operator(,) string<delimiter(")content(to_int)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(truncate)operator(()operator(\)) operator({) - type(double) ident(f) operator(=) ident(value)operator(;) - keyword(if) operator(()ident(f) operator(>) float(0.0)operator(\)) ident(f) operator(=) pre_type(Math)operator(.)ident(floor)operator(()ident(f)operator(\))operator(;) - keyword(if) operator(()ident(f) operator(<) float(0.0)operator(\)) ident(f) operator(=) pre_type(Math)operator(.)ident(ceil)operator(()ident(f)operator(\))operator(;) - - keyword(return) ident(dbl2num)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(f)operator(\))operator(;) - operator(}) - - comment(/** float_to_r, float_decode - * - */) - directive(static) directive(final) type(int) ident(DBL_MANT_DIG) operator(=) integer(53)operator(;) - directive(static) directive(final) type(int) ident(FLT_RADIX) operator(=) integer(2)operator(;) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(long)type([])ident(exp) operator(=) keyword(new) type(long)operator([)integer(1)operator(])operator(;) - type(double) ident(f) operator(=) ident(frexp)operator(()ident(value)operator(,) ident(exp)operator(\))operator(;) - ident(f) operator(=) ident(ldexp)operator(()ident(f)operator(,) ident(DBL_MANT_DIG)operator(\))operator(;) - type(long) ident(n) operator(=) ident(exp)operator([)integer(0)operator(]) operator(-) ident(DBL_MANT_DIG)operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(x) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(f_to_i)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newFloat)operator(()ident(f)operator(\))operator(\))operator(,) - ident(f_expt)operator(()ident(context)operator(,) - ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(FLT_RADIX)operator(\))operator(,) - ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(n)operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(x)operator(;) - operator(}) - - comment(/** floor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(floor)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(floor)operator(()operator(\)) operator({) - keyword(return) ident(dbl2num)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(floor)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - comment(/** flo_ceil - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ceil)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(ceil)operator(()operator(\)) operator({) - keyword(return) ident(dbl2num)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(ceil)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - comment(/** flo_round - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(round)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(round)operator(()operator(\)) operator({) - type(double) ident(f) operator(=) ident(value)operator(;) - keyword(if) operator(()ident(f) operator(>) float(0.0)operator(\)) operator({) - ident(f) operator(=) pre_type(Math)operator(.)ident(floor)operator(()ident(f) operator(+) float(0.5)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(f) operator(<) float(0.0)operator(\)) operator({) - ident(f) operator(=) pre_type(Math)operator(.)ident(ceil)operator(()ident(f) operator(-) float(0.5)operator(\))operator(;) - operator(}) - keyword(return) ident(dbl2num)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(f)operator(\))operator(;) - operator(}) - - comment(/** flo_is_nan_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nan?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nan_p)operator(()operator(\)) operator({) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - comment(/** flo_is_infinite_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(infinite?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(infinite_p)operator(()operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value) operator(<) integer(0) operator(?) operator(-)integer(1) operator(:) integer(1)operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** flo_is_finite_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(finite?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(finite_p)operator(()operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(value)operator(\)) operator(||) pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyFloat) ident(aFloat)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(aFloat)operator(\))operator(;) - - pre_type(String) ident(strValue) operator(=) ident(aFloat)operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(aFloat)operator(.)ident(value)operator(\))operator(\)) operator({) - ident(strValue) operator(=) ident(aFloat)operator(.)ident(value) operator(<) integer(0) operator(?) string<delimiter(")content(-inf)delimiter(")> operator(:) string<delimiter(")content(inf)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(aFloat)operator(.)ident(value)operator(\))operator(\)) operator({) - ident(strValue) operator(=) string<delimiter(")content(nan)delimiter(")>operator(;) - operator(}) - ident(output)operator(.)ident(writeString)operator(()ident(strValue)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyFloat) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(RubyFloat) ident(result) operator(=) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(org)operator(.)ident(jruby)operator(.)ident(util)operator(.)ident(Convert)operator(.)ident(byteListToDouble)operator(()ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(,)pre_constant(false)operator(\))operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * GC (Garbage Collection\) Module - * - * Note: Since we rely on Java's memory model we can't provide the - * kind of control over garbage collection that MRI provides. - * - * @author Anders - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(GC)delimiter(")>operator(\)) -directive(public) type(class) class(RubyGC) operator({) - directive(public) directive(static) ident(RubyModule) ident(createGCModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(result) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(GC)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setGC)operator(()ident(result)operator(\))operator(;) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyGC)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(start)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - pre_type(System)operator(.)ident(gc)operator(()operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(garbage_collect)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - pre_type(System)operator(.)ident(gc)operator(()operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(enable)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(EMPTY_IMPLEMENTATION)operator(,) string<delimiter(")content(GC.enable will not work on JRuby)delimiter(")>operator(,) string<delimiter(")content(GC.enable)delimiter(")>operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(disable)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(EMPTY_IMPLEMENTATION)operator(,) string<delimiter(")content(GC.disable will not work on JRuby)delimiter(")>operator(,) string<delimiter(")content(GC.disable)delimiter(")>operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2006 Michael Studman <codehaus@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.util.io.STDIO)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.environment.OSEnvironmentReaderExcepton)operator(;) -keyword(import) include(org.jruby.environment.OSEnvironment)operator(;) -keyword(import) include(org.jruby.internal.runtime.ValueAccessor)operator(;) -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Constants)operator(;) -keyword(import) include(org.jruby.runtime.GlobalVariable)operator(;) -keyword(import) include(org.jruby.runtime.IAccessor)operator(;) -keyword(import) include(org.jruby.runtime.ReadonlyGlobalVariable)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.KCode)operator(;) - -comment(/** This class initializes global variables and constants. - * - * @author jpetersen - */) -directive(public) type(class) class(RubyGlobal) operator({) - - comment(/** - * Obligate string-keyed and string-valued hash, used for ENV and ENV_JAVA - * - */) - directive(public) directive(static) type(class) class(StringOnlyRubyHash) directive(extends) ident(RubyHash) operator({) - - directive(public) ident(StringOnlyRubyHash)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Map) ident(valueMap)operator(,) ident(IRubyObject) ident(defaultValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(valueMap)operator(,) ident(defaultValue)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyHash) ident(to_hash)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyHash) ident(hash) operator(=) ident(RubyHash)operator(.)ident(newHash)operator(()ident(runtime)operator(\))operator(;) - ident(hash)operator(.)ident(replace)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(;) - keyword(return) ident(hash)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(return) local_variable(super)operator(.)ident(op_aref)operator(()ident(context)operator(,) ident(key)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(key)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(key)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(value)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\)) operator(&&) operator(!)ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(value)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) local_variable(super)operator(.)ident(delete)operator(()ident(context)operator(,) ident(key)operator(,) ident(org)operator(.)ident(jruby)operator(.)ident(runtime)operator(.)ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - comment(//return super.aset(getRuntime(\).newString("sadfasdF"\), getRuntime(\).newString("sadfasdF"\)\);) - keyword(return) local_variable(super)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(key)operator(,) string<delimiter(")content(to_str)delimiter(")>operator(\))operator(,) - ident(value)operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(value)operator(,) string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\))operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(ENV)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(void) ident(createGlobals)operator(()ident(ThreadContext) ident(context)operator(,) ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(TOPLEVEL_BINDING)delimiter(")>operator(,) ident(runtime)operator(.)ident(newBinding)operator(()operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(TRUE)delimiter(")>operator(,) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(FALSE)delimiter(")>operator(,) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(NIL)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - - comment(// define ARGV and $* for this runtime) - ident(RubyArray) ident(argvArray) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - pre_type(String)type([]) ident(argv) operator(=) ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getArgv)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(argv)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(argvArray)operator(.)ident(append)operator(()ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(argv)operator([)ident(i)operator(])operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(ARGV)delimiter(")>operator(,) ident(argvArray)operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($*)delimiter(")>operator(,) keyword(new) ident(ValueAccessor)operator(()ident(argvArray)operator(\))operator(\))operator(;) - - ident(IAccessor) ident(d) operator(=) keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(newString)operator(() - ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(displayedFileName)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(define)operator(()string<delimiter(")content($PROGRAM_NAME)delimiter(")>operator(,) ident(d)operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(define)operator(()string<delimiter(")content($0)delimiter(")>operator(,) ident(d)operator(\))operator(;) - - comment(// Version information:) - ident(IRubyObject) ident(version) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(RUBY_VERSION)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(IRubyObject) ident(release) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(COMPILE_DATE)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(IRubyObject) ident(platform) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(PLATFORM)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(IRubyObject) ident(engine) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(ENGINE)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RUBY_VERSION)delimiter(")>operator(,) ident(version)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RUBY_PATCHLEVEL)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(RUBY_PATCHLEVEL)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RUBY_RELEASE_DATE)delimiter(")>operator(,) ident(release)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RUBY_PLATFORM)delimiter(")>operator(,) ident(platform)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RUBY_ENGINE)delimiter(")>operator(,) ident(engine)operator(\))operator(;) - - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(VERSION)delimiter(")>operator(,) ident(version)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(RELEASE_DATE)delimiter(")>operator(,) ident(release)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(PLATFORM)delimiter(")>operator(,) ident(platform)operator(\))operator(;) - - ident(IRubyObject) ident(jrubyVersion) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Constants)operator(.)ident(VERSION)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(JRUBY_VERSION)delimiter(")>operator(,) ident(jrubyVersion)operator(\))operator(;) - - ident(GlobalVariable) ident(kcodeGV) operator(=) keyword(new) ident(KCodeGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($KCODE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(NONE)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()ident(kcodeGV)operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(GlobalVariable)operator(.)ident(Copy)operator(()ident(runtime)operator(,) string<delimiter(")content($-K)delimiter(")>operator(,) ident(kcodeGV)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(defaultRS) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getRecordSeparator)operator(()operator(\))operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(GlobalVariable) ident(rs) operator(=) keyword(new) ident(StringGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($/)delimiter(")>operator(,) ident(defaultRS)operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()ident(rs)operator(\))operator(;) - ident(runtime)operator(.)ident(setRecordSeparatorVar)operator(()ident(rs)operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(setDefaultSeparator)operator(()ident(defaultRS)operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(StringGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($)char(\\\\)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(StringGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($,)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LineNumberGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($.)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LastlineGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($_)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LastExitStatusVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($?)delimiter(")>operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(ErrorInfoGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($!)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(NonEffectiveGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($=)delimiter(")>operator(,) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(\))operator(\))operator(;) - - keyword(if)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getInputFieldSeparator)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(GlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($;)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(GlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($;)delimiter(")>operator(,) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getInputFieldSeparator)operator(()operator(\))operator(,) integer(0)operator(\))operator(\))operator(\))operator(;) - operator(}) - - pre_type(Boolean) ident(verbose) operator(=) ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getVerbose)operator(()operator(\))operator(;) - ident(IRubyObject) ident(verboseValue) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(verbose) operator(==) pre_constant(null)operator(\)) operator({) - ident(verboseValue) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(verbose) operator(==) pre_type(Boolean)operator(.)ident(TRUE)operator(\)) operator({) - ident(verboseValue) operator(=) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(verboseValue) operator(=) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(VerboseGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($VERBOSE)delimiter(")>operator(,) ident(verboseValue)operator(\))operator(\))operator(;) - - ident(IRubyObject) ident(debug) operator(=) ident(runtime)operator(.)ident(newBoolean)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isDebug)operator(()operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(DebugGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($DEBUG)delimiter(")>operator(,) ident(debug)operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(DebugGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($-d)delimiter(")>operator(,) ident(debug)operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(SafeGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($SAFE)delimiter(")>operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(BacktraceGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($@)delimiter(")>operator(\))operator(\))operator(;) - - ident(IRubyObject) ident(stdin) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(STDIO)operator(.)ident(IN)operator(\))operator(;) - ident(IRubyObject) ident(stdout) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(STDIO)operator(.)ident(OUT)operator(\))operator(;) - ident(IRubyObject) ident(stderr) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(STDIO)operator(.)ident(ERR)operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(InputGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($stdin)delimiter(")>operator(,) ident(stdin)operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(OutputGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($stdout)delimiter(")>operator(,) ident(stdout)operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(alias)operator(()string<delimiter(")content($>)delimiter(")>operator(,) string<delimiter(")content($stdout)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(alias)operator(()string<delimiter(")content($defout)delimiter(")>operator(,) string<delimiter(")content($stdout)delimiter(")>operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(OutputGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($stderr)delimiter(")>operator(,) ident(stderr)operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(alias)operator(()string<delimiter(")content($deferr)delimiter(")>operator(,) string<delimiter(")content($stderr)delimiter(")>operator(\))operator(;) - - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(STDIN)delimiter(")>operator(,) ident(stdin)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(STDOUT)delimiter(")>operator(,) ident(stdout)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(STDERR)delimiter(")>operator(,) ident(stderr)operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LoadedFeatures)operator(()ident(runtime)operator(,) string<delimiter(")content($)char(\\")delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LoadedFeatures)operator(()ident(runtime)operator(,) string<delimiter(")content($LOADED_FEATURES)delimiter(")>operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LoadPath)operator(()ident(runtime)operator(,) string<delimiter(")content($:)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LoadPath)operator(()ident(runtime)operator(,) string<delimiter(")content($-I)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LoadPath)operator(()ident(runtime)operator(,) string<delimiter(")content($LOAD_PATH)delimiter(")>operator(\))operator(\))operator(;) - - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(MatchMatchGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($&)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(PreMatchGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($`)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(PostMatchGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($')delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(LastMatchGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($+)delimiter(")>operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(defineVariable)operator(()keyword(new) ident(BackRefGlobalVariable)operator(()ident(runtime)operator(,) string<delimiter(")content($~)delimiter(")>operator(\))operator(\))operator(;) - - comment(// On platforms without a c-library accessable through JNA, getpid will return hashCode ) - comment(// as $$ used to. Using $$ to kill processes could take down many runtimes, but by basing) - comment(// $$ on getpid(\) where available, we have the same semantics as MRI.) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($$)delimiter(")>operator(,) keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(newFixnum)operator(()ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpid)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - - comment(// after defn of $stderr as the call may produce warnings) - ident(defineGlobalEnvConstants)operator(()ident(runtime)operator(\))operator(;) - - comment(// Fixme: Do we need the check or does Main.java not call this...they should consolidate ) - keyword(if) operator(()ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($*)delimiter(")>operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($*)delimiter(")>operator(,) keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($-p)delimiter(")>operator(,) - keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isAssumePrinting)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($-n)delimiter(")>operator(,) - keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isAssumeLoop)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($-a)delimiter(")>operator(,) - keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isSplit)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(defineReadonly)operator(()string<delimiter(")content($-l)delimiter(")>operator(,) - keyword(new) ident(ValueAccessor)operator(()ident(runtime)operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(isProcessLineEnds)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - - comment(// ARGF, $< object) - ident(RubyArgsFile)operator(.)ident(initArgsFile)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(defineGlobalEnvConstants)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - - pre_type(Map) ident(environmentVariableMap) operator(=) pre_constant(null)operator(;) - ident(OSEnvironment) ident(environment) operator(=) keyword(new) ident(OSEnvironment)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(environmentVariableMap) operator(=) ident(environment)operator(.)ident(getEnvironmentVariableMap)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(OSEnvironmentReaderExcepton) ident(e)operator(\)) operator({) - comment(// If the environment variables are not accessible shouldn't terminate ) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MISCELLANEOUS)operator(,) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(environmentVariableMap) operator(==) pre_constant(null)operator(\)) operator({) - comment(// if the environment variables can't be obtained, define an empty ENV) - ident(environmentVariableMap) operator(=) keyword(new) pre_type(HashMap)operator(()operator(\))operator(;) - operator(}) - - ident(StringOnlyRubyHash) ident(h1) operator(=) keyword(new) ident(StringOnlyRubyHash)operator(()ident(runtime)operator(,) - ident(environmentVariableMap)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - ident(h1)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(StringOnlyRubyHash)operator(.)ident(class)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(ENV)delimiter(")>operator(,) ident(h1)operator(\))operator(;) - - comment(// Define System.getProperties(\) in ENV_JAVA) - pre_type(Map) ident(systemProps) operator(=) ident(environment)operator(.)ident(getSystemPropertiesMap)operator(()ident(runtime)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(ENV_JAVA)delimiter(")>operator(,) keyword(new) ident(StringOnlyRubyHash)operator(() - ident(runtime)operator(,) ident(systemProps)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(\))operator(;) - - operator(}) - - directive(private) directive(static) type(class) class(NonEffectiveGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(NonEffectiveGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(INEFFECTIVE_GLOBAL)operator(,) string<delimiter(")content(warning: variable )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( is no longer effective; ignored)delimiter(")>operator(,) ident(name)operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(INEFFECTIVE_GLOBAL)operator(,) string<delimiter(")content(warning: variable )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( is no longer effective)delimiter(")>operator(,) ident(name)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(LastExitStatusVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(LastExitStatusVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - ident(IRubyObject) ident(lastExitStatus) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getLastExitStatus)operator(()operator(\))operator(;) - keyword(return) ident(lastExitStatus) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(lastExitStatus)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(lastExitStatus)operator(\)) operator({) - ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(setLastExitStatus)operator(()ident(lastExitStatus)operator(\))operator(;) - - keyword(return) ident(lastExitStatus)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(MatchMatchGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(MatchMatchGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(last_match)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(PreMatchGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(PreMatchGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(match_pre)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(PostMatchGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(PostMatchGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(match_post)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(LastMatchGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(LastMatchGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(match_last)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(BackRefGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(BackRefGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(getBackref)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RuntimeHelpers)operator(.)ident(setBackref)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - - comment(// Accessor methods.) - - directive(private) directive(static) type(class) class(LineNumberGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(LineNumberGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(RubyFixnum) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RubyArgsFile)operator(.)ident(setCurrentLineNumber)operator(()ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($<)delimiter(")>operator(\))operator(,)ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(value)operator(\))operator(\))operator(;) - keyword(return) local_variable(super)operator(.)ident(set)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(ErrorInfoGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(ErrorInfoGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - ident(set)operator(()ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(value)operator(.)ident(isNil)operator(()operator(\)) operator(&&) - operator(!)ident(runtime)operator(.)ident(getException)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(value)operator(\)) operator(&&) - operator(!)operator(()ident(JavaUtil)operator(.)ident(isJavaObject)operator(()ident(value)operator(\)) operator(&&) ident(JavaUtil)operator(.)ident(unwrapJavaObject)operator(()ident(value)operator(\)) keyword(instanceof) exception(Exception)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(assigning non-exception to $!)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(setErrorInfo)operator(()ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getErrorInfo)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// FIXME: move out of this class!) - directive(public) directive(static) type(class) class(StringGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(StringGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(value)operator(.)ident(isNil)operator(()operator(\)) operator(&&) operator(!) operator(()ident(value) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(value of )delimiter(")> operator(+) ident(name)operator(()operator(\)) operator(+) string<delimiter(")content( must be a String)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) local_variable(super)operator(.)ident(set)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(KCodeGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(KCodeGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getKCode)operator(()operator(\))operator(.)ident(kcode)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - ident(runtime)operator(.)ident(setKCode)operator(()ident(KCode)operator(.)ident(create)operator(()ident(runtime)operator(,) ident(value)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(SafeGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(SafeGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) -comment(// int level = RubyNumeric.fix2int(value\);) -comment(// if (level < runtime.getSafeLevel(\)\) {) -comment(// throw runtime.newSecurityError("tried to downgrade safe level from " + ) -comment(// runtime.getSafeLevel(\) + " to " + level\);) -comment(// }) -comment(// runtime.setSafeLevel(level\);) - comment(// thread.setSafeLevel(level\);) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(SAFE_NOT_SUPPORTED)operator(,) string<delimiter(")content(SAFE levels are not supported in JRuby)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(VerboseGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(VerboseGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(initialValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(initialValue)operator(\))operator(;) - ident(set)operator(()ident(initialValue)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getVerbose)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(newValue)operator(\)) operator({) - keyword(if) operator(()ident(newValue)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(setVerbose)operator(()ident(newValue)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(setVerbose)operator(()ident(runtime)operator(.)ident(newBoolean)operator(()ident(newValue)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(newValue)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(DebugGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(DebugGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(initialValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(initialValue)operator(\))operator(;) - ident(set)operator(()ident(initialValue)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getDebug)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(newValue)operator(\)) operator({) - keyword(if) operator(()ident(newValue)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(setDebug)operator(()ident(newValue)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(setDebug)operator(()ident(runtime)operator(.)ident(newBoolean)operator(()ident(newValue)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(newValue)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(BacktraceGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(BacktraceGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - ident(IRubyObject) ident(errorInfo) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($!)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(backtrace) operator(=) ident(errorInfo)operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(errorInfo)operator(.)ident(callMethod)operator(()ident(errorInfo)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(backtrace)delimiter(")>operator(\))operator(;) - comment(//$@ returns nil if $!.backtrace is not an array) - keyword(if) operator(()operator(!)operator(()ident(backtrace) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) operator({) - ident(backtrace) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(backtrace)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($!)delimiter(")>operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content($! not set.)delimiter(")>operator(\))operator(;) - operator(}) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($!)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(value)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(set_backtrace)delimiter(")>operator(,) ident(value)operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(LastlineGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(LastlineGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(getLastLine)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RuntimeHelpers)operator(.)ident(setLastLine)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(InputGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(InputGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(==) ident(get)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - keyword(return) local_variable(super)operator(.)ident(set)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(OutputGlobalVariable) directive(extends) ident(GlobalVariable) operator({) - directive(public) ident(OutputGlobalVariable)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(==) ident(get)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - keyword(if) operator(()ident(value) keyword(instanceof) ident(RubyIO)operator(\)) operator({) - ident(RubyIO) ident(io) operator(=) operator(()ident(RubyIO)operator(\))ident(value)operator(;) - - comment(// HACK: in order to have stdout/err act like ttys and flush always,) - comment(// we set anything assigned to stdout/stderr to sync) - ident(io)operator(.)ident(getHandler)operator(()operator(\))operator(.)ident(setSync)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(value)operator(.)ident(respondsTo)operator(()string<delimiter(")content(write)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(name)operator(()operator(\)) operator(+) string<delimiter(")content( must have write method, )delimiter(")> operator(+) - ident(value)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) local_variable(super)operator(.)ident(set)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(LoadPath) directive(extends) ident(ReadonlyGlobalVariable) operator({) - directive(public) ident(LoadPath)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.GlobalVariable#get(\) - */) - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(getLoadPath)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(class) class(LoadedFeatures) directive(extends) ident(ReadonlyGlobalVariable) operator({) - directive(public) ident(LoadedFeatures)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(name)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.GlobalVariable#get(\) - */) - annotation(@Override) - directive(public) ident(IRubyObject) ident(get)operator(()operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(getLoadedFeatures)operator(()operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2006 Ola Bini <Ola.Bini@ki.se> - * Copyright (C\) 2006 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 MenTaLguY <mental@rydia.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.AbstractCollection)operator(;) -keyword(import) include(java.util.AbstractSet)operator(;) -keyword(import) include(java.util.Collection)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(java.util.NoSuchElementException)operator(;) -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) - -comment(// Design overview:) -comment(//) -comment(// RubyHash is implemented as hash table with a singly-linked list of) -comment(// RubyHash.RubyHashEntry objects for each bucket. RubyHashEntry objects) -comment(// are also kept in a doubly-linked list which reflects their insertion) -comment(// order and is used for iteration. For simplicity, this latter list is) -comment(// circular; a dummy RubyHashEntry, RubyHash.head, is used to mark the) -comment(// ends of the list.) -comment(//) -comment(// When an entry is removed from the table, it is also removed from the) -comment(// doubly-linked list. However, while the reference to the previous) -comment(// RubyHashEntry is cleared (to mark the entry as dead\), the reference) -comment(// to the next RubyHashEntry is preserved so that iterators are not) -comment(// invalidated: any iterator with a reference to a dead entry can climb) -comment(// back up into the list of live entries by chasing next references until) -comment(// it finds a live entry (or head\).) -comment(//) -comment(// Ordinarily, this scheme would require O(N\) time to clear a hash (since) -comment(// each RubyHashEntry would need to be visited and unlinked from the) -comment(// iteration list\), but RubyHash also maintains a generation count. Every) -comment(// time the hash is cleared, the doubly-linked list is simply discarded and) -comment(// the generation count incremented. Iterators check to see whether the) -comment(// generation count has changed; if it has, they reset themselves back to) -comment(// the new start of the list.) -comment(//) -comment(// This design means that iterators are never invalidated by changes to the) -comment(// hashtable, and they do not need to modify the structure during their) -comment(// lifecycle.) -comment(//) - -comment(/** Implementation of the Hash class. - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */) -annotation(@JRubyClass)operator(()ident(name) operator(=) string<delimiter(")content(Hash)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyHash) directive(extends) ident(RubyObject) directive(implements) pre_type(Map) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createHashClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(hashc) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Hash)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(HASH_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setHash)operator(()ident(hashc)operator(\))operator(;) - ident(hashc)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(HASH)operator(;) - ident(hashc)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyHash)operator(;) - operator(}) - operator(})operator(;) - - ident(hashc)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - - ident(hashc)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyHash)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(hashc)operator(;) - operator(}) - - directive(private) directive(final) directive(static) ident(ObjectAllocator) ident(HASH_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyHash)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(HASH)operator(;) - operator(}) - - comment(/** rb_hash_s_create - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(create)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\)) ident(recv)operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyHash) ident(hash)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(() - ident(args)operator([)integer(0)operator(])operator(,) ident(runtime)operator(.)ident(getHash)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_HASH)operator(,) string<delimiter(")content(to_hash)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(RubyHash) ident(otherHash) operator(=) operator(()ident(RubyHash)operator(\)) ident(tmp)operator(;) - keyword(return) keyword(new) ident(RubyHash)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(otherHash)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(()ident(args)operator(.)ident(length) operator(&) integer(1)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(odd number of args for Hash)delimiter(")>operator(\))operator(;) - operator(}) - - ident(hash) operator(=) operator(()ident(RubyHash)operator(\))ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(+=)integer(2)operator(\)) ident(hash)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(,) ident(args)operator([)ident(i)operator(+)integer(1)operator(])operator(\))operator(;) - - keyword(return) ident(hash)operator(;) - operator(}) - - comment(/** rb_hash_new - * - */) - directive(public) directive(static) directive(final) ident(RubyHash) ident(newHash)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyHash)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_new - * - */) - directive(public) directive(static) directive(final) ident(RubyHash) ident(newHash)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Map) ident(valueMap)operator(,) ident(IRubyObject) ident(defaultValue)operator(\)) operator({) - keyword(assert) ident(defaultValue) operator(!=) pre_constant(null)operator(;) - - keyword(return) keyword(new) ident(RubyHash)operator(()ident(runtime)operator(,) ident(valueMap)operator(,) ident(defaultValue)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyHashEntry)type([]) ident(table)operator(;) - directive(private) type(int) ident(size) operator(=) integer(0)operator(;) - directive(private) type(int) ident(threshold)operator(;) - - directive(private) directive(static) directive(final) type(int) ident(PROCDEFAULT_HASH_F) operator(=) integer(1) operator(<)operator(<) integer(10)operator(;) - - directive(private) ident(IRubyObject) ident(ifNone)operator(;) - - directive(private) ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(,) ident(RubyHash) ident(other)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - local_variable(this)operator(.)ident(ifNone) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(threshold) operator(=) ident(INITIAL_THRESHOLD)operator(;) - ident(table) operator(=) ident(other)operator(.)ident(internalCopyTable)operator(()ident(head)operator(\))operator(;) - ident(size) operator(=) ident(other)operator(.)ident(size)operator(;) - operator(}) - - directive(public) ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - local_variable(this)operator(.)ident(ifNone) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(alloc)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(defaultValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getHash)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(ifNone) operator(=) ident(defaultValue)operator(;) - ident(alloc)operator(()operator(\))operator(;) - operator(}) - - comment(/* - * Constructor for internal usage (mainly for Array#|, Array#&, Array#- and Array#uniq\) - * it doesn't initialize ifNone field - */) - ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getHash)operator(()operator(\))operator(,) ident(objectSpace)operator(\))operator(;) - ident(alloc)operator(()operator(\))operator(;) - operator(}) - - comment(// TODO should this be deprecated ? (to be efficient, internals should deal with RubyHash directly\)) - directive(public) ident(RubyHash)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Map) ident(valueMap)operator(,) ident(IRubyObject) ident(defaultValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getHash)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(ifNone) operator(=) ident(defaultValue)operator(;) - ident(alloc)operator(()operator(\))operator(;) - - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(valueMap)operator(.)ident(entrySet)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;)ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(Map)operator(.)ident(Entry) ident(e) operator(=) operator(()pre_type(Map)operator(.)ident(Entry)operator(\))ident(iter)operator(.)ident(next)operator(()operator(\))operator(;) - ident(internalPut)operator(()operator(()ident(IRubyObject)operator(\))ident(e)operator(.)ident(getKey)operator(()operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(e)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(final) type(void) ident(alloc)operator(()operator(\)) operator({) - ident(threshold) operator(=) ident(INITIAL_THRESHOLD)operator(;) - ident(generation)operator(++)operator(;) - ident(head)operator(.)ident(nextAdded) operator(=) ident(head)operator(.)ident(prevAdded) operator(=) ident(head)operator(;) - ident(table) operator(=) keyword(new) ident(RubyHashEntry)operator([)ident(MRI_HASH_RESIZE) operator(?) ident(MRI_INITIAL_CAPACITY) operator(:) ident(JAVASOFT_INITIAL_CAPACITY)operator(])operator(;) - operator(}) - - comment(/* ============================ - * Here are hash internals - * (This could be extracted to a separate class but it's not too large though\) - * ============================ - */) - - directive(private) directive(static) directive(final) type(int) ident(MRI_PRIMES)type([]) operator(=) operator({) - integer(8) operator(+) integer(3)operator(,) integer(16) operator(+) integer(3)operator(,) integer(32) operator(+) integer(5)operator(,) integer(64) operator(+) integer(3)operator(,) integer(128) operator(+) integer(3)operator(,) integer(256) operator(+) integer(27)operator(,) integer(512) operator(+) integer(9)operator(,) integer(1024) operator(+) integer(9)operator(,) integer(2048) operator(+) integer(5)operator(,) integer(4096) operator(+) integer(3)operator(,) - integer(8192) operator(+) integer(27)operator(,) integer(16384) operator(+) integer(43)operator(,) integer(32768) operator(+) integer(3)operator(,) integer(65536) operator(+) integer(45)operator(,) integer(131072) operator(+) integer(29)operator(,) integer(262144) operator(+) integer(3)operator(,) integer(524288) operator(+) integer(21)operator(,) integer(1048576) operator(+) integer(7)operator(,) - integer(2097152) operator(+) integer(17)operator(,) integer(4194304) operator(+) integer(15)operator(,) integer(8388608) operator(+) integer(9)operator(,) integer(16777216) operator(+) integer(43)operator(,) integer(33554432) operator(+) integer(35)operator(,) integer(67108864) operator(+) integer(15)operator(,) - integer(134217728) operator(+) integer(29)operator(,) integer(268435456) operator(+) integer(3)operator(,) integer(536870912) operator(+) integer(11)operator(,) integer(1073741824) operator(+) integer(85)operator(,) integer(0) - operator(})operator(;) - - directive(private) directive(static) directive(final) type(int) ident(JAVASOFT_INITIAL_CAPACITY) operator(=) integer(8)operator(;) comment(// 16 ?) - directive(private) directive(static) directive(final) type(int) ident(MRI_INITIAL_CAPACITY) operator(=) ident(MRI_PRIMES)operator([)integer(0)operator(])operator(;) - - directive(private) directive(static) directive(final) type(int) ident(INITIAL_THRESHOLD) operator(=) ident(JAVASOFT_INITIAL_CAPACITY) operator(-) operator(()ident(JAVASOFT_INITIAL_CAPACITY) operator(>)operator(>) integer(2)operator(\))operator(;) - directive(private) directive(static) directive(final) type(int) ident(MAXIMUM_CAPACITY) operator(=) integer(1) operator(<)operator(<) integer(30)operator(;) - - directive(private) directive(static) directive(final) ident(RubyHashEntry) ident(NO_ENTRY) operator(=) keyword(new) ident(RubyHashEntry)operator(()operator(\))operator(;) - directive(private) type(int) ident(generation) operator(=) integer(0)operator(;) comment(// generation count for O(1\) clears) - directive(private) directive(final) ident(RubyHashEntry) ident(head) operator(=) keyword(new) ident(RubyHashEntry)operator(()operator(\))operator(;) - operator({) ident(head)operator(.)ident(prevAdded) operator(=) ident(head)operator(.)ident(nextAdded) operator(=) ident(head)operator(;) operator(}) - - directive(static) directive(final) type(class) class(RubyHashEntry) directive(implements) pre_type(Map)operator(.)ident(Entry) operator({) - directive(private) ident(IRubyObject) ident(key)operator(;) - directive(private) ident(IRubyObject) ident(value)operator(;) - directive(private) ident(RubyHashEntry) ident(next)operator(;) - directive(private) ident(RubyHashEntry) ident(prevAdded)operator(;) - directive(private) ident(RubyHashEntry) ident(nextAdded)operator(;) - directive(private) type(int) ident(hash)operator(;) - - ident(RubyHashEntry)operator(()operator(\)) operator({) - ident(key) operator(=) ident(NEVER)operator(;) - operator(}) - - ident(RubyHashEntry)operator(()type(int) ident(h)operator(,) ident(IRubyObject) ident(k)operator(,) ident(IRubyObject) ident(v)operator(,) ident(RubyHashEntry) ident(e)operator(,) ident(RubyHashEntry) ident(head)operator(\)) operator({) - ident(key) operator(=) ident(k)operator(;) ident(value) operator(=) ident(v)operator(;) ident(next) operator(=) ident(e)operator(;) ident(hash) operator(=) ident(h)operator(;) - ident(prevAdded) operator(=) ident(head)operator(.)ident(prevAdded)operator(;) - ident(nextAdded) operator(=) ident(head)operator(;) - ident(nextAdded)operator(.)ident(prevAdded) operator(=) local_variable(this)operator(;) - ident(prevAdded)operator(.)ident(nextAdded) operator(=) local_variable(this)operator(;) - operator(}) - - directive(public) type(void) ident(detach)operator(()operator(\)) operator({) - keyword(if) operator(()ident(prevAdded) operator(!=) pre_constant(null)operator(\)) operator({) - ident(prevAdded)operator(.)ident(nextAdded) operator(=) ident(nextAdded)operator(;) - ident(nextAdded)operator(.)ident(prevAdded) operator(=) ident(prevAdded)operator(;) - ident(prevAdded) operator(=) pre_constant(null)operator(;) - operator(}) - operator(}) - - directive(public) type(boolean) ident(isLive)operator(()operator(\)) operator({) - keyword(return) ident(prevAdded) operator(!=) pre_constant(null)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(getKey)operator(()operator(\)) operator({) - keyword(return) ident(key)operator(;) - operator(}) - directive(public) pre_type(Object) ident(getJavaifiedKey)operator(()operator(\))operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(key)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - directive(public) pre_type(Object) ident(getJavaifiedValue)operator(()operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(value)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(setValue)operator(()pre_type(Object) ident(value)operator(\)) operator({) - ident(IRubyObject) ident(oldValue) operator(=) local_variable(this)operator(.)ident(value)operator(;) - keyword(if) operator(()ident(value) keyword(instanceof) ident(IRubyObject)operator(\)) operator({) - local_variable(this)operator(.)ident(value) operator(=) operator(()ident(IRubyObject)operator(\))ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(throw) keyword(new) exception(UnsupportedOperationException)operator(()string<delimiter(")content(directEntrySet(\) doesn't support setValue for non IRubyObject instance entries, convert them manually or use entrySet(\) instead)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(oldValue)operator(;) - operator(}) - - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\))operator({) - keyword(if)operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyHashEntry)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(RubyHashEntry) ident(otherEntry) operator(=) operator(()ident(RubyHashEntry)operator(\))ident(other)operator(;) - keyword(if)operator(()ident(key) operator(==) ident(otherEntry)operator(.)ident(key) operator(||) ident(key)operator(.)ident(eql)operator(()ident(otherEntry)operator(.)ident(key)operator(\))operator(\))operator({) - keyword(if)operator(()ident(value) operator(==) ident(otherEntry)operator(.)ident(value) operator(||) ident(value)operator(.)ident(equals)operator(()ident(otherEntry)operator(.)ident(value)operator(\))operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(int) ident(hashCode)operator(()operator(\))operator({) - keyword(return) ident(key)operator(.)ident(hashCode)operator(()operator(\)) operator(^) ident(value)operator(.)ident(hashCode)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(int) ident(JavaSoftHashValue)operator(()type(int) ident(h)operator(\)) operator({) - ident(h) operator(^=) operator(()ident(h) operator(>)operator(>)operator(>) integer(20)operator(\)) operator(^) operator(()ident(h) operator(>)operator(>)operator(>) integer(12)operator(\))operator(;) - keyword(return) ident(h) operator(^) operator(()ident(h) operator(>)operator(>)operator(>) integer(7)operator(\)) operator(^) operator(()ident(h) operator(>)operator(>)operator(>) integer(4)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(int) ident(JavaSoftBucketIndex)operator(()directive(final) type(int) ident(h)operator(,) directive(final) type(int) ident(length)operator(\)) operator({) - keyword(return) ident(h) operator(&) operator(()ident(length) operator(-) integer(1)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(int) ident(MRIHashValue)operator(()type(int) ident(h)operator(\)) operator({) - keyword(return) ident(h) operator(&) ident(HASH_SIGN_BIT_MASK)operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(HASH_SIGN_BIT_MASK) operator(=) operator(~)operator(()integer(1) operator(<)operator(<) integer(31)operator(\))operator(;) - directive(private) directive(static) type(int) ident(MRIBucketIndex)operator(()directive(final) type(int) ident(h)operator(,) directive(final) type(int) ident(length)operator(\)) operator({) - keyword(return) operator(()ident(h) operator(%) ident(length)operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(resize)operator(()type(int) ident(newCapacity)operator(\)) operator({) - directive(final) ident(RubyHashEntry)type([]) ident(oldTable) operator(=) ident(table)operator(;) - directive(final) ident(RubyHashEntry)type([]) ident(newTable) operator(=) keyword(new) ident(RubyHashEntry)operator([)ident(newCapacity)operator(])operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(oldTable)operator(.)ident(length)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(RubyHashEntry) ident(entry) operator(=) ident(oldTable)operator([)ident(j)operator(])operator(;) - ident(oldTable)operator([)ident(j)operator(]) operator(=) pre_constant(null)operator(;) - keyword(while) operator(()ident(entry) operator(!=) pre_constant(null)operator(\)) operator({) - ident(RubyHashEntry) ident(next) operator(=) ident(entry)operator(.)ident(next)operator(;) - type(int) ident(i) operator(=) ident(bucketIndex)operator(()ident(entry)operator(.)ident(hash)operator(,) ident(newCapacity)operator(\))operator(;) - ident(entry)operator(.)ident(next) operator(=) ident(newTable)operator([)ident(i)operator(])operator(;) - ident(newTable)operator([)ident(i)operator(]) operator(=) ident(entry)operator(;) - ident(entry) operator(=) ident(next)operator(;) - operator(}) - operator(}) - ident(table) operator(=) ident(newTable)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(JavaSoftCheckResize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(size) operator(>) ident(threshold)operator(\)) operator({) - type(int) ident(oldCapacity) operator(=) ident(table)operator(.)ident(length)operator(;) - keyword(if) operator(()ident(oldCapacity) operator(==) ident(MAXIMUM_CAPACITY)operator(\)) operator({) - ident(threshold) operator(=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(;) - keyword(return)operator(;) - operator(}) - type(int) ident(newCapacity) operator(=) ident(table)operator(.)ident(length) operator(<)operator(<) integer(1)operator(;) - ident(resize)operator(()ident(newCapacity)operator(\))operator(;) - ident(threshold) operator(=) ident(newCapacity) operator(-) operator(()ident(newCapacity) operator(>)operator(>) integer(2)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(MIN_CAPA) operator(=) integer(8)operator(;) - directive(private) directive(static) directive(final) type(int) ident(ST_DEFAULT_MAX_DENSITY) operator(=) integer(5)operator(;) - directive(private) directive(final) type(void) ident(MRICheckResize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(size) operator(/) ident(table)operator(.)ident(length) operator(>) ident(ST_DEFAULT_MAX_DENSITY)operator(\)) operator({) - type(int) ident(forSize) operator(=) ident(table)operator(.)ident(length) operator(+) integer(1)operator(;) comment(// size + 1;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(,) ident(newCapacity) operator(=) ident(MIN_CAPA)operator(;) ident(i) operator(<) ident(MRI_PRIMES)operator(.)ident(length)operator(;) ident(i)operator(++)operator(,) ident(newCapacity) operator(<)operator(<=) integer(1)operator(\)) operator({) - keyword(if) operator(()ident(newCapacity) operator(>) ident(forSize)operator(\)) operator({) - ident(resize)operator(()ident(MRI_PRIMES)operator([)ident(i)operator(])operator(\))operator(;) - keyword(return)operator(;) - operator(}) - operator(}) - keyword(return)operator(;) comment(// suboptimal for large hashes (> 1073741824 + 85 entries\) not very likely to happen) - operator(}) - operator(}) - comment(// ------------------------------) - directive(private) directive(static) type(boolean) ident(MRI_HASH) operator(=) pre_constant(true)operator(;) - directive(private) directive(static) type(boolean) ident(MRI_HASH_RESIZE) operator(=) pre_constant(true)operator(;) - - directive(private) directive(static) type(int) ident(hashValue)operator(()directive(final) type(int) ident(h)operator(\)) operator({) - keyword(return) ident(MRI_HASH) operator(?) ident(MRIHashValue)operator(()ident(h)operator(\)) operator(:) ident(JavaSoftHashValue)operator(()ident(h)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(int) ident(bucketIndex)operator(()directive(final) type(int) ident(h)operator(,) directive(final) type(int) ident(length)operator(\)) operator({) - keyword(return) ident(MRI_HASH) operator(?) ident(MRIBucketIndex)operator(()ident(h)operator(,) ident(length)operator(\)) operator(:) ident(JavaSoftBucketIndex)operator(()ident(h)operator(,) ident(length)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(checkResize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(MRI_HASH_RESIZE)operator(\)) ident(MRICheckResize)operator(()operator(\))operator(;) keyword(else) ident(JavaSoftCheckResize)operator(()operator(\))operator(;) - operator(}) - comment(// ------------------------------) - directive(public) directive(static) type(long) ident(collisions) operator(=) integer(0)operator(;) - - comment(// put implementation) - - directive(private) directive(final) type(void) ident(internalPut)operator(()directive(final) ident(IRubyObject) ident(key)operator(,) directive(final) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(internalPut)operator(()ident(key)operator(,) ident(value)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(internalPut)operator(()directive(final) ident(IRubyObject) ident(key)operator(,) directive(final) ident(IRubyObject) ident(value)operator(,) directive(final) type(boolean) ident(checkForExisting)operator(\)) operator({) - ident(checkResize)operator(()operator(\))operator(;) - directive(final) type(int) ident(hash) operator(=) ident(hashValue)operator(()ident(key)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - directive(final) type(int) ident(i) operator(=) ident(bucketIndex)operator(()ident(hash)operator(,) ident(table)operator(.)ident(length)operator(\))operator(;) - - comment(// if (table[i] != null\) collisions++;) - - keyword(if) operator(()ident(checkForExisting)operator(\)) operator({) - keyword(for) operator(()ident(RubyHashEntry) ident(entry) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(entry) operator(!=) pre_constant(null)operator(;) ident(entry) operator(=) ident(entry)operator(.)ident(next)operator(\)) operator({) - ident(IRubyObject) ident(k)operator(;) - keyword(if) operator(()ident(entry)operator(.)ident(hash) operator(==) ident(hash) operator(&&) operator(()operator(()ident(k) operator(=) ident(entry)operator(.)ident(key)operator(\)) operator(==) ident(key) operator(||) ident(key)operator(.)ident(eql)operator(()ident(k)operator(\))operator(\))operator(\)) operator({) - ident(entry)operator(.)ident(value) operator(=) ident(value)operator(;) - keyword(return)operator(;) - operator(}) - operator(}) - operator(}) - - ident(table)operator([)ident(i)operator(]) operator(=) keyword(new) ident(RubyHashEntry)operator(()ident(hash)operator(,) ident(key)operator(,) ident(value)operator(,) ident(table)operator([)ident(i)operator(])operator(,) ident(head)operator(\))operator(;) - ident(size)operator(++)operator(;) - operator(}) - - comment(// get implementation) - - directive(private) directive(final) ident(IRubyObject) ident(internalGet)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) comment(// specialized for value) - keyword(return) ident(internalGetEntry)operator(()ident(key)operator(\))operator(.)ident(value)operator(;) - operator(}) - - directive(private) directive(final) ident(RubyHashEntry) ident(internalGetEntry)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - directive(final) type(int) ident(hash) operator(=) ident(hashValue)operator(()ident(key)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()ident(RubyHashEntry) ident(entry) operator(=) ident(table)operator([)ident(bucketIndex)operator(()ident(hash)operator(,) ident(table)operator(.)ident(length)operator(\))operator(])operator(;) ident(entry) operator(!=) pre_constant(null)operator(;) ident(entry) operator(=) ident(entry)operator(.)ident(next)operator(\)) operator({) - ident(IRubyObject) ident(k)operator(;) - keyword(if) operator(()ident(entry)operator(.)ident(hash) operator(==) ident(hash) operator(&&) operator(()operator(()ident(k) operator(=) ident(entry)operator(.)ident(key)operator(\)) operator(==) ident(key) operator(||) ident(key)operator(.)ident(eql)operator(()ident(k)operator(\))operator(\))operator(\)) keyword(return) ident(entry)operator(;) - operator(}) - keyword(return) ident(NO_ENTRY)operator(;) - operator(}) - - comment(// delete implementation) - - - directive(private) directive(final) ident(RubyHashEntry) ident(internalDelete)operator(()directive(final) ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(return) ident(internalDelete)operator(()ident(hashValue)operator(()ident(key)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(,) ident(MATCH_KEY)operator(,) ident(key)operator(\))operator(;) - operator(}) - - directive(private) directive(final) ident(RubyHashEntry) ident(internalDeleteEntry)operator(()directive(final) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - comment(// n.b. we need to recompute the hash in case the key object was modified) - keyword(return) ident(internalDelete)operator(()ident(hashValue)operator(()ident(entry)operator(.)ident(key)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(,) ident(MATCH_ENTRY)operator(,) ident(entry)operator(\))operator(;) - operator(}) - - directive(private) directive(final) ident(RubyHashEntry) ident(internalDelete)operator(()directive(final) type(int) ident(hash)operator(,) directive(final) ident(EntryMatchType) ident(matchType)operator(,) directive(final) pre_type(Object) ident(obj)operator(\)) operator({) - directive(final) type(int) ident(i) operator(=) ident(bucketIndex)operator(()ident(hash)operator(,) ident(table)operator(.)ident(length)operator(\))operator(;) - - ident(RubyHashEntry) ident(entry) operator(=) ident(table)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(entry) operator(!=) pre_constant(null)operator(\)) operator({) - ident(RubyHashEntry) ident(prior) operator(=) pre_constant(null)operator(;) - keyword(for) operator(()operator(;) ident(entry) operator(!=) pre_constant(null)operator(;) ident(prior) operator(=) ident(entry)operator(,) ident(entry) operator(=) ident(entry)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(entry)operator(.)ident(hash) operator(==) ident(hash) operator(&&) ident(matchType)operator(.)ident(matches)operator(()ident(entry)operator(,) ident(obj)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(prior) operator(!=) pre_constant(null)operator(\)) operator({) - ident(prior)operator(.)ident(next) operator(=) ident(entry)operator(.)ident(next)operator(;) - operator(}) keyword(else) operator({) - ident(table)operator([)ident(i)operator(]) operator(=) ident(entry)operator(.)ident(next)operator(;) - operator(}) - ident(entry)operator(.)ident(detach)operator(()operator(\))operator(;) - ident(size)operator(--)operator(;) - keyword(return) ident(entry)operator(;) - operator(}) - operator(}) - operator(}) - - keyword(return) ident(NO_ENTRY)operator(;) - operator(}) - - directive(private) directive(static) directive(abstract) type(class) class(EntryMatchType) operator({) - directive(public) directive(abstract) type(boolean) ident(matches)operator(()directive(final) ident(RubyHashEntry) ident(entry)operator(,) directive(final) pre_type(Object) ident(obj)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(EntryMatchType) ident(MATCH_KEY) operator(=) keyword(new) ident(EntryMatchType)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(matches)operator(()directive(final) ident(RubyHashEntry) ident(entry)operator(,) directive(final) pre_type(Object) ident(obj)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(key) operator(=) ident(entry)operator(.)ident(key)operator(;) - keyword(return) ident(obj) operator(==) ident(key) operator(||) operator(()operator(()operator(()ident(IRubyObject)operator(\))ident(obj)operator(\))operator(.)ident(eql)operator(()ident(key)operator(\))operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) directive(final) ident(EntryMatchType) ident(MATCH_ENTRY) operator(=) keyword(new) ident(EntryMatchType)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(matches)operator(()directive(final) ident(RubyHashEntry) ident(entry)operator(,) directive(final) pre_type(Object) ident(obj)operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(equals)operator(()ident(obj)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(RubyHashEntry)type([]) ident(internalCopyTable)operator(()ident(RubyHashEntry) ident(destHead)operator(\)) operator({) - ident(RubyHashEntry)type([])ident(newTable) operator(=) keyword(new) ident(RubyHashEntry)operator([)ident(table)operator(.)ident(length)operator(])operator(;) - - keyword(for) operator(()ident(RubyHashEntry) ident(entry) operator(=) ident(head)operator(.)ident(nextAdded)operator(;) ident(entry) operator(!=) ident(head)operator(;) ident(entry) operator(=) ident(entry)operator(.)ident(nextAdded)operator(\)) operator({) - type(int) ident(i) operator(=) ident(bucketIndex)operator(()ident(entry)operator(.)ident(hash)operator(,) ident(table)operator(.)ident(length)operator(\))operator(;) - ident(newTable)operator([)ident(i)operator(]) operator(=) keyword(new) ident(RubyHashEntry)operator(()ident(entry)operator(.)ident(hash)operator(,) ident(entry)operator(.)ident(key)operator(,) ident(entry)operator(.)ident(value)operator(,) ident(newTable)operator([)ident(i)operator(])operator(,) ident(destHead)operator(\))operator(;) - operator(}) - keyword(return) ident(newTable)operator(;) - operator(}) - - directive(public) directive(static) directive(abstract) type(class) class(Visitor) operator({) - directive(public) directive(abstract) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(visitAll)operator(()ident(Visitor) ident(visitor)operator(\)) operator({) - type(int) ident(startGeneration) operator(=) ident(generation)operator(;) - keyword(for) operator(()ident(RubyHashEntry) ident(entry) operator(=) ident(head)operator(.)ident(nextAdded)operator(;) ident(entry) operator(!=) ident(head)operator(;) ident(entry) operator(=) ident(entry)operator(.)ident(nextAdded)operator(\)) operator({) - keyword(if) operator(()ident(startGeneration) operator(!=) ident(generation)operator(\)) operator({) - ident(startGeneration) operator(=) ident(generation)operator(;) - ident(entry) operator(=) ident(head)operator(.)ident(nextAdded)operator(;) - keyword(if) operator(()ident(entry) operator(==) ident(head)operator(\)) keyword(break)operator(;) - operator(}) - keyword(if) operator(()ident(entry)operator(.)ident(isLive)operator(()operator(\))operator(\)) ident(visitor)operator(.)ident(visit)operator(()ident(entry)operator(.)ident(key)operator(,) ident(entry)operator(.)ident(value)operator(\))operator(;) - operator(}) - operator(}) - - comment(/* ============================ - * End of hash internals - * ============================ - */) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** rb_hash_initialize - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - ident(ifNone) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(,) ident(block)operator(\))operator(;) - ident(flags) operator(|=) ident(PROCDEFAULT_HASH_F)operator(;) - operator(}) keyword(else) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) ident(ifNone) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_default - * - */) - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(default_value_get)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(return) ident(default_value_get)operator(()ident(context)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(default_value_get)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(1)operator(\))operator(;) - operator(}) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(default)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(default_value_get)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(ifNone)operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(default)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(default_value_get)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(ifNone)operator(,) string<delimiter(")content(call)delimiter(")>operator(,) local_variable(this)operator(,) ident(arg)operator(\))operator(;) - operator(}) - keyword(return) ident(ifNone)operator(;) - operator(}) - - comment(/** rb_hash_set_default - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(default=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(default_value_set)operator(()directive(final) ident(IRubyObject) ident(defaultValue)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - ident(ifNone) operator(=) ident(defaultValue)operator(;) - ident(flags) operator(&=) operator(~)ident(PROCDEFAULT_HASH_F)operator(;) - - keyword(return) ident(ifNone)operator(;) - operator(}) - - comment(/** rb_hash_default_proc - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(default_proc)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(default_proc)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0) operator(?) ident(ifNone) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_hash_modify - * - */) - directive(public) type(void) ident(modify)operator(()operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(hash)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't modify hash)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** inspect_hash - * - */) - directive(private) ident(IRubyObject) ident(inspectHash)operator(()directive(final) ident(ThreadContext) ident(context)operator(\)) operator({) - directive(final) ident(ByteList) ident(buffer) operator(=) keyword(new) ident(ByteList)operator(()operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content({)delimiter(')>operator(\))operator(;) - directive(final) type(boolean)type([]) ident(firstEntry) operator(=) keyword(new) type(boolean)operator([)integer(1)operator(])operator(;) - - ident(firstEntry)operator([)integer(0)operator(]) operator(=) pre_constant(true)operator(;) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(firstEntry)operator([)integer(0)operator(])operator(\)) ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(,)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content( )delimiter(')>operator(\))operator(;) - - ident(buffer)operator(.)ident(append)operator(()ident(inspect)operator(()ident(context)operator(,) ident(key)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(=)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(>)delimiter(')>operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()ident(inspect)operator(()ident(context)operator(,) ident(value)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(firstEntry)operator([)integer(0)operator(]) operator(=) pre_constant(false)operator(;) - operator(}) - operator(})operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(})delimiter(')>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buffer)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(size) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content({})delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content({...})delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(inspectHash)operator(()ident(context)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_size - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(size)delimiter(")>operator(,) string<delimiter(")content(length)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyFixnum) ident(rb_size)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(size)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_empty_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(empty?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(empty_p)operator(()operator(\)) operator({) - keyword(return) ident(size) operator(==) integer(0) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_hash_to_a - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(result) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(size)operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(key)operator(,) ident(value)operator(\))operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - ident(result)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_hash_to_s & to_s_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content({...})delimiter(")>operator(\))operator(;) - keyword(try) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(to_a)operator(()operator(\))operator(.)ident(to_s)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_rehash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rehash)delimiter(")>operator(\)) - directive(public) ident(RubyHash) ident(rehash)operator(()operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - directive(final) ident(RubyHashEntry)type([]) ident(oldTable) operator(=) ident(table)operator(;) - directive(final) ident(RubyHashEntry)type([]) ident(newTable) operator(=) keyword(new) ident(RubyHashEntry)operator([)ident(oldTable)operator(.)ident(length)operator(])operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(oldTable)operator(.)ident(length)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(RubyHashEntry) ident(entry) operator(=) ident(oldTable)operator([)ident(j)operator(])operator(;) - ident(oldTable)operator([)ident(j)operator(]) operator(=) pre_constant(null)operator(;) - keyword(while) operator(()ident(entry) operator(!=) pre_constant(null)operator(\)) operator({) - ident(RubyHashEntry) ident(next) operator(=) ident(entry)operator(.)ident(next)operator(;) - ident(entry)operator(.)ident(hash) operator(=) ident(entry)operator(.)ident(key)operator(.)ident(hashCode)operator(()operator(\))operator(;) comment(// update the hash value) - type(int) ident(i) operator(=) ident(bucketIndex)operator(()ident(entry)operator(.)ident(hash)operator(,) ident(newTable)operator(.)ident(length)operator(\))operator(;) - ident(entry)operator(.)ident(next) operator(=) ident(newTable)operator([)ident(i)operator(])operator(;) - ident(newTable)operator([)ident(i)operator(]) operator(=) ident(entry)operator(;) - ident(entry) operator(=) ident(next)operator(;) - operator(}) - operator(}) - ident(table) operator(=) ident(newTable)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_to_hash - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_hash)delimiter(")>operator(\)) - directive(public) ident(RubyHash) ident(to_hash)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) ident(RubyHash) ident(convertToHash)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) directive(final) type(void) ident(fastASet)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(internalPut)operator(()ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(op_aset)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_aset - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content([]=)delimiter(")>operator(,) string<delimiter(")content(store)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(key) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - ident(internalPut)operator(()ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) keyword(else) operator({) - directive(final) ident(RubyHashEntry) ident(entry) operator(=) ident(internalGetEntry)operator(()ident(key)operator(\))operator(;) - keyword(if) operator(()ident(entry) operator(!=) ident(NO_ENTRY)operator(\)) operator({) - ident(entry)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) keyword(else) operator({) - ident(RubyString) ident(realKey) operator(=) operator(()ident(RubyString)operator(\))ident(key)operator(;) - - keyword(if) operator(()operator(!)ident(realKey)operator(.)ident(isFrozen)operator(()operator(\))operator(\)) operator({) - ident(realKey) operator(=) ident(realKey)operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(realKey)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(\))operator(;)operator(;) - ident(realKey)operator(.)ident(setFrozen)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - - ident(internalPut)operator(()ident(realKey)operator(,) ident(value)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** - * Note: this is included as a compatibility measure for AR-JDBC - * @deprecated use RubyHash.op_aset instead - */) - directive(public) ident(IRubyObject) ident(aset)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(op_aset)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * Note: this is included as a compatibility measure for Mongrel+JRuby - * @deprecated use RubyHash.op_aref instead - */) - directive(public) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(return) ident(op_aref)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(key)operator(\))operator(;) - operator(}) - - directive(public) directive(final) ident(IRubyObject) ident(fastARef)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) comment(// retuns null when not found to avoid unnecessary getRuntime(\).getNil(\) call) - keyword(return) ident(internalGet)operator(()ident(key)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_aref - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(\)) operator({) - ident(IRubyObject) ident(value)operator(;) - keyword(return) operator(()operator(()ident(value) operator(=) ident(internalGet)operator(()ident(key)operator(\))operator(\)) operator(==) pre_constant(null)operator(\)) operator(?) ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(DEFAULT)operator(,) string<delimiter(")content(default)delimiter(")>operator(,) ident(key)operator(\)) operator(:) ident(value)operator(;) - operator(}) - - comment(/** rb_hash_fetch - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fetch)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(fetch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2) operator(&&) ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(BLOCK_BEATS_DEFAULT_VALUE)operator(,) string<delimiter(")content(block supersedes default value argument)delimiter(")>operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(internalGet)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(key not found)delimiter(")>operator(\))operator(;) - keyword(return) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** rb_hash_has_key - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(has_key?)delimiter(")>operator(,) string<delimiter(")content(key?)delimiter(")>operator(,) string<delimiter(")content(include?)delimiter(")>operator(,) string<delimiter(")content(member?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(has_key_p)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(return) ident(internalGetEntry)operator(()ident(key)operator(\)) operator(==) ident(NO_ENTRY) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(class) class(Found) directive(extends) exception(RuntimeException) operator({)operator(}) - - directive(private) type(boolean) ident(hasValue)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(expected)operator(\)) operator({) - keyword(try) operator({) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(value)operator(,) ident(expected)operator(\))operator(\)) operator({) - keyword(throw) keyword(new) ident(Found)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - keyword(return) pre_constant(false)operator(;) - operator(}) keyword(catch) operator(()ident(Found) ident(found)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_has_value - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(has_value?)delimiter(")>operator(,) string<delimiter(")content(value?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(has_value_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(expected)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(hasValue)operator(()ident(context)operator(,) ident(expected)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_hash_each - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(each)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - comment(// rb_assoc_new equivalent) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(key)operator(,) ident(value)operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_each_pair - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_pair)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(each_pair)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - comment(// rb_yield_values(2,...\) equivalent) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(key)operator(,) ident(value)operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_each_value - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_value)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(each_value)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(value)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_each_key - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_key)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(each_key)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(key)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_sort - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sort)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(sort)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(to_a)operator(()operator(\))operator(.)ident(sort_bang)operator(()ident(block)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(class) class(FoundKey) directive(extends) exception(RuntimeException) operator({) - directive(public) ident(IRubyObject) ident(key)operator(;) - ident(FoundKey)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - local_variable(super)operator(()operator(\))operator(;) - local_variable(this)operator(.)ident(key) operator(=) ident(key)operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_index - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(index)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(expected)operator(\)) operator({) - ident(IRubyObject) ident(key) operator(=) ident(internalIndex)operator(()ident(context)operator(,) ident(expected)operator(\))operator(;) - keyword(if) operator(()ident(key) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(key)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(internalIndex)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(expected)operator(\)) operator({) - keyword(try) operator({) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(value)operator(,) ident(expected)operator(\))operator(\)) operator({) - keyword(throw) keyword(new) ident(FoundKey)operator(()ident(key)operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) keyword(catch) operator(()ident(FoundKey) ident(found)operator(\)) operator({) - keyword(return) ident(found)operator(.)ident(key)operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_indexes - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(indexes)delimiter(")>operator(,) string<delimiter(")content(indices)delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(indices)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(indices)operator(\)) operator({) - keyword(return) ident(values_at)operator(()ident(context)operator(,) ident(indices)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_keys - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(keys)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(keys)operator(()operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyArray) ident(keys) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(size)operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(keys)operator(.)ident(append)operator(()ident(key)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(keys)operator(;) - operator(}) - - comment(/** rb_hash_values - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(values)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(rb_values)operator(()operator(\)) operator({) - directive(final) ident(RubyArray) ident(values) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(size)operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(values)operator(.)ident(append)operator(()ident(value)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(values)operator(;) - operator(}) - - comment(/** rb_hash_equal - * - */) - - directive(private) directive(static) directive(final) type(boolean) ident(EQUAL_CHECK_DEFAULT_VALUE) operator(=) pre_constant(false)operator(;) - - directive(private) directive(static) type(class) class(Mismatch) directive(extends) exception(RuntimeException) operator({)operator(}) - - annotation(@Override) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyHash)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(other)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_hash)delimiter(")>operator(\)) operator(&&) ident(equalInternal)operator(()ident(context)operator(,) ident(other)operator(,) local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(final) ident(RubyHash) ident(otherHash) operator(=) operator(()ident(RubyHash)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(size) operator(!=) ident(otherHash)operator(.)ident(size)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(EQUAL_CHECK_DEFAULT_VALUE)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(equalInternal)operator(()ident(context)operator(,) ident(ifNone)operator(,) ident(otherHash)operator(.)ident(ifNone)operator(\)) operator(&&) - operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) operator(()ident(otherHash)operator(.)ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(IRubyObject) ident(otherValue) operator(=) ident(otherHash)operator(.)ident(internalGet)operator(()ident(key)operator(\))operator(;) - keyword(if) operator(()ident(otherValue) operator(==) pre_constant(null) operator(||) operator(!)ident(equalInternal)operator(()ident(context)operator(,) ident(value)operator(,) ident(otherValue)operator(\))operator(\)) keyword(throw) keyword(new) ident(Mismatch)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(Mismatch) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_hash_shift - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(shift)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(shift)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - ident(RubyHashEntry) ident(entry) operator(=) ident(head)operator(.)ident(nextAdded)operator(;) - keyword(if) operator(()ident(entry) operator(!=) ident(head)operator(\)) operator({) - ident(RubyArray) ident(result) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(entry)operator(.)ident(key)operator(,) ident(entry)operator(.)ident(value)operator(\))operator(;) - ident(internalDeleteEntry)operator(()ident(entry)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - keyword(if) operator(()operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(ifNone)operator(,) string<delimiter(")content(call)delimiter(")>operator(,) local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(ifNone)operator(;) - operator(}) - operator(}) - - directive(public) directive(final) type(boolean) ident(fastDelete)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(return) ident(internalDelete)operator(()ident(key)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - - comment(/** rb_hash_delete - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(delete)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(key)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - directive(final) ident(RubyHashEntry) ident(entry) operator(=) ident(internalDelete)operator(()ident(key)operator(\))operator(;) - keyword(if) operator(()ident(entry) operator(!=) ident(NO_ENTRY)operator(\)) keyword(return) ident(entry)operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(key)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_hash_select - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(select)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(select)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(RubyArray) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newArray)operator(()ident(key)operator(,) ident(value)operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(true)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newArray)operator(()ident(key)operator(,) ident(value)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_hash_delete_if - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete_if)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(delete_if)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyHash) ident(self) operator(=) local_variable(this)operator(;) - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(key)operator(,) ident(value)operator(\))operator(,) pre_constant(null)operator(,) pre_constant(null)operator(,) pre_constant(true)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(self)operator(.)ident(delete)operator(()ident(context)operator(,) ident(key)operator(,) ident(block)operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_reject - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reject)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(reject)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyHash)operator(\))ident(dup)operator(()operator(\))operator(\))operator(.)ident(delete_if)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_reject_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reject!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(reject_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(n) operator(=) ident(size)operator(;) - ident(delete_if)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(==) ident(size)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_clear - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clear)delimiter(")>operator(\)) - directive(public) ident(RubyHash) ident(rb_clear)operator(()operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(size) operator(>) integer(0)operator(\)) operator({) - ident(alloc)operator(()operator(\))operator(;) - ident(size) operator(=) integer(0)operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_invert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(invert)delimiter(")>operator(\)) - directive(public) ident(RubyHash) ident(invert)operator(()directive(final) ident(ThreadContext) ident(context)operator(\)) operator({) - directive(final) ident(RubyHash) ident(result) operator(=) ident(newHash)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(result)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(value)operator(,) ident(key)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_hash_update - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(merge!)delimiter(")>operator(,) string<delimiter(")content(update)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(merge_bang)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(other)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyHash) ident(otherHash) operator(=) ident(other)operator(.)ident(convertToHash)operator(()operator(\))operator(;) - directive(final) ident(RubyHash) ident(self) operator(=) local_variable(this)operator(;) - ident(otherHash)operator(.)ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(existing) operator(=) ident(self)operator(.)ident(internalGet)operator(()ident(key)operator(\))operator(;) - keyword(if) operator(()ident(existing) operator(!=) pre_constant(null)operator(\)) - ident(value) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyArray)operator(.)ident(newArrayNoCopy)operator(()ident(runtime)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(key)operator(,) ident(existing)operator(,) ident(value)operator(})operator(\))operator(\))operator(;) - operator(}) - ident(self)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_merge - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(merge)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyHash) ident(merge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyHash)operator(\))ident(dup)operator(()operator(\))operator(\))operator(.)ident(merge_bang)operator(()ident(context)operator(,) ident(other)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_replace - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(RubyHash) ident(initialize_copy)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(replace)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_hash_replace - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(replace)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyHash) ident(replace)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - directive(final) ident(RubyHash) ident(otherHash) operator(=) ident(other)operator(.)ident(convertToHash)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(otherHash)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(rb_clear)operator(()operator(\))operator(;) - - directive(final) ident(RubyHash) ident(self) operator(=) local_variable(this)operator(;) - ident(otherHash)operator(.)ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(self)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(key)operator(,) ident(value)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - ident(ifNone) operator(=) ident(otherHash)operator(.)ident(ifNone)operator(;) - - keyword(if) operator(()operator(()ident(otherHash)operator(.)ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(flags) operator(|=) ident(PROCDEFAULT_HASH_F)operator(;) - operator(}) keyword(else) operator({) - ident(flags) operator(&=) operator(~)ident(PROCDEFAULT_HASH_F)operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_hash_values_at - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(values_at)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyArray) ident(values_at)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyArray) ident(result) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(op_aref)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) type(boolean) ident(hasDefaultProc)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(PROCDEFAULT_HASH_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getIfNone)operator(()operator(\))operator({) - keyword(return) ident(ifNone)operator(;) - operator(}) - - directive(private) directive(static) type(class) class(VisitorIOException) directive(extends) exception(RuntimeException) operator({) - ident(VisitorIOException)operator(()pre_type(Throwable) ident(cause)operator(\)) operator({) - local_variable(super)operator(()ident(cause)operator(\))operator(;) - operator(}) - operator(}) - - comment(// FIXME: Total hack to get flash in Rails marshalling/unmarshalling in session ok...We need) - comment(// to totally change marshalling to work with overridden core classes.) - directive(public) directive(static) type(void) ident(marshalTo)operator(()directive(final) ident(RubyHash) ident(hash)operator(,) directive(final) ident(MarshalStream) ident(output)operator(\)) directive(throws) exception(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(hash)operator(\))operator(;) - ident(output)operator(.)ident(writeInt)operator(()ident(hash)operator(.)ident(size)operator(\))operator(;) - keyword(try) operator({) - ident(hash)operator(.)ident(visitAll)operator(()keyword(new) ident(Visitor)operator(()operator(\)) operator({) - directive(public) type(void) ident(visit)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(try) operator({) - ident(output)operator(.)ident(dumpObject)operator(()ident(key)operator(\))operator(;) - ident(output)operator(.)ident(dumpObject)operator(()ident(value)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) ident(VisitorIOException)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) - operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(VisitorIOException) ident(e)operator(\)) operator({) - keyword(throw) operator(()exception(IOException)operator(\))ident(e)operator(.)ident(getCause)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(hash)operator(.)ident(ifNone)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(output)operator(.)ident(dumpObject)operator(()ident(hash)operator(.)ident(ifNone)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyHash) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(,) type(boolean) ident(defaultValue)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyHash) ident(result) operator(=) ident(newHash)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - type(int) ident(size) operator(=) ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(size)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(,) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(defaultValue)operator(\)) ident(result)operator(.)ident(default_value_set)operator(()ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) pre_type(Class) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) pre_type(Map)operator(.)ident(class)operator(;) - operator(}) - - comment(// Satisfy java.util.Set interface (for Java integration\)) - - directive(public) type(int) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(size)operator(;) - operator(}) - - directive(public) type(boolean) ident(isEmpty)operator(()operator(\)) operator({) - keyword(return) ident(size) operator(==) integer(0)operator(;) - operator(}) - - directive(public) type(boolean) ident(containsKey)operator(()pre_type(Object) ident(key)operator(\)) operator({) - keyword(return) ident(internalGet)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(key)operator(\))operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - - directive(public) type(boolean) ident(containsValue)operator(()pre_type(Object) ident(value)operator(\)) operator({) - keyword(return) ident(hasValue)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(get)operator(()pre_type(Object) ident(key)operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(internalGet)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(key)operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(put)operator(()pre_type(Object) ident(key)operator(,) pre_type(Object) ident(value)operator(\)) operator({) - ident(internalPut)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(key)operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(\))operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(remove)operator(()pre_type(Object) ident(key)operator(\)) operator({) - ident(IRubyObject) ident(rubyKey) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(key)operator(\))operator(;) - keyword(return) ident(internalDelete)operator(()ident(rubyKey)operator(\))operator(.)ident(value)operator(;) - operator(}) - - directive(public) type(void) ident(putAll)operator(()pre_type(Map) ident(map)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(map)operator(.)ident(keySet)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(Object) ident(key) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(;) - ident(internalPut)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(runtime)operator(,) ident(key)operator(\))operator(,) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(runtime)operator(,) ident(map)operator(.)ident(get)operator(()ident(key)operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(clear)operator(()operator(\)) operator({) - ident(rb_clear)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyHash)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) pre_constant(true)operator(;) - keyword(return) ident(op_equal)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) operator(()ident(RubyHash)operator(\))ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(?) pre_constant(true) operator(:) pre_constant(false)operator(;) - operator(}) - - directive(public) pre_type(Set) ident(keySet)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseSet)operator(()ident(KEY_VIEW)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Set) ident(directKeySet)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseSet)operator(()ident(DIRECT_KEY_VIEW)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Collection) ident(values)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseCollection)operator(()ident(VALUE_VIEW)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Collection) ident(directValues)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseCollection)operator(()ident(DIRECT_VALUE_VIEW)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Set) ident(entrySet)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseSet)operator(()ident(ENTRY_VIEW)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Set) ident(directEntrySet)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseSet)operator(()ident(DIRECT_ENTRY_VIEW)operator(\))operator(;) - operator(}) - - directive(private) type(class) class(BaseSet) directive(extends) pre_type(AbstractSet) operator({) - directive(final) ident(EntryView) ident(view)operator(;) - - directive(public) ident(BaseSet)operator(()ident(EntryView) ident(view)operator(\)) operator({) - local_variable(this)operator(.)ident(view) operator(=) ident(view)operator(;) - operator(}) - - directive(public) pre_type(Iterator) ident(iterator)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseIterator)operator(()ident(view)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(contains)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(view)operator(.)ident(contains)operator(()ident(RubyHash)operator(.)ident(this)operator(,) ident(o)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(clear)operator(()operator(\)) operator({) - ident(RubyHash)operator(.)ident(this)operator(.)ident(clear)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(int) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(RubyHash)operator(.)ident(this)operator(.)ident(size)operator(;) - operator(}) - - directive(public) type(boolean) ident(remove)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(view)operator(.)ident(remove)operator(()ident(RubyHash)operator(.)ident(this)operator(,) ident(o)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(class) class(BaseCollection) directive(extends) pre_type(AbstractCollection) operator({) - directive(final) ident(EntryView) ident(view)operator(;) - - directive(public) ident(BaseCollection)operator(()ident(EntryView) ident(view)operator(\)) operator({) - local_variable(this)operator(.)ident(view) operator(=) ident(view)operator(;) - operator(}) - - directive(public) pre_type(Iterator) ident(iterator)operator(()operator(\)) operator({) - keyword(return) keyword(new) ident(BaseIterator)operator(()ident(view)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(contains)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(view)operator(.)ident(contains)operator(()ident(RubyHash)operator(.)ident(this)operator(,) ident(o)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(clear)operator(()operator(\)) operator({) - ident(RubyHash)operator(.)ident(this)operator(.)ident(clear)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(int) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(RubyHash)operator(.)ident(this)operator(.)ident(size)operator(;) - operator(}) - - directive(public) type(boolean) ident(remove)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(view)operator(.)ident(remove)operator(()ident(RubyHash)operator(.)ident(this)operator(,) ident(o)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(class) class(BaseIterator) directive(implements) pre_type(Iterator) operator({) - directive(final) directive(private) ident(EntryView) ident(view)operator(;) - directive(private) ident(RubyHashEntry) ident(entry)operator(;) - directive(private) type(boolean) ident(peeking)operator(;) - directive(private) type(int) ident(startGeneration)operator(;) - - directive(public) ident(BaseIterator)operator(()ident(EntryView) ident(view)operator(\)) operator({) - local_variable(this)operator(.)ident(view) operator(=) ident(view)operator(;) - local_variable(this)operator(.)ident(entry) operator(=) ident(head)operator(;) - local_variable(this)operator(.)ident(startGeneration) operator(=) ident(generation)operator(;) - operator(}) - - directive(private) type(void) ident(advance)operator(()type(boolean) ident(consume)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(peeking)operator(\)) operator({) - keyword(do) operator({) - keyword(if) operator(()ident(startGeneration) operator(!=) ident(generation)operator(\)) operator({) - ident(startGeneration) operator(=) ident(generation)operator(;) - ident(entry) operator(=) ident(head)operator(;) - operator(}) - ident(entry) operator(=) ident(entry)operator(.)ident(nextAdded)operator(;) - operator(}) keyword(while) operator(()ident(entry) operator(!=) ident(head) operator(&&) operator(!)ident(entry)operator(.)ident(isLive)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(peeking) operator(=) operator(!)ident(consume)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(next)operator(()operator(\)) operator({) - ident(advance)operator(()pre_constant(true)operator(\))operator(;) - keyword(if) operator(()ident(entry) operator(==) ident(head)operator(\)) operator({) - ident(peeking) operator(=) pre_constant(true)operator(;) comment(// remain where we are) - keyword(throw) keyword(new) exception(NoSuchElementException)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(view)operator(.)ident(convertEntry)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(entry)operator(\))operator(;) - operator(}) - - comment(// once hasNext has been called, we commit to next(\) returning) - comment(// the entry it found, even if it were subsequently deleted) - directive(public) type(boolean) ident(hasNext)operator(()operator(\)) operator({) - ident(advance)operator(()pre_constant(false)operator(\))operator(;) - keyword(return) ident(entry) operator(!=) ident(head)operator(;) - operator(}) - - directive(public) type(void) ident(remove)operator(()operator(\)) operator({) - keyword(if) operator(()ident(entry) operator(==) ident(head)operator(\)) operator({) - keyword(throw) keyword(new) exception(IllegalStateException)operator(()string<delimiter(")content(Iterator out of range)delimiter(")>operator(\))operator(;) - operator(}) - ident(internalDeleteEntry)operator(()ident(entry)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) directive(abstract) type(class) class(EntryView) operator({) - directive(public) directive(abstract) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(value)operator(\))operator(;) - directive(public) directive(abstract) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\))operator(;) - directive(public) directive(abstract) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(EntryView) ident(DIRECT_KEY_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(key)operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(IRubyObject)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(return) ident(hash)operator(.)ident(internalGet)operator(()operator(()ident(IRubyObject)operator(\))ident(o)operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(IRubyObject)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(return) ident(hash)operator(.)ident(internalDelete)operator(()operator(()ident(IRubyObject)operator(\))ident(o)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) directive(final) ident(EntryView) ident(KEY_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(entry)operator(.)ident(key)operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(hash)operator(.)ident(containsKey)operator(()ident(o)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(hash)operator(.)ident(remove)operator(()ident(o)operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) directive(final) ident(EntryView) ident(DIRECT_VALUE_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(value)operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(IRubyObject)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(IRubyObject) ident(obj) operator(=) operator(()ident(IRubyObject)operator(\))ident(o)operator(;) - keyword(return) ident(hash)operator(.)ident(hasValue)operator(()ident(obj)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(obj)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(IRubyObject)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(IRubyObject) ident(obj) operator(=) operator(()ident(IRubyObject)operator(\)) ident(o)operator(;) - ident(IRubyObject) ident(key) operator(=) ident(hash)operator(.)ident(internalIndex)operator(()ident(obj)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(obj)operator(\))operator(;) - keyword(if) operator(()ident(key) operator(==) pre_constant(null)operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(return) ident(hash)operator(.)ident(internalDelete)operator(()ident(key)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(EntryView) ident(VALUE_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(entry)operator(.)ident(value)operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(hash)operator(.)ident(containsValue)operator(()ident(o)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - ident(IRubyObject) ident(value) operator(=) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(hash)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(o)operator(\))operator(;) - ident(IRubyObject) ident(key) operator(=) ident(hash)operator(.)ident(internalIndex)operator(()ident(hash)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - keyword(if) operator(()ident(key) operator(==) pre_constant(null)operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(return) ident(hash)operator(.)ident(internalDelete)operator(()ident(key)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(EntryView) ident(DIRECT_ENTRY_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(entry)operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(RubyHashEntry)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(RubyHashEntry) ident(entry) operator(=) operator(()ident(RubyHashEntry)operator(\))ident(o)operator(;) - ident(RubyHashEntry) ident(candidate) operator(=) ident(internalGetEntry)operator(()ident(entry)operator(.)ident(key)operator(\))operator(;) - keyword(return) ident(candidate) operator(!=) ident(NO_ENTRY) operator(&&) ident(entry)operator(.)ident(equals)operator(()ident(candidate)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(RubyHashEntry)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - keyword(return) ident(hash)operator(.)ident(internalDeleteEntry)operator(()operator(()ident(RubyHashEntry)operator(\))ident(o)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(EntryView) ident(ENTRY_VIEW) operator(=) keyword(new) ident(EntryView)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(convertEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - keyword(return) keyword(new) ident(ConvertingEntry)operator(()ident(runtime)operator(,) ident(entry)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(contains)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(ConvertingEntry)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(ConvertingEntry) ident(entry) operator(=) operator(()ident(ConvertingEntry)operator(\))ident(o)operator(;) - ident(RubyHashEntry) ident(candidate) operator(=) ident(hash)operator(.)ident(internalGetEntry)operator(()ident(entry)operator(.)ident(entry)operator(.)ident(key)operator(\))operator(;) - keyword(return) ident(candidate) operator(!=) ident(NO_ENTRY) operator(&&) ident(entry)operator(.)ident(entry)operator(.)ident(equals)operator(()ident(candidate)operator(\))operator(;) - operator(}) - directive(public) type(boolean) ident(remove)operator(()ident(RubyHash) ident(hash)operator(,) pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(ConvertingEntry)operator(\))operator(\)) keyword(return) pre_constant(false)operator(;) - ident(ConvertingEntry) ident(entry) operator(=) operator(()ident(ConvertingEntry)operator(\))ident(o)operator(;) - keyword(return) ident(hash)operator(.)ident(internalDeleteEntry)operator(()ident(entry)operator(.)ident(entry)operator(\)) operator(!=) ident(NO_ENTRY)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) type(class) class(ConvertingEntry) directive(implements) pre_type(Map)operator(.)ident(Entry) operator({) - directive(private) directive(final) ident(RubyHashEntry) ident(entry)operator(;) - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - - directive(public) ident(ConvertingEntry)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyHashEntry) ident(entry)operator(\)) operator({) - local_variable(this)operator(.)ident(entry) operator(=) ident(entry)operator(;) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - operator(}) - - directive(public) pre_type(Object) ident(getKey)operator(()operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(entry)operator(.)ident(key)operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - directive(public) pre_type(Object) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(entry)operator(.)ident(value)operator(,) pre_type(Object)operator(.)ident(class)operator(\))operator(;) - operator(}) - directive(public) pre_type(Object) ident(setValue)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(setValue)operator(()ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(runtime)operator(,) ident(o)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(o)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(o) keyword(instanceof) ident(ConvertingEntry)operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - ident(ConvertingEntry) ident(other) operator(=) operator(()ident(ConvertingEntry)operator(\))ident(o)operator(;) - keyword(return) ident(entry)operator(.)ident(equals)operator(()ident(other)operator(.)ident(entry)operator(\))operator(;) - operator(}) - directive(public) type(int) ident(hashCode)operator(()operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(hashCode)operator(()operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2007 Koichiro Ohba <koichiro@meadowy.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.nio.ByteBuffer)operator(;) -keyword(import) include(java.nio.CharBuffer)operator(;) -keyword(import) include(java.nio.charset.CharacterCodingException)operator(;) -keyword(import) include(java.nio.charset.Charset)operator(;) -keyword(import) include(java.nio.charset.CharsetDecoder)operator(;) -keyword(import) include(java.nio.charset.CharsetEncoder)operator(;) -keyword(import) include(java.nio.charset.CodingErrorAction)operator(;) -keyword(import) include(java.nio.charset.IllegalCharsetNameException)operator(;) -keyword(import) include(java.nio.charset.MalformedInputException)operator(;) -keyword(import) include(java.nio.charset.UnmappableCharacterException)operator(;) -keyword(import) include(java.nio.charset.UnsupportedCharsetException)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(org.jruby.util.ByteList)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv)delimiter(")>operator(\)) -directive(public) type(class) class(RubyIconv) directive(extends) ident(RubyObject) operator({) - comment(//static private final String TRANSLIT = "//translit";) - directive(static) directive(private) directive(final) pre_type(String) ident(IGNORE) operator(=) string<delimiter(")content(//ignore)delimiter(")>operator(;) - - directive(private) pre_type(CharsetDecoder) ident(fromEncoding)operator(;) - directive(private) pre_type(CharsetEncoder) ident(toEncoding)operator(;) - - directive(public) ident(RubyIconv)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ObjectAllocator) ident(ICONV_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyIconv)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Failure) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::IllegalSequence)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(IllegalSequence) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::InvalidCharacter)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(InvalidCharacter) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::InvalidEncoding)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(InvalidEncoding) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::OutOfRange)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(OutOfRange) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Iconv::BrokenLibrary)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(ArgumentError)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Iconv::Failure)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(BrokenLibrary) operator({)operator(}) - - directive(public) directive(static) type(void) ident(createIconv)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(iconvClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Iconv)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ICONV_ALLOCATOR)operator(\))operator(;) - - ident(iconvClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyIconv)operator(.)ident(class)operator(\))operator(;) - - ident(RubyModule) ident(failure) operator(=) ident(iconvClass)operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(Failure)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(argumentError) operator(=) ident(runtime)operator(.)ident(getArgumentError)operator(()operator(\))operator(;) - - pre_type(String)type([]) ident(iconvErrors) operator(=) operator({)string<delimiter(")content(IllegalSequence)delimiter(")>operator(,) string<delimiter(")content(InvalidCharacter)delimiter(")>operator(,) string<delimiter(")content(InvalidEncoding)delimiter(")>operator(,) - string<delimiter(")content(OutOfRange)delimiter(")>operator(,) string<delimiter(")content(BrokenLibrary)delimiter(")>operator(})operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(iconvErrors)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyClass) ident(subClass) operator(=) ident(iconvClass)operator(.)ident(defineClassUnder)operator(()ident(iconvErrors)operator([)ident(i)operator(])operator(,) ident(argumentError)operator(,) ident(RubyFailure)operator(.)ident(ICONV_FAILURE_ALLOCATOR)operator(\))operator(;) - ident(subClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyFailure)operator(.)ident(class)operator(\))operator(;) - ident(subClass)operator(.)ident(includeModule)operator(()ident(failure)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(RubyFailure) directive(extends) ident(RubyException) operator({) - directive(private) ident(IRubyObject) ident(success)operator(;) - directive(private) ident(IRubyObject) ident(failed)operator(;) - - directive(public) directive(static) ident(RubyFailure) ident(newInstance)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(excptnClass)operator(,) pre_type(String) ident(msg)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyFailure)operator(()ident(runtime)operator(,) ident(excptnClass)operator(,) ident(msg)operator(\))operator(;) - operator(}) - - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(ICONV_FAILURE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyFailure)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(protected) ident(RubyFailure)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyFailure)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(String) ident(message)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) ident(message)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - local_variable(super)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - ident(success) operator(=) ident(args)operator(.)ident(length) operator(>=) integer(2) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(failed) operator(=) ident(args)operator(.)ident(length) operator(==) integer(3) operator(?) ident(args)operator([)integer(2)operator(]) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(success)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(success)operator(()operator(\)) operator({) - keyword(return) ident(success)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(failed)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(failed)operator(()operator(\)) operator({) - keyword(return) ident(failed)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(RubyModule) ident(rubyClass) operator(=) ident(getMetaClass)operator(()operator(\))operator(;) - pre_type(StringBuilder) ident(buffer) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()ident(rubyClass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(: )delimiter(")>operator(\))operator(.)ident(append)operator(()ident(success)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(")content(, )delimiter(")>operator(\))operator(.)ident(append)operator(()ident(failed)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buffer)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) pre_type(String) ident(getCharset)operator(()pre_type(String) ident(encoding)operator(\)) operator({) - type(int) ident(index) operator(=) ident(encoding)operator(.)ident(indexOf)operator(()string<delimiter(")content(//)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(index) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(encoding)operator(;) - keyword(return) ident(encoding)operator(.)ident(substring)operator(()integer(0)operator(,) ident(index)operator(\))operator(;) - operator(}) - - comment(/* Currently dead code, but useful when we figure out how to actually perform translit. - private static boolean isTranslit(String encoding\) { - return encoding.toLowerCase(\).indexOf(TRANSLIT\) != -1 ? true : false; - }*/) - - directive(private) directive(static) type(boolean) ident(isIgnore)operator(()pre_type(String) ident(encoding)operator(\)) operator({) - keyword(return) ident(encoding)operator(.)ident(toLowerCase)operator(()operator(\))operator(.)ident(indexOf)operator(()ident(IGNORE)operator(\)) operator(!=) operator(-)integer(1) operator(?) pre_constant(true) operator(:) pre_constant(false)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(to)operator(,) ident(IRubyObject) ident(from)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(RubyIconv) ident(iconv) operator(=) ident(newIconv)operator(()ident(context)operator(,) ident(recv)operator(,) ident(to)operator(,) ident(from)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(return) ident(iconv)operator(;) - - ident(IRubyObject) ident(result) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(result) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(iconv)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(iconv)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) directive(static) ident(RubyIconv) ident(newIconv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) - ident(IRubyObject) ident(to)operator(,) ident(IRubyObject) ident(from)operator(\)) operator({) - ident(RubyClass) ident(klazz) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - keyword(return) operator(()ident(RubyIconv)operator(\)) ident(klazz)operator(.)ident(newInstance)operator(() - ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(to)operator(,) ident(from)operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(arg1)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(arg1)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(arg2)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(arg2)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(String) ident(to) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - pre_type(String) ident(from) operator(=) ident(arg2)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(try) operator({) - - ident(fromEncoding) operator(=) pre_type(Charset)operator(.)ident(forName)operator(()ident(getCharset)operator(()ident(from)operator(\))operator(\))operator(.)ident(newDecoder)operator(()operator(\))operator(;) - ident(toEncoding) operator(=) pre_type(Charset)operator(.)ident(forName)operator(()ident(getCharset)operator(()ident(to)operator(\))operator(\))operator(.)ident(newEncoder)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isIgnore)operator(()ident(from)operator(\))operator(\)) ident(fromEncoding)operator(.)ident(onUnmappableCharacter)operator(()pre_type(CodingErrorAction)operator(.)ident(REPORT)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isIgnore)operator(()ident(to)operator(\))operator(\)) ident(toEncoding)operator(.)ident(onUnmappableCharacter)operator(()pre_type(CodingErrorAction)operator(.)ident(REPORT)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IllegalCharsetNameException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newInvalidEncoding)operator(()string<delimiter(")content(invalid encoding)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedCharsetException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newInvalidEncoding)operator(()string<delimiter(")content(invalid encoding)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSystemCallError)operator(()ident(e)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - ident(toEncoding) operator(=) pre_constant(null)operator(;) - ident(fromEncoding) operator(=) pre_constant(null)operator(;) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(iconv)operator(()ident(IRubyObject) ident(str)operator(\)) operator({) - keyword(return) ident(iconv)operator(()ident(str)operator(,) integer(0)operator(,) operator(-)integer(1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(iconv)operator(()ident(IRubyObject) ident(str)operator(,) ident(IRubyObject) ident(startArg)operator(\)) operator({) - type(int) ident(start) operator(=) integer(0)operator(;) - keyword(if) operator(()operator(!)ident(startArg)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(start) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(startArg)operator(\))operator(;) - keyword(return) ident(iconv)operator(()ident(str)operator(,) ident(start)operator(,) operator(-)integer(1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(iconv)operator(()ident(IRubyObject) ident(str)operator(,) ident(IRubyObject) ident(startArg)operator(,) ident(IRubyObject) ident(endArg)operator(\)) operator({) - type(int) ident(start) operator(=) integer(0)operator(;) - type(int) ident(end) operator(=) operator(-)integer(1)operator(;) - - keyword(if) operator(()operator(!)ident(startArg)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(start) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(startArg)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(endArg)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(end) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(endArg)operator(\))operator(;) - - keyword(return) ident(iconv)operator(()ident(str)operator(,) ident(start)operator(,) ident(end)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(iconv)operator(()ident(IRubyObject) ident(str)operator(,) type(int) ident(start)operator(,) type(int) ident(end)operator(\)) operator({) - keyword(if) operator(()ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(fromEncoding)operator(.)ident(reset)operator(()operator(\))operator(;) - ident(toEncoding)operator(.)ident(reset)operator(()operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(_iconv)operator(()ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(,) ident(start)operator(,) ident(end)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one, two or three arguments. - */) - directive(public) ident(IRubyObject) ident(iconv)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(iconv)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(iconv)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) integer(3)operator(:) - keyword(return) ident(iconv)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(// FIXME: We are assuming that original string will be raw bytes. If -Ku is provided) - comment(// this will not be true, but that is ok for now. Deal with that when someone needs it.) - directive(private) ident(IRubyObject) ident(_iconv)operator(()ident(RubyString) ident(str)operator(,) type(int) ident(start)operator(,) type(int) ident(end)operator(\)) operator({) - keyword(if) operator(()ident(fromEncoding) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(closed iconv)delimiter(")>operator(\))operator(;) - operator(}) - - ident(ByteList) ident(bytes) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - comment(// treat start and end as start...end for end >= 0, start..end for end < 0) - keyword(if) operator(()ident(start) operator(<) integer(0)operator(\)) operator({) - ident(start) operator(+=) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(end) operator(<) integer(0)operator(\)) operator({) - ident(end) operator(+=) integer(1) operator(+) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(end) operator(>) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(end) operator(=) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(start) operator(<) integer(0) operator(||) ident(end) operator(<) ident(start)operator(\)) operator({) comment(// invalid ranges result in an empty string) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - pre_type(ByteBuffer) ident(buf) operator(=) pre_type(ByteBuffer)operator(.)ident(wrap)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\)) operator(+) ident(start)operator(,) ident(end) operator(-) ident(start)operator(\))operator(;) - - keyword(try) operator({) - pre_type(CharBuffer) ident(cbuf) operator(=) ident(fromEncoding)operator(.)ident(decode)operator(()ident(buf)operator(\))operator(;) - ident(buf) operator(=) ident(toEncoding)operator(.)ident(encode)operator(()ident(cbuf)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(MalformedInputException) ident(e)operator(\)) operator({) - operator(}) keyword(catch) operator(()exception(UnmappableCharacterException) ident(e)operator(\)) operator({) - operator(}) keyword(catch) operator(()exception(CharacterCodingException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newInvalidEncoding)operator(()string<delimiter(")content(invalid sequence)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IllegalStateException) ident(e)operator(\)) operator({) - operator(}) - type(byte)type([]) ident(arr) operator(=) ident(buf)operator(.)ident(array)operator(()operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()ident(arr)operator(,) integer(0)operator(,) ident(buf)operator(.)ident(limit)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(iconv)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(iconv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(convertWithArgs)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(,) string<delimiter(")content(iconv)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(conv)delimiter(")>operator(,) ident(required) operator(=) integer(3)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(conv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(convertWithArgs)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(,) string<delimiter(")content(conv)delimiter(")>operator(\))operator(.)ident(join)operator(()ident(context)operator(,) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(charset_map)delimiter(")>operator(,) ident(meta)operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(charset_map_get)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCharsetMap)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String) ident(mapCharset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(val)operator(\)) operator({) - ident(RubyHash) ident(charset) operator(=) ident(val)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCharsetMap)operator(()operator(\))operator(;) - keyword(if) operator(()ident(charset)operator(.)ident(size)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(RubyString) ident(key) operator(=) ident(val)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(downcase)delimiter(")>operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(IRubyObject) ident(tryVal) operator(=) ident(charset)operator(.)ident(fastARef)operator(()ident(key)operator(\))operator(;) - keyword(if) operator(()ident(tryVal) operator(!=) pre_constant(null)operator(\)) ident(val) operator(=) ident(tryVal)operator(;) - operator(}) - - keyword(return) ident(val)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(convertWithArgs)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) pre_type(String) ident(function)operator(\)) operator({) - keyword(assert) ident(args)operator(.)ident(length) operator(>=) integer(2)operator(;) - - ident(RubyArray) ident(array) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(args)operator(.)ident(length) operator(-) integer(2)operator(\))operator(;) - ident(RubyIconv) ident(iconv) operator(=) ident(newIconv)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - - keyword(try) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(2)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(iconv)operator(.)ident(iconv)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(iconv)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(array)operator(;) - operator(}) - - comment(/* - private static IRubyObject convert(String fromEncoding, String toEncoding, RubyString original\) - throws UnsupportedEncodingException { - // Get all bytes from PLAIN string pretend they are not encoded in any way. - byte[] string = original.getBytes(\); - // Now create a string pretending it is from fromEncoding - string = new String(string, fromEncoding\).getBytes(toEncoding\); - // Finally recode back to PLAIN - return RubyString.newString(original.getRuntime(\), string\); - } - */) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.BufferedInputStream)operator(;) -keyword(import) include(java.io.ByteArrayInputStream)operator(;) -keyword(import) include(java.io.File)operator(;) -keyword(import) include(java.io.FileInputStream)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.PrintStream)operator(;) -keyword(import) include(java.io.UnsupportedEncodingException)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.HashSet)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(java.util.StringTokenizer)operator(;) -keyword(import) include(org.jruby.ast.executable.Script)operator(;) -keyword(import) include(org.jruby.exceptions.MainExitException)operator(;) -keyword(import) include(org.jruby.runtime.Constants)operator(;) -keyword(import) include(org.jruby.runtime.load.LoadService)operator(;) -keyword(import) include(org.jruby.util.ClassCache)operator(;) -keyword(import) include(org.jruby.util.JRubyFile)operator(;) -keyword(import) include(org.jruby.util.KCode)operator(;) -keyword(import) include(org.jruby.util.NormalizedFile)operator(;) -keyword(import) include(org.jruby.util.SafePropertyAccessor)operator(;) -keyword(import) include(org.objectweb.asm.Opcodes)operator(;) - -directive(public) type(class) class(RubyInstanceConfig) operator({) - - comment(/** - * The max count of active methods eligible for JIT-compilation. - */) - directive(private) directive(static) directive(final) type(int) ident(JIT_MAX_METHODS_LIMIT) operator(=) integer(4096)operator(;) - - comment(/** - * The max size of JIT-compiled methods (full class size\) allowed. - */) - directive(private) directive(static) directive(final) type(int) ident(JIT_MAX_SIZE_LIMIT) operator(=) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(;) - - comment(/** - * The JIT threshold to the specified method invocation count. - */) - directive(private) directive(static) directive(final) type(int) ident(JIT_THRESHOLD) operator(=) integer(50)operator(;) - - comment(/** The version to use for generated classes. Set to current JVM version by default */) - directive(public) directive(static) directive(final) type(int) ident(JAVA_VERSION)operator(;) - - comment(/** - * Default size for chained compilation. - */) - directive(private) directive(static) directive(final) type(int) ident(CHAINED_COMPILE_LINE_COUNT_DEFAULT) operator(=) integer(500)operator(;) - - comment(/** - * The number of lines at which a method, class, or block body is split into - * chained methods (to dodge 64k method-size limit in JVM\). - */) - directive(public) directive(static) directive(final) type(int) ident(CHAINED_COMPILE_LINE_COUNT) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getInt)operator(()string<delimiter(")content(jruby.compile.chainsize)delimiter(")>operator(,) ident(CHAINED_COMPILE_LINE_COUNT_DEFAULT)operator(\))operator(;) - - directive(public) type(enum) ident(CompileMode) operator({) - ident(JIT)operator(,) ident(FORCE)operator(,) ident(OFF)operator(;) - - directive(public) type(boolean) ident(shouldPrecompileCLI)operator(()operator(\)) operator({) - keyword(switch) operator(()local_variable(this)operator(\)) operator({) - keyword(case) ident(JIT)operator(:) keyword(case) ident(FORCE)operator(:) - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(shouldJIT)operator(()operator(\)) operator({) - keyword(switch) operator(()local_variable(this)operator(\)) operator({) - keyword(case) ident(JIT)operator(:) keyword(case) ident(FORCE)operator(:) - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(shouldPrecompileAll)operator(()operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(FORCE)operator(;) - operator(}) - operator(}) - directive(private) pre_type(InputStream) ident(input) operator(=) pre_type(System)operator(.)ident(in)operator(;) - directive(private) pre_type(PrintStream) ident(output) operator(=) pre_type(System)operator(.)ident(out)operator(;) - directive(private) pre_type(PrintStream) ident(error) operator(=) pre_type(System)operator(.)ident(err)operator(;) - directive(private) ident(Profile) ident(profile) operator(=) ident(Profile)operator(.)ident(DEFAULT)operator(;) - directive(private) type(boolean) ident(objectSpaceEnabled) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.objectspace.enabled)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - - directive(private) ident(CompileMode) ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(JIT)operator(;) - directive(private) type(boolean) ident(runRubyInProcess) operator(=) pre_constant(true)operator(;) - directive(private) pre_type(String) ident(currentDirectory)operator(;) - directive(private) pre_type(Map) ident(environment)operator(;) - directive(private) pre_type(String)type([]) ident(argv) operator(=) operator({)operator(})operator(;) - - directive(private) directive(final) type(boolean) ident(jitLogging)operator(;) - directive(private) directive(final) type(boolean) ident(jitLoggingVerbose)operator(;) - directive(private) directive(final) type(int) ident(jitLogEvery)operator(;) - directive(private) directive(final) type(int) ident(jitThreshold)operator(;) - directive(private) directive(final) type(int) ident(jitMax)operator(;) - directive(private) directive(final) type(int) ident(jitMaxSize)operator(;) - directive(private) directive(final) type(boolean) ident(samplingEnabled)operator(;) - directive(private) ident(CompatVersion) ident(compatVersion)operator(;) - - directive(private) pre_type(ClassLoader) ident(contextLoader) operator(=) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\))operator(.)ident(getContextClassLoader)operator(()operator(\))operator(;) - directive(private) pre_type(ClassLoader) ident(loader) operator(=) ident(contextLoader) operator(==) pre_constant(null) operator(?) ident(RubyInstanceConfig)operator(.)ident(class)operator(.)ident(getClassLoader)operator(()operator(\)) operator(:) ident(contextLoader)operator(;) - - directive(private) ident(ClassCache)operator(<)ident(Script)operator(>) ident(classCache)operator(;) - - comment(// from CommandlineParser) - directive(private) pre_type(List)operator(<)pre_type(String)operator(>) ident(loadPaths) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - directive(private) pre_type(Set)operator(<)pre_type(String)operator(>) ident(excludedMethods) operator(=) keyword(new) pre_type(HashSet)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - directive(private) pre_type(StringBuffer) ident(inlineScript) operator(=) keyword(new) pre_type(StringBuffer)operator(()operator(\))operator(;) - directive(private) type(boolean) ident(hasInlineScript) operator(=) pre_constant(false)operator(;) - directive(private) pre_type(String) ident(scriptFileName) operator(=) pre_constant(null)operator(;) - directive(private) pre_type(List)operator(<)pre_type(String)operator(>) ident(requiredLibraries) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - directive(private) type(boolean) ident(benchmarking) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(argvGlobalsOn) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(assumeLoop) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(assumePrinting) operator(=) pre_constant(false)operator(;) - directive(private) pre_type(Map) ident(optionGlobals) operator(=) keyword(new) pre_type(HashMap)operator(()operator(\))operator(;) - directive(private) type(boolean) ident(processLineEnds) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(split) operator(=) pre_constant(false)operator(;) - comment(// This property is a Boolean, to allow three values, so it can match MRI's nil, false and true) - directive(private) pre_type(Boolean) ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(FALSE)operator(;) - directive(private) type(boolean) ident(debug) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(showVersion) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(showBytecode) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(showCopyright) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(endOfArguments) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(shouldRunInterpreter) operator(=) pre_constant(true)operator(;) - directive(private) type(boolean) ident(shouldPrintUsage) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(shouldPrintProperties)operator(=)pre_constant(false)operator(;) - directive(private) type(boolean) ident(yarv) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(rubinius) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(yarvCompile) operator(=) pre_constant(false)operator(;) - directive(private) ident(KCode) ident(kcode) operator(=) ident(KCode)operator(.)ident(NONE)operator(;) - directive(private) pre_type(String) ident(recordSeparator) operator(=) string<delimiter(")char(\\n)delimiter(")>operator(;) - directive(private) type(boolean) ident(shouldCheckSyntax) operator(=) pre_constant(false)operator(;) - directive(private) pre_type(String) ident(inputFieldSeparator) operator(=) pre_constant(null)operator(;) - directive(private) type(boolean) ident(managementEnabled) operator(=) pre_constant(true)operator(;) - - directive(private) type(int) ident(safeLevel) operator(=) integer(0)operator(;) - - directive(private) pre_type(String) ident(jrubyHome)operator(;) - - directive(public) directive(static) directive(final) type(boolean) ident(FASTEST_COMPILE_ENABLED) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.fastest)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(BOXED_COMPILE_ENABLED) - operator(=) ident(FASTEST_COMPILE_ENABLED) - operator(||) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.boxed)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(FASTOPS_COMPILE_ENABLED) - operator(=) ident(FASTEST_COMPILE_ENABLED) - operator(||) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.fastops)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(FRAMELESS_COMPILE_ENABLED) - operator(=) ident(FASTEST_COMPILE_ENABLED) - operator(||) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.frameless)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(POSITIONLESS_COMPILE_ENABLED) - operator(=) ident(FASTEST_COMPILE_ENABLED) - operator(||) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.positionless)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(THREADLESS_COMPILE_ENABLED) - operator(=) ident(FASTEST_COMPILE_ENABLED) - operator(||) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.threadless)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(LAZYHANDLES_COMPILE) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.compile.lazyHandles)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(FORK_ENABLED) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.fork.enabled)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(boolean) ident(POOLING_ENABLED) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.thread.pool.enabled)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(POOL_MAX) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getInt)operator(()string<delimiter(")content(jruby.thread.pool.max)delimiter(")>operator(,) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(POOL_MIN) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getInt)operator(()string<delimiter(")content(jruby.thread.pool.min)delimiter(")>operator(,) integer(0)operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(POOL_TTL) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getInt)operator(()string<delimiter(")content(jruby.thread.pool.ttl)delimiter(")>operator(,) integer(60)operator(\))operator(;) - - directive(public) directive(static) directive(final) type(boolean) ident(NATIVE_NET_PROTOCOL) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.native.net.protocol)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - - directive(public) directive(static) type(boolean) ident(FULL_TRACE_ENABLED) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.debug.fullTrace)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - - directive(public) directive(static) directive(final) pre_type(String) ident(COMPILE_EXCLUDE) - operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.exclude)delimiter(")>operator(\))operator(;) - directive(public) directive(static) type(boolean) ident(nativeEnabled) operator(=) pre_constant(true)operator(;) - - - directive(public) directive(static) type(interface) class(LoadServiceCreator) operator({) - ident(LoadService) ident(create)operator(()ident(Ruby) ident(runtime)operator(\))operator(;) - - ident(LoadServiceCreator) ident(DEFAULT) operator(=) keyword(new) ident(LoadServiceCreator)operator(()operator(\)) operator({) - directive(public) ident(LoadService) ident(create)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(LoadService)operator(()ident(runtime)operator(\))operator(;) - operator(}) - operator(})operator(;) - operator(}) - - directive(private) ident(LoadServiceCreator) ident(creator) operator(=) ident(LoadServiceCreator)operator(.)ident(DEFAULT)operator(;) - - - directive(static) operator({) - pre_type(String) ident(specVersion) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - ident(specVersion) operator(=) pre_type(System)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.bytecode.version)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(specVersion) operator(==) pre_constant(null)operator(\)) operator({) - ident(specVersion) operator(=) pre_type(System)operator(.)ident(getProperty)operator(()string<delimiter(")content(java.specification.version)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()pre_type(System)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.native.enabled)delimiter(")>operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(nativeEnabled) operator(=) pre_type(Boolean)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.native.enabled)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(SecurityException) ident(se)operator(\)) operator({) - ident(nativeEnabled) operator(=) pre_constant(false)operator(;) - ident(specVersion) operator(=) string<delimiter(")content(1.5)delimiter(")>operator(;) - operator(}) - - keyword(if) operator(()ident(specVersion)operator(.)ident(equals)operator(()string<delimiter(")content(1.5)delimiter(")>operator(\))operator(\)) operator({) - ident(JAVA_VERSION) operator(=) ident(Opcodes)operator(.)ident(V1_5)operator(;) - operator(}) keyword(else) operator({) - ident(JAVA_VERSION) operator(=) ident(Opcodes)operator(.)ident(V1_6)operator(;) - operator(}) - operator(}) - - directive(public) type(int) ident(characterIndex) operator(=) integer(0)operator(;) - - directive(public) ident(RubyInstanceConfig)operator(()operator(\)) operator({) - keyword(if) operator(()ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\))operator(\)) - ident(currentDirectory) operator(=) string<delimiter(")content(/)delimiter(")>operator(;) - keyword(else) operator({) - ident(currentDirectory) operator(=) ident(JRubyFile)operator(.)ident(getFileProperty)operator(()string<delimiter(")content(user.dir)delimiter(")>operator(\))operator(;) - operator(}) - - ident(samplingEnabled) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.sampling.enabled)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - pre_type(String) ident(compatString) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.compat.version)delimiter(")>operator(,) string<delimiter(")content(RUBY1_8)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(compatString)operator(.)ident(equalsIgnoreCase)operator(()string<delimiter(")content(RUBY1_8)delimiter(")>operator(\))operator(\)) operator({) - ident(compatVersion) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(compatString)operator(.)ident(equalsIgnoreCase)operator(()string<delimiter(")content(RUBY1_9)delimiter(")>operator(\))operator(\)) operator({) - ident(compatVersion) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(;) - operator(}) keyword(else) operator({) - pre_type(System)operator(.)ident(err)operator(.)ident(println)operator(()string<delimiter(")content(Compatibility version `)delimiter(")> operator(+) ident(compatString) operator(+) string<delimiter(")content(' invalid; use RUBY1_8 or RUBY1_9. Using RUBY1_8.)delimiter(")>operator(\))operator(;) - ident(compatVersion) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(;) - operator(}) - - keyword(if) operator(()ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(OFF)operator(;) - ident(jitLogging) operator(=) pre_constant(false)operator(;) - ident(jitLoggingVerbose) operator(=) pre_constant(false)operator(;) - ident(jitLogEvery) operator(=) integer(0)operator(;) - ident(jitThreshold) operator(=) operator(-)integer(1)operator(;) - ident(jitMax) operator(=) integer(0)operator(;) - ident(jitMaxSize) operator(=) operator(-)integer(1)operator(;) - ident(managementEnabled) operator(=) pre_constant(false)operator(;) - operator(}) keyword(else) operator({) - pre_type(String) ident(threshold) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.threshold)delimiter(")>operator(\))operator(;) - pre_type(String) ident(max) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.max)delimiter(")>operator(\))operator(;) - pre_type(String) ident(maxSize) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.maxsize)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(COMPILE_EXCLUDE) operator(!=) pre_constant(null)operator(\)) operator({) - pre_type(String)type([]) ident(elements) operator(=) ident(COMPILE_EXCLUDE)operator(.)ident(split)operator(()string<delimiter(")content(,)delimiter(")>operator(\))operator(;) - keyword(for) operator(()pre_type(String) ident(element) operator(:) ident(elements)operator(\)) ident(excludedMethods)operator(.)ident(add)operator(()ident(element)operator(\))operator(;) - operator(}) - - ident(managementEnabled) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.management.enabled)delimiter(")>operator(,) pre_constant(true)operator(\))operator(;) - ident(runRubyInProcess) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.launch.inproc)delimiter(")>operator(,) pre_constant(true)operator(\))operator(;) - type(boolean) ident(jitProperty) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.enabled)delimiter(")>operator(\)) operator(!=) pre_constant(null)operator(;) - keyword(if) operator(()ident(jitProperty)operator(\)) operator({) - ident(error)operator(.)ident(print)operator(()string<delimiter(")content(jruby.jit.enabled property is deprecated; use jruby.compile.mode=(OFF|JIT|FORCE\) for -C, default, and +C flags)delimiter(")>operator(\))operator(;) - ident(compileMode) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.jit.enabled)delimiter(")>operator(\)) operator(?) ident(CompileMode)operator(.)ident(JIT) operator(:) ident(CompileMode)operator(.)ident(OFF)operator(;) - operator(}) keyword(else) operator({) - pre_type(String) ident(jitModeProperty) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.compile.mode)delimiter(")>operator(,) string<delimiter(")content(JIT)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(jitModeProperty)operator(.)ident(equals)operator(()string<delimiter(")content(OFF)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(OFF)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(jitModeProperty)operator(.)ident(equals)operator(()string<delimiter(")content(JIT)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(JIT)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(jitModeProperty)operator(.)ident(equals)operator(()string<delimiter(")content(FORCE)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(FORCE)operator(;) - operator(}) keyword(else) operator({) - ident(error)operator(.)ident(print)operator(()string<delimiter(")content(jruby.compile.mode property must be OFF, JIT, FORCE, or unset; defaulting to JIT)delimiter(")>operator(\))operator(;) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(JIT)operator(;) - operator(}) - operator(}) - ident(jitLogging) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.jit.logging)delimiter(")>operator(\))operator(;) - ident(jitLoggingVerbose) operator(=) ident(SafePropertyAccessor)operator(.)ident(getBoolean)operator(()string<delimiter(")content(jruby.jit.logging.verbose)delimiter(")>operator(\))operator(;) - pre_type(String) ident(logEvery) operator(=) ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.jit.logEvery)delimiter(")>operator(\))operator(;) - ident(jitLogEvery) operator(=) ident(logEvery) operator(==) pre_constant(null) operator(?) integer(0) operator(:) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(logEvery)operator(\))operator(;) - ident(jitThreshold) operator(=) ident(threshold) operator(==) pre_constant(null) operator(?) - ident(JIT_THRESHOLD) operator(:) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(threshold)operator(\))operator(;) - ident(jitMax) operator(=) ident(max) operator(==) pre_constant(null) operator(?) - ident(JIT_MAX_METHODS_LIMIT) operator(:) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(max)operator(\))operator(;) - ident(jitMaxSize) operator(=) ident(maxSize) operator(==) pre_constant(null) operator(?) - ident(JIT_MAX_SIZE_LIMIT) operator(:) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(maxSize)operator(\))operator(;) - operator(}) - - comment(// default ClassCache using jitMax as a soft upper bound) - ident(classCache) operator(=) keyword(new) ident(ClassCache)operator(<)ident(Script)operator(>)operator(()ident(loader)operator(,) ident(jitMax)operator(\))operator(;) - - keyword(if) operator(()ident(FORK_ENABLED)operator(\)) operator({) - ident(error)operator(.)ident(print)operator(()string<delimiter(")content(WARNING: fork is highly unlikely to be safe or stable on the JVM. Have fun!)char(\\n)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(LoadServiceCreator) ident(getLoadServiceCreator)operator(()operator(\)) operator({) - keyword(return) ident(creator)operator(;) - operator(}) - - directive(public) type(void) ident(setLoadServiceCreator)operator(()ident(LoadServiceCreator) ident(creator)operator(\)) operator({) - local_variable(this)operator(.)ident(creator) operator(=) ident(creator)operator(;) - operator(}) - - directive(public) ident(LoadService) ident(createLoadService)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(creator)operator(.)ident(create)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(public) pre_type(String) ident(getBasicUsageHelp)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(sb) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(sb) - operator(.)ident(append)operator(()string<delimiter(")content(Usage: jruby [switches] [--] [programfile] [arguments])char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -0[octal] specify record separator ()char(\\0)content(, if no argument\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -a autosplit mode with -n or -p (splits $_ into $F\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -b benchmark mode, times the script execution)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -c check syntax only)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -Cdirectory cd to directory, before executing your script)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -d set debugging flags (set $DEBUG to true\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -e 'command' one line of script. Several -e's allowed. Omit [programfile])char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -Fpattern split(\) pattern for autosplit (-a\))char(\\n)delimiter(")>operator(\)) - comment(//.append(" -i[extension] edit ARGV files in place (make backup if extension supplied\)\\n"\)) - operator(.)ident(append)operator(()string<delimiter(")content( -Idirectory specify $LOAD_PATH directory (may be used more than once\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -J[java option] pass an option on to the JVM (e.g. -J-Xmx512m\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( use --properties to list JRuby properties)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( run 'java -help' for a list of other Java options)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -Kkcode specifies code-set (e.g. -Ku for Unicode)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -l enable line ending processing)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -n assume 'while gets(\); ... end' loop around your script)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -p assume loop like -n but print line also like sed)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -rlibrary require the library, before executing your script)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -s enable some switch parsing for switches after script name)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -S look for the script in bin or using PATH environment variable)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -T[level] turn on tainting checks)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -v print version number, then turn on verbose mode)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -w turn warnings on for your script)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -W[level] set warning level; 0=silence, 1=medium, 2=verbose (default\))char(\\n)delimiter(")>operator(\)) - comment(//.append(" -x[directory] strip off text before #!ruby line and perhaps cd to directory\\n"\)) - operator(.)ident(append)operator(()string<delimiter(")content( -X[option] enable extended option (omit option to list\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --copyright print the copyright)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --debug sets the execution mode most suitable for debugger functionality)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --jdb runs JRuby process under JDB)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --properties List all configuration Java properties (pass -J-Dproperty=value\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --sample run with profiling using the JVM's sampling profiler)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --client use the non-optimizing )char(\\")content(client)char(\\")content( JVM (improves startup; default\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --server use the optimizing )char(\\")content(server)char(\\")content( JVM (improves perf\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --manage enable remote JMX management and monitoring of the VM and JRuby)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --1.8 specify Ruby 1.8.x compatibility (default\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --1.9 specify Ruby 1.9.x compatibility)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --bytecode show the JVM bytecode produced by compiling specified code)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( --version print the version)char(\\n)delimiter(")>operator(\))operator(;) - - keyword(return) ident(sb)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(String) ident(getExtendedHelp)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(sb) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(sb) - operator(.)ident(append)operator(()string<delimiter(")content(These flags are for extended JRuby options.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content(Specify them by passing -X<option>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -O run with ObjectSpace disabled (default; improves performance\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( +O run with ObjectSpace enabled (reduces performance\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -C disable all compilation)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( +C force compilation of all scripts before they are run (except eval\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -y read a YARV-compiled Ruby script and run that (EXPERIMENTAL\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -Y compile a Ruby script into YARV bytecodes and run this (EXPERIMENTAL\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( -R read a Rubinius-compiled Ruby script and run that (EXPERIMENTAL\))char(\\n)delimiter(")>operator(\))operator(;) - - keyword(return) ident(sb)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(String) ident(getPropertyHelp)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(sb) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - ident(sb) - operator(.)ident(append)operator(()string<delimiter(")content(These properties can be used to alter runtime behavior for perf or compatibility.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content(Specify them by passing -J-D<property>=<value>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")char(\\n)content(COMPILER SETTINGS:)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.mode=JIT|FORCE|OFF)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set compilation mode. JIT is default; FORCE compiles all, OFF disables)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.fastest=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Turn on all experimental compiler optimizations)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.boxed=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Use boxed variables; this can speed up some methods. Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.frameless=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Turn on frameless compilation where possible)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.positionless=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Turn on compilation that avoids updating Ruby position info. Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.threadless=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Turn on compilation without polling for )char(\\")content(unsafe)char(\\")content( thread events. Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.fastops=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL\) Turn on fast operators for Fixnum. Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.chainsize=<line count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set the number of lines at which compiled bodies are )char(\\")content(chained)char(\\")content(. Default is )delimiter(")> operator(+) ident(CHAINED_COMPILE_LINE_COUNT_DEFAULT) operator(+) string<delimiter(")char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compile.lazyHandles=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Generate method bindings (handles\) for compiled methods lazily. Default is false.)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")char(\\n)content(JIT SETTINGS:)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.threshold=<invocation count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set the JIT threshold to the specified method invocation count. Default is )delimiter(")> operator(+) ident(JIT_THRESHOLD) operator(+) string<delimiter(")content(.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.max=<method count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set the max count of active methods eligible for JIT-compilation.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Default is )delimiter(")> operator(+) ident(JIT_MAX_METHODS_LIMIT) operator(+) string<delimiter(")content( per runtime. A value of 0 disables JIT, -1 disables max.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.maxsize=<jitted method size (full .class\)>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set the maximum full-class byte size allowed for jitted methods. Default is Integer.MAX_VALUE)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.logging=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable JIT logging (reports successful compilation\). Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.logging.verbose=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable verbose JIT logging (reports failed compilation\). Default is false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.logEvery=<method count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Log a message every n methods JIT compiled. Default is 0 (off\).)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.jit.exclude=<ClsOrMod,ClsOrMod::method_name,-::method_name>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Exclude methods from JIT by class/module short name, c/m::method_name,)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( or -::method_name for anon/singleton classes/modules. Comma-delimited.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")char(\\n)content(NATIVE SUPPORT:)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.native.enabled=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable/disable native extensions (like JNA for non-Java APIs; Default is true)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (This affects all JRuby instances in a given JVM\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.native.verbose=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable verbose logging of native extension loading. Default is false.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.fork.enabled=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( (EXPERIMENTAL, maybe dangerous\) Enable fork(2\) on platforms that support it.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")char(\\n)content(THREAD POOLING:)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.thread.pool.enabled=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable reuse of native backing threads via a thread pool. Default is false.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.thread.pool.min=<min thread count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( The minimum number of threads to keep alive in the pool. Default is 0.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.thread.pool.max=<max thread count>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( The maximum number of threads to allow in the pool. Default is unlimited.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.thread.pool.ttl=<time to live, in seconds>)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( The maximum number of seconds to keep alive an idle thread. Default is 60.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")char(\\n)content(MISCELLANY:)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.compat.version=RUBY1_8|RUBY1_9)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Specify the major Ruby version to be compatible with; Default is RUBY1_8)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.objectspace.enabled=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Enable or disable ObjectSpace.each_object (default is disabled\))char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.launch.inproc=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set in-process launching of e.g. system('ruby ...'\). Default is true)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.bytecode.version=1.5|1.6)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set bytecode version for JRuby to generate. Default is current JVM version.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.management.enabled=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set whether JMX management is enabled. Default is true.)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( jruby.debug.fullTrace=true|false)char(\\n)delimiter(")>operator(\)) - operator(.)ident(append)operator(()string<delimiter(")content( Set whether full traces are enabled (c-call/c-return\). Default is false.)char(\\n)delimiter(")>operator(\))operator(;) - - keyword(return) ident(sb)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(String) ident(getVersionString)operator(()operator(\)) operator({) - pre_type(String) ident(ver) operator(=) ident(Constants)operator(.)ident(RUBY_VERSION)operator(;) - keyword(switch) operator(()ident(compatVersion)operator(\)) operator({) - keyword(case) ident(RUBY1_8)operator(:) - ident(ver) operator(=) ident(Constants)operator(.)ident(RUBY_VERSION)operator(;) - keyword(break)operator(;) - keyword(case) ident(RUBY1_9)operator(:) - ident(ver) operator(=) ident(Constants)operator(.)ident(RUBY1_9_VERSION)operator(;) - keyword(break)operator(;) - operator(}) - - pre_type(String) ident(fullVersion) operator(=) pre_type(String)operator(.)ident(format)operator(() - string<delimiter(")content(jruby %s (ruby %s patchlevel %s\) (%s rev %s\) [%s-java])char(\\n)delimiter(")>operator(,) - ident(Constants)operator(.)ident(VERSION)operator(,) ident(ver)operator(,) ident(Constants)operator(.)ident(RUBY_PATCHLEVEL)operator(,) - ident(Constants)operator(.)ident(COMPILE_DATE)operator(,) ident(Constants)operator(.)ident(REVISION)operator(,) - ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(os.arch)delimiter(")>operator(,) string<delimiter(")content(unknown)delimiter(")>operator(\)) - operator(\))operator(;) - - keyword(return) ident(fullVersion)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getCopyrightString)operator(()operator(\)) operator({) - keyword(return) string<delimiter(")content(JRuby - Copyright (C\) 2001-2008 The JRuby Community (and contribs\))char(\\n)delimiter(")>operator(;) - operator(}) - - directive(public) type(void) ident(processArguments)operator(()pre_type(String)type([]) ident(arguments)operator(\)) operator({) - keyword(new) ident(ArgumentProcessor)operator(()ident(arguments)operator(\))operator(.)ident(processArguments)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(CompileMode) ident(getCompileMode)operator(()operator(\)) operator({) - keyword(return) ident(compileMode)operator(;) - operator(}) - - directive(public) type(void) ident(setCompileMode)operator(()ident(CompileMode) ident(compileMode)operator(\)) operator({) - local_variable(this)operator(.)ident(compileMode) operator(=) ident(compileMode)operator(;) - operator(}) - - directive(public) type(boolean) ident(isJitLogging)operator(()operator(\)) operator({) - keyword(return) ident(jitLogging)operator(;) - operator(}) - - directive(public) type(boolean) ident(isJitLoggingVerbose)operator(()operator(\)) operator({) - keyword(return) ident(jitLoggingVerbose)operator(;) - operator(}) - - directive(public) type(int) ident(getJitLogEvery)operator(()operator(\)) operator({) - keyword(return) ident(jitLogEvery)operator(;) - operator(}) - - directive(public) type(boolean) ident(isSamplingEnabled)operator(()operator(\)) operator({) - keyword(return) ident(samplingEnabled)operator(;) - operator(}) - - directive(public) type(int) ident(getJitThreshold)operator(()operator(\)) operator({) - keyword(return) ident(jitThreshold)operator(;) - operator(}) - - directive(public) type(int) ident(getJitMax)operator(()operator(\)) operator({) - keyword(return) ident(jitMax)operator(;) - operator(}) - - directive(public) type(int) ident(getJitMaxSize)operator(()operator(\)) operator({) - keyword(return) ident(jitMaxSize)operator(;) - operator(}) - - directive(public) type(boolean) ident(isRunRubyInProcess)operator(()operator(\)) operator({) - keyword(return) ident(runRubyInProcess)operator(;) - operator(}) - - directive(public) type(void) ident(setRunRubyInProcess)operator(()type(boolean) ident(flag)operator(\)) operator({) - local_variable(this)operator(.)ident(runRubyInProcess) operator(=) ident(flag)operator(;) - operator(}) - - directive(public) type(void) ident(setInput)operator(()pre_type(InputStream) ident(newInput)operator(\)) operator({) - ident(input) operator(=) ident(newInput)operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getInput)operator(()operator(\)) operator({) - keyword(return) ident(input)operator(;) - operator(}) - - directive(public) ident(CompatVersion) ident(getCompatVersion)operator(()operator(\)) operator({) - keyword(return) ident(compatVersion)operator(;) - operator(}) - - directive(public) type(void) ident(setOutput)operator(()pre_type(PrintStream) ident(newOutput)operator(\)) operator({) - ident(output) operator(=) ident(newOutput)operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getOutput)operator(()operator(\)) operator({) - keyword(return) ident(output)operator(;) - operator(}) - - directive(public) type(void) ident(setError)operator(()pre_type(PrintStream) ident(newError)operator(\)) operator({) - ident(error) operator(=) ident(newError)operator(;) - operator(}) - - directive(public) pre_type(PrintStream) ident(getError)operator(()operator(\)) operator({) - keyword(return) ident(error)operator(;) - operator(}) - - directive(public) type(void) ident(setCurrentDirectory)operator(()pre_type(String) ident(newCurrentDirectory)operator(\)) operator({) - ident(currentDirectory) operator(=) ident(newCurrentDirectory)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getCurrentDirectory)operator(()operator(\)) operator({) - keyword(return) ident(currentDirectory)operator(;) - operator(}) - - directive(public) type(void) ident(setProfile)operator(()ident(Profile) ident(newProfile)operator(\)) operator({) - ident(profile) operator(=) ident(newProfile)operator(;) - operator(}) - - directive(public) ident(Profile) ident(getProfile)operator(()operator(\)) operator({) - keyword(return) ident(profile)operator(;) - operator(}) - - directive(public) type(void) ident(setObjectSpaceEnabled)operator(()type(boolean) ident(newObjectSpaceEnabled)operator(\)) operator({) - ident(objectSpaceEnabled) operator(=) ident(newObjectSpaceEnabled)operator(;) - operator(}) - - directive(public) type(boolean) ident(isObjectSpaceEnabled)operator(()operator(\)) operator({) - keyword(return) ident(objectSpaceEnabled)operator(;) - operator(}) - - directive(public) type(void) ident(setEnvironment)operator(()pre_type(Map) ident(newEnvironment)operator(\)) operator({) - ident(environment) operator(=) ident(newEnvironment)operator(;) - operator(}) - - directive(public) pre_type(Map) ident(getEnvironment)operator(()operator(\)) operator({) - keyword(return) ident(environment)operator(;) - operator(}) - - directive(public) pre_type(ClassLoader) ident(getLoader)operator(()operator(\)) operator({) - keyword(return) ident(loader)operator(;) - operator(}) - - directive(public) type(void) ident(setLoader)operator(()pre_type(ClassLoader) ident(loader)operator(\)) operator({) - comment(// Setting the loader needs to reset the class cache) - keyword(if)operator(()local_variable(this)operator(.)ident(loader) operator(!=) ident(loader)operator(\)) operator({) - local_variable(this)operator(.)ident(classCache) operator(=) keyword(new) ident(ClassCache)operator(<)ident(Script)operator(>)operator(()ident(loader)operator(,) local_variable(this)operator(.)ident(classCache)operator(.)ident(getMax)operator(()operator(\))operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(loader) operator(=) ident(loader)operator(;) - operator(}) - - directive(public) pre_type(String)type([]) ident(getArgv)operator(()operator(\)) operator({) - keyword(return) ident(argv)operator(;) - operator(}) - - directive(public) type(void) ident(setArgv)operator(()pre_type(String)type([]) ident(argv)operator(\)) operator({) - local_variable(this)operator(.)ident(argv) operator(=) ident(argv)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getJRubyHome)operator(()operator(\)) operator({) - keyword(if) operator(()ident(jrubyHome) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(Ruby)operator(.)ident(isSecurityRestricted)operator(()operator(\))operator(\)) operator({) - keyword(return) string<delimiter(")content(SECURITY RESTRICTED)delimiter(")>operator(;) - operator(}) - ident(jrubyHome) operator(=) ident(verifyHome)operator(()ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(jruby.home)delimiter(")>operator(,) - ident(SafePropertyAccessor)operator(.)ident(getProperty)operator(()string<delimiter(")content(user.home)delimiter(")>operator(\)) operator(+) string<delimiter(")content(/.jruby)delimiter(")>operator(\))operator(\))operator(;) - - keyword(try) operator({) - comment(// This comment also in rbConfigLibrary) - comment(// Our shell scripts pass in non-canonicalized paths, but even if we didn't) - comment(// anyone who did would become unhappy because Ruby apps expect no relative) - comment(// operators in the pathname (rubygems, for example\).) - ident(jrubyHome) operator(=) keyword(new) ident(NormalizedFile)operator(()ident(jrubyHome)operator(\))operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) operator(}) - - ident(jrubyHome) operator(=) keyword(new) ident(NormalizedFile)operator(()ident(jrubyHome)operator(\))operator(.)ident(getAbsolutePath)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(jrubyHome)operator(;) - operator(}) - - directive(public) type(void) ident(setJRubyHome)operator(()pre_type(String) ident(home)operator(\)) operator({) - ident(jrubyHome) operator(=) ident(verifyHome)operator(()ident(home)operator(\))operator(;) - operator(}) - - comment(// We require the home directory to be absolute) - directive(private) pre_type(String) ident(verifyHome)operator(()pre_type(String) ident(home)operator(\)) operator({) - keyword(if) operator(()ident(home)operator(.)ident(equals)operator(()string<delimiter(")content(.)delimiter(")>operator(\))operator(\)) operator({) - ident(home) operator(=) pre_type(System)operator(.)ident(getProperty)operator(()string<delimiter(")content(user.dir)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(home)operator(.)ident(startsWith)operator(()string<delimiter(")content(file:)delimiter(")>operator(\))operator(\)) operator({) - ident(NormalizedFile) ident(f) operator(=) keyword(new) ident(NormalizedFile)operator(()ident(home)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(f)operator(.)ident(isAbsolute)operator(()operator(\))operator(\)) operator({) - ident(home) operator(=) ident(f)operator(.)ident(getAbsolutePath)operator(()operator(\))operator(;) - operator(}) - ident(f)operator(.)ident(mkdirs)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(home)operator(;) - operator(}) - - directive(private) type(class) class(ArgumentProcessor) operator({) - directive(private) pre_type(String)type([]) ident(arguments)operator(;) - directive(private) type(int) ident(argumentIndex) operator(=) integer(0)operator(;) - - directive(public) ident(ArgumentProcessor)operator(()pre_type(String)type([]) ident(arguments)operator(\)) operator({) - local_variable(this)operator(.)ident(arguments) operator(=) ident(arguments)operator(;) - operator(}) - - directive(public) type(void) ident(processArguments)operator(()operator(\)) operator({) - keyword(while) operator(()ident(argumentIndex) operator(<) ident(arguments)operator(.)ident(length) operator(&&) ident(isInterpreterArgument)operator(()ident(arguments)operator([)ident(argumentIndex)operator(])operator(\))operator(\)) operator({) - ident(processArgument)operator(()operator(\))operator(;) - ident(argumentIndex)operator(++)operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(hasInlineScript) operator(&&) ident(scriptFileName) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(argumentIndex) operator(<) ident(arguments)operator(.)ident(length)operator(\)) operator({) - ident(setScriptFileName)operator(()ident(arguments)operator([)ident(argumentIndex)operator(])operator(\))operator(;) comment(//consume the file name) - ident(argumentIndex)operator(++)operator(;) - operator(}) - operator(}) - - ident(processArgv)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(processArgv)operator(()operator(\)) operator({) - pre_type(List)operator(<)pre_type(String)operator(>) ident(arglist) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()operator(;) ident(argumentIndex) operator(<) ident(arguments)operator(.)ident(length)operator(;) ident(argumentIndex)operator(++)operator(\)) operator({) - pre_type(String) ident(arg) operator(=) ident(arguments)operator([)ident(argumentIndex)operator(])operator(;) - keyword(if) operator(()ident(argvGlobalsOn) operator(&&) ident(arg)operator(.)ident(startsWith)operator(()string<delimiter(")content(-)delimiter(")>operator(\))operator(\)) operator({) - ident(arg) operator(=) ident(arg)operator(.)ident(substring)operator(()integer(1)operator(\))operator(;) - keyword(if) operator(()ident(arg)operator(.)ident(indexOf)operator(()string<delimiter(')content(=)delimiter(')>operator(\)) operator(>) integer(0)operator(\)) operator({) - pre_type(String)type([]) ident(keyvalue) operator(=) ident(arg)operator(.)ident(split)operator(()string<delimiter(")content(=)delimiter(")>operator(,) integer(2)operator(\))operator(;) - ident(optionGlobals)operator(.)ident(put)operator(()ident(keyvalue)operator([)integer(0)operator(])operator(,) ident(keyvalue)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(optionGlobals)operator(.)ident(put)operator(()ident(arg)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(argvGlobalsOn) operator(=) pre_constant(false)operator(;) - ident(arglist)operator(.)ident(add)operator(()ident(arg)operator(\))operator(;) - operator(}) - operator(}) - - comment(// Remaining arguments are for the script itself) - ident(argv) operator(=) ident(arglist)operator(.)ident(toArray)operator(()keyword(new) pre_type(String)operator([)ident(arglist)operator(.)ident(size)operator(()operator(\))operator(])operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isInterpreterArgument)operator(()pre_type(String) ident(argument)operator(\)) operator({) - keyword(return) operator(()ident(argument)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(-)delimiter(')> operator(||) ident(argument)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(+)delimiter(')>operator(\)) operator(&&) operator(!)ident(endOfArguments)operator(;) - operator(}) - - directive(private) pre_type(String) ident(getArgumentError)operator(()pre_type(String) ident(additionalError)operator(\)) operator({) - keyword(return) string<delimiter(")content(jruby: invalid argument)char(\\n)delimiter(")> operator(+) ident(additionalError) operator(+) string<delimiter(")char(\\n)delimiter(")>operator(;) - operator(}) - - directive(private) type(void) ident(processArgument)operator(()operator(\)) operator({) - pre_type(String) ident(argument) operator(=) ident(arguments)operator([)ident(argumentIndex)operator(])operator(;) - ident(FOR) operator(:) keyword(for) operator(()ident(characterIndex) operator(=) integer(1)operator(;) ident(characterIndex) operator(<) ident(argument)operator(.)ident(length)operator(()operator(\))operator(;) ident(characterIndex)operator(++)operator(\)) operator({) - keyword(switch) operator(()ident(argument)operator(.)ident(charAt)operator(()ident(characterIndex)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(0)delimiter(')>operator(:) operator({) - pre_type(String) ident(temp) operator(=) ident(grabOptionalValue)operator(()operator(\))operator(;) - keyword(if) operator(()pre_constant(null) operator(==) ident(temp)operator(\)) operator({) - ident(recordSeparator) operator(=) string<delimiter(")char(\\u0000)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(temp)operator(.)ident(equals)operator(()string<delimiter(")content(0)delimiter(")>operator(\))operator(\)) operator({) - ident(recordSeparator) operator(=) string<delimiter(")char(\\n)char(\\n)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(temp)operator(.)ident(equals)operator(()string<delimiter(")content(777)delimiter(")>operator(\))operator(\)) operator({) - ident(recordSeparator) operator(=) string<delimiter(")char(\\uFFFF)delimiter(")>operator(;) comment(// Specify something that can't separate) - operator(}) keyword(else) operator({) - keyword(try) operator({) - type(int) ident(val) operator(=) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(temp)operator(,) integer(8)operator(\))operator(;) - ident(recordSeparator) operator(=) string<delimiter(")delimiter(")> operator(+) operator(()type(char)operator(\)) ident(val)operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) ident(getArgumentError)operator(()string<delimiter(")content( -0 must be followed by either 0, 777, or a valid octal value)delimiter(")>operator(\))operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - keyword(throw) ident(mee)operator(;) - operator(}) - operator(}) - keyword(break) ident(FOR)operator(;) - operator(}) - keyword(case) string<delimiter(')content(a)delimiter(')>operator(:) - ident(split) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(b)delimiter(')>operator(:) - ident(benchmarking) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(c)delimiter(')>operator(:) - ident(shouldCheckSyntax) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(C)delimiter(')>operator(:) - keyword(try) operator({) - pre_type(String) ident(saved) operator(=) ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content( -C must be followed by a directory expression)delimiter(")>operator(\))operator(\))operator(;) - pre_type(File) ident(base) operator(=) keyword(new) pre_type(File)operator(()ident(currentDirectory)operator(\))operator(;) - pre_type(File) ident(newDir) operator(=) keyword(new) pre_type(File)operator(()ident(saved)operator(\))operator(;) - keyword(if) operator(()ident(newDir)operator(.)ident(isAbsolute)operator(()operator(\))operator(\)) operator({) - ident(currentDirectory) operator(=) ident(newDir)operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(currentDirectory) operator(=) keyword(new) pre_type(File)operator(()ident(base)operator(,) ident(newDir)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)operator(()keyword(new) pre_type(File)operator(()ident(currentDirectory)operator(\))operator(.)ident(isDirectory)operator(()operator(\))operator(\))operator(\)) operator({) - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) string<delimiter(")content(jruby: Can't chdir to )delimiter(")> operator(+) ident(saved) operator(+) string<delimiter(")content( (fatal\))delimiter(")>operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - keyword(throw) ident(mee)operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) ident(getArgumentError)operator(()string<delimiter(")content( -C must be followed by a valid directory)delimiter(")>operator(\))operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - keyword(throw) ident(mee)operator(;) - operator(}) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(d)delimiter(')>operator(:) - ident(debug) operator(=) pre_constant(true)operator(;) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(e)delimiter(')>operator(:) - ident(inlineScript)operator(.)ident(append)operator(()ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content( -e must be followed by an expression to evaluate)delimiter(")>operator(\))operator(\))operator(\))operator(;) - ident(inlineScript)operator(.)ident(append)operator(()string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - ident(hasInlineScript) operator(=) pre_constant(true)operator(;) - keyword(break) ident(FOR)operator(;) - keyword(case) string<delimiter(')content(F)delimiter(')>operator(:) - ident(inputFieldSeparator) operator(=) ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content( -F must be followed by a pattern for input field separation)delimiter(")>operator(\))operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(h)delimiter(')>operator(:) - ident(shouldPrintUsage) operator(=) pre_constant(true)operator(;) - ident(shouldRunInterpreter) operator(=) pre_constant(false)operator(;) - keyword(break)operator(;) - comment(// FIXME: -i flag not supported) -comment(// case 'i' :) -comment(// break;) - keyword(case) string<delimiter(')content(I)delimiter(')>operator(:) - pre_type(String) ident(s) operator(=) ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content(-I must be followed by a directory name to add to lib path)delimiter(")>operator(\))operator(\))operator(;) - pre_type(String)type([]) ident(ls) operator(=) ident(s)operator(.)ident(split)operator(()ident(java)operator(.)ident(io)operator(.)ident(File)operator(.)ident(pathSeparator)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(ls)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(loadPaths)operator(.)ident(add)operator(()ident(ls)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(break) ident(FOR)operator(;) - keyword(case) string<delimiter(')content(K)delimiter(')>operator(:) - comment(// FIXME: No argument seems to work for -K in MRI plus this should not) - comment(// siphon off additional args 'jruby -K ~/scripts/foo'. Also better error) - comment(// processing.) - pre_type(String) ident(eArg) operator(=) ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content(provide a value for -K)delimiter(")>operator(\))operator(\))operator(;) - ident(kcode) operator(=) ident(KCode)operator(.)ident(create)operator(()pre_constant(null)operator(,) ident(eArg)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(l)delimiter(')>operator(:) - ident(processLineEnds) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(n)delimiter(')>operator(:) - ident(assumeLoop) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(p)delimiter(')>operator(:) - ident(assumePrinting) operator(=) pre_constant(true)operator(;) - ident(assumeLoop) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(r)delimiter(')>operator(:) - ident(requiredLibraries)operator(.)ident(add)operator(()ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content(-r must be followed by a package to require)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(break) ident(FOR)operator(;) - keyword(case) string<delimiter(')content(s)delimiter(')> operator(:) - ident(argvGlobalsOn) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(S)delimiter(')>operator(:) - ident(runBinScript)operator(()operator(\))operator(;) - keyword(break) ident(FOR)operator(;) - keyword(case) string<delimiter(')content(T)delimiter(')> operator(:)operator({) - pre_type(String) ident(temp) operator(=) ident(grabOptionalValue)operator(()operator(\))operator(;) - type(int) ident(value) operator(=) integer(1)operator(;) - - keyword(if)operator(()ident(temp)operator(!=)pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(value) operator(=) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(temp)operator(,) integer(8)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - ident(value) operator(=) integer(1)operator(;) - operator(}) - operator(}) - - ident(safeLevel) operator(=) ident(value)operator(;) - - keyword(break) ident(FOR)operator(;) - operator(}) - keyword(case) string<delimiter(')content(v)delimiter(')>operator(:) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - ident(setShowVersion)operator(()pre_constant(true)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(w)delimiter(')>operator(:) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(W)delimiter(')>operator(:) operator({) - pre_type(String) ident(temp) operator(=) ident(grabOptionalValue)operator(()operator(\))operator(;) - type(int) ident(value) operator(=) integer(2)operator(;) - keyword(if) operator(()pre_constant(null) operator(!=) ident(temp)operator(\)) operator({) - keyword(if) operator(()ident(temp)operator(.)ident(equals)operator(()string<delimiter(")content(2)delimiter(")>operator(\))operator(\)) operator({) - ident(value) operator(=) integer(2)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(temp)operator(.)ident(equals)operator(()string<delimiter(")content(1)delimiter(")>operator(\))operator(\)) operator({) - ident(value) operator(=) integer(1)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(temp)operator(.)ident(equals)operator(()string<delimiter(")content(0)delimiter(")>operator(\))operator(\)) operator({) - ident(value) operator(=) integer(0)operator(;) - operator(}) keyword(else) operator({) - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) ident(getArgumentError)operator(()string<delimiter(")content( -W must be followed by either 0, 1, 2 or nothing)delimiter(")>operator(\))operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - keyword(throw) ident(mee)operator(;) - operator(}) - operator(}) - keyword(switch) operator(()ident(value)operator(\)) operator({) - keyword(case) integer(0)operator(:) - ident(verbose) operator(=) pre_constant(null)operator(;) - keyword(break)operator(;) - keyword(case) integer(1)operator(:) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(FALSE)operator(;) - keyword(break)operator(;) - keyword(case) integer(2)operator(:) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - keyword(break)operator(;) - operator(}) - - - keyword(break) ident(FOR)operator(;) - operator(}) - comment(// FIXME: -x flag not supported) -comment(// case 'x' :) -comment(// break;) - keyword(case) string<delimiter(')content(X)delimiter(')>operator(:) - pre_type(String) ident(extendedOption) operator(=) ident(grabOptionalValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(extendedOption) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) keyword(new) ident(MainExitException)operator(()integer(0)operator(,) string<delimiter(")content(jruby: missing extended option, listing available options)char(\\n)delimiter(")> operator(+) ident(getExtendedHelp)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(-O)delimiter(")>operator(\))operator(\)) operator({) - ident(objectSpaceEnabled) operator(=) pre_constant(false)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(+O)delimiter(")>operator(\))operator(\)) operator({) - ident(objectSpaceEnabled) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(-C)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(OFF)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(+C)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(FORCE)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(-y)delimiter(")>operator(\))operator(\)) operator({) - ident(yarv) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(-Y)delimiter(")>operator(\))operator(\)) operator({) - ident(yarvCompile) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(extendedOption)operator(.)ident(equals)operator(()string<delimiter(")content(-R)delimiter(")>operator(\))operator(\)) operator({) - ident(rubinius) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - ident(MainExitException) ident(mee) operator(=) - keyword(new) ident(MainExitException)operator(()integer(1)operator(,) string<delimiter(")content(jruby: invalid extended option )delimiter(")> operator(+) ident(extendedOption) operator(+) string<delimiter(")content( (-X will list valid options\))char(\\n)delimiter(")>operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - - keyword(throw) ident(mee)operator(;) - operator(}) - keyword(break) ident(FOR)operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--command)delimiter(")>operator(\)) operator(||) ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--bin)delimiter(")>operator(\))operator(\)) operator({) - ident(characterIndex) operator(=) ident(argument)operator(.)ident(length)operator(()operator(\))operator(;) - ident(runBinScript)operator(()operator(\))operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--compat)delimiter(")>operator(\))operator(\)) operator({) - ident(characterIndex) operator(=) ident(argument)operator(.)ident(length)operator(()operator(\))operator(;) - ident(compatVersion) operator(=) ident(CompatVersion)operator(.)ident(getVersionFromString)operator(()ident(grabValue)operator(()ident(getArgumentError)operator(()string<delimiter(")content(--compat must be RUBY1_8 or RUBY1_9)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(if) operator(()ident(compatVersion) operator(==) pre_constant(null)operator(\)) operator({) - ident(compatVersion) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(;) - operator(}) - keyword(break) ident(FOR)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--copyright)delimiter(")>operator(\))operator(\)) operator({) - ident(setShowCopyright)operator(()pre_constant(true)operator(\))operator(;) - ident(shouldRunInterpreter) operator(=) pre_constant(false)operator(;) - keyword(break) ident(FOR)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--debug)delimiter(")>operator(\))operator(\)) operator({) - ident(compileMode) operator(=) ident(CompileMode)operator(.)ident(OFF)operator(;) - ident(FULL_TRACE_ENABLED) operator(=) pre_constant(true)operator(;) - pre_type(System)operator(.)ident(setProperty)operator(()string<delimiter(")content(jruby.reflection)delimiter(")>operator(,) string<delimiter(")content(true)delimiter(")>operator(\))operator(;) - keyword(break) ident(FOR)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--jdb)delimiter(")>operator(\))operator(\)) operator({) - ident(debug) operator(=) pre_constant(true)operator(;) - ident(verbose) operator(=) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--help)delimiter(")>operator(\))operator(\)) operator({) - ident(shouldPrintUsage) operator(=) pre_constant(true)operator(;) - ident(shouldRunInterpreter) operator(=) pre_constant(false)operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--properties)delimiter(")>operator(\))operator(\)) operator({) - ident(shouldPrintProperties) operator(=) pre_constant(true)operator(;) - ident(shouldRunInterpreter) operator(=) pre_constant(false)operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--version)delimiter(")>operator(\))operator(\)) operator({) - ident(setShowVersion)operator(()pre_constant(true)operator(\))operator(;) - keyword(break) ident(FOR)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--bytecode)delimiter(")>operator(\))operator(\)) operator({) - ident(setShowBytecode)operator(()pre_constant(true)operator(\))operator(;) - keyword(break) ident(FOR)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(argument)operator(.)ident(equals)operator(()string<delimiter(")content(--)delimiter(")>operator(\))operator(\)) operator({) - comment(// ruby interpreter compatibilty) - comment(// Usage: ruby [switches] [--] [programfile] [arguments]\)) - ident(endOfArguments) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - operator(}) - operator(}) - keyword(default)operator(:) - keyword(throw) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) string<delimiter(")content(jruby: unknown option )delimiter(")> operator(+) ident(argument)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(private) type(void) ident(runBinScript)operator(()operator(\)) operator({) - pre_type(String) ident(scriptName) operator(=) ident(grabValue)operator(()string<delimiter(")content(jruby: provide a bin script to execute)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(scriptName)operator(.)ident(equals)operator(()string<delimiter(")content(irb)delimiter(")>operator(\))operator(\)) operator({) - ident(scriptName) operator(=) string<delimiter(")content(jirb)delimiter(")>operator(;) - operator(}) - - ident(scriptFileName) operator(=) ident(scriptName)operator(;) - - keyword(if) operator(()operator(!)keyword(new) pre_type(File)operator(()ident(scriptFileName)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - pre_type(String) ident(jrubyHome) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()pre_type(System)operator(.)ident(getProperty)operator(()string<delimiter(")content(user.dir)delimiter(")>operator(\))operator(,) ident(JRubyFile)operator(.)ident(getFileProperty)operator(()string<delimiter(")content(jruby.home)delimiter(")>operator(\))operator(\))operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - ident(scriptFileName) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(jrubyHome) operator(+) ident(JRubyFile)operator(.)ident(separator) operator(+) string<delimiter(")content(bin)delimiter(")>operator(,) ident(scriptName)operator(\))operator(.)ident(getCanonicalPath)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(io)operator(\)) operator({) - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) string<delimiter(")content(jruby: Can't determine script filename)delimiter(")>operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - keyword(throw) ident(mee)operator(;) - operator(}) - operator(}) - - comment(// route 'gem' through ruby code in case we're running out of the complete jar) - keyword(if) operator(()ident(scriptName)operator(.)ident(equals)operator(()string<delimiter(")content(gem)delimiter(")>operator(\)) operator(||) operator(!)keyword(new) pre_type(File)operator(()ident(scriptFileName)operator(\))operator(.)ident(exists)operator(()operator(\))operator(\)) operator({) - ident(requiredLibraries)operator(.)ident(add)operator(()string<delimiter(")content(jruby/commands)delimiter(")>operator(\))operator(;) - ident(inlineScript)operator(.)ident(append)operator(()string<delimiter(")content(JRuby::Commands.)delimiter(")> operator(+) ident(scriptName)operator(\))operator(;) - ident(inlineScript)operator(.)ident(append)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - ident(hasInlineScript) operator(=) pre_constant(true)operator(;) - operator(}) - ident(endOfArguments) operator(=) pre_constant(true)operator(;) - operator(}) - - directive(private) pre_type(String) ident(grabValue)operator(()pre_type(String) ident(errorMessage)operator(\)) operator({) - ident(characterIndex)operator(++)operator(;) - keyword(if) operator(()ident(characterIndex) operator(<) ident(arguments)operator([)ident(argumentIndex)operator(])operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(arguments)operator([)ident(argumentIndex)operator(])operator(.)ident(substring)operator(()ident(characterIndex)operator(\))operator(;) - operator(}) - ident(argumentIndex)operator(++)operator(;) - keyword(if) operator(()ident(argumentIndex) operator(<) ident(arguments)operator(.)ident(length)operator(\)) operator({) - keyword(return) ident(arguments)operator([)ident(argumentIndex)operator(])operator(;) - operator(}) - - ident(MainExitException) ident(mee) operator(=) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) ident(errorMessage)operator(\))operator(;) - ident(mee)operator(.)ident(setUsageError)operator(()pre_constant(true)operator(\))operator(;) - - keyword(throw) ident(mee)operator(;) - operator(}) - - directive(private) pre_type(String) ident(grabOptionalValue)operator(()operator(\)) operator({) - ident(characterIndex)operator(++)operator(;) - keyword(if) operator(()ident(characterIndex) operator(<) ident(arguments)operator([)ident(argumentIndex)operator(])operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(arguments)operator([)ident(argumentIndex)operator(])operator(.)ident(substring)operator(()ident(characterIndex)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) - - directive(public) type(byte)type([]) ident(inlineScript)operator(()operator(\)) operator({) - keyword(return) ident(inlineScript)operator(.)ident(toString)operator(()operator(\))operator(.)ident(getBytes)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(requiredLibraries)operator(()operator(\)) operator({) - keyword(return) ident(requiredLibraries)operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(loadPaths)operator(()operator(\)) operator({) - keyword(return) ident(loadPaths)operator(;) - operator(}) - - directive(public) type(boolean) ident(shouldRunInterpreter)operator(()operator(\)) operator({) - keyword(if)operator(()ident(isShowVersion)operator(()operator(\)) operator(&&) operator(()ident(hasInlineScript) operator(||) ident(scriptFileName) operator(!=) pre_constant(null)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) ident(isShouldRunInterpreter)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(shouldPrintUsage)operator(()operator(\)) operator({) - keyword(return) ident(shouldPrintUsage)operator(;) - operator(}) - - directive(public) type(boolean) ident(shouldPrintProperties)operator(()operator(\)) operator({) - keyword(return) ident(shouldPrintProperties)operator(;) - operator(}) - - directive(private) type(boolean) ident(isSourceFromStdin)operator(()operator(\)) operator({) - keyword(return) ident(getScriptFileName)operator(()operator(\)) operator(==) pre_constant(null)operator(;) - operator(}) - - directive(public) type(boolean) ident(isInlineScript)operator(()operator(\)) operator({) - keyword(return) ident(hasInlineScript)operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getScriptSource)operator(()operator(\)) operator({) - keyword(try) operator({) - comment(// KCode.NONE is used because KCODE does not affect parse in Ruby 1.8) - comment(// if Ruby 2.0 encoding pragmas are implemented, this will need to change) - keyword(if) operator(()ident(hasInlineScript)operator(\)) operator({) - keyword(return) keyword(new) pre_type(ByteArrayInputStream)operator(()ident(inlineScript)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isSourceFromStdin)operator(()operator(\))operator(\)) operator({) - comment(// can't use -v and stdin) - keyword(if) operator(()ident(isShowVersion)operator(()operator(\))operator(\)) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - keyword(return) ident(getInput)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(File) ident(file) operator(=) ident(JRubyFile)operator(.)ident(create)operator(()ident(getCurrentDirectory)operator(()operator(\))operator(,) ident(getScriptFileName)operator(()operator(\))operator(\))operator(;) - keyword(return) keyword(new) pre_type(BufferedInputStream)operator(()keyword(new) pre_type(FileInputStream)operator(()ident(file)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) ident(MainExitException)operator(()integer(1)operator(,) string<delimiter(")content(Error opening script file: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) pre_type(String) ident(displayedFileName)operator(()operator(\)) operator({) - keyword(if) operator(()ident(hasInlineScript)operator(\)) operator({) - keyword(if) operator(()ident(scriptFileName) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(scriptFileName)operator(;) - operator(}) keyword(else) operator({) - keyword(return) string<delimiter(")content(-e)delimiter(")>operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(isSourceFromStdin)operator(()operator(\))operator(\)) operator({) - keyword(return) string<delimiter(")content(-)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getScriptFileName)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(setScriptFileName)operator(()pre_type(String) ident(scriptFileName)operator(\)) operator({) - local_variable(this)operator(.)ident(scriptFileName) operator(=) ident(scriptFileName)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getScriptFileName)operator(()operator(\)) operator({) - keyword(return) ident(scriptFileName)operator(;) - operator(}) - - directive(public) type(boolean) ident(isBenchmarking)operator(()operator(\)) operator({) - keyword(return) ident(benchmarking)operator(;) - operator(}) - - directive(public) type(boolean) ident(isAssumeLoop)operator(()operator(\)) operator({) - keyword(return) ident(assumeLoop)operator(;) - operator(}) - - directive(public) type(boolean) ident(isAssumePrinting)operator(()operator(\)) operator({) - keyword(return) ident(assumePrinting)operator(;) - operator(}) - - directive(public) type(boolean) ident(isProcessLineEnds)operator(()operator(\)) operator({) - keyword(return) ident(processLineEnds)operator(;) - operator(}) - - directive(public) type(boolean) ident(isSplit)operator(()operator(\)) operator({) - keyword(return) ident(split)operator(;) - operator(}) - - directive(public) type(boolean) ident(isVerbose)operator(()operator(\)) operator({) - keyword(return) ident(verbose) operator(==) pre_type(Boolean)operator(.)ident(TRUE)operator(;) - operator(}) - - directive(public) pre_type(Boolean) ident(getVerbose)operator(()operator(\)) operator({) - keyword(return) ident(verbose)operator(;) - operator(}) - - directive(public) type(boolean) ident(isDebug)operator(()operator(\)) operator({) - keyword(return) ident(debug)operator(;) - operator(}) - - directive(public) type(boolean) ident(isShowVersion)operator(()operator(\)) operator({) - keyword(return) ident(showVersion)operator(;) - operator(}) - - directive(public) type(boolean) ident(isShowBytecode)operator(()operator(\)) operator({) - keyword(return) ident(showBytecode)operator(;) - operator(}) - - directive(public) type(boolean) ident(isShowCopyright)operator(()operator(\)) operator({) - keyword(return) ident(showCopyright)operator(;) - operator(}) - - directive(protected) type(void) ident(setShowVersion)operator(()type(boolean) ident(showVersion)operator(\)) operator({) - local_variable(this)operator(.)ident(showVersion) operator(=) ident(showVersion)operator(;) - operator(}) - - directive(protected) type(void) ident(setShowBytecode)operator(()type(boolean) ident(showBytecode)operator(\)) operator({) - local_variable(this)operator(.)ident(showBytecode) operator(=) ident(showBytecode)operator(;) - operator(}) - - directive(protected) type(void) ident(setShowCopyright)operator(()type(boolean) ident(showCopyright)operator(\)) operator({) - local_variable(this)operator(.)ident(showCopyright) operator(=) ident(showCopyright)operator(;) - operator(}) - - directive(public) type(boolean) ident(isShouldRunInterpreter)operator(()operator(\)) operator({) - keyword(return) ident(shouldRunInterpreter)operator(;) - operator(}) - - directive(public) type(boolean) ident(isShouldCheckSyntax)operator(()operator(\)) operator({) - keyword(return) ident(shouldCheckSyntax)operator(;) - operator(}) - - directive(public) type(boolean) ident(isYARVEnabled)operator(()operator(\)) operator({) - keyword(return) ident(yarv)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getInputFieldSeparator)operator(()operator(\)) operator({) - keyword(return) ident(inputFieldSeparator)operator(;) - operator(}) - - directive(public) type(boolean) ident(isRubiniusEnabled)operator(()operator(\)) operator({) - keyword(return) ident(rubinius)operator(;) - operator(}) - - directive(public) type(boolean) ident(isYARVCompileEnabled)operator(()operator(\)) operator({) - keyword(return) ident(yarvCompile)operator(;) - operator(}) - - directive(public) ident(KCode) ident(getKCode)operator(()operator(\)) operator({) - keyword(return) ident(kcode)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getRecordSeparator)operator(()operator(\)) operator({) - keyword(return) ident(recordSeparator)operator(;) - operator(}) - - directive(public) type(int) ident(getSafeLevel)operator(()operator(\)) operator({) - keyword(return) ident(safeLevel)operator(;) - operator(}) - - directive(public) type(void) ident(setRecordSeparator)operator(()pre_type(String) ident(recordSeparator)operator(\)) operator({) - local_variable(this)operator(.)ident(recordSeparator) operator(=) ident(recordSeparator)operator(;) - operator(}) - - directive(public) ident(ClassCache) ident(getClassCache)operator(()operator(\)) operator({) - keyword(return) ident(classCache)operator(;) - operator(}) - - directive(public) type(void) ident(setClassCache)operator(()ident(ClassCache) ident(classCache)operator(\)) operator({) - local_variable(this)operator(.)ident(classCache) operator(=) ident(classCache)operator(;) - operator(}) - - directive(public) pre_type(Map) ident(getOptionGlobals)operator(()operator(\)) operator({) - keyword(return) ident(optionGlobals)operator(;) - operator(}) - - directive(public) type(boolean) ident(isManagementEnabled)operator(()operator(\)) operator({) - keyword(return) ident(managementEnabled)operator(;) - operator(}) - - directive(public) pre_type(Set) ident(getExcludedMethods)operator(()operator(\)) operator({) - keyword(return) ident(excludedMethods)operator(;) - operator(}) - -operator(}) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.BlockBody)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** Implementation of the Integer class. - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Integer)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Numeric)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Precision)delimiter(")>operator(\)) -directive(public) directive(abstract) type(class) class(RubyInteger) directive(extends) ident(RubyNumeric) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createIntegerClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(integer) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Integer)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(,) - ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setInteger)operator(()ident(integer)operator(\))operator(;) - ident(integer)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyInteger)operator(;) - operator(}) - operator(})operator(;) - - ident(integer)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - ident(integer)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getPrecision)operator(()operator(\))operator(\))operator(;) - - ident(integer)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyInteger)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(integer)operator(;) - operator(}) - - directive(public) ident(RubyInteger)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyInteger)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) type(boolean) ident(useObjectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) ident(useObjectSpace)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyInteger) ident(convertToInteger)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(// conversion) - directive(protected) ident(RubyFloat) ident(toFloat)operator(()operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** int_int_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(integer?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(integer_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** int_upto - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(upto)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(upto)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(to)operator(,) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(to) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(RubyFixnum) ident(toFixnum) operator(=) operator(()ident(RubyFixnum)operator(\)) ident(to)operator(;) - directive(final) type(long) ident(toValue) operator(=) ident(toFixnum)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - directive(final) type(long) ident(fromValue) operator(=) ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(getBody)operator(()operator(\))operator(.)ident(getArgumentType)operator(()operator(\)) operator(==) ident(BlockBody)operator(.)ident(ZERO_ARGS)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(nil) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(for) operator(()type(long) ident(i) operator(=) ident(fromValue)operator(;) ident(i) operator(<=) ident(toValue)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(nil)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(long) ident(i) operator(=) ident(fromValue)operator(;) ident(i) operator(<=) ident(toValue)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - ident(RubyNumeric) ident(i) operator(=) local_variable(this)operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(if) operator(()ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_GT)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(to)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(i)operator(\))operator(;) - ident(i) operator(=) operator(()ident(RubyNumeric)operator(\)) ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** int_downto - * - */) - comment(// TODO: Make callCoerced work in block context...then fix downto, step, and upto.) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(downto)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(downto)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(to)operator(,) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(to) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(RubyFixnum) ident(toFixnum) operator(=) operator(()ident(RubyFixnum)operator(\)) ident(to)operator(;) - directive(final) type(long) ident(toValue) operator(=) ident(toFixnum)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(block)operator(.)ident(getBody)operator(()operator(\))operator(.)ident(getArgumentType)operator(()operator(\)) operator(==) ident(BlockBody)operator(.)ident(ZERO_ARGS)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(nil) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(for) operator(()type(long) ident(i) operator(=) ident(getLongValue)operator(()operator(\))operator(;) ident(i) operator(>=) ident(toValue)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(nil)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(long) ident(i) operator(=) ident(getLongValue)operator(()operator(\))operator(;) ident(i) operator(>=) ident(toValue)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - ident(RubyNumeric) ident(i) operator(=) local_variable(this)operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(if) operator(()ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(to)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(i)operator(\))operator(;) - ident(i) operator(=) operator(()ident(RubyNumeric)operator(\)) ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(times)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(times)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - directive(final) type(long) ident(value) operator(=) ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(block)operator(.)ident(getBody)operator(()operator(\))operator(.)ident(getArgumentType)operator(()operator(\)) operator(==) ident(BlockBody)operator(.)ident(ZERO_ARGS)operator(\)) operator({) - directive(final) ident(IRubyObject) ident(nil) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(for) operator(()type(long) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(value)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(nil)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(long) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(value)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - ident(RubyNumeric) ident(i) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) local_variable(this)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(i)operator(\))operator(;) - ident(i) operator(=) operator(()ident(RubyNumeric)operator(\)) ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** int_succ - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(succ)delimiter(")>operator(,) string<delimiter(")content(next)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(succ)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getLongValue)operator(()operator(\)) operator(+) integer(1L)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** int_chr - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chr)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(chr)operator(()operator(\)) operator({) - keyword(if) operator(()ident(getLongValue)operator(()operator(\)) operator(<) integer(0) operator(||) ident(getLongValue)operator(()operator(\)) operator(>) hex(0xff)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()local_variable(this)operator(.)ident(toString)operator(()operator(\)) operator(+) string<delimiter(")content( out of char range)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)operator(()type(byte)operator(\))ident(getLongValue)operator(()operator(\))operator(})operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - comment(/** int_to_i - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_i)delimiter(")>operator(,) string<delimiter(")content(to_int)delimiter(")>operator(,) string<delimiter(")content(floor)delimiter(")>operator(,) string<delimiter(")content(ceil)delimiter(")>operator(,) string<delimiter(")content(round)delimiter(")>operator(,) string<delimiter(")content(truncate)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(to_i)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** integer_to_r - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalCanonicalize)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(odd?)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(odd_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(if)operator(()ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\)) operator(!=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(even?)delimiter(")>operator(})operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(even_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(if)operator(()ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\)) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(pred)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - operator(}) - - - comment(/* ================ - * Singleton Methods - * ================ - */) - - comment(/** rb_int_induced_from - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(induced_from)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(induced_from)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum) operator(||) ident(other) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(other)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFloat) operator(||) ident(other) keyword(instanceof) ident(RubyRational)operator(\)) operator({) - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_I)operator(,) string<delimiter(")content(to_i)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(() - string<delimiter(")content(failed to convert )delimiter(")> operator(+) ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( into Integer)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2006 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Evan Buswell <ebuswell@gmail.com> - * Copyright (C\) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.EOFException)operator(;) -keyword(import) include(java.io.FileDescriptor)operator(;) -keyword(import) include(java.io.FilterInputStream)operator(;) -keyword(import) include(java.io.FilterOutputStream)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.OutputStream)operator(;) -keyword(import) include(java.lang.ref.Reference)operator(;) -keyword(import) include(java.lang.ref.WeakReference)operator(;) -keyword(import) include(java.nio.channels.Channel)operator(;) -keyword(import) include(java.nio.channels.Channels)operator(;) -keyword(import) include(java.nio.channels.FileChannel)operator(;) -keyword(import) include(java.nio.channels.Pipe)operator(;) -keyword(import) include(java.nio.channels.SelectableChannel)operator(;) -keyword(import) include(java.nio.channels.SelectionKey)operator(;) -keyword(import) include(java.nio.channels.Selector)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.HashSet)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Set)operator(;) - -keyword(import) include(java.util.concurrent.atomic.AtomicInteger)operator(;) -keyword(import) include(org.jruby.anno.FrameField)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.ext.posix.util.FieldAccess)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.io.Stream)operator(;) -keyword(import) include(org.jruby.util.io.ModeFlags)operator(;) -keyword(import) include(org.jruby.util.ShellLauncher)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) -keyword(import) include(org.jruby.util.io.BadDescriptorException)operator(;) -keyword(import) include(org.jruby.util.io.ChannelStream)operator(;) -keyword(import) include(org.jruby.util.io.InvalidValueException)operator(;) -keyword(import) include(org.jruby.util.io.PipeException)operator(;) -keyword(import) include(org.jruby.util.io.FileExistsException)operator(;) -keyword(import) include(org.jruby.util.io.STDIO)operator(;) -keyword(import) include(org.jruby.util.io.OpenFile)operator(;) -keyword(import) include(org.jruby.util.io.ChannelDescriptor)operator(;) - -keyword(import) include(static) include(org.jruby.CompatVersion)operator(.)operator(*)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(IO)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyIO) directive(extends) ident(RubyObject) operator({) - directive(protected) ident(OpenFile) ident(openFile)operator(;) - directive(protected) pre_type(List)operator(<)ident(RubyThread)operator(>) ident(blockingThreads)operator(;) - - directive(public) type(void) ident(registerDescriptor)operator(()ident(ChannelDescriptor) ident(descriptor)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getDescriptors)operator(()operator(\))operator(.)ident(put)operator(()keyword(new) pre_type(Integer)operator(()ident(descriptor)operator(.)ident(getFileno)operator(()operator(\))operator(\))operator(,) keyword(new) pre_type(WeakReference)operator(<)ident(ChannelDescriptor)operator(>)operator(()ident(descriptor)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(unregisterDescriptor)operator(()type(int) ident(aFileno)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getDescriptors)operator(()operator(\))operator(.)ident(remove)operator(()keyword(new) pre_type(Integer)operator(()ident(aFileno)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(ChannelDescriptor) ident(getDescriptorByFileno)operator(()type(int) ident(aFileno)operator(\)) operator({) - pre_type(Reference)operator(<)ident(ChannelDescriptor)operator(>) ident(reference) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getDescriptors)operator(()operator(\))operator(.)ident(get)operator(()keyword(new) pre_type(Integer)operator(()ident(aFileno)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(reference) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - keyword(return) ident(reference)operator(.)ident(get)operator(()operator(\))operator(;) - operator(}) - - comment(// FIXME can't use static; would interfere with other runtimes in the same JVM) - directive(protected) directive(static) pre_type(AtomicInteger) ident(filenoIndex) operator(=) keyword(new) pre_type(AtomicInteger)operator(()integer(2)operator(\))operator(;) - - directive(public) directive(static) type(int) ident(getNewFileno)operator(()operator(\)) operator({) - keyword(return) ident(filenoIndex)operator(.)ident(incrementAndGet)operator(()operator(\))operator(;) - operator(}) - - comment(// This should only be called by this and RubyFile.) - comment(// It allows this object to be created without a IOHandler.) - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(OutputStream) ident(outputStream)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(\))operator(;) - - comment(// We only want IO objects with valid streams (better to error now\). ) - keyword(if) operator(()ident(outputStream) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(Opening invalid stream)delimiter(")>operator(\))operator(;) - operator(}) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(runtime)operator(,) keyword(new) ident(ChannelDescriptor)operator(()pre_type(Channels)operator(.)ident(newChannel)operator(()ident(outputStream)operator(\))operator(,) ident(getNewFileno)operator(()operator(\))operator(,) keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(setMode)operator(()ident(OpenFile)operator(.)ident(WRITABLE) operator(|) ident(OpenFile)operator(.)ident(APPEND)operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(InputStream) ident(inputStream)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(inputStream) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(Opening invalid stream)delimiter(")>operator(\))operator(;) - operator(}) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(runtime)operator(,) keyword(new) ident(ChannelDescriptor)operator(()pre_type(Channels)operator(.)ident(newChannel)operator(()ident(inputStream)operator(\))operator(,) ident(getNewFileno)operator(()operator(\))operator(,) keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(setMode)operator(()ident(OpenFile)operator(.)ident(READABLE)operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Channel) ident(channel)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(\))operator(;) - - comment(// We only want IO objects with valid streams (better to error now\). ) - keyword(if) operator(()ident(channel) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(Opening invalid stream)delimiter(")>operator(\))operator(;) - operator(}) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(runtime)operator(,) keyword(new) ident(ChannelDescriptor)operator(()ident(channel)operator(,) ident(getNewFileno)operator(()operator(\))operator(,) keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(setMode)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getModes)operator(()operator(\))operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) ident(ShellLauncher)operator(.)ident(POpenProcess) ident(process)operator(,) ident(ModeFlags) ident(modes)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(\))operator(;) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - ident(openFile)operator(.)ident(setMode)operator(()ident(modes)operator(.)ident(getOpenFileFlags)operator(()operator(\)) operator(|) ident(OpenFile)operator(.)ident(SYNC)operator(\))operator(;) - ident(openFile)operator(.)ident(setProcess)operator(()ident(process)operator(\))operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(openFile)operator(.)ident(isReadable)operator(()operator(\))operator(\)) operator({) - pre_type(Channel) ident(inChannel)operator(;) - keyword(if) operator(()ident(process)operator(.)ident(getInput)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - comment(// NIO-based) - ident(inChannel) operator(=) ident(process)operator(.)ident(getInput)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// Stream-based) - ident(inChannel) operator(=) pre_type(Channels)operator(.)ident(newChannel)operator(()ident(process)operator(.)ident(getInputStream)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(ChannelDescriptor) ident(main) operator(=) keyword(new) ident(ChannelDescriptor)operator(() - ident(inChannel)operator(,) - ident(getNewFileno)operator(()operator(\))operator(,) - keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(;) - ident(main)operator(.)ident(setCanBeSeekable)operator(()pre_constant(false)operator(\))operator(;) - - ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(main)operator(\))operator(\))operator(;) - ident(registerDescriptor)operator(()ident(main)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(openFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - pre_type(Channel) ident(outChannel)operator(;) - keyword(if) operator(()ident(process)operator(.)ident(getOutput)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - comment(// NIO-based) - ident(outChannel) operator(=) ident(process)operator(.)ident(getOutput)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(outChannel) operator(=) pre_type(Channels)operator(.)ident(newChannel)operator(()ident(process)operator(.)ident(getOutputStream)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(ChannelDescriptor) ident(pipe) operator(=) keyword(new) ident(ChannelDescriptor)operator(() - ident(outChannel)operator(,) - ident(getNewFileno)operator(()operator(\))operator(,) - keyword(new) pre_type(FileDescriptor)operator(()operator(\))operator(\))operator(;) - ident(pipe)operator(.)ident(setCanBeSeekable)operator(()pre_constant(false)operator(\))operator(;) - - keyword(if) operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(openFile)operator(.)ident(setPipeStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(pipe)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(openFile)operator(.)ident(setMainStream)operator(()keyword(new) ident(ChannelStream)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(pipe)operator(\))operator(\))operator(;) - operator(}) - - ident(registerDescriptor)operator(()ident(pipe)operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(RubyIO)operator(()ident(Ruby) ident(runtime)operator(,) ident(STDIO) ident(stdio)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(\))operator(;) - - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - - keyword(try) operator({) - keyword(switch) operator(()ident(stdio)operator(\)) operator({) - keyword(case) ident(IN)operator(:) - ident(openFile)operator(.)ident(setMainStream)operator(() - keyword(new) ident(ChannelStream)operator(() - ident(runtime)operator(,) - comment(// special constructor that accepts stream, not channel) - keyword(new) ident(ChannelDescriptor)operator(()ident(runtime)operator(.)ident(getIn)operator(()operator(\))operator(,) integer(0)operator(,) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(RDONLY)operator(\))operator(,) pre_type(FileDescriptor)operator(.)ident(in)operator(\))operator(,) - pre_type(FileDescriptor)operator(.)ident(in)operator(\))operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(OUT)operator(:) - ident(openFile)operator(.)ident(setMainStream)operator(() - keyword(new) ident(ChannelStream)operator(() - ident(runtime)operator(,) - keyword(new) ident(ChannelDescriptor)operator(()pre_type(Channels)operator(.)ident(newChannel)operator(()ident(runtime)operator(.)ident(getOut)operator(()operator(\))operator(\))operator(,) integer(1)operator(,) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(WRONLY) operator(|) ident(ModeFlags)operator(.)ident(APPEND)operator(\))operator(,) pre_type(FileDescriptor)operator(.)ident(out)operator(\))operator(,) - pre_type(FileDescriptor)operator(.)ident(out)operator(\))operator(\))operator(;) - ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setSync)operator(()pre_constant(true)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) ident(ERR)operator(:) - ident(openFile)operator(.)ident(setMainStream)operator(() - keyword(new) ident(ChannelStream)operator(() - ident(runtime)operator(,) - keyword(new) ident(ChannelDescriptor)operator(()pre_type(Channels)operator(.)ident(newChannel)operator(()ident(runtime)operator(.)ident(getErr)operator(()operator(\))operator(\))operator(,) integer(2)operator(,) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(WRONLY) operator(|) ident(ModeFlags)operator(.)ident(APPEND)operator(\))operator(,) pre_type(FileDescriptor)operator(.)ident(err)operator(\))operator(,) - pre_type(FileDescriptor)operator(.)ident(err)operator(\))operator(\))operator(;) - ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setSync)operator(()pre_constant(true)operator(\))operator(;) - keyword(break)operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(setMode)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getModes)operator(()operator(\))operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyIO) ident(newIO)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Channel) ident(channel)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(channel)operator(\))operator(;) - operator(}) - - directive(public) ident(OpenFile) ident(getOpenFile)operator(()operator(\)) operator({) - keyword(return) ident(openFile)operator(;) - operator(}) - - directive(protected) ident(OpenFile) ident(getOpenFileChecked)operator(()operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(openFile)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(IO_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createIOClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(ioClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(IO)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(IO_ALLOCATOR)operator(\))operator(;) - ident(ioClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyIO)operator(;) - operator(}) - operator(})operator(;) - - ident(ioClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - - comment(// TODO: Implement tty? and isatty. We have no real capability to) - comment(// determine this from java, but if we could set tty status, then) - comment(// we could invoke jruby differently to allow stdin to return true) - comment(// on this. This would allow things like cgi.rb to work properly.) - - ident(ioClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyIO)operator(.)ident(class)operator(\))operator(;) - - comment(// Constants for seek) - ident(ioClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(SEEK_SET)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Stream)operator(.)ident(SEEK_SET)operator(\))operator(\))operator(;) - ident(ioClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(SEEK_CUR)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Stream)operator(.)ident(SEEK_CUR)operator(\))operator(\))operator(;) - ident(ioClass)operator(.)ident(fastSetConstant)operator(()string<delimiter(")content(SEEK_END)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Stream)operator(.)ident(SEEK_END)operator(\))operator(\))operator(;) - - keyword(return) ident(ioClass)operator(;) - operator(}) - - directive(public) pre_type(OutputStream) ident(getOutStream)operator(()operator(\)) operator({) - keyword(return) ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(newOutputStream)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(InputStream) ident(getInStream)operator(()operator(\)) operator({) - keyword(return) ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(newInputStream)operator(()operator(\))operator(;) - operator(}) - - directive(public) pre_type(Channel) ident(getChannel)operator(()operator(\)) operator({) - keyword(if) operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\)) keyword(instanceof) ident(ChannelStream)operator(\)) operator({) - keyword(return) operator(()operator(()ident(ChannelStream)operator(\)) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getChannel)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) - - directive(public) ident(Stream) ident(getHandler)operator(()operator(\)) operator({) - keyword(return) ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reopen)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(reopen)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) ident(InvalidValueException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(1)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(tmp) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(,) - ident(MethodIndex)operator(.)ident(getIndex)operator(()string<delimiter(")content(to_io)delimiter(")>operator(\))operator(,) string<delimiter(")content(to_io)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(RubyIO) ident(ios) operator(=) operator(()ident(RubyIO)operator(\)) ident(tmp)operator(;) - - keyword(if) operator(()ident(ios)operator(.)ident(openFile) operator(==) local_variable(this)operator(.)ident(openFile)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - ident(OpenFile) ident(originalFile) operator(=) ident(ios)operator(.)ident(getOpenFileChecked)operator(()operator(\))operator(;) - ident(OpenFile) ident(selfFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - type(long) ident(pos) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(originalFile)operator(.)ident(isReadable)operator(()operator(\))operator(\)) operator({) - ident(pos) operator(=) ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fgetpos)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(originalFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(selfFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - ident(selfFile)operator(.)ident(getWriteStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - operator(}) - - ident(selfFile)operator(.)ident(setMode)operator(()ident(originalFile)operator(.)ident(getMode)operator(()operator(\))operator(\))operator(;) - ident(selfFile)operator(.)ident(setProcess)operator(()ident(originalFile)operator(.)ident(getProcess)operator(()operator(\))operator(\))operator(;) - ident(selfFile)operator(.)ident(setLineNumber)operator(()ident(originalFile)operator(.)ident(getLineNumber)operator(()operator(\))operator(\))operator(;) - ident(selfFile)operator(.)ident(setPath)operator(()ident(originalFile)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(;) - ident(selfFile)operator(.)ident(setFinalizer)operator(()ident(originalFile)operator(.)ident(getFinalizer)operator(()operator(\))operator(\))operator(;) - - ident(ChannelDescriptor) ident(selfDescriptor) operator(=) ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - ident(ChannelDescriptor) ident(originalDescriptor) operator(=) ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - - comment(// confirm we're not reopening self's channel) - keyword(if) operator(()ident(selfDescriptor)operator(.)ident(getChannel)operator(()operator(\)) operator(!=) ident(originalDescriptor)operator(.)ident(getChannel)operator(()operator(\))operator(\)) operator({) - comment(// check if we're a stdio IO, and ensure we're not badly mutilated) - keyword(if) operator(()ident(selfDescriptor)operator(.)ident(getFileno)operator(()operator(\)) operator(>=)integer(0) operator(&&) ident(selfDescriptor)operator(.)ident(getFileno)operator(()operator(\)) operator(<=) integer(2)operator(\)) operator({) - ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - comment(// dup2 new fd into self to preserve fileno and references to it) - ident(originalDescriptor)operator(.)ident(dup2Into)operator(()ident(selfDescriptor)operator(\))operator(;) - - comment(// re-register, since fileno points at something new now) - ident(registerDescriptor)operator(()ident(selfDescriptor)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(Stream) ident(pipeFile) operator(=) ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(;) - type(int) ident(mode) operator(=) ident(selfFile)operator(.)ident(getMode)operator(()operator(\))operator(;) - ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(selfFile)operator(.)ident(setPipeStream)operator(()pre_constant(null)operator(\))operator(;) - - comment(// TODO: turn off readable? am I reading this right?) - comment(// This only seems to be used while duping below, since modes gets) - comment(// reset to actual modes afterward) - comment(//fptr->mode &= (m & FMODE_READABLE\) ? ~FMODE_READABLE : ~FMODE_WRITABLE;) - - keyword(if) operator(()ident(pipeFile) operator(!=) pre_constant(null)operator(\)) operator({) - ident(selfFile)operator(.)ident(setMainStream)operator(()ident(ChannelStream)operator(.)ident(fdopen)operator(()ident(runtime)operator(,) ident(originalDescriptor)operator(,) keyword(new) ident(ModeFlags)operator(()operator(\))operator(\))operator(\))operator(;) - ident(selfFile)operator(.)ident(setPipeStream)operator(()ident(pipeFile)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(selfFile)operator(.)ident(setMainStream)operator(() - keyword(new) ident(ChannelStream)operator(() - ident(runtime)operator(,) - ident(originalDescriptor)operator(.)ident(dup2)operator(()ident(selfDescriptor)operator(.)ident(getFileno)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - - comment(// re-register the descriptor) - ident(registerDescriptor)operator(()ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - - comment(// since we're not actually duping the incoming channel into our handler, we need to) - comment(// copy the original sync behavior from the other handler) - ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setSync)operator(()ident(selfFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(isSync)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(selfFile)operator(.)ident(setMode)operator(()ident(mode)operator(\))operator(;) - operator(}) - - comment(// TODO: anything threads attached to original fd are notified of the close...) - comment(// see rb_thread_fd_close) - - keyword(if) operator(()ident(originalFile)operator(.)ident(isReadable)operator(()operator(\)) operator(&&) ident(pos) operator(>=) integer(0)operator(\)) operator({) - ident(selfFile)operator(.)ident(seek)operator(()ident(pos)operator(,) ident(Stream)operator(.)ident(SEEK_SET)operator(\))operator(;) - ident(originalFile)operator(.)ident(seek)operator(()ident(pos)operator(,) ident(Stream)operator(.)ident(SEEK_SET)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null) operator(&&) ident(selfDescriptor)operator(.)ident(getFileno)operator(()operator(\)) operator(!=) ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\))operator(\)) operator({) - type(int) ident(fd) operator(=) ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(selfFile)operator(.)ident(setPipeStream)operator(()pre_constant(null)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(fd) operator(!=) ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\))operator(\)) operator({) - ident(selfFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(ChannelDescriptor) ident(newFD2) operator(=) ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(dup2)operator(()ident(fd)operator(\))operator(;) - ident(selfFile)operator(.)ident(setPipeStream)operator(()ident(ChannelStream)operator(.)ident(fdopen)operator(()ident(runtime)operator(,) ident(newFD2)operator(,) ident(getIOModes)operator(()ident(runtime)operator(,) string<delimiter(")content(w)delimiter(")>operator(\))operator(\))operator(\))operator(;) - - comment(// re-register, since fileno points at something new now) - ident(registerDescriptor)operator(()ident(newFD2)operator(\))operator(;) - operator(}) - operator(}) - - comment(// TODO: restore binary mode) - comment(// if (fptr->mode & FMODE_BINMODE\) {) - comment(// rb_io_binmode(io\);) - comment(// }) - - comment(// TODO: set our metaclass to target's class (i.e. scary!\)) - - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) comment(// TODO: better error handling) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not reopen: )delimiter(")> operator(+) ident(ex)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not reopen: )delimiter(")> operator(+) ident(ex)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not reopen: )delimiter(")> operator(+) ident(ex)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(pathString) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - - comment(// TODO: check safe, taint on incoming string) - - keyword(if) operator(()ident(openFile) operator(==) pre_constant(null)operator(\)) operator({) - ident(openFile) operator(=) keyword(new) ident(OpenFile)operator(()operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(ModeFlags) ident(modes)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(IRubyObject) ident(modeString) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(modes) operator(=) ident(getIOModes)operator(()ident(runtime)operator(,) ident(modeString)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - ident(openFile)operator(.)ident(setMode)operator(()ident(modes)operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modes) operator(=) ident(getIOModes)operator(()ident(runtime)operator(,) string<delimiter(")content(r)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(String) ident(path) operator(=) ident(pathString)operator(.)ident(toString)operator(()operator(\))operator(;) - - comment(// Ruby code frequently uses a platform check to choose "NUL:" on windows) - comment(// but since that check doesn't work well on JRuby, we help it out) - - ident(openFile)operator(.)ident(setPath)operator(()ident(path)operator(\))operator(;) - - keyword(if) operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(openFile)operator(.)ident(setMainStream)operator(()ident(ChannelStream)operator(.)ident(fopen)operator(()ident(runtime)operator(,) ident(path)operator(,) ident(modes)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(FileExistsException) ident(fee)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEEXISTError)operator(()ident(path)operator(\))operator(;) - operator(}) - - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(unregisterDescriptor)operator(()ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\))operator(\))operator(;) - ident(openFile)operator(.)ident(setPipeStream)operator(()pre_constant(null)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) keyword(else) operator({) - comment(// TODO: This is an freopen in MRI, this is close, but not quite the same) - ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(freopen)operator(()ident(path)operator(,) ident(getIOModes)operator(()ident(runtime)operator(,) ident(openFile)operator(.)ident(getModeAsString)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - - comment(// re-register) - ident(registerDescriptor)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - comment(// TODO: pipe handler to be reopened with path and "w" mode) - operator(}) - operator(}) - operator(}) keyword(catch) operator(()ident(PipeException) ident(pe)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// A potentially previously close IO is being 'reopened'.) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) directive(static) ident(ModeFlags) ident(getIOModes)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(modesString)operator(\)) directive(throws) ident(InvalidValueException) operator({) - keyword(return) keyword(new) ident(ModeFlags)operator(()ident(getIOModesIntFromString)operator(()ident(runtime)operator(,) ident(modesString)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(int) ident(getIOModesIntFromString)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(modesString)operator(\)) operator({) - type(int) ident(modes) operator(=) integer(0)operator(;) - type(int) ident(length) operator(=) ident(modesString)operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal access mode)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(switch) operator(()ident(modesString)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(r)delimiter(')> operator(:) - ident(modes) operator(|=) ident(ModeFlags)operator(.)ident(RDONLY)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(a)delimiter(')> operator(:) - ident(modes) operator(|=) ident(ModeFlags)operator(.)ident(APPEND) operator(|) ident(ModeFlags)operator(.)ident(WRONLY) operator(|) ident(ModeFlags)operator(.)ident(CREAT)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(w)delimiter(')> operator(:) - ident(modes) operator(|=) ident(ModeFlags)operator(.)ident(WRONLY) operator(|) ident(ModeFlags)operator(.)ident(TRUNC) operator(|) ident(ModeFlags)operator(.)ident(CREAT)operator(;) - keyword(break)operator(;) - keyword(default) operator(:) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal access mode )delimiter(")> operator(+) ident(modes)operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(n) operator(=) integer(1)operator(;) ident(n) operator(<) ident(length)operator(;) ident(n)operator(++)operator(\)) operator({) - keyword(switch) operator(()ident(modesString)operator(.)ident(charAt)operator(()ident(n)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(b)delimiter(')>operator(:) - ident(modes) operator(|=) ident(ModeFlags)operator(.)ident(BINARY)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) - ident(modes) operator(=) operator(()ident(modes) operator(&) operator(~)ident(ModeFlags)operator(.)ident(ACCMODE)operator(\)) operator(|) ident(ModeFlags)operator(.)ident(RDWR)operator(;) - keyword(break)operator(;) - keyword(default)operator(:) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal access mode )delimiter(")> operator(+) ident(modes)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(modes)operator(;) - operator(}) - - directive(private) directive(static) ident(ByteList) ident(getSeparatorFromArgs)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) type(int) ident(idx)operator(\)) operator({) - ident(IRubyObject) ident(sepVal)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) ident(idx)operator(\)) operator({) - ident(sepVal) operator(=) ident(args)operator([)ident(idx)operator(])operator(;) - operator(}) keyword(else) operator({) - ident(sepVal) operator(=) ident(runtime)operator(.)ident(getRecordSeparatorVar)operator(()operator(\))operator(.)ident(get)operator(()operator(\))operator(;) - operator(}) - - ident(ByteList) ident(separator) operator(=) ident(sepVal)operator(.)ident(isNil)operator(()operator(\)) operator(?) pre_constant(null) operator(:) ident(sepVal)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(separator) operator(!=) pre_constant(null) operator(&&) ident(separator)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(separator) operator(=) ident(Stream)operator(.)ident(PARAGRAPH_DELIMETER)operator(;) - operator(}) - - keyword(return) ident(separator)operator(;) - operator(}) - - directive(private) ident(ByteList) ident(getSeparatorForGets)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(getSeparatorFromArgs)operator(()ident(runtime)operator(,) ident(args)operator(,) integer(0)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getline)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(separator)operator(\)) operator({) - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(runtime)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - type(boolean) ident(isParagraph) operator(=) ident(separator) operator(==) ident(Stream)operator(.)ident(PARAGRAPH_DELIMETER)operator(;) - ident(separator) operator(=) operator(()ident(separator) operator(==) ident(Stream)operator(.)ident(PARAGRAPH_DELIMETER)operator(\)) operator(?) - ident(Stream)operator(.)ident(PARAGRAPH_SEPARATOR) operator(:) ident(separator)operator(;) - - keyword(if) operator(()ident(isParagraph)operator(\)) operator({) - ident(swallow)operator(()string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(separator) operator(==) pre_constant(null)operator(\)) operator({) - ident(IRubyObject) ident(str) operator(=) ident(readAll)operator(()pre_constant(null)operator(\))operator(;) - keyword(if) operator(()operator(()operator(()ident(RubyString)operator(\))ident(str)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(incrementLineno)operator(()ident(runtime)operator(,) ident(myOpenFile)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(separator)operator(.)ident(length)operator(()operator(\)) operator(==) integer(1)operator(\)) operator({) - keyword(return) ident(getlineFast)operator(()ident(runtime)operator(,) ident(separator)operator(.)ident(get)operator(()integer(0)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(Stream) ident(readStream) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(;) - type(int) ident(c) operator(=) operator(-)integer(1)operator(;) - type(int) ident(n) operator(=) operator(-)integer(1)operator(;) - type(int) ident(newline) operator(=) ident(separator)operator(.)ident(get)operator(()ident(separator)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator(&) hex(0xFF)operator(;) - - ident(ByteList) ident(buf) operator(=) keyword(new) ident(ByteList)operator(()integer(0)operator(\))operator(;) - type(boolean) ident(update) operator(=) pre_constant(false)operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(do) operator({) - ident(readCheck)operator(()ident(readStream)operator(\))operator(;) - ident(readStream)operator(.)ident(clearerr)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(n) operator(=) ident(readStream)operator(.)ident(getline)operator(()ident(buf)operator(,) operator(()type(byte)operator(\)) ident(newline)operator(\))operator(;) - ident(c) operator(=) ident(buf)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(?) ident(buf)operator(.)ident(get)operator(()ident(buf)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator(&) hex(0xff) operator(:) operator(-)integer(1)operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - ident(n) operator(=) operator(-)integer(1)operator(;) - operator(}) - - keyword(if) operator(()ident(n) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(readStream)operator(.)ident(isBlocking)operator(()operator(\)) operator(&&) operator(()ident(readStream) keyword(instanceof) ident(ChannelStream)operator(\))operator(\)) operator({) - keyword(if)operator(()operator(!)operator(()ident(waitReadable)operator(()operator(()operator(()ident(ChannelStream)operator(\))ident(readStream)operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(bad file descriptor: )delimiter(")> operator(+) ident(openFile)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(continue)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - ident(update) operator(=) pre_constant(true)operator(;) - operator(}) keyword(while) operator(()ident(c) operator(!=) ident(newline)operator(\))operator(;) comment(// loop until we see the nth separator char) - - comment(// if we hit EOF, we're done) - keyword(if) operator(()ident(n) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - - comment(// if we've found the last char of the separator,) - comment(// and we've found at least as many characters as separator length,) - comment(// and the last n characters of our buffer match the separator, we're done) - keyword(if) operator(()ident(c) operator(==) ident(newline) operator(&&) ident(buf)operator(.)ident(length)operator(()operator(\)) operator(>=) ident(separator)operator(.)ident(length)operator(()operator(\)) operator(&&) - integer(0) operator(==) ident(ByteList)operator(.)ident(memcmp)operator(()ident(buf)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(buf)operator(.)ident(begin) operator(+) ident(buf)operator(.)ident(realSize) operator(-) ident(separator)operator(.)ident(length)operator(()operator(\))operator(,) ident(separator)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(separator)operator(.)ident(begin)operator(,) ident(separator)operator(.)ident(realSize)operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(isParagraph)operator(\)) operator({) - keyword(if) operator(()ident(c) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(swallow)operator(()string<delimiter(')content(\\n)delimiter(')>operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(update)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(incrementLineno)operator(()ident(runtime)operator(,) ident(myOpenFile)operator(\))operator(;) - ident(RubyString) ident(str) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buf)operator(\))operator(;) - ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(str)operator(;) - operator(}) - operator(}) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(incrementLineno)operator(()ident(Ruby) ident(runtime)operator(,) ident(OpenFile) ident(myOpenFile)operator(\)) operator({) - type(int) ident(lineno) operator(=) ident(myOpenFile)operator(.)ident(getLineNumber)operator(()operator(\)) operator(+) integer(1)operator(;) - ident(myOpenFile)operator(.)ident(setLineNumber)operator(()ident(lineno)operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($.)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(lineno)operator(\))operator(\))operator(;) - comment(// this is for a range check, near as I can tell) - ident(RubyNumeric)operator(.)ident(int2fix)operator(()ident(runtime)operator(,) ident(myOpenFile)operator(.)ident(getLineNumber)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(protected) type(boolean) ident(swallow)operator(()type(int) ident(term)operator(\)) directive(throws) exception(IOException)operator(,) ident(BadDescriptorException) operator({) - ident(Stream) ident(readStream) operator(=) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(;) - type(int) ident(c)operator(;) - - keyword(do) operator({) - ident(readCheck)operator(()ident(readStream)operator(\))operator(;) - - keyword(try) operator({) - ident(c) operator(=) ident(readStream)operator(.)ident(fgetc)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - ident(c) operator(=) operator(-)integer(1)operator(;) - operator(}) - - keyword(if) operator(()ident(c) operator(!=) ident(term)operator(\)) operator({) - ident(readStream)operator(.)ident(ungetc)operator(()ident(c)operator(\))operator(;) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) keyword(while) operator(()ident(c) operator(!=) operator(-)integer(1)operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getlineFast)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(delim)operator(\)) directive(throws) exception(IOException)operator(,) ident(BadDescriptorException) operator({) - ident(Stream) ident(readStream) operator(=) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(;) - type(int) ident(c) operator(=) operator(-)integer(1)operator(;) - - ident(ByteList) ident(buf) operator(=) keyword(new) ident(ByteList)operator(()integer(0)operator(\))operator(;) - type(boolean) ident(update) operator(=) pre_constant(false)operator(;) - keyword(do) operator({) - ident(readCheck)operator(()ident(readStream)operator(\))operator(;) - ident(readStream)operator(.)ident(clearerr)operator(()operator(\))operator(;) - type(int) ident(n)operator(;) - keyword(try) operator({) - ident(n) operator(=) ident(readStream)operator(.)ident(getline)operator(()ident(buf)operator(,) operator(()type(byte)operator(\)) ident(delim)operator(\))operator(;) - ident(c) operator(=) ident(buf)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(?) ident(buf)operator(.)ident(get)operator(()ident(buf)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(\)) operator(&) hex(0xff) operator(:) operator(-)integer(1)operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - ident(n) operator(=) operator(-)integer(1)operator(;) - operator(}) - - keyword(if) operator(()ident(n) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(readStream)operator(.)ident(isBlocking)operator(()operator(\)) operator(&&) operator(()ident(readStream) keyword(instanceof) ident(ChannelStream)operator(\))operator(\)) operator({) - keyword(if)operator(()operator(!)operator(()ident(waitReadable)operator(()operator(()operator(()ident(ChannelStream)operator(\))ident(readStream)operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(bad file descriptor: )delimiter(")> operator(+) ident(openFile)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - ident(update) operator(=) pre_constant(true)operator(;) - operator(}) keyword(while) operator(()ident(c) operator(!=) ident(delim)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(update)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(incrementLineno)operator(()ident(runtime)operator(,) ident(openFile)operator(\))operator(;) - ident(RubyString) ident(str) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buf)operator(\))operator(;) - ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - operator(}) - comment(// IO class methods.) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content(for_fd)delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(className) operator(=) ident(klass)operator(.)ident(getName)operator(()operator(\))operator(;) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(() - ident(ID)operator(.)ident(BLOCK_NOT_ACCEPTED)operator(,) - ident(className) operator(+) string<delimiter(")content(::new(\) does not take block; use )delimiter(")> operator(+) ident(className) operator(+) string<delimiter(")content(::open(\) instead)delimiter(")>operator(,) - ident(className) operator(+) string<delimiter(")content(::open(\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(klass)operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - type(int) ident(argCount) operator(=) ident(args)operator(.)ident(length)operator(;) - ident(ModeFlags) ident(modes)operator(;) - - type(int) ident(fileno) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - - keyword(try) operator({) - ident(ChannelDescriptor) ident(descriptor) operator(=) ident(getDescriptorByFileno)operator(()ident(fileno)operator(\))operator(;) - - keyword(if) operator(()ident(descriptor) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - - ident(descriptor)operator(.)ident(checkOpen)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(argCount) operator(==) integer(2)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(RubyFixnum)operator(.)ident(fix2long)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modes) operator(=) ident(getIOModes)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - comment(// use original modes) - ident(modes) operator(=) ident(descriptor)operator(.)ident(getOriginalModes)operator(()operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(setMode)operator(()ident(modes)operator(.)ident(getOpenFileFlags)operator(()operator(\))operator(\))operator(;) - - ident(openFile)operator(.)ident(setMainStream)operator(()ident(fdopen)operator(()ident(descriptor)operator(,) ident(modes)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ive)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(protected) ident(Stream) ident(fdopen)operator(()ident(ChannelDescriptor) ident(existingDescriptor)operator(,) ident(ModeFlags) ident(modes)operator(\)) directive(throws) ident(InvalidValueException) operator({) - comment(// See if we already have this descriptor open.) - comment(// If so then we can mostly share the handler (keep open) - comment(// file, but possibly change the mode\).) - - keyword(if) operator(()ident(existingDescriptor) operator(==) pre_constant(null)operator(\)) operator({) - comment(// redundant, done above as well) - - comment(// this seems unlikely to happen unless it's a totally bogus fileno) - comment(// ...so do we even need to bother trying to create one?) - - comment(// IN FACT, we should probably raise an error, yes?) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - -comment(// if (mode == null\) {) -comment(// mode = "r";) -comment(// }) -comment(// ) -comment(// try {) -comment(// openFile.setMainStream(streamForFileno(getRuntime(\), fileno\)\);) -comment(// } catch (BadDescriptorException e\) {) -comment(// throw getRuntime(\).newErrnoEBADFError(\);) -comment(// } catch (IOException e\) {) -comment(// throw getRuntime(\).newErrnoEBADFError(\);) -comment(// }) -comment(// //modes = new IOModes(getRuntime(\), mode\);) -comment(// ) -comment(// registerStream(openFile.getMainStream(\)\);) - operator(}) keyword(else) operator({) - comment(// We are creating a new IO object that shares the same) - comment(// IOHandler (and fileno\).) - keyword(return) ident(ChannelStream)operator(.)ident(fdopen)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(existingDescriptor)operator(,) ident(modes)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - ident(RubyIO) ident(io) operator(=) operator(()ident(RubyIO)operator(\))ident(klass)operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(io)operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(try) operator({) - ident(io)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(invoke)operator(()ident(context)operator(,) ident(io)operator(,) string<delimiter(")content(close)delimiter(")>operator(,) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(CallType)operator(.)ident(FUNCTIONAL)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(re)operator(\)) operator({) - ident(RubyException) ident(rubyEx) operator(=) ident(re)operator(.)ident(getException)operator(()operator(\))operator(;) - keyword(if) operator(()ident(rubyEx)operator(.)ident(kind_of_p)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getStandardError)operator(()operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - comment(// MRI behavior: swallow StandardErorrs) - operator(}) keyword(else) operator({) - keyword(throw) ident(re)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - keyword(return) ident(io)operator(;) - operator(}) - - comment(// This appears to be some windows-only mode. On a java platform this is a no-op) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(binmode)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(binmode)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** @deprecated will be removed in 1.2 */) - directive(protected) type(void) ident(checkInitialized)operator(()operator(\)) operator({) - keyword(if) operator(()ident(openFile) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(uninitialized stream)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** @deprecated will be removed in 1.2 */) - directive(protected) type(void) ident(checkClosed)operator(()operator(\)) operator({) - keyword(if) operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(==) pre_constant(null) operator(&&) ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(closed stream)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(syswrite)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(syswrite)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(RubyString) ident(string) operator(=) ident(obj)operator(.)ident(asString)operator(()operator(\))operator(;) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkWritable)operator(()ident(runtime)operator(\))operator(;) - - ident(Stream) ident(writeStream) operator(=) ident(myOpenFile)operator(.)ident(getWriteStream)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(isWriteBuffered)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(SYSWRITE_BUFFERED_IO)operator(,) string<delimiter(")content(syswrite for buffered IO)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(writeStream)operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - ident(myOpenFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - type(int) ident(read) operator(=) ident(writeStream)operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(write)operator(()ident(string)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(read) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// TODO? I think this ends up propagating from normal Java exceptions) - comment(// sys_fail(openFile.getPath(\)\)) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(read)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSystemCallError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(write_nonblock)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(write_nonblock)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - comment(// MRI behavior: always check whether the file is writable) - comment(// or not, even if we are to write 0 bytes.) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(checkWritable)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) - - comment(// TODO: Obviously, we're not doing a non-blocking write here) - keyword(return) ident(write)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - operator(}) - - comment(/** io_write - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(write)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(write)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(obj)operator(.)ident(asString)operator(()operator(\))operator(;) - - comment(// TODO: Ruby reuses this logic for other "write" behavior by checking if it's an IO and calling write again) - - keyword(if) operator(()ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkWritable)operator(()ident(runtime)operator(\))operator(;) - - type(int) ident(written) operator(=) ident(fwrite)operator(()ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(written) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// TODO: sys fail) - operator(}) - - comment(// if not sync, we switch to write buffered mode) - keyword(if) operator(()operator(!)ident(myOpenFile)operator(.)ident(isSync)operator(()operator(\))operator(\)) operator({) - ident(myOpenFile)operator(.)ident(setWriteBuffered)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(written)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(protected) type(boolean) ident(waitWritable)operator(()ident(ChannelDescriptor) ident(descriptor)operator(\)) directive(throws) exception(IOException) operator({) - pre_type(Channel) ident(channel) operator(=) ident(descriptor)operator(.)ident(getChannel)operator(()operator(\))operator(;) - keyword(if) operator(()ident(channel) operator(==) pre_constant(null) operator(||) operator(!)operator(()ident(channel) keyword(instanceof) pre_type(SelectableChannel)operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - pre_type(Selector) ident(selector) operator(=) pre_type(Selector)operator(.)ident(open)operator(()operator(\))operator(;) - - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(configureBlocking)operator(()pre_constant(false)operator(\))operator(;) - type(int) ident(real_ops) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(validOps)operator(()operator(\)) operator(&) pre_type(SelectionKey)operator(.)ident(OP_WRITE)operator(;) - pre_type(SelectionKey) ident(key) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(keyFor)operator(()ident(selector)operator(\))operator(;) - - keyword(if) operator(()ident(key) operator(==) pre_constant(null)operator(\)) operator({) - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(register)operator(()ident(selector)operator(,) ident(real_ops)operator(,) ident(descriptor)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(key)operator(.)ident(interestOps)operator(()ident(key)operator(.)ident(interestOps)operator(()operator(\))operator(|)ident(real_ops)operator(\))operator(;) - operator(}) - - keyword(while)operator(()ident(selector)operator(.)ident(select)operator(()operator(\)) operator(==) integer(0)operator(\))operator(;) - - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) ident(selector)operator(.)ident(selectedKeys)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - pre_type(SelectionKey) ident(skey) operator(=) operator(()pre_type(SelectionKey)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - keyword(if) operator(()operator(()ident(skey)operator(.)ident(interestOps)operator(()operator(\)) operator(&) ident(skey)operator(.)ident(readyOps)operator(()operator(\)) operator(&) operator(()pre_type(SelectionKey)operator(.)ident(OP_WRITE)operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(if)operator(()ident(skey)operator(.)ident(attachment)operator(()operator(\)) operator(==) ident(descriptor)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(protected) type(boolean) ident(waitReadable)operator(()ident(ChannelDescriptor) ident(descriptor)operator(\)) directive(throws) exception(IOException) operator({) - pre_type(Channel) ident(channel) operator(=) ident(descriptor)operator(.)ident(getChannel)operator(()operator(\))operator(;) - keyword(if) operator(()ident(channel) operator(==) pre_constant(null) operator(||) operator(!)operator(()ident(channel) keyword(instanceof) pre_type(SelectableChannel)operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - pre_type(Selector) ident(selector) operator(=) pre_type(Selector)operator(.)ident(open)operator(()operator(\))operator(;) - - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(configureBlocking)operator(()pre_constant(false)operator(\))operator(;) - type(int) ident(real_ops) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(validOps)operator(()operator(\)) operator(&) operator(()pre_type(SelectionKey)operator(.)ident(OP_READ) operator(|) pre_type(SelectionKey)operator(.)ident(OP_ACCEPT)operator(\))operator(;) - pre_type(SelectionKey) ident(key) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(keyFor)operator(()ident(selector)operator(\))operator(;) - - keyword(if) operator(()ident(key) operator(==) pre_constant(null)operator(\)) operator({) - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(register)operator(()ident(selector)operator(,) ident(real_ops)operator(,) ident(descriptor)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(key)operator(.)ident(interestOps)operator(()ident(key)operator(.)ident(interestOps)operator(()operator(\))operator(|)ident(real_ops)operator(\))operator(;) - operator(}) - - keyword(while)operator(()ident(selector)operator(.)ident(select)operator(()operator(\)) operator(==) integer(0)operator(\))operator(;) - - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) ident(selector)operator(.)ident(selectedKeys)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - pre_type(SelectionKey) ident(skey) operator(=) operator(()pre_type(SelectionKey)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - keyword(if) operator(()operator(()ident(skey)operator(.)ident(interestOps)operator(()operator(\)) operator(&) ident(skey)operator(.)ident(readyOps)operator(()operator(\)) operator(&) operator(()pre_type(SelectionKey)operator(.)ident(OP_READ) operator(|) pre_type(SelectionKey)operator(.)ident(OP_ACCEPT)operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - keyword(if)operator(()ident(skey)operator(.)ident(attachment)operator(()operator(\)) operator(==) ident(descriptor)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(protected) type(int) ident(fwrite)operator(()ident(ByteList) ident(buffer)operator(\)) operator({) - type(int) ident(n)operator(,) ident(r)operator(,) ident(l)operator(,) ident(offset) operator(=) integer(0)operator(;) - type(boolean) ident(eagain) operator(=) pre_constant(false)operator(;) - ident(Stream) ident(writeStream) operator(=) ident(openFile)operator(.)ident(getWriteStream)operator(()operator(\))operator(;) - - type(int) ident(len) operator(=) ident(buffer)operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(()ident(n) operator(=) ident(len)operator(\)) operator(<=) integer(0)operator(\)) keyword(return) ident(n)operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(openFile)operator(.)ident(isSync)operator(()operator(\))operator(\)) operator({) - ident(openFile)operator(.)ident(fflush)operator(()ident(writeStream)operator(\))operator(;) - - comment(// TODO: why is this guarded?) - comment(// if (!rb_thread_fd_writable(fileno(f\)\)\) {) - comment(// rb_io_check_closed(fptr\);) - comment(// }) - - keyword(while)operator(()ident(offset)operator(<)ident(len)operator(\)) operator({) - ident(l) operator(=) ident(n)operator(;) - - comment(// TODO: Something about pipe buffer length here) - - ident(r) operator(=) ident(writeStream)operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(write)operator(()ident(buffer)operator(,)ident(offset)operator(,)ident(l)operator(\))operator(;) - - keyword(if)operator(()ident(r) operator(==) ident(len)operator(\)) operator({) - keyword(return) ident(len)operator(;) comment(//Everything written) - operator(}) - - keyword(if) operator(()integer(0) operator(<=) ident(r)operator(\)) operator({) - ident(offset) operator(+=) ident(r)operator(;) - ident(n) operator(-=) ident(r)operator(;) - ident(eagain) operator(=) pre_constant(true)operator(;) - operator(}) - - keyword(if)operator(()ident(eagain) operator(&&) ident(waitWritable)operator(()ident(writeStream)operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if)operator(()ident(offset) operator(>=) ident(buffer)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - ident(eagain) operator(=) pre_constant(false)operator(;) - operator(}) keyword(else) operator({) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - operator(}) - - - comment(// TODO: all this stuff...some pipe logic, some async thread stuff) - comment(// retry:) - comment(// l = n;) - comment(// if (PIPE_BUF < l &&) - comment(// !rb_thread_critical &&) - comment(// !rb_thread_alone(\) &&) - comment(// wsplit_p(fptr\)\) {) - comment(// l = PIPE_BUF;) - comment(// }) - comment(// TRAP_BEG;) - comment(// r = write(fileno(f\), RSTRING(str\)->ptr+offset, l\);) - comment(// TRAP_END;) - comment(// if (r == n\) return len;) - comment(// if (0 <= r\) {) - comment(// offset += r;) - comment(// n -= r;) - comment(// errno = EAGAIN;) - comment(// }) - comment(// if (rb_io_wait_writable(fileno(f\)\)\) {) - comment(// rb_io_check_closed(fptr\);) - comment(// if (offset < RSTRING(str\)->len\)) - comment(// goto retry;) - comment(// }) - comment(// return -1L;) - operator(}) - - comment(// TODO: handle errors in buffered write by retrying until finished or file is closed) - keyword(return) ident(writeStream)operator(.)ident(fwrite)operator(()ident(buffer)operator(\))operator(;) - comment(// while (errno = 0, offset += (r = fwrite(RSTRING(str\)->ptr+offset, 1, n, f\)\), (n -= r\) > 0\) {) - comment(// if (ferror(f\)) - comment(// \) {) - comment(// if (rb_io_wait_writable(fileno(f\)\)\) {) - comment(// rb_io_check_closed(fptr\);) - comment(// clearerr(f\);) - comment(// if (offset < RSTRING(str\)->len\)) - comment(// continue;) - comment(// }) - comment(// return -1L;) - comment(// }) - comment(// }) - -comment(// return len - n;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_io_addstr - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_append)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(anObject)operator(\)) operator({) - comment(// Claims conversion is done via 'to_s' in docs.) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(anObject)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fileno)delimiter(")>operator(,) ident(alias) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(fileno)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** Returns the current line number. - * - * @return the current line number. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(lineno)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getLineNumber)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** Sets the current line number. - * - * @param newLineNumber The new line number. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyFixnum) ident(lineno_set)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(newLineNumber)operator(\)) operator({) - ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(setLineNumber)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(newLineNumber)operator(\))operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getLineNumber)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** Returns the current sync mode. - * - * @return the current sync mode. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(sync)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(isSync)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * <p>Return the process id (pid\) of the process this IO object - * spawned. If no process exists (popen was not called\), then - * nil is returned. This is not how it appears to be defined - * but ruby 1.8 works this way.</p> - * - * @return the pid or nil - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pid)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pid)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getProcess)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(// Of course this isn't particularly useful.) - type(int) ident(pid) operator(=) ident(myOpenFile)operator(.)ident(getProcess)operator(()operator(\))operator(.)ident(hashCode)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(pid)operator(\))operator(;) - operator(}) - - comment(/** - * @deprecated - * @return - */) - directive(public) type(boolean) ident(writeDataBuffered)operator(()operator(\)) operator({) - keyword(return) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(writeDataBuffered)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(pos)delimiter(")>operator(,) string<delimiter(")content(tell)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyFixnum) ident(pos)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fgetpos)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(bde)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyFixnum) ident(pos_set)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(newPosition)operator(\)) operator({) - type(long) ident(offset) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(newPosition)operator(\))operator(;) - - keyword(if) operator(()ident(offset) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSystemCallError)operator(()string<delimiter(")content(Negative seek offset)delimiter(")>operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(lseek)operator(()ident(offset)operator(,) ident(Stream)operator(.)ident(SEEK_SET)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(offset)operator(\))operator(;) - operator(}) - - comment(/** Print some objects to the stream. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(print)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(print)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getLastLine)operator(()operator(\)) operator(})operator(;) - operator(}) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(fs) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($,)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(rs) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($)char(\\\\)delimiter(")>operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(>) integer(0) operator(&&) operator(!)ident(fs)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(fs)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(args)operator([)ident(i)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(nil)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()operator(!)ident(rs)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(rs)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(printf)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(printf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyKernel)operator(.)ident(sprintf)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(args)operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(putc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(backtrace) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(putc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - type(int) ident(c) operator(=) ident(RubyNumeric)operator(.)ident(num2chr)operator(()ident(object)operator(\))operator(;) - - keyword(try) operator({) - ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fputc)operator(()ident(c)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(object)operator(;) - operator(}) - - directive(public) ident(RubyFixnum) ident(seek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(long) ident(offset) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - type(int) ident(whence) operator(=) ident(Stream)operator(.)ident(SEEK_SET)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(whence) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(doSeek)operator(()ident(context)operator(,) ident(offset)operator(,) ident(whence)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seek)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(seek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - type(long) ident(offset) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - type(int) ident(whence) operator(=) ident(Stream)operator(.)ident(SEEK_SET)operator(;) - - keyword(return) ident(doSeek)operator(()ident(context)operator(,) ident(offset)operator(,) ident(whence)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seek)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(seek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - type(long) ident(offset) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg0)operator(\))operator(;) - type(int) ident(whence) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(.)ident(convertToInteger)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(doSeek)operator(()ident(context)operator(,) ident(offset)operator(,) ident(whence)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyFixnum) ident(doSeek)operator(()ident(ThreadContext) ident(context)operator(,) type(long) ident(offset)operator(,) type(int) ident(whence)operator(\)) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(seek)operator(()ident(offset)operator(,) ident(whence)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// This was a getOpt with one mandatory arg, but it did not work) - comment(// so I am parsing it for now.) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sysseek)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyFixnum) ident(sysseek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(long) ident(offset) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - type(long) ident(pos)operator(;) - type(int) ident(whence) operator(=) ident(Stream)operator(.)ident(SEEK_SET)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(whence) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(try) operator({) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(isReadable)operator(()operator(\)) operator(&&) ident(myOpenFile)operator(.)ident(isReadBuffered)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(sysseek for buffered IO)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(myOpenFile)operator(.)ident(isWritable)operator(()operator(\)) operator(&&) ident(myOpenFile)operator(.)ident(isWriteBuffered)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(SYSSEEK_BUFFERED_IO)operator(,) string<delimiter(")content(sysseek for buffered IO)delimiter(")>operator(\))operator(;) - operator(}) - - ident(pos) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(lseek)operator(()ident(offset)operator(,) ident(whence)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(pos)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rewind)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(rewind)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(OpenFile) ident(myOpenfile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(myOpenfile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(lseek)operator(()integer(0L)operator(,) ident(Stream)operator(.)ident(SEEK_SET)operator(\))operator(;) - ident(myOpenfile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - comment(// TODO: This is some goofy global file value from MRI..what to do?) -comment(// if (io == current_file\) {) -comment(// gets_lineno -= fptr->lineno;) -comment(// }) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoESPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// Must be back on first line on rewind.) - ident(myOpenfile)operator(.)ident(setLineNumber)operator(()integer(0)operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fsync)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(fsync)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkWritable)operator(()ident(runtime)operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(getWriteStream)operator(()operator(\))operator(.)ident(sync)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** Sets the current sync mode. - * - * @param newSync The new sync mode. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(sync_set)operator(()ident(IRubyObject) ident(newSync)operator(\)) operator({) - ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(setSync)operator(()ident(newSync)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setSync)operator(()ident(newSync)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(eof?)delimiter(")>operator(,) string<delimiter(")content(eof)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(eof_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(runtime)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(feof)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(readDataBuffered)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - ident(readCheck)operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - type(int) ident(c) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fgetc)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(c) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(ungetc)operator(()ident(c)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - ident(myOpenFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(clearerr)operator(()operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(tty?)delimiter(")>operator(,) string<delimiter(")content(isatty)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(tty_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(isatty)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileDescriptor)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\))operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(original)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(RubyIO) ident(originalIO) operator(=) operator(()ident(RubyIO)operator(\)) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()ident(original)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_IO)operator(,) string<delimiter(")content(to_io)delimiter(")>operator(\))operator(;) - - ident(OpenFile) ident(originalFile) operator(=) ident(originalIO)operator(.)ident(getOpenFileChecked)operator(()operator(\))operator(;) - ident(OpenFile) ident(newFile) operator(=) ident(openFile)operator(;) - - keyword(try) operator({) - comment(// TODO: I didn't see where MRI has this check, but it seems to be the right place) - ident(originalFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - - keyword(if) operator(()ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(originalFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(lseek)operator(()integer(0)operator(,) ident(Stream)operator(.)ident(SEEK_CUR)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(originalFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(lseek)operator(()integer(0)operator(,) ident(Stream)operator(.)ident(SEEK_CUR)operator(\))operator(;) - operator(}) - - ident(newFile)operator(.)ident(setMode)operator(()ident(originalFile)operator(.)ident(getMode)operator(()operator(\))operator(\))operator(;) - ident(newFile)operator(.)ident(setProcess)operator(()ident(originalFile)operator(.)ident(getProcess)operator(()operator(\))operator(\))operator(;) - ident(newFile)operator(.)ident(setLineNumber)operator(()ident(originalFile)operator(.)ident(getLineNumber)operator(()operator(\))operator(\))operator(;) - ident(newFile)operator(.)ident(setPath)operator(()ident(originalFile)operator(.)ident(getPath)operator(()operator(\))operator(\))operator(;) - ident(newFile)operator(.)ident(setFinalizer)operator(()ident(originalFile)operator(.)ident(getFinalizer)operator(()operator(\))operator(\))operator(;) - - ident(ModeFlags) ident(modes)operator(;) - keyword(if) operator(()ident(newFile)operator(.)ident(isReadable)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(newFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(newFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(RDONLY)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(RDWR)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(RDONLY)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(newFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(ModeFlags)operator(.)ident(WRONLY)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modes) operator(=) ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getModes)operator(()operator(\))operator(;) - operator(}) - operator(}) - - ident(ChannelDescriptor) ident(descriptor) operator(=) ident(originalFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - ident(newFile)operator(.)ident(setMainStream)operator(()ident(ChannelStream)operator(.)ident(fdopen)operator(()ident(runtime)operator(,) ident(descriptor)operator(,) ident(modes)operator(\))operator(\))operator(;) - - comment(// TODO: the rest of this...seeking to same position is unnecessary since we share a channel) - comment(// but some of this may be needed?) - -comment(// fseeko(fptr->f, ftello(orig->f\), SEEK_SET\);) -comment(// if (orig->f2\) {) -comment(// if (fileno(orig->f\) != fileno(orig->f2\)\) {) -comment(// fd = ruby_dup(fileno(orig->f2\)\);) -comment(// }) -comment(// fptr->f2 = rb_fdopen(fd, "w"\);) -comment(// fseeko(fptr->f2, ftello(orig->f2\), SEEK_SET\);) -comment(// }) -comment(// if (fptr->mode & FMODE_BINMODE\) {) -comment(// rb_io_binmode(dest\);) -comment(// }) - - comment(// Register the new descriptor) - ident(registerDescriptor)operator(()ident(newFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not init copy: )delimiter(")> operator(+) ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not init copy: )delimiter(")> operator(+) ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not init copy: )delimiter(")> operator(+) ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(could not init copy: )delimiter(")> operator(+) ident(ex)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** Closes the IO. - * - * @return The IO. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(closed_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(==) pre_constant(null) operator(&&) ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\))operator(;) - operator(}) - - comment(/** - * <p>Closes all open resources for the IO. It also removes - * it from our magical all open file descriptor pool.</p> - * - * @return The IO. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't close)delimiter(")>operator(\))operator(;) - operator(}) - - ident(openFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - keyword(return) ident(close2)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(close2)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(if) operator(()ident(openFile) operator(==) pre_constant(null)operator(\)) keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - comment(// These would be used when we notify threads...if we notify threads) - ident(interruptBlockingThreads)operator(()operator(\))operator(;) - - ident(ChannelDescriptor) ident(main)operator(,) ident(pipe)operator(;) - keyword(if) operator(()ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(pipe) operator(=) ident(openFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(pipe) operator(=) pre_constant(null)operator(;) - operator(}) - - ident(main) operator(=) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - - comment(// cleanup, raising errors if any) - ident(openFile)operator(.)ident(cleanup)operator(()ident(runtime)operator(,) pre_constant(true)operator(\))operator(;) - - comment(// TODO: notify threads waiting on descriptors/IO? probably not...) - - keyword(if) operator(()ident(openFile)operator(.)ident(getProcess)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(IRubyObject) ident(processResult) operator(=) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(openFile)operator(.)ident(getProcess)operator(()operator(\))operator(.)ident(waitFor)operator(()operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($?)delimiter(")>operator(,) ident(processResult)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(ie)operator(\)) operator({) - comment(// TODO: do something here?) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close_write)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close_write)operator(()ident(ThreadContext) ident(context)operator(\)) directive(throws) ident(BadDescriptorException) operator({) - keyword(try) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't close)delimiter(")>operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null) operator(&&) ident(myOpenFile)operator(.)ident(isReadable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(closing non-duplex IO for writing)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(close)operator(()operator(\))operator(;) - operator(}) keyword(else)operator({) - ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setPipeStream)operator(()pre_constant(null)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setMode)operator(()ident(myOpenFile)operator(.)ident(getMode)operator(()operator(\)) operator(&) operator(~)ident(OpenFile)operator(.)ident(WRITABLE)operator(\))operator(;) - comment(// TODO) - comment(// n is result of fclose; but perhaps having a SysError below is enough?) - comment(// if (n != 0\) rb_sys_fail(fptr->path\);) - operator(}) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - comment(// hmmmm) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close_read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close_read)operator(()ident(ThreadContext) ident(context)operator(\)) directive(throws) ident(BadDescriptorException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't close)delimiter(")>operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null) operator(&&) ident(myOpenFile)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()string<delimiter(")content(closing non-duplex IO for reading)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(close)operator(()operator(\))operator(;) - operator(}) keyword(else)operator({) - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fclose)operator(()operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setMode)operator(()ident(myOpenFile)operator(.)ident(getMode)operator(()operator(\)) operator(&) operator(~)ident(OpenFile)operator(.)ident(READABLE)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setMainStream)operator(()ident(myOpenFile)operator(.)ident(getPipeStream)operator(()operator(\))operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setPipeStream)operator(()pre_constant(null)operator(\))operator(;) - comment(// TODO) - comment(// n is result of fclose; but perhaps having a SysError below is enough?) - comment(// if (n != 0\) rb_sys_fail(fptr->path\);) - operator(}) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - comment(// I believe Ruby bails out with a "bug" if closing fails) - keyword(throw) ident(runtime)operator(.)ident(newIOErrorFromException)operator(()ident(ioe)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** Flushes the IO output stream. - * - * @return The IO. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flush)delimiter(")>operator(\)) - directive(public) ident(RubyIO) ident(flush)operator(()operator(\)) operator({) - keyword(try) operator({) - ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getWriteStream)operator(()operator(\))operator(.)ident(fflush)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** Read a line. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gets)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(gets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ByteList) ident(separator) operator(=) ident(getSeparatorForGets)operator(()ident(runtime)operator(,) ident(args)operator(\))operator(;) - - ident(IRubyObject) ident(result) operator(=) ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(result)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) type(boolean) ident(getBlocking)operator(()operator(\)) operator({) - keyword(return) operator(()operator(()ident(ChannelStream)operator(\)) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(.)ident(isBlocking)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fcntl)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(fcntl)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(cmd)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - comment(// TODO: This version differs from ioctl by checking whether fcntl exists) - comment(// and raising notimplemented if it doesn't; perhaps no difference for us?) - keyword(return) ident(ctl)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmd)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ioctl)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(ioctl)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(cmd) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(IRubyObject) ident(arg)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2)operator(\)) operator({) - ident(arg) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) keyword(else) operator({) - ident(arg) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(ctl)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(cmd)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(ctl)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(cmd)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(long) ident(realCmd) operator(=) ident(cmd)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(nArg) operator(=) integer(0)operator(;) - - comment(// FIXME: Arg may also be true, false, and nil and still be valid. Strangely enough, ) - comment(// protocol conversion is not happening in Ruby on this arg?) - keyword(if) operator(()ident(arg)operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(arg) operator(==) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(\)) operator({) - ident(nArg) operator(=) integer(0)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(nArg) operator(=) ident(RubyFixnum)operator(.)ident(fix2long)operator(()ident(arg)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) operator(==) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(\)) operator({) - ident(nArg) operator(=) integer(1)operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(JRuby does not support string for second fcntl/ioctl argument yet)delimiter(")>operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - comment(// Fixme: Only F_SETFL is current supported) - keyword(if) operator(()ident(realCmd) operator(==) integer(1L)operator(\)) operator({) comment(// cmd is F_SETFL) - type(boolean) ident(block) operator(=) pre_constant(true)operator(;) - - keyword(if) operator(()operator(()ident(nArg) operator(&) ident(ModeFlags)operator(.)ident(NONBLOCK)operator(\)) operator(==) ident(ModeFlags)operator(.)ident(NONBLOCK)operator(\)) operator({) - ident(block) operator(=) pre_constant(false)operator(;) - operator(}) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setBlocking)operator(()ident(block)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(JRuby only supports F_SETFL for fcntl/ioctl currently)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ByteList) ident(NIL_BYTELIST) operator(=) ident(ByteList)operator(.)ident(create)operator(()string<delimiter(")content(nil)delimiter(")>operator(\))operator(;) - directive(private) directive(static) directive(final) ident(ByteList) ident(RECURSIVE_BYTELIST) operator(=) ident(ByteList)operator(.)ident(create)operator(()string<delimiter(")content([...])delimiter(")>operator(\))operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(puts)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(puts)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(assert) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(getDefaultSeparator)operator(()operator(\)) keyword(instanceof) ident(RubyString)operator(;) - ident(RubyString) ident(separator) operator(=) operator(()ident(RubyString)operator(\)) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(getDefaultSeparator)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(write)operator(()ident(context)operator(,) ident(separator)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(ByteList) ident(line)operator(;) - - keyword(if) operator(()ident(args)operator([)ident(i)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(line) operator(=) ident(NIL_BYTELIST)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\)) operator({) - ident(line) operator(=) ident(RECURSIVE_BYTELIST)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - ident(inspectPuts)operator(()ident(context)operator(,) operator(()ident(RubyArray)operator(\)) ident(args)operator([)ident(i)operator(])operator(\))operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) operator({) - ident(line) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(asString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - - ident(write)operator(()ident(context)operator(,) ident(line)operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0) operator(||) operator(!)ident(line)operator(.)ident(endsWith)operator(()ident(separator)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(\)) operator({) - ident(write)operator(()ident(context)operator(,) ident(separator)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(write)operator(()ident(ThreadContext) ident(context)operator(,) ident(ByteList) ident(byteList)operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(byteList)operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(inspectPuts)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyArray) ident(array)operator(\)) operator({) - keyword(try) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()ident(array)operator(\))operator(;) - keyword(return) ident(puts)operator(()ident(context)operator(,) ident(array)operator(.)ident(toJavaArray)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()ident(array)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Read a line. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readline)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(readline)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(line)operator(;) - operator(}) - - comment(/** Read a byte. On EOF returns nil. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getc)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(getc)operator(()operator(\)) operator({) - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - ident(Stream) ident(stream) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(;) - - ident(readCheck)operator(()ident(stream)operator(\))operator(;) - ident(stream)operator(.)ident(clearerr)operator(()operator(\))operator(;) - - type(int) ident(c) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fgetc)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(c) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// TODO: check for ferror, clear it, and try once more up above readCheck) -comment(// if (ferror(f\)\) {) -comment(// clearerr(f\);) -comment(// if (!rb_io_wait_readable(fileno(f\)\)\)) -comment(// rb_sys_fail(fptr->path\);) -comment(// goto retry;) -comment(// }) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(c)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(readCheck)operator(()ident(Stream) ident(stream)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(stream)operator(.)ident(readDataBuffered)operator(()operator(\))operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * <p>Pushes char represented by int back onto IOS.</p> - * - * @param number to push back - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ungetc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(ungetc)operator(()ident(IRubyObject) ident(number)operator(\)) operator({) - type(int) ident(ch) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(number)operator(\))operator(;) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(myOpenFile)operator(.)ident(isReadBuffered)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(unread stream)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(ungetc)operator(()ident(ch)operator(\)) operator(==) operator(-)integer(1) operator(&&) ident(ch) operator(!=) operator(-)integer(1)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(ungetc failed)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read_nonblock)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(read_nonblock)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(openFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - - keyword(if)operator(()operator(!)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) keyword(instanceof) ident(ChannelStream)operator(\))operator(\)) operator({) - comment(// cryptic for the uninitiated...) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(read_nonblock only works with Nio based handlers)delimiter(")>operator(\))operator(;) - operator(}) - keyword(try) operator({) - type(int) ident(maxLength) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(maxLength) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(maxLength) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - ident(ByteList) ident(buf) operator(=) operator(()operator(()ident(ChannelStream)operator(\))ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(.)ident(readnonblock)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - ident(IRubyObject) ident(strbuf) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buf) operator(==) pre_constant(null) operator(?) keyword(new) ident(ByteList)operator(()ident(ByteList)operator(.)ident(NULL_ARRAY)operator(\)) operator(:) ident(buf)operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(args)operator([)integer(1)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LSHIFT)operator(,) string<delimiter(")content(<<)delimiter(")>operator(,) ident(strbuf)operator(\))operator(;) - keyword(return) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) - - keyword(return) ident(strbuf)operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readpartial)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(readpartial)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(openFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - - keyword(if)operator(()operator(!)operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\)) keyword(instanceof) ident(ChannelStream)operator(\))operator(\)) operator({) - comment(// cryptic for the uninitiated...) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(readpartial only works with Nio based handlers)delimiter(")>operator(\))operator(;) - operator(}) - keyword(try) operator({) - type(int) ident(maxLength) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(maxLength) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(maxLength) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - ident(ByteList) ident(buf) operator(=) operator(()operator(()ident(ChannelStream)operator(\))ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(.)ident(readpartial)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - ident(IRubyObject) ident(strbuf) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buf) operator(==) pre_constant(null) operator(?) keyword(new) ident(ByteList)operator(()ident(ByteList)operator(.)ident(NULL_ARRAY)operator(\)) operator(:) ident(buf)operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(args)operator([)integer(1)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LSHIFT)operator(,) string<delimiter(")content(<<)delimiter(")>operator(,) ident(strbuf)operator(\))operator(;) - keyword(return) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) - - keyword(return) ident(strbuf)operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sysread)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(sysread)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(int) ident(len) operator(=) operator(()type(int)operator(\))ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(Negative size)delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - ident(RubyString) ident(str)operator(;) - ident(ByteList) ident(buffer)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1) operator(||) ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(\))operator(;) - operator(}) - - ident(buffer) operator(=) keyword(new) ident(ByteList)operator(()ident(len)operator(\))operator(;) - ident(str) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(buffer)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(str) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(str)operator(.)ident(modify)operator(()ident(len)operator(\))operator(;) - - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - - ident(buffer) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(readDataBuffered)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(sysread for buffered IO)delimiter(")>operator(\))operator(;) - operator(}) - - comment(// TODO: Ruby locks the string here) - - ident(context)operator(.)ident(getThread)operator(()operator(\))operator(.)ident(beforeBlockingCall)operator(()operator(\))operator(;) - ident(myOpenFile)operator(.)ident(checkClosed)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - comment(// TODO: Ruby re-checks that the buffer string hasn't been modified) - - type(int) ident(bytesRead) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(read)operator(()ident(len)operator(,) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - - comment(// TODO: Ruby unlocks the string here) - - comment(// TODO: Ruby truncates string to specific size here, but our bytelist should handle this already?) - - keyword(if) operator(()ident(bytesRead) operator(==) operator(-)integer(1) operator(||) operator(()ident(bytesRead) operator(==) integer(0) operator(&&) ident(len) operator(>) integer(0)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) - - ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(str)operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - comment(// All errors to sysread should be SystemCallErrors, but on a closed stream) - comment(// Ruby returns an IOError. Java throws same exception for all errors so) - comment(// we resort to this hack...) - keyword(if) operator(()string<delimiter(")content(File not open)delimiter(")>operator(.)ident(equals)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSystemCallError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(getThread)operator(()operator(\))operator(.)ident(afterBlockingCall)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(IRubyObject) ident(read)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(return) ident(read)operator(()ident(context)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(read)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(read)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(2)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(runtime)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - keyword(return) ident(readAll)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(if) operator(()ident(arg0)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(read)operator(()ident(context)operator(\))operator(;) - operator(}) - - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - type(int) ident(length) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg0)operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(length) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyString) ident(str) operator(=) pre_constant(null)operator(;) - - keyword(return) ident(readNotAll)operator(()ident(context)operator(,) ident(myOpenFile)operator(,) ident(length)operator(,) ident(str)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(arg0)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - keyword(return) ident(readAll)operator(()ident(arg1)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - type(int) ident(length) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg0)operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(length) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyString) ident(str) operator(=) pre_constant(null)operator(;) -comment(// ByteList buffer = null;) - keyword(if) operator(()ident(arg1)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) -comment(// buffer = new ByteList(length\);) -comment(// str = RubyString.newString(getRuntime(\), buffer\);) - operator(}) keyword(else) operator({) - ident(str) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(str)operator(.)ident(modify)operator(()ident(length)operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - -comment(// buffer = str.getByteList(\);) - operator(}) - - keyword(return) ident(readNotAll)operator(()ident(context)operator(,) ident(myOpenFile)operator(,) ident(length)operator(,) ident(str)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(readNotAll)operator(()ident(ThreadContext) ident(context)operator(,) ident(OpenFile) ident(myOpenFile)operator(,) type(int) ident(length)operator(,) ident(RubyString) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(runtime)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(feof)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(// TODO: Ruby locks the string here) - - comment(// READ_CHECK from MRI io.c) - ident(readCheck)operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(\))operator(;) - - comment(// TODO: check buffer length again?) - comment(// if (RSTRING(str\)->len != len\) {) - comment(// rb_raise(rb_eRuntimeError, "buffer string modified"\);) - comment(// }) - - comment(// TODO: read into buffer using all the fread logic) - comment(// int read = openFile.getMainStream(\).fread(buffer\);) - ident(ByteList) ident(newBuffer) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fread)operator(()ident(length)operator(\))operator(;) - - comment(// TODO: Ruby unlocks the string here) - - comment(// TODO: change this to check number read into buffer once that's working) - comment(// if (read == 0\) {) - - keyword(if) operator(()ident(newBuffer) operator(==) pre_constant(null) operator(||) ident(newBuffer)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(feof)operator(()operator(\))operator(\)) operator({) - comment(// truncate buffer string to zero, if provided) - keyword(if) operator(()ident(str) operator(!=) pre_constant(null)operator(\)) operator({) - ident(str)operator(.)ident(setValue)operator(()ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(.)ident(dup)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(// Removed while working on JRUBY-2386, since fixes for that) - comment(// modified EOF logic such that this check is not really valid.) - comment(// We expect that an EOFException will be thrown now in EOF) - comment(// cases.) -comment(// if (length > 0\) {) -comment(// // I think this is only partly correct; sys fail based on errno in Ruby) -comment(// throw getRuntime(\).newEOFError(\);) -comment(// }) - operator(}) - - - comment(// TODO: Ruby truncates string to specific size here, but our bytelist should handle this already?) - - comment(// FIXME: I don't like the null checks here) - keyword(if) operator(()ident(str) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(newBuffer) operator(==) pre_constant(null)operator(\)) operator({) - ident(str) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(str) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(newBuffer)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(newBuffer) operator(==) pre_constant(null)operator(\)) operator({) - ident(str)operator(.)ident(empty)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(str)operator(.)ident(setValue)operator(()ident(newBuffer)operator(\))operator(;) - operator(}) - operator(}) - ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(str)operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOErrorFromException)operator(()ident(ex)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(protected) ident(IRubyObject) ident(readAll)operator(()ident(IRubyObject) ident(buffer)operator(\)) directive(throws) ident(BadDescriptorException)operator(,) exception(EOFException)operator(,) exception(IOException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - comment(// TODO: handle writing into original buffer better) - - ident(RubyString) ident(str) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(buffer) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(str) operator(=) operator(()ident(RubyString)operator(\))ident(buffer)operator(;) - operator(}) - - comment(// TODO: ruby locks the string here) - - comment(// READ_CHECK from MRI io.c) - keyword(if) operator(()ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(readDataBuffered)operator(()operator(\))operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - ident(ByteList) ident(newBuffer) operator(=) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(readall)operator(()operator(\))operator(;) - - comment(// TODO same zero-length checks as file above) - - keyword(if) operator(()ident(str) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(newBuffer) operator(==) pre_constant(null)operator(\)) operator({) - ident(str) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(str) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(newBuffer)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(newBuffer) operator(==) pre_constant(null)operator(\)) operator({) - ident(str)operator(.)ident(empty)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(str)operator(.)ident(setValue)operator(()ident(newBuffer)operator(\))operator(;) - operator(}) - operator(}) - - ident(str)operator(.)ident(taint)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(str)operator(;) -comment(// long bytes = 0;) -comment(// long n;) -comment(//) -comment(// if (siz == 0\) siz = BUFSIZ;) -comment(// if (NIL_P(str\)\) {) -comment(// str = rb_str_new(0, siz\);) -comment(// }) -comment(// else {) -comment(// rb_str_resize(str, siz\);) -comment(// }) -comment(// for (;;\) {) -comment(// rb_str_locktmp(str\);) -comment(// READ_CHECK(fptr->f\);) -comment(// n = io_fread(RSTRING(str\)->ptr+bytes, siz-bytes, fptr\);) -comment(// rb_str_unlocktmp(str\);) -comment(// if (n == 0 && bytes == 0\) {) -comment(// if (!fptr->f\) break;) -comment(// if (feof(fptr->f\)\) break;) -comment(// if (!ferror(fptr->f\)\) break;) -comment(// rb_sys_fail(fptr->path\);) -comment(// }) -comment(// bytes += n;) -comment(// if (bytes < siz\) break;) -comment(// siz += BUFSIZ;) -comment(// rb_str_resize(str, siz\);) -comment(// }) -comment(// if (bytes != siz\) rb_str_resize(str, bytes\);) -comment(// OBJ_TAINT(str\);) -comment(//) -comment(// return str;) - operator(}) - - comment(// TODO: There's a lot of complexity here due to error handling and) - comment(// nonblocking IO; much of this goes away, but for now I'm just) - comment(// having read call ChannelStream.fread directly.) -comment(// protected int fread(int len, ByteList buffer\) {) -comment(// long n = len;) -comment(// int c;) -comment(// int saved_errno;) -comment(//) -comment(// while (n > 0\) {) -comment(// c = read_buffered_data(ptr, n, fptr->f\);) -comment(// if (c < 0\) goto eof;) -comment(// if (c > 0\) {) -comment(// ptr += c;) -comment(// if ((n -= c\) <= 0\) break;) -comment(// }) -comment(// rb_thread_wait_fd(fileno(fptr->f\)\);) -comment(// rb_io_check_closed(fptr\);) -comment(// clearerr(fptr->f\);) -comment(// TRAP_BEG;) -comment(// c = getc(fptr->f\);) -comment(// TRAP_END;) -comment(// if (c == EOF\) {) -comment(// eof:) -comment(// if (ferror(fptr->f\)\) {) -comment(// switch (errno\) {) -comment(// case EINTR:) -comment(// #if defined(ERESTART\)) -comment(// case ERESTART:) -comment(// #endif) -comment(// clearerr(fptr->f\);) -comment(// continue;) -comment(// case EAGAIN:) -comment(// #if defined(EWOULDBLOCK\) && EWOULDBLOCK != EAGAIN) -comment(// case EWOULDBLOCK:) -comment(// #endif) -comment(// if (len > n\) {) -comment(// clearerr(fptr->f\);) -comment(// }) -comment(// saved_errno = errno;) -comment(// rb_warning("nonblocking IO#read is obsolete; use IO#readpartial or IO#sysread"\);) -comment(// errno = saved_errno;) -comment(// }) -comment(// if (len == n\) return 0;) -comment(// }) -comment(// break;) -comment(// }) -comment(// *ptr++ = c;) -comment(// n--;) -comment(// }) -comment(// return len - n;) -comment(// ) -comment(// }) - - comment(/** Read a byte. On EOF throw EOFError. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readchar)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(readchar)operator(()operator(\)) operator({) - ident(IRubyObject) ident(c) operator(=) ident(getc)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(c)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(c)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(stat)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(openFile)operator(.)ident(checkClosed)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(getOpenFileChecked)operator(()operator(\))operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileDescriptor)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * <p>Invoke a block for each byte.</p> - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_byte)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_byte)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(OpenFile) ident(myOpenFile) operator(=) ident(getOpenFileChecked)operator(()operator(\))operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - ident(myOpenFile)operator(.)ident(checkReadable)operator(()ident(runtime)operator(\))operator(;) - ident(myOpenFile)operator(.)ident(setReadBuffered)operator(()operator(\))operator(;) - - comment(// TODO: READ_CHECK from MRI) - - type(int) ident(c) operator(=) ident(myOpenFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(fgetc)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(c) operator(==) operator(-)integer(1)operator(\)) operator({) - comment(// TODO: check for error, clear it, and wait until readable before trying once more) -comment(// if (ferror(f\)\) {) -comment(// clearerr(f\);) -comment(// if (!rb_io_wait_readable(fileno(f\)\)\)) -comment(// rb_sys_fail(fptr->path\);) -comment(// continue;) -comment(// }) - keyword(break)operator(;) - operator(}) - - keyword(assert) ident(c) operator(<) integer(256)operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(c)operator(\))operator(\))operator(;) - operator(}) - - comment(// TODO: one more check for error) -comment(// if (ferror(f\)\) rb_sys_fail(fptr->path\);) - keyword(return) local_variable(this)operator(;) - operator(}) keyword(catch) operator(()ident(PipeException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEPIPEError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(BadDescriptorException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEBADFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(EOFException) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * <p>Invoke a block for each line.</p> - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(each_line)delimiter(")>operator(,) string<delimiter(")content(each)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyIO) ident(each_line)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ByteList) ident(separator) operator(=) ident(getSeparatorForGets)operator(()ident(runtime)operator(,) ident(args)operator(\))operator(;) - - keyword(for) operator(()ident(IRubyObject) ident(line) operator(=) ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(;) operator(!)ident(line)operator(.)ident(isNil)operator(()operator(\))operator(;) - ident(line) operator(=) ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(line)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(readlines)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject)type([]) ident(separatorArgs) operator(=) ident(args)operator(.)ident(length) operator(>) integer(0) operator(?) keyword(new) ident(IRubyObject)type([]) operator({) ident(args)operator([)integer(0)operator(]) operator(}) operator(:) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(;) - ident(ByteList) ident(separator) operator(=) ident(getSeparatorForGets)operator(()ident(runtime)operator(,) ident(separatorArgs)operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(line)operator(;) - - keyword(while) operator(()operator(!) operator(()ident(line) operator(=) ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(line)operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_io)delimiter(")>operator(\)) - directive(public) ident(RubyIO) ident(to_io)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(String) ident(toString)operator(()operator(\)) operator({) - keyword(return) string<delimiter(")content(RubyIO()delimiter(")> operator(+) ident(openFile)operator(.)ident(getMode)operator(()operator(\)) operator(+) string<delimiter(")content(, )delimiter(")> operator(+) ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(.)ident(getFileno)operator(()operator(\)) operator(+) string<delimiter(")content(\))delimiter(")>operator(;) - operator(}) - - comment(/* class methods for IO */) - - comment(/** rb_io_s_foreach - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(foreach)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(foreach)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(count) operator(=) ident(args)operator(.)ident(length)operator(;) - ident(IRubyObject) ident(filename) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(filename)operator(\))operator(;) - - ident(ByteList) ident(separator) operator(=) ident(getSeparatorFromArgs)operator(()ident(runtime)operator(,) ident(args)operator(,) integer(1)operator(\))operator(;) - - ident(RubyIO) ident(io) operator(=) operator(()ident(RubyIO)operator(\))ident(RubyFile)operator(.)ident(open)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(filename) operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(io)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(IRubyObject) ident(str) operator(=) ident(io)operator(.)ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(;) - keyword(while) operator(()operator(!)ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(str)operator(\))operator(;) - ident(str) operator(=) ident(io)operator(.)ident(getline)operator(()ident(runtime)operator(,) ident(separator)operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(io)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(RubyIO) ident(convertToIO)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) operator(()ident(RubyIO)operator(\))ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(obj)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getIO)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_IO)operator(,) string<delimiter(")content(to_io)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(registerSelect)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(Selector) ident(selector)operator(,) ident(IRubyObject) ident(obj)operator(,) ident(RubyIO) ident(ioObj)operator(,) type(int) ident(ops)operator(\)) directive(throws) exception(IOException) operator({) - pre_type(Channel) ident(channel) operator(=) ident(ioObj)operator(.)ident(getChannel)operator(()operator(\))operator(;) - keyword(if) operator(()ident(channel) operator(==) pre_constant(null) operator(||) operator(!)operator(()ident(channel) keyword(instanceof) pre_type(SelectableChannel)operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(configureBlocking)operator(()pre_constant(false)operator(\))operator(;) - type(int) ident(real_ops) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(validOps)operator(()operator(\)) operator(&) ident(ops)operator(;) - pre_type(SelectionKey) ident(key) operator(=) operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(keyFor)operator(()ident(selector)operator(\))operator(;) - - keyword(if) operator(()ident(key) operator(==) pre_constant(null)operator(\)) operator({) - operator(()operator(()pre_type(SelectableChannel)operator(\)) ident(channel)operator(\))operator(.)ident(register)operator(()ident(selector)operator(,) ident(real_ops)operator(,) ident(obj)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(key)operator(.)ident(interestOps)operator(()ident(key)operator(.)ident(interestOps)operator(()operator(\))operator(|)ident(real_ops)operator(\))operator(;) - operator(}) - - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(select)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(3)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(select_static)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(checkArrayType)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> - operator(+) ident(obj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Array\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(select_static)operator(()ident(ThreadContext) ident(context)operator(,) ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(try) operator({) - pre_type(Set) ident(pending) operator(=) keyword(new) pre_type(HashSet)operator(()operator(\))operator(;) - pre_type(Set) ident(unselectable_reads) operator(=) keyword(new) pre_type(HashSet)operator(()operator(\))operator(;) - pre_type(Set) ident(unselectable_writes) operator(=) keyword(new) pre_type(HashSet)operator(()operator(\))operator(;) - pre_type(Selector) ident(selector) operator(=) pre_type(Selector)operator(.)ident(open)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - comment(// read) - ident(checkArrayType)operator(()ident(runtime)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) operator(()ident(IRubyObject)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - ident(RubyIO) ident(ioObj) operator(=) ident(convertToIO)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - keyword(if) operator(()ident(registerSelect)operator(()ident(context)operator(,) ident(selector)operator(,) ident(obj)operator(,) ident(ioObj)operator(,) pre_type(SelectionKey)operator(.)ident(OP_READ) operator(|) pre_type(SelectionKey)operator(.)ident(OP_ACCEPT)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(ioObj)operator(.)ident(writeDataBuffered)operator(()operator(\))operator(\)) operator({) - ident(pending)operator(.)ident(add)operator(()ident(obj)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(() ident(ioObj)operator(.)ident(openFile)operator(.)ident(getMode)operator(()operator(\)) operator(&) ident(OpenFile)operator(.)ident(READABLE) operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(unselectable_reads)operator(.)ident(add)operator(()ident(obj)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1) operator(&&) operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - comment(// write) - ident(checkArrayType)operator(()ident(runtime)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) operator(()operator(()ident(RubyArray)operator(\)) ident(args)operator([)integer(1)operator(])operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) operator(()ident(IRubyObject)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - ident(RubyIO) ident(ioObj) operator(=) ident(convertToIO)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(registerSelect)operator(()ident(context)operator(,) ident(selector)operator(,) ident(obj)operator(,) ident(ioObj)operator(,) pre_type(SelectionKey)operator(.)ident(OP_WRITE)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(() ident(ioObj)operator(.)ident(openFile)operator(.)ident(getMode)operator(()operator(\)) operator(&) ident(OpenFile)operator(.)ident(WRITABLE) operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(unselectable_writes)operator(.)ident(add)operator(()ident(obj)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2) operator(&&) operator(!)ident(args)operator([)integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(checkArrayType)operator(()ident(runtime)operator(,) ident(args)operator([)integer(2)operator(])operator(\))operator(;) - comment(// Java's select doesn't do anything about this, so we leave it be.) - operator(}) - - directive(final) type(boolean) ident(has_timeout) operator(=) operator(() ident(args)operator(.)ident(length) operator(>) integer(3) operator(&&) operator(!)ident(args)operator([)integer(3)operator(])operator(.)ident(isNil)operator(()operator(\)) operator(\))operator(;) - type(long) ident(timeout) operator(=) integer(0)operator(;) - keyword(if)operator(()ident(has_timeout)operator(\)) operator({) - ident(IRubyObject) ident(timeArg) operator(=) ident(args)operator([)integer(3)operator(])operator(;) - keyword(if) operator(()ident(timeArg) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(timeout) operator(=) pre_type(Math)operator(.)ident(round)operator(()operator(()operator(()ident(RubyFloat)operator(\)) ident(timeArg)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(timeArg) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(timeout) operator(=) pre_type(Math)operator(.)ident(round)operator(()operator(()operator(()ident(RubyFixnum)operator(\)) ident(timeArg)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - operator(}) keyword(else) operator({) comment(// TODO: MRI also can hadle Bignum here) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> - operator(+) ident(timeArg)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( into time interval)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(timeout) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative timeout given)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(pending)operator(.)ident(isEmpty)operator(()operator(\)) operator(&&) ident(unselectable_reads)operator(.)ident(isEmpty)operator(()operator(\)) operator(&&) ident(unselectable_writes)operator(.)ident(isEmpty)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(has_timeout)operator(\)) operator({) - keyword(if) operator(()ident(timeout)operator(==)integer(0)operator(\)) operator({) - ident(selector)operator(.)ident(selectNow)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(selector)operator(.)ident(select)operator(()ident(timeout)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(selector)operator(.)ident(select)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(selector)operator(.)ident(selectNow)operator(()operator(\))operator(;) - operator(}) - - pre_type(List) ident(r) operator(=) keyword(new) pre_type(ArrayList)operator(()operator(\))operator(;) - pre_type(List) ident(w) operator(=) keyword(new) pre_type(ArrayList)operator(()operator(\))operator(;) - pre_type(List) ident(e) operator(=) keyword(new) pre_type(ArrayList)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) ident(selector)operator(.)ident(selectedKeys)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - pre_type(SelectionKey) ident(key) operator(=) operator(()pre_type(SelectionKey)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - keyword(if) operator(()operator(()ident(key)operator(.)ident(interestOps)operator(()operator(\)) operator(&) ident(key)operator(.)ident(readyOps)operator(()operator(\)) - operator(&) operator(()pre_type(SelectionKey)operator(.)ident(OP_READ)operator(|)pre_type(SelectionKey)operator(.)ident(OP_ACCEPT)operator(|)pre_type(SelectionKey)operator(.)ident(OP_CONNECT)operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(r)operator(.)ident(add)operator(()ident(key)operator(.)ident(attachment)operator(()operator(\))operator(\))operator(;) - ident(pending)operator(.)ident(remove)operator(()ident(key)operator(.)ident(attachment)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(()ident(key)operator(.)ident(interestOps)operator(()operator(\)) operator(&) ident(key)operator(.)ident(readyOps)operator(()operator(\)) operator(&) operator(()pre_type(SelectionKey)operator(.)ident(OP_WRITE)operator(\))operator(\)) operator(!=) integer(0)operator(\)) operator({) - ident(w)operator(.)ident(add)operator(()ident(key)operator(.)ident(attachment)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - ident(r)operator(.)ident(addAll)operator(()ident(pending)operator(\))operator(;) - ident(r)operator(.)ident(addAll)operator(()ident(unselectable_reads)operator(\))operator(;) - ident(w)operator(.)ident(addAll)operator(()ident(unselectable_writes)operator(\))operator(;) - - comment(// make all sockets blocking as configured again) - keyword(for) operator(()pre_type(Iterator) ident(i) operator(=) ident(selector)operator(.)ident(keys)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - pre_type(SelectionKey) ident(key) operator(=) operator(()pre_type(SelectionKey)operator(\)) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - pre_type(SelectableChannel) ident(channel) operator(=) ident(key)operator(.)ident(channel)operator(()operator(\))operator(;) - directive(synchronized)operator(()ident(channel)operator(.)ident(blockingLock)operator(()operator(\))operator(\)) operator({) - ident(RubyIO) ident(originalIO) operator(=) operator(()ident(RubyIO)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(() - operator(()ident(IRubyObject)operator(\)) ident(key)operator(.)ident(attachment)operator(()operator(\))operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(,) - ident(MethodIndex)operator(.)ident(TO_IO)operator(,) string<delimiter(")content(to_io)delimiter(")>operator(\))operator(;) - type(boolean) ident(blocking) operator(=) ident(originalIO)operator(.)ident(getBlocking)operator(()operator(\))operator(;) - ident(key)operator(.)ident(cancel)operator(()operator(\))operator(;) - ident(channel)operator(.)ident(configureBlocking)operator(()ident(blocking)operator(\))operator(;) - operator(}) - operator(}) - ident(selector)operator(.)ident(close)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(r)operator(.)ident(size)operator(()operator(\)) operator(==) integer(0) operator(&&) ident(w)operator(.)ident(size)operator(()operator(\)) operator(==) integer(0) operator(&&) ident(e)operator(.)ident(size)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - pre_type(List) ident(ret) operator(=) keyword(new) pre_type(ArrayList)operator(()operator(\))operator(;) - - ident(ret)operator(.)ident(add)operator(()ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(r)operator(\))operator(\))operator(;) - ident(ret)operator(.)ident(add)operator(()ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(w)operator(\))operator(\))operator(;) - ident(ret)operator(.)ident(add)operator(()ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(e)operator(\))operator(\))operator(;) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(runtime)operator(,) ident(ret)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOError)operator(()ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(read)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(read)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(3)operator(:) keyword(return) ident(read)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(3)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject)type([]) ident(fileArguments) operator(=) keyword(new) ident(IRubyObject)type([]) operator({)ident(arg0)operator(})operator(;) - ident(RubyIO) ident(file) operator(=) operator(()ident(RubyIO)operator(\)) ident(RubyKernel)operator(.)ident(open)operator(()ident(context)operator(,) ident(recv)operator(,) ident(fileArguments)operator(,) ident(block)operator(\))operator(;) - - keyword(try) operator({) - keyword(return) ident(file)operator(.)ident(read)operator(()ident(context)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(file)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject)type([]) ident(fileArguments) operator(=) keyword(new) ident(IRubyObject)type([]) operator({)ident(arg0)operator(})operator(;) - ident(RubyIO) ident(file) operator(=) operator(()ident(RubyIO)operator(\)) ident(RubyKernel)operator(.)ident(open)operator(()ident(context)operator(,) ident(recv)operator(,) ident(fileArguments)operator(,) ident(block)operator(\))operator(;) - - keyword(try) operator({) - keyword(if) operator(()operator(!)ident(arg1)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(file)operator(.)ident(read)operator(()ident(context)operator(,) ident(arg1)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(file)operator(.)ident(read)operator(()ident(context)operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(file)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(read)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject)type([]) ident(fileArguments) operator(=) keyword(new) ident(IRubyObject)type([])operator({)ident(arg0)operator(})operator(;) - ident(RubyIO) ident(file) operator(=) operator(()ident(RubyIO)operator(\)) ident(RubyKernel)operator(.)ident(open)operator(()ident(context)operator(,) ident(recv)operator(,) ident(fileArguments)operator(,) ident(block)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(arg2)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(file)operator(.)ident(seek)operator(()ident(context)operator(,) ident(arg2)operator(\))operator(;) - operator(}) - - keyword(try) operator({) - keyword(if) operator(()operator(!)ident(arg1)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(file)operator(.)ident(read)operator(()ident(context)operator(,) ident(arg1)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(file)operator(.)ident(read)operator(()ident(context)operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(file)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(readlines)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(count) operator(=) ident(args)operator(.)ident(length)operator(;) - - ident(IRubyObject)type([]) ident(fileArguments) operator(=) keyword(new) ident(IRubyObject)type([])operator({) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\)) operator(})operator(;) - ident(IRubyObject)type([]) ident(separatorArguments) operator(=) ident(count) operator(>=) integer(2) operator(?) keyword(new) ident(IRubyObject)type([])operator({)ident(args)operator([)integer(1)operator(])operator(}) operator(:) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(;) - ident(RubyIO) ident(file) operator(=) operator(()ident(RubyIO)operator(\)) ident(RubyKernel)operator(.)ident(open)operator(()ident(context)operator(,) ident(recv)operator(,) ident(fileArguments)operator(,) ident(block)operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(file)operator(.)ident(readlines)operator(()ident(context)operator(,) ident(separatorArguments)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(file)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(popen)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(popen)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(mode)operator(;) - - ident(IRubyObject) ident(cmdObj) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(cmdObj)operator(\))operator(;) - - keyword(if) operator(()string<delimiter(")content(-)delimiter(")>operator(.)ident(equals)operator(()ident(cmdObj)operator(.)ident(toString)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(popen()char(\\")content(-)char(\\")content(\) is unimplemented)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(try) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(mode) operator(=) ident(ModeFlags)operator(.)ident(RDONLY)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(mode) operator(=) ident(RubyFixnum)operator(.)ident(num2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(mode) operator(=) ident(getIOModesIntFromString)operator(()ident(runtime)operator(,) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(ModeFlags) ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(mode)operator(\))operator(;) - - ident(ShellLauncher)operator(.)ident(POpenProcess) ident(process) operator(=) ident(ShellLauncher)operator(.)ident(popen)operator(()ident(runtime)operator(,) ident(cmdObj)operator(,) ident(modes)operator(\))operator(;) - ident(RubyIO) ident(io) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(process)operator(,) ident(modes)operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(io)operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(if) operator(()ident(io)operator(.)ident(openFile)operator(.)ident(isOpen)operator(()operator(\))operator(\)) operator({) - ident(io)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($?)delimiter(")>operator(,) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) operator(()ident(process)operator(.)ident(waitFor)operator(()operator(\)) operator(*) integer(256)operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(io)operator(;) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(ex)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newIOErrorFromException)operator(()ident(e)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(unexpected interrupt)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(// NIO based pipe) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pipe)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(pipe)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) directive(throws) exception(Exception) operator({) - comment(// TODO: This isn't an exact port of MRI's pipe behavior, so revisit) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Pipe) ident(pipe) operator(=) pre_type(Pipe)operator(.)ident(open)operator(()operator(\))operator(;) - - ident(RubyIO) ident(source) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(pipe)operator(.)ident(source)operator(()operator(\))operator(\))operator(;) - ident(RubyIO) ident(sink) operator(=) keyword(new) ident(RubyIO)operator(()ident(runtime)operator(,) ident(pipe)operator(.)ident(sink)operator(()operator(\))operator(\))operator(;) - - ident(sink)operator(.)ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(setSync)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newArrayNoCopy)operator(()keyword(new) ident(IRubyObject)type([]) operator({) ident(source)operator(,) ident(sink) operator(})operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(copy_stream)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(compat) operator(=) ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(copy_stream)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) - ident(IRubyObject) ident(stream1)operator(,) ident(IRubyObject) ident(stream2)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyIO) ident(io1) operator(=) operator(()ident(RubyIO)operator(\))ident(stream1)operator(;) - ident(RubyIO) ident(io2) operator(=) operator(()ident(RubyIO)operator(\))ident(stream2)operator(;) - - ident(ChannelDescriptor) ident(d1) operator(=) ident(io1)operator(.)ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(d1)operator(.)ident(isSeekable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(only supports file-to-file copy)delimiter(")>operator(\))operator(;) - operator(}) - ident(ChannelDescriptor) ident(d2) operator(=) ident(io2)operator(.)ident(openFile)operator(.)ident(getMainStream)operator(()operator(\))operator(.)ident(getDescriptor)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(d2)operator(.)ident(isSeekable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(only supports file-to-file copy)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(FileChannel) ident(f1) operator(=) operator(()pre_type(FileChannel)operator(\))ident(d1)operator(.)ident(getChannel)operator(()operator(\))operator(;) - pre_type(FileChannel) ident(f2) operator(=) operator(()pre_type(FileChannel)operator(\))ident(d2)operator(.)ident(getChannel)operator(()operator(\))operator(;) - - type(long) ident(size) operator(=) ident(f1)operator(.)ident(size)operator(()operator(\))operator(;) - - ident(f1)operator(.)ident(transferTo)operator(()ident(f2)operator(.)ident(position)operator(()operator(\))operator(,) ident(size)operator(,) ident(f2)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(size)operator(\))operator(;) - operator(}) - - comment(/** - * Add a thread to the list of blocking threads for this IO. - * - * @param thread A thread blocking on this IO - */) - directive(public) directive(synchronized) type(void) ident(addBlockingThread)operator(()ident(RubyThread) ident(thread)operator(\)) operator({) - keyword(if) operator(()ident(blockingThreads) operator(==) pre_constant(null)operator(\)) operator({) - ident(blockingThreads) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(RubyThread)operator(>)operator(()integer(1)operator(\))operator(;) - operator(}) - ident(blockingThreads)operator(.)ident(add)operator(()ident(thread)operator(\))operator(;) - operator(}) - - comment(/** - * Remove a thread from the list of blocking threads for this IO. - * - * @param thread A thread blocking on this IO - */) - directive(public) directive(synchronized) type(void) ident(removeBlockingThread)operator(()ident(RubyThread) ident(thread)operator(\)) operator({) - keyword(if) operator(()ident(blockingThreads) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return)operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(blockingThreads)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(blockingThreads)operator(.)ident(get)operator(()ident(i)operator(\)) operator(==) ident(thread)operator(\)) operator({) - comment(// not using remove(Object\) here to avoid the equals(\) call) - ident(blockingThreads)operator(.)ident(remove)operator(()ident(i)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** - * Fire an IOError in all threads blocking on this IO object - */) - directive(protected) directive(synchronized) type(void) ident(interruptBlockingThreads)operator(()operator(\)) operator({) - keyword(if) operator(()ident(blockingThreads) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return)operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(blockingThreads)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyThread) ident(thread) operator(=) ident(blockingThreads)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - - comment(// raise will also wake the thread from selection) - ident(thread)operator(.)ident(raise)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(stream closed)delimiter(")>operator(\))operator(.)ident(getException)operator(()operator(\))operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2005 Thomas E Enebo <enebo@acm.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.PrintWriter)operator(;) -keyword(import) include(java.io.StringWriter)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) - -keyword(import) include(org.jruby.ast.ArgsNode)operator(;) -keyword(import) include(org.jruby.ast.ArgumentNode)operator(;) -keyword(import) include(org.jruby.ast.ListNode)operator(;) -keyword(import) include(org.jruby.ast.LocalAsgnNode)operator(;) -keyword(import) include(org.jruby.javasupport.Java)operator(;) -keyword(import) include(org.jruby.javasupport.JavaObject)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.load.Library)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) - -keyword(import) include(org.jruby.ast.Node)operator(;) -keyword(import) include(org.jruby.compiler.ASTInspector)operator(;) -keyword(import) include(org.jruby.compiler.ASTCompiler)operator(;) -keyword(import) include(org.jruby.compiler.impl.StandardASMCompiler)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.MethodArgs)operator(;) -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.runtime.InterpretedBlock)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) -keyword(import) include(org.objectweb.asm.ClassReader)operator(;) -keyword(import) include(org.objectweb.asm.util.TraceClassVisitor)operator(;) - -comment(/** - * Module which defines JRuby-specific methods for use. - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(JRuby)delimiter(")>operator(\)) -directive(public) type(class) class(RubyJRuby) operator({) - directive(public) directive(static) ident(RubyModule) ident(createJRuby)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(require)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(java)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyModule) ident(jrubyModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(JRuby)delimiter(")>operator(\))operator(;) - - ident(jrubyModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyJRuby)operator(.)ident(class)operator(\))operator(;) - - ident(RubyClass) ident(compiledScriptClass) operator(=) ident(jrubyModule)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(CompiledScript)delimiter(")>operator(,)ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - - ident(compiledScriptClass)operator(.)ident(attr_accessor)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(name)delimiter(")>operator(\))operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(class_name)delimiter(")>operator(\))operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(original_script)delimiter(")>operator(\))operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(code)delimiter(")>operator(\))operator(})operator(\))operator(;) - ident(compiledScriptClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(JRubyCompiledScript)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(jrubyModule)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyModule) ident(createJRubyExt)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(require)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(java)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyModule) ident(mJRubyExt) operator(=) ident(runtime)operator(.)ident(getOrCreateModule)operator(()string<delimiter(")content(JRuby)delimiter(")>operator(\))operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(Extensions)delimiter(")>operator(\))operator(;) - - ident(mJRubyExt)operator(.)ident(defineAnnotatedMethods)operator(()ident(JRubyExtensions)operator(.)ident(class)operator(\))operator(;) - - ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(includeModule)operator(()ident(mJRubyExt)operator(\))operator(;) - - keyword(return) ident(mJRubyExt)operator(;) - operator(}) - - directive(public) directive(static) type(class) class(ExtLibrary) directive(implements) ident(Library) operator({) - directive(public) type(void) ident(load)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(wrap)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyJRuby)operator(.)ident(createJRubyExt)operator(()ident(runtime)operator(\))operator(;) - - ident(runtime)operator(.)ident(getMethod)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(MethodExtensions)operator(.)ident(class)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(TypeLibrary) directive(implements) ident(Library) operator({) - directive(public) type(void) ident(load)operator(()ident(Ruby) ident(runtime)operator(,) type(boolean) ident(wrap)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyModule) ident(jrubyType) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Type)delimiter(")>operator(\))operator(;) - ident(jrubyType)operator(.)ident(defineAnnotatedMethods)operator(()ident(TypeLibrary)operator(.)ident(class)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(coerce_to)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(object)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(method)operator(\)) operator({) - ident(Ruby) ident(ruby) operator(=) ident(object)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(clazz) keyword(instanceof) ident(RubyClass)operator(\))operator(\)) operator({) - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()ident(clazz)operator(,) ident(ruby)operator(.)ident(getClassClass)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)operator(()ident(method) keyword(instanceof) ident(RubySymbol)operator(\))operator(\)) operator({) - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()ident(method)operator(,) ident(ruby)operator(.)ident(getSymbol)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(RubyClass) ident(rubyClass) operator(=) operator(()ident(RubyClass)operator(\))ident(clazz)operator(;) - ident(RubySymbol) ident(methodSym) operator(=) operator(()ident(RubySymbol)operator(\))ident(method)operator(;) - - keyword(return) ident(TypeConverter)operator(.)ident(convertToTypeOrRaise)operator(()ident(object)operator(,) ident(rubyClass)operator(,) ident(methodSym)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(runtime)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(runtime)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(Java)operator(.)ident(java_to_ruby)operator(()ident(recv)operator(,) ident(JavaObject)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(objectspace)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getObjectSpaceEnabled)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(b)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(return) ident(RubyBoolean)operator(.)ident(newBoolean)operator(() - ident(runtime)operator(,) ident(runtime)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(objectspace=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setObjectSpaceEnabled)operator(() - ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(b)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(setObjectSpaceEnabled)operator(()ident(arg)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(parse)delimiter(")>operator(,) string<delimiter(")content(ast_for)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(parse)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if)operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(if)operator(()ident(block)operator(.)ident(getBody)operator(()operator(\)) keyword(instanceof) ident(org)operator(.)ident(jruby)operator(.)ident(runtime)operator(.)ident(CompiledBlock)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Cannot compile an already compiled block. Use -J-Djruby.jit.enabled=false to avoid this problem.)delimiter(")>operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(0)operator(,)integer(0)operator(\))operator(;) - keyword(return) ident(Java)operator(.)ident(java_to_ruby)operator(()ident(recv)operator(,) ident(JavaObject)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(InterpretedBlock)operator(\))ident(block)operator(.)ident(getBody)operator(()operator(\))operator(\))operator(.)ident(getIterNode)operator(()operator(\))operator(.)ident(getBodyNode)operator(()operator(\))operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(1)operator(,)integer(3)operator(\))operator(;) - pre_type(String) ident(filename) operator(=) string<delimiter(")content(-)delimiter(")>operator(;) - type(boolean) ident(extraPositionInformation) operator(=) pre_constant(false)operator(;) - ident(RubyString) ident(content) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length)operator(>)integer(1)operator(\)) operator({) - ident(filename) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length)operator(>)integer(2)operator(\)) operator({) - ident(extraPositionInformation) operator(=) ident(args)operator([)integer(2)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(Java)operator(.)ident(java_to_ruby)operator(()ident(recv)operator(,) ident(JavaObject)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(parse)operator(()ident(content)operator(.)ident(getByteList)operator(()operator(\))operator(,) ident(filename)operator(,) pre_constant(null)operator(,) integer(0)operator(,) ident(extraPositionInformation)operator(\))operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(compile)delimiter(")>operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(compile)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Node) ident(node)operator(;) - pre_type(String) ident(filename)operator(;) - ident(RubyString) ident(content)operator(;) - keyword(if)operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(0)operator(,)integer(0)operator(\))operator(;) - keyword(if)operator(()ident(block)operator(.)ident(getBody)operator(()operator(\)) keyword(instanceof) ident(org)operator(.)ident(jruby)operator(.)ident(runtime)operator(.)ident(CompiledBlock)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Cannot compile an already compiled block. Use -J-Djruby.jit.enabled=false to avoid this problem.)delimiter(")>operator(\))operator(;) - operator(}) - ident(content) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(Node) ident(bnode) operator(=) operator(()operator(()ident(InterpretedBlock)operator(\))ident(block)operator(.)ident(getBody)operator(()operator(\))operator(\))operator(.)ident(getIterNode)operator(()operator(\))operator(.)ident(getBodyNode)operator(()operator(\))operator(;) - ident(node) operator(=) keyword(new) ident(org)operator(.)ident(jruby)operator(.)ident(ast)operator(.)ident(RootNode)operator(()ident(bnode)operator(.)ident(getPosition)operator(()operator(\))operator(,) ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getDynamicScope)operator(()operator(\))operator(,) ident(bnode)operator(\))operator(;) - ident(filename) operator(=) string<delimiter(")content(__block_)delimiter(")> operator(+) ident(node)operator(.)ident(getPosition)operator(()operator(\))operator(.)ident(getFile)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(1)operator(,)integer(3)operator(\))operator(;) - ident(filename) operator(=) string<delimiter(")content(-)delimiter(")>operator(;) - type(boolean) ident(extraPositionInformation) operator(=) pre_constant(false)operator(;) - ident(content) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length)operator(>)integer(1)operator(\)) operator({) - ident(filename) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length)operator(>)integer(2)operator(\)) operator({) - ident(extraPositionInformation) operator(=) ident(args)operator([)integer(2)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - ident(node) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(parse)operator(()ident(content)operator(.)ident(getByteList)operator(()operator(\))operator(,) ident(filename)operator(,) pre_constant(null)operator(,) integer(0)operator(,) ident(extraPositionInformation)operator(\))operator(;) - operator(}) - - pre_type(String) ident(classname)operator(;) - keyword(if) operator(()ident(filename)operator(.)ident(equals)operator(()string<delimiter(")content(-e)delimiter(")>operator(\))operator(\)) operator({) - ident(classname) operator(=) string<delimiter(")content(__dash_e__)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(classname) operator(=) ident(filename)operator(.)ident(replace)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(,) string<delimiter(')content(/)delimiter(')>operator(\))operator(.)ident(replaceAll)operator(()string<delimiter(")content(.rb)delimiter(")>operator(,) string<delimiter(")delimiter(")>operator(\))operator(.)ident(replaceAll)operator(()string<delimiter(")content(-)delimiter(")>operator(,)string<delimiter(")content(_dash_)delimiter(")>operator(\))operator(;) - operator(}) - - ident(ASTInspector) ident(inspector) operator(=) keyword(new) ident(ASTInspector)operator(()operator(\))operator(;) - ident(inspector)operator(.)ident(inspect)operator(()ident(node)operator(\))operator(;) - - ident(StandardASMCompiler) ident(asmCompiler) operator(=) keyword(new) ident(StandardASMCompiler)operator(()ident(classname)operator(,) ident(filename)operator(\))operator(;) - ident(ASTCompiler) ident(compiler) operator(=) keyword(new) ident(ASTCompiler)operator(()operator(\))operator(;) - ident(compiler)operator(.)ident(compileRoot)operator(()ident(node)operator(,) ident(asmCompiler)operator(,) ident(inspector)operator(\))operator(;) - type(byte)type([]) ident(bts) operator(=) ident(asmCompiler)operator(.)ident(getClassByteArray)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(compiledScript) operator(=) operator(()operator(()ident(RubyModule)operator(\))ident(recv)operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(CompiledScript)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - ident(compiledScript)operator(.)ident(callMethod)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(name=)delimiter(")>operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(filename)operator(\))operator(\))operator(;) - ident(compiledScript)operator(.)ident(callMethod)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(class_name=)delimiter(")>operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(classname)operator(\))operator(\))operator(;) - ident(compiledScript)operator(.)ident(callMethod)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(original_script=)delimiter(")>operator(,) ident(content)operator(\))operator(;) - ident(compiledScript)operator(.)ident(callMethod)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(code=)delimiter(")>operator(,) ident(Java)operator(.)ident(java_to_ruby)operator(()ident(recv)operator(,) ident(JavaObject)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(bts)operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(\))operator(;) - - keyword(return) ident(compiledScript)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reference)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(reference)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(Java)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getJavaSupport)operator(()operator(\))operator(.)ident(getJavaUtilitiesModule)operator(()operator(\))operator(,) - ident(JavaObject)operator(.)ident(wrap)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(obj)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dereference)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dereference)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(obj)operator(.)ident(dataGetStruct)operator(()operator(\)) keyword(instanceof) ident(JavaObject)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(got )delimiter(")> operator(+) ident(obj) operator(+) string<delimiter(")content(, expected wrapped Java object)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(Object) ident(unwrapped) operator(=) ident(JavaUtil)operator(.)ident(unwrapJavaObject)operator(()ident(obj)operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(unwrapped) keyword(instanceof) ident(IRubyObject)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(got )delimiter(")> operator(+) ident(obj) operator(+) string<delimiter(")content(, expected Java-wrapped Ruby object)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()ident(IRubyObject)operator(\))ident(unwrapped)operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(JRuby::CompiledScript)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(JRubyCompiledScript) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(compiled_script_to_s)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastGetInstanceVariable)operator(()string<delimiter(")content(@original_script)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(compiled_script_inspect)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(#<JRuby::CompiledScript )delimiter(")> operator(+) ident(recv)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastGetInstanceVariable)operator(()string<delimiter(")content(@name)delimiter(")>operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect_bytecode)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(compiled_script_inspect_bytecode)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - pre_type(StringWriter) ident(sw) operator(=) keyword(new) pre_type(StringWriter)operator(()operator(\))operator(;) - ident(ClassReader) ident(cr) operator(=) keyword(new) ident(ClassReader)operator(()operator(()type(byte)type([])operator(\))ident(org)operator(.)ident(jruby)operator(.)ident(javasupport)operator(.)ident(JavaUtil)operator(.)ident(convertRubyToJava)operator(()ident(recv)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastGetInstanceVariable)operator(()string<delimiter(")content(@code)delimiter(")>operator(\))operator(,)type(byte)type([])operator(.)ident(class)operator(\))operator(\))operator(;) - ident(TraceClassVisitor) ident(cv) operator(=) keyword(new) ident(TraceClassVisitor)operator(()keyword(new) pre_type(PrintWriter)operator(()ident(sw)operator(\))operator(\))operator(;) - ident(cr)operator(.)ident(accept)operator(()ident(cv)operator(,) ident(ClassReader)operator(.)ident(SKIP_DEBUG)operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(sw)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(JRubyExtensions)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(JRubyExtensions) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(steal_method)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(steal_method)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(type)operator(,) ident(IRubyObject) ident(methodName)operator(\)) operator({) - ident(RubyModule) ident(to_add) operator(=) pre_constant(null)operator(;) - keyword(if)operator(()ident(recv) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - ident(to_add) operator(=) operator(()ident(RubyModule)operator(\))ident(recv)operator(;) - operator(}) keyword(else) operator({) - ident(to_add) operator(=) ident(recv)operator(.)ident(getSingletonClass)operator(()operator(\))operator(;) - operator(}) - pre_type(String) ident(name) operator(=) ident(methodName)operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)operator(()ident(type) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(First argument must be a module/class)delimiter(")>operator(\))operator(;) - operator(}) - - ident(DynamicMethod) ident(method) operator(=) operator(()operator(()ident(RubyModule)operator(\))ident(type)operator(\))operator(.)ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if)operator(()ident(method) operator(==) pre_constant(null) operator(||) ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(No such method )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( on )delimiter(")> operator(+) ident(type)operator(\))operator(;) - operator(}) - - ident(to_add)operator(.)ident(addMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(steal_methods)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(steal_methods)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(type) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - keyword(for)operator(()type(int) ident(i)operator(=)integer(1)operator(;)ident(i)operator(<)ident(args)operator(.)ident(length)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(steal_method)operator(()ident(recv)operator(,) ident(type)operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(MethodExtensions) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(args)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(methodArgs)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(ruby) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyMethod) ident(rubyMethod) operator(=) operator(()ident(RubyMethod)operator(\))ident(recv)operator(;) - - ident(DynamicMethod) ident(method) operator(=) ident(rubyMethod)operator(.)ident(method)operator(;) - - keyword(if) operator(()ident(method) keyword(instanceof) ident(MethodArgs)operator(\)) operator({) - ident(MethodArgs) ident(interpMethod) operator(=) operator(()ident(MethodArgs)operator(\))ident(method)operator(;) - ident(ArgsNode) ident(args) operator(=) ident(interpMethod)operator(.)ident(getArgsNode)operator(()operator(\))operator(;) - ident(RubyArray) ident(argsArray) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(ruby)operator(\))operator(;) - - ident(RubyArray) ident(reqArray) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(ruby)operator(\))operator(;) - ident(ListNode) ident(requiredArgs) operator(=) ident(args)operator(.)ident(getArgs)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(requiredArgs) operator(!=) pre_constant(null) operator(&&) ident(i) operator(<) ident(requiredArgs)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(ArgumentNode) ident(arg) operator(=) operator(()ident(ArgumentNode)operator(\))ident(requiredArgs)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - ident(reqArray)operator(.)ident(append)operator(()ident(RubySymbol)operator(.)ident(newSymbol)operator(()ident(ruby)operator(,) ident(arg)operator(.)ident(getName)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(argsArray)operator(.)ident(append)operator(()ident(reqArray)operator(\))operator(;) - - ident(RubyArray) ident(optArray) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(ruby)operator(\))operator(;) - ident(ListNode) ident(optArgs) operator(=) ident(args)operator(.)ident(getOptArgs)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(optArgs) operator(!=) pre_constant(null) operator(&&) ident(i) operator(<) ident(optArgs)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(LocalAsgnNode) ident(arg) operator(=) operator(()ident(LocalAsgnNode)operator(\))ident(optArgs)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - ident(optArray)operator(.)ident(append)operator(()ident(RubySymbol)operator(.)ident(newSymbol)operator(()ident(ruby)operator(,) ident(arg)operator(.)ident(getName)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(argsArray)operator(.)ident(append)operator(()ident(optArray)operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(getRestArgNode)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(argsArray)operator(.)ident(append)operator(()ident(RubySymbol)operator(.)ident(newSymbol)operator(()ident(ruby)operator(,) ident(args)operator(.)ident(getRestArgNode)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(argsArray)operator(.)ident(append)operator(()ident(ruby)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(getBlockArgNode)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(argsArray)operator(.)ident(append)operator(()ident(RubySymbol)operator(.)ident(newSymbol)operator(()ident(ruby)operator(,) ident(args)operator(.)ident(getBlockArgNode)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(argsArray)operator(.)ident(append)operator(()ident(ruby)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(argsArray)operator(;) - operator(}) - - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()string<delimiter(")content(Method args are only available for standard interpreted or jitted methods)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Kiel Hodges <jruby-devel@selfsosoft.com> - * Copyright (C\) 2006 Evan Buswell <evan@heron.sytes.net> - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * Copyright (C\) 2006 Michael Studman <codehaus@michaelstudman.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.ByteArrayOutputStream)operator(;) -keyword(import) include(java.math.BigInteger)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(static) include(org.jruby.anno.FrameField)operator(.)operator(*)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.ast.util.ArgsUtil)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.evaluator.ASTInterpreter)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.exceptions.MainExitException)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.internal.runtime.JumpTarget)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(static) include(org.jruby.runtime.Visibility)operator(.)operator(*)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.load.IAutoloadMethod)operator(;) -keyword(import) include(org.jruby.runtime.load.LoadService)operator(;) -keyword(import) include(org.jruby.util.IdUtil)operator(;) -keyword(import) include(org.jruby.util.ShellLauncher)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) - -comment(/** - * Note: For CVS history, see KernelModule.java. - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Kernel)delimiter(")>operator(\)) -directive(public) type(class) class(RubyKernel) operator({) - directive(public) directive(final) directive(static) pre_type(Class)operator(<)operator(?)operator(>) ident(IRUBY_OBJECT) operator(=) ident(IRubyObject)operator(.)ident(class)operator(;) - - directive(public) directive(static) ident(RubyModule) ident(createKernelModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Kernel)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setKernel)operator(()ident(module)operator(\))operator(;) - - ident(module)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyKernel)operator(.)ident(class)operator(\))operator(;) - ident(module)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyObject)operator(.)ident(class)operator(\))operator(;) - - ident(runtime)operator(.)ident(setRespondToMethod)operator(()ident(module)operator(.)ident(searchMethod)operator(()string<delimiter(")content(respond_to?)delimiter(")>operator(\))operator(\))operator(;) - - ident(module)operator(.)ident(setFlag)operator(()ident(RubyObject)operator(.)ident(USER7_F)operator(,) pre_constant(false)operator(\))operator(;) comment(//Kernel is the only Module that doesn't need an implementor) - - keyword(return) ident(module)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(at_exit)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(at_exit)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(pushExitBlock)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(,) ident(block)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(autoload?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(autoload_p)operator(()ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyModule) ident(module) operator(=) ident(recv) keyword(instanceof) ident(RubyModule) operator(?) operator(()ident(RubyModule)operator(\)) ident(recv) operator(:) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) ident(module)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - - ident(IAutoloadMethod) ident(autoloadMethod) operator(=) ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoloadFor)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(autoloadMethod) operator(==) pre_constant(null)operator(\)) keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(autoloadMethod)operator(.)ident(file)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(autoload)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(autoload)operator(()directive(final) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(symbol)operator(,) directive(final) ident(IRubyObject) ident(file)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(LoadService) ident(loadService) operator(=) ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(;) - pre_type(String) ident(nonInternedName) operator(=) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(IdUtil)operator(.)ident(isValidConstantName)operator(()ident(nonInternedName)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(autoload must be constant name)delimiter(")>operator(,) ident(nonInternedName)operator(\))operator(;) - operator(}) - - ident(RubyString) ident(fileString) operator(=) ident(file)operator(.)ident(convertToString)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(fileString)operator(.)ident(isEmpty)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(empty file name)delimiter(")>operator(\))operator(;) - operator(}) - - directive(final) pre_type(String) ident(baseName) operator(=) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) comment(// interned, OK for "fast" methods) - directive(final) ident(RubyModule) ident(module) operator(=) ident(recv) keyword(instanceof) ident(RubyModule) operator(?) operator(()ident(RubyModule)operator(\)) ident(recv) operator(:) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - pre_type(String) ident(nm) operator(=) ident(module)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(baseName)operator(;) - - ident(IRubyObject) ident(existingValue) operator(=) ident(module)operator(.)ident(fastFetchConstant)operator(()ident(baseName)operator(\))operator(;) - keyword(if) operator(()ident(existingValue) operator(!=) pre_constant(null) operator(&&) ident(existingValue) operator(!=) ident(RubyObject)operator(.)ident(UNDEF)operator(\)) keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(module)operator(.)ident(fastStoreConstant)operator(()ident(baseName)operator(,) ident(RubyObject)operator(.)ident(UNDEF)operator(\))operator(;) - - ident(loadService)operator(.)ident(addAutoload)operator(()ident(nm)operator(,) keyword(new) ident(IAutoloadMethod)operator(()operator(\)) operator({) - directive(public) pre_type(String) ident(file)operator(()operator(\)) operator({) - keyword(return) ident(file)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - comment(/** - * @see org.jruby.runtime.load.IAutoloadMethod#load(Ruby, String\) - */) - directive(public) ident(IRubyObject) ident(load)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - type(boolean) ident(required) operator(=) ident(loadService)operator(.)ident(require)operator(()ident(file)operator(()operator(\))operator(\))operator(;) - - comment(// File to be loaded by autoload has already been or is being loaded.) - keyword(if) operator(()operator(!)ident(required)operator(\)) keyword(return) pre_constant(null)operator(;) - - keyword(return) ident(module)operator(.)ident(fastGetConstant)operator(()ident(baseName)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method_missing)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(method_missing)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0) operator(||) operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubySymbol)operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no id given)delimiter(")>operator(\))operator(;) - - pre_type(Visibility) ident(lastVis) operator(=) ident(context)operator(.)ident(getLastVisibility)operator(()operator(\))operator(;) - ident(CallType) ident(lastCallType) operator(=) ident(context)operator(.)ident(getLastCallType)operator(()operator(\))operator(;) - - comment(// create a lightweight thunk) - ident(IRubyObject) ident(msg) operator(=) keyword(new) ident(RubyNameError)operator(.)ident(RubyNameErrorMessage)operator(()ident(runtime)operator(,) - ident(recv)operator(,) - ident(args)operator([)integer(0)operator(])operator(,) - ident(lastVis)operator(,) - ident(lastCallType)operator(\))operator(;) - directive(final) ident(IRubyObject)type([])ident(exArgs)operator(;) - directive(final) ident(RubyClass) ident(exc)operator(;) - keyword(if) operator(()ident(lastCallType) operator(!=) ident(CallType)operator(.)ident(VARIABLE)operator(\)) operator({) - ident(exc) operator(=) ident(runtime)operator(.)ident(getNoMethodError)operator(()operator(\))operator(;) - ident(exArgs) operator(=) keyword(new) ident(IRubyObject)type([])operator({)ident(msg)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(RubyArray)operator(.)ident(newArrayNoCopy)operator(()ident(runtime)operator(,) ident(args)operator(,) integer(1)operator(\))operator(})operator(;) - operator(}) keyword(else) operator({) - ident(exc) operator(=) ident(runtime)operator(.)ident(getNameError)operator(()operator(\))operator(;) - ident(exArgs) operator(=) keyword(new) ident(IRubyObject)type([])operator({)ident(msg)operator(,) ident(args)operator([)integer(0)operator(])operator(})operator(;) - operator(}) - - keyword(throw) keyword(new) ident(RaiseException)operator(()operator(()ident(RubyException)operator(\))ident(exc)operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(exArgs)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(arg) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(arg)operator(.)ident(startsWith)operator(()string<delimiter(")content(|)delimiter(")>operator(\))operator(\)) operator({) - pre_type(String) ident(command) operator(=) ident(arg)operator(.)ident(substring)operator(()integer(1)operator(\))operator(;) - comment(// exec process, create IO with process) - keyword(return) ident(RubyIO)operator(.)ident(popen)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getIO)operator(()operator(\))operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(runtime)operator(.)ident(newString)operator(()ident(command)operator(\))operator(})operator(,) ident(block)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyFile)operator(.)ident(open)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getc)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(getc is obsolete; use STDIN.getc instead)delimiter(")>operator(,) string<delimiter(")content(getc)delimiter(")>operator(,) string<delimiter(")content(STDIN.getc)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(defin) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stdin)delimiter(")>operator(\))operator(;) - keyword(return) ident(defin)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(getc)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gets)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyArgsFile)operator(.)ident(gets)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($<)delimiter(")>operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(abort)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stderr)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(puts)delimiter(")>operator(,)ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - keyword(throw) keyword(new) ident(MainExitException)operator(()integer(1)operator(,)pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Array)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_array)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - ident(IRubyObject) ident(value) operator(=) ident(object)operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(value)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(object)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(searchMethod)operator(()string<delimiter(")content(to_a)delimiter(")>operator(\))operator(.)ident(getImplementationClass)operator(()operator(\)) operator(!=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getKernel)operator(()operator(\))operator(\)) operator({) - ident(value) operator(=) ident(object)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_A)operator(,) string<delimiter(")content(to_a)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(value) keyword(instanceof) ident(RubyArray)operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(`to_a' did not return Array)delimiter(")>operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(object)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Complex)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_complex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Complex)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_complex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(,) ident(arg)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Complex)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_complex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getComplex)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Rational)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_rational)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRational)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Rational)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_rational)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRational)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(,) ident(arg)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Rational)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_rational)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRational)operator(()operator(\))operator(,) string<delimiter(")content(convert)delimiter(")>operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Float)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_float)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(if)operator(()ident(object) keyword(instanceof) ident(RubyFixnum)operator(\))operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(object)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(object)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(})keyword(else) keyword(if)operator(()ident(object) keyword(instanceof) ident(RubyFloat)operator(\))operator({) - keyword(return) ident(object)operator(;) - operator(})keyword(else) keyword(if)operator(()ident(object) keyword(instanceof) ident(RubyBignum)operator(\))operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(object)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(RubyBignum)operator(.)ident(big2dbl)operator(()operator(()ident(RubyBignum)operator(\))ident(object)operator(\))operator(\))operator(;) - operator(})keyword(else) keyword(if)operator(()ident(object) keyword(instanceof) ident(RubyString)operator(\))operator({) - keyword(if)operator(()operator(()operator(()ident(RubyString)operator(\))ident(object)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(==) integer(0)operator(\))operator({) comment(// rb_cstr_to_dbl case) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Float(\): )delimiter(")> operator(+) ident(object)operator(.)ident(inspect)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyNumeric)operator(.)ident(str2fnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)operator(()ident(RubyString)operator(\))ident(object)operator(,)pre_constant(true)operator(\))operator(;) - operator(})keyword(else) keyword(if)operator(()ident(object)operator(.)ident(isNil)operator(()operator(\))operator(\))operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert nil into Float)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyFloat) ident(rFloat) operator(=) operator(()ident(RubyFloat)operator(\))ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(object)operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFloat)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_F)operator(,) string<delimiter(")content(to_f)delimiter(")>operator(\))operator(;) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(rFloat)operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(\)) keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Float(\))delimiter(")>operator(\))operator(;) - keyword(return) ident(rFloat)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(Integer)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_integer)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(val) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(object)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(val) operator(>) operator(()type(double)operator(\)) ident(RubyFixnum)operator(.)ident(MAX) operator(&&) ident(val) operator(<) operator(()type(double)operator(\)) ident(RubyFixnum)operator(.)ident(MIN)operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(dbl2num)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,)operator(()operator(()ident(RubyFloat)operator(\))ident(object)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyFixnum) operator(||) ident(object) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(object)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,)operator(()ident(RubyString)operator(\))ident(object)operator(,)integer(0)operator(,)pre_constant(true)operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(tmp) operator(=) ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(object)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getInteger)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_INT)operator(,) string<delimiter(")content(to_int)delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(object)operator(.)ident(convertToInteger)operator(()ident(MethodIndex)operator(.)ident(TO_I)operator(,) string<delimiter(")content(to_i)delimiter(")>operator(\))operator(;) - keyword(return) ident(tmp)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(String)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(new_string)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(return) ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(object)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(p)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(defout) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)ident(i)operator(]) operator(!=) pre_constant(null)operator(\)) operator({) - ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyObject)operator(.)ident(inspect)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(defout) keyword(instanceof) ident(RubyFile)operator(\)) operator({) - operator(()operator(()ident(RubyFile)operator(\))ident(defout)operator(\))operator(.)ident(flush)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_f_putc - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(putc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(putc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(ch)operator(\)) operator({) - ident(IRubyObject) ident(defout) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\))operator(;) - keyword(return) ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(putc)delimiter(")>operator(,) ident(ch)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(puts)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(puts)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(defout) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\))operator(;) - - ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(puts)delimiter(")>operator(,) ident(args)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(print)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(print)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(defout) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\))operator(;) - - ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(print)delimiter(")>operator(,) ident(args)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(printf)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(printf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(defout) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - ident(defout) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(args) operator(=) ident(ArgsUtil)operator(.)ident(popArray)operator(()ident(args)operator(\))operator(;) - operator(}) - - ident(defout)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyKernel)operator(.)ident(sprintf)operator(()ident(recv)operator(,) ident(args)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readline)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(readline)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(line)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(readlines)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyArgsFile)operator(.)ident(readlines)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($<)delimiter(")>operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** Returns value of $_. - * - * @throws TypeError if $_ is not a String or nil. - * @return value of $_ as String. - */) - directive(private) directive(static) ident(RubyString) ident(getLastlineString)operator(()ident(ThreadContext) ident(context)operator(,) ident(Ruby) ident(runtime)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(getLastLine)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content($_ value need to be String (nil given\).)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)operator(()ident(line) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content($_ value need to be String ()delimiter(")> operator(+) ident(line)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( given\).)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) operator(()ident(RubyString)operator(\)) ident(line)operator(;) - operator(}) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(gsub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chop!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chop_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(chop_bang)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chop)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chop)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(>) integer(0)operator(\)) operator({) - ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(str)operator(.)ident(dup)operator(()operator(\))operator(;) - ident(str)operator(.)ident(chop_bang)operator(()operator(\))operator(;) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(str)operator(\))operator(;) - operator(}) - - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(chomp_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(chomp_bang)operator(()ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chomp_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(chomp_bang)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chomp_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(chomp_bang)operator(()ident(arg0)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one-arg versions. - */) - directive(public) directive(static) ident(IRubyObject) ident(chomp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(dup) operator(=) operator(()ident(RubyString)operator(\)) ident(str)operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(dup)operator(.)ident(chomp_bang)operator(()ident(args)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(dup)operator(\))operator(;) - keyword(return) ident(dup)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chomp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(dup) operator(=) operator(()ident(RubyString)operator(\)) ident(str)operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(dup)operator(.)ident(chomp_bang)operator(()operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(dup)operator(\))operator(;) - keyword(return) ident(dup)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) ident(LASTLINE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(chomp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(dup) operator(=) operator(()ident(RubyString)operator(\)) ident(str)operator(.)ident(dup)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(dup)operator(.)ident(chomp_bang)operator(()ident(arg0)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(dup)operator(\))operator(;) - keyword(return) ident(dup)operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * - * @param context The thread context for the current thread - * @param recv The receiver of the method (usually a class that has included Kernel\) - * @return - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) directive(static) ident(IRubyObject) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(split)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(split)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(split)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(split)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(split)operator(()ident(context)operator(,) ident(arg0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(split)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(LASTLINE)operator(,) ident(writes) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(split)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scan)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(,) ident(writes) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(scan)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(pattern)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getLastlineString)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(scan)operator(()ident(context)operator(,) ident(pattern)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(select)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(3)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyIO)operator(.)ident(select_static)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sleep)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sleep)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(long) ident(milliseconds)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - comment(// Zero sleeps forever) - ident(milliseconds) operator(=) integer(0)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyNumeric)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(args)operator([)integer(0)operator(])operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(into time interval)delimiter(")>operator(\))operator(;) - operator(}) - ident(milliseconds) operator(=) operator(()type(long)operator(\)) operator(()ident(args)operator([)integer(0)operator(])operator(.)ident(convertToFloat)operator(()operator(\))operator(.)ident(getDoubleValue)operator(()operator(\)) operator(*) integer(1000)operator(\))operator(;) - keyword(if) operator(()ident(milliseconds) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(time interval must be positive)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(milliseconds) operator(==) integer(0)operator(\)) operator({) - comment(// Explicit zero in MRI returns immediately) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - operator(}) - operator(}) - type(long) ident(startTime) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - - ident(RubyThread) ident(rubyThread) operator(=) ident(context)operator(.)ident(getThread)operator(()operator(\))operator(;) - - keyword(do) operator({) - type(long) ident(loopStartTime) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(rubyThread)operator(.)ident(sleep)operator(()ident(milliseconds)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(iExcptn)operator(\)) operator({) - operator(}) - ident(milliseconds) operator(-=) operator(()pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(-) ident(loopStartTime)operator(\))operator(;) - operator(}) keyword(while) operator(()ident(milliseconds) operator(>) integer(0)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()pre_type(Math)operator(.)ident(round)operator(()operator(()pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(-) ident(startTime)operator(\)) operator(/) float(1000.0)operator(\))operator(\))operator(;) - operator(}) - - comment(// FIXME: Add at_exit and finalizers to exit, then make exit_bang not call those.) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exit)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(exit)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) pre_constant(false)operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) comment(// not reached) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit!)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exit_bang)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(exit)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) comment(// not reached) - operator(}) - - directive(private) directive(static) type(void) ident(exit)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) type(boolean) ident(hard)operator(\)) operator({) - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - - type(int) ident(status) operator(=) integer(1)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(RubyObject) ident(argument) operator(=) operator(()ident(RubyObject)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - keyword(if) operator(()ident(argument) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(status) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(argument)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(status) operator(=) ident(argument)operator(.)ident(isFalse)operator(()operator(\)) operator(?) integer(1) operator(:) integer(0)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(hard)operator(\)) operator({) - keyword(throw) keyword(new) ident(MainExitException)operator(()ident(status)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSystemExit)operator(()ident(status)operator(\))operator(;) - operator(}) - operator(}) - - - comment(/** Returns an Array with the names of all global variables. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(global_variables)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(global_variables)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(globalVariables) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()pre_type(String) ident(globalVariableName) operator(:) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(getNames)operator(()operator(\))operator(\)) operator({) - ident(globalVariables)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(globalVariableName)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(globalVariables)operator(;) - operator(}) - - comment(/** Returns an Array with the names of all local variables. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(local_variables)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(local_variables)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(localVariables) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()pre_type(String) ident(name)operator(:) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(.)ident(getAllNamesInScope)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isLocal)operator(()ident(name)operator(\))operator(\)) ident(localVariables)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(localVariables)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(binding)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyBinding) ident(binding)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RubyBinding)operator(.)ident(newBinding)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(block_given?)delimiter(")>operator(,) string<delimiter(")content(iterator?)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(block_given_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(getBlock)operator(()operator(\))operator(.)ident(isGiven)operator(()operator(\))operator(\))operator(;) - operator(}) - - - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(sprintf)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(sprintf)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(sprintf)delimiter(")>operator(,) string<delimiter(")content(format)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sprintf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(sprintf must have at least one argument)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyString) ident(str) operator(=) ident(RubyString)operator(.)ident(stringValue)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - - ident(RubyArray) ident(newArgs) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()ident(args)operator(\))operator(;) - ident(newArgs)operator(.)ident(shift)operator(()operator(\))operator(;) - - keyword(return) ident(str)operator(.)ident(op_format)operator(()ident(context)operator(,) ident(newArgs)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(raise)delimiter(")>operator(,) string<delimiter(")content(fail)delimiter(")>operator(})operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(raise)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - comment(// FIXME: Pass block down?) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(lastException) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($!)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(lastException)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) keyword(new) ident(RaiseException)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRuntimeError)operator(()operator(\))operator(,) string<delimiter(")delimiter(")>operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - keyword(throw) keyword(new) ident(RaiseException)operator(()operator(()ident(RubyException)operator(\)) ident(lastException)operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(exception)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(throw) keyword(new) ident(RaiseException)operator(()operator(()ident(RubyException)operator(\))ident(runtime)operator(.)ident(getRuntimeError)operator(()operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(respondsTo)operator(()string<delimiter(")content(exception)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception class/object expected)delimiter(")>operator(\))operator(;) - operator(}) - ident(exception) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(exception)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(respondsTo)operator(()string<delimiter(")content(exception)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception class/object expected)delimiter(")>operator(\))operator(;) - operator(}) - - ident(exception) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(exception)delimiter(")>operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Exception)delimiter(")>operator(\))operator(.)ident(isInstance)operator(()ident(exception)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception object expected)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(3)operator(\)) operator({) - operator(()operator(()ident(RubyException)operator(\)) ident(exception)operator(\))operator(.)ident(set_backtrace)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(runtime)operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(printExceptionSummary)operator(()ident(context)operator(,) ident(runtime)operator(,) operator(()ident(RubyException)operator(\)) ident(exception)operator(\))operator(;) - operator(}) - - keyword(throw) keyword(new) ident(RaiseException)operator(()operator(()ident(RubyException)operator(\)) ident(exception)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(printExceptionSummary)operator(()ident(ThreadContext) ident(context)operator(,) ident(Ruby) ident(runtime)operator(,) ident(RubyException) ident(rEx)operator(\)) operator({) - pre_type(Frame) ident(currentFrame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - - pre_type(String) ident(msg) operator(=) pre_type(String)operator(.)ident(format)operator(()string<delimiter(")content(Exception `%s' at %s:%s - %s)char(\\n)delimiter(")>operator(,) - ident(rEx)operator(.)ident(getMetaClass)operator(()operator(\))operator(,) - ident(currentFrame)operator(.)ident(getFile)operator(()operator(\))operator(,) ident(currentFrame)operator(.)ident(getLine)operator(()operator(\)) operator(+) integer(1)operator(,) - ident(rEx)operator(.)ident(to_s)operator(()operator(\))operator(\))operator(;) - - ident(IRubyObject) ident(errorStream) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stderr)delimiter(")>operator(\))operator(;) - ident(errorStream)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()ident(msg)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Require. - * MRI allows to require ever .rb files or ruby extension dll (.so or .dll depending on system\). - * we allow requiring either .rb files or jars. - * @param recv ruby object used to call require (any object will do and it won't be used anyway\). - * @param name the name of the file to require - **/) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(require)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(require)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(name)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()ident(name)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(load)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyString) ident(file) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - type(boolean) ident(wrap) operator(=) ident(args)operator(.)ident(length) operator(==) integer(2) operator(?) ident(args)operator([)integer(1)operator(])operator(.)ident(isTrue)operator(()operator(\)) operator(:) pre_constant(false)operator(;) - - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(load)operator(()ident(file)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) ident(wrap)operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eval)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - comment(// string to eval) - ident(RubyString) ident(src) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(checkSafeString)operator(()ident(src)operator(\))operator(;) - - ident(IRubyObject) ident(scope) operator(=) ident(args)operator(.)ident(length) operator(>) integer(1) operator(&&) operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) pre_constant(null)operator(;) - pre_type(String) ident(file)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) operator({) - ident(file) operator(=) ident(args)operator([)integer(2)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(scope) operator(==) pre_constant(null)operator(\)) operator({) - ident(file) operator(=) string<delimiter(")content((eval\))delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(file) operator(=) pre_constant(null)operator(;) - operator(}) - type(int) ident(line)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(3)operator(\)) operator({) - ident(line) operator(=) operator(()type(int)operator(\)) ident(args)operator([)integer(3)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(scope) operator(==) pre_constant(null)operator(\)) operator({) - ident(line) operator(=) integer(0)operator(;) - operator(}) keyword(else) operator({) - ident(line) operator(=) operator(-)integer(1)operator(;) - operator(}) - keyword(if) operator(()ident(scope) operator(==) pre_constant(null)operator(\)) ident(scope) operator(=) ident(RubyBinding)operator(.)ident(newBindingForEval)operator(()ident(context)operator(\))operator(;) - - keyword(return) ident(ASTInterpreter)operator(.)ident(evalWithBinding)operator(()ident(context)operator(,) ident(src)operator(,) ident(scope)operator(,) ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(callcc)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(callcc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(EMPTY_IMPLEMENTATION)operator(,) string<delimiter(")content(Kernel#callcc: Continuations are not implemented in JRuby and will not work)delimiter(")>operator(,) string<delimiter(")content(Kernel#callcc)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(cc) operator(=) ident(runtime)operator(.)ident(getContinuation)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - ident(cc)operator(.)ident(dataWrapStruct)operator(()ident(block)operator(\))operator(;) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(cc)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(caller)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(caller)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int) ident(level) operator(=) ident(args)operator(.)ident(length) operator(>) integer(0) operator(?) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\)) operator(:) integer(1)operator(;) - - keyword(if) operator(()ident(level) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative level()delimiter(")> operator(+) ident(level) operator(+) string<delimiter(')content(\))delimiter(')>operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(createCallerBacktrace)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(level)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(catch)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rbCatch)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(tag)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(CatchTarget) ident(target) operator(=) keyword(new) ident(CatchTarget)operator(()ident(tag)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - keyword(try) operator({) - ident(context)operator(.)ident(pushCatch)operator(()ident(target)operator(\))operator(;) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(tag)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ThrowJump) ident(tj)operator(\)) operator({) - keyword(if) operator(()ident(tj)operator(.)ident(getTarget)operator(()operator(\)) operator(==) ident(target)operator(\)) keyword(return) operator(()ident(IRubyObject)operator(\)) ident(tj)operator(.)ident(getValue)operator(()operator(\))operator(;) - - keyword(throw) ident(tj)operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(popCatch)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(CatchTarget) directive(implements) ident(JumpTarget) operator({) - directive(private) directive(final) pre_type(String) ident(tag)operator(;) - directive(public) ident(CatchTarget)operator(()pre_type(String) ident(tag)operator(\)) operator({) local_variable(this)operator(.)ident(tag) operator(=) ident(tag)operator(;) operator(}) - directive(public) pre_type(String) ident(getTag)operator(()operator(\)) operator({) keyword(return) ident(tag)operator(;) operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(throw)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rbThrow)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - pre_type(String) ident(tag) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(;) - ident(CatchTarget)type([]) ident(catches) operator(=) ident(context)operator(.)ident(getActiveCatches)operator(()operator(\))operator(;) - - pre_type(String) ident(message) operator(=) string<delimiter(")content(uncaught throw `)delimiter(")> operator(+) ident(tag) operator(+) string<delimiter(")content(')delimiter(")>operator(;) - - comment(// Ordering of array traversal not important, just intuitive) - keyword(for) operator(()type(int) ident(i) operator(=) ident(catches)operator(.)ident(length) operator(-) integer(1) operator(;) ident(i) operator(>=) integer(0) operator(;) ident(i)operator(--)operator(\)) operator({) - keyword(if) operator(()ident(tag)operator(.)ident(equals)operator(()ident(catches)operator([)ident(i)operator(])operator(.)ident(getTag)operator(()operator(\))operator(\))operator(\)) operator({) - comment(//Catch active, throw for catch to handle) - keyword(throw) keyword(new) ident(JumpException)operator(.)ident(ThrowJump)operator(()ident(catches)operator([)ident(i)operator(])operator(,) ident(args)operator(.)ident(length) operator(>) integer(1) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(// No catch active for this throw) - ident(RubyThread) ident(currentThread) operator(=) ident(context)operator(.)ident(getThread)operator(()operator(\))operator(;) - keyword(if) operator(()ident(currentThread) operator(==) ident(runtime)operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getMainThread)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()ident(message)operator(,) ident(tag)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()ident(message) operator(+) string<delimiter(")content( in thread 0x)delimiter(")> operator(+) pre_type(Integer)operator(.)ident(toHexString)operator(()ident(RubyInteger)operator(.)ident(fix2int)operator(()ident(currentThread)operator(.)ident(id)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(trap)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(trap)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(jsignal)delimiter(")>operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(recv)operator(,) string<delimiter(")content(__jtrap)delimiter(")>operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(warn)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(warn)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(message)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(runtime)operator(.)ident(getVerbose)operator(()operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(out) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($stderr)delimiter(")>operator(\))operator(;) - ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(out)operator(,) string<delimiter(")content(puts)delimiter(")>operator(,) ident(message)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(set_trace_func)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(set_trace_func)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(trace_func)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(trace_func)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setTraceFunction)operator(()pre_constant(null)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)operator(()ident(trace_func) keyword(instanceof) ident(RubyProc)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(trace_func needs to be Proc.)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setTraceFunction)operator(()operator(()ident(RubyProc)operator(\)) ident(trace_func)operator(\))operator(;) - operator(}) - keyword(return) ident(trace_func)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(trace_var)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(trace_var)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - ident(RubyProc) ident(proc) operator(=) pre_constant(null)operator(;) - pre_type(String) ident(var) operator(=) ident(args)operator(.)ident(length) operator(>) integer(1) operator(?) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\)) operator(:) pre_constant(null)operator(;) - comment(// ignore if it's not a global var) - keyword(if) operator(()ident(var)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(!=) string<delimiter(')content($)delimiter(')>operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) ident(proc) operator(=) ident(RubyProc)operator(.)ident(newProc)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(block)operator(,) ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2)operator(\)) operator({) - ident(proc) operator(=) operator(()ident(RubyProc)operator(\))ident(TypeConverter)operator(.)ident(convertToType)operator(()ident(args)operator([)integer(1)operator(])operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getProc)operator(()operator(\))operator(,) integer(0)operator(,) string<delimiter(")content(to_proc)delimiter(")>operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(setTraceVar)operator(()ident(var)operator(,) ident(proc)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(untrace_var)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(untrace_var)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - pre_type(String) ident(var) operator(=) ident(args)operator(.)ident(length) operator(>=) integer(1) operator(?) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\)) operator(:) pre_constant(null)operator(;) - - comment(// ignore if it's not a global var) - keyword(if) operator(()ident(var)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(!=) string<delimiter(')content($)delimiter(')>operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>) ident(success) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(untraceVar)operator(()ident(var)operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(\)) operator({) - ident(success)operator(.)ident(add)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(success)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(untraceVar)operator(()ident(var)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(singleton_method_added)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(singleton_method_added)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(symbolId)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(singleton_method_removed)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(singleton_method_removed)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(symbolId)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(singleton_method_undefined)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(singleton_method_undefined)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(symbolId)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(proc)delimiter(")>operator(,) string<delimiter(")content(lambda)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(\)) - directive(public) directive(static) ident(RubyProc) ident(proc)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) ident(RubyProc) ident(proc)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(lambda)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(RubyProc) ident(lambda)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(proc)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(RubyProc) ident(proc_1_9)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(loop)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(loop)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - - ident(context)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(test)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(test)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - - type(int) ident(cmd)operator(;) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(cmd) operator(=) operator(()type(int)operator(\))operator(()operator(()ident(RubyFixnum)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString) operator(&&) - operator(()operator(()ident(RubyString)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - comment(// MRI behavior: use first byte of string value if len > 0) - ident(cmd) operator(=) operator(()operator(()ident(RubyString)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(charAt)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(cmd) operator(=) operator(()type(int)operator(\)) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - - comment(// MRI behavior: raise ArgumentError for 'unknown command' before) - comment(// checking number of args.) - keyword(switch)operator(()ident(cmd)operator(\)) operator({) - keyword(case) string<delimiter(')content(A)delimiter(')>operator(:) keyword(case) string<delimiter(')content(b)delimiter(')>operator(:) keyword(case) string<delimiter(')content(c)delimiter(')>operator(:) keyword(case) string<delimiter(')content(C)delimiter(')>operator(:) keyword(case) string<delimiter(')content(d)delimiter(')>operator(:) keyword(case) string<delimiter(')content(e)delimiter(')>operator(:) keyword(case) string<delimiter(')content(f)delimiter(')>operator(:) keyword(case) string<delimiter(')content(g)delimiter(')>operator(:) keyword(case) string<delimiter(')content(G)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(k)delimiter(')>operator(:) keyword(case) string<delimiter(')content(M)delimiter(')>operator(:) keyword(case) string<delimiter(')content(l)delimiter(')>operator(:) keyword(case) string<delimiter(')content(o)delimiter(')>operator(:) keyword(case) string<delimiter(')content(O)delimiter(')>operator(:) keyword(case) string<delimiter(')content(p)delimiter(')>operator(:) keyword(case) string<delimiter(')content(r)delimiter(')>operator(:) keyword(case) string<delimiter(')content(R)delimiter(')>operator(:) keyword(case) string<delimiter(')content(s)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(S)delimiter(')>operator(:) keyword(case) string<delimiter(')content(u)delimiter(')>operator(:) keyword(case) string<delimiter(')content(w)delimiter(')>operator(:) keyword(case) string<delimiter(')content(W)delimiter(')>operator(:) keyword(case) string<delimiter(')content(x)delimiter(')>operator(:) keyword(case) string<delimiter(')content(X)delimiter(')>operator(:) keyword(case) string<delimiter(')content(z)delimiter(')>operator(:) keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(default)operator(:) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(unknown command ?)delimiter(")> operator(+) operator(()type(char)operator(\)) ident(cmd)operator(\))operator(;) - operator(}) - - comment(// MRI behavior: now check arg count) - - keyword(switch)operator(()ident(cmd)operator(\)) operator({) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(3)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(3)operator(\))operator(;) - keyword(break)operator(;) - keyword(default)operator(:) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(2)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(2)operator(\))operator(;) - keyword(break)operator(;) - operator(}) - - keyword(switch) operator(()ident(cmd)operator(\)) operator({) - keyword(case) string<delimiter(')content(A)delimiter(')>operator(:) comment(// ?A | Time | Last access time for file1) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(atime)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(b)delimiter(')>operator(:) comment(// ?b | boolean | True if file1 is a block device) - keyword(return) ident(RubyFileTest)operator(.)ident(blockdev_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(c)delimiter(')>operator(:) comment(// ?c | boolean | True if file1 is a character device) - keyword(return) ident(RubyFileTest)operator(.)ident(chardev_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(C)delimiter(')>operator(:) comment(// ?C | Time | Last change time for file1) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(ctime)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(d)delimiter(')>operator(:) comment(// ?d | boolean | True if file1 exists and is a directory) - keyword(return) ident(RubyFileTest)operator(.)ident(directory_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(e)delimiter(')>operator(:) comment(// ?e | boolean | True if file1 exists) - keyword(return) ident(RubyFileTest)operator(.)ident(exist_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(f)delimiter(')>operator(:) comment(// ?f | boolean | True if file1 exists and is a regular file) - keyword(return) ident(RubyFileTest)operator(.)ident(file_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(g)delimiter(')>operator(:) comment(// ?g | boolean | True if file1 has the \\CF{setgid} bit) - keyword(return) ident(RubyFileTest)operator(.)ident(setgid_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(G)delimiter(')>operator(:) comment(// ?G | boolean | True if file1 exists and has a group ownership equal to the caller's group) - keyword(return) ident(RubyFileTest)operator(.)ident(grpowned_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(k)delimiter(')>operator(:) comment(// ?k | boolean | True if file1 exists and has the sticky bit set) - keyword(return) ident(RubyFileTest)operator(.)ident(sticky_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(M)delimiter(')>operator(:) comment(// ?M | Time | Last modification time for file1) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(mtime)operator(()operator(\))operator(;) - keyword(case) string<delimiter(')content(l)delimiter(')>operator(:) comment(// ?l | boolean | True if file1 exists and is a symbolic link) - keyword(return) ident(RubyFileTest)operator(.)ident(symlink_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(o)delimiter(')>operator(:) comment(// ?o | boolean | True if file1 exists and is owned by the caller's effective uid) - keyword(return) ident(RubyFileTest)operator(.)ident(owned_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(O)delimiter(')>operator(:) comment(// ?O | boolean | True if file1 exists and is owned by the caller's real uid ) - keyword(return) ident(RubyFileTest)operator(.)ident(rowned_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(p)delimiter(')>operator(:) comment(// ?p | boolean | True if file1 exists and is a fifo) - keyword(return) ident(RubyFileTest)operator(.)ident(pipe_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(r)delimiter(')>operator(:) comment(// ?r | boolean | True if file1 is readable by the effective uid/gid of the caller) - keyword(return) ident(RubyFileTest)operator(.)ident(readable_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(R)delimiter(')>operator(:) comment(// ?R | boolean | True if file is readable by the real uid/gid of the caller) - comment(// FIXME: Need to implement an readable_real_p in FileTest) - keyword(return) ident(RubyFileTest)operator(.)ident(readable_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(s)delimiter(')>operator(:) comment(// ?s | int/nil | If file1 has nonzero size, return the size, otherwise nil) - keyword(return) ident(RubyFileTest)operator(.)ident(size_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(S)delimiter(')>operator(:) comment(// ?S | boolean | True if file1 exists and is a socket) - keyword(return) ident(RubyFileTest)operator(.)ident(socket_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(u)delimiter(')>operator(:) comment(// ?u | boolean | True if file1 has the setuid bit set) - keyword(return) ident(RubyFileTest)operator(.)ident(setuid_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(w)delimiter(')>operator(:) comment(// ?w | boolean | True if file1 exists and is writable by effective uid/gid) - keyword(return) ident(RubyFileTest)operator(.)ident(writable_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(W)delimiter(')>operator(:) comment(// ?W | boolean | True if file1 exists and is writable by the real uid/gid) - comment(// FIXME: Need to implement an writable_real_p in FileTest) - keyword(return) ident(RubyFileTest)operator(.)ident(writable_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(x)delimiter(')>operator(:) comment(// ?x | boolean | True if file1 exists and is executable by the effective uid/gid) - keyword(return) ident(RubyFileTest)operator(.)ident(executable_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(X)delimiter(')>operator(:) comment(// ?X | boolean | True if file1 exists and is executable by the real uid/gid) - keyword(return) ident(RubyFileTest)operator(.)ident(executable_real_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(z)delimiter(')>operator(:) comment(// ?z | boolean | True if file1 exists and has a zero length) - keyword(return) ident(RubyFileTest)operator(.)ident(zero_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) comment(// ?= | boolean | True if the modification times of file1 and file2 are equal) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(mtimeEquals)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) comment(// ?< | boolean | True if the modification time of file1 is prior to that of file2) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(mtimeLessThan)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) comment(// ?> | boolean | True if the modification time of file1 is after that of file2) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFileStat)operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(.)ident(mtimeGreaterThan)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) comment(// ?- | boolean | True if file1 and file2 are identical) - keyword(return) ident(RubyFileTest)operator(.)ident(identical_p)operator(()ident(recv)operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(default)operator(:) - keyword(throw) keyword(new) exception(InternalError)operator(()string<delimiter(")content(unreachable code reached!)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(`)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(backquote)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(aString)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(ByteArrayOutputStream) ident(output) operator(=) keyword(new) pre_type(ByteArrayOutputStream)operator(()operator(\))operator(;) - - ident(RubyString) ident(string) operator(=) ident(aString)operator(.)ident(convertToString)operator(()operator(\))operator(;) - type(int) ident(resultCode) operator(=) ident(ShellLauncher)operator(.)ident(runAndWait)operator(()ident(runtime)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(string)operator(})operator(,) ident(output)operator(\))operator(;) - - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($?)delimiter(")>operator(,) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(resultCode)operator(\))operator(\))operator(;) - - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(output)operator(.)ident(toByteArray)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(srand)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyInteger) ident(srand)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(long) ident(oldRandomSeed) operator(=) ident(runtime)operator(.)ident(getRandomSeed)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(RubyInteger) ident(integerSeed) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()ident(MethodIndex)operator(.)ident(TO_INT)operator(,) string<delimiter(")content(to_int)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setRandomSeed)operator(()ident(integerSeed)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// Not sure how well this works, but it works much better than) - comment(// just currentTimeMillis by itself.) - ident(runtime)operator(.)ident(setRandomSeed)operator(()pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(^) - ident(recv)operator(.)ident(hashCode)operator(()operator(\)) operator(^) ident(runtime)operator(.)ident(incrementRandomSeedSequence)operator(()operator(\)) operator(^) - ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(nextInt)operator(()pre_type(Math)operator(.)ident(max)operator(()integer(1)operator(,) pre_type(Math)operator(.)ident(abs)operator(()operator(()type(int)operator(\))ident(runtime)operator(.)ident(getRandomSeed)operator(()operator(\))operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(setSeed)operator(()ident(runtime)operator(.)ident(getRandomSeed)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(oldRandomSeed)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rand)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyNumeric) ident(rand)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(long) ident(ceil)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(ceil) operator(=) integer(0)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - type(byte)type([]) ident(bigCeilBytes) operator(=) operator(()operator(()ident(RubyBignum)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getValue)operator(()operator(\))operator(.)ident(toByteArray)operator(()operator(\))operator(;) - pre_type(BigInteger) ident(bigCeil) operator(=) keyword(new) pre_type(BigInteger)operator(()ident(bigCeilBytes)operator(\))operator(.)ident(abs)operator(()operator(\))operator(;) - - type(byte)type([]) ident(randBytes) operator(=) keyword(new) type(byte)operator([)ident(bigCeilBytes)operator(.)ident(length)operator(])operator(;) - ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(nextBytes)operator(()ident(randBytes)operator(\))operator(;) - - pre_type(BigInteger) ident(result) operator(=) keyword(new) pre_type(BigInteger)operator(()ident(randBytes)operator(\))operator(.)ident(abs)operator(()operator(\))operator(.)ident(mod)operator(()ident(bigCeil)operator(\))operator(;) - - keyword(return) keyword(new) ident(RubyBignum)operator(()ident(runtime)operator(,) ident(result)operator(\))operator(;) - operator(}) - - ident(RubyInteger) ident(integerCeil) operator(=) operator(()ident(RubyInteger)operator(\))ident(RubyKernel)operator(.)ident(new_integer)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - ident(ceil) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(integerCeil)operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong # of arguments()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+) string<delimiter(")content( for 1\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(ceil) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(nextDouble)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(ceil) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()pre_type(Math)operator(.)ident(abs)operator(()ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(nextLong)operator(()operator(\))operator(\)) operator(%) ident(ceil)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(runtime)operator(.)ident(getRandom)operator(()operator(\))operator(.)ident(nextInt)operator(()operator(()type(int)operator(\)) ident(ceil)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(syscall)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(9)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(syscall)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Kernel#syscall is not implemented in JRuby)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(system)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(system)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(resultCode)operator(;) - keyword(try) operator({) - ident(resultCode) operator(=) ident(ShellLauncher)operator(.)ident(runAndWait)operator(()ident(runtime)operator(,) ident(args)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - ident(resultCode) operator(=) integer(127)operator(;) - operator(}) - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(()string<delimiter(")content($?)delimiter(")>operator(,) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(resultCode)operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newBoolean)operator(()ident(resultCode) operator(==) integer(0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(exec)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exec)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(resultCode)operator(;) - keyword(try) operator({) - comment(// TODO: exec should replace the current process.) - comment(// This could be possible with JNA. ) - ident(resultCode) operator(=) ident(ShellLauncher)operator(.)ident(execAndWait)operator(()ident(runtime)operator(,) ident(args)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoENOENTError)operator(()string<delimiter(")content(cannot execute)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(exit)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(runtime)operator(.)ident(newFixnum)operator(()ident(resultCode)operator(\))operator(})operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fork)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(fork)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(RubyInstanceConfig)operator(.)ident(FORK_ENABLED)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(fork is unsafe and disabled by default on JRuby)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - type(int) ident(pid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(fork)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pid) operator(==) integer(0)operator(\)) operator({) - keyword(try) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(re)operator(\)) operator({) - keyword(if) operator(()ident(re)operator(.)ident(getException)operator(()operator(\)) keyword(instanceof) ident(RubySystemExit)operator(\)) operator({) - keyword(throw) ident(re)operator(;) - operator(}) - keyword(return) ident(exit_bang)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(})operator(\))operator(;) - operator(}) keyword(catch) operator(()pre_type(Throwable) ident(t)operator(\)) operator({) - keyword(return) ident(exit_bang)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(})operator(\))operator(;) - operator(}) - keyword(return) ident(exit_bang)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({)ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(pid)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(result) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(fork)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(result) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(result)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(tap)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - keyword(return) ident(recv)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(LocalJumpError)delimiter(")>operator(,)ident(parent)operator(=)string<delimiter(")content(StandardError)delimiter(")>operator(\)) -directive(public) type(class) class(RubyLocalJumpError) directive(extends) ident(RubyException) operator({) - directive(private) directive(static) ident(ObjectAllocator) ident(LOCALJUMPERROR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyLocalJumpError)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createLocalJumpErrorClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(standardErrorClass)operator(\)) operator({) - ident(RubyClass) ident(nameErrorClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(LocalJumpError)delimiter(")>operator(,) ident(standardErrorClass)operator(,) ident(LOCALJUMPERROR_ALLOCATOR)operator(\))operator(;) - - ident(nameErrorClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyLocalJumpError)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(nameErrorClass)operator(;) - operator(}) - - directive(private) ident(RubyLocalJumpError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyLocalJumpError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(,) pre_type(String) ident(message)operator(,) pre_type(String) ident(reason)operator(,) ident(IRubyObject) ident(exitValue)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(message)operator(\))operator(;) - ident(fastSetInternalVariable)operator(()string<delimiter(")content(reason)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()ident(reason)operator(\))operator(\))operator(;) - ident(fastSetInternalVariable)operator(()string<delimiter(")content(exit_value)delimiter(")>operator(,) ident(exitValue)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reason)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(reason)operator(()operator(\)) operator({) - keyword(return) ident(fastGetInternalVariable)operator(()string<delimiter(")content(reason)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit_value)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(exit_value)operator(()operator(\)) operator({) - keyword(return) ident(fastGetInternalVariable)operator(()string<delimiter(")content(exit_value)delimiter(")>operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2007 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2003 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.ByteArrayInputStream)operator(;) -keyword(import) include(java.io.ByteArrayOutputStream)operator(;) -keyword(import) include(java.io.EOFException)operator(;) -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.OutputStream)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.Constants)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) - -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.IOInputStream)operator(;) -keyword(import) include(org.jruby.util.IOOutputStream)operator(;) - -comment(/** - * Marshal module - * - * @author Anders - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Marshal)delimiter(")>operator(\)) -directive(public) type(class) class(RubyMarshal) operator({) - - directive(public) directive(static) ident(RubyModule) ident(createMarshalModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Marshal)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setMarshal)operator(()ident(module)operator(\))operator(;) - - ident(module)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyMarshal)operator(.)ident(class)operator(\))operator(;) - ident(module)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAJOR_VERSION)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Constants)operator(.)ident(MARSHAL_MAJOR)operator(\))operator(\))operator(;) - ident(module)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MINOR_VERSION)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Constants)operator(.)ident(MARSHAL_MINOR)operator(\))operator(\))operator(;) - - keyword(return) ident(module)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dump)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dump)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(1)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong # of arguments(at least 1\))delimiter(")>operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(objectToDump) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - - ident(IRubyObject) ident(io) operator(=) pre_constant(null)operator(;) - type(int) ident(depthLimit) operator(=) operator(-)integer(1)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>=) integer(2)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(respondsTo)operator(()string<delimiter(")content(write)delimiter(")>operator(\))operator(\)) operator({) - ident(io) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(depthLimit) operator(=) operator(()type(int)operator(\)) operator(()operator(()ident(RubyFixnum)operator(\)) ident(args)operator([)integer(1)operator(])operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Instance of IO needed)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(3)operator(\)) operator({) - ident(depthLimit) operator(=) operator(()type(int)operator(\)) operator(()operator(()ident(RubyFixnum)operator(\)) ident(args)operator([)integer(2)operator(])operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(try) operator({) - keyword(if) operator(()ident(io) operator(!=) pre_constant(null)operator(\)) operator({) - ident(dumpToStream)operator(()ident(objectToDump)operator(,) ident(outputStream)operator(()ident(io)operator(\))operator(,) ident(depthLimit)operator(\))operator(;) - keyword(return) ident(io)operator(;) - operator(}) - pre_type(ByteArrayOutputStream) ident(stringOutput) operator(=) keyword(new) pre_type(ByteArrayOutputStream)operator(()operator(\))operator(;) - ident(dumpToStream)operator(()ident(objectToDump)operator(,) ident(stringOutput)operator(,) ident(depthLimit)operator(\))operator(;) - - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(stringOutput)operator(.)ident(toByteArray)operator(()operator(\))operator(,)pre_constant(false)operator(\))operator(\))operator(;) - - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ioe)operator(\))operator(;) - operator(}) - - operator(}) - - directive(private) directive(static) pre_type(OutputStream) ident(outputStream)operator(()ident(IRubyObject) ident(out)operator(\)) operator({) - ident(setBinmodeIfPossible)operator(()ident(out)operator(\))operator(;) - keyword(if) operator(()ident(out) keyword(instanceof) ident(RubyIO)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyIO)operator(\)) ident(out)operator(\))operator(.)ident(getOutStream)operator(()operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(IOOutputStream)operator(()ident(out)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(setBinmodeIfPossible)operator(()ident(IRubyObject) ident(io)operator(\)) operator({) - keyword(if) operator(()ident(io)operator(.)ident(respondsTo)operator(()string<delimiter(")content(binmode)delimiter(")>operator(\))operator(\)) operator({) - ident(io)operator(.)ident(callMethod)operator(()ident(io)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(binmode)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(load)delimiter(")>operator(,) string<delimiter(")content(restore)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(try) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(1)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments (0 for 1\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments ()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+) string<delimiter(")content( for 2\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(in) operator(=) pre_constant(null)operator(;) - ident(IRubyObject) ident(proc) operator(=) pre_constant(null)operator(;) - - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(2)operator(:) - ident(proc) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - keyword(case) integer(1)operator(:) - ident(in) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - - pre_type(InputStream) ident(rawInput)operator(;) - keyword(if) operator(()ident(in) operator(!=) pre_constant(null) operator(&&) ident(in)operator(.)ident(respondsTo)operator(()string<delimiter(")content(read)delimiter(")>operator(\))operator(\)) operator({) - ident(rawInput) operator(=) ident(inputStream)operator(()ident(in)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(in) operator(!=) pre_constant(null) operator(&&) ident(in)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - ident(RubyString) ident(inString) operator(=) operator(()ident(RubyString)operator(\)) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(in)operator(,) string<delimiter(")content(to_str)delimiter(")>operator(\))operator(;) - ident(ByteList) ident(bytes) operator(=) ident(inString)operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(rawInput) operator(=) keyword(new) pre_type(ByteArrayInputStream)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(instance of IO needed)delimiter(")>operator(\))operator(;) - operator(}) - - ident(UnmarshalStream) ident(input) operator(=) keyword(new) ident(UnmarshalStream)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(rawInput)operator(,) ident(proc)operator(\))operator(;) - - keyword(return) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(;) - - operator(}) keyword(catch) operator(()exception(EOFException) ident(ee)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(ioe)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) pre_type(InputStream) ident(inputStream)operator(()ident(IRubyObject) ident(in)operator(\)) operator({) - ident(setBinmodeIfPossible)operator(()ident(in)operator(\))operator(;) - keyword(if) operator(()ident(in) keyword(instanceof) ident(RubyIO)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyIO)operator(\)) ident(in)operator(\))operator(.)ident(getInStream)operator(()operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(IOInputStream)operator(()ident(in)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(void) ident(dumpToStream)operator(()ident(IRubyObject) ident(object)operator(,) pre_type(OutputStream) ident(rawOutput)operator(,) type(int) ident(depthLimit)operator(\)) - directive(throws) exception(IOException) - operator({) - ident(MarshalStream) ident(output) operator(=) keyword(new) ident(MarshalStream)operator(()ident(object)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(rawOutput)operator(,) ident(depthLimit)operator(\))operator(;) - ident(output)operator(.)ident(dumpObject)operator(()ident(object)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.Iterator)operator(;) - -keyword(import) include(org.joni.NameEntry)operator(;) -keyword(import) include(org.joni.Regex)operator(;) -keyword(import) include(org.joni.Region)operator(;) -keyword(import) include(org.joni.exception.JOniException)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** - * @author olabini - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(MatchData)delimiter(")>operator(\)) -directive(public) type(class) class(RubyMatchData) directive(extends) ident(RubyObject) operator({) - pre_type(Region) ident(regs)operator(;) comment(// captures) - type(int) ident(begin)operator(;) comment(// begin and end are used when not groups defined) - type(int) ident(end)operator(;) - ident(RubyString) ident(str)operator(;) - ident(Regex) ident(pattern)operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createMatchDataClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// TODO: Is NOT_ALLOCATABLE_ALLOCATOR ok here, since you can't actually instantiate MatchData directly?) - ident(RubyClass) ident(matchDataClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(MatchData)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setMatchData)operator(()ident(matchDataClass)operator(\))operator(;) - ident(runtime)operator(.)ident(defineGlobalConstant)operator(()string<delimiter(")content(MatchingData)delimiter(")>operator(,) ident(matchDataClass)operator(\))operator(;) - ident(matchDataClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyMatchData)operator(;) - operator(}) - operator(})operator(;) - - ident(matchDataClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - ident(matchDataClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyMatchData)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(matchDataClass)operator(;) - operator(}) - - directive(public) ident(RubyMatchData)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getMatchData)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(final) directive(static) type(int) ident(MATCH_BUSY) operator(=) ident(USER2_F)operator(;) - - comment(// rb_match_busy) - directive(public) directive(final) type(void) ident(use)operator(()operator(\)) operator({) - ident(flags) operator(|=) ident(MATCH_BUSY)operator(;) - operator(}) - - directive(public) directive(final) type(boolean) ident(used)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(MATCH_BUSY)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) ident(RubyArray) ident(match_array)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(start)operator(\)) operator({) - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(start) operator(!=) integer(0)operator(\)) keyword(return) ident(runtime)operator(.)ident(newEmptyArray)operator(()operator(\))operator(;) - keyword(if) operator(()ident(begin) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyString) ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(runtime)operator(,) ident(begin)operator(,) ident(end) operator(-) ident(begin)operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(ss)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(ss)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(RubyArray) ident(arr) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(regs)operator(.)ident(numRegs) operator(-) ident(start)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)ident(start)operator(;) ident(i)operator(<)ident(regs)operator(.)ident(numRegs)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(regs)operator(.)ident(beg)operator([)ident(i)operator(]) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(arr)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(RubyString) ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(runtime)operator(,) ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(,) ident(regs)operator(.)ident(end)operator([)ident(i)operator(]) operator(-) ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(ss)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - ident(arr)operator(.)ident(append)operator(()ident(ss)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(arr)operator(;) - operator(}) - - operator(}) - - directive(public) ident(IRubyObject) ident(group)operator(()type(long) ident(n)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()operator(()type(int)operator(\))ident(n)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(group)operator(()type(int) ident(n)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(n)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - keyword(if) operator(()ident(pattern) operator(==) pre_constant(null)operator(\)) keyword(return) ident(anyToString)operator(()operator(\))operator(;) - - ident(RubyString) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()operator(\))operator(;) - ident(result)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(#)delimiter(')>operator(\))operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(<)delimiter(')>operator(\))operator(;) - ident(result)operator(.)ident(append)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(to_s)operator(()operator(\))operator(\))operator(;) - - ident(NameEntry)type([])ident(names) operator(=) keyword(new) ident(NameEntry)operator([)ident(regs) operator(==) pre_constant(null) operator(?) integer(1) operator(:) ident(regs)operator(.)ident(numRegs)operator(])operator(;) - - keyword(if) operator(()ident(pattern)operator(.)ident(numberOfNames)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - keyword(for) operator(()pre_type(Iterator)operator(<)ident(NameEntry)operator(>) ident(i) operator(=) ident(pattern)operator(.)ident(namedBackrefIterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(NameEntry) ident(e) operator(=) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(num) operator(:) ident(e)operator(.)ident(getBackRefs)operator(()operator(\))operator(\)) ident(names)operator([)ident(num)operator(]) operator(=) ident(e)operator(;) - operator(}) - operator(}) - - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(names)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content( )delimiter(')>operator(\))operator(;) - keyword(if) operator(()ident(i) operator(>) integer(0)operator(\)) operator({) - ident(NameEntry) ident(e) operator(=) ident(names)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(e) operator(!=) pre_constant(null)operator(\)) operator({) - ident(result)operator(.)ident(cat)operator(()ident(e)operator(.)ident(name)operator(,) ident(e)operator(.)ident(nameP)operator(,) ident(e)operator(.)ident(nameEnd) operator(-) ident(e)operator(.)ident(nameP)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))operator(()string<delimiter(')content(0)delimiter(')> operator(+) ident(i)operator(\))operator(\))operator(;) - operator(}) - ident(result)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(:)delimiter(')>operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(v) operator(=) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(i)operator(,) local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(v)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(result)operator(.)ident(cat)operator(()string<delimiter(")content(nil)delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(v)operator(.)ident(inspect)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(result)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(>)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** match_to_a - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - keyword(return) ident(match_array)operator(()ident(getRuntime)operator(()operator(\))operator(,) integer(0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(values_at)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(values_at)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(to_a)operator(()operator(\))operator(.)ident(values_at)operator(()ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(select)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(to_a)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** match_captures - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(captures)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(captures)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(match_array)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(1)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(nameToBackrefNumber)operator(()ident(RubyString) ident(str)operator(\)) operator({) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(pattern)operator(.)ident(nameToBackrefNumber)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) ident(regs)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JOniException) ident(je)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()ident(je)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(final) type(int) ident(backrefNumber)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - keyword(return) ident(nameToBackrefNumber)operator(()operator(()ident(RubyString)operator(\))operator(()operator(()ident(RubySymbol)operator(\))ident(obj)operator(\))operator(.)ident(id2name)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(nameToBackrefNumber)operator(()operator(()ident(RubyString)operator(\))ident(obj)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(obj)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(op_aref)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(op_aref)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** match_aref - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(IRubyObject) ident(idx)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(op_arefCommon)operator(()ident(idx)operator(\))operator(;) - keyword(return) ident(result) operator(==) pre_constant(null) operator(?) operator(()operator(()ident(RubyArray)operator(\))ident(to_a)operator(()operator(\))operator(\))operator(.)ident(aref)operator(()ident(idx)operator(\)) operator(:) ident(result)operator(;) - operator(}) - - comment(/** match_aref - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(IRubyObject) ident(idx)operator(,) ident(IRubyObject) ident(rest)operator(\)) operator({) - ident(IRubyObject) ident(result)operator(;) - keyword(return) operator(!)ident(rest)operator(.)ident(isNil)operator(()operator(\)) operator(||) operator(()ident(result) operator(=) ident(op_arefCommon)operator(()ident(idx)operator(\))operator(\)) operator(==) pre_constant(null) operator(?) operator(()operator(()ident(RubyArray)operator(\))ident(to_a)operator(()operator(\))operator(\))operator(.)ident(aref)operator(()ident(idx)operator(,) ident(rest)operator(\)) operator(:) ident(result)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(op_arefCommon)operator(()ident(IRubyObject) ident(idx)operator(\)) operator({) - keyword(if) operator(()ident(idx) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(int) ident(num) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(idx)operator(\))operator(;) - keyword(if) operator(()ident(num) operator(>=) integer(0)operator(\)) keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(num)operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(idx) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(nameToBackrefNumber)operator(()operator(()ident(RubyString)operator(\))operator(()operator(()ident(RubySymbol)operator(\))ident(idx)operator(\))operator(.)ident(id2name)operator(()operator(\))operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(idx) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(nameToBackrefNumber)operator(()operator(()ident(RubyString)operator(\))ident(idx)operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** match_size - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(size)delimiter(")>operator(,) string<delimiter(")content(length)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(regs) operator(==) pre_constant(null) operator(?) ident(RubyFixnum)operator(.)ident(one)operator(()ident(getRuntime)operator(()operator(\))operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(regs)operator(.)ident(numRegs)operator(\))operator(;) - operator(}) - - comment(/** match_begin - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(begin)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(begin)operator(()ident(IRubyObject) ident(index)operator(\)) operator({) - type(int) ident(i) operator(=) ident(backrefNumber)operator(()ident(index)operator(\))operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(begin) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(begin)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(i) operator(<) integer(0) operator(||) ident(regs)operator(.)ident(numRegs) operator(<=) ident(i)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(regs)operator(.)ident(beg)operator([)ident(i)operator(]) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - comment(/** match_end - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(end)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(end)operator(()ident(IRubyObject) ident(index)operator(\)) operator({) - type(int) ident(i) operator(=) ident(backrefNumber)operator(()ident(index)operator(\))operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(end) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(end)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(i) operator(<) integer(0) operator(||) ident(regs)operator(.)ident(numRegs) operator(<=) ident(i)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(regs)operator(.)ident(end)operator([)ident(i)operator(]) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(regs)operator(.)ident(end)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - comment(/** match_offset - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(offset)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(offset)operator(()ident(IRubyObject) ident(index)operator(\)) operator({) - type(int) ident(i) operator(=) ident(backrefNumber)operator(()ident(index)operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(begin) operator(<) integer(0)operator(\)) keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(begin)operator(\))operator(,)ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(end)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(i) operator(<) integer(0) operator(||) ident(regs)operator(.)ident(numRegs) operator(<=) ident(i)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(i) operator(+) string<delimiter(")content( out of matches)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(regs)operator(.)ident(beg)operator([)ident(i)operator(]) operator(<) integer(0)operator(\)) keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(\))operator(,)ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(regs)operator(.)ident(end)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** match_pre_match - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pre_match)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pre_match)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(ss)operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if)operator(()ident(begin) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(0)operator(,) ident(begin)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if)operator(()ident(regs)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(0)operator(,) ident(regs)operator(.)ident(beg)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(ss)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(ss)operator(;) - operator(}) - - comment(/** match_post_match - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(post_match)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(post_match)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(ss)operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(begin) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(end)operator(,) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(-) ident(end)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(regs)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(ss) operator(=) ident(str)operator(.)ident(makeShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(regs)operator(.)ident(end)operator([)integer(0)operator(])operator(,) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(-) ident(regs)operator(.)ident(end)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - keyword(if)operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(ss)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(ss)operator(;) - operator(}) - - comment(/** match_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - ident(IRubyObject) ident(ss) operator(=) ident(RubyRegexp)operator(.)ident(last_match)operator(()local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(ss)operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(ss) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(ss)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(ss)operator(;) - operator(}) - - comment(/** match_string - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(string)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(string)operator(()operator(\)) operator({) - keyword(return) ident(str)operator(;) comment(//str is frozen) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(original)operator(\)) keyword(return) local_variable(this)operator(;) - - keyword(if) operator(()operator(!)operator(()ident(getMetaClass)operator(()operator(\)) operator(==) ident(original)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator({) comment(// MRI also does a pointer comparison here) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument class)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyMatchData) ident(origMatchData) operator(=) operator(()ident(RubyMatchData)operator(\))ident(original)operator(;) - ident(str) operator(=) ident(origMatchData)operator(.)ident(str)operator(;) - ident(regs) operator(=) ident(origMatchData)operator(.)ident(regs)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Math)delimiter(")>operator(\)) -directive(public) type(class) class(RubyMath) operator({) - comment(/** Create the Math module and add it to the Ruby runtime. - * - */) - directive(public) directive(static) ident(RubyModule) ident(createMathModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(result) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Math)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setMath)operator(()ident(result)operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(E)delimiter(")>operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) pre_type(Math)operator(.)ident(E)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(PI)delimiter(")>operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(runtime)operator(,) pre_type(Math)operator(.)ident(PI)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyMath)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - - directive(private) directive(static) type(void) ident(domainCheck)operator(()ident(IRubyObject) ident(recv)operator(,) type(double) ident(value)operator(,) pre_type(String) ident(msg)operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEDOMError)operator(()ident(msg)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) type(double) ident(chebylevSerie)operator(()type(double) ident(x)operator(,) type(double) ident(coef)type([])operator(\)) operator({) - type(double) ident(b0)operator(,) ident(b1)operator(,) ident(b2)operator(,) ident(twox)operator(;) - type(int) ident(i)operator(;) - ident(b1) operator(=) float(0.0)operator(;) - ident(b0) operator(=) float(0.0)operator(;) - ident(b2) operator(=) float(0.0)operator(;) - ident(twox) operator(=) float(2.0) operator(*) ident(x)operator(;) - keyword(for) operator(()ident(i) operator(=) ident(coef)operator(.)ident(length)operator(-)integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(b2) operator(=) ident(b1)operator(;) - ident(b1) operator(=) ident(b0)operator(;) - ident(b0) operator(=) ident(twox) operator(*) ident(b1) operator(-) ident(b2) operator(+) ident(coef)operator([)ident(i)operator(])operator(;) - operator(}) - keyword(return) float(0.5)operator(*)operator(()ident(b0) operator(-) ident(b2)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(double) ident(sign)operator(()type(double) ident(x)operator(,) type(double) ident(y)operator(\)) operator({) - type(double) ident(abs) operator(=) operator(()operator(()ident(x) operator(<) integer(0)operator(\)) operator(?) operator(-)ident(x) operator(:) ident(x)operator(\))operator(;) - keyword(return) operator(()ident(y) operator(<) float(0.0)operator(\)) operator(?) operator(-)ident(abs) operator(:) ident(abs)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(atan2)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(atan2)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - type(double) ident(valuea) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(valueb) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(y)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(atan2)operator(()ident(valuea)operator(,) ident(valueb)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(cos)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(cos)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)pre_type(Math)operator(.)ident(cos)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sin)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(sin)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)pre_type(Math)operator(.)ident(sin)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tan)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(tan)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)pre_type(Math)operator(.)ident(tan)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(asin)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(asin)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result) operator(=) pre_type(Math)operator(.)ident(asin)operator(()ident(value)operator(\))operator(;) - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(asin)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(acos)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(acos)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result) operator(=) pre_type(Math)operator(.)ident(acos)operator(()ident(value)operator(\))operator(;) - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(acos)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(atan)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(atan)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)pre_type(Math)operator(.)ident(atan)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(cosh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(cosh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)operator(()pre_type(Math)operator(.)ident(exp)operator(()ident(value)operator(\)) operator(+) pre_type(Math)operator(.)ident(exp)operator(()operator(-)ident(value)operator(\))operator(\)) operator(/) float(2.0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sinh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(sinh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)operator(()pre_type(Math)operator(.)ident(exp)operator(()ident(value)operator(\)) operator(-) pre_type(Math)operator(.)ident(exp)operator(()operator(-)ident(value)operator(\))operator(\)) operator(/) float(2.0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tanh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(tanh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Math)operator(.)ident(tanh)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(acosh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(acosh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result)operator(;) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\)) operator(||) ident(value) operator(<) integer(1)operator(\)) operator({) - ident(result) operator(=) pre_type(Double)operator(.)ident(NaN)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(value) operator(<) float(94906265.62)operator(\)) operator({) - ident(result) operator(=) pre_type(Math)operator(.)ident(log)operator(()ident(value) operator(+) pre_type(Math)operator(.)ident(sqrt)operator(()ident(value) operator(*) ident(value) operator(-) float(1.0)operator(\))operator(\))operator(;) - operator(}) keyword(else)operator({) - ident(result) operator(=) float(0.69314718055994530941723212145818) operator(+) pre_type(Math)operator(.)ident(log)operator(()ident(value)operator(\))operator(;) - operator(}) - - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(acosh)delimiter(")>operator(\))operator(;) - - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(double) ident(ASINH_COEF)type([]) operator(=) operator({) - operator(-)float(.12820039911738186343372127359268e+0)operator(,) - operator(-)float(.58811761189951767565211757138362e-1)operator(,) - float(.47274654322124815640725249756029e-2)operator(,) - operator(-)float(.49383631626536172101360174790273e-3)operator(,) - float(.58506207058557412287494835259321e-4)operator(,) - operator(-)float(.74669983289313681354755069217188e-5)operator(,) - float(.10011693583558199265966192015812e-5)operator(,) - operator(-)float(.13903543858708333608616472258886e-6)operator(,) - float(.19823169483172793547317360237148e-7)operator(,) - operator(-)float(.28847468417848843612747272800317e-8)operator(,) - float(.42672965467159937953457514995907e-9)operator(,) - operator(-)float(.63976084654366357868752632309681e-10)operator(,) - float(.96991686089064704147878293131179e-11)operator(,) - operator(-)float(.14844276972043770830246658365696e-11)operator(,) - float(.22903737939027447988040184378983e-12)operator(,) - operator(-)float(.35588395132732645159978942651310e-13)operator(,) - float(.55639694080056789953374539088554e-14)operator(,) - operator(-)float(.87462509599624678045666593520162e-15)operator(,) - float(.13815248844526692155868802298129e-15)operator(,) - operator(-)float(.21916688282900363984955142264149e-16)operator(,) - float(.34904658524827565638313923706880e-17) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(asinh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(asinh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(y) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(value)operator(\))operator(;) - type(double) ident(result)operator(;) - - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - ident(result) operator(=) pre_type(Double)operator(.)ident(NaN)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<=) float(1.05367e-08)operator(\)) operator({) - ident(result) operator(=) ident(value)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<=) float(1.0)operator(\)) operator({) - ident(result) operator(=) ident(value) operator(*) operator(()float(1.0) operator(+) ident(chebylevSerie)operator(()float(2.0) operator(*) ident(value) operator(*) ident(value) operator(-) float(1.0)operator(,) ident(ASINH_COEF)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<) float(94906265.62)operator(\)) operator({) - ident(result) operator(=) pre_type(Math)operator(.)ident(log)operator(()ident(value) operator(+) pre_type(Math)operator(.)ident(sqrt)operator(()ident(value) operator(*) ident(value) operator(+) float(1.0)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) float(0.69314718055994530941723212145818) operator(+) pre_type(Math)operator(.)ident(log)operator(()ident(y)operator(\))operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) ident(result) operator(*=) operator(-)integer(1)operator(;) - operator(}) - - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(double) ident(ATANH_COEF)type([]) operator(=) operator({) - float(.9439510239319549230842892218633e-1)operator(,) - float(.4919843705578615947200034576668e-1)operator(,) - float(.2102593522455432763479327331752e-2)operator(,) - float(.1073554449776116584640731045276e-3)operator(,) - float(.5978267249293031478642787517872e-5)operator(,) - float(.3505062030889134845966834886200e-6)operator(,) - float(.2126374343765340350896219314431e-7)operator(,) - float(.1321694535715527192129801723055e-8)operator(,) - float(.8365875501178070364623604052959e-10)operator(,) - float(.5370503749311002163881434587772e-11)operator(,) - float(.3486659470157107922971245784290e-12)operator(,) - float(.2284549509603433015524024119722e-13)operator(,) - float(.1508407105944793044874229067558e-14)operator(,) - float(.1002418816804109126136995722837e-15)operator(,) - float(.6698674738165069539715526882986e-17)operator(,) - float(.4497954546494931083083327624533e-18) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(atanh)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(atanh)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(y) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(value)operator(\))operator(;) - type(double) ident(result)operator(;) - - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(value)operator(\))operator(\)) operator({) - ident(result) operator(=) pre_type(Double)operator(.)ident(NaN)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<) float(1.82501e-08)operator(\)) operator({) - ident(result) operator(=) ident(value)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<=) float(0.5)operator(\)) operator({) - ident(result) operator(=) ident(value) operator(*) operator(()float(1.0) operator(+) ident(chebylevSerie)operator(()float(8.0) operator(*) ident(value) operator(*) ident(value) operator(-) float(1.0)operator(,) ident(ATANH_COEF)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<) float(1.0)operator(\)) operator({) - ident(result) operator(=) float(0.5) operator(*) pre_type(Math)operator(.)ident(log)operator(()operator(()float(1.0) operator(+) ident(value)operator(\)) operator(/) operator(()float(1.0) operator(-) ident(value)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(==) float(1.0)operator(\)) operator({) - ident(result) operator(=) ident(value) operator(*) pre_type(Double)operator(.)ident(POSITIVE_INFINITY)operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) pre_type(Double)operator(.)ident(NaN)operator(;) - operator(}) - - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(atanh)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exp)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(exp)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(exponent)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(exponent)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)pre_type(Math)operator(.)ident(exp)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - comment(/** Returns the natural logarithm of x. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(log)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(log)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result) operator(=) pre_type(Math)operator(.)ident(log)operator(()ident(value)operator(\))operator(;) - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(log)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - comment(/** Returns the base 10 logarithm of x. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(log10)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(log10)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result) operator(=) pre_type(Math)operator(.)ident(log)operator(()ident(value)operator(\)) operator(/) pre_type(Math)operator(.)ident(log)operator(()integer(10)operator(\))operator(;) - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(log10)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sqrt)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(sqrt)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result)operator(;) - - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) operator({) - ident(result) operator(=) pre_type(Double)operator(.)ident(NaN)operator(;) - operator(}) keyword(else)operator({) - ident(result) operator(=) pre_type(Math)operator(.)ident(sqrt)operator(()ident(value)operator(\))operator(;) - operator(}) - - ident(domainCheck)operator(()ident(recv)operator(,) ident(result)operator(,) string<delimiter(")content(sqrt)delimiter(")>operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hypot)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(hypot)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - type(double) ident(valuea) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(valueb) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(y)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result)operator(;) - - keyword(if) operator(()pre_type(Math)operator(.)ident(abs)operator(()ident(valuea)operator(\)) operator(>) pre_type(Math)operator(.)ident(abs)operator(()ident(valueb)operator(\))operator(\)) operator({) - ident(result) operator(=) ident(valueb) operator(/) ident(valuea)operator(;) - ident(result) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(valuea)operator(\)) operator(*) pre_type(Math)operator(.)ident(sqrt)operator(()integer(1) operator(+) ident(result) operator(*) ident(result)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(valueb) operator(!=) integer(0)operator(\)) operator({) - ident(result) operator(=) ident(valuea) operator(/) ident(valueb)operator(;) - ident(result) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(valueb)operator(\)) operator(*) pre_type(Math)operator(.)ident(sqrt)operator(()integer(1) operator(+) ident(result) operator(*) ident(result)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) integer(0)operator(;) - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - - comment(/* - * x = mantissa * 2 ** exponent - * - * Where mantissa is in the range of [.5, 1\) - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(frexp)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(frexp)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - type(double) ident(mantissa) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(other)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(short) ident(sign) operator(=) integer(1)operator(;) - type(long) ident(exponent) operator(=) integer(0)operator(;) - - keyword(if) operator(()ident(mantissa) operator(!=) float(0.0)operator(\)) operator({) - comment(// Make mantissa same sign so we only have one code path.) - keyword(if) operator(()ident(mantissa) operator(<) integer(0)operator(\)) operator({) - ident(mantissa) operator(=) operator(-)ident(mantissa)operator(;) - ident(sign) operator(=) operator(-)integer(1)operator(;) - operator(}) - - comment(// Increase value to hit lower range.) - keyword(for) operator(()operator(;) ident(mantissa) operator(<) float(0.5)operator(;) ident(mantissa) operator(*=) float(2.0)operator(,) ident(exponent) operator(-=)integer(1)operator(\)) operator({) operator(}) - - comment(// Decrease value to hit upper range. ) - keyword(for) operator(()operator(;) ident(mantissa) operator(>=) float(1.0)operator(;) ident(mantissa) operator(*=) float(0.5)operator(,) ident(exponent) operator(+=)integer(1)operator(\)) operator({) operator(}) - operator(}) - - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) - ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(sign) operator(*) ident(mantissa)operator(\))operator(,) - ident(RubyNumeric)operator(.)ident(int2fix)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(exponent)operator(\))operator(\))operator(;) - operator(}) - - comment(/* - * r = x * 2 ** y - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ldexp)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(ldexp)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(mantissa)operator(,) ident(IRubyObject) ident(exponent)operator(\)) operator({) - type(double) ident(mantissaValue) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,) ident(mantissa)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(mantissaValue) operator(*) pre_type(Math)operator(.)ident(pow)operator(()float(2.0)operator(,) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(exponent)operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(double) ident(ERFC_COEF)type([]) operator(=) operator({) - operator(-)float(.490461212346918080399845440334e-1)operator(,) - operator(-)float(.142261205103713642378247418996e0)operator(,) - float(.100355821875997955757546767129e-1)operator(,) - operator(-)float(.576876469976748476508270255092e-3)operator(,) - float(.274199312521960610344221607915e-4)operator(,) - operator(-)float(.110431755073445076041353812959e-5)operator(,) - float(.384887554203450369499613114982e-7)operator(,) - operator(-)float(.118085825338754669696317518016e-8)operator(,) - float(.323342158260509096464029309534e-10)operator(,) - operator(-)float(.799101594700454875816073747086e-12)operator(,) - float(.179907251139614556119672454866e-13)operator(,) - operator(-)float(.371863548781869263823168282095e-15)operator(,) - float(.710359900371425297116899083947e-17)operator(,) - operator(-)float(.126124551191552258324954248533e-18) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(erf)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(erf)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - - type(double) ident(result)operator(;) - type(double) ident(y) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(value)operator(\))operator(;) - - keyword(if) operator(()ident(y) operator(<=) float(1.49012e-08)operator(\)) operator({) - ident(result) operator(=) integer(2) operator(*) ident(value) operator(/) float(1.77245385090551602729816748334)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<=) integer(1)operator(\)) operator({) - ident(result) operator(=) ident(value) operator(*) operator(()integer(1) operator(+) ident(chebylevSerie)operator(()integer(2) operator(*) ident(value) operator(*) ident(value) operator(-) integer(1)operator(,) ident(ERFC_COEF)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<) float(6.013687357)operator(\)) operator({) - ident(result) operator(=) ident(sign)operator(()integer(1) operator(-) ident(erfc)operator(()ident(recv)operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(y)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) ident(sign)operator(()integer(1)operator(,) ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(double) ident(ERFC2_COEF)type([]) operator(=) operator({) - operator(-)float(.69601346602309501127391508262e-1)operator(,) - operator(-)float(.411013393626208934898221208467e-1)operator(,) - float(.391449586668962688156114370524e-2)operator(,) - operator(-)float(.490639565054897916128093545077e-3)operator(,) - float(.715747900137703638076089414183e-4)operator(,) - operator(-)float(.115307163413123283380823284791e-4)operator(,) - float(.199467059020199763505231486771e-5)operator(,) - operator(-)float(.364266647159922287393611843071e-6)operator(,) - float(.694437261000501258993127721463e-7)operator(,) - operator(-)float(.137122090210436601953460514121e-7)operator(,) - float(.278838966100713713196386034809e-8)operator(,) - operator(-)float(.581416472433116155186479105032e-9)operator(,) - float(.123892049175275318118016881795e-9)operator(,) - operator(-)float(.269063914530674343239042493789e-10)operator(,) - float(.594261435084791098244470968384e-11)operator(,) - operator(-)float(.133238673575811957928775442057e-11)operator(,) - float(.30280468061771320171736972433e-12)operator(,) - operator(-)float(.696664881494103258879586758895e-13)operator(,) - float(.162085454105392296981289322763e-13)operator(,) - operator(-)float(.380993446525049199987691305773e-14)operator(,) - float(.904048781597883114936897101298e-15)operator(,) - operator(-)float(.2164006195089607347809812047e-15)operator(,) - float(.522210223399585498460798024417e-16)operator(,) - operator(-)float(.126972960236455533637241552778e-16)operator(,) - float(.310914550427619758383622741295e-17)operator(,) - operator(-)float(.766376292032038552400956671481e-18)operator(,) - float(.190081925136274520253692973329e-18) - operator(})operator(;) - - directive(private) directive(static) directive(final) type(double) ident(ERFCC_COEF)type([]) operator(=) operator({) - float(.715179310202924774503697709496e-1)operator(,) - operator(-)float(.265324343376067157558893386681e-1)operator(,) - float(.171115397792085588332699194606e-2)operator(,) - operator(-)float(.163751663458517884163746404749e-3)operator(,) - float(.198712935005520364995974806758e-4)operator(,) - operator(-)float(.284371241276655508750175183152e-5)operator(,) - float(.460616130896313036969379968464e-6)operator(,) - operator(-)float(.822775302587920842057766536366e-7)operator(,) - float(.159214187277090112989358340826e-7)operator(,) - operator(-)float(.329507136225284321486631665072e-8)operator(,) - float(.72234397604005554658126115389e-9)operator(,) - operator(-)float(.166485581339872959344695966886e-9)operator(,) - float(.401039258823766482077671768814e-10)operator(,) - operator(-)float(.100481621442573113272170176283e-10)operator(,) - float(.260827591330033380859341009439e-11)operator(,) - operator(-)float(.699111056040402486557697812476e-12)operator(,) - float(.192949233326170708624205749803e-12)operator(,) - operator(-)float(.547013118875433106490125085271e-13)operator(,) - float(.158966330976269744839084032762e-13)operator(,) - operator(-)float(.47268939801975548392036958429e-14)operator(,) - float(.14358733767849847867287399784e-14)operator(,) - operator(-)float(.444951056181735839417250062829e-15)operator(,) - float(.140481088476823343737305537466e-15)operator(,) - operator(-)float(.451381838776421089625963281623e-16)operator(,) - float(.147452154104513307787018713262e-16)operator(,) - operator(-)float(.489262140694577615436841552532e-17)operator(,) - float(.164761214141064673895301522827e-17)operator(,) - operator(-)float(.562681717632940809299928521323e-18)operator(,) - float(.194744338223207851429197867821e-18) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(erfc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(erfc)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - type(double) ident(value) operator(=) operator(()operator(()ident(RubyFloat)operator(\))ident(RubyKernel)operator(.)ident(new_float)operator(()ident(recv)operator(,)ident(x)operator(\))operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(double) ident(result)operator(;) - type(double) ident(y) operator(=) pre_type(Math)operator(.)ident(abs)operator(()ident(value)operator(\))operator(;) - - keyword(if) operator(()ident(value) operator(<=) operator(-)float(6.013687357)operator(\)) operator({) - ident(result) operator(=) integer(2)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<) float(1.49012e-08)operator(\)) operator({) - ident(result) operator(=) integer(1) operator(-) integer(2) operator(*) ident(value) operator(/) float(1.77245385090551602729816748334)operator(;) - operator(}) keyword(else) operator({) - type(double) ident(ysq) operator(=) ident(y)operator(*)ident(y)operator(;) - keyword(if) operator(()ident(y) operator(<) integer(1)operator(\)) operator({) - ident(result) operator(=) integer(1) operator(-) ident(value) operator(*) operator(()integer(1) operator(+) ident(chebylevSerie)operator(()integer(2) operator(*) ident(ysq) operator(-) integer(1)operator(,) ident(ERFC_COEF)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(y) operator(<=) float(4.0)operator(\)) operator({) - ident(result) operator(=) pre_type(Math)operator(.)ident(exp)operator(()operator(-)ident(ysq)operator(\))operator(/)ident(y)operator(*)operator(()float(0.5)operator(+)ident(chebylevSerie)operator(()operator(()float(8.0) operator(/) ident(ysq) operator(-) float(5.0)operator(\)) operator(/) float(3.0)operator(,) ident(ERFC2_COEF)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) ident(result) operator(=) float(2.0) operator(-) ident(result)operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) ident(result) operator(=) float(2.0) operator(-) ident(result)operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) ident(result) operator(=) float(2.0) operator(-) ident(result)operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) pre_type(Math)operator(.)ident(exp)operator(()operator(-)ident(ysq)operator(\)) operator(/) ident(y) operator(*) operator(()float(0.5) operator(+) ident(chebylevSerie)operator(()float(8.0) operator(/) ident(ysq) operator(-) integer(1)operator(,) ident(ERFCC_COEF)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(value) operator(<) integer(0)operator(\)) ident(result) operator(=) float(2.0) operator(-) ident(result)operator(;) - operator(}) - operator(}) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallbackFactory)operator(;) -keyword(import) include(org.jruby.runtime.MethodBlock)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * The RubyMethod class represents a RubyMethod object. - * - * You can get such a method by calling the "method" method of an object. - * - * Note: This was renamed from Method.java - * - * @author jpetersen - * @since 0.2.3 - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Method)delimiter(")>operator(\)) -directive(public) type(class) class(RubyMethod) directive(extends) ident(RubyObject) operator({) - directive(protected) ident(RubyModule) ident(implementationModule)operator(;) - directive(protected) pre_type(String) ident(methodName)operator(;) - directive(protected) ident(RubyModule) ident(originModule)operator(;) - directive(protected) pre_type(String) ident(originName)operator(;) - directive(protected) ident(DynamicMethod) ident(method)operator(;) - directive(protected) ident(IRubyObject) ident(receiver)operator(;) - - directive(protected) ident(RubyMethod)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - operator(}) - - comment(/** Create the RubyMethod class and add it to the Ruby runtime. - * - */) - directive(public) directive(static) ident(RubyClass) ident(createMethodClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415) - ident(RubyClass) ident(methodClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Method)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setMethod)operator(()ident(methodClass)operator(\))operator(;) - - ident(methodClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyMethod)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(methodClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyMethod) ident(newMethod)operator(() - ident(RubyModule) ident(implementationModule)operator(,) - pre_type(String) ident(methodName)operator(,) - ident(RubyModule) ident(originModule)operator(,) - pre_type(String) ident(originName)operator(,) - ident(DynamicMethod) ident(method)operator(,) - ident(IRubyObject) ident(receiver)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(implementationModule)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyMethod) ident(newMethod) operator(=) keyword(new) ident(RubyMethod)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getMethod)operator(()operator(\))operator(\))operator(;) - - ident(newMethod)operator(.)ident(implementationModule) operator(=) ident(implementationModule)operator(;) - ident(newMethod)operator(.)ident(methodName) operator(=) ident(methodName)operator(;) - ident(newMethod)operator(.)ident(originModule) operator(=) ident(originModule)operator(;) - ident(newMethod)operator(.)ident(originName) operator(=) ident(originName)operator(;) - ident(newMethod)operator(.)ident(method) operator(=) ident(method)operator(.)ident(getRealMethod)operator(()operator(\))operator(;) - ident(newMethod)operator(.)ident(receiver) operator(=) ident(receiver)operator(;) - - keyword(return) ident(newMethod)operator(;) - operator(}) - - comment(/** Call the method. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(receiver)operator(,) ident(implementationModule)operator(,) ident(methodName)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(receiver)operator(,) ident(implementationModule)operator(,) ident(methodName)operator(,) ident(arg)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(receiver)operator(,) ident(implementationModule)operator(,) ident(methodName)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(receiver)operator(,) ident(implementationModule)operator(,) ident(methodName)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(method)operator(.)ident(call)operator(()ident(context)operator(,) ident(receiver)operator(,) ident(implementationModule)operator(,) ident(methodName)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** Returns the number of arguments a method accepted. - * - * @return the number of arguments of a method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(arity)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(arity)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(method)operator(.)ident(getArity)operator(()operator(\))operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(RubyBoolean) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyMethod)operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - ident(RubyMethod) ident(otherMethod) operator(=) operator(()ident(RubyMethod)operator(\))ident(other)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(implementationModule) operator(==) ident(otherMethod)operator(.)ident(implementationModule) operator(&&) - ident(originModule) operator(==) ident(otherMethod)operator(.)ident(originModule) operator(&&) - ident(receiver) operator(==) ident(otherMethod)operator(.)ident(receiver) operator(&&) - ident(method)operator(.)ident(getRealMethod)operator(()operator(\)) operator(==) ident(otherMethod)operator(.)ident(method)operator(.)ident(getRealMethod)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clone)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyMethod) ident(rbClone)operator(()operator(\)) operator({) - keyword(return) ident(newMethod)operator(()ident(implementationModule)operator(,) ident(methodName)operator(,) ident(originModule)operator(,) ident(originName)operator(,) ident(method)operator(,) ident(receiver)operator(\))operator(;) - operator(}) - - comment(/** Create a Proc object. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_proc)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(to_proc)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(CallbackFactory) ident(f) operator(=) ident(runtime)operator(.)ident(callbackFactory)operator(()ident(RubyMethod)operator(.)ident(class)operator(\))operator(;) - ident(Block) ident(block) operator(=) ident(MethodBlock)operator(.)ident(createMethodBlock)operator(()ident(context)operator(,) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(,) - ident(f)operator(.)ident(getBlockMethod)operator(()string<delimiter(")content(bmcall)delimiter(")>operator(\))operator(,) local_variable(this)operator(,) ident(runtime)operator(.)ident(getTopSelf)operator(()operator(\))operator(\))operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(try) operator({) - comment(// FIXME: We should not be regenerating this over and over) - keyword(return) ident(mproc)operator(()ident(context)operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(RetryJump) ident(rj)operator(\)) operator({) - comment(// Execute iterateMethod again.) - operator(}) - operator(}) - operator(}) - - comment(/** Create a Proc object which is called like a ruby method. - * - * Used by the RubyMethod#to_proc method. - * - */) - directive(private) ident(IRubyObject) ident(mproc)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(try) operator({) - ident(context)operator(.)ident(preMproc)operator(()operator(\))operator(;) - - keyword(return) ident(RubyKernel)operator(.)ident(proc)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postMproc)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Delegate a block call to a bound method call. - * - * Used by the RubyMethod#to_proc method. - * - */) - directive(public) directive(static) ident(IRubyObject) ident(bmcall)operator(()ident(IRubyObject) ident(blockArg)operator(,) ident(IRubyObject) ident(arg1)operator(,) - ident(IRubyObject) ident(self)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(blockArg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(blockArg) keyword(instanceof) ident(RubyArray)operator(\)) operator({) - comment(// ENEBO: Very wrong) - keyword(return) operator(()operator(()ident(RubyMethod)operator(\)) ident(arg1)operator(\))operator(.)ident(call)operator(()ident(context)operator(,) operator(()operator(()ident(RubyArray)operator(\)) ident(blockArg)operator(\))operator(.)ident(toJavaArray)operator(()operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - comment(// ENEBO: Very wrong) - keyword(return) operator(()operator(()ident(RubyMethod)operator(\)) ident(arg1)operator(\))operator(.)ident(call)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(blockArg) operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(unbind)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyUnboundMethod) ident(unbind)operator(()ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(RubyUnboundMethod) ident(unboundMethod) operator(=) - ident(RubyUnboundMethod)operator(.)ident(newUnboundMethod)operator(()ident(implementationModule)operator(,) ident(methodName)operator(,) ident(originModule)operator(,) ident(originName)operator(,) ident(method)operator(\))operator(;) - ident(unboundMethod)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - - keyword(return) ident(unboundMethod)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(inspect)delimiter(")>operator(,) string<delimiter(")content(to_s)delimiter(")>operator(})operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - pre_type(StringBuilder) ident(buf) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(;) - type(char) ident(delimeter) operator(=) string<delimiter(')content(#)delimiter(')>operator(;) - - ident(buf)operator(.)ident(append)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(: )delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(implementationModule)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(attached) operator(=) operator(()operator(()ident(MetaClass)operator(\)) ident(implementationModule)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(;) - keyword(if) operator(()ident(receiver) operator(==) pre_constant(null)operator(\)) operator({) - ident(buf)operator(.)ident(append)operator(()ident(implementationModule)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(receiver) operator(==) ident(attached)operator(\)) operator({) - ident(buf)operator(.)ident(append)operator(()ident(attached)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(delimeter) operator(=) string<delimiter(')content(.)delimiter(')>operator(;) - operator(}) keyword(else) operator({) - ident(buf)operator(.)ident(append)operator(()ident(receiver)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(buf)operator(.)ident(append)operator(()string<delimiter(')content(()delimiter(')>operator(\))operator(.)ident(append)operator(()ident(attached)operator(.)ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(')content(\))delimiter(')>operator(\))operator(;) - ident(delimeter) operator(=) string<delimiter(')content(.)delimiter(')>operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(buf)operator(.)ident(append)operator(()ident(originModule)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(implementationModule) operator(!=) ident(originModule)operator(\)) operator({) - ident(buf)operator(.)ident(append)operator(()string<delimiter(')content(()delimiter(')>operator(\))operator(.)ident(append)operator(()ident(implementationModule)operator(.)ident(getName)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(')content(\))delimiter(')>operator(\))operator(;) - operator(}) - operator(}) - - ident(buf)operator(.)ident(append)operator(()ident(delimeter)operator(\))operator(.)ident(append)operator(()ident(methodName)operator(\))operator(.)ident(append)operator(()string<delimiter(')content(>)delimiter(')>operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buf)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) -operator(}) - -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006-2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.reflect.Field)operator(;) -keyword(import) include(java.lang.reflect.Method)operator(;) -keyword(import) include(java.lang.reflect.Modifier)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.Collections)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.HashSet)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(java.util.concurrent.ConcurrentHashMap)operator(;) -keyword(import) include(java.util.concurrent.locks.ReentrantLock)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyConstant)operator(;) -keyword(import) include(org.jruby.anno.JavaMethodDescriptor)operator(;) -keyword(import) include(org.jruby.anno.TypePopulator)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.compiler.ASTInspector)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.AliasMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.FullFunctionCallbackMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.SimpleCallbackMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.MethodMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.ProcMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.UndefinedMethod)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.WrapperMethod)operator(;) -keyword(import) include(org.jruby.parser.StaticScope)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CacheMap)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(static) include(org.jruby.runtime.Visibility)operator(.)operator(*)operator(;) -keyword(import) include(static) include(org.jruby.anno.FrameField)operator(.)operator(*)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) -keyword(import) include(org.jruby.runtime.callback.Callback)operator(;) -keyword(import) include(org.jruby.runtime.component.VariableEntry)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ClassProvider)operator(;) -keyword(import) include(org.jruby.util.IdUtil)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.JavaMethod)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodFactory)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Module)delimiter(")>operator(\)) -directive(public) type(class) class(RubyModule) directive(extends) ident(RubyObject) operator({) - directive(private) directive(static) directive(final) type(boolean) ident(DEBUG) operator(=) pre_constant(false)operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createModuleClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(moduleClass)operator(\)) operator({) - ident(moduleClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(MODULE)operator(;) - ident(moduleClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyModule)operator(;) - operator(}) - operator(})operator(;) - - ident(moduleClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyModule)operator(.)ident(class)operator(\))operator(;) - ident(moduleClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(ModuleKernelMethods)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(moduleClass)operator(;) - operator(}) - - directive(public) directive(static) type(class) class(ModuleKernelMethods) operator({) - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(autoload)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(autoload)operator(()ident(recv)operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(autoload?)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(autoload_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(autoload_p)operator(()ident(context)operator(,) ident(recv)operator(,) ident(arg0)operator(\))operator(;) - operator(}) - operator(}) - - directive(static) ident(ObjectAllocator) ident(MODULE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyModule)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(MODULE)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isModule)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isClass)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(isSingleton)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(// superClass may be null.) - directive(protected) ident(RubyClass) ident(superClass)operator(;) - - directive(public) type(int) ident(index)operator(;) - - directive(public) directive(static) type(class) class(KindOf) operator({) - directive(public) directive(static) directive(final) ident(KindOf) ident(DEFAULT_KIND_OF) operator(=) keyword(new) ident(KindOf)operator(()operator(\))operator(;) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(hasModuleInHierarchy)operator(()ident(type)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(boolean) ident(isInstance)operator(()ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(return) ident(kindOf)operator(.)ident(isKindOf)operator(()ident(object)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) ident(KindOf) ident(kindOf) operator(=) ident(KindOf)operator(.)ident(DEFAULT_KIND_OF)operator(;) - - directive(public) directive(final) type(int) ident(id)operator(;) - - comment(// Containing class...The parent of Object is null. Object should always be last in chain.) - directive(public) ident(RubyModule) ident(parent)operator(;) - - comment(// ClassId is the name of the class/module sans where it is located.) - comment(// If it is null, then it an anonymous class.) - directive(protected) pre_type(String) ident(classId)operator(;) - - - comment(// CONSTANT TABLE) - - comment(// Lock used for variableTable/constantTable writes. The RubyObject variableTable) - comment(// write methods are overridden here to use this lock rather than Java) - comment(// synchronization for faster concurrent writes for modules/classes.) - directive(protected) directive(final) pre_type(ReentrantLock) ident(variableWriteLock) operator(=) keyword(new) pre_type(ReentrantLock)operator(()operator(\))operator(;) - - directive(protected) directive(transient) directive(volatile) ident(ConstantTableEntry)type([]) ident(constantTable) operator(=) - keyword(new) ident(ConstantTableEntry)operator([)ident(CONSTANT_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - - directive(protected) directive(transient) type(int) ident(constantTableSize)operator(;) - - directive(protected) directive(transient) type(int) ident(constantTableThreshold) operator(=) - operator(()type(int)operator(\))operator(()ident(CONSTANT_TABLE_DEFAULT_CAPACITY) operator(*) ident(CONSTANT_TABLE_LOAD_FACTOR)operator(\))operator(;) - - directive(private) directive(final) pre_type(Map)operator(<)pre_type(String)operator(,) ident(DynamicMethod)operator(>) ident(methods) operator(=) keyword(new) pre_type(ConcurrentHashMap)operator(<)pre_type(String)operator(,) ident(DynamicMethod)operator(>)operator(()integer(12)operator(,) float(0.75f)operator(,) integer(1)operator(\))operator(;) - - comment(// ClassProviders return Java class/module (in #defineOrGetClassUnder and) - comment(// #defineOrGetModuleUnder\) when class/module is opened using colon syntax. ) - directive(private) directive(transient) pre_type(List)operator(<)ident(ClassProvider)operator(>) ident(classProviders)operator(;) - - comment(/** separate path for MetaClass construction - * - */) - directive(protected) ident(RubyModule)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(metaClass)operator(,) ident(objectSpace)operator(\))operator(;) - ident(id) operator(=) ident(runtime)operator(.)ident(allocModuleId)operator(()operator(\))operator(;) - comment(// if (parent == null\) parent = runtime.getObject(\);) - ident(setFlag)operator(()ident(USER7_F)operator(,) operator(!)ident(isClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** used by MODULE_ALLOCATOR and RubyClass constructors - * - */) - directive(protected) ident(RubyModule)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(metaClass)operator(,) ident(runtime)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** standard path for Module construction - * - */) - directive(protected) ident(RubyModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getModule)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(needsImplementer)operator(()operator(\)) operator({) - keyword(return) ident(getFlag)operator(()ident(USER7_F)operator(\))operator(;) - operator(}) - - comment(/** rb_module_new - * - */) - directive(public) directive(static) ident(RubyModule) ident(newModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyModule)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** rb_module_new/rb_define_module_id/rb_name_class/rb_set_class_path - * - */) - directive(public) directive(static) ident(RubyModule) ident(newModule)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(,) ident(RubyModule) ident(parent)operator(,) type(boolean) ident(setParent)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) ident(newModule)operator(()ident(runtime)operator(\))operator(;) - ident(module)operator(.)ident(setBaseName)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(setParent)operator(\)) ident(module)operator(.)ident(setParent)operator(()ident(parent)operator(\))operator(;) - ident(parent)operator(.)ident(setConstant)operator(()ident(name)operator(,) ident(module)operator(\))operator(;) - keyword(return) ident(module)operator(;) - operator(}) - - comment(// synchronized method per JRUBY-1173 (unsafe Double-Checked Locking\)) - comment(// FIXME: synchronization is still wrong in CP code) - directive(public) directive(synchronized) type(void) ident(addClassProvider)operator(()ident(ClassProvider) ident(provider)operator(\)) operator({) - keyword(if) operator(()ident(classProviders) operator(==) pre_constant(null)operator(\)) operator({) - pre_type(List)operator(<)ident(ClassProvider)operator(>) ident(cp) operator(=) pre_type(Collections)operator(.)ident(synchronizedList)operator(()keyword(new) pre_type(ArrayList)operator(<)ident(ClassProvider)operator(>)operator(()operator(\))operator(\))operator(;) - ident(cp)operator(.)ident(add)operator(()ident(provider)operator(\))operator(;) - ident(classProviders) operator(=) ident(cp)operator(;) - operator(}) keyword(else) operator({) - directive(synchronized)operator(()ident(classProviders)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(classProviders)operator(.)ident(contains)operator(()ident(provider)operator(\))operator(\)) operator({) - ident(classProviders)operator(.)ident(add)operator(()ident(provider)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - - directive(public) type(void) ident(removeClassProvider)operator(()ident(ClassProvider) ident(provider)operator(\)) operator({) - keyword(if) operator(()ident(classProviders) operator(!=) pre_constant(null)operator(\)) operator({) - ident(classProviders)operator(.)ident(remove)operator(()ident(provider)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(RubyClass) ident(searchProvidersForClass)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClazz)operator(\)) operator({) - keyword(if) operator(()ident(classProviders) operator(!=) pre_constant(null)operator(\)) operator({) - directive(synchronized)operator(()ident(classProviders)operator(\)) operator({) - ident(RubyClass) ident(clazz)operator(;) - keyword(for) operator(()ident(ClassProvider) ident(classProvider)operator(:) ident(classProviders)operator(\)) operator({) - keyword(if) operator(()operator(()ident(clazz) operator(=) ident(classProvider)operator(.)ident(defineClassUnder)operator(()local_variable(this)operator(,) ident(name)operator(,) ident(superClazz)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(clazz)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(private) ident(RubyModule) ident(searchProvidersForModule)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(classProviders) operator(!=) pre_constant(null)operator(\)) operator({) - directive(synchronized)operator(()ident(classProviders)operator(\)) operator({) - ident(RubyModule) ident(module)operator(;) - keyword(for) operator(()ident(ClassProvider) ident(classProvider)operator(:) ident(classProviders)operator(\)) operator({) - keyword(if) operator(()operator(()ident(module) operator(=) ident(classProvider)operator(.)ident(defineModuleUnder)operator(()local_variable(this)operator(,) ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(module)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** Getter for property superClass. - * @return Value of property superClass. - */) - directive(public) ident(RubyClass) ident(getSuperClass)operator(()operator(\)) operator({) - keyword(return) ident(superClass)operator(;) - operator(}) - - directive(protected) type(void) ident(setSuperClass)operator(()ident(RubyClass) ident(superClass)operator(\)) operator({) - local_variable(this)operator(.)ident(superClass) operator(=) ident(superClass)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getParent)operator(()operator(\)) operator({) - keyword(return) ident(parent)operator(;) - operator(}) - - directive(public) type(void) ident(setParent)operator(()ident(RubyModule) ident(parent)operator(\)) operator({) - local_variable(this)operator(.)ident(parent) operator(=) ident(parent)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) ident(DynamicMethod)operator(>) ident(getMethods)operator(()operator(\)) operator({) - keyword(return) ident(methods)operator(;) - operator(}) - - - comment(// note that addMethod now does its own put, so any change made to) - comment(// functionality here should be made there as well ) - directive(private) type(void) ident(putMethod)operator(()pre_type(String) ident(name)operator(,) ident(DynamicMethod) ident(method)operator(\)) operator({) - ident(getMethods)operator(()operator(\))operator(.)ident(put)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** - * Is this module one that in an included one (e.g. an IncludedModuleWrapper\). - */) - directive(public) type(boolean) ident(isIncluded)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) ident(RubyModule) ident(getNonIncludedClass)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getBaseName)operator(()operator(\)) operator({) - keyword(return) ident(classId)operator(;) - operator(}) - - directive(public) type(void) ident(setBaseName)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(classId) operator(=) ident(name)operator(;) - operator(}) - - directive(private) directive(volatile) pre_type(String) ident(bareName)operator(;) - directive(private) directive(volatile) pre_type(String) ident(fullName)operator(;) - - comment(/** - * Generate a fully-qualified class name or a #-style name for anonymous and singleton classes. - * - * Ruby C equivalent = "classname" - * - * @return The generated class name - */) - directive(public) pre_type(String) ident(getName)operator(()operator(\)) operator({) - keyword(if) operator(()ident(fullName) operator(==) pre_constant(null)operator(\)) operator({) - ident(fullName) operator(=) ident(calculateFullName)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(fullName)operator(;) - operator(}) - - directive(private) pre_type(String) ident(calculateFullName)operator(()operator(\)) operator({) - keyword(if) operator(()ident(getBaseName)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(bareName) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(isClass)operator(()operator(\))operator(\)) operator({) - ident(bareName) operator(=) string<delimiter(")content(#<)delimiter(")> operator(+) string<delimiter(")content(Class)delimiter(")> operator(+) string<delimiter(")content(:01x)delimiter(")> operator(+) pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(bareName) operator(=) string<delimiter(")content(#<)delimiter(")> operator(+) string<delimiter(")content(Module)delimiter(")> operator(+) string<delimiter(")content(:01x)delimiter(")> operator(+) pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(;) - operator(}) - operator(}) - - keyword(return) ident(bareName)operator(;) - operator(}) - - pre_type(String) ident(result) operator(=) ident(getBaseName)operator(()operator(\))operator(;) - ident(RubyClass) ident(objectClass) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(.)ident(getParent)operator(()operator(\))operator(;) ident(p) operator(!=) pre_constant(null) operator(&&) ident(p) operator(!=) ident(objectClass)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getParent)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(pName) operator(=) ident(p)operator(.)ident(getBaseName)operator(()operator(\))operator(;) - comment(// This is needed when the enclosing class or module is a singleton.) - comment(// In that case, we generated a name such as null::Foo, which broke ) - comment(// Marshalling, among others. The correct thing to do in this situation ) - comment(// is to insert the generate the name of form #<Class:01xasdfasd> if ) - comment(// it's a singleton module/class, which this code accomplishes.) - keyword(if)operator(()ident(pName) operator(==) pre_constant(null)operator(\)) operator({) - ident(pName) operator(=) ident(p)operator(.)ident(getName)operator(()operator(\))operator(;) - operator(}) - ident(result) operator(=) ident(pName) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(result)operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * Create a wrapper to use for including the specified module into this one. - * - * Ruby C equivalent = "include_class_new" - * - * @return The module wrapper - */) - directive(public) ident(IncludedModuleWrapper) ident(newIncludeClass)operator(()ident(RubyClass) ident(superClazz)operator(\)) operator({) - ident(IncludedModuleWrapper) ident(includedModule) operator(=) keyword(new) ident(IncludedModuleWrapper)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(superClazz)operator(,) local_variable(this)operator(\))operator(;) - - comment(// include its parent (and in turn that module's parents\)) - keyword(if) operator(()ident(getSuperClass)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(includedModule)operator(.)ident(includeModule)operator(()ident(getSuperClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(includedModule)operator(;) - operator(}) - comment(/** - * Finds a class that is within the current module (or class\). - * - * @param name to be found in this module (or class\) - * @return the class or null if no such class - */) - directive(public) ident(RubyClass) ident(getClass)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(IRubyObject) ident(module)operator(;) - keyword(if) operator(()operator(()ident(module) operator(=) ident(getConstantAt)operator(()ident(name)operator(\))operator(\)) keyword(instanceof) ident(RubyClass)operator(\)) operator({) - keyword(return) operator(()ident(RubyClass)operator(\))ident(module)operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(public) ident(RubyClass) ident(fastGetClass)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - ident(IRubyObject) ident(module)operator(;) - keyword(if) operator(()operator(()ident(module) operator(=) ident(fastGetConstantAt)operator(()ident(internedName)operator(\))operator(\)) keyword(instanceof) ident(RubyClass)operator(\)) operator({) - keyword(return) operator(()ident(RubyClass)operator(\))ident(module)operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** - * Include a new module in this module or class. - * - * @param arg The module to include - */) - directive(public) directive(synchronized) type(void) ident(includeModule)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(assert) ident(arg) operator(!=) pre_constant(null)operator(;) - - ident(testFrozen)operator(()string<delimiter(")content(module)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)operator(()ident(arg) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Wrong argument type )delimiter(")> operator(+) ident(arg)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) - string<delimiter(")content( (expected Module\).)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyModule) ident(module) operator(=) operator(()ident(RubyModule)operator(\)) ident(arg)operator(;) - - comment(// Make sure the module we include does not already exist) - keyword(if) operator(()ident(isSame)operator(()ident(module)operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - ident(infectBy)operator(()ident(module)operator(\))operator(;) - - ident(doIncludeModule)operator(()ident(module)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(defineMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - pre_type(Visibility) ident(visibility) operator(=) ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(initialize)delimiter(")>operator(\)) operator(?) - ident(PRIVATE) operator(:) ident(PUBLIC)operator(;) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(FullFunctionCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(visibility)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(defineAnnotatedMethod)operator(()pre_type(Class) ident(clazz)operator(,) pre_type(String) ident(name)operator(\)) operator({) - comment(// FIXME: This is probably not very efficient, since it loads all methods for each call) - type(boolean) ident(foundMethod) operator(=) pre_constant(false)operator(;) - keyword(for) operator(()pre_type(Method) ident(method) operator(:) ident(clazz)operator(.)ident(getDeclaredMethods)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(method)operator(.)ident(getName)operator(()operator(\))operator(.)ident(equals)operator(()ident(name)operator(\)) operator(&&) ident(defineAnnotatedMethod)operator(()ident(method)operator(,) ident(MethodFactory)operator(.)ident(createFactory)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(\))operator(\))operator(\)) operator({) - ident(foundMethod) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(foundMethod)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(No JRubyMethod present for method )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(on class )delimiter(")> operator(+) ident(clazz)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(defineAnnotatedConstants)operator(()pre_type(Class) ident(clazz)operator(\)) operator({) - pre_type(Field)type([]) ident(declaredFields) operator(=) ident(clazz)operator(.)ident(getDeclaredFields)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Field) ident(field) operator(:) ident(declaredFields)operator(\)) operator({) - keyword(if)operator(()pre_type(Modifier)operator(.)ident(isStatic)operator(()ident(field)operator(.)ident(getModifiers)operator(()operator(\))operator(\))operator(\)) operator({) - ident(defineAnnotatedConstant)operator(()ident(field)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(boolean) ident(defineAnnotatedConstant)operator(()pre_type(Field) ident(field)operator(\)) operator({) - ident(JRubyConstant) ident(jrubyConstant) operator(=) ident(field)operator(.)ident(getAnnotation)operator(()ident(JRubyConstant)operator(.)ident(class)operator(\))operator(;) - - keyword(if) operator(()ident(jrubyConstant) operator(==) pre_constant(null)operator(\)) keyword(return) pre_constant(false)operator(;) - - pre_type(String)type([]) ident(names) operator(=) ident(jrubyConstant)operator(.)ident(value)operator(()operator(\))operator(;) - keyword(if)operator(()ident(names)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(names) operator(=) keyword(new) pre_type(String)type([])operator({)ident(field)operator(.)ident(getName)operator(()operator(\))operator(})operator(;) - operator(}) - - pre_type(Class) ident(tp) operator(=) ident(field)operator(.)ident(getType)operator(()operator(\))operator(;) - ident(IRubyObject) ident(realVal)operator(;) - - keyword(try) operator({) - keyword(if)operator(()ident(tp) operator(==) pre_type(Integer)operator(.)ident(class) operator(||) ident(tp) operator(==) pre_type(Integer)operator(.)ident(TYPE) operator(||) ident(tp) operator(==) pre_type(Short)operator(.)ident(class) operator(||) ident(tp) operator(==) pre_type(Short)operator(.)ident(TYPE) operator(||) ident(tp) operator(==) pre_type(Byte)operator(.)ident(class) operator(||) ident(tp) operator(==) pre_type(Byte)operator(.)ident(TYPE)operator(\)) operator({) - ident(realVal) operator(=) ident(RubyNumeric)operator(.)ident(int2fix)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(field)operator(.)ident(getInt)operator(()pre_constant(null)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(tp) operator(==) pre_type(Boolean)operator(.)ident(class) operator(||) ident(tp) operator(==) pre_type(Boolean)operator(.)ident(TYPE)operator(\)) operator({) - ident(realVal) operator(=) ident(field)operator(.)ident(getBoolean)operator(()pre_constant(null)operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(realVal) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - ident(realVal) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - - keyword(for)operator(()pre_type(String) ident(name) operator(:) ident(names)operator(\)) operator({) - local_variable(this)operator(.)ident(fastSetConstant)operator(()ident(name)operator(,) ident(realVal)operator(\))operator(;) - operator(}) - - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(public) type(void) ident(defineAnnotatedMethods)operator(()pre_type(Class) ident(clazz)operator(\)) operator({) - ident(defineAnnotatedMethodsIndividually)operator(()ident(clazz)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(class) class(MethodClumper) operator({) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(annotatedMethods) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(staticAnnotatedMethods) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(annotatedMethods1_8) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(staticAnnotatedMethods1_8) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(annotatedMethods1_9) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(staticAnnotatedMethods1_9) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>)operator(()operator(\))operator(;) - - directive(public) type(void) ident(clump)operator(()pre_type(Class) ident(cls)operator(\)) operator({) - pre_type(Method)type([]) ident(declaredMethods) operator(=) ident(cls)operator(.)ident(getDeclaredMethods)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Method) ident(method)operator(:) ident(declaredMethods)operator(\)) operator({) - ident(JRubyMethod) ident(anno) operator(=) ident(method)operator(.)ident(getAnnotation)operator(()ident(JRubyMethod)operator(.)ident(class)operator(\))operator(;) - keyword(if) operator(()ident(anno) operator(==) pre_constant(null)operator(\)) keyword(continue)operator(;) - - ident(JavaMethodDescriptor) ident(desc) operator(=) keyword(new) ident(JavaMethodDescriptor)operator(()ident(method)operator(\))operator(;) - - pre_type(String) ident(name) operator(=) ident(anno)operator(.)ident(name)operator(()operator(\))operator(.)ident(length) operator(==) integer(0) operator(?) ident(method)operator(.)ident(getName)operator(()operator(\)) operator(:) ident(anno)operator(.)ident(name)operator(()operator(\))operator([)integer(0)operator(])operator(;) - - pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>) ident(methodDescs)operator(;) - pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(methodsHash) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(desc)operator(.)ident(isStatic)operator(\)) operator({) - keyword(if) operator(()ident(anno)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(\)) operator({) - ident(methodsHash) operator(=) ident(staticAnnotatedMethods1_8)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(anno)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) operator({) - ident(methodsHash) operator(=) ident(staticAnnotatedMethods1_9)operator(;) - operator(}) keyword(else) operator({) - ident(methodsHash) operator(=) ident(staticAnnotatedMethods)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(anno)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_8)operator(\)) operator({) - ident(methodsHash) operator(=) ident(annotatedMethods1_8)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(anno)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) operator({) - ident(methodsHash) operator(=) ident(annotatedMethods1_9)operator(;) - operator(}) keyword(else) operator({) - ident(methodsHash) operator(=) ident(annotatedMethods)operator(;) - operator(}) - operator(}) - - ident(methodDescs) operator(=) ident(methodsHash)operator(.)ident(get)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(methodDescs) operator(==) pre_constant(null)operator(\)) operator({) - ident(methodDescs) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(JavaMethodDescriptor)operator(>)operator(()operator(\))operator(;) - ident(methodsHash)operator(.)ident(put)operator(()ident(name)operator(,) ident(methodDescs)operator(\))operator(;) - operator(}) - - ident(methodDescs)operator(.)ident(add)operator(()ident(desc)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getAnnotatedMethods)operator(()operator(\)) operator({) - keyword(return) ident(annotatedMethods)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getAnnotatedMethods1_8)operator(()operator(\)) operator({) - keyword(return) ident(annotatedMethods1_8)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getAnnotatedMethods1_9)operator(()operator(\)) operator({) - keyword(return) ident(annotatedMethods1_9)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getStaticAnnotatedMethods)operator(()operator(\)) operator({) - keyword(return) ident(staticAnnotatedMethods)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getStaticAnnotatedMethods1_8)operator(()operator(\)) operator({) - keyword(return) ident(staticAnnotatedMethods1_8)operator(;) - operator(}) - - directive(public) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>)operator(>) ident(getStaticAnnotatedMethods1_9)operator(()operator(\)) operator({) - keyword(return) ident(staticAnnotatedMethods1_9)operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(defineAnnotatedMethodsIndividually)operator(()pre_type(Class) ident(clazz)operator(\)) operator({) - pre_type(String) ident(x) operator(=) ident(clazz)operator(.)ident(getSimpleName)operator(()operator(\))operator(;) - ident(TypePopulator) ident(populator) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()ident(RubyInstanceConfig)operator(.)ident(FULL_TRACE_ENABLED)operator(\)) operator({) - comment(// we need full traces, use default (slow\) populator) - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(trace mode, using default populator)delimiter(")>operator(\))operator(;) - ident(populator) operator(=) ident(TypePopulator)operator(.)ident(DEFAULT)operator(;) - operator(}) keyword(else) operator({) - keyword(try) operator({) - pre_type(String) ident(qualifiedName) operator(=) string<delimiter(")content(org.jruby.gen.)delimiter(")> operator(+) ident(clazz)operator(.)ident(getCanonicalName)operator(()operator(\))operator(.)ident(replace)operator(()string<delimiter(')content(.)delimiter(')>operator(,) string<delimiter(')content($)delimiter(')>operator(\))operator(;) - - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(looking for )delimiter(")> operator(+) ident(qualifiedName) operator(+) string<delimiter(")content($Populator)delimiter(")>operator(\))operator(;) - - pre_type(Class) ident(populatorClass) operator(=) pre_type(Class)operator(.)ident(forName)operator(()ident(qualifiedName) operator(+) string<delimiter(")content($Populator)delimiter(")>operator(\))operator(;) - ident(populator) operator(=) operator(()ident(TypePopulator)operator(\))ident(populatorClass)operator(.)ident(newInstance)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()pre_type(Throwable) ident(t)operator(\)) operator({) - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(Could not find it, using default populator)delimiter(")>operator(\))operator(;) - ident(populator) operator(=) ident(TypePopulator)operator(.)ident(DEFAULT)operator(;) - operator(}) - operator(}) - - ident(populator)operator(.)ident(populate)operator(()local_variable(this)operator(,) ident(clazz)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(private) type(void) ident(defineAnnotatedMethodsIndexed)operator(()pre_type(Class) ident(clazz)operator(\)) operator({) - ident(MethodFactory) ident(methodFactory) operator(=) ident(MethodFactory)operator(.)ident(createFactory)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getJRubyClassLoader)operator(()operator(\))operator(\))operator(;) - ident(methodFactory)operator(.)ident(defineIndexedAnnotatedMethods)operator(()local_variable(this)operator(,) ident(clazz)operator(,) ident(methodDefiningCallback)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(MethodFactory)operator(.)ident(MethodDefiningCallback) ident(methodDefiningCallback) operator(=) keyword(new) ident(MethodFactory)operator(.)ident(MethodDefiningCallback)operator(()operator(\)) operator({) - directive(public) type(void) ident(define)operator(()ident(RubyModule) ident(module)operator(,) ident(JavaMethodDescriptor) ident(desc)operator(,) ident(DynamicMethod) ident(dynamicMethod)operator(\)) operator({) - ident(JRubyMethod) ident(jrubyMethod) operator(=) ident(desc)operator(.)ident(anno)operator(;) - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(frame)operator(()operator(\))operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(\)) operator({) - ident(ASTInspector)operator(.)ident(FRAME_AWARE_METHODS)operator(.)ident(add)operator(()ident(name)operator(\))operator(;) - operator(}) - operator(}) - keyword(if)operator(()ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(BOTH) operator(||) - ident(module)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompatVersion)operator(()operator(\)) operator(==) ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\))operator(\)) operator({) - ident(RubyModule) ident(singletonClass)operator(;) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(meta)operator(()operator(\))operator(\)) operator({) - ident(singletonClass) operator(=) ident(module)operator(.)ident(getSingletonClass)operator(()operator(\))operator(;) - ident(dynamicMethod)operator(.)ident(setImplementationClass)operator(()ident(singletonClass)operator(\))operator(;) - - pre_type(String) ident(baseName)operator(;) - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(baseName) operator(=) ident(desc)operator(.)ident(name)operator(;) - ident(singletonClass)operator(.)ident(addMethod)operator(()ident(baseName)operator(,) ident(dynamicMethod)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(baseName) operator(=) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator([)integer(0)operator(])operator(;) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(\)) operator({) - ident(singletonClass)operator(.)ident(addMethod)operator(()ident(name)operator(,) ident(dynamicMethod)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(alias) operator(:) ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(\)) operator({) - ident(singletonClass)operator(.)ident(defineAlias)operator(()ident(alias)operator(,) ident(baseName)operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - pre_type(String) ident(baseName)operator(;) - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(baseName) operator(=) ident(desc)operator(.)ident(name)operator(;) - ident(module)operator(.)ident(addMethod)operator(()ident(baseName)operator(,) ident(dynamicMethod)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(baseName) operator(=) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator([)integer(0)operator(])operator(;) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(\)) operator({) - ident(module)operator(.)ident(addMethod)operator(()ident(name)operator(,) ident(dynamicMethod)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(alias) operator(:) ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(\)) operator({) - ident(module)operator(.)ident(defineAlias)operator(()ident(alias)operator(,) ident(baseName)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(module)operator(()operator(\))operator(\)) operator({) - ident(singletonClass) operator(=) ident(module)operator(.)ident(getSingletonClass)operator(()operator(\))operator(;) - comment(// module/singleton methods are all defined public) - ident(DynamicMethod) ident(moduleMethod) operator(=) ident(dynamicMethod)operator(.)ident(dup)operator(()operator(\))operator(;) - ident(moduleMethod)operator(.)ident(setVisibility)operator(()ident(PUBLIC)operator(\))operator(;) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(baseName) operator(=) ident(desc)operator(.)ident(name)operator(;) - ident(singletonClass)operator(.)ident(addMethod)operator(()ident(desc)operator(.)ident(name)operator(,) ident(moduleMethod)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(baseName) operator(=) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator([)integer(0)operator(])operator(;) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(jrubyMethod)operator(.)ident(name)operator(()operator(\))operator(\)) operator({) - ident(singletonClass)operator(.)ident(addMethod)operator(()ident(name)operator(,) ident(moduleMethod)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(alias) operator(:) ident(jrubyMethod)operator(.)ident(alias)operator(()operator(\))operator(\)) operator({) - ident(singletonClass)operator(.)ident(defineAlias)operator(()ident(alias)operator(,) ident(baseName)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - operator(}) - operator(}) - operator(})operator(;) - - directive(public) type(boolean) ident(defineAnnotatedMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(List)operator(<)ident(JavaMethodDescriptor)operator(>) ident(methods)operator(,) ident(MethodFactory) ident(methodFactory)operator(\)) operator({) - ident(JavaMethodDescriptor) ident(desc) operator(=) ident(methods)operator(.)ident(get)operator(()integer(0)operator(\))operator(;) - keyword(if) operator(()ident(methods)operator(.)ident(size)operator(()operator(\)) operator(==) integer(1)operator(\)) operator({) - keyword(return) ident(defineAnnotatedMethod)operator(()ident(desc)operator(,) ident(methodFactory)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(DynamicMethod) ident(dynamicMethod) operator(=) ident(methodFactory)operator(.)ident(getAnnotatedMethod)operator(()local_variable(this)operator(,) ident(methods)operator(\))operator(;) - ident(methodDefiningCallback)operator(.)ident(define)operator(()local_variable(this)operator(,) ident(desc)operator(,) ident(dynamicMethod)operator(\))operator(;) - - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - directive(public) type(boolean) ident(defineAnnotatedMethod)operator(()pre_type(Method) ident(method)operator(,) ident(MethodFactory) ident(methodFactory)operator(\)) operator({) - ident(JRubyMethod) ident(jrubyMethod) operator(=) ident(method)operator(.)ident(getAnnotation)operator(()ident(JRubyMethod)operator(.)ident(class)operator(\))operator(;) - - keyword(if) operator(()ident(jrubyMethod) operator(==) pre_constant(null)operator(\)) keyword(return) pre_constant(false)operator(;) - - keyword(if)operator(()ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(BOTH) operator(||) - ident(getRuntime)operator(()operator(\))operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompatVersion)operator(()operator(\)) operator(==) ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\))operator(\)) operator({) - ident(JavaMethodDescriptor) ident(desc) operator(=) keyword(new) ident(JavaMethodDescriptor)operator(()ident(method)operator(\))operator(;) - ident(DynamicMethod) ident(dynamicMethod) operator(=) ident(methodFactory)operator(.)ident(getAnnotatedMethod)operator(()local_variable(this)operator(,) ident(desc)operator(\))operator(;) - ident(methodDefiningCallback)operator(.)ident(define)operator(()local_variable(this)operator(,) ident(desc)operator(,) ident(dynamicMethod)operator(\))operator(;) - - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(defineAnnotatedMethod)operator(()ident(JavaMethodDescriptor) ident(desc)operator(,) ident(MethodFactory) ident(methodFactory)operator(\)) operator({) - ident(JRubyMethod) ident(jrubyMethod) operator(=) ident(desc)operator(.)ident(anno)operator(;) - - keyword(if) operator(()ident(jrubyMethod) operator(==) pre_constant(null)operator(\)) keyword(return) pre_constant(false)operator(;) - - keyword(if)operator(()ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\)) operator(==) ident(CompatVersion)operator(.)ident(BOTH) operator(||) - ident(getRuntime)operator(()operator(\))operator(.)ident(getInstanceConfig)operator(()operator(\))operator(.)ident(getCompatVersion)operator(()operator(\)) operator(==) ident(jrubyMethod)operator(.)ident(compat)operator(()operator(\))operator(\)) operator({) - ident(DynamicMethod) ident(dynamicMethod) operator(=) ident(methodFactory)operator(.)ident(getAnnotatedMethod)operator(()local_variable(this)operator(,) ident(desc)operator(\))operator(;) - ident(methodDefiningCallback)operator(.)ident(define)operator(()local_variable(this)operator(,) ident(desc)operator(,) ident(dynamicMethod)operator(\))operator(;) - - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(void) ident(defineFastMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - pre_type(Visibility) ident(visibility) operator(=) ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(initialize)delimiter(")>operator(\)) operator(?) - ident(PRIVATE) operator(:) ident(PUBLIC)operator(;) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(SimpleCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(visibility)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(defineFastMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(,) pre_type(Visibility) ident(visibility)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(SimpleCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(visibility)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(definePrivateMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(FullFunctionCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(PRIVATE)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(defineFastPrivateMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(SimpleCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(PRIVATE)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(defineFastProtectedMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(SimpleCallbackMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(PROTECTED)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(undefineMethod)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) ident(UndefinedMethod)operator(.)ident(getInstance)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_undef - * - */) - directive(public) type(void) ident(undef)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\)) ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) keyword(new) exception(SecurityException)operator(()string<delimiter(")content(Insecure: can't undef)delimiter(")>operator(\))operator(;) - operator(}) - ident(testFrozen)operator(()string<delimiter(")content(module)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(__id__)delimiter(")>operator(\)) operator(||) ident(name)operator(.)ident(equals)operator(()string<delimiter(")content(__send__)delimiter(")>operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(UNDEFINING_BAD)operator(,) string<delimiter(")content(undefining `)delimiter(")>operator(+) ident(name) operator(+)string<delimiter(")content(' may cause serious problem)delimiter(")>operator(\))operator(;) - operator(}) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(s0) operator(=) string<delimiter(")content( class)delimiter(")>operator(;) - ident(RubyModule) ident(c) operator(=) local_variable(this)operator(;) - - keyword(if) operator(()ident(c)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) operator(()operator(()ident(MetaClass)operator(\))ident(c)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(obj) operator(!=) pre_constant(null) operator(&&) ident(obj) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - ident(c) operator(=) operator(()ident(RubyModule)operator(\)) ident(obj)operator(;) - ident(s0) operator(=) string<delimiter(")delimiter(")>operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(c)operator(.)ident(isModule)operator(()operator(\))operator(\)) operator({) - ident(s0) operator(=) string<delimiter(")content( module)delimiter(")>operator(;) - operator(}) - - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(Undefined method )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( for)delimiter(")> operator(+) ident(s0) operator(+) string<delimiter(")content( ')delimiter(")> operator(+) ident(c)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - ident(addMethod)operator(()ident(name)operator(,) ident(UndefinedMethod)operator(.)ident(getInstance)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(singleton) operator(=) operator(()operator(()ident(MetaClass)operator(\))local_variable(this)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(;) - ident(singleton)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(singleton_method_undefined)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(method_undefined)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(include?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(include_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(arg)operator(.)ident(isModule)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(arg)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getModule)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(()ident(p) keyword(instanceof) ident(IncludedModuleWrapper)operator(\)) operator(&&) operator(()operator(()ident(IncludedModuleWrapper)operator(\)) ident(p)operator(\))operator(.)ident(getNonIncludedClass)operator(()operator(\)) operator(==) ident(arg)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(// TODO: Consider a better way of synchronizing ) - directive(public) type(void) ident(addMethod)operator(()pre_type(String) ident(name)operator(,) ident(DynamicMethod) ident(method)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\)) ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't define method)delimiter(")>operator(\))operator(;) - operator(}) - ident(testFrozen)operator(()string<delimiter(")content(class/module)delimiter(")>operator(\))operator(;) - - comment(// We can safely reference methods here instead of doing getMethods(\) since if we) - comment(// are adding we are not using a IncludedModuleWrapper.) - directive(synchronized)operator(()ident(getMethods)operator(()operator(\))operator(\)) operator({) - comment(// If we add a method which already is cached in this class, then we should update the ) - comment(// cachemap so it stays up to date.) - ident(DynamicMethod) ident(existingMethod) operator(=) ident(getMethods)operator(()operator(\))operator(.)ident(put)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - keyword(if) operator(()ident(existingMethod) operator(!=) pre_constant(null)operator(\)) operator({) - ident(runtime)operator(.)ident(getCacheMap)operator(()operator(\))operator(.)ident(remove)operator(()ident(existingMethod)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - directive(public) type(void) ident(removeMethod)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\)) ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't remove method)delimiter(")>operator(\))operator(;) - operator(}) - ident(testFrozen)operator(()string<delimiter(")content(class/module)delimiter(")>operator(\))operator(;) - - comment(// We can safely reference methods here instead of doing getMethods(\) since if we) - comment(// are adding we are not using a IncludedModuleWrapper.) - directive(synchronized)operator(()ident(getMethods)operator(()operator(\))operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) operator(()ident(DynamicMethod)operator(\)) ident(getMethods)operator(()operator(\))operator(.)ident(remove)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(method) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(method ')delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(' not defined in )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - operator(}) - - ident(runtime)operator(.)ident(getCacheMap)operator(()operator(\))operator(.)ident(remove)operator(()ident(method)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(singleton) operator(=) operator(()operator(()ident(MetaClass)operator(\))local_variable(this)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(;) - ident(singleton)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(singleton_method_removed)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(method_removed)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */) - directive(public) ident(DynamicMethod) ident(searchMethod)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(getMethods)operator(()operator(\))operator(.)ident(get)operator(()ident(name)operator(\))operator(;) - - keyword(if) operator(()ident(method) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(method)operator(;) - - keyword(return) ident(superClass) operator(==) pre_constant(null) operator(?) ident(UndefinedMethod)operator(.)ident(getInstance)operator(()operator(\)) operator(:) ident(superClass)operator(.)ident(searchMethod)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */) - directive(public) ident(DynamicMethod) ident(retrieveMethod)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(getMethods)operator(()operator(\))operator(.)ident(get)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */) - directive(public) ident(RubyModule) ident(findImplementer)operator(()ident(RubyModule) ident(clazz)operator(\)) operator({) - keyword(for) operator(()ident(RubyModule) ident(searchModule) operator(=) local_variable(this)operator(;) ident(searchModule) operator(!=) pre_constant(null)operator(;) ident(searchModule) operator(=) ident(searchModule)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(searchModule)operator(.)ident(isSame)operator(()ident(clazz)operator(\))operator(\)) operator({) - keyword(return) ident(searchModule)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(public) type(void) ident(addModuleFunction)operator(()pre_type(String) ident(name)operator(,) ident(DynamicMethod) ident(method)operator(\)) operator({) - ident(addMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(addMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** rb_define_module_function - * - */) - directive(public) type(void) ident(defineModuleFunction)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(definePrivateMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** rb_define_module_function - * - */) - directive(public) type(void) ident(definePublicModuleFunction)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(defineMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** rb_define_module_function - * - */) - directive(public) type(void) ident(defineFastModuleFunction)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(defineFastPrivateMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** rb_define_module_function - * - */) - directive(public) type(void) ident(defineFastPublicModuleFunction)operator(()pre_type(String) ident(name)operator(,) pre_type(Callback) ident(method)operator(\)) operator({) - ident(defineFastMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastMethod)operator(()ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - - comment(/** rb_alias - * - */) - directive(public) directive(synchronized) type(void) ident(defineAlias)operator(()pre_type(String) ident(name)operator(,) pre_type(String) ident(oldName)operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(module)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(oldName)operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()local_variable(this) operator(==) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - operator(}) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(oldName)operator(\))operator(;) - ident(DynamicMethod) ident(oldMethod) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(isModule)operator(()operator(\))operator(\)) operator({) - ident(method) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(searchMethod)operator(()ident(oldName)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(undefined method `)delimiter(")> operator(+) ident(oldName) operator(+) string<delimiter(")content(' for )delimiter(")> operator(+) - operator(()ident(isModule)operator(()operator(\)) operator(?) string<delimiter(")content(module)delimiter(")> operator(:) string<delimiter(")content(class)delimiter(")>operator(\)) operator(+) string<delimiter(")content( `)delimiter(")> operator(+) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(,) ident(oldName)operator(\))operator(;) - operator(}) - operator(}) - ident(CacheMap) ident(cacheMap) operator(=) ident(runtime)operator(.)ident(getCacheMap)operator(()operator(\))operator(;) - ident(cacheMap)operator(.)ident(remove)operator(()ident(method)operator(\))operator(;) - ident(cacheMap)operator(.)ident(remove)operator(()ident(oldMethod)operator(\))operator(;) - keyword(if) operator(()ident(oldMethod) operator(!=) ident(oldMethod)operator(.)ident(getRealMethod)operator(()operator(\))operator(\)) operator({) - ident(cacheMap)operator(.)ident(remove)operator(()ident(oldMethod)operator(.)ident(getRealMethod)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(putMethod)operator(()ident(name)operator(,) keyword(new) ident(AliasMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(oldName)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(synchronized) type(void) ident(defineAliases)operator(()pre_type(List)operator(<)pre_type(String)operator(>) ident(aliases)operator(,) pre_type(String) ident(oldName)operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(module)delimiter(")>operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()local_variable(this) operator(==) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - operator(}) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(oldName)operator(\))operator(;) - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(isModule)operator(()operator(\))operator(\)) operator({) - ident(method) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(searchMethod)operator(()ident(oldName)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(undefined method `)delimiter(")> operator(+) ident(oldName) operator(+) string<delimiter(")content(' for )delimiter(")> operator(+) - operator(()ident(isModule)operator(()operator(\)) operator(?) string<delimiter(")content(module)delimiter(")> operator(:) string<delimiter(")content(class)delimiter(")>operator(\)) operator(+) string<delimiter(")content( `)delimiter(")> operator(+) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(,) ident(oldName)operator(\))operator(;) - operator(}) - operator(}) - ident(CacheMap) ident(cacheMap) operator(=) ident(runtime)operator(.)ident(getCacheMap)operator(()operator(\))operator(;) - ident(cacheMap)operator(.)ident(remove)operator(()ident(method)operator(\))operator(;) - keyword(for) operator(()pre_type(String) ident(name)operator(:) ident(aliases)operator(\)) operator({) - keyword(if) operator(()ident(oldName)operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) keyword(continue)operator(;) - ident(DynamicMethod) ident(oldMethod) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - ident(cacheMap)operator(.)ident(remove)operator(()ident(oldMethod)operator(\))operator(;) - keyword(if) operator(()ident(oldMethod) operator(!=) ident(oldMethod)operator(.)ident(getRealMethod)operator(()operator(\))operator(\)) operator({) - ident(cacheMap)operator(.)ident(remove)operator(()ident(oldMethod)operator(.)ident(getRealMethod)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(putMethod)operator(()ident(name)operator(,) keyword(new) ident(AliasMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(oldName)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** this method should be used only by interpreter or compiler - * - */) - directive(public) ident(RubyClass) ident(defineOrGetClassUnder)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClazz)operator(\)) operator({) - comment(// This method is intended only for defining new classes in Ruby code,) - comment(// so it uses the allocator of the specified superclass or default to) - comment(// the Object allocator. It should NOT be used to define classes that require a native allocator.) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(classObj) operator(=) ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - ident(RubyClass) ident(clazz)operator(;) - - keyword(if) operator(()ident(classObj) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(classObj) keyword(instanceof) ident(RubyClass)operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(name) operator(+) string<delimiter(")content( is not a class)delimiter(")>operator(\))operator(;) - ident(clazz) operator(=) operator(()ident(RubyClass)operator(\))ident(classObj)operator(;) - - keyword(if) operator(()ident(superClazz) operator(!=) pre_constant(null)operator(\)) operator({) - ident(RubyClass) ident(tmp) operator(=) ident(clazz)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - keyword(while) operator(()ident(tmp) operator(!=) pre_constant(null) operator(&&) ident(tmp)operator(.)ident(isIncluded)operator(()operator(\))operator(\)) ident(tmp) operator(=) ident(tmp)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) comment(// need to skip IncludedModuleWrappers) - keyword(if) operator(()ident(tmp) operator(!=) pre_constant(null)operator(\)) ident(tmp) operator(=) ident(tmp)operator(.)ident(getRealClass)operator(()operator(\))operator(;) - keyword(if) operator(()ident(tmp) operator(!=) ident(superClazz)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(superclass mismatch for class )delimiter(")> operator(+) ident(name)operator(\))operator(;) - comment(// superClazz = null;) - operator(}) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(extending class prohibited)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(classProviders) operator(!=) pre_constant(null) operator(&&) operator(()ident(clazz) operator(=) ident(searchProvidersForClass)operator(()ident(name)operator(,) ident(superClazz)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - comment(// reopen a java class) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(superClazz) operator(==) pre_constant(null)operator(\)) ident(superClazz) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - ident(clazz) operator(=) ident(RubyClass)operator(.)ident(newClass)operator(()ident(runtime)operator(,) ident(superClazz)operator(,) ident(name)operator(,) ident(superClazz)operator(.)ident(getAllocator)operator(()operator(\))operator(,) local_variable(this)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(return) ident(clazz)operator(;) - operator(}) - - comment(/** this method should be used only by interpreter or compiler - * - */) - directive(public) ident(RubyModule) ident(defineOrGetModuleUnder)operator(()pre_type(String) ident(name)operator(\)) operator({) - comment(// This method is intended only for defining new modules in Ruby code) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(moduleObj) operator(=) ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - ident(RubyModule) ident(module)operator(;) - keyword(if) operator(()ident(moduleObj) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(moduleObj)operator(.)ident(isModule)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(name) operator(+) string<delimiter(")content( is not a module)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()string<delimiter(")content(extending module prohibited)delimiter(")>operator(\))operator(;) - ident(module) operator(=) operator(()ident(RubyModule)operator(\))ident(moduleObj)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(classProviders) operator(!=) pre_constant(null) operator(&&) operator(()ident(module) operator(=) ident(searchProvidersForModule)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - comment(// reopen a java module) - operator(}) keyword(else) operator({) - ident(module) operator(=) ident(RubyModule)operator(.)ident(newModule)operator(()ident(runtime)operator(,) ident(name)operator(,) local_variable(this)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) ident(module)operator(;) - operator(}) - - comment(/** rb_define_class_under - * this method should be used only as an API to define/open nested classes - */) - directive(public) ident(RubyClass) ident(defineClassUnder)operator(()pre_type(String) ident(name)operator(,) ident(RubyClass) ident(superClass)operator(,) ident(ObjectAllocator) ident(allocator)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(defineClassUnder)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(allocator)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** rb_define_module_under - * this method should be used only as an API to define/open nested module - */) - directive(public) ident(RubyModule) ident(defineModuleUnder)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(defineModuleUnder)operator(()ident(name)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(// FIXME: create AttrReaderMethod, AttrWriterMethod, for faster attr access) - directive(private) type(void) ident(addAccessor)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(internedName)operator(,) type(boolean) ident(readable)operator(,) type(boolean) ident(writeable)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - comment(// Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed) - pre_type(Visibility) ident(attributeScope) operator(=) ident(context)operator(.)ident(getCurrentVisibility)operator(()operator(\))operator(;) - keyword(if) operator(()ident(attributeScope) operator(==) ident(PRIVATE)operator(\)) operator({) - comment(//FIXME warning) - operator(}) keyword(else) keyword(if) operator(()ident(attributeScope) operator(==) ident(MODULE_FUNCTION)operator(\)) operator({) - ident(attributeScope) operator(=) ident(PRIVATE)operator(;) - comment(// FIXME warning) - operator(}) - directive(final) pre_type(String) ident(variableName) operator(=) operator(()string<delimiter(")content(@)delimiter(")> operator(+) ident(internedName)operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) - keyword(if) operator(()ident(readable)operator(\)) operator({) - comment(// FIXME: should visibility be set to current visibility?) - ident(addMethod)operator(()ident(internedName)operator(,) keyword(new) ident(JavaMethod)operator(()local_variable(this)operator(,) ident(PUBLIC)operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(0)operator(\)) ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(runtime)operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(0)operator(\))operator(;) - - ident(IRubyObject) ident(variable) operator(=) ident(self)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastGetInstanceVariable)operator(()ident(variableName)operator(\))operator(;) - - keyword(return) ident(variable) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(variable)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(noArguments)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(method_added)delimiter(")>operator(,) ident(runtime)operator(.)ident(fastNewSymbol)operator(()ident(internedName)operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(writeable)operator(\)) operator({) - ident(internedName) operator(=) operator(()ident(internedName) operator(+) string<delimiter(")content(=)delimiter(")>operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) - comment(// FIXME: should visibility be set to current visibility?) - ident(addMethod)operator(()ident(internedName)operator(,) keyword(new) ident(JavaMethod)operator(()local_variable(this)operator(,) ident(PUBLIC)operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - comment(// ENEBO: Can anyone get args to be anything but length 1?) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(1)operator(\)) ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(runtime)operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - - keyword(return) ident(self)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastSetInstanceVariable)operator(()ident(variableName)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(singleArgument)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(method_added)delimiter(")>operator(,) ident(runtime)operator(.)ident(fastNewSymbol)operator(()ident(internedName)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** set_method_visibility - * - */) - directive(public) type(void) ident(setMethodVisibility)operator(()ident(IRubyObject)type([]) ident(methods)operator(,) pre_type(Visibility) ident(visibility)operator(\)) operator({) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't change method visibility)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(methods)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(exportMethod)operator(()ident(methods)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(,) ident(visibility)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_export_method - * - */) - directive(public) type(void) ident(exportMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Visibility) ident(visibility)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - operator(}) - - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(undefined method ')delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(' for )delimiter(")> operator(+) - operator(()ident(isModule)operator(()operator(\)) operator(?) string<delimiter(")content(module)delimiter(")> operator(:) string<delimiter(")content(class)delimiter(")>operator(\)) operator(+) string<delimiter(")content( ')delimiter(")> operator(+) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(!=) ident(visibility)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(method)operator(.)ident(getImplementationClass)operator(()operator(\))operator(\)) operator({) - ident(method)operator(.)ident(setVisibility)operator(()ident(visibility)operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// FIXME: Why was this using a FullFunctionCallbackMethod before that did callSuper?) - ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(WrapperMethod)operator(()local_variable(this)operator(,) ident(method)operator(,) ident(visibility)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** - * MRI: rb_method_boundp - * - */) - directive(public) type(boolean) ident(isMethodBound)operator(()pre_type(String) ident(name)operator(,) type(boolean) ident(checkVisibility)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(return) operator(!)operator(()ident(checkVisibility) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(==) ident(PRIVATE)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(newMethod)operator(()ident(IRubyObject) ident(receiver)operator(,) pre_type(String) ident(name)operator(,) type(boolean) ident(bound)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(undefined method `)delimiter(")> operator(+) ident(name) operator(+) - string<delimiter(")content(' for class `)delimiter(")> operator(+) local_variable(this)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(')delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - ident(RubyModule) ident(implementationModule) operator(=) ident(method)operator(.)ident(getImplementationClass)operator(()operator(\))operator(;) - ident(RubyModule) ident(originModule) operator(=) local_variable(this)operator(;) - keyword(while) operator(()ident(originModule) operator(!=) ident(implementationModule) operator(&&) ident(originModule)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(originModule) operator(=) operator(()operator(()ident(MetaClass)operator(\))ident(originModule)operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(;) - operator(}) - - ident(RubyMethod) ident(newMethod) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(bound)operator(\)) operator({) - ident(newMethod) operator(=) ident(RubyMethod)operator(.)ident(newMethod)operator(()ident(implementationModule)operator(,) ident(name)operator(,) ident(originModule)operator(,) ident(name)operator(,) ident(method)operator(,) ident(receiver)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(newMethod) operator(=) ident(RubyUnboundMethod)operator(.)ident(newUnboundMethod)operator(()ident(implementationModule)operator(,) ident(name)operator(,) ident(originModule)operator(,) ident(name)operator(,) ident(method)operator(\))operator(;) - operator(}) - ident(newMethod)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - - keyword(return) ident(newMethod)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(define_method)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(define_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) ident(arg0)operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) - ident(DynamicMethod) ident(newMethod) operator(=) pre_constant(null)operator(;) - pre_type(Visibility) ident(visibility) operator(=) ident(context)operator(.)ident(getCurrentVisibility)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(visibility) operator(==) ident(MODULE_FUNCTION)operator(\)) ident(visibility) operator(=) ident(PRIVATE)operator(;) - ident(RubyProc) ident(proc) operator(=) ident(runtime)operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(,) ident(block)operator(\))operator(;) - - comment(// a normal block passed to define_method changes to do arity checking; make it a lambda) - ident(proc)operator(.)ident(getBlock)operator(()operator(\))operator(.)ident(type) operator(=) ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(;) - - ident(newMethod) operator(=) ident(createProcMethod)operator(()ident(name)operator(,) ident(visibility)operator(,) ident(proc)operator(\))operator(;) - - ident(RuntimeHelpers)operator(.)ident(addInstanceMethod)operator(()local_variable(this)operator(,) ident(name)operator(,) ident(newMethod)operator(,) ident(context)operator(.)ident(getPreviousVisibility)operator(()operator(\))operator(,) ident(context)operator(,) ident(runtime)operator(\))operator(;) - - keyword(return) ident(proc)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(define_method)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(define_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(body)operator(;) - pre_type(String) ident(name) operator(=) ident(arg0)operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) - ident(DynamicMethod) ident(newMethod) operator(=) pre_constant(null)operator(;) - pre_type(Visibility) ident(visibility) operator(=) ident(context)operator(.)ident(getCurrentVisibility)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(visibility) operator(==) ident(MODULE_FUNCTION)operator(\)) ident(visibility) operator(=) ident(PRIVATE)operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getProc)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(arg1)operator(\))operator(\)) operator({) - comment(// double-testing args.length here, but it avoids duplicating the proc-setup code in two places) - ident(RubyProc) ident(proc) operator(=) operator(()ident(RubyProc)operator(\))ident(arg1)operator(;) - ident(body) operator(=) ident(proc)operator(;) - - ident(newMethod) operator(=) ident(createProcMethod)operator(()ident(name)operator(,) ident(visibility)operator(,) ident(proc)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(runtime)operator(.)ident(getMethod)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(arg1)operator(\))operator(\)) operator({) - ident(RubyMethod) ident(method) operator(=) operator(()ident(RubyMethod)operator(\))ident(arg1)operator(;) - ident(body) operator(=) ident(method)operator(;) - - ident(newMethod) operator(=) keyword(new) ident(MethodMethod)operator(()local_variable(this)operator(,) ident(method)operator(.)ident(unbind)operator(()pre_constant(null)operator(\))operator(,) ident(visibility)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(arg1)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Proc/Method\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(RuntimeHelpers)operator(.)ident(addInstanceMethod)operator(()local_variable(this)operator(,) ident(name)operator(,) ident(newMethod)operator(,) ident(context)operator(.)ident(getPreviousVisibility)operator(()operator(\))operator(,) ident(context)operator(,) ident(runtime)operator(\))operator(;) - - keyword(return) ident(body)operator(;) - operator(}) - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(define_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(define_method)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(define_method)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong # of arguments()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+) string<delimiter(")content( for 2\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(DynamicMethod) ident(createProcMethod)operator(()pre_type(String) ident(name)operator(,) pre_type(Visibility) ident(visibility)operator(,) ident(RubyProc) ident(proc)operator(\)) operator({) - ident(Block) ident(block) operator(=) ident(proc)operator(.)ident(getBlock)operator(()operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getFrame)operator(()operator(\))operator(.)ident(setKlazz)operator(()local_variable(this)operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getFrame)operator(()operator(\))operator(.)ident(setName)operator(()ident(name)operator(\))operator(;) - - ident(StaticScope) ident(scope) operator(=) ident(block)operator(.)ident(getBody)operator(()operator(\))operator(.)ident(getStaticScope)operator(()operator(\))operator(;) - - comment(// for zsupers in define_method (blech!\) we tell the proc scope to act as the "argument" scope) - ident(scope)operator(.)ident(setArgumentScope)operator(()pre_constant(true)operator(\))operator(;) - - ident(Arity) ident(arity) operator(=) ident(block)operator(.)ident(arity)operator(()operator(\))operator(;) - comment(// just using required is broken...but no more broken than before zsuper refactoring) - ident(scope)operator(.)ident(setRequiredArgs)operator(()ident(arity)operator(.)ident(required)operator(()operator(\))operator(\))operator(;) - - keyword(if)operator(()operator(!)ident(arity)operator(.)ident(isFixed)operator(()operator(\))operator(\)) operator({) - ident(scope)operator(.)ident(setRestArg)operator(()ident(arity)operator(.)ident(required)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) keyword(new) ident(ProcMethod)operator(()local_variable(this)operator(,) ident(proc)operator(,) ident(visibility)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(executeUnder)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(Callback) ident(method)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(context)operator(.)ident(preExecuteUnder)operator(()local_variable(this)operator(,) ident(block)operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(method)operator(.)ident(execute)operator(()local_variable(this)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postExecuteUnder)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(name)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(name)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(getBaseName)operator(()operator(\)) operator(==) pre_constant(null) operator(?) string<delimiter(")delimiter(")> operator(:) ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(cloneMethods)operator(()ident(RubyModule) ident(clone)operator(\)) operator({) - ident(RubyModule) ident(realType) operator(=) local_variable(this)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Map)operator(.)ident(Entry)operator(<)pre_type(String)operator(,) ident(DynamicMethod)operator(>) ident(entry) operator(:) ident(getMethods)operator(()operator(\))operator(.)ident(entrySet)operator(()operator(\))operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(entry)operator(.)ident(getValue)operator(()operator(\))operator(;) - comment(// Do not clone cached methods) - comment(// FIXME: MRI copies all methods here) - keyword(if) operator(()ident(method)operator(.)ident(getImplementationClass)operator(()operator(\)) operator(==) ident(realType) operator(||) ident(method) keyword(instanceof) ident(UndefinedMethod)operator(\)) operator({) - - comment(// A cloned method now belongs to a new class. Set it.) - comment(// TODO: Make DynamicMethod immutable) - ident(DynamicMethod) ident(clonedMethod) operator(=) ident(method)operator(.)ident(dup)operator(()operator(\))operator(;) - ident(clonedMethod)operator(.)ident(setImplementationClass)operator(()ident(clone)operator(\))operator(;) - ident(clone)operator(.)ident(putMethod)operator(()ident(entry)operator(.)ident(getKey)operator(()operator(\))operator(,) ident(clonedMethod)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(clone)operator(;) - operator(}) - - comment(/** rb_mod_init_copy - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\)) operator({) - local_variable(super)operator(.)ident(initialize_copy)operator(()ident(original)operator(\))operator(;) - - ident(RubyModule) ident(originalModule) operator(=) operator(()ident(RubyModule)operator(\))ident(original)operator(;) - - keyword(if) operator(()operator(!)ident(getMetaClass)operator(()operator(\))operator(.)ident(isSingleton)operator(()operator(\))operator(\)) ident(setMetaClass)operator(()ident(originalModule)operator(.)ident(getSingletonClassClone)operator(()operator(\))operator(\))operator(;) - ident(setSuperClass)operator(()ident(originalModule)operator(.)ident(getSuperClass)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(originalModule)operator(.)ident(hasVariables)operator(()operator(\))operator(\))operator({) - ident(syncVariables)operator(()ident(originalModule)operator(.)ident(getVariableList)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(originalModule)operator(.)ident(cloneMethods)operator(()local_variable(this)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_mod_included_modules - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(included_modules)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(included_modules)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) ident(getSuperClass)operator(()operator(\))operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(p)operator(.)ident(isIncluded)operator(()operator(\))operator(\)) operator({) - ident(ary)operator(.)ident(append)operator(()ident(p)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_mod_ancestors - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ancestors)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(ancestors)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(getAncestorList)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) ident(RubyArray) ident(ancestors)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(getAncestorList)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(getAncestorList)operator(()operator(\)) operator({) - pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if)operator(()operator(!)ident(p)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(p)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(list)operator(;) - operator(}) - - directive(public) type(boolean) ident(hasModuleInHierarchy)operator(()ident(RubyModule) ident(type)operator(\)) operator({) - comment(// XXX: This check previously used callMethod("=="\) to check for equality between classes) - comment(// when scanning the hierarchy. However the == check may be safe; we should only ever have) - comment(// one instance bound to a given type/constant. If it's found to be unsafe, examine ways) - comment(// to avoid the == call.) - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(p)operator(.)ident(getNonIncludedClass)operator(()operator(\)) operator(==) ident(type)operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(hashCode)operator(()operator(\)) operator({) - keyword(return) ident(id)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(id)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if)operator(()ident(isSingleton)operator(()operator(\))operator(\))operator({) - ident(IRubyObject) ident(attached) operator(=) operator(()operator(()ident(MetaClass)operator(\))local_variable(this)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(;) - pre_type(StringBuilder) ident(buffer) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(#<Class:)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(attached) operator(!=) pre_constant(null)operator(\)) operator({) comment(// FIXME: figure out why we get null sometimes) - keyword(if)operator(()ident(attached) keyword(instanceof) ident(RubyClass) operator(||) ident(attached) keyword(instanceof) ident(RubyModule)operator(\))operator({) - ident(buffer)operator(.)ident(append)operator(()ident(attached)operator(.)ident(inspect)operator(()operator(\))operator(\))operator(;) - operator(})keyword(else)operator({) - ident(buffer)operator(.)ident(append)operator(()ident(attached)operator(.)ident(anyToString)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buffer)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_mod_eqq - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(===)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(RubyBoolean) ident(op_eqq)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isInstance)operator(()ident(obj)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) local_variable(super)operator(.)ident(op_equal)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_freeze - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(freeze)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(to_s)operator(()operator(\))operator(;) - keyword(return) local_variable(super)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_le - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(compared with non class/module)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(isKindOfModule)operator(()operator(()ident(RubyModule)operator(\)) ident(obj)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(()operator(()ident(RubyModule)operator(\)) ident(obj)operator(\))operator(.)ident(isKindOfModule)operator(()local_variable(this)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_mod_lt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(obj) operator(==) local_variable(this) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(op_le)operator(()ident(obj)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_ge - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(compared with non class/module)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()operator(()ident(RubyModule)operator(\)) ident(obj)operator(\))operator(.)ident(op_le)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_gt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(obj) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(op_ge)operator(()ident(obj)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(obj)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(RubyModule) ident(module) operator(=) operator(()ident(RubyModule)operator(\)) ident(obj)operator(;) - - keyword(if) operator(()ident(module)operator(.)ident(isKindOfModule)operator(()local_variable(this)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()local_variable(this)operator(.)ident(isKindOfModule)operator(()ident(module)operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(-)integer(1)operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(isKindOfModule)operator(()ident(RubyModule) ident(type)operator(\)) operator({) - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(p)operator(.)ident(isSame)operator(()ident(type)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(protected) type(boolean) ident(isSame)operator(()ident(RubyModule) ident(module)operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(module)operator(;) - operator(}) - - comment(/** rb_mod_initialize - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - comment(// class and module bodies default to public, so make the block's visibility public. JRUBY-1185.) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()ident(PUBLIC)operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(,) local_variable(this)operator(,) local_variable(this)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(addReadWriteAttribute)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(addAccessor)operator(()ident(context)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(true)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(addReadAttribute)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(addAccessor)operator(()ident(context)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(true)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(addWriteAttribute)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - ident(addAccessor)operator(()ident(context)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_attr - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(attr)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(attr)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(boolean) ident(writeable) operator(=) ident(args)operator(.)ident(length) operator(>) integer(1) operator(?) ident(args)operator([)integer(1)operator(])operator(.)ident(isTrue)operator(()operator(\)) operator(:) pre_constant(false)operator(;) - - ident(addAccessor)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(true)operator(,) ident(writeable)operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * @deprecated - */) - directive(public) ident(IRubyObject) ident(attr_reader)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(attr_reader)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_attr_reader - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(attr_reader)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(attr_reader)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(addAccessor)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(true)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_mod_attr_writer - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(attr_writer)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(attr_writer)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(addAccessor)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * @deprecated - */) - directive(public) ident(IRubyObject) ident(attr_accessor)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(attr_accessor)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_attr_accessor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(attr_accessor)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(reads) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(IRubyObject) ident(attr_accessor)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - comment(// This is almost always already interned, since it will be called with a symbol in most cases) - comment(// but when created from Java code, we might get an argument that needs to be interned.) - comment(// addAccessor has as a precondition that the string MUST be interned) - ident(addAccessor)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) pre_constant(true)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Get a list of all instance methods names of the provided visibility unless not is true, then - * get all methods which are not the provided - * - * @param args passed into one of the Ruby instance_method methods - * @param visibility to find matching instance methods against - * @param not if true only find methods not matching supplied visibility - * @return a RubyArray of instance method names - */) - directive(private) ident(RubyArray) ident(instance_methods)operator(()ident(IRubyObject)type([]) ident(args)operator(,) directive(final) pre_type(Visibility) ident(visibility)operator(,) type(boolean) ident(not)operator(\)) operator({) - type(boolean) ident(includeSuper) operator(=) ident(args)operator(.)ident(length) operator(>) integer(0) operator(?) ident(args)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\)) operator(:) pre_constant(true)operator(;) - ident(RubyArray) ident(ary) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - pre_type(Set)operator(<)pre_type(String)operator(>) ident(seen) operator(=) keyword(new) pre_type(HashSet)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(RubyModule) ident(type) operator(=) local_variable(this)operator(;) ident(type) operator(!=) pre_constant(null)operator(;) ident(type) operator(=) ident(type)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - ident(RubyModule) ident(realType) operator(=) ident(type)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator) ident(iter) operator(=) ident(type)operator(.)ident(getMethods)operator(()operator(\))operator(.)ident(entrySet)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(Map)operator(.)ident(Entry) ident(entry) operator(=) operator(()pre_type(Map)operator(.)ident(Entry)operator(\)) ident(iter)operator(.)ident(next)operator(()operator(\))operator(;) - ident(DynamicMethod) ident(method) operator(=) operator(()ident(DynamicMethod)operator(\)) ident(entry)operator(.)ident(getValue)operator(()operator(\))operator(;) - pre_type(String) ident(methodName) operator(=) operator(()pre_type(String)operator(\)) ident(entry)operator(.)ident(getKey)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!) ident(seen)operator(.)ident(contains)operator(()ident(methodName)operator(\))operator(\)) operator({) - ident(seen)operator(.)ident(add)operator(()ident(methodName)operator(\))operator(;) - - keyword(if) operator(()ident(method)operator(.)ident(getImplementationClass)operator(()operator(\)) operator(==) ident(realType) operator(&&) - operator(()operator(!)ident(not) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(==) ident(visibility) operator(||) operator(()ident(not) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(!=) ident(visibility)operator(\))operator(\)) operator(&&) - operator(!) ident(method)operator(.)ident(isUndefined)operator(()operator(\))operator(\)) operator({) - - ident(ary)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(methodName)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(includeSuper)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - keyword(return) ident(ary)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(instance_methods)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(instance_methods)operator(()ident(args)operator(,) ident(PRIVATE)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(public_instance_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(public_instance_methods)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(instance_methods)operator(()ident(args)operator(,) ident(PUBLIC)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_method)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(instance_method)operator(()ident(IRubyObject) ident(symbol)operator(\)) operator({) - keyword(return) ident(newMethod)operator(()pre_constant(null)operator(,) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_class_protected_instance_methods - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(protected_instance_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(protected_instance_methods)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(instance_methods)operator(()ident(args)operator(,) ident(PROTECTED)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_class_private_instance_methods - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(private_instance_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(private_instance_methods)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(instance_methods)operator(()ident(args)operator(,) ident(PRIVATE)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_append_features - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(append_features)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(RubyModule) ident(append_features)operator(()ident(IRubyObject) ident(module)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(module) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - comment(// MRI error message says Class, even though Module is ok ) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(module)operator(,)ident(getRuntime)operator(()operator(\))operator(.)ident(getClassClass)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(()operator(()ident(RubyModule)operator(\)) ident(module)operator(\))operator(.)ident(includeModule)operator(()local_variable(this)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_mod_extend_object - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(extend_object)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(extend_object)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(obj)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(includeModule)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - comment(/** rb_mod_include - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(include)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(RubyModule) ident(include)operator(()ident(IRubyObject)type([]) ident(modules)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - comment(// MRI checks all types first:) - keyword(for) operator(()type(int) ident(i) operator(=) ident(modules)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) ident(modules)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()operator(!)ident(obj)operator(.)ident(isModule)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(obj)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getModule)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) ident(modules)operator(.)ident(length) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(modules)operator([)ident(i)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(append_features)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - ident(modules)operator([)ident(i)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(included)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(included)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(included)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(extended)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(extended)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(setVisibility)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) pre_type(Visibility) ident(visibility)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't change method visibility)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - comment(// Note: we change current frames visibility here because the methods which call) - comment(// this method are all "fast" (e.g. they do not created their own frame\).) - ident(context)operator(.)ident(setCurrentVisibility)operator(()ident(visibility)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(setMethodVisibility)operator(()ident(args)operator(,) ident(visibility)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_mod_public - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(public)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(writes) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(RubyModule) ident(rbPublic)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(setVisibility)operator(()ident(context)operator(,) ident(args)operator(,) ident(PUBLIC)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_mod_protected - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(protected)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(writes) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(RubyModule) ident(rbProtected)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(setVisibility)operator(()ident(context)operator(,) ident(args)operator(,) ident(PROTECTED)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_mod_private - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(private)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(writes) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(RubyModule) ident(rbPrivate)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(setVisibility)operator(()ident(context)operator(,) ident(args)operator(,) ident(PRIVATE)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_mod_modfunc - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(module_function)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(,) ident(writes) operator(=) ident(VISIBILITY)operator(\)) - directive(public) ident(RubyModule) ident(module_function)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't change method visibility)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(context)operator(.)ident(setCurrentVisibility)operator(()ident(MODULE_FUNCTION)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(setMethodVisibility)operator(()ident(args)operator(,) ident(PRIVATE)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(;) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(name)operator(\))operator(;) - keyword(assert) operator(!)ident(method)operator(.)ident(isUndefined)operator(()operator(\)) operator(:) string<delimiter(")content(undefined method ')delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(')delimiter(")>operator(;) - ident(getSingletonClass)operator(()operator(\))operator(.)ident(addMethod)operator(()ident(name)operator(,) keyword(new) ident(WrapperMethod)operator(()ident(getSingletonClass)operator(()operator(\))operator(,) ident(method)operator(,) ident(PUBLIC)operator(\))operator(\))operator(;) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(singleton_method_added)delimiter(")>operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method_added)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(method_added)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(nothing)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method_removed)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(method_removed)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(nothing)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method_undefined)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(method_undefined)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(nothing)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(method_defined_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - keyword(return) ident(isMethodBound)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(,) pre_constant(true)operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(public_method_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(public_method_defined)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(!)ident(method)operator(.)ident(isUndefined)operator(()operator(\)) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(==) ident(PUBLIC)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(protected_method_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(protected_method_defined)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(!)ident(method)operator(.)ident(isUndefined)operator(()operator(\)) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(==) ident(PROTECTED)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(private_method_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(private_method_defined)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - ident(DynamicMethod) ident(method) operator(=) ident(searchMethod)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(!)ident(method)operator(.)ident(isUndefined)operator(()operator(\)) operator(&&) ident(method)operator(.)ident(getVisibility)operator(()operator(\)) operator(==) ident(PRIVATE)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(public_class_method)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyModule) ident(public_class_method)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(getMetaClass)operator(()operator(\))operator(.)ident(setMethodVisibility)operator(()ident(args)operator(,) ident(PUBLIC)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(private_class_method)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyModule) ident(private_class_method)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(getMetaClass)operator(()operator(\))operator(.)ident(setMethodVisibility)operator(()ident(args)operator(,) ident(PRIVATE)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(alias_method)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(RubyModule) ident(alias_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(newId)operator(,) ident(IRubyObject) ident(oldId)operator(\)) operator({) - pre_type(String) ident(newName) operator(=) ident(newId)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - ident(defineAlias)operator(()ident(newName)operator(,) ident(oldId)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - ident(RubySymbol) ident(newSym) operator(=) ident(newId) keyword(instanceof) ident(RubySymbol) operator(?) operator(()ident(RubySymbol)operator(\))ident(newId) operator(:) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSymbol)operator(()ident(newName)operator(\))operator(;) - keyword(if) operator(()ident(isSingleton)operator(()operator(\))operator(\)) operator({) - operator(()operator(()ident(MetaClass)operator(\))local_variable(this)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(singleton_method_added)delimiter(")>operator(,) ident(newSym)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(method_added)delimiter(")>operator(,) ident(newSym)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(undef_method)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(RubyModule) ident(undef_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(undef)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(module_eval)delimiter(")>operator(,) string<delimiter(")content(class_eval)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(module_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(module_eval)delimiter(")>operator(,) string<delimiter(")content(class_eval)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(module_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(module_eval)delimiter(")>operator(,) string<delimiter(")content(class_eval)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(module_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(module_eval)delimiter(")>operator(,) string<delimiter(")content(class_eval)delimiter(")>operator(})operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(module_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(module_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remove_method)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(RubyModule) ident(remove_method)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(;)ident(i)operator(<)ident(args)operator(.)ident(length)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(removeMethod)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyModule) ident(module)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(module)operator(\))operator(;) - ident(output)operator(.)ident(writeString)operator(()ident(MarshalStream)operator(.)ident(getPathFromClass)operator(()ident(module)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyModule) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - pre_type(String) ident(name) operator(=) ident(RubyString)operator(.)ident(byteListToString)operator(()ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(\))operator(;) - ident(RubyModule) ident(result) operator(=) ident(UnmarshalStream)operator(.)ident(getModuleFromPath)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/* Module class methods */) - - comment(/** - * Return an array of nested modules or classes. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nesting)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(nesting)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyModule) ident(object) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - ident(StaticScope) ident(scope) operator(=) ident(context)operator(.)ident(getCurrentScope)operator(()operator(\))operator(.)ident(getStaticScope)operator(()operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(StaticScope) ident(current) operator(=) ident(scope)operator(;) ident(current)operator(.)ident(getModule)operator(()operator(\)) operator(!=) ident(object)operator(;) ident(current) operator(=) ident(current)operator(.)ident(getPreviousCRefScope)operator(()operator(\))operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(current)operator(.)ident(getModule)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) type(void) ident(doIncludeModule)operator(()ident(RubyModule) ident(includedModule)operator(\)) operator({) - type(boolean) ident(skip) operator(=) pre_constant(false)operator(;) - - ident(RubyModule) ident(currentModule) operator(=) local_variable(this)operator(;) - keyword(while) operator(()ident(includedModule) operator(!=) pre_constant(null)operator(\)) operator({) - - keyword(if) operator(()ident(getNonIncludedClass)operator(()operator(\)) operator(==) ident(includedModule)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(cyclic include detected)delimiter(")>operator(\))operator(;) - operator(}) - - type(boolean) ident(superclassSeen) operator(=) pre_constant(false)operator(;) - - comment(// scan class hierarchy for module) - keyword(for) operator(()ident(RubyModule) ident(superClass) operator(=) local_variable(this)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) ident(superClass) operator(!=) pre_constant(null)operator(;) ident(superClass) operator(=) ident(superClass)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(superClass) keyword(instanceof) ident(IncludedModuleWrapper)operator(\)) operator({) - keyword(if) operator(()ident(superClass)operator(.)ident(getNonIncludedClass)operator(()operator(\)) operator(==) ident(includedModule)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)ident(superclassSeen)operator(\)) operator({) - ident(currentModule) operator(=) ident(superClass)operator(;) - operator(}) - ident(skip) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(superclassSeen) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(skip)operator(\)) operator({) - - comment(// blow away caches for any methods that are redefined by module) - ident(getRuntime)operator(()operator(\))operator(.)ident(getCacheMap)operator(()operator(\))operator(.)ident(moduleIncluded)operator(()ident(currentModule)operator(,) ident(includedModule)operator(\))operator(;) - - comment(// In the current logic, if we get here we know that module is not an) - comment(// IncludedModuleWrapper, so there's no need to fish out the delegate. But just) - comment(// in case the logic should change later, let's do it anyway:) - ident(currentModule)operator(.)ident(setSuperClass)operator(()keyword(new) ident(IncludedModuleWrapper)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(currentModule)operator(.)ident(getSuperClass)operator(()operator(\))operator(,) - ident(includedModule)operator(.)ident(getNonIncludedClass)operator(()operator(\))operator(\))operator(\))operator(;) - ident(currentModule) operator(=) ident(currentModule)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - - ident(includedModule) operator(=) ident(includedModule)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - ident(skip) operator(=) pre_constant(false)operator(;) - operator(}) - operator(}) - - - comment(//) - comment(////////////////// CLASS VARIABLE RUBY METHODS ////////////////) - comment(//) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(class_variable_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(class_variable_defined_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(var)operator(\)) operator({) - pre_type(String) ident(internedName) operator(=) ident(validateClassVariable)operator(()ident(var)operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(intern)operator(()operator(\))operator(\))operator(;) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(fastHasClassVariable)operator(()ident(internedName)operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_mod_cvar_get - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(class_variable_get)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(class_variable_get)operator(()ident(IRubyObject) ident(var)operator(\)) operator({) - keyword(return) ident(fastGetClassVar)operator(()ident(validateClassVariable)operator(()ident(var)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(.)ident(intern)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_mod_cvar_set - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(class_variable_set)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(class_variable_set)operator(()ident(IRubyObject) ident(var)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(fastSetClassVar)operator(()ident(validateClassVariable)operator(()ident(var)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_remove_cvar - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remove_class_variable)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(remove_class_variable)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - pre_type(String) ident(javaName) operator(=) ident(validateClassVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - - keyword(if) operator(()operator(()ident(value) operator(=) ident(deleteClassVariable)operator(()ident(javaName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - keyword(if) operator(()ident(fastIsClassVarDefined)operator(()ident(javaName)operator(\))operator(\)) operator({) - keyword(throw) ident(cannotRemoveError)operator(()ident(javaName)operator(\))operator(;) - operator(}) - - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(class variable )delimiter(")> operator(+) ident(javaName) operator(+) string<delimiter(")content( not defined for )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(javaName)operator(\))operator(;) - operator(}) - - comment(/** rb_mod_class_variables - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(class_variables)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(class_variables)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - pre_type(Set)operator(<)pre_type(String)operator(>) ident(names) operator(=) keyword(new) pre_type(HashSet)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(p)operator(.)ident(getClassVariableNameList)operator(()operator(\))operator(\)) operator({) - ident(names)operator(.)ident(add)operator(()ident(name)operator(\))operator(;) - operator(}) - operator(}) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(ary) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(names)operator(\)) operator({) - ident(ary)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(ary)operator(;) - operator(}) - - - comment(//) - comment(////////////////// CONSTANT RUBY METHODS ////////////////) - comment(//) - - comment(/** rb_mod_const_defined - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(const_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(const_defined_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(symbol)operator(\)) operator({) - comment(// Note: includes part of fix for JRUBY-1339) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(fastIsConstantDefined)operator(()ident(validateConstant)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(.)ident(intern)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_mod_const_get - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(const_get)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(const_get)operator(()ident(IRubyObject) ident(symbol)operator(\)) operator({) - keyword(return) ident(fastGetConstant)operator(()ident(validateConstant)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(.)ident(intern)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_mod_const_set - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(const_set)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(const_set)operator(()ident(IRubyObject) ident(symbol)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(return) ident(fastSetConstant)operator(()ident(validateConstant)operator(()ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remove_const)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(remove_const)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - pre_type(String) ident(id) operator(=) ident(validateConstant)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(deleteConstant)operator(()ident(id)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(removeAutoLoadFor)operator(()ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(id)operator(\))operator(;) - comment(// FIXME: I'm not sure this is right, but the old code returned) - comment(// the undef, which definitely isn't right...) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(hasConstantInHierarchy)operator(()ident(id)operator(\))operator(\)) operator({) - keyword(throw) ident(cannotRemoveError)operator(()ident(id)operator(\))operator(;) - operator(}) - - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(constant )delimiter(")> operator(+) ident(id) operator(+) string<delimiter(")content( not defined for )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(id)operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(hasConstantInHierarchy)operator(()directive(final) pre_type(String) ident(name)operator(\)) operator({) - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(p)operator(.)ident(hasConstant)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** - * Base implementation of Module#const_missing, throws NameError for specific missing constant. - * - * @param name The constant name which was found to be missing - * @return Nothing! Absolutely nothing! (though subclasses might choose to return something\) - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(const_missing)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(const_missing)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(,) ident(Block) ident(block)operator(\)) operator({) - comment(/* Uninitialized constant */) - keyword(if) operator(()local_variable(this) operator(!=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(uninitialized constant )delimiter(")> operator(+) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(,) string<delimiter(")delimiter(")> operator(+) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(uninitialized constant )delimiter(")> operator(+) ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(,) ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_mod_constants - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(constants)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(constants)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(array) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - ident(RubyModule) ident(objectClass) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getModule)operator(()operator(\)) operator(==) local_variable(this)operator(\)) operator({) - - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(objectClass)operator(.)ident(getStoredConstantNameList)operator(()operator(\))operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - operator(}) keyword(else) keyword(if) operator(()ident(objectClass) operator(==) local_variable(this)operator(\)) operator({) - - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(getStoredConstantNameList)operator(()operator(\))operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - operator(}) keyword(else) operator({) - pre_type(Set)operator(<)pre_type(String)operator(>) ident(names) operator(=) keyword(new) pre_type(HashSet)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) ident(p) operator(!=) pre_constant(null)operator(;) ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(objectClass) operator(!=) ident(p)operator(\)) operator({) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(p)operator(.)ident(getStoredConstantNameList)operator(()operator(\))operator(\)) operator({) - ident(names)operator(.)ident(add)operator(()ident(name)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(names)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(array)operator(;) - operator(}) - - - comment(//) - comment(////////////////// CLASS VARIABLE API METHODS ////////////////) - comment(//) - - comment(/** - * Set the named class variable to the given value, provided taint and freeze allow setting it. - * - * Ruby C equivalent = "rb_cvar_set" - * - * @param name The variable name to set - * @param value The value to set it to - */) - directive(public) ident(IRubyObject) ident(setClassVar)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(hasClassVariable)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(module)operator(.)ident(storeClassVariable)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) ident(storeClassVariable)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastSetClassVar)operator(()directive(final) pre_type(String) ident(internedName)operator(,) directive(final) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(fastHasClassVariable)operator(()ident(internedName)operator(\))operator(\)) operator({) - keyword(return) ident(module)operator(.)ident(fastStoreClassVariable)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) ident(fastStoreClassVariable)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the specified class variable, searching through this module, included modules, and supermodules. - * - * Ruby C equivalent = "rb_cvar_get" - * - * @param name The name of the variable to retrieve - * @return The variable's value, or throws NameError if not found - */) - directive(public) ident(IRubyObject) ident(getClassVar)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(name)operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - - keyword(do) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(module)operator(.)ident(variableTableFetch)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(value)operator(;) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(uninitialized class variable )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( in )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastGetClassVar)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(internedName)operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - - keyword(do) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(module)operator(.)ident(variableTableFastFetch)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(value)operator(;) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(uninitialized class variable )delimiter(")> operator(+) ident(internedName) operator(+) string<delimiter(")content( in )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * Is class var defined? - * - * Ruby C equivalent = "rb_cvar_defined" - * - * @param name The class var to determine "is defined?" - * @return true if true, false if false - */) - directive(public) type(boolean) ident(isClassVarDefined)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(hasClassVariable)operator(()ident(name)operator(\))operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(fastIsClassVarDefined)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(fastHasClassVariable)operator(()ident(internedName)operator(\))operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - - comment(/** rb_mod_remove_cvar - * - * FIXME: any good reason to have two identical methods? (same as remove_class_variable\) - */) - directive(public) ident(IRubyObject) ident(removeCvar)operator(()ident(IRubyObject) ident(name)operator(\)) operator({) comment(// Wrong Parameter ?) - pre_type(String) ident(internedName) operator(=) ident(validateClassVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - - keyword(if) operator(()operator(()ident(value) operator(=) ident(deleteClassVariable)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - keyword(if) operator(()ident(fastIsClassVarDefined)operator(()ident(internedName)operator(\))operator(\)) operator({) - keyword(throw) ident(cannotRemoveError)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(class variable )delimiter(")> operator(+) ident(internedName) operator(+) string<delimiter(")content( not defined for )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(internedName)operator(\))operator(;) - operator(}) - - - comment(//) - comment(////////////////// CONSTANT API METHODS ////////////////) - comment(//) - - directive(public) ident(IRubyObject) ident(getConstantAt)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(fetchConstant)operator(()ident(name)operator(\))operator(\)) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - ident(deleteConstant)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoload)operator(()ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastGetConstantAt)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(fastFetchConstant)operator(()ident(internedName)operator(\))operator(\)) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - ident(deleteConstant)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoload)operator(()ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * Retrieve the named constant, invoking 'const_missing' should that be appropriate. - * - * @param name The constant to retrieve - * @return The value for the constant, or null if not found - */) - directive(public) ident(IRubyObject) ident(getConstant)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(;) - type(boolean) ident(retryForModule) operator(=) pre_constant(false)operator(;) - ident(IRubyObject) ident(value)operator(;) - ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) - - ident(retry)operator(:) keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(while) operator(()ident(p) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(p)operator(.)ident(constantTableFetch)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - ident(p)operator(.)ident(deleteConstant)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoload)operator(() - ident(p)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) - ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(retryForModule) operator(&&) operator(!)ident(isClass)operator(()operator(\))operator(\)) operator({) - ident(retryForModule) operator(=) pre_constant(true)operator(;) - ident(p) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - keyword(continue) ident(retry)operator(;) - operator(}) - - keyword(break)operator(;) - operator(}) - - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) - string<delimiter(")content(const_missing)delimiter(")>operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastGetConstant)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\))operator(;) - type(boolean) ident(retryForModule) operator(=) pre_constant(false)operator(;) - ident(IRubyObject) ident(value)operator(;) - ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) - - ident(retry)operator(:) keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(while) operator(()ident(p) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(p)operator(.)ident(constantTableFastFetch)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - ident(p)operator(.)ident(deleteConstant)operator(()ident(internedName)operator(\))operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoload)operator(() - ident(p)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) - ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(retryForModule) operator(&&) operator(!)ident(isClass)operator(()operator(\))operator(\)) operator({) - ident(retryForModule) operator(=) pre_constant(true)operator(;) - ident(p) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - keyword(continue) ident(retry)operator(;) - operator(}) - - keyword(break)operator(;) - operator(}) - - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) - string<delimiter(")content(const_missing)delimiter(")>operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()ident(internedName)operator(\))operator(\))operator(;) - operator(}) - - comment(// not actually called anywhere (all known uses call the fast version\)) - directive(public) ident(IRubyObject) ident(getConstantFrom)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(fastGetConstantFrom)operator(()ident(name)operator(.)ident(intern)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastGetConstantFrom)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\))operator(;) - ident(RubyClass) ident(objectClass) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - - ident(RubyModule) ident(p) operator(=) local_variable(this)operator(;) - - keyword(while) operator(()ident(p) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(p)operator(.)ident(constantTableFastFetch)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) operator({) - keyword(if) operator(()ident(p) operator(==) ident(objectClass) operator(&&) local_variable(this) operator(!=) ident(objectClass)operator(\)) operator({) - pre_type(String) ident(badCName) operator(=) ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(CONSTANT_BAD_REFERENCE)operator(,) string<delimiter(")content(toplevel constant )delimiter(")> operator(+) - ident(internedName) operator(+) string<delimiter(")content( referenced by )delimiter(")> operator(+) ident(badCName)operator(,) ident(badCName)operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - ident(p)operator(.)ident(deleteConstant)operator(()ident(internedName)operator(\))operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoload)operator(() - ident(p)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) - ident(p) operator(=) ident(p)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) - string<delimiter(")content(const_missing)delimiter(")>operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(fastNewSymbol)operator(()ident(internedName)operator(\))operator(\))operator(;) - operator(}) - comment(/** - * Set the named constant on this module. Also, if the value provided is another Module and - * that module has not yet been named, assign it the specified name. - * - * @param name The name to assign - * @param value The value to assign to it; if an unnamed Module, also set its basename to name - * @return The result of setting the variable. - */) - directive(public) ident(IRubyObject) ident(setConstant)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(IRubyObject) ident(oldValue)operator(;) - keyword(if) operator(()operator(()ident(oldValue) operator(=) ident(fetchConstant)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(oldValue) operator(==) ident(UNDEF)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(removeAutoLoadFor)operator(()ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(CONSTANT_ALREADY_INITIALIZED)operator(,) string<delimiter(")content(already initialized constant )delimiter(")> operator(+) ident(name)operator(,) ident(name)operator(\))operator(;) - operator(}) - operator(}) - - ident(storeConstant)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - - comment(// if adding a module under a constant name, set that module's basename to the constant name) - keyword(if) operator(()ident(value) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) operator(()ident(RubyModule)operator(\))ident(value)operator(;) - keyword(if) operator(()ident(module)operator(.)ident(getBaseName)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(module)operator(.)ident(setBaseName)operator(()ident(name)operator(\))operator(;) - ident(module)operator(.)ident(setParent)operator(()local_variable(this)operator(\))operator(;) - operator(}) - comment(/* - module.setParent(this\); - */) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastSetConstant)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - ident(IRubyObject) ident(oldValue)operator(;) - keyword(if) operator(()operator(()ident(oldValue) operator(=) ident(fastFetchConstant)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(oldValue) operator(==) ident(UNDEF)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(removeAutoLoadFor)operator(()ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(CONSTANT_ALREADY_INITIALIZED)operator(,) string<delimiter(")content(already initialized constant )delimiter(")> operator(+) ident(internedName)operator(,) ident(internedName)operator(\))operator(;) - operator(}) - operator(}) - - ident(fastStoreConstant)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - - comment(// if adding a module under a constant name, set that module's basename to the constant name) - keyword(if) operator(()ident(value) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) operator(()ident(RubyModule)operator(\))ident(value)operator(;) - keyword(if) operator(()ident(module)operator(.)ident(getBaseName)operator(()operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(module)operator(.)ident(setBaseName)operator(()ident(internedName)operator(\))operator(;) - ident(module)operator(.)ident(setParent)operator(()local_variable(this)operator(\))operator(;) - operator(}) - comment(/* - module.setParent(this\); - */) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** rb_define_const - * - */) - directive(public) type(void) ident(defineConstant)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(value) operator(!=) pre_constant(null)operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getClassClass)operator(()operator(\))operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(IdUtil)operator(.)ident(isValidConstantName)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(bad constant name )delimiter(")> operator(+) ident(name)operator(,) ident(name)operator(\))operator(;) - operator(}) - - ident(setConstant)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(// Fix for JRUBY-1339 - search hierarchy for constant) - comment(/** rb_const_defined_at - * - */) - directive(public) type(boolean) ident(isConstantDefined)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(;) - type(boolean) ident(isObject) operator(=) local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - - keyword(do) operator({) - pre_type(Object) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(module)operator(.)ident(constantTableFetch)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) keyword(return) pre_constant(true)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoloadFor)operator(() - ident(module)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(name)operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - - operator(}) keyword(while) operator(()ident(isObject) operator(&&) operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null) operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) type(boolean) ident(fastIsConstantDefined)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\))operator(;) - type(boolean) ident(isObject) operator(=) local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - - keyword(do) operator({) - pre_type(Object) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(module)operator(.)ident(constantTableFastFetch)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(value) operator(!=) ident(UNDEF)operator(\)) keyword(return) pre_constant(true)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(autoloadFor)operator(() - ident(module)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(::)delimiter(")> operator(+) ident(internedName)operator(\)) operator(!=) pre_constant(null)operator(;) - operator(}) - - operator(}) keyword(while) operator(()ident(isObject) operator(&&) operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null) operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(//) - comment(////////////////// COMMON CONSTANT / CVAR METHODS ////////////////) - comment(//) - - directive(private) ident(RaiseException) ident(cannotRemoveError)operator(()pre_type(String) ident(id)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(cannot remove )delimiter(")> operator(+) ident(id) operator(+) string<delimiter(")content( for )delimiter(")> operator(+) ident(getName)operator(()operator(\))operator(,) ident(id)operator(\))operator(;) - operator(}) - - - comment(//) - comment(////////////////// INTERNAL MODULE VARIABLE API METHODS ////////////////) - comment(//) - - comment(/** - * Behaves similarly to {@link #getClassVar(String\)}. Searches this - * class/module <em>and its ancestors</em> for the specified internal - * variable. - * - * @param name the internal variable name - * @return the value of the specified internal variable if found, else null - * @see #setInternalModuleVariable(String, IRubyObject\) - */) - directive(public) type(boolean) ident(hasInternalModuleVariable)operator(()directive(final) pre_type(String) ident(name)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(hasInternalVariable)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) pre_constant(false)operator(;) - operator(}) - comment(/** - * Behaves similarly to {@link #getClassVar(String\)}. Searches this - * class/module <em>and its ancestors</em> for the specified internal - * variable. - * - * @param name the internal variable name - * @return the value of the specified internal variable if found, else null - * @see #setInternalModuleVariable(String, IRubyObject\) - */) - directive(public) ident(IRubyObject) ident(searchInternalModuleVariable)operator(()directive(final) pre_type(String) ident(name)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - ident(IRubyObject) ident(value)operator(;) - keyword(do) operator({) - keyword(if) operator(()operator(()ident(value) operator(=) ident(module)operator(.)ident(getInternalVariable)operator(()ident(name)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** - * Behaves similarly to {@link #setClassVar(String, IRubyObject\)}. If the - * specified internal variable is found in this class/module <em>or an ancestor</em>, - * it is set where found. Otherwise it is set in this module. - * - * @param name the internal variable name - * @param value the internal variable value - * @see #searchInternalModuleVariable(String\) - */) - directive(public) type(void) ident(setInternalModuleVariable)operator(()directive(final) pre_type(String) ident(name)operator(,) directive(final) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RubyModule) ident(module) operator(=) local_variable(this)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(module)operator(.)ident(hasInternalVariable)operator(()ident(name)operator(\))operator(\)) operator({) - ident(module)operator(.)ident(setInternalVariable)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - keyword(return)operator(;) - operator(}) - operator(}) keyword(while) operator(()operator(()ident(module) operator(=) ident(module)operator(.)ident(getSuperClass)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\))operator(;) - - ident(setInternalVariable)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(//) - comment(////////////////// LOW-LEVEL CLASS VARIABLE INTERFACE ////////////////) - comment(//) - comment(// fetch/store/list class variables for this module) - comment(//) - - directive(public) type(boolean) ident(hasClassVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(fastHasClassVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fetchClassVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastFetchClassVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(storeClassVariable)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(name)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureClassVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastStoreClassVariable)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(internedName)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureClassVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(deleteClassVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(name)operator(\))operator(;) - ident(ensureClassVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getClassVariableList)operator(()operator(\)) operator({) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(list)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(getClassVariableNameList)operator(()operator(\)) operator({) - pre_type(ArrayList)operator(<)pre_type(String)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isClassVariable)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - directive(protected) directive(static) directive(final) pre_type(String) ident(ERR_INSECURE_SET_CLASS_VAR) operator(=) string<delimiter(")content(Insecure: can't modify class variable)delimiter(")>operator(;) - directive(protected) directive(static) directive(final) pre_type(String) ident(ERR_FROZEN_CVAR_TYPE) operator(=) string<delimiter(")content(class/module )delimiter(")>operator(;) - - directive(protected) directive(final) pre_type(String) ident(validateClassVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isValidClassVariableName)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(name)operator(;) - operator(}) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(`)delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(' is not allowed as a class variable name)delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(protected) directive(final) type(void) ident(ensureClassVariablesSettable)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isFrozen)operator(()operator(\)) operator(&&) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(<) integer(4) operator(||) ident(isTaint)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()ident(ERR_INSECURE_SET_CONSTANT)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFrozenError)operator(()ident(ERR_FROZEN_CONST_TYPE)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFrozenError)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(//) - comment(////////////////// LOW-LEVEL CONSTANT INTERFACE ////////////////) - comment(//) - comment(// fetch/store/list constants for this module) - comment(//) - - directive(public) type(boolean) ident(hasConstant)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(constantTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(fastHasConstant)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(constantTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(// returns the stored value without processing undefs (autoloads\)) - directive(public) ident(IRubyObject) ident(fetchConstant)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(constantTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(// returns the stored value without processing undefs (autoloads\)) - directive(public) ident(IRubyObject) ident(fastFetchConstant)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(constantTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(storeConstant)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureConstantsSettable)operator(()operator(\))operator(;) - keyword(return) ident(constantTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(fastStoreConstant)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(internedName)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureConstantsSettable)operator(()operator(\))operator(;) - keyword(return) ident(constantTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(// removes and returns the stored value without processing undefs (autoloads\)) - directive(public) ident(IRubyObject) ident(deleteConstant)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(;) - ident(ensureConstantsSettable)operator(()operator(\))operator(;) - keyword(return) ident(constantTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getStoredConstantList)operator(()operator(\)) operator({) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(table) operator(=) ident(constantTableGetTable)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(getStoredConstantNameList)operator(()operator(\)) operator({) - pre_type(ArrayList)operator(<)pre_type(String)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(table) operator(=) ident(constantTableGetTable)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - directive(protected) directive(static) directive(final) pre_type(String) ident(ERR_INSECURE_SET_CONSTANT) operator(=) string<delimiter(")content(Insecure: can't modify constant)delimiter(")>operator(;) - directive(protected) directive(static) directive(final) pre_type(String) ident(ERR_FROZEN_CONST_TYPE) operator(=) string<delimiter(")content(class/module )delimiter(")>operator(;) - - directive(protected) directive(final) pre_type(String) ident(validateConstant)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isValidConstantName)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(name)operator(;) - operator(}) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(wrong constant name )delimiter(")> operator(+) ident(name)operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(protected) directive(final) type(void) ident(ensureConstantsSettable)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isFrozen)operator(()operator(\)) operator(&&) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(<) integer(4) operator(||) ident(isTaint)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newSecurityError)operator(()ident(ERR_INSECURE_SET_CONSTANT)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFrozenError)operator(()ident(ERR_FROZEN_CONST_TYPE)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFrozenError)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - - comment(//) - comment(////////////////// VARIABLE TABLE METHODS ////////////////) - comment(//) - comment(// Overridden to use variableWriteLock in place of synchronization ) - comment(//) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableStore)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(table) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(,) pre_constant(null)operator(\))operator(;) - ident(table)operator([)ident(hash) operator(&) operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(-) integer(1)operator(\))operator(]) operator(=) ident(e)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTableSize) operator(=) integer(1)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(variableTableSize) operator(+) integer(1)operator(\)) operator(>) ident(variableTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(variableTableRehash)operator(()operator(\))operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(e)operator(.)ident(value) operator(=) ident(value)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - comment(// external volatile value initialization intended to obviate the need for) - comment(// readValueUnderLock technique used in ConcurrentHashMap. may be a little) - comment(// slower, but better to pay a price on first write rather than all reads.) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) ident(e)operator(;) - ident(variableTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableFastStore)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( not interned)delimiter(")>operator(;) - type(int) ident(hash) operator(=) ident(internedName)operator(.)ident(hashCode)operator(()operator(\))operator(;) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(table) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(value)operator(,) pre_constant(null)operator(\))operator(;) - ident(table)operator([)ident(hash) operator(&) operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(-) integer(1)operator(\))operator(]) operator(=) ident(e)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTableSize) operator(=) integer(1)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(variableTableSize) operator(+) integer(1)operator(\)) operator(>) ident(variableTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(variableTableRehash)operator(()operator(\))operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - ident(e)operator(.)ident(value) operator(=) ident(value)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - comment(// external volatile value initialization intended to obviate the need for) - comment(// readValueUnderLock technique used in ConcurrentHashMap. may be a little) - comment(// slower, but better to pay a price on first write rather than all reads.) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) ident(e)operator(;) - ident(variableTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableRemove)operator(()pre_type(String) ident(name)operator(\)) operator({) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - type(int) ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(;) - ident(VariableTableEntry) ident(first) operator(=) ident(table)operator([)ident(index)operator(])operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(first)operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(oldValue) operator(=) ident(e)operator(.)ident(value)operator(;) - comment(// All entries following removed node can stay) - comment(// in list, but all preceding ones need to be) - comment(// cloned.) - ident(VariableTableEntry) ident(newFirst) operator(=) ident(e)operator(.)ident(next)operator(;) - keyword(for) operator(()ident(VariableTableEntry) ident(p) operator(=) ident(first)operator(;) ident(p) operator(!=) ident(e)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - ident(newFirst) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(value)operator(,) ident(newFirst)operator(\))operator(;) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) ident(newFirst)operator(;) - ident(variableTableSize)operator(--)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile ) - keyword(return) ident(oldValue)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@Override) - directive(protected) ident(IRubyObject) ident(variableTableReadLocked)operator(()ident(VariableTableEntry) ident(entry)operator(\)) operator({) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(entry)operator(.)ident(value)operator(;) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(protected) type(void) ident(variableTableSync)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(vars)operator(\)) operator({) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(variableTableSize) operator(=) integer(0)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTable) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - keyword(for) operator(()ident(Variable)operator(<)ident(IRubyObject)operator(>) ident(var) operator(:) ident(vars)operator(\)) operator({) - keyword(assert) operator(!)ident(var)operator(.)ident(isConstant)operator(()operator(\)) operator(&&) ident(var)operator(.)ident(getValue)operator(()operator(\)) operator(!=) pre_constant(null)operator(;) - ident(variableTableStore)operator(()ident(var)operator(.)ident(getName)operator(()operator(\))operator(,) ident(var)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(syncVariables)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(variables)operator(\)) operator({) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(constants) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()ident(variables)operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - ident(Variable)operator(<)ident(IRubyObject)operator(>) ident(var)operator(;) - keyword(for) operator(()pre_type(Iterator)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(iter) operator(=) ident(variables)operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;) operator(\)) operator({) - keyword(if) operator(()operator(()ident(var) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(.)ident(isConstant)operator(()operator(\))operator(\)) operator({) - ident(constants)operator(.)ident(add)operator(()ident(var)operator(\))operator(;) - ident(iter)operator(.)ident(remove)operator(()operator(\))operator(;) - operator(}) - operator(}) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(variableTableSync)operator(()ident(variables)operator(\))operator(;) - ident(constantTableSync)operator(()ident(constants)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Deprecated) comment(// born deprecated) - directive(public) pre_type(Map) ident(getVariableMap)operator(()operator(\)) operator({) - pre_type(Map) ident(map) operator(=) ident(variableTableGetMap)operator(()operator(\))operator(;) - ident(constantTableGetMap)operator(()ident(map)operator(\))operator(;) - keyword(return) ident(map)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(hasVariables)operator(()operator(\)) operator({) - keyword(return) ident(variableTableGetSize)operator(()operator(\)) operator(>) integer(0) operator(||) ident(constantTableGetSize)operator(()operator(\)) operator(>) integer(0)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getVariableCount)operator(()operator(\)) operator({) - keyword(return) ident(variableTableGetSize)operator(()operator(\)) operator(+) ident(constantTableGetSize)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getVariableList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(vtable) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(ctable) operator(=) ident(constantTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(vtable)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(vtable)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(list)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) ident(ctable)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(ctable)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(getVariableNameList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(vtable) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(ctable) operator(=) ident(constantTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)pre_type(String)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(vtable)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(vtable)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) ident(ctable)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(ctable)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - - comment(//) - comment(////////////////// CONSTANT TABLE METHODS, ETC. ////////////////) - comment(//) - - directive(protected) directive(static) directive(final) type(int) ident(CONSTANT_TABLE_DEFAULT_CAPACITY) operator(=) integer(8)operator(;) comment(// MUST be power of 2!) - directive(protected) directive(static) directive(final) type(int) ident(CONSTANT_TABLE_MAXIMUM_CAPACITY) operator(=) integer(1) operator(<)operator(<) integer(30)operator(;) - directive(protected) directive(static) directive(final) type(float) ident(CONSTANT_TABLE_LOAD_FACTOR) operator(=) float(0.75f)operator(;) - - directive(protected) directive(static) directive(final) type(class) class(ConstantTableEntry) directive(implements) ident(Variable)operator(<)ident(IRubyObject)operator(>) operator({) - directive(final) type(int) ident(hash)operator(;) - directive(final) pre_type(String) ident(name)operator(;) - directive(final) ident(IRubyObject) ident(value)operator(;) - directive(final) ident(ConstantTableEntry) ident(next)operator(;) - - comment(// constant table entry values are final; if a constant is redefined, the) - comment(// entry will be removed and replaced with a new entry.) - ident(ConstantTableEntry)operator(() - type(int) ident(hash)operator(,) - pre_type(String) ident(name)operator(,) - ident(IRubyObject) ident(value)operator(,) - ident(ConstantTableEntry) ident(next)operator(\)) operator({) - local_variable(this)operator(.)ident(hash) operator(=) ident(hash)operator(;) - local_variable(this)operator(.)ident(name) operator(=) ident(name)operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - local_variable(this)operator(.)ident(next) operator(=) ident(next)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getName)operator(()operator(\)) operator({) - keyword(return) ident(name)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - directive(public) directive(final) type(boolean) ident(isClassVariable)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) directive(final) type(boolean) ident(isConstant)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(public) directive(final) type(boolean) ident(isInstanceVariable)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(public) directive(final) type(boolean) ident(isRubyVariable)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - directive(protected) type(boolean) ident(constantTableContains)operator(()pre_type(String) ident(name)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(constantTable)operator(\))operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(protected) type(boolean) ident(constantTableFastContains)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(constantTable)operator(\))operator([)ident(internedName)operator(.)ident(hashCode)operator(()operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(constantTableFetch)operator(()pre_type(String) ident(name)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(constantTable)operator(\))operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(value)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(constantTableFastFetch)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(constantTable)operator(\))operator([)ident(internedName)operator(.)ident(hashCode)operator(()operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(value)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(constantTableStore)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - ident(ConstantTableEntry) ident(e)operator(;) - ident(ConstantTableEntry) ident(first)operator(;) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(constantTableSize) operator(+) integer(1)operator(\)) operator(>) ident(constantTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(constantTableRehash)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(table) operator(=) ident(constantTable)operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(first) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - comment(// if value is unchanged, do nothing) - keyword(if) operator(()ident(value) operator(==) ident(e)operator(.)ident(value)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - comment(// create new entry, prepend to any trailing entries) - ident(ConstantTableEntry) ident(newFirst) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(e)operator(.)ident(hash)operator(,) ident(e)operator(.)ident(name)operator(,) ident(value)operator(,) ident(e)operator(.)ident(next)operator(\))operator(;) - comment(// all entries before this one must be cloned) - keyword(for) operator(()ident(ConstantTableEntry) ident(n) operator(=) ident(first)operator(;) ident(n) operator(!=) ident(e)operator(;) ident(n) operator(=) ident(n)operator(.)ident(next)operator(\)) operator({) - ident(newFirst) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(n)operator(.)ident(hash)operator(,) ident(n)operator(.)ident(name)operator(,) ident(n)operator(.)ident(value)operator(,) ident(newFirst)operator(\))operator(;) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) ident(newFirst)operator(;) - ident(constantTable) operator(=) ident(table)operator(;) comment(// write-volatile) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(hash)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(constantTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(constantTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(constantTableFastStore)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( not interned)delimiter(")>operator(;) - type(int) ident(hash) operator(=) ident(internedName)operator(.)ident(hashCode)operator(()operator(\))operator(;) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - ident(ConstantTableEntry) ident(e)operator(;) - ident(ConstantTableEntry) ident(first)operator(;) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(constantTableSize) operator(+) integer(1)operator(\)) operator(>) ident(constantTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(constantTableRehash)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(table) operator(=) ident(constantTable)operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(first) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - comment(// if value is unchanged, do nothing) - keyword(if) operator(()ident(value) operator(==) ident(e)operator(.)ident(value)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - comment(// create new entry, prepend to any trailing entries) - ident(ConstantTableEntry) ident(newFirst) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(e)operator(.)ident(hash)operator(,) ident(e)operator(.)ident(name)operator(,) ident(value)operator(,) ident(e)operator(.)ident(next)operator(\))operator(;) - comment(// all entries before this one must be cloned) - keyword(for) operator(()ident(ConstantTableEntry) ident(n) operator(=) ident(first)operator(;) ident(n) operator(!=) ident(e)operator(;) ident(n) operator(=) ident(n)operator(.)ident(next)operator(\)) operator({) - ident(newFirst) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(n)operator(.)ident(hash)operator(,) ident(n)operator(.)ident(name)operator(,) ident(n)operator(.)ident(value)operator(,) ident(newFirst)operator(\))operator(;) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) ident(newFirst)operator(;) - ident(constantTable) operator(=) ident(table)operator(;) comment(// write-volatile) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(constantTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(constantTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(constantTableRemove)operator(()pre_type(String) ident(name)operator(\)) operator({) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(constantTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - type(int) ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(;) - ident(ConstantTableEntry) ident(first) operator(=) ident(table)operator([)ident(index)operator(])operator(;) - ident(ConstantTableEntry) ident(e)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(first)operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(oldValue) operator(=) ident(e)operator(.)ident(value)operator(;) - comment(// All entries following removed node can stay) - comment(// in list, but all preceding ones need to be) - comment(// cloned.) - ident(ConstantTableEntry) ident(newFirst) operator(=) ident(e)operator(.)ident(next)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(p) operator(=) ident(first)operator(;) ident(p) operator(!=) ident(e)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - ident(newFirst) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(value)operator(,) ident(newFirst)operator(\))operator(;) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) ident(newFirst)operator(;) - ident(constantTableSize)operator(--)operator(;) - ident(constantTable) operator(=) ident(table)operator(;) comment(// write-volatile ) - keyword(return) ident(oldValue)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - - directive(protected) ident(ConstantTableEntry)type([]) ident(constantTableGetTable)operator(()operator(\)) operator({) - keyword(return) ident(constantTable)operator(;) - operator(}) - - directive(protected) type(int) ident(constantTableGetSize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(constantTable) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(constantTableSize)operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - directive(protected) type(void) ident(constantTableSync)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(vars)operator(\)) operator({) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(variableWriteLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(constantTableSize) operator(=) integer(0)operator(;) - ident(constantTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(CONSTANT_TABLE_DEFAULT_CAPACITY) operator(*) ident(CONSTANT_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(constantTable) operator(=) keyword(new) ident(ConstantTableEntry)operator([)ident(CONSTANT_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - keyword(for) operator(()ident(Variable)operator(<)ident(IRubyObject)operator(>) ident(var) operator(:) ident(vars)operator(\)) operator({) - keyword(assert) ident(var)operator(.)ident(isConstant)operator(()operator(\)) operator(&&) ident(var)operator(.)ident(getValue)operator(()operator(\)) operator(!=) pre_constant(null)operator(;) - ident(constantTableStore)operator(()ident(var)operator(.)ident(getName)operator(()operator(\))operator(,) ident(var)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// MUST be called from synchronized/locked block!) - comment(// should only be called by constantTableStore/constantTableFastStore) - directive(private) directive(final) ident(ConstantTableEntry)type([]) ident(constantTableRehash)operator(()operator(\)) operator({) - ident(ConstantTableEntry)type([]) ident(oldTable) operator(=) ident(constantTable)operator(;) - type(int) ident(oldCapacity)operator(;) - keyword(if) operator(()operator(()ident(oldCapacity) operator(=) ident(oldTable)operator(.)ident(length)operator(\)) operator(>=) ident(CONSTANT_TABLE_MAXIMUM_CAPACITY)operator(\)) operator({) - keyword(return) ident(oldTable)operator(;) - operator(}) - - type(int) ident(newCapacity) operator(=) ident(oldCapacity) operator(<)operator(<) integer(1)operator(;) - ident(ConstantTableEntry)type([]) ident(newTable) operator(=) keyword(new) ident(ConstantTableEntry)operator([)ident(newCapacity)operator(])operator(;) - ident(constantTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(newCapacity) operator(*) ident(CONSTANT_TABLE_LOAD_FACTOR)operator(\))operator(;) - type(int) ident(sizeMask) operator(=) ident(newCapacity) operator(-) integer(1)operator(;) - ident(ConstantTableEntry) ident(e)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(oldCapacity)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - comment(// We need to guarantee that any existing reads of old Map can) - comment(// proceed. So we cannot yet null out each bin.) - ident(e) operator(=) ident(oldTable)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()ident(e) operator(!=) pre_constant(null)operator(\)) operator({) - ident(ConstantTableEntry) ident(next) operator(=) ident(e)operator(.)ident(next)operator(;) - type(int) ident(idx) operator(=) ident(e)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - - comment(// Single node on list) - keyword(if) operator(()ident(next) operator(==) pre_constant(null)operator(\)) - ident(newTable)operator([)ident(idx)operator(]) operator(=) ident(e)operator(;) - - keyword(else) operator({) - comment(// Reuse trailing consecutive sequence at same slot) - ident(ConstantTableEntry) ident(lastRun) operator(=) ident(e)operator(;) - type(int) ident(lastIdx) operator(=) ident(idx)operator(;) - keyword(for) operator(()ident(ConstantTableEntry) ident(last) operator(=) ident(next)operator(;) - ident(last) operator(!=) pre_constant(null)operator(;) - ident(last) operator(=) ident(last)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(last)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - keyword(if) operator(()ident(k) operator(!=) ident(lastIdx)operator(\)) operator({) - ident(lastIdx) operator(=) ident(k)operator(;) - ident(lastRun) operator(=) ident(last)operator(;) - operator(}) - operator(}) - ident(newTable)operator([)ident(lastIdx)operator(]) operator(=) ident(lastRun)operator(;) - - comment(// Clone all remaining nodes) - keyword(for) operator(()ident(ConstantTableEntry) ident(p) operator(=) ident(e)operator(;) ident(p) operator(!=) ident(lastRun)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(p)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - ident(ConstantTableEntry) ident(m) operator(=) keyword(new) ident(ConstantTableEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(value)operator(,) ident(newTable)operator([)ident(k)operator(])operator(\))operator(;) - ident(newTable)operator([)ident(k)operator(]) operator(=) ident(m)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - ident(constantTable) operator(=) ident(newTable)operator(;) - keyword(return) ident(newTable)operator(;) - operator(}) - - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - directive(protected) pre_type(Map) ident(constantTableGetMap)operator(()operator(\)) operator({) - pre_type(HashMap) ident(map) operator(=) keyword(new) pre_type(HashMap)operator(()operator(\))operator(;) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(constantTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(map)operator(.)ident(put)operator(()ident(e)operator(.)ident(name)operator(,) ident(e)operator(.)ident(value)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(map)operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - directive(protected) pre_type(Map) ident(constantTableGetMap)operator(()pre_type(Map) ident(map)operator(\)) operator({) - ident(ConstantTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(constantTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(ConstantTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(map)operator(.)ident(put)operator(()ident(e)operator(.)ident(name)operator(,) ident(e)operator(.)ident(value)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(map)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.runtime.Visibility.PRIVATE)operator(;) -keyword(import) include(static) include(org.jruby.runtime.Visibility.PROTECTED)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.Sprintf)operator(;) - -comment(/** - * @author Anders Bengtsson - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(NameError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(StandardError)delimiter(")>operator(\)) -directive(public) type(class) class(RubyNameError) directive(extends) ident(RubyException) operator({) - directive(private) ident(IRubyObject) ident(name)operator(;) - - comment(/** - * Nested class whose instances act as thunks reacting to to_str method - * called from (Exception#to_str, Exception#message\) - * MRI equivalent: rb_cNameErrorMesg, class name: "message", construction method: "!", - * to_str implementation: "name_err_mesg_to_str" - * - * TODO: this class should not be lookupable - */) - annotation(@JRubyClass)operator(()ident(name) operator(=) string<delimiter(")content(NameError::Message)delimiter(")>operator(,) ident(parent) operator(=) string<delimiter(")content(Object)delimiter(")>operator(\)) - directive(public) directive(static) directive(final) type(class) class(RubyNameErrorMessage) directive(extends) ident(RubyObject) operator({) - - directive(static) ident(ObjectAllocator) ident(NAMEERRORMESSAGE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(IRubyObject) ident(dummy) operator(=) keyword(new) ident(RubyObject)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\))operator(;) - keyword(return) keyword(new) ident(RubyNameErrorMessage)operator(()ident(runtime)operator(,) ident(dummy)operator(,) ident(dummy)operator(,) pre_type(Visibility)operator(.)ident(PRIVATE)operator(,) ident(CallType)operator(.)ident(VARIABLE)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(final) ident(IRubyObject) ident(object)operator(;) - directive(private) directive(final) ident(IRubyObject) ident(method)operator(;) - directive(private) directive(final) pre_type(Visibility) ident(visibility)operator(;) - directive(private) directive(final) ident(CallType) ident(callType)operator(;) - - ident(RubyNameErrorMessage)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(object)operator(,) ident(IRubyObject) ident(method)operator(,) pre_type(Visibility) ident(visibility)operator(,) ident(CallType) ident(callType)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getNameErrorMessage)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - local_variable(this)operator(.)ident(object) operator(=) ident(object)operator(;) - local_variable(this)operator(.)ident(method) operator(=) ident(method)operator(;) - local_variable(this)operator(.)ident(visibility) operator(=) ident(visibility)operator(;) - local_variable(this)operator(.)ident(callType) operator(=) ident(callType)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_load)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(arg)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_dump)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(dump)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(to_str)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_str)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_str)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - pre_type(String) ident(format) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()ident(visibility) operator(==) ident(PRIVATE)operator(\)) operator({) - ident(format) operator(=) string<delimiter(")content(private method `%s' called for %s)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(visibility) operator(==) ident(PROTECTED)operator(\)) operator({) - ident(format) operator(=) string<delimiter(")content(protected method `%s' called for %s)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(callType) operator(==) ident(CallType)operator(.)ident(VARIABLE)operator(\)) operator({) - ident(format) operator(=) string<delimiter(")content(undefined local variable or method `%s' for %s)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(callType) operator(==) ident(CallType)operator(.)ident(SUPER)operator(\)) operator({) - ident(format) operator(=) string<delimiter(")content(super: no superclass method `%s')delimiter(")>operator(;) - operator(}) - - keyword(if) operator(()ident(format) operator(==) pre_constant(null)operator(\)) ident(format) operator(=) string<delimiter(")content(undefined method `%s' for %s)delimiter(")>operator(;) - - pre_type(String) ident(description) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()ident(object)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(description) operator(=) string<delimiter(")content(nil)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyBoolean) operator(&&) ident(object)operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(description) operator(=) string<delimiter(")content(true)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(object) keyword(instanceof) ident(RubyBoolean) operator(&&) operator(!)ident(object)operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(description) operator(=) string<delimiter(")content(false)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - keyword(try) operator({) - ident(description) operator(=) ident(RubyObject)operator(.)ident(inspect)operator(()ident(context)operator(,) ident(object)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(JumpException) ident(e)operator(\)) operator({)operator(}) - - keyword(if) operator(()ident(description) operator(==) pre_constant(null) operator(||) ident(description)operator(.)ident(length)operator(()operator(\)) operator(>) integer(65)operator(\)) ident(description) operator(=) ident(object)operator(.)ident(anyToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(description)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0) operator(||) operator(()ident(description)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(description)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(!=) string<delimiter(')content(#)delimiter(')>operator(\))operator(\)) operator({) - ident(description) operator(=) ident(description) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(object)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(;) - operator(}) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(arr) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(method)operator(,) ident(runtime)operator(.)ident(newString)operator(()ident(description)operator(\))operator(\))operator(;) - ident(RubyString) ident(msg) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(Sprintf)operator(.)ident(sprintf)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(format)operator(\))operator(,) ident(arr)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(object)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(msg)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(msg)operator(;) - operator(}) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(NAMEERROR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyNameError)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createNameErrorClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(standardErrorClass)operator(\)) operator({) - ident(RubyClass) ident(nameErrorClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(NameError)delimiter(")>operator(,) ident(standardErrorClass)operator(,) ident(NAMEERROR_ALLOCATOR)operator(\))operator(;) - ident(nameErrorClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNameError)operator(.)ident(class)operator(\))operator(;) - keyword(return) ident(nameErrorClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createNameErrorMessageClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(nameErrorClass)operator(\)) operator({) - ident(RubyClass) ident(messageClass) operator(=) ident(nameErrorClass)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Message)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(RubyNameErrorMessage)operator(.)ident(NAMEERRORMESSAGE_ALLOCATOR)operator(\))operator(;) - ident(messageClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNameErrorMessage)operator(.)ident(class)operator(\))operator(;) - keyword(return) ident(messageClass)operator(;) - operator(}) - - directive(protected) ident(RubyNameError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(exceptionClass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNameError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(,) pre_type(String) ident(message)operator(\)) operator({) - local_variable(this)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(message)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNameError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(,) pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(message)operator(\))operator(;) - local_variable(this)operator(.)ident(name) operator(=) ident(name) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exception)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyException) ident(newRubyNameError)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - ident(RubyException) ident(newError) operator(=) operator(()ident(RubyException)operator(\)) ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(newError)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(return) ident(newError)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(name) operator(=) ident(args)operator([)ident(args)operator(.)ident(length) operator(-) integer(1)operator(])operator(;) - type(int) ident(newLength) operator(=) ident(args)operator(.)ident(length) operator(>) integer(2) operator(?) ident(args)operator(.)ident(length) operator(-) integer(2) operator(:) ident(args)operator(.)ident(length) operator(-) integer(1)operator(;) - - ident(IRubyObject) type([])ident(tmpArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(newLength)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(tmpArgs)operator(,) integer(0)operator(,) ident(newLength)operator(\))operator(;) - ident(args) operator(=) ident(tmpArgs)operator(;) - operator(}) keyword(else) operator({) - ident(name) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - local_variable(super)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(if) operator(()ident(message)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(message)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(str) operator(=) ident(message)operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(str) operator(!=) ident(message)operator(\)) ident(message) operator(=) ident(str)operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(message)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(message)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(name)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(name)operator(()operator(\)) operator({) - keyword(return) ident(name)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(NilClass)delimiter(")>operator(\)) -directive(public) type(class) class(RubyNil) directive(extends) ident(RubyObject) operator({) - directive(public) ident(RubyNil)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getNilClass)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - ident(flags) operator(|=) ident(NIL_F) operator(|) ident(FALSE_F)operator(;) - operator(}) - - directive(public) directive(static) directive(final) ident(ObjectAllocator) ident(NIL_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createNilClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(nilClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(NilClass)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(NIL_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setNilClass)operator(()ident(nilClass)operator(\))operator(;) - ident(nilClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(NIL)operator(;) - - ident(nilClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNil)operator(.)ident(class)operator(\))operator(;) - - ident(nilClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - comment(// FIXME: This is causing a verification error for some reason) - comment(//nilClass.dispatcher = callbackFactory.createDispatcher(nilClass\);) - - keyword(return) ident(nilClass)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(NIL)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyClass) ident(getSingletonClass)operator(()operator(\)) operator({) - keyword(return) ident(metaClass)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) type(void)operator(.)ident(class)operator(;) - operator(}) - - comment(// Methods of the Nil Class (nil_*\):) - - comment(/** nil_to_i - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyFixnum) ident(to_i)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * nil_to_f - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyFloat) ident(to_f)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) float(0.0D)operator(\))operator(;) - operator(}) - - comment(/** nil_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyString) ident(to_s)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nil_to_a - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyArray) ident(to_a)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEmptyArray)operator(()operator(\))operator(;) - operator(}) - - comment(/** nil_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyString) ident(inspect)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(nil)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** nil_type - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(type)delimiter(")>operator(\)) - directive(public) directive(static) ident(RubyClass) ident(type)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNilClass)operator(()operator(\))operator(;) - operator(}) - - comment(/** nil_and - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(&)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_and)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nil_or - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(|)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_or)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(obj)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nil_xor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(^)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(op_xor)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(obj)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nil?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nil_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyFixnum) ident(id)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(4)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(taint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** nilclass_to_c - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_c)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(to_c)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyComplex)operator(.)ident(newComplexCanonicalize)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** nilclass_to_r - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalCanonicalize)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Koichiro Ohba <koichiro@meadowy.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.nio.ByteBuffer)operator(;) -keyword(import) include(java.nio.CharBuffer)operator(;) -keyword(import) include(java.nio.charset.CharacterCodingException)operator(;) -keyword(import) include(java.nio.charset.Charset)operator(;) -keyword(import) include(java.nio.charset.CharsetDecoder)operator(;) -keyword(import) include(java.nio.charset.CharsetEncoder)operator(;) -keyword(import) include(java.nio.charset.UnsupportedCharsetException)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.KCode)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(NKF)delimiter(")>operator(\)) -directive(public) type(class) class(RubyNKF) operator({) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(AUTO) operator(=) keyword(new) ident(NKFCharset)operator(()integer(0)operator(,) string<delimiter(")content(x-JISAutoDetect)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(JIS) operator(=) keyword(new) ident(NKFCharset)operator(()integer(1)operator(,) string<delimiter(")content(iso-2022-jp)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(EUC) operator(=) keyword(new) ident(NKFCharset)operator(()integer(2)operator(,) string<delimiter(")content(EUC-JP)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(SJIS) operator(=) keyword(new) ident(NKFCharset)operator(()integer(3)operator(,) string<delimiter(")content(Windows-31J)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(BINARY) operator(=) keyword(new) ident(NKFCharset)operator(()integer(4)operator(,) pre_constant(null)operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(NOCONV) operator(=) keyword(new) ident(NKFCharset)operator(()integer(4)operator(,) pre_constant(null)operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(UNKNOWN) operator(=) keyword(new) ident(NKFCharset)operator(()integer(0)operator(,) pre_constant(null)operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(ASCII) operator(=) keyword(new) ident(NKFCharset)operator(()integer(5)operator(,) string<delimiter(")content(iso-8859-1)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(UTF8) operator(=) keyword(new) ident(NKFCharset)operator(()integer(6)operator(,) string<delimiter(")content(UTF-8)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(UTF16) operator(=) keyword(new) ident(NKFCharset)operator(()integer(8)operator(,) string<delimiter(")content(UTF-16)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(UTF32) operator(=) keyword(new) ident(NKFCharset)operator(()integer(12)operator(,) string<delimiter(")content(UTF-32)delimiter(")>operator(\))operator(;) - directive(public) directive(static) directive(final) ident(NKFCharset) ident(OTHER) operator(=) keyword(new) ident(NKFCharset)operator(()integer(16)operator(,) pre_constant(null)operator(\))operator(;) - - directive(public) directive(static) type(class) class(NKFCharset) operator({) - directive(private) directive(final) type(int) ident(value)operator(;) - directive(private) directive(final) pre_type(String) ident(charset)operator(;) - - directive(public) ident(NKFCharset)operator(()type(int) ident(v)operator(,) pre_type(String) ident(c)operator(\)) operator({) - ident(value) operator(=) ident(v)operator(;) - ident(charset) operator(=) ident(c)operator(;) - operator(}) - - directive(public) type(int) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - directive(public) pre_type(String) ident(getCharset)operator(()operator(\)) operator({) - keyword(return) ident(charset)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(void) ident(createNKF)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(nkfModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(NKF)delimiter(")>operator(\))operator(;) - - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(AUTO)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(AUTO)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(JIS)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(JIS)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(EUC)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(EUC)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(SJIS)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(SJIS)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(BINARY)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(BINARY)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(NOCONV)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(NOCONV)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(UNKNOWN)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(UNKNOWN)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ASCII)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(ASCII)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(UTF8)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(UTF8)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(UTF16)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(UTF16)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(UTF32)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(UTF32)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - ident(nkfModule)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OTHER)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(OTHER)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(\))operator(;) - - ident(RubyString) ident(version) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(2.0.7 (JRuby 2007-05-11\))delimiter(")>operator(\))operator(;) - ident(RubyString) ident(nkfVersion) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(2.0.7)delimiter(")>operator(\))operator(;) - ident(RubyString) ident(nkfDate) operator(=) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(2007-05-11)delimiter(")>operator(\))operator(;) - - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - ident(version)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(nkfVersion)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(nkfDate)operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - - ident(nkfModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNKF)operator(.)ident(class)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(guess)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(guess)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(s)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(s)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(s)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - ident(ByteList) ident(bytes) operator(=) ident(s)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - pre_type(ByteBuffer) ident(buf) operator(=) pre_type(ByteBuffer)operator(.)ident(wrap)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - pre_type(CharsetDecoder) ident(decoder) operator(=) pre_type(Charset)operator(.)ident(forName)operator(()string<delimiter(")content(x-JISAutoDetect)delimiter(")>operator(\))operator(.)ident(newDecoder)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(decoder)operator(.)ident(decode)operator(()ident(buf)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(CharacterCodingException) ident(e)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(UNKNOWN)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(decoder)operator(.)ident(isCharsetDetected)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(UNKNOWN)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - pre_type(Charset) ident(charset) operator(=) ident(decoder)operator(.)ident(detectedCharset)operator(()operator(\))operator(;) - pre_type(String) ident(name) operator(=) ident(charset)operator(.)ident(name)operator(()operator(\))operator(;) -comment(// System.out.println("detect: " + name + "\\n"\);) - keyword(if) operator(()string<delimiter(")content(Shift_JIS)delimiter(")>operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(SJIS)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()string<delimiter(")content(windows-31j)delimiter(")>operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(SJIS)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(else) keyword(if) operator(()string<delimiter(")content(EUC-JP)delimiter(")>operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(EUC)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(else) keyword(if) operator(()string<delimiter(")content(ISO-2022-JP)delimiter(")>operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(JIS)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(else) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(UNKNOWN)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(guess1)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(guess1)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - keyword(return) ident(guess)operator(()ident(context)operator(,) ident(recv)operator(,) ident(str)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(guess2)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(guess2)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - keyword(return) ident(guess)operator(()ident(context)operator(,) ident(recv)operator(,) ident(str)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nkf)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(nkf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(opt)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(opt)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(opt)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(str)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't convert )delimiter(")> operator(+) ident(str)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( into String)delimiter(")>operator(\))operator(;) - operator(}) - - pre_type(Map)operator(<)pre_type(String)operator(,) ident(NKFCharset)operator(>) ident(options) operator(=) ident(parseOpt)operator(()ident(opt)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - - ident(NKFCharset) ident(nc) operator(=) ident(options)operator(.)ident(get)operator(()string<delimiter(")content(input)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(nc)operator(.)ident(getValue)operator(()operator(\)) operator(==) ident(AUTO)operator(.)ident(getValue)operator(()operator(\))operator(\)) operator({) - ident(KCode) ident(kcode) operator(=) ident(runtime)operator(.)ident(getKCode)operator(()operator(\))operator(;) - keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(SJIS)operator(\)) operator({) - ident(nc) operator(=) ident(SJIS)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(EUC)operator(\)) operator({) - ident(nc) operator(=) ident(EUC)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(UTF8)operator(\)) operator({) - ident(nc) operator(=) ident(UTF8)operator(;) - operator(}) - operator(}) - pre_type(String) ident(decodeCharset) operator(=) ident(nc)operator(.)ident(getCharset)operator(()operator(\))operator(;) - pre_type(String) ident(encodeCharset) operator(=) ident(options)operator(.)ident(get)operator(()string<delimiter(")content(output)delimiter(")>operator(\))operator(.)ident(getCharset)operator(()operator(\))operator(;) - - keyword(return) ident(convert)operator(()ident(context)operator(,) ident(decodeCharset)operator(,) ident(encodeCharset)operator(,) ident(str)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(decodeCharset)operator(,) - pre_type(String) ident(encodeCharset)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(CharsetDecoder) ident(decoder)operator(;) - pre_type(CharsetEncoder) ident(encoder)operator(;) - keyword(try) operator({) - ident(decoder) operator(=) pre_type(Charset)operator(.)ident(forName)operator(()ident(decodeCharset)operator(\))operator(.)ident(newDecoder)operator(()operator(\))operator(;) - ident(encoder) operator(=) pre_type(Charset)operator(.)ident(forName)operator(()ident(encodeCharset)operator(\))operator(.)ident(newEncoder)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedCharsetException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid encoding)delimiter(")>operator(\))operator(;) - operator(}) - - ident(ByteList) ident(bytes) operator(=) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - pre_type(ByteBuffer) ident(buf) operator(=) pre_type(ByteBuffer)operator(.)ident(wrap)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - keyword(try) operator({) - pre_type(CharBuffer) ident(cbuf) operator(=) ident(decoder)operator(.)ident(decode)operator(()ident(buf)operator(\))operator(;) - ident(buf) operator(=) ident(encoder)operator(.)ident(encode)operator(()ident(cbuf)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(CharacterCodingException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid encoding)delimiter(")>operator(\))operator(;) - operator(}) - type(byte)type([]) ident(arr) operator(=) ident(buf)operator(.)ident(array)operator(()operator(\))operator(;) - - keyword(return) ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()ident(arr)operator(,) integer(0)operator(,) ident(buf)operator(.)ident(limit)operator(()operator(\))operator(\))operator(\))operator(;) - - operator(}) - - directive(private) directive(static) type(int) ident(optionUTF)operator(()pre_type(String) ident(s)operator(,) type(int) ident(i)operator(\)) operator({) - type(int) ident(n) operator(=) integer(8)operator(;) - keyword(if) operator(()ident(i)operator(+)integer(1) operator(<) ident(s)operator(.)ident(length)operator(()operator(\)) operator(&&) pre_type(Character)operator(.)ident(isDigit)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(+)integer(1)operator(\))operator(\))operator(\)) operator({) - ident(n) operator(=) pre_type(Character)operator(.)ident(digit)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(+)integer(1)operator(\))operator(,) integer(10)operator(\))operator(;) - keyword(if) operator(()ident(i)operator(+)integer(2) operator(<) ident(s)operator(.)ident(length)operator(()operator(\)) operator(&&) pre_type(Character)operator(.)ident(isDigit)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(+)integer(2)operator(\))operator(\))operator(\)) operator({) - ident(n) operator(*=) integer(10)operator(;) - ident(n) operator(+=) pre_type(Character)operator(.)ident(digit)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(+)integer(2)operator(\))operator(,) integer(10)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(n)operator(;) - operator(}) - - directive(private) directive(static) pre_type(Map)operator(<)pre_type(String)operator(,) ident(NKFCharset)operator(>) ident(parseOpt)operator(()pre_type(String) ident(s)operator(\)) operator({) - pre_type(Map)operator(<)pre_type(String)operator(,) ident(NKFCharset)operator(>) ident(options) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) ident(NKFCharset)operator(>)operator(()operator(\))operator(;) - - comment(// default options) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(AUTO)operator(\))operator(;) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(JIS)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(s)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(switch) operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(b)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(u)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(j)delimiter(')>operator(:) comment(// iso-2022-jp) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(JIS)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(s)delimiter(')>operator(:) comment(// Shift_JIS) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(SJIS)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(e)delimiter(')>operator(:) comment(// EUC-JP) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(EUC)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(w)delimiter(')>operator(:) comment(// UTF-8) - operator({) - type(int) ident(n) operator(=) ident(optionUTF)operator(()ident(s)operator(,) ident(i)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(==) integer(32)operator(\)) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(UTF32)operator(\))operator(;) - keyword(else) keyword(if) operator(()ident(n) operator(==) integer(16)operator(\)) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(UTF16)operator(\))operator(;) - keyword(else) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(output)delimiter(")>operator(,) ident(UTF8)operator(\))operator(;) - operator(}) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(J)delimiter(')>operator(:) comment(// iso-2022-jp) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(JIS)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(S)delimiter(')>operator(:) comment(// Shift_JIS) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(SJIS)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(E)delimiter(')>operator(:) comment(// EUC-JP) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(EUC)operator(\))operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(W)delimiter(')>operator(:) comment(// UTF-8) - operator({) - type(int) ident(n) operator(=) ident(optionUTF)operator(()ident(s)operator(,) ident(i)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(==) integer(32)operator(\)) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(UTF32)operator(\))operator(;) - keyword(else) keyword(if) operator(()ident(n) operator(==) integer(16)operator(\)) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(UTF16)operator(\))operator(;) - keyword(else) - ident(options)operator(.)ident(put)operator(()string<delimiter(")content(input)delimiter(")>operator(,) ident(UTF8)operator(\))operator(;) - operator(}) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(t)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(r)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(h)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(m)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(M)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(l)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(f)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(F)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(Z)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(X)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(x)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(B)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(T)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(d)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(c)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(I)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(L)delimiter(')>operator(:) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(if) operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(+)integer(1)operator(\)) operator(==) string<delimiter(')content(-)delimiter(')>operator(\)) operator({) - comment(// long name option) - operator(}) - keyword(default)operator(:) - operator(}) - operator(}) - keyword(return) ident(options)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(NoMethodError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(NameError)delimiter(")>operator(\)) -directive(public) type(class) class(RubyNoMethodError) directive(extends) ident(RubyNameError) operator({) - directive(private) ident(IRubyObject) ident(args)operator(;) - - directive(private) directive(static) directive(final) ident(ObjectAllocator) ident(NOMETHODERROR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyNoMethodError)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createNoMethodErrorClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(nameErrorClass)operator(\)) operator({) - ident(RubyClass) ident(noMethodErrorClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(NoMethodError)delimiter(")>operator(,) ident(nameErrorClass)operator(,) ident(NOMETHODERROR_ALLOCATOR)operator(\))operator(;) - - ident(noMethodErrorClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNoMethodError)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(noMethodErrorClass)operator(;) - operator(}) - - directive(protected) ident(RubyNoMethodError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(exceptionClass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - local_variable(this)operator(.)ident(args) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNoMethodError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(,) pre_type(String) ident(message)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(args)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(,) ident(message)operator(,) ident(name)operator(\))operator(;) - local_variable(this)operator(.)ident(args) operator(=) ident(args)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) operator({) - local_variable(this)operator(.)ident(args) operator(=) ident(args)operator([)ident(args)operator(.)ident(length) operator(-) integer(1)operator(])operator(;) - ident(IRubyObject) type([])ident(tmpArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(args)operator(.)ident(length) operator(-) integer(1)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(tmpArgs)operator(,) integer(0)operator(,) ident(tmpArgs)operator(.)ident(length)operator(\))operator(;) - ident(args) operator(=) ident(tmpArgs)operator(;) - operator(}) keyword(else) operator({) - local_variable(this)operator(.)ident(args) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - local_variable(super)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(args)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(args)operator(()operator(\)) operator({) - keyword(return) ident(args)operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2006 Antti Karanta <Antti.Karanta@napa.fi> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.util.Numeric.f_abs)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_arg)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_negative_p)operator(;) - -keyword(import) include(java.math.BigInteger)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.Convert)operator(;) - -comment(/** - * Base class for all numerical types in ruby. - */) -comment(// TODO: Numeric.new works in Ruby and it does here too. However trying to use) -comment(// that instance in a numeric operation should generate an ArgumentError. Doing) -comment(// this seems so pathological I do not see the need to fix this now.) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Numeric)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Comparable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyNumeric) directive(extends) ident(RubyObject) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createNumericClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(numeric) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Numeric)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(NUMERIC_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setNumeric)operator(()ident(numeric)operator(\))operator(;) - - ident(numeric)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyNumeric)operator(;) - operator(}) - operator(})operator(;) - - ident(numeric)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getComparable)operator(()operator(\))operator(\))operator(;) - ident(numeric)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyNumeric)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(numeric)operator(;) - operator(}) - - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(NUMERIC_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyNumeric)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) type(double) ident(DBL_EPSILON)operator(=)float(2.2204460492503131e-16)operator(;) - - directive(private) directive(static) ident(IRubyObject) ident(convertToNum)operator(()type(double) ident(val)operator(,) ident(Ruby) ident(runtime)operator(\)) operator({) - - keyword(if) operator(()ident(val) operator(>=) operator(()type(double)operator(\)) ident(RubyFixnum)operator(.)ident(MAX) operator(||) ident(val) operator(<) operator(()type(double)operator(\)) ident(RubyFixnum)operator(.)ident(MIN)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(runtime)operator(,) ident(val)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) operator(()type(long)operator(\)) ident(val)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNumeric)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(metaClass)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyNumeric)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(,) type(boolean) ident(useObjectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(metaClass)operator(,) ident(useObjectSpace)operator(\))operator(;) - operator(}) - - comment(// The implementations of these are all bonus (see TODO above\) I was going) - comment(// to throw an error from these, but it appears to be the wrong place to) - comment(// do it.) - directive(public) type(double) ident(getDoubleValue)operator(()operator(\)) operator({) - keyword(return) integer(0)operator(;) - operator(}) - - directive(public) type(long) ident(getLongValue)operator(()operator(\)) operator({) - keyword(return) integer(0)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyNumeric) ident(newNumeric)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyNumeric)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* ================ - * Utility Methods - * ================ - */) - - comment(/** rb_num2int, NUM2INT - * - */) - directive(public) directive(static) type(int) ident(num2int)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - type(long) ident(num) operator(=) ident(num2long)operator(()ident(arg)operator(\))operator(;) - - ident(checkInt)operator(()ident(arg)operator(,) ident(num)operator(\))operator(;) - keyword(return) operator(()type(int)operator(\))ident(num)operator(;) - operator(}) - - comment(/** check_int - * - */) - directive(public) directive(static) type(void) ident(checkInt)operator(()ident(IRubyObject) ident(arg)operator(,) type(long) ident(num)operator(\))operator({) - pre_type(String) ident(s)operator(;) - keyword(if) operator(()ident(num) operator(<) pre_type(Integer)operator(.)ident(MIN_VALUE)operator(\)) operator({) - ident(s) operator(=) string<delimiter(")content(small)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(num) operator(>) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(\)) operator({) - ident(s) operator(=) string<delimiter(")content(big)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - keyword(return)operator(;) - operator(}) - keyword(throw) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(integer )delimiter(")> operator(+) ident(num) operator(+) string<delimiter(")content( too )delimiter(")> operator(+) ident(s) operator(+) string<delimiter(")content( to convert to `int')delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * NUM2CHR - */) - directive(public) directive(static) type(byte) ident(num2chr)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyString)operator(\)) operator({) - pre_type(String) ident(value) operator(=) operator(()operator(()ident(RubyString)operator(\)) ident(arg)operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(value) operator(!=) pre_constant(null) operator(&&) ident(value)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0)operator(\)) keyword(return) operator(()type(byte)operator(\)) ident(value)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(;) - operator(}) - - keyword(return) operator(()type(byte)operator(\)) ident(num2int)operator(()ident(arg)operator(\))operator(;) - operator(}) - - comment(/** rb_num2long and FIX2LONG (numeric.c\) - * - */) - directive(public) directive(static) type(long) ident(num2long)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyFixnum)operator(\)) ident(arg)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(arg)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(no implicit conversion from nil to integer)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(aFloat) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(arg)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(aFloat) operator(<=) operator(()type(double)operator(\)) pre_type(Long)operator(.)ident(MAX_VALUE) operator(&&) ident(aFloat) operator(>=) operator(()type(double)operator(\)) pre_type(Long)operator(.)ident(MIN_VALUE)operator(\)) operator({) - keyword(return) operator(()type(long)operator(\)) ident(aFloat)operator(;) - operator(}) keyword(else) operator({) - comment(// TODO: number formatting here, MRI uses "%-.10g", 1.4 API is a must?) - keyword(throw) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(float )delimiter(")> operator(+) ident(aFloat) operator(+) string<delimiter(")content( out of range of integer)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(big2long)operator(()operator(()ident(RubyBignum)operator(\)) ident(arg)operator(\))operator(;) - operator(}) - keyword(return) ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_dbl2big + LONG2FIX at once (numeric.c\) - * - */) - directive(public) directive(static) ident(IRubyObject) ident(dbl2num)operator(()ident(Ruby) ident(runtime)operator(,) type(double) ident(val)operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(val)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFloatDomainError)operator(()ident(val) operator(<) integer(0) operator(?) string<delimiter(")content(-Infinity)delimiter(")> operator(:) string<delimiter(")content(Infinity)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(val)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newFloatDomainError)operator(()string<delimiter(")content(NaN)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(convertToNum)operator(()ident(val)operator(,)ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** rb_num2dbl and NUM2DBL - * - */) - directive(public) directive(static) type(double) ident(num2dbl)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyFloat)operator(\)) ident(arg)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(throw) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(no implicit conversion to float from string)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) operator(==) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(arg)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(no implicit conversion to float from nil)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(arg)operator(.)ident(convertToFloat)operator(()operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_dbl_cmp (numeric.c\) - * - */) - directive(public) directive(static) ident(IRubyObject) ident(dbl_cmp)operator(()ident(Ruby) ident(runtime)operator(,) type(double) ident(a)operator(,) type(double) ident(b)operator(\)) operator({) - keyword(if) operator(()pre_type(Double)operator(.)ident(isNaN)operator(()ident(a)operator(\)) operator(||) pre_type(Double)operator(.)ident(isNaN)operator(()ident(b)operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(a) operator(>) ident(b)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(a) operator(<) ident(b)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(long) ident(fix2long)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyFixnum)operator(\)) ident(arg)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(int) ident(fix2int)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - type(long) ident(num) operator(=) ident(arg) keyword(instanceof) ident(RubyFixnum) operator(?) ident(fix2long)operator(()ident(arg)operator(\)) operator(:) ident(num2long)operator(()ident(arg)operator(\))operator(;) - - ident(checkInt)operator(()ident(arg)operator(,) ident(num)operator(\))operator(;) - keyword(return) operator(()type(int)operator(\)) ident(num)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyInteger) ident(str2inum)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(str)operator(,) type(int) ident(base)operator(\)) operator({) - keyword(return) ident(str2inum)operator(()ident(runtime)operator(,)ident(str)operator(,)ident(base)operator(,)pre_constant(false)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyNumeric) ident(int2fix)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(val)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,)ident(val)operator(\))operator(;) - operator(}) - - comment(/** rb_num2fix - * - */) - directive(public) directive(static) ident(IRubyObject) ident(num2fix)operator(()ident(IRubyObject) ident(val)operator(\)) operator({) - keyword(if) operator(()ident(val) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(return) ident(val)operator(;) - operator(}) - keyword(if) operator(()ident(val) keyword(instanceof) ident(RubyBignum)operator(\)) operator({) - comment(// any BigInteger is bigger than Fixnum and we don't have FIXABLE) - keyword(throw) ident(val)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(integer )delimiter(")> operator(+) ident(val) operator(+) string<delimiter(")content( out of range of fixnum)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(val)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(num2long)operator(()ident(val)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Converts a string representation of an integer to the integer value. - * Parsing starts at the beginning of the string (after leading and - * trailing whitespace have been removed\), and stops at the end or at the - * first character that can't be part of an integer. Leading signs are - * allowed. If <code>base</code> is zero, strings that begin with '0[xX]', - * '0[bB]', or '0' (optionally preceded by a sign\) will be treated as hex, - * binary, or octal numbers, respectively. If a non-zero base is given, - * only the prefix (if any\) that is appropriate to that base will be - * parsed correctly. For example, if the base is zero or 16, the string - * "0xff" will be converted to 256, but if the base is 10, it will come out - * as zero, since 'x' is not a valid decimal digit. If the string fails - * to parse as a number, zero is returned. - * - * @param runtime the ruby runtime - * @param str the string to be converted - * @param base the expected base of the number (for example, 2, 8, 10, 16\), - * or 0 if the method should determine the base automatically - * (defaults to 10\). Values 0 and 2-36 are permitted. Any other - * value will result in an ArgumentError. - * @param strict if true, enforce the strict criteria for String encoding of - * numeric values, as required by Integer('n'\), and raise an - * exception when those criteria are not met. Otherwise, allow - * lax expression of values, as permitted by String#to_i, and - * return a value in almost all cases (excepting illegal radix\). - * TODO: describe the rules/criteria - * @return a RubyFixnum or (if necessary\) a RubyBignum representing - * the result of the conversion, which will be zero if the - * conversion failed. - */) - directive(public) directive(static) ident(RubyInteger) ident(str2inum)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(str)operator(,) type(int) ident(base)operator(,) type(boolean) ident(strict)operator(\)) operator({) - keyword(if) operator(()ident(base) operator(!=) integer(0) operator(&&) operator(()ident(base) operator(<) integer(2) operator(||) ident(base) operator(>) integer(36)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(illegal radix )delimiter(")> operator(+) ident(base)operator(\))operator(;) - operator(}) - ident(ByteList) ident(bytes) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(Convert)operator(.)ident(byteListToLong)operator(()ident(bytes)operator(,) ident(base)operator(,) ident(strict)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidIntegerException) ident(e)operator(\)) operator({) - keyword(return) ident(str2inumIIE)operator(()ident(strict)operator(,) ident(runtime)operator(,) ident(str)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(NumberTooLargeException) ident(e)operator(\)) operator({) - keyword(return) ident(str2inumNTLE)operator(()ident(strict)operator(,) ident(runtime)operator(,) ident(str)operator(,) ident(bytes)operator(,) ident(base)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) ident(RubyInteger) ident(str2inumIIE)operator(()type(boolean) ident(strict)operator(,) ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(str)operator(\)) directive(throws) ident(RaiseException) operator({) - keyword(if) operator(()ident(strict)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Integer: )delimiter(")> operator(+) ident(str)operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(RubyInteger) ident(str2inumNTLE)operator(()type(boolean) ident(strict)operator(,) ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(str)operator(,) ident(ByteList) ident(bytes)operator(,) type(int) ident(base)operator(\)) operator({) - keyword(try) operator({) - pre_type(BigInteger) ident(bi) operator(=) ident(Convert)operator(.)ident(byteListToBigInteger)operator(()ident(bytes)operator(,) ident(base)operator(,) ident(strict)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyBignum)operator(()ident(runtime)operator(,) ident(bi)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(InvalidIntegerException) ident(e2)operator(\)) operator({) - keyword(return) ident(str2inumIIE)operator(()ident(strict)operator(,) ident(runtime)operator(,) ident(str)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyFloat) ident(str2fnum)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(arg)operator(\)) operator({) - keyword(return) ident(str2fnum)operator(()ident(runtime)operator(,)ident(arg)operator(,)pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** - * Converts a string representation of a floating-point number to the - * numeric value. Parsing starts at the beginning of the string (after - * leading and trailing whitespace have been removed\), and stops at the - * end or at the first character that can't be part of a number. If - * the string fails to parse as a number, 0.0 is returned. - * - * @param runtime the ruby runtime - * @param arg the string to be converted - * @param strict if true, enforce the strict criteria for String encoding of - * numeric values, as required by Float('n'\), and raise an - * exception when those criteria are not met. Otherwise, allow - * lax expression of values, as permitted by String#to_f, and - * return a value in all cases. - * TODO: describe the rules/criteria - * @return a RubyFloat representing the result of the conversion, which - * will be 0.0 if the conversion failed. - */) - directive(public) directive(static) ident(RubyFloat) ident(str2fnum)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(arg)operator(,) type(boolean) ident(strict)operator(\)) operator({) - directive(final) type(double) ident(ZERO) operator(=) float(0.0)operator(;) - - keyword(try) operator({) - keyword(return) keyword(new) ident(RubyFloat)operator(()ident(runtime)operator(,)ident(Convert)operator(.)ident(byteListToDouble)operator(()ident(arg)operator(.)ident(getByteList)operator(()operator(\))operator(,)ident(strict)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(NumberFormatException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(strict)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Float(\): )delimiter(")> - operator(+) ident(arg)operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) keyword(new) ident(RubyFloat)operator(()ident(runtime)operator(,)ident(ZERO)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Numeric methods. (num_*\) - * - */) - - directive(protected) ident(IRubyObject)type([]) ident(getCoerced)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) type(boolean) ident(error)operator(\)) operator({) - ident(IRubyObject) ident(result)operator(;) - - keyword(try) operator({) - ident(result) operator(=) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(coerce)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(error)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(() - ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( can't be coerced into )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) pre_constant(null)operator(;) - operator(}) - - keyword(if) operator(()operator(!)operator(()ident(result) keyword(instanceof) ident(RubyArray)operator(\)) operator(||) operator(()operator(()ident(RubyArray)operator(\))ident(result)operator(\))operator(.)ident(getLength)operator(()operator(\)) operator(!=) integer(2)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(coerce must return [x, y])delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) operator(()operator(()ident(RubyArray)operator(\))ident(result)operator(\))operator(.)ident(toJavaArray)operator(()operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(callCoerced)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(,) type(boolean) ident(err)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) ident(getCoerced)operator(()ident(context)operator(,) ident(other)operator(,) ident(err)operator(\))operator(;) - keyword(if)operator(()ident(args) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(callCoerced)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject)type([]) ident(args) operator(=) ident(getCoerced)operator(()ident(context)operator(,) ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(args) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - - comment(// beneath are rewritten coercions that reflect MRI logic, the aboves are used only by RubyBigDecimal) - - comment(/** coerce_body - * - */) - directive(protected) directive(final) ident(IRubyObject) ident(coerceBody)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(coerce)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** do_coerce - * - */) - directive(protected) directive(final) ident(RubyArray) ident(doCoerce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(,) type(boolean) ident(err)operator(\)) operator({) - ident(IRubyObject) ident(result)operator(;) - keyword(try) operator({) - ident(result) operator(=) ident(coerceBody)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(e)operator(\)) operator({) - keyword(if) operator(()ident(err)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(() - ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( can't be coerced into )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - keyword(if) operator(()operator(!)operator(()ident(result) keyword(instanceof) ident(RubyArray)operator(\)) operator(||) operator(()operator(()ident(RubyArray)operator(\)) ident(result)operator(\))operator(.)ident(getLength)operator(()operator(\)) operator(!=) integer(2)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(coerce must return [x, y])delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) operator(()ident(RubyArray)operator(\)) ident(result)operator(;) - operator(}) - - comment(/** rb_num_coerce_bin - * coercion taking two arguments - */) - directive(protected) directive(final) ident(IRubyObject) ident(coerceBin)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(doCoerce)operator(()ident(context)operator(,) ident(other)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) operator(()ident(ary)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(,) ident(ary)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_num_coerce_cmp - * coercion used for comparisons - */) - directive(protected) directive(final) ident(IRubyObject) ident(coerceCmp)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(doCoerce)operator(()ident(context)operator(,) ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(ary) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) comment(// MRI does it!) - operator(}) - keyword(return) operator(()ident(ary)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(,) ident(ary)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_num_coerce_relop - * coercion used for relative operators - */) - directive(protected) directive(final) ident(IRubyObject) ident(coerceRelOp)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(doCoerce)operator(()ident(context)operator(,) ident(other)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if) operator(()ident(ary) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(RubyComparable)operator(.)ident(cmperr)operator(()local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - keyword(return) ident(unwrapCoerced)operator(()ident(context)operator(,) ident(method)operator(,) ident(other)operator(,) ident(ary)operator(\))operator(;) - operator(}) - - directive(private) directive(final) ident(IRubyObject) ident(unwrapCoerced)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(method)operator(,) ident(IRubyObject) ident(other)operator(,) ident(RubyArray) ident(ary)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) operator(()ident(ary)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(method)operator(,) ident(ary)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RubyComparable)operator(.)ident(cmperr)operator(()local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) ident(RubyNumeric) ident(asNumeric)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/* ================ - * Instance Methods - * ================ - */) - - comment(/** num_sadded - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(singleton_method_added)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sadded)operator(()ident(IRubyObject) ident(name)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't define singleton method )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( for )delimiter(")> operator(+) ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** num_init_copy - * - */) - annotation(@Override) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't copy )delimiter(")> operator(+) ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** num_coerce - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(coerce)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(getClass)operator(()operator(\)) operator(==) ident(other)operator(.)ident(getClass)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(other)operator(,) local_variable(this)operator(\))operator(;) - - ident(IRubyObject) ident(cdr) operator(=) ident(RubyKernel)operator(.)ident(new_float)operator(()local_variable(this)operator(,) local_variable(this)operator(\))operator(;) - ident(IRubyObject) ident(car) operator(=) ident(RubyKernel)operator(.)ident(new_float)operator(()local_variable(this)operator(,) ident(other)operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(car)operator(,) ident(cdr)operator(\))operator(;) - operator(}) - - comment(/** num_uplus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uplus)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** num_uminus - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-@)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_uminus)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyFixnum) ident(zero) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyArray) ident(ary) operator(=) ident(zero)operator(.)ident(doCoerce)operator(()ident(context)operator(,) local_variable(this)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) ident(ary)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(ary)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(\))operator(;) - operator(}) - - comment(/** num_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) operator({) comment(// won't hurt fixnums) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_eql - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(getClass)operator(()operator(\)) operator(!=) ident(other)operator(.)ident(getClass)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(return) ident(equalInternal)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_quo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(quo)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(quo)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** num_quo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(quo)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(quo_19)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalRaw)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** num_div - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(div)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(.)ident(convertToFloat)operator(()operator(\))operator(.)ident(floor)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_divmod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(divmod)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(RubyArray)operator(.)ident(newArray)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(div)operator(()ident(context)operator(,) ident(other)operator(\))operator(,) ident(modulo)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - - comment(/** num_fdiv (1.9\) */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fdiv)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(fdiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(.)ident(convertToFloat)operator(()operator(\))operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** num_modulo - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(modulo)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(modulo)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** num_remainder - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remainder)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(remainder)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(dividend)operator(\)) operator({) - ident(IRubyObject) ident(z) operator(=) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(%)delimiter(")>operator(,) ident(dividend)operator(\))operator(;) - ident(IRubyObject) ident(x) operator(=) local_variable(this)operator(;) - ident(RubyFixnum) ident(zero) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(equalInternal)operator(()ident(context)operator(,) ident(z)operator(,) ident(zero)operator(\)) operator(&&) - operator(()operator(()ident(x)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(&&) - ident(dividend)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_GT)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator(||) - operator(()ident(x)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_GT)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(&&) - ident(dividend)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(zero)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(z)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(dividend)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(z)operator(;) - operator(}) - operator(}) - - comment(/** num_abs - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(abs)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(-@)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** num_to_int - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_int)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_int)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) string<delimiter(")content(to_i)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** num_scalar_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scalar?)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(scalar_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_int_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(integer?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(integer_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_zero_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(zero_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(equalInternal)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_nonzero_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nonzero?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nonzero_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(zero?)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** num_floor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(floor)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(floor)operator(()operator(\)) operator({) - keyword(return) ident(convertToFloat)operator(()operator(\))operator(.)ident(floor)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_ceil - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ceil)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(ceil)operator(()operator(\)) operator({) - keyword(return) ident(convertToFloat)operator(()operator(\))operator(.)ident(ceil)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_round - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(round)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(round)operator(()operator(\)) operator({) - keyword(return) ident(convertToFloat)operator(()operator(\))operator(.)ident(round)operator(()operator(\))operator(;) - operator(}) - - comment(/** num_truncate - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(truncate)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(truncate)operator(()operator(\)) operator({) - keyword(return) ident(convertToFloat)operator(()operator(\))operator(.)ident(truncate)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(step)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(step)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(step)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(step)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(2)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(step)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(step)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(step)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(step)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(step)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(to)operator(,) ident(IRubyObject) ident(step)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(to) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(step) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(value) operator(=) ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(end) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(to)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(diff) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(step)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(diff) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step cannot be 0)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(diff) operator(>) integer(0)operator(\)) operator({) - keyword(for) operator(()type(long) ident(i) operator(=) ident(value)operator(;) ident(i) operator(<=) ident(end)operator(;) ident(i) operator(+=) ident(diff)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(long) ident(i) operator(=) ident(value)operator(;) ident(i) operator(>=) ident(end)operator(;) ident(i) operator(+=) ident(diff)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyFloat) operator(||) ident(to) keyword(instanceof) ident(RubyFloat) operator(||) ident(step) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(beg) operator(=) ident(num2dbl)operator(()local_variable(this)operator(\))operator(;) - type(double) ident(end) operator(=) ident(num2dbl)operator(()ident(to)operator(\))operator(;) - type(double) ident(unit) operator(=) ident(num2dbl)operator(()ident(step)operator(\))operator(;) - - keyword(if) operator(()ident(unit) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step cannot be 0)delimiter(")>operator(\))operator(;) - operator(}) - - type(double) ident(n) operator(=) operator(()ident(end) operator(-) ident(beg)operator(\))operator(/)ident(unit)operator(;) - type(double) ident(err) operator(=) operator(()pre_type(Math)operator(.)ident(abs)operator(()ident(beg)operator(\)) operator(+) pre_type(Math)operator(.)ident(abs)operator(()ident(end)operator(\)) operator(+) pre_type(Math)operator(.)ident(abs)operator(()ident(end) operator(-) ident(beg)operator(\))operator(\)) operator(/) pre_type(Math)operator(.)ident(abs)operator(()ident(unit)operator(\)) operator(*) ident(DBL_EPSILON)operator(;) - - keyword(if) operator(()ident(err)operator(>)float(0.5)operator(\)) operator({) - ident(err)operator(=)float(0.5)operator(;) - operator(}) - ident(n) operator(=) pre_type(Math)operator(.)ident(floor)operator(()ident(n) operator(+) ident(err)operator(\)) operator(+) integer(1)operator(;) - - keyword(for)operator(()type(double) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(n)operator(;) ident(i)operator(++)operator(\))operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(i) operator(*) ident(unit) operator(+) ident(beg)operator(\))operator(\))operator(;) - operator(}) - - operator(}) keyword(else) operator({) - ident(RubyNumeric) ident(i) operator(=) local_variable(this)operator(;) - - type(int) ident(cmp)operator(;) - pre_type(String) ident(cmpString)operator(;) - keyword(if) operator(()operator(()operator(()ident(RubyBoolean)operator(\)) ident(step)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_GT)operator(,) string<delimiter(")content(>)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(cmp) operator(=) ident(MethodIndex)operator(.)ident(OP_GT)operator(;) - operator(}) keyword(else) operator({) - ident(cmp) operator(=) ident(MethodIndex)operator(.)ident(OP_LT)operator(;) - operator(}) - ident(cmpString) operator(=) ident(MethodIndex)operator(.)ident(NAMES)operator(.)ident(get)operator(()ident(cmp)operator(\))operator(;) - - keyword(while) operator(()pre_constant(true)operator(\)) operator({) - keyword(if) operator(()ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(cmp)operator(,) ident(cmpString)operator(,) ident(to)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(i)operator(\))operator(;) - ident(i) operator(=) operator(()ident(RubyNumeric)operator(\)) ident(i)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(step)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** num_equal, doesn't override RubyObject.op_equal - * - */) - directive(protected) directive(final) ident(IRubyObject) ident(op_num_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - comment(// it won't hurt fixnums) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EQUALEQUAL)operator(,) string<delimiter(")content(==)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** num_numerator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(numerator)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(numerator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalConvert)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(numerator)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** num_denominator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(denominator)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(denominator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalConvert)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(denominator)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** numeric_to_c - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_c)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(to_c)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyComplex)operator(.)ident(newComplexCanonicalize)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** numeric_re - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(re)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(re)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyComplex)operator(.)ident(newComplexConvert)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** numeric_im - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(im)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(im)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyComplex)operator(.)ident(newComplexConvert)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** numeric_real - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(real)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(real)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** numeric_image - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(image)delimiter(")>operator(,) string<delimiter(")content(imag)delimiter(")>operator(})operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(image)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** numeric_arg - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(arg)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(arg)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(f_negative_p)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getMath)operator(()operator(\))operator(.)ident(fastFetchConstant)operator(()string<delimiter(")content(PI)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** numeric_polar - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(polar)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(polar)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(f_abs)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(f_arg)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(\))operator(;) - operator(}) - - comment(/** numeric_real - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(conjugate)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(conjugate)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) directive(static) type(class) class(InvalidIntegerException) directive(extends) exception(NumberFormatException) operator({) - directive(private) directive(static) directive(final) type(long) ident(serialVersionUID) operator(=) integer(55019452543252148L)operator(;) - - directive(public) ident(InvalidIntegerException)operator(()operator(\)) operator({) - local_variable(super)operator(()operator(\))operator(;) - operator(}) - directive(public) ident(InvalidIntegerException)operator(()pre_type(String) ident(message)operator(\)) operator({) - local_variable(super)operator(()ident(message)operator(\))operator(;) - operator(}) - directive(public) pre_type(Throwable) ident(fillInStackTrace)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - directive(public) directive(static) type(class) class(NumberTooLargeException) directive(extends) exception(NumberFormatException) operator({) - directive(private) directive(static) directive(final) type(long) ident(serialVersionUID) operator(=) operator(-)integer(1835120694982699449L)operator(;) - directive(public) ident(NumberTooLargeException)operator(()operator(\)) operator({) - local_variable(super)operator(()operator(\))operator(;) - operator(}) - directive(public) ident(NumberTooLargeException)operator(()pre_type(String) ident(message)operator(\)) operator({) - local_variable(super)operator(()ident(message)operator(\))operator(;) - operator(}) - directive(public) pre_type(Throwable) ident(fillInStackTrace)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Ola Bini <ola.bini@ki.se> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 MenTaLguY <mental@rydia.net> - * Copyright (C\) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.io.ObjectInputStream)operator(;) -keyword(import) include(java.io.ObjectOutputStream)operator(;) -keyword(import) include(java.io.Serializable)operator(;) -keyword(import) include(java.util.concurrent.atomic.AtomicBoolean)operator(;) - -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.evaluator.ASTInterpreter)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) -keyword(import) include(org.jruby.runtime.component.VariableEntry)operator(;) -keyword(import) include(org.jruby.util.IdUtil)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.javasupport.JavaObject)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.builtin.InstanceVariables)operator(;) -keyword(import) include(org.jruby.runtime.builtin.InternalVariables)operator(;) -keyword(import) include(org.jruby.runtime.marshal.CoreObjectType)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) - -comment(/** - * RubyObject is the only implementation of the - * {@link org.jruby.runtime.builtin.IRubyObject}. Every Ruby object in JRuby - * is represented by something that is an instance of RubyObject. In - * some of the core class implementations, this means doing a subclass - * that extends RubyObject, in other cases it means using a simple - * RubyObject instance and the data field to store specific - * information about the Ruby object. - * - * Some care has been taken to make the implementation be as - * monomorphic as possible, so that the Java Hotspot engine can - * improve performance of it. That is the reason for several patterns - * that might seem odd in this class. - * - * The IRubyObject interface used to have lots of methods for - * different things, but these have now mostly been refactored into - * several interfaces that gives access to that specific part of the - * object. This gives us the possibility to switch out that subsystem - * without changing interfaces again. For example, instance variable - * and internal variables are handled this way, but the implementation - * in RubyObject only returns "this" in {@link #getInstanceVariables(\)} and - * {@link #getInternalVariables(\)}. - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Object)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Kernel)delimiter(")>operator(\)) -directive(public) type(class) class(RubyObject) directive(implements) pre_type(Cloneable)operator(,) ident(IRubyObject)operator(,) pre_type(Serializable)operator(,) ident(CoreObjectType)operator(,) ident(InstanceVariables)operator(,) ident(InternalVariables) operator({) - - comment(/** - * It's not valid to create a totally empty RubyObject. Since the - * RubyObject is always defined in relation to a runtime, that - * means that creating RubyObjects from outside the class might - * cause problems. - */) - directive(private) ident(RubyObject)operator(()operator(\))operator({)operator(})operator(;) - - comment(/** - * A value that is used as a null sentinel in among other places - * the RubyArray implementation. It will cause large problems to - * call any methods on this object. - */) - directive(public) directive(static) directive(final) ident(IRubyObject) ident(NEVER) operator(=) keyword(new) ident(RubyObject)operator(()operator(\))operator(;) - - comment(/** - * A value that specifies an undefined value. This value is used - * as a sentinel for undefined constant values, and other places - * where neither null nor NEVER makes sense. - */) - directive(public) directive(static) directive(final) ident(IRubyObject) ident(UNDEF) operator(=) keyword(new) ident(RubyObject)operator(()operator(\))operator(;) - - comment(// The class of this object) - directive(protected) directive(transient) ident(RubyClass) ident(metaClass)operator(;) - - comment(/** - * The variableTable contains variables for an object, defined as: - * <ul> - * <li> instance variables - * <li> class variables (for classes/modules\) - * <li> internal variables (such as those used when marshaling RubyRange and RubyException\) - * </ul> - * - * Constants are stored separately, see {@link RubyModule}. - * - */) - directive(protected) directive(transient) directive(volatile) ident(VariableTableEntry)type([]) ident(variableTable)operator(;) - directive(protected) directive(transient) type(int) ident(variableTableSize)operator(;) - directive(protected) directive(transient) type(int) ident(variableTableThreshold)operator(;) - - comment(// The dataStruct is a place where custom information can be) - comment(// contained for core implementations that doesn't necessarily) - comment(// want to go to the trouble of creating a subclass of) - comment(// RubyObject. The OpenSSL implementation uses this heavily to) - comment(// save holder objects containing Java cryptography objects.) - comment(// Java integration uses this to store the Java object ref.) - directive(protected) directive(transient) pre_type(Object) ident(dataStruct)operator(;) - - directive(protected) type(int) ident(flags)operator(;) comment(// zeroed by jvm) - directive(public) directive(static) directive(final) type(int) ident(ALL_F) operator(=) operator(-)integer(1)operator(;) - directive(public) directive(static) directive(final) type(int) ident(FALSE_F) operator(=) integer(1) operator(<)operator(<) integer(0)operator(;) - - comment(/** - * This flag is a bit funny. It's used to denote that this value - * is nil. It's a bit counterintuitive for a Java programmer to - * not use subclassing to handle this case, since we have a - * RubyNil subclass anyway. Well, the reason for it being a flag - * is that the {@link #isNil(\)} method is called extremely often. So often - * that it gives a good speed boost to make it monomorphic and - * final. It turns out using a flag for this actually gives us - * better performance than having a polymorphic {@link #isNil(\)} method. - */) - directive(public) directive(static) directive(final) type(int) ident(NIL_F) operator(=) integer(1) operator(<)operator(<) integer(1)operator(;) - - directive(public) directive(static) directive(final) type(int) ident(FROZEN_F) operator(=) integer(1) operator(<)operator(<) integer(2)operator(;) - directive(public) directive(static) directive(final) type(int) ident(TAINTED_F) operator(=) integer(1) operator(<)operator(<) integer(3)operator(;) - - directive(public) directive(static) directive(final) type(int) ident(FL_USHIFT) operator(=) integer(4)operator(;) - - directive(public) directive(static) directive(final) type(int) ident(USER0_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(0)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER1_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(1)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER2_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(2)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER3_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(3)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER4_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(4)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER5_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(5)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER6_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(6)operator(\))operator(\))operator(;) - directive(public) directive(static) directive(final) type(int) ident(USER7_F) operator(=) operator(()integer(1)operator(<)operator(<)operator(()ident(FL_USHIFT)operator(+)integer(7)operator(\))operator(\))operator(;) - - comment(/** - * Sets or unsets a flag on this object. The only flags that are - * guaranteed to be valid to use as the first argument is: - * - * <ul> - * <li>{@link #FALSE_F}</li> - * <li>{@link NIL_F}</li> - * <li>{@link FROZEN_F}</li> - * <li>{@link TAINTED_F}</li> - * <li>{@link USER0_F}</li> - * <li>{@link USER1_F}</li> - * <li>{@link USER2_F}</li> - * <li>{@link USER3_F}</li> - * <li>{@link USER4_F}</li> - * <li>{@link USER5_F}</li> - * <li>{@link USER6_F}</li> - * <li>{@link USER7_F}</li> - * </ul> - * - * @param flag the actual flag to set or unset. - * @param set if true, the flag will be set, if false, the flag will be unset. - */) - directive(public) directive(final) type(void) ident(setFlag)operator(()type(int) ident(flag)operator(,) type(boolean) ident(set)operator(\)) operator({) - keyword(if) operator(()ident(set)operator(\)) operator({) - ident(flags) operator(|=) ident(flag)operator(;) - operator(}) keyword(else) operator({) - ident(flags) operator(&=) operator(~)ident(flag)operator(;) - operator(}) - operator(}) - - comment(/** - * Get the value of a custom flag on this object. The only - * guaranteed flags that can be sent in to this method is: - * - * <ul> - * <li>{@link #FALSE_F}</li> - * <li>{@link NIL_F}</li> - * <li>{@link FROZEN_F}</li> - * <li>{@link TAINTED_F}</li> - * <li>{@link USER0_F}</li> - * <li>{@link USER1_F}</li> - * <li>{@link USER2_F}</li> - * <li>{@link USER3_F}</li> - * <li>{@link USER4_F}</li> - * <li>{@link USER5_F}</li> - * <li>{@link USER6_F}</li> - * <li>{@link USER7_F}</li> - * </ul> - * - * @param flag the flag to get - * @return true if the flag is set, false otherwise - */) - directive(public) directive(final) type(boolean) ident(getFlag)operator(()type(int) ident(flag)operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(flag)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) directive(transient) ident(Finalizer) ident(finalizer)operator(;) - - comment(/** - * Class that keeps track of the finalizers for the object under - * operation. - */) - directive(public) type(class) class(Finalizer) directive(implements) ident(Finalizable) operator({) - directive(private) type(long) ident(id)operator(;) - directive(private) pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(finalizers)operator(;) - directive(private) pre_type(AtomicBoolean) ident(finalized)operator(;) - - directive(public) ident(Finalizer)operator(()type(long) ident(id)operator(\)) operator({) - local_variable(this)operator(.)ident(id) operator(=) ident(id)operator(;) - local_variable(this)operator(.)ident(finalized) operator(=) keyword(new) pre_type(AtomicBoolean)operator(()pre_constant(false)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(addFinalizer)operator(()ident(IRubyObject) ident(finalizer)operator(\)) operator({) - keyword(if) operator(()ident(finalizers) operator(==) pre_constant(null)operator(\)) operator({) - ident(finalizers) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - operator(}) - ident(finalizers)operator(.)ident(add)operator(()ident(finalizer)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(removeFinalizers)operator(()operator(\)) operator({) - ident(finalizers) operator(=) pre_constant(null)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(finalize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(finalized)operator(.)ident(compareAndSet)operator(()pre_constant(false)operator(,) pre_constant(true)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(finalizers) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(finalizers)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(finalizer) operator(=) ident(finalizers)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - ident(RuntimeHelpers)operator(.)ident(invoke)operator(() - ident(finalizer)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) - ident(finalizer)operator(,) string<delimiter(")content(call)delimiter(")>operator(,) ident(RubyObject)operator(.)ident(this)operator(.)ident(id)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - operator(}) - - comment(/** - * Standard path for object creation. Objects are entered into ObjectSpace - * only if ObjectSpace is enabled. - */) - directive(public) ident(RubyObject)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(\)) operator({) - local_variable(this)operator(.)ident(metaClass) operator(=) ident(metaClass)operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\)) ident(addToObjectSpace)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(3)operator(\)) ident(taint)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - comment(/** - * Path for objects who want to decide whether they don't want to be in - * ObjectSpace even when it is on. (notably used by objects being - * considered immediate, they'll always pass false here\) - */) - directive(protected) ident(RubyObject)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(,) type(boolean) ident(useObjectSpace)operator(\)) operator({) - local_variable(this)operator(.)ident(metaClass) operator(=) ident(metaClass)operator(;) - - keyword(if) operator(()ident(useObjectSpace)operator(\)) ident(addToObjectSpace)operator(()ident(runtime)operator(\))operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(3)operator(\)) ident(taint)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(addToObjectSpace)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(assert) ident(runtime)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(add)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** - * Will create the Ruby class Object in the runtime - * specified. This method needs to take the actual class as an - * argument because of the Object class' central part in runtime - * initialization. - */) - directive(public) directive(static) ident(RubyClass) ident(createObjectClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(objectClass)operator(\)) operator({) - ident(objectClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(OBJECT)operator(;) - - ident(objectClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(ObjectMethods)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(objectClass)operator(;) - operator(}) - - comment(/** - * Interestingly, the Object class doesn't really have that many - * methods for itself. Instead almost all of the Object methods - * are really defined on the Kernel module. This class is a holder - * for all Object methods. - * - * @see RubyKernel - */) - directive(public) directive(static) type(class) class(ObjectMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(intialize)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Default allocator instance for all Ruby objects. The only - * reason to not use this allocator is if you actually need to - * have all instances of something be a subclass of RubyObject. - * - * @see org.jruby.runtime.ObjectAllocator - */) - directive(public) directive(static) directive(final) ident(ObjectAllocator) ident(OBJECT_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyObject)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - comment(/** - * Will make sure that this object is added to the current object - * space. - * - * @see org.jruby.runtime.ObjectSpace - */) - directive(public) type(void) ident(attachToObjectSpace)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(add)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** - * This is overridden in the other concrete Java builtins to provide a fast way - * to determine what type they are. - * - * Will generally return a value from org.jruby.runtime.ClassIndex - * - * @see org.jruby.runtime.ClassInde - */) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(OBJECT)operator(;) - operator(}) - - comment(/** - * Specifically polymorphic method that are meant to be overridden - * by modules to specify that they are modules in an easy way. - */) - directive(public) type(boolean) ident(isModule)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** - * Specifically polymorphic method that are meant to be overridden - * by classes to specify that they are classes in an easy way. - */) - directive(public) type(boolean) ident(isClass)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** - * Is object immediate (def: Fixnum, Symbol, true, false, nil?\). - */) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** rb_make_metaclass - * - * Will create a new meta class, insert this in the chain of - * classes for this specific object, and return the generated meta - * class. - */) - directive(public) ident(RubyClass) ident(makeMetaClass)operator(()ident(RubyClass) ident(superClass)operator(\)) operator({) - ident(MetaClass) ident(klass) operator(=) keyword(new) ident(MetaClass)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(superClass)operator(\))operator(;) comment(// rb_class_boot) - ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - ident(klass)operator(.)ident(setAttached)operator(()local_variable(this)operator(\))operator(;) - ident(klass)operator(.)ident(setMetaClass)operator(()ident(superClass)operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(klass)operator(;) - operator(}) - - comment(/** - * Will return the Java interface that most closely can represent - * this object, when working through JAva integration - * translations. - */) - directive(public) pre_type(Class) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(if) operator(()ident(dataGetStruct)operator(()operator(\)) keyword(instanceof) ident(JavaObject)operator(\)) operator({) - keyword(return) operator(()operator(()ident(JavaObject)operator(\))ident(dataGetStruct)operator(()operator(\))operator(\))operator(.)ident(getValue)operator(()operator(\))operator(.)ident(getClass)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getClass)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Simple helper to print any objects. - */) - directive(public) directive(static) type(void) ident(puts)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()ident(obj)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * This method is just a wrapper around the Ruby "==" method, - * provided so that RubyObjects can be used as keys in the Java - * HashMap object underlying RubyHash. - */) - annotation(@Override) - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\)) operator({) - keyword(return) ident(other) operator(==) local_variable(this) operator(||) - ident(other) keyword(instanceof) ident(IRubyObject) operator(&&) - ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(EQUALEQUAL)operator(,) string<delimiter(")content(==)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\)) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * The default toString method is just a wrapper that calls the - * Ruby "to_s" method. - */) - annotation(@Override) - directive(public) pre_type(String) ident(toString)operator(()operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Will return the runtime that this object is associated with. - * - * @return current runtime - */) - directive(public) directive(final) ident(Ruby) ident(getRuntime)operator(()operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(getClassRuntime)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * if exist return the meta-class else return the type of the object. - * - */) - directive(public) directive(final) ident(RubyClass) ident(getMetaClass)operator(()operator(\)) operator({) - keyword(return) ident(metaClass)operator(;) - operator(}) - - comment(/** - * Makes it possible to change the metaclass of an object. In - * practice, this is a simple version of Smalltalks Become, except - * that it doesn't work when we're dealing with subclasses. In - * practice it's used to change the singleton/meta class used, - * without changing the "real" inheritance chain. - */) - directive(public) type(void) ident(setMetaClass)operator(()ident(RubyClass) ident(metaClass)operator(\)) operator({) - local_variable(this)operator(.)ident(metaClass) operator(=) ident(metaClass)operator(;) - operator(}) - - comment(/** - * Is this value frozen or not? Shortcut for doing - * getFlag(FROZEN_F\). - * - * @return true if this object is frozen, false otherwise - */) - directive(public) type(boolean) ident(isFrozen)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(FROZEN_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - comment(/** - * Sets whether this object is frozen or not. Shortcut for doing - * setFlag(FROZEN_F, frozen\). - * - * @param frozen should this object be frozen? - */) - directive(public) type(void) ident(setFrozen)operator(()type(boolean) ident(frozen)operator(\)) operator({) - keyword(if) operator(()ident(frozen)operator(\)) operator({) - ident(flags) operator(|=) ident(FROZEN_F)operator(;) - operator(}) keyword(else) operator({) - ident(flags) operator(&=) operator(~)ident(FROZEN_F)operator(;) - operator(}) - operator(}) - - comment(/** rb_frozen_class_p - * - * Helper to test whether this object is frozen, and if it is will - * throw an exception based on the message. - */) - directive(protected) directive(final) type(void) ident(testFrozen)operator(()pre_type(String) ident(message)operator(\)) operator({) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFrozenError)operator(()ident(message) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * The actual method that checks frozen with the default frozen message from MRI. - * If possible, call this instead of {@link #testFrozen}. - */) - directive(protected) type(void) ident(checkFrozen)operator(()operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(can't modify frozen )delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Gets the taint. Shortcut for getFlag(TAINTED_F\). - * - * @return true if this object is tainted - */) - directive(public) type(boolean) ident(isTaint)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(TAINTED_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - comment(/** - * Sets the taint flag. Shortcut for setFlag(TAINTED_F, taint\) - * - * @param taint should this object be tainted or not? - */) - directive(public) type(void) ident(setTaint)operator(()type(boolean) ident(taint)operator(\)) operator({) - keyword(if) operator(()ident(taint)operator(\)) operator({) - ident(flags) operator(|=) ident(TAINTED_F)operator(;) - operator(}) keyword(else) operator({) - ident(flags) operator(&=) operator(~)ident(TAINTED_F)operator(;) - operator(}) - operator(}) - - comment(/** - * Does this object represent nil? See the docs for the {@link - * #NIL_F} flag for more information. - */) - directive(public) directive(final) type(boolean) ident(isNil)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(NIL_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - comment(/** - * Is this value a true value or not? Based on the {@link #FALSE_F} flag. - */) - directive(public) directive(final) type(boolean) ident(isTrue)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(FALSE_F)operator(\)) operator(==) integer(0)operator(;) - operator(}) - - comment(/** - * Is this value a false value or not? Based on the {@link #FALSE_F} flag. - */) - directive(public) directive(final) type(boolean) ident(isFalse)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(FALSE_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - comment(/** - * Does this object respond to the specified message? Uses a - * shortcut if it can be proved that respond_to? haven't been - * overridden. - */) - directive(public) directive(final) type(boolean) ident(respondsTo)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(searchMethod)operator(()string<delimiter(")content(respond_to?)delimiter(")>operator(\)) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getRespondToMethod)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(isMethodBound)operator(()ident(name)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(respond_to?)delimiter(")>operator(,)ident(getRuntime)operator(()operator(\))operator(.)ident(newSymbol)operator(()ident(name)operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_singleton_class - * - * Note: this method is specialized for RubyFixnum, RubySymbol, - * RubyNil and RubyBoolean - * - * Will either return the existing singleton class for this - * object, or create a new one and return that. - */) - directive(public) ident(RubyClass) ident(getSingletonClass)operator(()operator(\)) operator({) - ident(RubyClass) ident(klass)operator(;) - - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(isSingleton)operator(()operator(\)) operator(&&) operator(()operator(()ident(MetaClass)operator(\))ident(getMetaClass)operator(()operator(\))operator(\))operator(.)ident(getAttached)operator(()operator(\)) operator(==) local_variable(this)operator(\)) operator({) - ident(klass) operator(=) ident(getMetaClass)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(klass) operator(=) ident(makeMetaClass)operator(()ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(klass)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) ident(klass)operator(.)ident(setFrozen)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) ident(klass)operator(;) - operator(}) - - comment(/** rb_singleton_class_clone - * - * Will make sure that if the current objects class is a - * singleton, it will get cloned. - * - * @return either a real class, or a clone of the current singleton class - */) - directive(protected) ident(RubyClass) ident(getSingletonClassClone)operator(()operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) ident(getMetaClass)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(klass)operator(.)ident(isSingleton)operator(()operator(\))operator(\)) keyword(return) ident(klass)operator(;) - - ident(MetaClass) ident(clone) operator(=) keyword(new) ident(MetaClass)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(clone)operator(.)ident(flags) operator(=) ident(flags)operator(;) - - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyClass)operator(\)) operator({) - ident(clone)operator(.)ident(setMetaClass)operator(()ident(clone)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(clone)operator(.)ident(setMetaClass)operator(()ident(klass)operator(.)ident(getSingletonClassClone)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(clone)operator(.)ident(setSuperClass)operator(()ident(klass)operator(.)ident(getSuperClass)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(klass)operator(.)ident(hasVariables)operator(()operator(\))operator(\)) operator({) - ident(clone)operator(.)ident(syncVariables)operator(()ident(klass)operator(.)ident(getVariableList)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(klass)operator(.)ident(cloneMethods)operator(()ident(clone)operator(\))operator(;) - - operator(()operator(()ident(MetaClass)operator(\))ident(clone)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(.)ident(setAttached)operator(()ident(clone)operator(\))operator(;) - - operator(()operator(()ident(MetaClass)operator(\))ident(clone)operator(\))operator(.)ident(setAttached)operator(()operator(()operator(()ident(MetaClass)operator(\))ident(klass)operator(\))operator(.)ident(getAttached)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(clone)operator(;) - operator(}) - - comment(/** init_copy - * - * Initializes a copy with variable and special instance variable - * information, and then call the initialize_copy Ruby method. - */) - directive(private) directive(static) type(void) ident(initCopy)operator(()ident(IRubyObject) ident(clone)operator(,) ident(RubyObject) ident(original)operator(\)) operator({) - keyword(assert) operator(!)ident(clone)operator(.)ident(isFrozen)operator(()operator(\)) operator(:) string<delimiter(")content(frozen object ()delimiter(")> operator(+) ident(clone)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(\) allocated)delimiter(")>operator(;) - - ident(original)operator(.)ident(copySpecialInstanceVariables)operator(()ident(clone)operator(\))operator(;) - - keyword(if) operator(()ident(original)operator(.)ident(hasVariables)operator(()operator(\))operator(\)) operator({) - ident(clone)operator(.)ident(syncVariables)operator(()ident(original)operator(.)ident(getVariableList)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/* FIXME: finalizer should be dupped here */) - ident(clone)operator(.)ident(callMethod)operator(()ident(clone)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(original)operator(\))operator(;) - operator(}) - - comment(/** OBJ_INFECT - * - * Infects this object with traits from the argument obj. In real - * terms this currently means that if obj is tainted, this object - * will get tainted too. It's possible to hijack this method to do - * other infections if that would be interesting. - */) - directive(public) ident(IRubyObject) ident(infectBy)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * The protocol for super method invocation is a bit complicated - * in Ruby. In real terms it involves first finding the real - * implementation class (the super class\), getting the name of the - * method to call from the frame, and then invoke that on the - * super class with the current self as the actual object - * invoking. - */) - directive(public) ident(IRubyObject) ident(callSuper)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyModule) ident(klazz) operator(=) ident(context)operator(.)ident(getFrameKlazz)operator(()operator(\))operator(;) - - ident(RubyClass) ident(superClass) operator(=) ident(RuntimeHelpers)operator(.)ident(findImplementerIfNecessary)operator(()ident(getMetaClass)operator(()operator(\))operator(,) ident(klazz)operator(\))operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(superClass) operator(==) pre_constant(null)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(context)operator(.)ident(getFrameName)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(callMethodMissing)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(klazz)operator(.)ident(searchMethod)operator(()ident(name)operator(\))operator(,) ident(name)operator(,) ident(args)operator(,) local_variable(this)operator(,) ident(CallType)operator(.)ident(SUPER)operator(,) ident(block)operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invokeAs)operator(()ident(context)operator(,) ident(superClass)operator(,) local_variable(this)operator(,) ident(context)operator(.)ident(getFrameName)operator(()operator(\))operator(,) ident(args)operator(,) ident(CallType)operator(.)ident(SUPER)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke a named method with no arguments and no block. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke a named method with one argument and no block with - * functional invocation. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke a named method with the supplied arguments and no - * block with functional invocation. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke a named method with the supplied arguments and - * supplied block with functional invocation. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke an indexed method with the no arguments and no - * block. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) type(int) ident(methodIndex)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Will invoke an indexed method with the one argument and no - * block with a functional invocation. - */) - directive(public) directive(final) ident(IRubyObject) ident(callMethod)operator(()ident(ThreadContext) ident(context)operator(,) type(int) ident(methodIndex)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - comment(/** - * Call the Ruby initialize method with the supplied arguments and block. - */) - directive(public) directive(final) type(void) ident(callInit)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** rb_to_id - * - * Will try to convert this object to a String using the Ruby - * "to_str" if the object isn't already a String. If this still - * doesn't work, will throw a Ruby TypeError. - * - */) - directive(public) pre_type(String) ident(asJavaString)operator(()operator(\)) operator({) - ident(IRubyObject) ident(asString) operator(=) ident(checkStringType)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)ident(asString)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) operator(()operator(()ident(RubyString)operator(\))ident(asString)operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(inspect)operator(()operator(\))operator(.)ident(toString)operator(()operator(\)) operator(+) string<delimiter(")content( is not a symbol)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby Array using the "to_ary" - * method. - */) - directive(public) ident(RubyArray) ident(convertToArray)operator(()operator(\)) operator({) - keyword(return) operator(()ident(RubyArray)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getArray)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_ARY)operator(,) string<delimiter(")content(to_ary)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby Hash using the "to_hash" - * method. - */) - directive(public) ident(RubyHash) ident(convertToHash)operator(()operator(\)) operator({) - keyword(return) operator(()ident(RubyHash)operator(\))ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getHash)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_HASH)operator(,) string<delimiter(")content(to_hash)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby Float using the "to_f" - * method. - */) - directive(public) ident(RubyFloat) ident(convertToFloat)operator(()operator(\)) operator({) - keyword(return) operator(()ident(RubyFloat)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getFloat)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_F)operator(,) string<delimiter(")content(to_f)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby Integer using the "to_int" - * method. - */) - directive(public) ident(RubyInteger) ident(convertToInteger)operator(()operator(\)) operator({) - keyword(return) ident(convertToInteger)operator(()ident(MethodIndex)operator(.)ident(TO_INT)operator(,) string<delimiter(")content(to_int)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby Integer using the - * supplied conversion method. - */) - directive(public) ident(RubyInteger) ident(convertToInteger)operator(()type(int) ident(convertMethodIndex)operator(,) pre_type(String) ident(convertMethod)operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getInteger)operator(()operator(\))operator(,) ident(convertMethodIndex)operator(,) ident(convertMethod)operator(,) pre_constant(true)operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(val) keyword(instanceof) ident(RubyInteger)operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(#)delimiter(")> operator(+) ident(convertMethod) operator(+) string<delimiter(")content( should return Integer)delimiter(")>operator(\))operator(;) - keyword(return) operator(()ident(RubyInteger)operator(\))ident(val)operator(;) - operator(}) - - comment(/** - * Tries to convert this object to a Ruby String using the - * "to_str" method. - */) - directive(public) ident(RubyString) ident(convertToString)operator(()operator(\)) operator({) - keyword(return) operator(()ident(RubyString)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_STR)operator(,) string<delimiter(")content(to_str)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * Tries to convert this object to the specified Ruby type, using - * a specific conversion method. - */) - directive(public) directive(final) ident(IRubyObject) ident(convertToType)operator(()ident(RubyClass) ident(target)operator(,) type(int) ident(convertMethodIndex)operator(\)) operator({) - keyword(return) ident(TypeConverter)operator(.)ident(convertToType)operator(()local_variable(this)operator(,) ident(target)operator(,) ident(convertMethodIndex)operator(,) operator(()pre_type(String)operator(\))ident(MethodIndex)operator(.)ident(NAMES)operator(.)ident(get)operator(()ident(convertMethodIndex)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_as_string - * - * First converts this object into a String using the "to_s" - * method, infects it with the current taint and returns it. If - * to_s doesn't return a Ruby String, {@link #anyToString} is used - * instead. - */) - directive(public) ident(RubyString) ident(asString)operator(()operator(\)) operator({) - ident(IRubyObject) ident(str) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(str) keyword(instanceof) ident(RubyString)operator(\))operator(\)) keyword(return) operator(()ident(RubyString)operator(\))ident(anyToString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) operator(()ident(RubyString)operator(\)) ident(str)operator(;) - operator(}) - - comment(/** rb_check_string_type - * - * Tries to return a coerced string representation of this object, - * using "to_str". If that returns something other than a String - * or nil, an empty String will be returned. - * - */) - directive(public) ident(IRubyObject) ident(checkStringType)operator(()operator(\)) operator({) - ident(IRubyObject) ident(str) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_STR)operator(,) string<delimiter(")content(to_str)delimiter(")>operator(\))operator(;) - keyword(if)operator(()operator(!)ident(str)operator(.)ident(isNil)operator(()operator(\)) operator(&&) operator(!)operator(()ident(str) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - ident(str) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_check_array_type - * - * Returns the result of trying to convert this object to an Array - * with "to_ary". - */) - directive(public) ident(IRubyObject) ident(checkArrayType)operator(()operator(\)) operator({) - keyword(return) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()local_variable(this)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getArray)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(TO_ARY)operator(,) string<delimiter(")content(to_ary)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */) - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(specificEval)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(mod)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(0)operator(\))operator(;) - - keyword(return) ident(yieldUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(block)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(block not supplied)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(3)operator(\)) operator({) - pre_type(String) ident(lastFuncName) operator(=) ident(context)operator(.)ident(getFrameName)operator(()operator(\))operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(() - string<delimiter(")content(wrong # of arguments: )delimiter(")> operator(+) ident(lastFuncName) operator(+) string<delimiter(")content((src\) or )delimiter(")> operator(+) ident(lastFuncName) operator(+) string<delimiter(")content({..})delimiter(")>operator(\))operator(;) - operator(}) - - comment(// We just want the TypeError if the argument doesn't convert to a String (JRUBY-386\)) - ident(RubyString) ident(evalStr)operator(;) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(evalStr) operator(=) operator(()ident(RubyString)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - operator(}) keyword(else) operator({) - ident(evalStr) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(}) - - pre_type(String) ident(file)operator(;) - type(int) ident(line)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(file) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) operator({) - ident(line) operator(=) operator(()type(int)operator(\))operator(()ident(args)operator([)integer(2)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(line) operator(=) integer(0)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(file) operator(=) string<delimiter(")content((eval\))delimiter(")>operator(;) - ident(line) operator(=) integer(0)operator(;) - operator(}) - - keyword(return) ident(evalUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(evalStr)operator(,) ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) - - comment(/** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */) - directive(public) ident(IRubyObject) ident(specificEval)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(mod)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(yieldUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(block not supplied)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */) - directive(public) ident(IRubyObject) ident(specificEval)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(mod)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(1)operator(,) integer(0)operator(\))operator(;) - - comment(// We just want the TypeError if the argument doesn't convert to a String (JRUBY-386\)) - ident(RubyString) ident(evalStr)operator(;) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(evalStr) operator(=) operator(()ident(RubyString)operator(\))ident(arg)operator(;) - operator(}) keyword(else) operator({) - ident(evalStr) operator(=) ident(arg)operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(}) - - pre_type(String) ident(file) operator(=) string<delimiter(")content((eval\))delimiter(")>operator(;) - type(int) ident(line) operator(=) integer(0)operator(;) - - keyword(return) ident(evalUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(evalStr)operator(,) ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) - - comment(/** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */) - directive(public) ident(IRubyObject) ident(specificEval)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(mod)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(2)operator(,) integer(0)operator(\))operator(;) - - comment(// We just want the TypeError if the argument doesn't convert to a String (JRUBY-386\)) - ident(RubyString) ident(evalStr)operator(;) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(evalStr) operator(=) operator(()ident(RubyString)operator(\))ident(arg0)operator(;) - operator(}) keyword(else) operator({) - ident(evalStr) operator(=) ident(arg0)operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(}) - - pre_type(String) ident(file) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(;) - type(int) ident(line) operator(=) integer(0)operator(;) - - keyword(return) ident(evalUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(evalStr)operator(,) ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) - - comment(/** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */) - directive(public) ident(IRubyObject) ident(specificEval)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(mod)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(2)operator(,) integer(0)operator(\))operator(;) - - comment(// We just want the TypeError if the argument doesn't convert to a String (JRUBY-386\)) - ident(RubyString) ident(evalStr)operator(;) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(evalStr) operator(=) operator(()ident(RubyString)operator(\))ident(arg0)operator(;) - operator(}) keyword(else) operator({) - ident(evalStr) operator(=) ident(arg0)operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(}) - - pre_type(String) ident(file) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(;) - type(int) ident(line) operator(=) operator(()type(int)operator(\))operator(()ident(arg2)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - - keyword(return) ident(evalUnder)operator(()ident(context)operator(,) ident(mod)operator(,) ident(evalStr)operator(,) ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) - - comment(/** - * Evaluates the string src with self set to the current object, - * using the module under as the context. - * @deprecated Call with an int line number and String file - */) - directive(public) ident(IRubyObject) ident(evalUnder)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(under)operator(,) ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(file)operator(,) ident(IRubyObject) ident(line)operator(\)) operator({) - keyword(return) ident(evalUnder)operator(()ident(context)operator(,) ident(under)operator(,) ident(src)operator(.)ident(convertToString)operator(()operator(\))operator(,) ident(file)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(,) operator(()type(int)operator(\)) operator(()ident(line)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(-) integer(1)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Evaluates the string src with self set to the current object, - * using the module under as the context. - */) - directive(public) ident(IRubyObject) ident(evalUnder)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(under)operator(,) ident(RubyString) ident(src)operator(,) pre_type(String) ident(file)operator(,) type(int) ident(line)operator(\)) operator({) - pre_type(Visibility) ident(savedVisibility) operator(=) ident(context)operator(.)ident(getCurrentVisibility)operator(()operator(\))operator(;) - ident(context)operator(.)ident(setCurrentVisibility)operator(()pre_type(Visibility)operator(.)ident(PUBLIC)operator(\))operator(;) - ident(context)operator(.)ident(preExecuteUnder)operator(()ident(under)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - keyword(try) operator({) - keyword(return) ident(ASTInterpreter)operator(.)ident(evalSimple)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(src)operator(,) - ident(file)operator(,) ident(line)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(context)operator(.)ident(postExecuteUnder)operator(()operator(\))operator(;) - ident(context)operator(.)ident(setCurrentVisibility)operator(()ident(savedVisibility)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Will yield to the specific block changing the self to be the - * current object instead of the self that is part of the frame - * saved in the block frame. This method is the basis for the Ruby - * instance_eval and module_eval methods. The arguments sent in to - * it in the args array will be yielded to the block. This makes - * it possible to emulate both instance_eval and instance_exec - * with this implementation. - */) - directive(private) ident(IRubyObject) ident(yieldUnder)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(under)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(context)operator(.)ident(preExecuteUnder)operator(()ident(under)operator(,) ident(block)operator(\))operator(;) - - pre_type(Visibility) ident(savedVisibility) operator(=) ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getVisibility)operator(()operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()pre_type(Visibility)operator(.)ident(PUBLIC)operator(\))operator(;) - - keyword(try) operator({) - ident(IRubyObject) ident(valueInYield)operator(;) - type(boolean) ident(aValue)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(valueInYield) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(aValue) operator(=) pre_constant(false)operator(;) - operator(}) keyword(else) operator({) - ident(valueInYield) operator(=) ident(RubyArray)operator(.)ident(newArrayNoCopy)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - ident(aValue) operator(=) pre_constant(true)operator(;) - operator(}) - - comment(// FIXME: This is an ugly hack to resolve JRUBY-1381; I'm not proud of it) - ident(block) operator(=) ident(block)operator(.)ident(cloneBlock)operator(()operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setSelf)operator(()ident(RubyObject)operator(.)ident(this)operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getFrame)operator(()operator(\))operator(.)ident(setSelf)operator(()ident(RubyObject)operator(.)ident(this)operator(\))operator(;) - comment(// end hack) - - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(valueInYield)operator(,) ident(RubyObject)operator(.)ident(this)operator(,) ident(context)operator(.)ident(getRubyClass)operator(()operator(\))operator(,) ident(aValue)operator(\))operator(;) - comment(//TODO: Should next and return also catch here?) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()ident(savedVisibility)operator(\))operator(;) - - ident(context)operator(.)ident(postExecuteUnder)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Will yield to the specific block changing the self to be the - * current object instead of the self that is part of the frame - * saved in the block frame. This method is the basis for the Ruby - * instance_eval and module_eval methods. The arguments sent in to - * it in the args array will be yielded to the block. This makes - * it possible to emulate both instance_eval and instance_exec - * with this implementation. - */) - directive(private) ident(IRubyObject) ident(yieldUnder)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(RubyModule) ident(under)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(context)operator(.)ident(preExecuteUnder)operator(()ident(under)operator(,) ident(block)operator(\))operator(;) - - pre_type(Visibility) ident(savedVisibility) operator(=) ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getVisibility)operator(()operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()pre_type(Visibility)operator(.)ident(PUBLIC)operator(\))operator(;) - - keyword(try) operator({) - comment(// FIXME: This is an ugly hack to resolve JRUBY-1381; I'm not proud of it) - ident(block) operator(=) ident(block)operator(.)ident(cloneBlock)operator(()operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setSelf)operator(()ident(RubyObject)operator(.)ident(this)operator(\))operator(;) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getFrame)operator(()operator(\))operator(.)ident(setSelf)operator(()ident(RubyObject)operator(.)ident(this)operator(\))operator(;) - comment(// end hack) - - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) local_variable(this)operator(,) local_variable(this)operator(,) ident(context)operator(.)ident(getRubyClass)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - comment(//TODO: Should next and return also catch here?) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()ident(savedVisibility)operator(\))operator(;) - - ident(context)operator(.)ident(postExecuteUnder)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// Methods of the Object class (rb_obj_*\):) - - comment(/** rb_obj_equal - * - * Will by default use identity equality to compare objects. This - * follows the Ruby semantics. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(obj) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_equal - * - * Will use Java identity equality. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(equal?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(equal_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(obj) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** method used for Hash key comparison (specialized for String, Symbol and Fixnum\) - * - * Will by default just call the Ruby method "eql?" - */) - directive(public) type(boolean) ident(eql)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(EQL_P)operator(,) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_equal - * - * Just like "==" and "equal?", "eql?" will use identity equality for Object. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) local_variable(this) operator(==) ident(obj) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_equal - * - * The Ruby "===" method is used by default in case/when - * statements. The Object implementation first checks Java identity - * equality and then calls the "==" method too. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(===)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_eqq)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(equalInternal)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Helper method for checking equality, first using Java identity - * equality, and then calling the "==" method. - */) - directive(protected) directive(static) type(boolean) ident(equalInternal)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(that)operator(,) directive(final) ident(IRubyObject) ident(other)operator(\))operator({) - keyword(return) ident(that) operator(==) ident(other) operator(||) ident(that)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EQUALEQUAL)operator(,) string<delimiter(")content(==)delimiter(")>operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Helper method for checking equality, first using Java identity - * equality, and then calling the "eql?" method. - */) - directive(protected) directive(static) type(boolean) ident(eqlInternal)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) directive(final) ident(IRubyObject) ident(that)operator(,) directive(final) ident(IRubyObject) ident(other)operator(\))operator({) - keyword(return) ident(that) operator(==) ident(other) operator(||) ident(that)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EQL_P)operator(,) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(other)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_init_copy - * - * Initializes this object as a copy of the original, that is the - * parameter to this object. Will make sure that the argument - * actually has the same real class as this object. It shouldn't - * be possible to initialize an object with something totally - * different. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(original)operator(\)) keyword(return) local_variable(this)operator(;) - ident(checkFrozen)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(original)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(initialize_copy should take same class object)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** obj_respond_to - * - * respond_to?( aSymbol, includePriv=false \) -> true or false - * - * Returns true if this object responds to the given method. Private - * methods are included in the search only if the optional second - * parameter evaluates to true. - * - * @return true if this responds to the given method - * - * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 - * - * Going back to splitting according to method arity. MRI is wrong - * about most of these anyway, and since we have arity splitting - * in both the compiler and the interpreter, the performance - * benefit is important for this method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(respond_to?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(respond_to_p)operator(()ident(IRubyObject) ident(mname)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(mname)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(isMethodBound)operator(()ident(name)operator(,) pre_constant(true)operator(\))operator(\))operator(;) - operator(}) - - comment(/** obj_respond_to - * - * respond_to?( aSymbol, includePriv=false \) -> true or false - * - * Returns true if this object responds to the given method. Private - * methods are included in the search only if the optional second - * parameter evaluates to true. - * - * @return true if this responds to the given method - * - * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 - * - * Going back to splitting according to method arity. MRI is wrong - * about most of these anyway, and since we have arity splitting - * in both the compiler and the interpreter, the performance - * benefit is important for this method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(respond_to?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(respond_to_p)operator(()ident(IRubyObject) ident(mname)operator(,) ident(IRubyObject) ident(includePrivate)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(mname)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(isMethodBound)operator(()ident(name)operator(,) operator(!)ident(includePrivate)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_id - * - * Return the internal id of an object. - * - * FIXME: Should this be renamed to match its ruby name? - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(object_id)delimiter(")>operator(,) string<delimiter(")content(__id__)delimiter(")>operator(})operator(\)) - directive(public) directive(synchronized) ident(IRubyObject) ident(id)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(idOf)operator(()local_variable(this)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_id_obsolete - * - * Old id version. This one is bound to the "id" name and will emit a deprecation warning. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(id)delimiter(")>operator(\)) - directive(public) directive(synchronized) ident(IRubyObject) ident(id_deprecated)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(Object#id will be deprecated; use Object#object_id)delimiter(")>operator(,) string<delimiter(")content(Object#id)delimiter(")>operator(,) string<delimiter(")content(Object#object_id)delimiter(")>operator(\))operator(;) - keyword(return) ident(id)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_id - * - * Will return the hash code of this object. In comparison to MRI, - * this method will use the Java identity hash code instead of - * using rb_obj_id, since the usage of id in JRuby will incur the - * cost of some. ObjectSpace maintenance. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()local_variable(super)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Override the Object#hashCode method to make sure that the Ruby - * hash is actually used as the hashcode for Ruby objects. If the - * Ruby "hash" method doesn't return a number, the Object#hashCode - * implementation will be used instead. - */) - annotation(@Override) - directive(public) type(int) ident(hashCode)operator(()operator(\)) operator({) - ident(IRubyObject) ident(hashValue) operator(=) ident(callMethod)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(MethodIndex)operator(.)ident(HASH)operator(,) string<delimiter(")content(hash)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(hashValue) keyword(instanceof) ident(RubyFixnum)operator(\)) keyword(return) operator(()type(int)operator(\)) ident(RubyNumeric)operator(.)ident(fix2long)operator(()ident(hashValue)operator(\))operator(;) - - keyword(return) local_variable(super)operator(.)ident(hashCode)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_class - * - * Returns the real class of this object, excluding any - * singleton/meta class in the inheritance chain. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(class)delimiter(")>operator(\)) - directive(public) ident(RubyClass) ident(type)operator(()operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_type - * - * The deprecated version of type, that emits a deprecation - * warning. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(type)delimiter(")>operator(\)) - directive(public) ident(RubyClass) ident(type_deprecated)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(Object#type is deprecated; use Object#class)delimiter(")>operator(,) string<delimiter(")content(Object#type)delimiter(")>operator(,) string<delimiter(")content(Object#class)delimiter(")>operator(\))operator(;) - keyword(return) ident(type)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_clone - * - * This method should be overridden only by: Proc, Method, - * UnboundedMethod, Binding. It will use the defined allocated of - * the object, then clone the singleton class, taint the object, - * call initCopy and then copy frozen state. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clone)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(rbClone)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't clone )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - - comment(// We're cloning ourselves, so we know the result should be a RubyObject) - ident(RubyObject) ident(clone) operator(=) operator(()ident(RubyObject)operator(\))ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(clone)operator(.)ident(setMetaClass)operator(()ident(getSingletonClassClone)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(clone)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - ident(initCopy)operator(()ident(clone)operator(,) local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) ident(clone)operator(.)ident(setFrozen)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(clone)operator(;) - operator(}) - - comment(/** rb_obj_dup - * - * This method should be overridden only by: Proc - * - * Will allocate a new instance of the real class of this object, - * and then initialize that copy. It's different from {@link - * #rbClone} in that it doesn't copy the singleton class. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dup)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(dup)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't dup )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - - ident(IRubyObject) ident(dup) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(allocate)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) ident(dup)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - ident(initCopy)operator(()ident(dup)operator(,) local_variable(this)operator(\))operator(;) - - keyword(return) ident(dup)operator(;) - operator(}) - - comment(/** - * Lots of MRI objects keep their state in non-lookupable ivars - * (e:g. Range, Struct, etc\). This method is responsible for - * dupping our java field equivalents - */) - directive(protected) type(void) ident(copySpecialInstanceVariables)operator(()ident(IRubyObject) ident(clone)operator(\)) operator({) - operator(}) - - comment(/** rb_obj_display - * - * call-seq: - * obj.display(port=$>\) => nil - * - * Prints <i>obj</i> on the given port (default <code>$></code>\). - * Equivalent to: - * - * def display(port=$>\) - * port.write self - * end - * - * For example: - * - * 1.display - * "cat".display - * [ 4, 5, 6 ].display - * puts - * - * <em>produces:</em> - * - * 1cat456 - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(display)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(display)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(port) operator(=) ident(args)operator(.)ident(length) operator(==) integer(0) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($>)delimiter(")>operator(\)) operator(:) ident(args)operator([)integer(0)operator(])operator(;) - - ident(port)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_tainted - * - * call-seq: - * obj.tainted? => true or false - * - * Returns <code>true</code> if the object is tainted. - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tainted?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(tainted_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_taint - * - * call-seq: - * obj.taint -> obj - * - * Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is - * set appropriately, many method calls which might alter the running - * programs environment will refuse to accept tainted strings. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taint)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(taint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(taint)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) type(void) ident(taint)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(object)delimiter(")>operator(\))operator(;) - ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_obj_untaint - * - * call-seq: - * obj.untaint => obj - * - * Removes the taint from <i>obj</i>. - * - * Only callable in if more secure than 3. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(untaint)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(untaint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(secure)operator(()integer(3)operator(\))operator(;) - - keyword(if) operator(()ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(object)delimiter(")>operator(\))operator(;) - ident(setTaint)operator(()pre_constant(false)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_obj_freeze - * - * call-seq: - * obj.freeze => obj - * - * Prevents further modifications to <i>obj</i>. A - * <code>TypeError</code> will be raised if modification is attempted. - * There is no way to unfreeze a frozen object. See also - * <code>Object#frozen?</code>. - * - * a = [ "a", "b", "c" ] - * a.freeze - * a << "z" - * - * <em>produces:</em> - * - * prog.rb:3:in `<<': can't modify frozen array (TypeError\) - * from prog.rb:3 - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(freeze)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(FROZEN_F)operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't freeze object)delimiter(")>operator(\))operator(;) - operator(}) - ident(flags) operator(|=) ident(FROZEN_F)operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_obj_frozen_p - * - * call-seq: - * obj.frozen? => true or false - * - * Returns the freeze status of <i>obj</i>. - * - * a = [ "a", "b", "c" ] - * a.freeze #=> ["a", "b", "c"] - * a.frozen? #=> true - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(frozen?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(frozen_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isFrozen)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** inspect_obj - * - * The internal helper method that takes care of the part of the - * inspection that inspects instance variables. - */) - directive(private) pre_type(StringBuilder) ident(inspectObj)operator(()pre_type(StringBuilder) ident(part)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(String) ident(sep) operator(=) string<delimiter(")delimiter(")>operator(;) - - keyword(for) operator(()ident(Variable)operator(<)ident(IRubyObject)operator(>) ident(ivar) operator(:) ident(getInstanceVariableList)operator(()operator(\))operator(\)) operator({) - ident(part)operator(.)ident(append)operator(()ident(sep)operator(\))operator(.)ident(append)operator(()string<delimiter(")content( )delimiter(")>operator(\))operator(.)ident(append)operator(()ident(ivar)operator(.)ident(getName)operator(()operator(\))operator(\))operator(.)ident(append)operator(()string<delimiter(")content(=)delimiter(")>operator(\))operator(;) - ident(part)operator(.)ident(append)operator(()ident(ivar)operator(.)ident(getValue)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(\))operator(;) - ident(sep) operator(=) string<delimiter(")content(,)delimiter(")>operator(;) - operator(}) - ident(part)operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(return) ident(part)operator(;) - operator(}) - - comment(/** rb_inspect - * - * The internal helper that ensures a RubyString instance is returned - * so dangerous casting can be omitted - * Prefered over callMethod(context, "inspect"\) - */) - directive(static) ident(RubyString) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(object)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_inspect - * - * call-seq: - * obj.inspect => string - * - * Returns a string containing a human-readable representation of - * <i>obj</i>. If not overridden, uses the <code>to_s</code> method to - * generate the string. - * - * [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \\"five\\"]" - * Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003" - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(()operator(!)ident(isImmediate)operator(()operator(\))operator(\)) operator(&&) - comment(// TYPE(obj\) == T_OBJECT) - operator(!)operator(()local_variable(this) keyword(instanceof) ident(RubyClass)operator(\)) operator(&&) - local_variable(this) operator(!=) ident(runtime)operator(.)ident(getObject)operator(()operator(\)) operator(&&) - local_variable(this) operator(!=) ident(runtime)operator(.)ident(getModule)operator(()operator(\)) operator(&&) - operator(!)operator(()local_variable(this) keyword(instanceof) ident(RubyModule)operator(\)) operator(&&) - comment(// TODO: should have #hasInstanceVariables method, though) - comment(// this will work here:) - ident(hasVariables)operator(()operator(\))operator(\)) operator({) - - pre_type(StringBuilder) ident(part) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - pre_type(String) ident(cname) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(;) - ident(part)operator(.)ident(append)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(cname)operator(\))operator(.)ident(append)operator(()string<delimiter(")content(:0x)delimiter(")>operator(\))operator(;) - ident(part)operator(.)ident(append)operator(()pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(runtime)operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) operator({) - comment(/* 6:tags 16:addr 1:eos */) - ident(part)operator(.)ident(append)operator(()string<delimiter(")content( ...>)delimiter(")>operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(part)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(try) operator({) - ident(runtime)operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()ident(inspectObj)operator(()ident(part)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(RubyNil)operator(.)ident(inspect)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) local_variable(this)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_obj_is_instance_of - * - * call-seq: - * obj.instance_of?(class\) => true or false - * - * Returns <code>true</code> if <i>obj</i> is an instance of the given - * class. See also <code>Object#kind_of?</code>. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_of?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(instance_of_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(type)operator(\)) operator({) - keyword(if) operator(()ident(type)operator(()operator(\)) operator(==) ident(type)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)operator(()ident(type) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(class or module required)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - - comment(/** rb_obj_is_kind_of - * - * call-seq: - * obj.is_a?(class\) => true or false - * obj.kind_of?(class\) => true or false - * - * Returns <code>true</code> if <i>class</i> is the class of - * <i>obj</i>, or if <i>class</i> is one of the superclasses of - * <i>obj</i> or modules included in <i>obj</i>. - * - * module M; end - * class A - * include M - * end - * class B < A; end - * class C < B; end - * b = B.new - * b.instance_of? A #=> false - * b.instance_of? B #=> true - * b.instance_of? C #=> false - * b.instance_of? M #=> false - * b.kind_of? A #=> true - * b.kind_of? B #=> true - * b.kind_of? C #=> false - * b.kind_of? M #=> true - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(kind_of?)delimiter(")>operator(,) string<delimiter(")content(is_a?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(kind_of_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(type)operator(\)) operator({) - comment(// TODO: Generalize this type-checking code into IRubyObject helper.) - keyword(if) operator(()operator(!)operator(()ident(type) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) operator({) - comment(// TODO: newTypeError does not offer enough for ruby error string...) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(class or module required)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(()operator(()ident(RubyModule)operator(\))ident(type)operator(\))operator(.)ident(isInstance)operator(()local_variable(this)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_methods - * - * call-seq: - * obj.methods => array - * - * Returns a list of the names of methods publicly accessible in - * <i>obj</i>. This will include all the methods accessible in - * <i>obj</i>'s ancestors. - * - * class Klass - * def kMethod(\) - * end - * end - * k = Klass.new - * k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?", - * "class", "instance_variable_set", - * "methods", "extend", "__send__", "instance_eval"] - * k.methods.length #=> 42 - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(methods)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(boolean) ident(all) operator(=) pre_constant(true)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(all) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - ident(RubyArray) ident(singletonMethods) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(singletonMethods) operator(=) - ident(getMetaClass)operator(()operator(\))operator(.)ident(instance_methods)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(})operator(\))operator(;) - keyword(if) operator(()ident(all)operator(\)) operator({) - ident(singletonMethods)operator(.)ident(concat)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getSuperClass)operator(()operator(\))operator(.)ident(instance_methods)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(})operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(all)operator(\)) operator({) - ident(singletonMethods) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(instance_methods)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(})operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(singletonMethods) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEmptyArray)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(singletonMethods)operator(;) - operator(}) - - comment(/** rb_obj_public_methods - * - * call-seq: - * obj.public_methods(all=true\) => array - * - * Returns the list of public methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(public_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(public_methods)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(})operator(;) - operator(}) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(public_instance_methods)operator(()ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_protected_methods - * - * call-seq: - * obj.protected_methods(all=true\) => array - * - * Returns the list of protected methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - * - * Internally this implementation uses the - * {@link RubyModule#protected_instance_methods} method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(protected_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(protected_methods)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(})operator(;) - operator(}) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(protected_instance_methods)operator(()ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_private_methods - * - * call-seq: - * obj.private_methods(all=true\) => array - * - * Returns the list of private methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - * - * Internally this implementation uses the - * {@link RubyModule#private_instance_methods} method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(private_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(private_methods)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(})operator(;) - operator(}) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(private_instance_methods)operator(()ident(args)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_singleton_methods - * - * call-seq: - * obj.singleton_methods(all=true\) => array - * - * Returns an array of the names of singleton methods for <i>obj</i>. - * If the optional <i>all</i> parameter is true, the list will include - * methods in modules included in <i>obj</i>. - * - * module Other - * def three(\) end - * end - * - * class Single - * def Single.four(\) end - * end - * - * a = Single.new - * - * def a.one(\) - * end - * - * class << a - * include Other - * def two(\) - * end - * end - * - * Single.singleton_methods #=> ["four"] - * a.singleton_methods(false\) #=> ["two", "one"] - * a.singleton_methods #=> ["two", "one", "three"] - */) - comment(// TODO: This is almost RubyModule#instance_methods on the metaClass. Perhaps refactor.) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(singleton_methods)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyArray) ident(singleton_methods)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(boolean) ident(all) operator(=) pre_constant(true)operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(all) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(;) - operator(}) - - ident(RubyArray) ident(singletonMethods)operator(;) - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(isSingleton)operator(()operator(\))operator(\)) operator({) - ident(singletonMethods) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(instance_methods)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(})operator(\))operator(;) - keyword(if) operator(()ident(all)operator(\)) operator({) - ident(RubyClass) ident(superClass) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - keyword(while) operator(()ident(superClass)operator(.)ident(isIncluded)operator(()operator(\))operator(\)) operator({) - ident(singletonMethods)operator(.)ident(concat)operator(()ident(superClass)operator(.)ident(instance_methods)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(})operator(\))operator(\))operator(;) - ident(superClass) operator(=) ident(superClass)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - ident(singletonMethods) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newEmptyArray)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(singletonMethods)operator(;) - operator(}) - - comment(/** rb_obj_method - * - * call-seq: - * obj.method(sym\) => method - * - * Looks up the named method as a receiver in <i>obj</i>, returning a - * <code>Method</code> object (or raising <code>NameError</code>\). The - * <code>Method</code> object acts as a closure in <i>obj</i>'s object - * instance, so instance variables and the value of <code>self</code> - * remain available. - * - * class Demo - * def initialize(n\) - * @iv = n - * end - * def hello(\) - * "Hello, @iv = #{@iv}" - * end - * end - * - * k = Demo.new(99\) - * m = k.method(:hello\) - * m.call #=> "Hello, @iv = 99" - * - * l = Demo.new('Fred'\) - * m = l.method("hello"\) - * m.call #=> "Hello, @iv = Fred" - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(method)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(method)operator(()ident(IRubyObject) ident(symbol)operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(newMethod)operator(()local_variable(this)operator(,) ident(symbol)operator(.)ident(asJavaString)operator(()operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - comment(/** - * Internal method that helps to convert any object into the - * format of a class name and a hex string inside of #<>. - */) - directive(public) ident(IRubyObject) ident(anyToString)operator(()operator(\)) operator({) - pre_type(String) ident(cname) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(;) - comment(/* 6:tags 16:addr 1:eos */) - ident(RubyString) ident(str) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(#<)delimiter(")> operator(+) ident(cname) operator(+) string<delimiter(")content(:0x)delimiter(")> operator(+) pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - ident(str)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_any_to_s - * - * call-seq: - * obj.to_s => string - * - * Returns a string representing <i>obj</i>. The default - * <code>to_s</code> prints the object's class and an encoding of the - * object id. As a special case, the top-level object that is the - * initial execution context of Ruby programs returns ``main.'' - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(return) ident(anyToString)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_any_to_a - * - * call-seq: - * obj.to_a -> anArray - * - * Returns an array representation of <i>obj</i>. For objects of class - * <code>Object</code> and others that don't explicitly override the - * method, the return value is an array containing <code>self</code>. - * However, this latter behavior will soon be obsolete. - * - * self.to_a #=> -:1: warning: default `to_a' will be obsolete - * "hello".to_a #=> ["hello"] - * Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"] - * - * The default to_a method is deprecated. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PUBLIC)operator(\)) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(default 'to_a' will be obsolete)delimiter(")>operator(,) string<delimiter(")content(to_a)delimiter(")>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_instance_eval - * - * call-seq: - * obj.instance_eval(string [, filename [, lineno]] \) => obj - * obj.instance_eval {| | block } => obj - * - * Evaluates a string containing Ruby source code, or the given block, - * within the context of the receiver (_obj_\). In order to set the - * context, the variable +self+ is set to _obj_ while - * the code is executing, giving the code access to _obj_'s - * instance variables. In the version of <code>instance_eval</code> - * that takes a +String+, the optional second and third - * parameters supply a filename and starting line number that are used - * when reporting compilation errors. - * - * class Klass - * def initialize - * @secret = 99 - * end - * end - * k = Klass.new - * k.instance_eval { @secret } #=> 99 - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_eval)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(instance_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) ident(getInstanceEvalClass)operator(()operator(\))operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_eval)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(instance_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) ident(getInstanceEvalClass)operator(()operator(\))operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_eval)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(instance_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) ident(getInstanceEvalClass)operator(()operator(\))operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_eval)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(instance_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(specificEval)operator(()ident(context)operator(,) ident(getInstanceEvalClass)operator(()operator(\))operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@Deprecated) - directive(public) ident(IRubyObject) ident(instance_eval)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyModule) ident(klazz)operator(;) - - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) operator({) - comment(// Ruby uses Qnil here, we use "dummy" because we need a class) - ident(klazz) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDummy)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(klazz) operator(=) ident(getSingletonClass)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(specificEval)operator(()ident(context)operator(,) ident(klazz)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyModule) ident(getInstanceEvalClass)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) operator({) - comment(// Ruby uses Qnil here, we use "dummy" because we need a class) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getDummy)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getSingletonClass)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_obj_instance_exec - * - * call-seq: - * obj.instance_exec(arg...\) {|var...| block } => obj - * - * Executes the given block within the context of the receiver - * (_obj_\). In order to set the context, the variable +self+ is set - * to _obj_ while the code is executing, giving the code access to - * _obj_'s instance variables. Arguments are passed as block parameters. - * - * class Klass - * def initialize - * @secret = 99 - * end - * end - * k = Klass.new - * k.instance_exec(5\) {|x| @secret+x } #=> 104 - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_exec)delimiter(")>operator(,) ident(optional) operator(=) integer(3)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(instance_exec)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(block not supplied)delimiter(")>operator(\))operator(;) - - ident(RubyModule) ident(klazz)operator(;) - keyword(if) operator(()ident(isImmediate)operator(()operator(\))operator(\)) operator({) - comment(// Ruby uses Qnil here, we use "dummy" because we need a class) - ident(klazz) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDummy)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(klazz) operator(=) ident(getSingletonClass)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(yieldUnder)operator(()ident(context)operator(,) ident(klazz)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_extend - * - * call-seq: - * obj.extend(module, ...\) => obj - * - * Adds to _obj_ the instance methods from each module given as a - * parameter. - * - * module Mod - * def hello - * "Hello from Mod.\\n" - * end - * end - * - * class Klass - * def hello - * "Hello from Klass.\\n" - * end - * end - * - * k = Klass.new - * k.hello #=> "Hello from Klass.\\n" - * k.extend(Mod\) #=> #<Klass:0x401b3bc8> - * k.hello #=> "Hello from Mod.\\n" - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(extend)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(extend)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - comment(// Make sure all arguments are modules before calling the callbacks) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)ident(i)operator(])operator(.)ident(isModule)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(args)operator([)ident(i)operator(])operator(,) ident(runtime)operator(.)ident(getModule)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - comment(// MRI extends in order from last to first) - keyword(for) operator(()type(int) ident(i) operator(=) ident(args)operator(.)ident(length) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(args)operator([)ident(i)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(extend_object)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - ident(args)operator([)ident(i)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(extended)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_obj_dummy - * - * Default initialize method. This one gets defined in some other - * place as a Ruby method. - */) - directive(public) ident(IRubyObject) ident(initialize)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_f_send - * - * send( aSymbol [, args ]* \) -> anObject - * - * Invokes the method identified by aSymbol, passing it any arguments - * specified. You can use __send__ if the name send clashes with an - * existing method in this object. - * - * <pre> - * class Klass - * def hello(*args\) - * "Hello " + args.join(' '\) - * end - * end - * - * k = Klass.new - * k.send :hello, "gentle", "readers" - * </pre> - * - * @return the result of invoking the method identified by aSymbol. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(send)delimiter(")>operator(,) string<delimiter(")content(__send__)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(send)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()integer(0)operator(,) integer(1)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(send)delimiter(")>operator(,) string<delimiter(")content(__send__)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(send)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(arg0)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(finvoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(send)delimiter(")>operator(,) string<delimiter(")content(__send__)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(send)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(arg0)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(finvoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(send)delimiter(")>operator(,) string<delimiter(")content(__send__)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(send)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(arg0)operator(.)ident(asJavaString)operator(()operator(\))operator(;) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(finvoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(block)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(send)delimiter(")>operator(,) string<delimiter(")content(__send__)delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(send)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(name) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(;) - type(int) ident(newArgsLength) operator(=) ident(args)operator(.)ident(length) operator(-) integer(1)operator(;) - - ident(IRubyObject)type([]) ident(newArgs)operator(;) - keyword(if) operator(()ident(newArgsLength) operator(==) integer(0)operator(\)) operator({) - ident(newArgs) operator(=) ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(;) - operator(}) keyword(else) operator({) - ident(newArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(newArgsLength)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(1)operator(,) ident(newArgs)operator(,) integer(0)operator(,) ident(newArgs)operator(.)ident(length)operator(\))operator(;) - operator(}) - - keyword(return) ident(getMetaClass)operator(()operator(\))operator(.)ident(finvoke)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(name)operator(,) ident(newArgs)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** rb_false - * - * call_seq: - * nil.nil? => true - * <anything_else>.nil? => false - * - * Only the object <i>nil</i> responds <code>true</code> to <code>nil?</code>. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(nil?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(nil_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_pattern_match - * - * call-seq: - * obj =~ other => false - * - * Pattern Match---Overridden by descendents (notably - * <code>Regexp</code> and <code>String</code>\) to provide meaningful - * pattern-match semantics. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(=~)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_match)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(to_java)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseName)operator(()operator(\)) operator(+) string<delimiter(")content( cannot coerce to a Java type.)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(as)operator(()pre_type(Class) ident(javaClass)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseName)operator(()operator(\)) operator(+) string<delimiter(")content( cannot coerce to a Java type.)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.IRubyObject#getType(\) - */) - directive(public) ident(RubyClass) ident(getType)operator(()operator(\)) operator({) - keyword(return) ident(type)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.IRubyObject#dataWrapStruct(\) - */) - directive(public) directive(synchronized) type(void) ident(dataWrapStruct)operator(()pre_type(Object) ident(obj)operator(\)) operator({) - local_variable(this)operator(.)ident(dataStruct) operator(=) ident(obj)operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.IRubyObject#dataGetStruct(\) - */) - directive(public) directive(synchronized) pre_type(Object) ident(dataGetStruct)operator(()operator(\)) operator({) - keyword(return) ident(dataStruct)operator(;) - operator(}) - - comment(/** - * Adds the specified object as a finalizer for this object. - */) - directive(public) type(void) ident(addFinalizer)operator(()ident(IRubyObject) ident(finalizer)operator(\)) operator({) - keyword(if) operator(()local_variable(this)operator(.)ident(finalizer) operator(==) pre_constant(null)operator(\)) operator({) - local_variable(this)operator(.)ident(finalizer) operator(=) keyword(new) ident(Finalizer)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(idOf)operator(()local_variable(this)operator(\))operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(addFinalizer)operator(()local_variable(this)operator(.)ident(finalizer)operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(finalizer)operator(.)ident(addFinalizer)operator(()ident(finalizer)operator(\))operator(;) - operator(}) - - comment(/** - * Remove all the finalizers for this object. - */) - directive(public) type(void) ident(removeFinalizers)operator(()operator(\)) operator({) - keyword(if) operator(()ident(finalizer) operator(!=) pre_constant(null)operator(\)) operator({) - ident(finalizer)operator(.)ident(removeFinalizers)operator(()operator(\))operator(;) - ident(finalizer) operator(=) pre_constant(null)operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(removeFinalizer)operator(()local_variable(this)operator(.)ident(finalizer)operator(\))operator(;) - operator(}) - operator(}) - - - comment(//) - comment(// INSTANCE VARIABLE RUBY METHODS) - comment(//) - - comment(/** rb_obj_ivar_defined - * - * call-seq: - * obj.instance_variable_defined?(symbol\) => true or false - * - * Returns <code>true</code> if the given instance variable is - * defined in <i>obj</i>. - * - * class Fred - * def initialize(p1, p2\) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99\) - * fred.instance_variable_defined?(:@a\) #=> true - * fred.instance_variable_defined?("@b"\) #=> true - * fred.instance_variable_defined?("@c"\) #=> false - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_variable_defined?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(instance_variable_defined_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(variableTableContains)operator(()ident(validateInstanceVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(\))operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_ivar_get - * - * call-seq: - * obj.instance_variable_get(symbol\) => obj - * - * Returns the value of the given instance variable, or nil if the - * instance variable is not set. The <code>@</code> part of the - * variable name should be included for regular instance - * variables. Throws a <code>NameError</code> exception if the - * supplied symbol is not valid as an instance variable name. - * - * class Fred - * def initialize(p1, p2\) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99\) - * fred.instance_variable_get(:@a\) #=> "cat" - * fred.instance_variable_get("@b"\) #=> 99 - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(instance_variable_get)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(\)) operator({) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(variableTableFetch)operator(()ident(validateInstanceVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_obj_ivar_set - * - * call-seq: - * obj.instance_variable_set(symbol, obj\) => obj - * - * Sets the instance variable names by <i>symbol</i> to - * <i>object</i>, thereby frustrating the efforts of the class's - * author to attempt to provide proper encapsulation. The variable - * did not have to exist prior to this call. - * - * class Fred - * def initialize(p1, p2\) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99\) - * fred.instance_variable_set(:@a, 'dog'\) #=> "dog" - * fred.instance_variable_set(:@c, 'cat'\) #=> "cat" - * fred.inspect #=> "#<Fred:0x401b3da8 @a=\\"dog\\", @b=99, @c=\\"cat\\">" - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_variable_set)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(instance_variable_set)operator(()ident(IRubyObject) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(ensureInstanceVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableStore)operator(()ident(validateInstanceVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** rb_obj_remove_instance_variable - * - * call-seq: - * obj.remove_instance_variable(symbol\) => obj - * - * Removes the named instance variable from <i>obj</i>, returning that - * variable's value. - * - * class Dummy - * attr_reader :var - * def initialize - * @var = 99 - * end - * def remove - * remove_instance_variable(:@var\) - * end - * end - * d = Dummy.new - * d.var #=> 99 - * d.remove #=> 99 - * d.var #=> nil - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remove_instance_variable)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(remove_instance_variable)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(name)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(ensureInstanceVariablesSettable)operator(()operator(\))operator(;) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(variableTableRemove)operator(()ident(validateInstanceVariable)operator(()ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(instance variable )delimiter(")> operator(+) ident(name)operator(.)ident(asJavaString)operator(()operator(\)) operator(+) string<delimiter(")content( not defined)delimiter(")>operator(,) ident(name)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_obj_instance_variables - * - * call-seq: - * obj.instance_variables => array - * - * Returns an array of instance variable names for the receiver. Note - * that simply defining an accessor does not create the corresponding - * instance variable. - * - * class Fred - * attr_accessor :a1 - * def initialize - * @iv = 3 - * end - * end - * Fred.new.instance_variables #=> ["@iv"] - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(instance_variables)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(instance_variables)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(List)operator(<)pre_type(String)operator(>) ident(nameList) operator(=) ident(getInstanceVariableNameList)operator(()operator(\))operator(;) - - ident(RubyArray) ident(array) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(nameList)operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(nameList)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(array)operator(;) - operator(}) - - comment(//) - comment(// INSTANCE VARIABLE API METHODS) - comment(//) - - comment(/** - * Dummy method to avoid a cast, and to avoid polluting the - * IRubyObject interface with all the instance variable management - * methods. - */) - directive(public) ident(InstanceVariables) ident(getInstanceVariables)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#hasInstanceVariable - */) - directive(public) type(boolean) ident(hasInstanceVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#fastHasInstanceVariable - */) - directive(public) type(boolean) ident(fastHasInstanceVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariable - */) - directive(public) ident(IRubyObject) ident(getInstanceVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#fastGetInstanceVariable - */) - directive(public) ident(IRubyObject) ident(fastGetInstanceVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** rb_iv_set / rb_ivar_set - * - * @see org.jruby.runtime.builtin.InstanceVariables#setInstanceVariable - */) - directive(public) ident(IRubyObject) ident(setInstanceVariable)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(name)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureInstanceVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#fastSetInstanceVariable - */) - directive(public) ident(IRubyObject) ident(fastSetInstanceVariable)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(internedName)operator(\)) operator(&&) ident(value) operator(!=) pre_constant(null)operator(;) - ident(ensureInstanceVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#removeInstanceVariable - */) - directive(public) ident(IRubyObject) ident(removeInstanceVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(name)operator(\))operator(;) - ident(ensureInstanceVariablesSettable)operator(()operator(\))operator(;) - keyword(return) ident(variableTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariableList - */) - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getInstanceVariableList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(list)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariableNameList - */) - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(getInstanceVariableNameList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)pre_type(String)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isInstanceVariable)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - comment(/** - * The error message used when some one tries to modify an - * instance variable in a high security setting. - */) - directive(protected) directive(static) directive(final) pre_type(String) ident(ERR_INSECURE_SET_INST_VAR) operator(=) string<delimiter(")content(Insecure: can't modify instance variable)delimiter(")>operator(;) - - comment(/** - * Checks if the name parameter represents a legal instance variable name, and otherwise throws a Ruby NameError - */) - directive(protected) pre_type(String) ident(validateInstanceVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(if) operator(()ident(IdUtil)operator(.)ident(isValidInstanceVariableName)operator(()ident(name)operator(\))operator(\)) keyword(return) ident(name)operator(;) - - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()string<delimiter(")content(`)delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content(' is not allowable as an instance variable name)delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Makes sure that instance variables can be set on this object, - * including information about whether this object is frozen, or - * tainted. Will throw a suitable exception in that case. - */) - directive(protected) type(void) ident(ensureInstanceVariablesSettable)operator(()operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isFrozen)operator(()operator(\)) operator(&&) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(<) integer(4) operator(||) ident(isTaint)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(return)operator(;) - operator(}) - - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4) operator(&&) operator(!)ident(isTaint)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()ident(ERR_INSECURE_SET_INST_VAR)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()local_variable(this) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFrozenError)operator(()string<delimiter(")content(class/module )delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFrozenError)operator(()string<delimiter(")delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(//) - comment(// INTERNAL VARIABLE METHODS) - comment(//) - - comment(/** - * Dummy method to avoid a cast, and to avoid polluting the - * IRubyObject interface with all the instance variable management - * methods. - */) - directive(public) ident(InternalVariables) ident(getInternalVariables)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#hasInternalVariable - */) - directive(public) type(boolean) ident(hasInternalVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableContains)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#fastHasInternalVariable - */) - directive(public) type(boolean) ident(fastHasInternalVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastContains)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#getInternalVariable - */) - directive(public) ident(IRubyObject) ident(getInternalVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableFetch)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#fastGetInternalVariable - */) - directive(public) ident(IRubyObject) ident(fastGetInternalVariable)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(internedName)operator(\))operator(;) - keyword(return) ident(variableTableFastFetch)operator(()ident(internedName)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#setInternalVariable - */) - directive(public) type(void) ident(setInternalVariable)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(name)operator(\))operator(;) - ident(variableTableStore)operator(()ident(name)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#fastSetInternalVariable - */) - directive(public) type(void) ident(fastSetInternalVariable)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(internedName)operator(\))operator(;) - ident(variableTableFastStore)operator(()ident(internedName)operator(,) ident(value)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#removeInternalVariable - */) - directive(public) ident(IRubyObject) ident(removeInternalVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(assert) operator(!)ident(isRubyVariable)operator(()ident(name)operator(\))operator(;) - keyword(return) ident(variableTableRemove)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(/** - * Sync one variable table with another - this is used to make - * rbClone work correctly. - */) - directive(public) type(void) ident(syncVariables)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(variables)operator(\)) operator({) - ident(variableTableSync)operator(()ident(variables)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.builtin.InternalVariables#getInternalVariableList - */) - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getInternalVariableList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isRubyVariable)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(list)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - - comment(//) - comment(// COMMON VARIABLE METHODS) - comment(//) - - comment(/** - * Returns true if object has any variables, defined as: - * <ul> - * <li> instance variables - * <li> class variables - * <li> constants - * <li> internal variables, such as those used when marshaling Ranges and Exceptions - * </ul> - * @return true if object has any variables, else false - */) - directive(public) type(boolean) ident(hasVariables)operator(()operator(\)) operator({) - keyword(return) ident(variableTableGetSize)operator(()operator(\)) operator(>) integer(0)operator(;) - operator(}) - - comment(/** - * Returns the amount of instance variables, class variables, - * constants and internal variables this object has. - */) - directive(public) type(int) ident(getVariableCount)operator(()operator(\)) operator({) - keyword(return) ident(variableTableGetSize)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Gets a list of all variables in this object. - */) - comment(// TODO: must override in RubyModule to pick up constants) - directive(public) pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(getVariableList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>)operator(()operator(\))operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(list)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - comment(/** - * Gets a name list of all variables in this object. - */) - comment(// TODO: must override in RubyModule to pick up constants) - directive(public) pre_type(List)operator(<)pre_type(String)operator(>) ident(getVariableNameList)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table) operator(=) ident(variableTableGetTable)operator(()operator(\))operator(;) - pre_type(ArrayList)operator(<)pre_type(String)operator(>) ident(list) operator(=) keyword(new) pre_type(ArrayList)operator(<)pre_type(String)operator(>)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(list)operator(.)ident(add)operator(()ident(e)operator(.)ident(name)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(list)operator(;) - operator(}) - - comment(/** - * Gets internal access to the getmap for variables. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - annotation(@Deprecated) comment(// born deprecated) - directive(public) pre_type(Map) ident(getVariableMap)operator(()operator(\)) operator({) - keyword(return) ident(variableTableGetMap)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Check the syntax of a Ruby variable, including that it's longer - * than zero characters, and starts with either an @ or a capital - * letter. - */) - comment(// FIXME: this should go somewhere more generic -- maybe IdUtil) - directive(protected) directive(static) directive(final) type(boolean) ident(isRubyVariable)operator(()pre_type(String) ident(name)operator(\)) operator({) - type(char) ident(c)operator(;) - keyword(return) ident(name)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) operator(()operator(()ident(c) operator(=) ident(name)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\)) operator(==) string<delimiter(')content(@)delimiter(')> operator(||) operator(()ident(c) operator(<=) string<delimiter(')content(Z)delimiter(')> operator(&&) ident(c) operator(>=) string<delimiter(')content(A)delimiter(')>operator(\))operator(\))operator(;) - operator(}) - - comment(//) - comment(// VARIABLE TABLE METHODS, ETC.) - comment(//) - - directive(protected) directive(static) directive(final) type(int) ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(=) integer(8)operator(;) comment(// MUST be power of 2!) - directive(protected) directive(static) directive(final) type(int) ident(VARIABLE_TABLE_MAXIMUM_CAPACITY) operator(=) integer(1) operator(<)operator(<) integer(30)operator(;) - directive(protected) directive(static) directive(final) type(float) ident(VARIABLE_TABLE_LOAD_FACTOR) operator(=) float(0.75f)operator(;) - directive(protected) directive(static) directive(final) ident(VariableTableEntry)type([]) ident(VARIABLE_TABLE_EMPTY_TABLE) operator(=) keyword(new) ident(VariableTableEntry)operator([)integer(0)operator(])operator(;) - - comment(/** - * Every entry in the variable map is represented by an instance - * of this class. - */) - directive(protected) directive(static) directive(final) type(class) class(VariableTableEntry) operator({) - directive(final) type(int) ident(hash)operator(;) - directive(final) pre_type(String) ident(name)operator(;) - directive(volatile) ident(IRubyObject) ident(value)operator(;) - directive(final) ident(VariableTableEntry) ident(next)operator(;) - - ident(VariableTableEntry)operator(()type(int) ident(hash)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(,) ident(VariableTableEntry) ident(next)operator(\)) operator({) - keyword(assert) ident(name) operator(==) ident(name)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(name) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - local_variable(this)operator(.)ident(hash) operator(=) ident(hash)operator(;) - local_variable(this)operator(.)ident(name) operator(=) ident(name)operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - local_variable(this)operator(.)ident(next) operator(=) ident(next)operator(;) - operator(}) - operator(}) - - comment(/** - * Reads the value of the specified entry, locked on the current - * object. - */) - directive(protected) directive(synchronized) ident(IRubyObject) ident(variableTableReadLocked)operator(()ident(VariableTableEntry) ident(entry)operator(\)) operator({) - keyword(return) ident(entry)operator(.)ident(value)operator(;) - operator(}) - - comment(/** - * Checks if the variable table contains a variable of the - * specified name. - */) - directive(protected) type(boolean) ident(variableTableContains)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** - * Checks if the variable table contains the the variable of the - * specified name, where the precondition is that the name must be - * an interned Java String. - */) - directive(protected) type(boolean) ident(variableTableFastContains)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( not interned)delimiter(")>operator(;) - ident(VariableTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(internedName)operator(.)ident(hashCode)operator(()operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** - * Fetch an object from the variable table based on the name. - * - * @return the object or null if not found - */) - directive(protected) ident(IRubyObject) ident(variableTableFetch)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(readValue)operator(;) - keyword(return) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** - * Fetch an object from the variable table based on the name, - * where the name must be an interned Java String. - * - * @return the object or null if not found - */) - directive(protected) ident(IRubyObject) ident(variableTableFastFetch)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( not interned)delimiter(")>operator(;) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(internedName)operator(.)ident(hashCode)operator(()operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(readValue)operator(;) - keyword(return) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** - * Store a value in the variable store under the specific name. - */) - directive(protected) ident(IRubyObject) ident(variableTableStore)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(table) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(,) pre_constant(null)operator(\))operator(;) - ident(table)operator([)ident(hash) operator(&) operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(-) integer(1)operator(\))operator(]) operator(=) ident(e)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTableSize) operator(=) integer(1)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(variableTableSize) operator(+) integer(1)operator(\)) operator(>) ident(variableTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(variableTableRehash)operator(()operator(\))operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(e)operator(.)ident(value) operator(=) ident(value)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(name)operator(.)ident(intern)operator(()operator(\))operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) ident(e)operator(;) - ident(variableTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** - * Will store the value under the specified name, where the name - * needs to be an interned Java String. - */) - directive(protected) ident(IRubyObject) ident(variableTableFastStore)operator(()pre_type(String) ident(internedName)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( not interned)delimiter(")>operator(;) - type(int) ident(hash) operator(=) ident(internedName)operator(.)ident(hashCode)operator(()operator(\))operator(;) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - ident(table) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(value)operator(,) pre_constant(null)operator(\))operator(;) - ident(table)operator([)ident(hash) operator(&) operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(-) integer(1)operator(\))operator(]) operator(=) ident(e)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTableSize) operator(=) integer(1)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(variableTableSize) operator(+) integer(1)operator(\)) operator(>) ident(variableTableThreshold)operator(\)) operator({) - ident(table) operator(=) ident(variableTableRehash)operator(()operator(\))operator(;) - operator(}) - type(int) ident(index)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - ident(e)operator(.)ident(value) operator(=) ident(value)operator(;) - keyword(return) ident(value)operator(;) - operator(}) - operator(}) - ident(e) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(value)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) ident(e)operator(;) - ident(variableTableSize) operator(=) ident(potentialNewSize)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile) - operator(}) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** - * Removes the entry with the specified name from the variable - * table, and returning the removed value. - */) - directive(protected) ident(IRubyObject) ident(variableTableRemove)operator(()pre_type(String) ident(name)operator(\)) operator({) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - type(int) ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(;) - ident(VariableTableEntry) ident(first) operator(=) ident(table)operator([)ident(index)operator(])operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(for) operator(()ident(e) operator(=) ident(first)operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(oldValue) operator(=) ident(e)operator(.)ident(value)operator(;) - comment(// All entries following removed node can stay) - comment(// in list, but all preceding ones need to be) - comment(// cloned.) - ident(VariableTableEntry) ident(newFirst) operator(=) ident(e)operator(.)ident(next)operator(;) - keyword(for) operator(()ident(VariableTableEntry) ident(p) operator(=) ident(first)operator(;) ident(p) operator(!=) ident(e)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - ident(newFirst) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(value)operator(,) ident(newFirst)operator(\))operator(;) - operator(}) - ident(table)operator([)ident(index)operator(]) operator(=) ident(newFirst)operator(;) - ident(variableTableSize)operator(--)operator(;) - ident(variableTable) operator(=) ident(table)operator(;) comment(// write-volatile ) - keyword(return) ident(oldValue)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** - * Get the actual table used to save variable entries. - */) - directive(protected) ident(VariableTableEntry)type([]) ident(variableTableGetTable)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(table)operator(;) - operator(}) - keyword(return) ident(VARIABLE_TABLE_EMPTY_TABLE)operator(;) - operator(}) - - comment(/** - * Get the size of the variable table. - */) - directive(protected) type(int) ident(variableTableGetSize)operator(()operator(\)) operator({) - keyword(if) operator(()ident(variableTable) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(variableTableSize)operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - comment(/** - * Synchronize the variable table with the argument. In real terms - * this means copy all entries into a newly allocated table. - */) - directive(protected) type(void) ident(variableTableSync)operator(()pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(vars)operator(\)) operator({) - directive(synchronized)operator(()local_variable(this)operator(\)) operator({) - ident(variableTableSize) operator(=) integer(0)operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(VARIABLE_TABLE_DEFAULT_CAPACITY) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - ident(variableTable) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(VARIABLE_TABLE_DEFAULT_CAPACITY)operator(])operator(;) - keyword(for) operator(()ident(Variable)operator(<)ident(IRubyObject)operator(>) ident(var) operator(:) ident(vars)operator(\)) operator({) - ident(variableTableStore)operator(()ident(var)operator(.)ident(getName)operator(()operator(\))operator(,) ident(var)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** - * Rehashes the variable table. Must be called from a synchronized - * block. - */) - comment(// MUST be called from synchronized/locked block!) - comment(// should only be called by variableTableStore/variableTableFastStore) - directive(protected) directive(final) ident(VariableTableEntry)type([]) ident(variableTableRehash)operator(()operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(oldTable) operator(=) ident(variableTable)operator(;) - type(int) ident(oldCapacity)operator(;) - keyword(if) operator(()operator(()ident(oldCapacity) operator(=) ident(oldTable)operator(.)ident(length)operator(\)) operator(>=) ident(VARIABLE_TABLE_MAXIMUM_CAPACITY)operator(\)) operator({) - keyword(return) ident(oldTable)operator(;) - operator(}) - - type(int) ident(newCapacity) operator(=) ident(oldCapacity) operator(<)operator(<) integer(1)operator(;) - ident(VariableTableEntry)type([]) ident(newTable) operator(=) keyword(new) ident(VariableTableEntry)operator([)ident(newCapacity)operator(])operator(;) - ident(variableTableThreshold) operator(=) operator(()type(int)operator(\))operator(()ident(newCapacity) operator(*) ident(VARIABLE_TABLE_LOAD_FACTOR)operator(\))operator(;) - type(int) ident(sizeMask) operator(=) ident(newCapacity) operator(-) integer(1)operator(;) - ident(VariableTableEntry) ident(e)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(oldCapacity)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - comment(// We need to guarantee that any existing reads of old Map can) - comment(// proceed. So we cannot yet null out each bin.) - ident(e) operator(=) ident(oldTable)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()ident(e) operator(!=) pre_constant(null)operator(\)) operator({) - ident(VariableTableEntry) ident(next) operator(=) ident(e)operator(.)ident(next)operator(;) - type(int) ident(idx) operator(=) ident(e)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - - comment(// Single node on list) - keyword(if) operator(()ident(next) operator(==) pre_constant(null)operator(\)) - ident(newTable)operator([)ident(idx)operator(]) operator(=) ident(e)operator(;) - - keyword(else) operator({) - comment(// Reuse trailing consecutive sequence at same slot) - ident(VariableTableEntry) ident(lastRun) operator(=) ident(e)operator(;) - type(int) ident(lastIdx) operator(=) ident(idx)operator(;) - keyword(for) operator(()ident(VariableTableEntry) ident(last) operator(=) ident(next)operator(;) - ident(last) operator(!=) pre_constant(null)operator(;) - ident(last) operator(=) ident(last)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(last)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - keyword(if) operator(()ident(k) operator(!=) ident(lastIdx)operator(\)) operator({) - ident(lastIdx) operator(=) ident(k)operator(;) - ident(lastRun) operator(=) ident(last)operator(;) - operator(}) - operator(}) - ident(newTable)operator([)ident(lastIdx)operator(]) operator(=) ident(lastRun)operator(;) - - comment(// Clone all remaining nodes) - keyword(for) operator(()ident(VariableTableEntry) ident(p) operator(=) ident(e)operator(;) ident(p) operator(!=) ident(lastRun)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(p)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - ident(VariableTableEntry) ident(m) operator(=) keyword(new) ident(VariableTableEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(value)operator(,) ident(newTable)operator([)ident(k)operator(])operator(\))operator(;) - ident(newTable)operator([)ident(k)operator(]) operator(=) ident(m)operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - ident(variableTable) operator(=) ident(newTable)operator(;) - keyword(return) ident(newTable)operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - directive(protected) pre_type(Map) ident(variableTableGetMap)operator(()operator(\)) operator({) - pre_type(HashMap) ident(map) operator(=) keyword(new) pre_type(HashMap)operator(()operator(\))operator(;) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(map)operator(.)ident(put)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(map)operator(;) - operator(}) - - comment(/** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unchecked)delimiter(")>operator(\)) - directive(protected) pre_type(Map) ident(variableTableGetMap)operator(()pre_type(Map) ident(map)operator(\)) operator({) - ident(VariableTableEntry)type([]) ident(table)operator(;) - ident(IRubyObject) ident(readValue)operator(;) - keyword(if) operator(()operator(()ident(table) operator(=) ident(variableTable)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(VariableTableEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()operator(()ident(readValue) operator(=) ident(e)operator(.)ident(value)operator(\)) operator(==) pre_constant(null)operator(\)) ident(readValue) operator(=) ident(variableTableReadLocked)operator(()ident(e)operator(\))operator(;) - ident(map)operator(.)ident(put)operator(()ident(e)operator(.)ident(name)operator(,) ident(readValue)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) ident(map)operator(;) - operator(}) - - comment(/** - * Tries to support Java serialization of Ruby objects. This is - * still experimental and might not work. - */) - comment(// NOTE: Serialization is primarily supported for testing purposes, and there is no general) - comment(// guarantee that serialization will work correctly. Specifically, instance variables pointing) - comment(// at symbols, threads, modules, classes, and other unserializable types are not detected.) - directive(private) type(void) ident(writeObject)operator(()pre_type(ObjectOutputStream) ident(out)operator(\)) directive(throws) exception(IOException) operator({) - ident(out)operator(.)ident(defaultWriteObject)operator(()operator(\))operator(;) - comment(// write out ivar count followed by name/value pairs) - pre_type(List)operator(<)pre_type(String)operator(>) ident(names) operator(=) ident(getInstanceVariableNameList)operator(()operator(\))operator(;) - ident(out)operator(.)ident(writeInt)operator(()ident(names)operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()pre_type(String) ident(name) operator(:) ident(names)operator(\)) operator({) - ident(out)operator(.)ident(writeObject)operator(()ident(name)operator(\))operator(;) - ident(out)operator(.)ident(writeObject)operator(()ident(getInstanceVariables)operator(()operator(\))operator(.)ident(getInstanceVariable)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Tries to support Java unserialization of Ruby objects. This is - * still experimental and might not work. - */) - directive(private) type(void) ident(readObject)operator(()pre_type(ObjectInputStream) ident(in)operator(\)) directive(throws) exception(IOException)operator(,) exception(ClassNotFoundException) operator({) - ident(in)operator(.)ident(defaultReadObject)operator(()operator(\))operator(;) - comment(// rest in ivar count followed by name/value pairs) - type(int) ident(ivarCount) operator(=) ident(in)operator(.)ident(readInt)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(ivarCount)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(setInstanceVariable)operator(()operator(()pre_type(String)operator(\))ident(in)operator(.)ident(readObject)operator(()operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(in)operator(.)ident(readObject)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - -operator(}) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * - * @author nicksieger - */) -directive(public) type(interface) class(RubyObjectAdapter) operator({) - - type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(value)operator(,) ident(RubyModule) ident(rubyModule)operator(\))operator(;) - - ident(IRubyObject) ident(setInstanceVariable)operator(()ident(IRubyObject) ident(obj)operator(,) pre_type(String) ident(variableName)operator(,) ident(IRubyObject) ident(value)operator(\))operator(;) - - ident(IRubyObject)type([]) ident(convertToJavaArray)operator(()ident(IRubyObject) ident(array)operator(\))operator(;) - - ident(RubyInteger) ident(convertToRubyInteger)operator(()ident(IRubyObject) ident(obj)operator(\))operator(;) - - ident(IRubyObject) ident(getInstanceVariable)operator(()ident(IRubyObject) ident(obj)operator(,) pre_type(String) ident(variableName)operator(\))operator(;) - - ident(RubyString) ident(convertToRubyString)operator(()ident(IRubyObject) ident(obj)operator(\))operator(;) - - comment(// These call* assume ThreadContext = receiver.getRuntime(\).getCurrentContext(\)) - ident(IRubyObject) ident(callMethod)operator(()ident(IRubyObject) ident(receiver)operator(,) pre_type(String) ident(methodName)operator(\))operator(;) - - ident(IRubyObject) ident(callMethod)operator(()ident(IRubyObject) ident(receiver)operator(,) pre_type(String) ident(methodName)operator(,) ident(IRubyObject) ident(singleArg)operator(\))operator(;) - - ident(IRubyObject) ident(callMethod)operator(()ident(IRubyObject) ident(receiver)operator(,) pre_type(String) ident(methodName)operator(,) ident(IRubyObject)type([]) ident(args)operator(\))operator(;) - - ident(IRubyObject) ident(callMethod)operator(()ident(IRubyObject) ident(receiver)operator(,) pre_type(String) ident(methodName)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\))operator(;) - - ident(IRubyObject) ident(callSuper)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject)type([]) ident(args)operator(\))operator(;) - - ident(IRubyObject) ident(callSuper)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\))operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.Iterator)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(ObjectSpace)delimiter(")>operator(\)) -directive(public) type(class) class(RubyObjectSpace) operator({) - - comment(/** Create the ObjectSpace module and add it to the Ruby runtime. - * - */) - directive(public) directive(static) ident(RubyModule) ident(createObjectSpaceModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(objectSpaceModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(ObjectSpace)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setObjectSpaceModule)operator(()ident(objectSpaceModule)operator(\))operator(;) - - ident(objectSpaceModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyObjectSpace)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(objectSpaceModule)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(define_finalizer)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(define_finalizer)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(finalizer) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2)operator(\)) operator({) - ident(finalizer) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - keyword(if) operator(()operator(!)ident(finalizer)operator(.)ident(respondsTo)operator(()string<delimiter(")content(call)delimiter(")>operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong type argument )delimiter(")> - operator(+) ident(finalizer)operator(.)ident(getType)operator(()operator(\)) operator(+) string<delimiter(")content( (should be callable\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(finalizer) operator(=) ident(runtime)operator(.)ident(newProc)operator(()ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(,) ident(block)operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(obj) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(runtime)operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(addFinalizer)operator(()ident(obj)operator(,) ident(finalizer)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(newFixnum)operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\))operator(\))operator(,) ident(finalizer)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(undefine_finalizer)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(undefine_finalizer)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(removeFinalizers)operator(()ident(RubyNumeric)operator(.)ident(fix2long)operator(()ident(arg1)operator(.)ident(id)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(recv)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_id2ref)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(id2ref)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(id)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(id)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(id) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(id)operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFixnum)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(RubyFixnum) ident(idFixnum) operator(=) operator(()ident(RubyFixnum)operator(\)) ident(id)operator(;) - type(long) ident(longId) operator(=) ident(idFixnum)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(longId) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(longId) operator(==) integer(2)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(longId) operator(==) integer(4)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(longId) operator(%) integer(2) operator(!=) integer(0)operator(\)) operator({) - comment(// odd) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()operator(()ident(longId) operator(-) integer(1)operator(\)) operator(/) integer(2)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(object) operator(=) ident(runtime)operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(id2ref)operator(()ident(longId)operator(\))operator(;) - keyword(if) operator(()ident(object) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(object)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_object)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_object)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyModule) ident(rubyClass)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(rubyClass) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getObject)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyModule)operator(\))operator(\)) keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(class or module required)delimiter(")>operator(\))operator(;) - ident(rubyClass) operator(=) operator(()ident(RubyModule)operator(\)) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(count) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(rubyClass) operator(!=) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)ident(runtime)operator(.)ident(isObjectSpaceEnabled)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(ObjectSpace is disabled; each_object will only work with Class, pass +O to enable)delimiter(")>operator(\))operator(;) - operator(}) - pre_type(Iterator) ident(iter) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getObjectSpace)operator(()operator(\))operator(.)ident(iterator)operator(()ident(rubyClass)operator(\))operator(;) - - ident(IRubyObject) ident(obj) operator(=) pre_constant(null)operator(;) - keyword(while) operator(()operator(()ident(obj) operator(=) operator(()ident(IRubyObject)operator(\))ident(iter)operator(.)ident(next)operator(()operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(count)operator(++)operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - pre_type(Iterator) ident(iter) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(subclasses)operator(()pre_constant(true)operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) - - keyword(while) operator(()ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(\)) operator({) - ident(count)operator(++)operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) operator(()ident(IRubyObject)operator(\))ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(count)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(garbage_collect)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(garbage_collect)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(RubyGC)operator(.)ident(start)operator(()ident(recv)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.callback.Callback)operator(;) - -comment(/** - * - * @author jpetersen - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Precision)delimiter(")>operator(\)) -directive(public) type(class) class(RubyPrecision) operator({) - - directive(public) directive(static) ident(RubyModule) ident(createPrecisionModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(precisionModule) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Precision)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setPrecision)operator(()ident(precisionModule)operator(\))operator(;) - - ident(precisionModule)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyPrecision)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(precisionModule)operator(;) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(induced_from)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject) ident(source)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(throw) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Undefined conversion from )delimiter(")> operator(+) ident(source)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( into )delimiter(")> operator(+) operator(()operator(()ident(RubyClass)operator(\))ident(receiver)operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(append_features)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(append_features)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject) ident(include)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(include) keyword(instanceof) ident(RubyModule)operator(\)) operator({) - operator(()operator(()ident(RubyModule)operator(\)) ident(include)operator(\))operator(.)ident(includeModule)operator(()ident(receiver)operator(\))operator(;) - ident(include)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineMethod)operator(()string<delimiter(")content(induced_from)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - - keyword(return) ident(RubyPrecision)operator(.)ident(induced_from)operator(()ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(ONE_ARGUMENT)operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - keyword(return) ident(receiver)operator(;) - operator(}) - - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(prec)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(prec)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject) ident(type)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(type)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(induced_from)delimiter(")>operator(,) ident(receiver)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(prec_i)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(prec_i)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(receiver)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getInteger)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(induced_from)delimiter(")>operator(,) ident(receiver)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(prec_f)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(prec_f)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(receiver)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFloat)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(induced_from)delimiter(")>operator(,) ident(receiver)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.reflect.InvocationHandler)operator(;) -keyword(import) include(java.lang.reflect.Method)operator(;) -keyword(import) include(java.lang.reflect.Proxy)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.exceptions.JumpException)operator(;) -keyword(import) include(org.jruby.internal.runtime.JumpTarget)operator(;) -keyword(import) include(org.jruby.java.MiniJava)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Proc)delimiter(")>operator(\)) -directive(public) type(class) class(RubyProc) directive(extends) ident(RubyObject) directive(implements) ident(JumpTarget) operator({) - directive(private) ident(Block) ident(block) operator(=) ident(Block)operator(.)ident(NULL_BLOCK)operator(;) - directive(private) ident(Block)operator(.)ident(Type) ident(type)operator(;) - directive(private) pre_type(String) ident(file)operator(;) - directive(private) type(int) ident(line)operator(;) - - directive(public) ident(RubyProc)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) ident(Block)operator(.)ident(Type) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - - local_variable(this)operator(.)ident(type) operator(=) ident(type)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(PROC_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyProc) ident(instance) operator(=) ident(RubyProc)operator(.)ident(newProc)operator(()ident(runtime)operator(,) ident(Block)operator(.)ident(Type)operator(.)ident(PROC)operator(\))operator(;) - - ident(instance)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createProcClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(procClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Proc)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(PROC_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setProc)operator(()ident(procClass)operator(\))operator(;) - - ident(procClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyProc)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(procClass)operator(;) - operator(}) - - directive(public) ident(Block) ident(getBlock)operator(()operator(\)) operator({) - keyword(return) ident(block)operator(;) - operator(}) - - comment(// Proc class) - - directive(public) directive(static) ident(RubyProc) ident(newProc)operator(()ident(Ruby) ident(runtime)operator(,) ident(Block)operator(.)ident(Type) ident(type)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyProc)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getProc)operator(()operator(\))operator(,) ident(type)operator(\))operator(;) - operator(}) - directive(public) directive(static) ident(RubyProc) ident(newProc)operator(()ident(Ruby) ident(runtime)operator(,) ident(Block) ident(block)operator(,) ident(Block)operator(.)ident(Type) ident(type)operator(\)) operator({) - ident(RubyProc) ident(proc) operator(=) keyword(new) ident(RubyProc)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getProc)operator(()operator(\))operator(,) ident(type)operator(\))operator(;) - ident(proc)operator(.)ident(callInit)operator(()ident(NULL_ARRAY)operator(,) ident(block)operator(\))operator(;) - - keyword(return) ident(proc)operator(;) - operator(}) - - comment(/** - * Create a new instance of a Proc object. We override this method (from RubyClass\) - * since we need to deal with special case of Proc.new with no arguments or block arg. In - * this case, we need to check previous frame for a block to consume. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - comment(// No passed in block, lets check next outer frame for one ('Proc.new'\)) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(block) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(getBlock)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\)) operator(&&) ident(block)operator(.)ident(getProcObject)operator(()operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(block)operator(.)ident(getProcObject)operator(()operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(obj) operator(=) operator(()operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(obj)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(procBlock)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(procBlock)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(tried to create Proc object without a block)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(type) operator(==) ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA) operator(&&) ident(procBlock) operator(==) pre_constant(null)operator(\)) operator({) - comment(// TODO: warn "tried to create Proc object without a block") - operator(}) - - ident(block) operator(=) ident(procBlock)operator(.)ident(cloneBlock)operator(()operator(\))operator(;) - ident(block)operator(.)ident(type) operator(=) ident(type)operator(;) - ident(block)operator(.)ident(setProcObject)operator(()local_variable(this)operator(\))operator(;) - - ident(file) operator(=) ident(context)operator(.)ident(getFile)operator(()operator(\))operator(;) - ident(line) operator(=) ident(context)operator(.)ident(getLine)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clone)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rbClone)operator(()operator(\)) operator({) - ident(RubyProc) ident(newProc) operator(=) keyword(new) ident(RubyProc)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getProc)operator(()operator(\))operator(,) ident(type)operator(\))operator(;) - ident(newProc)operator(.)ident(block) operator(=) ident(getBlock)operator(()operator(\))operator(;) - ident(newProc)operator(.)ident(file) operator(=) ident(file)operator(;) - ident(newProc)operator(.)ident(line) operator(=) ident(line)operator(;) - comment(// TODO: CLONE_SETUP here) - keyword(return) ident(newProc)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dup)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(dup)operator(()operator(\)) operator({) - ident(RubyProc) ident(newProc) operator(=) keyword(new) ident(RubyProc)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getProc)operator(()operator(\))operator(,) ident(type)operator(\))operator(;) - ident(newProc)operator(.)ident(block) operator(=) ident(getBlock)operator(()operator(\))operator(;) - ident(newProc)operator(.)ident(file) operator(=) ident(file)operator(;) - ident(newProc)operator(.)ident(line) operator(=) ident(line)operator(;) - keyword(return) ident(newProc)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyProc)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(other) operator(||) local_variable(this)operator(.)ident(block) operator(==) operator(()operator(()ident(RubyProc)operator(\))ident(other)operator(\))operator(.)ident(block)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) - string<delimiter(")content(#<Proc:0x)delimiter(")> operator(+) pre_type(Integer)operator(.)ident(toString)operator(()ident(block)operator(.)ident(hashCode)operator(()operator(\))operator(,) integer(16)operator(\)) operator(+) string<delimiter(")content(@)delimiter(")> operator(+) - ident(file) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) operator(()ident(line) operator(+) integer(1)operator(\)) operator(+) string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(binding)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(binding)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBinding)operator(()ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(call)operator(()ident(context)operator(,) ident(args)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(assert) ident(args) operator(!=) pre_constant(null)operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(Block) ident(newBlock) operator(=) ident(block)operator(.)ident(cloneBlock)operator(()operator(\))operator(;) - ident(JumpTarget) ident(jumpTarget) operator(=) ident(newBlock)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(getFrame)operator(()operator(\))operator(.)ident(getJumpTarget)operator(()operator(\))operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(self) operator(!=) pre_constant(null)operator(\)) ident(newBlock)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setSelf)operator(()ident(self)operator(\))operator(;) - - keyword(return) ident(newBlock)operator(.)ident(call)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(BreakJump) ident(bj)operator(\)) operator({) - keyword(switch)operator(()ident(block)operator(.)ident(type)operator(\)) operator({) - keyword(case) ident(LAMBDA)operator(:) keyword(if) operator(()ident(bj)operator(.)ident(getTarget)operator(()operator(\)) operator(==) ident(jumpTarget)operator(\)) operator({) - keyword(return) operator(()ident(IRubyObject)operator(\)) ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(runtime)operator(.)ident(newLocalJumpError)operator(()string<delimiter(")content(break)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(unexpected break)delimiter(")>operator(\))operator(;) - operator(}) - keyword(case) ident(PROC)operator(:) - keyword(if) operator(()ident(newBlock)operator(.)ident(isEscaped)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newLocalJumpError)operator(()string<delimiter(")content(break)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(bj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(break from proc-closure)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(bj)operator(;) - operator(}) - keyword(default)operator(:) keyword(throw) ident(bj)operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(ReturnJump) ident(rj)operator(\)) operator({) - pre_type(Object) ident(target) operator(=) ident(rj)operator(.)ident(getTarget)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(target) operator(==) ident(jumpTarget) operator(&&) ident(block)operator(.)ident(type) operator(==) ident(Block)operator(.)ident(Type)operator(.)ident(LAMBDA)operator(\)) keyword(return) operator(()ident(IRubyObject)operator(\)) ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(type) operator(==) ident(Block)operator(.)ident(Type)operator(.)ident(THREAD)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(return can't jump across threads)delimiter(")>operator(\))operator(;) - operator(}) - keyword(throw) ident(rj)operator(;) - operator(}) keyword(catch) operator(()ident(JumpException)operator(.)ident(RetryJump) ident(rj)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newLocalJumpError)operator(()string<delimiter(")content(retry)delimiter(")>operator(,) operator(()ident(IRubyObject)operator(\))ident(rj)operator(.)ident(getValue)operator(()operator(\))operator(,) string<delimiter(")content(retry not supported outside rescue)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(arity)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(arity)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(block)operator(.)ident(arity)operator(()operator(\))operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_proc)delimiter(")>operator(\)) - directive(public) ident(RubyProc) ident(to_proc)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(as)operator(()pre_type(Class) ident(asClass)operator(\)) operator({) - directive(final) ident(Ruby) ident(ruby) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(asClass)operator(.)ident(isInterface)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(ruby)operator(.)ident(newTypeError)operator(()ident(asClass)operator(.)ident(getCanonicalName)operator(()operator(\)) operator(+) string<delimiter(")content( is not an interface)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(MiniJava)operator(.)ident(javaToRuby)operator(()ident(ruby)operator(,) pre_type(Proxy)operator(.)ident(newProxyInstance)operator(()ident(Ruby)operator(.)ident(getClassLoader)operator(()operator(\))operator(,) keyword(new) pre_type(Class)type([]) operator({)ident(asClass)operator(})operator(,) keyword(new) pre_type(InvocationHandler)operator(()operator(\)) operator({) - directive(public) pre_type(Object) ident(invoke)operator(()pre_type(Object) ident(proxy)operator(,) pre_type(Method) ident(method)operator(,) pre_type(Object)type([]) ident(args)operator(\)) directive(throws) pre_type(Throwable) operator({) - ident(IRubyObject)type([]) ident(rubyArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(args)operator(.)ident(length) operator(+) integer(1)operator(])operator(;) - ident(rubyArgs)operator([)integer(0)operator(]) operator(=) ident(RubySymbol)operator(.)ident(newSymbol)operator(()ident(ruby)operator(,) ident(method)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(rubyArgs)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(rubyArgs)operator([)ident(i)operator(]) operator(=) ident(MiniJava)operator(.)ident(javaToRuby)operator(()ident(ruby)operator(,) ident(args)operator([)ident(i) operator(-) integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(MiniJava)operator(.)ident(rubyToJava)operator(()ident(call)operator(()ident(ruby)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(rubyArgs)operator(\))operator(\))operator(;) - operator(}) - operator(})operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.ext.posix.POSIX)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.BlockCallback)operator(;) -keyword(import) include(org.jruby.runtime.CallBlock)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - - -comment(/** - */) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Process)delimiter(")>operator(\)) -directive(public) type(class) class(RubyProcess) operator({) - - directive(public) directive(static) ident(RubyModule) ident(createProcessModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(process) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Process)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setProcess)operator(()ident(process)operator(\))operator(;) - - comment(// TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415) - ident(RubyClass) ident(process_status) operator(=) ident(process)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Status)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setProcStatus)operator(()ident(process_status)operator(\))operator(;) - - ident(RubyModule) ident(process_uid) operator(=) ident(process)operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(UID)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setProcUID)operator(()ident(process_uid)operator(\))operator(;) - - ident(RubyModule) ident(process_gid) operator(=) ident(process)operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(GID)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setProcGID)operator(()ident(process_gid)operator(\))operator(;) - - ident(RubyModule) ident(process_sys) operator(=) ident(process)operator(.)ident(defineModuleUnder)operator(()string<delimiter(")content(Sys)delimiter(")>operator(\))operator(;) - ident(runtime)operator(.)ident(setProcSys)operator(()ident(process_sys)operator(\))operator(;) - - ident(process)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyProcess)operator(.)ident(class)operator(\))operator(;) - ident(process_status)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyStatus)operator(.)ident(class)operator(\))operator(;) - ident(process_uid)operator(.)ident(defineAnnotatedMethods)operator(()ident(UserID)operator(.)ident(class)operator(\))operator(;) - ident(process_gid)operator(.)ident(defineAnnotatedMethods)operator(()ident(GroupID)operator(.)ident(class)operator(\))operator(;) - ident(process_sys)operator(.)ident(defineAnnotatedMethods)operator(()ident(Sys)operator(.)ident(class)operator(\))operator(;) - - ident(process)operator(.)ident(defineConstant)operator(()string<delimiter(")content(PRIO_PROCESS)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(process)operator(.)ident(defineConstant)operator(()string<delimiter(")content(PRIO_PGRP)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - ident(process)operator(.)ident(defineConstant)operator(()string<delimiter(")content(PRIO_USER)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\))operator(;) - - ident(process)operator(.)ident(defineConstant)operator(()string<delimiter(")content(WNOHANG)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - - keyword(return) ident(process)operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Process::Status)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(RubyStatus) directive(extends) ident(RubyObject) operator({) - directive(private) type(long) ident(status) operator(=) integer(0L)operator(;) - - directive(private) directive(static) directive(final) type(long) ident(EXIT_SUCCESS) operator(=) integer(0L)operator(;) - directive(public) ident(RubyStatus)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(,) type(long) ident(status)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(metaClass)operator(\))operator(;) - local_variable(this)operator(.)ident(status) operator(=) ident(status)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyStatus) ident(newProcessStatus)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(status)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyStatus)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getProcStatus)operator(()operator(\))operator(,) ident(status)operator(\))operator(;) - operator(}) - - comment(// Bunch of methods still not implemented) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_int)delimiter(")>operator(,) string<delimiter(")content(pid)delimiter(")>operator(,) string<delimiter(")content(stopped?)delimiter(")>operator(,) string<delimiter(")content(stopsig)delimiter(")>operator(,) string<delimiter(")content(signaled?)delimiter(")>operator(,) string<delimiter(")content(termsig?)delimiter(")>operator(,) string<delimiter(")content(exited?)delimiter(")>operator(,) string<delimiter(")content(coredump?)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(not_implemented)operator(()operator(\)) operator({) - pre_type(String) ident(error) operator(=) string<delimiter(")content(Process::Status#)delimiter(")> operator(+) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getFrameName)operator(()operator(\)) operator(+) string<delimiter(")content( not implemented)delimiter(")>operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()ident(error)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(&)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(not_implemented1)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - pre_type(String) ident(error) operator(=) string<delimiter(")content(Process::Status#)delimiter(")> operator(+) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getFrameName)operator(()operator(\)) operator(+) string<delimiter(")content( not implemented)delimiter(")>operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()ident(error)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(exitstatus)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(status)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_rshift)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - type(long) ident(shiftValue) operator(=) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(status) operator(>)operator(>) ident(shiftValue)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EQUALEQUAL)operator(,) string<delimiter(")content(==)delimiter(")>operator(,) local_variable(this)operator(.)ident(to_i)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(to_i)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(shiftedValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()pre_type(String)operator(.)ident(valueOf)operator(()ident(shiftedValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(#<Process::Status: pid=????,exited()delimiter(")> operator(+) pre_type(String)operator(.)ident(valueOf)operator(()ident(status)operator(\)) operator(+) string<delimiter(")content(\)>)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(success?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(success_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(status) operator(==) ident(EXIT_SUCCESS)operator(\))operator(;) - operator(}) - - directive(private) type(long) ident(shiftedValue)operator(()operator(\)) operator({) - keyword(return) ident(status) operator(<)operator(<) integer(8)operator(;) - operator(}) - operator(}) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Process::UID)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(UserID) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(change_privilege)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(change_privilege)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::UID::change_privilege not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(euid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eid=)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eid)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(euid_set)operator(()ident(self)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(grant_privilege)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(grant_privilege)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::UID::grant_privilege not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(re_exchange)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(re_exchange)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(switch_rb)operator(()ident(context)operator(,) ident(self)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(re_exchangeable?)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(re_exchangeable_p)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::UID::re_exchangeable? not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(uid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sid_available?)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sid_available_p)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::UID::sid_available not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(switch)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(switch_rb)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(uid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getuid)operator(()operator(\))operator(;) - type(int) ident(euid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(geteuid)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(seteuid)operator(()ident(uid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setuid)operator(()ident(euid)operator(\))operator(;) - - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(seteuid)operator(()ident(euid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setuid)operator(()ident(uid)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(seteuid)operator(()ident(uid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setuid)operator(()ident(euid)operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Process::GID)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(GroupID) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(change_privilege)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(change_privilege)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::GID::change_privilege not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(egid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eid=)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(eid)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(RubyProcess)operator(.)ident(egid_set)operator(()ident(self)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(grant_privilege)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(grant_privilege)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::GID::grant_privilege not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(re_exchange)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(re_exchange)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(switch_rb)operator(()ident(context)operator(,) ident(self)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(re_exchangeable?)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(re_exchangeable_p)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::GID::re_exchangeable? not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(rid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(gid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sid_available?)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(sid_available_p)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process::GID::sid_available not implemented yet)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(switch)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(switch_rb)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(gid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getgid)operator(()operator(\))operator(;) - type(int) ident(egid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getegid)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setegid)operator(()ident(gid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setgid)operator(()ident(egid)operator(\))operator(;) - - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setegid)operator(()ident(egid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setgid)operator(()ident(gid)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setegid)operator(()ident(gid)operator(\))operator(;) - ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setgid)operator(()ident(egid)operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Process::Sys)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Sys) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getegid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getegid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(egid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(geteuid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(geteuid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(euid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getgid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getgid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(gid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getuid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getuid)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(uid)operator(()ident(self)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setegid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setegid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(egid_set)operator(()ident(recv)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seteuid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(seteuid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(euid_set)operator(()ident(recv)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setgid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setgid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(gid_set)operator(()ident(recv)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setuid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setuid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(uid_set)operator(()ident(recv)operator(,) ident(arg)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(abort)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(abort)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit!)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exit_bang)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(exit_bang)operator(()ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(groups)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(groups)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#groups not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setrlimit)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setrlimit)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#setrlimit not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpgrp)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpgrp)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpgrp)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(groups=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(groups_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#groups not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(waitpid)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(waitpid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(pid) operator(=) operator(-)integer(1)operator(;) - type(int) ident(flags) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(pid) operator(=) operator(()type(int)operator(\))ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(flags) operator(=) operator(()type(int)operator(\))ident(args)operator([)integer(1)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - - type(int)type([]) ident(status) operator(=) keyword(new) type(int)operator([)integer(1)operator(])operator(;) - ident(pid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(waitpid)operator(()ident(pid)operator(,) ident(status)operator(,) ident(flags)operator(\))operator(;) - - keyword(if) operator(()ident(pid) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoECHILDError)operator(()operator(\))operator(;) - operator(}) - - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(() - string<delimiter(")content($?)delimiter(")>operator(,) - ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(status)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(pid)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(wait)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(wait)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(return) ident(waitpid)operator(()ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - type(int)type([]) ident(status) operator(=) keyword(new) type(int)operator([)integer(1)operator(])operator(;) - type(int) ident(pid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(wait)operator(()ident(status)operator(\))operator(;) - - keyword(if) operator(()ident(pid) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoECHILDError)operator(()operator(\))operator(;) - operator(}) - - ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(set)operator(() - string<delimiter(")content($?)delimiter(")>operator(,) - ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(status)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(pid)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(waitall)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(waitall)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - ident(RubyArray) ident(results) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\))operator(;) - - type(int)type([]) ident(status) operator(=) keyword(new) type(int)operator([)integer(1)operator(])operator(;) - type(int) ident(result) operator(=) ident(posix)operator(.)ident(wait)operator(()ident(status)operator(\))operator(;) - keyword(while) operator(()ident(result) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(results)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(newFixnum)operator(()ident(result)operator(\))operator(,) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(status)operator([)integer(0)operator(])operator(\))operator(\))operator(\))operator(;) - ident(result) operator(=) ident(posix)operator(.)ident(wait)operator(()ident(status)operator(\))operator(;) - operator(}) - - keyword(return) ident(results)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setsid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setsid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setsid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setpgrp)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setpgrp)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setpgid)operator(()integer(0)operator(,) integer(0)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(egid=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(egid_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setegid)operator(()operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(euid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(euid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(geteuid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(uid=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(uid_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setuid)operator(()operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getgid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(maxgroups)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(maxgroups)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#maxgroups not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpriority)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpriority)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - type(int) ident(which) operator(=) operator(()type(int)operator(\))ident(arg1)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(who) operator(=) operator(()type(int)operator(\))ident(arg2)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(result) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpriority)operator(()ident(which)operator(,) ident(who)operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(uid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(uid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getuid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(waitpid2)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(waitpid2)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(pid) operator(=) operator(-)integer(1)operator(;) - type(int) ident(flags) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(pid) operator(=) operator(()type(int)operator(\))ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(flags) operator(=) operator(()type(int)operator(\))ident(args)operator([)integer(1)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) - - type(int)type([]) ident(status) operator(=) keyword(new) type(int)operator([)integer(1)operator(])operator(;) - ident(pid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(waitpid)operator(()ident(pid)operator(,) ident(status)operator(,) ident(flags)operator(\))operator(;) - - keyword(if) operator(()ident(pid) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newErrnoECHILDError)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(newFixnum)operator(()ident(pid)operator(\))operator(,) ident(RubyProcess)operator(.)ident(RubyStatus)operator(.)ident(newProcessStatus)operator(()ident(runtime)operator(,) ident(status)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initgroups)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(initgroups)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#initgroups not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(maxgroups=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(maxgroups_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#maxgroups_set not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ppid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(ppid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getppid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gid=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(gid_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setgid)operator(()operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(wait2)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(wait2)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(waitpid2)operator(()ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(euid=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(euid_set)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(seteuid)operator(()operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setpriority)delimiter(")>operator(,) ident(required) operator(=) integer(3)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setpriority)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(IRubyObject) ident(arg3)operator(\)) operator({) - type(int) ident(which) operator(=) operator(()type(int)operator(\))ident(arg1)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(who) operator(=) operator(()type(int)operator(\))ident(arg2)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(prio) operator(=) operator(()type(int)operator(\))ident(arg3)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(result) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setpriority)operator(()ident(which)operator(,) ident(who)operator(,) ident(prio)operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(setpgid)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(setpgid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - type(int) ident(pid) operator(=) operator(()type(int)operator(\))ident(arg1)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(int) ident(gid) operator(=) operator(()type(int)operator(\))ident(arg2)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(setpgid)operator(()ident(pid)operator(,) ident(gid)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getpgid)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getpgid)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpgid)operator(()operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getrlimit)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(getrlimit)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Process#getrlimit not yet implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(egid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(egid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getegid)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(static) pre_type(String)type([]) ident(signals) operator(=) keyword(new) pre_type(String)type([]) operator({)string<delimiter(")content(EXIT)delimiter(")>operator(,) string<delimiter(")content(HUP)delimiter(")>operator(,) string<delimiter(")content(INT)delimiter(")>operator(,) string<delimiter(")content(QUIT)delimiter(")>operator(,) string<delimiter(")content(ILL)delimiter(")>operator(,) string<delimiter(")content(TRAP)delimiter(")>operator(,) - string<delimiter(")content(ABRT)delimiter(")>operator(,) string<delimiter(")content(POLL)delimiter(")>operator(,) string<delimiter(")content(FPE)delimiter(")>operator(,) string<delimiter(")content(KILL)delimiter(")>operator(,) string<delimiter(")content(BUS)delimiter(")>operator(,) string<delimiter(")content(SEGV)delimiter(")>operator(,) string<delimiter(")content(SYS)delimiter(")>operator(,) string<delimiter(")content(PIPE)delimiter(")>operator(,) string<delimiter(")content(ALRM)delimiter(")>operator(,) string<delimiter(")content(TERM)delimiter(")>operator(,) string<delimiter(")content(URG)delimiter(")>operator(,) string<delimiter(")content(STOP)delimiter(")>operator(,) - string<delimiter(")content(TSTP)delimiter(")>operator(,) string<delimiter(")content(CONT)delimiter(")>operator(,) string<delimiter(")content(CHLD)delimiter(")>operator(,) string<delimiter(")content(TTIN)delimiter(")>operator(,) string<delimiter(")content(TTOU)delimiter(")>operator(,) string<delimiter(")content(XCPU)delimiter(")>operator(,) string<delimiter(")content(XFSZ)delimiter(")>operator(,) string<delimiter(")content(VTALRM)delimiter(")>operator(,) string<delimiter(")content(PROF)delimiter(")>operator(,) string<delimiter(")content(USR1)delimiter(")>operator(,) string<delimiter(")content(USR2)delimiter(")>operator(})operator(;) - - directive(private) directive(static) type(int) ident(parseSignalString)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(value)operator(\)) operator({) - type(int) ident(startIndex) operator(=) integer(0)operator(;) - type(boolean) ident(negative) operator(=) ident(value)operator(.)ident(startsWith)operator(()string<delimiter(")content(-)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(negative)operator(\)) ident(startIndex)operator(++)operator(;) - - type(boolean) ident(signalString) operator(=) ident(value)operator(.)ident(startsWith)operator(()string<delimiter(")content(SIG)delimiter(")>operator(,) ident(startIndex)operator(\))operator(;) - - keyword(if) operator(()ident(signalString)operator(\)) ident(startIndex) operator(+=) integer(3)operator(;) - - pre_type(String) ident(signalName) operator(=) ident(value)operator(.)ident(substring)operator(()ident(startIndex)operator(\))operator(;) - - comment(// FIXME: This table will get moved into POSIX library so we can get all actual supported) - comment(// signals. This is a quick fix to support basic signals until that happens.) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(signals)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(signals)operator([)ident(i)operator(])operator(.)ident(equals)operator(()ident(signalName)operator(\))operator(\)) keyword(return) ident(negative) operator(?) operator(-)ident(i) operator(:) ident(i)operator(;) - operator(}) - - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(unsupported name `SIG)delimiter(")> operator(+) ident(signalName) operator(+) string<delimiter(")content(')delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(kill)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(kill)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(2)operator(\)) operator({) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments -- kill(sig, pid...\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(signal)operator(;) - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(signal) operator(=) operator(()type(int)operator(\)) operator(()operator(()ident(RubyFixnum)operator(\)) ident(args)operator([)integer(0)operator(])operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - ident(signal) operator(=) ident(parseSignalString)operator(()ident(runtime)operator(,) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(signal) operator(=) ident(parseSignalString)operator(()ident(runtime)operator(,) ident(args)operator([)integer(0)operator(])operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(signal) operator(=) ident(parseSignalString)operator(()ident(runtime)operator(,) ident(args)operator([)integer(0)operator(])operator(.)ident(checkStringType)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - type(boolean) ident(processGroupKill) operator(=) ident(signal) operator(<) integer(0)operator(;) - - keyword(if) operator(()ident(processGroupKill)operator(\)) ident(signal) operator(=) operator(-)ident(signal)operator(;) - - ident(POSIX) ident(posix) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - type(int) ident(pid) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(;) - - comment(// FIXME: It may be possible to killpg on systems which support it. POSIX library) - comment(// needs to tell whether a particular method works or not) - keyword(if) operator(()ident(pid) operator(==) integer(0)operator(\)) ident(pid) operator(=) ident(runtime)operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpid)operator(()operator(\))operator(;) - ident(posix)operator(.)ident(kill)operator(()ident(processGroupKill) operator(?) operator(-)ident(pid) operator(:) ident(pid)operator(,) ident(signal)operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(args)operator(.)ident(length) operator(-) integer(1)operator(\))operator(;) - - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(detach)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(detach)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - directive(final) type(int) ident(pid) operator(=) operator(()type(int)operator(\))ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(BlockCallback) ident(callback) operator(=) keyword(new) ident(BlockCallback)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(int)type([]) ident(status) operator(=) keyword(new) type(int)operator([)integer(1)operator(])operator(;) - type(int) ident(result) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(waitpid)operator(()ident(pid)operator(,) ident(status)operator(,) integer(0)operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(result)operator(\))operator(;) - operator(}) - operator(})operator(;) - - keyword(return) ident(RubyThread)operator(.)ident(newInstance)operator(() - ident(runtime)operator(.)ident(getThread)operator(()operator(\))operator(,) - ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) - ident(CallBlock)operator(.)ident(newCallClosure)operator(()ident(recv)operator(,) operator(()ident(RubyModule)operator(\))ident(recv)operator(,) ident(Arity)operator(.)ident(NO_ARGUMENTS)operator(,) ident(callback)operator(,) ident(context)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(times)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(times)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(double) ident(currentTime) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(/) float(1000.0)operator(;) - type(double) ident(startTime) operator(=) ident(runtime)operator(.)ident(getStartTime)operator(()operator(\)) operator(/) float(1000.0)operator(;) - ident(RubyFloat) ident(zero) operator(=) ident(runtime)operator(.)ident(newFloat)operator(()float(0.0)operator(\))operator(;) - keyword(return) ident(RubyStruct)operator(.)ident(newStruct)operator(()ident(runtime)operator(.)ident(getTmsStruct)operator(()operator(\))operator(,) - keyword(new) ident(IRubyObject)type([]) operator({) ident(runtime)operator(.)ident(newFloat)operator(()ident(currentTime) operator(-) ident(startTime)operator(\))operator(,) ident(zero)operator(,) ident(zero)operator(,) ident(zero) operator(})operator(,) - ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pid)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(pid)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getPosix)operator(()operator(\))operator(.)ident(getpid)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fork)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(fork)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(fork)operator(()ident(context)operator(,) ident(recv)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exit)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(RubyKernel)operator(.)ident(exit)operator(()ident(recv)operator(,) ident(args)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001 Ed Sinjiashvili <slorcim@users.sourceforge.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.List)operator(;) - -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.BlockCallback)operator(;) -keyword(import) include(org.jruby.runtime.CallBlock)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ObjectMarshal)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) -keyword(import) include(org.jruby.runtime.component.VariableEntry)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) - -comment(/** - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Range)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyRange) directive(extends) ident(RubyObject) operator({) - directive(private) ident(IRubyObject) ident(begin)operator(;) - directive(private) ident(IRubyObject) ident(end)operator(;) - directive(private) type(boolean) ident(isExclusive)operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createRangeClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(result) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Range)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(RANGE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setRange)operator(()ident(result)operator(\))operator(;) - ident(result)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyRange)operator(;) - operator(}) - operator(})operator(;) - - ident(result)operator(.)ident(setMarshal)operator(()ident(RANGE_MARSHAL)operator(\))operator(;) - ident(result)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - - comment(// We override Enumerable#member? since ranges in 1.8.1 are continuous.) - comment(// result.defineMethod("member?", callbackFactory.getMethod("include_p", RubyKernel.IRUBY_OBJECT\)\);) - comment(// result.defineMethod("===", callbackFactory.getMethod("include_p", RubyKernel.IRUBY_OBJECT\)\);) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyRange)operator(.)ident(class)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ObjectAllocator) ident(RANGE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyRange)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(private) ident(RubyRange)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - ident(begin) operator(=) ident(end) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyRange) ident(newRange)operator(()ident(Ruby) ident(runtime)operator(,) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(begin)operator(,) ident(IRubyObject) ident(end)operator(,) type(boolean) ident(isExclusive)operator(\)) operator({) - ident(RubyRange) ident(range) operator(=) keyword(new) ident(RubyRange)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRange)operator(()operator(\))operator(\))operator(;) - ident(range)operator(.)ident(init)operator(()ident(context)operator(,) ident(begin)operator(,) ident(end)operator(,) ident(isExclusive)operator(\))operator(;) - keyword(return) ident(range)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyRange) ident(newExclusiveRange)operator(()ident(Ruby) ident(runtime)operator(,) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(begin)operator(,) ident(IRubyObject) ident(end)operator(\)) operator({) - ident(RubyRange) ident(range) operator(=) keyword(new) ident(RubyRange)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRange)operator(()operator(\))operator(\))operator(;) - ident(range)operator(.)ident(init)operator(()ident(context)operator(,) ident(begin)operator(,) ident(end)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) ident(range)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyRange) ident(newInclusiveRange)operator(()ident(Ruby) ident(runtime)operator(,) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(begin)operator(,) ident(IRubyObject) ident(end)operator(\)) operator({) - ident(RubyRange) ident(range) operator(=) keyword(new) ident(RubyRange)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRange)operator(()operator(\))operator(\))operator(;) - ident(range)operator(.)ident(init)operator(()ident(context)operator(,) ident(begin)operator(,) ident(end)operator(,) pre_constant(false)operator(\))operator(;) - keyword(return) ident(range)operator(;) - operator(}) - - directive(protected) type(void) ident(copySpecialInstanceVariables)operator(()ident(IRubyObject) ident(clone)operator(\)) operator({) - ident(RubyRange) ident(range) operator(=) operator(()ident(RubyRange)operator(\))ident(clone)operator(;) - ident(range)operator(.)ident(begin) operator(=) ident(begin)operator(;) - ident(range)operator(.)ident(end) operator(=) ident(end)operator(;) - ident(range)operator(.)ident(isExclusive) operator(=) ident(isExclusive)operator(;) - operator(}) - - directive(final) type(long)type([]) ident(begLen)operator(()type(long) ident(len)operator(,) type(int) ident(err)operator(\))operator({) - type(long) ident(beg) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()local_variable(this)operator(.)ident(begin)operator(\))operator(;) - type(long) ident(end) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()local_variable(this)operator(.)ident(end)operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(+=) ident(len)operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(err) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()ident(beg) operator(+) string<delimiter(")content(..)delimiter(")> operator(+) operator(()ident(isExclusive) operator(?) string<delimiter(")content(.)delimiter(")> operator(:) string<delimiter(")delimiter(")>operator(\)) operator(+) ident(end) operator(+) string<delimiter(")content( out of range)delimiter(")>operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(err) operator(==) integer(0) operator(||) ident(err) operator(==) integer(2)operator(\)) operator({) - keyword(if) operator(()ident(beg) operator(>) ident(len)operator(\)) operator({) - keyword(if) operator(()ident(err) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()ident(beg) operator(+) string<delimiter(")content(..)delimiter(")> operator(+) operator(()ident(isExclusive) operator(?) string<delimiter(")content(.)delimiter(")> operator(:) string<delimiter(")delimiter(")>operator(\)) operator(+) ident(end) operator(+) string<delimiter(")content( out of range)delimiter(")>operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - keyword(if) operator(()ident(end) operator(>) ident(len)operator(\)) ident(end) operator(=) ident(len)operator(;) - operator(}) - - keyword(if) operator(()ident(end) operator(<) integer(0)operator(\)) ident(end) operator(+=) ident(len)operator(;) - keyword(if) operator(()operator(!)ident(isExclusive)operator(\)) ident(end)operator(++)operator(;) - ident(len) operator(=) ident(end) operator(-) ident(beg)operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) ident(len) operator(=) integer(0)operator(;) - - keyword(return) keyword(new) type(long)type([])operator({)ident(beg)operator(,) ident(len)operator(})operator(;) - operator(}) - - directive(private) type(void) ident(init)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(begin)operator(,) ident(IRubyObject) ident(end)operator(,) type(boolean) ident(isExclusive)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(begin) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(end) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(IRubyObject) ident(result) operator(=) ident(begin)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(end)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(bad value for range)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(RaiseException) ident(re)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(bad value for range)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - local_variable(this)operator(.)ident(begin) operator(=) ident(begin)operator(;) - local_variable(this)operator(.)ident(end) operator(=) ident(end)operator(;) - local_variable(this)operator(.)ident(isExclusive) operator(=) ident(isExclusive)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(init)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator(.)ident(length) operator(>) integer(2) operator(&&) ident(args)operator([)integer(2)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(first)delimiter(")>operator(,) string<delimiter(")content(begin)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(first)operator(()operator(\)) operator({) - keyword(return) ident(begin)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(last)delimiter(")>operator(,) string<delimiter(")content(end)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(last)operator(()operator(\)) operator({) - keyword(return) ident(end)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(hash)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - type(long) ident(hash) operator(=) ident(isExclusive) operator(?) integer(1) operator(:) integer(0)operator(;) - type(long) ident(h) operator(=) ident(hash)operator(;) - - type(long) ident(v) operator(=) ident(begin)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(HASH)operator(,) string<delimiter(")content(hash)delimiter(")>operator(\))operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - ident(hash) operator(^=) ident(v) operator(<)operator(<) integer(1)operator(;) - ident(v) operator(=) ident(end)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(HASH)operator(,) string<delimiter(")content(hash)delimiter(")>operator(\))operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - ident(hash) operator(^=) ident(v) operator(<)operator(<) integer(9)operator(;) - ident(hash) operator(^=) ident(h) operator(<)operator(<) integer(24)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(hash)operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(byte)type([]) ident(DOTDOTDOT) operator(=) string<delimiter(")content(...)delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(;) - directive(private) directive(static) type(byte)type([]) ident(DOTDOT) operator(=) string<delimiter(")content(..)delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(inspect)operator(()ident(context)operator(,) ident(begin)operator(\))operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(str2) operator(=) ident(inspect)operator(()ident(context)operator(,) ident(end)operator(\))operator(;) - - ident(str)operator(.)ident(cat)operator(()ident(isExclusive) operator(?) ident(DOTDOTDOT) operator(:) ident(DOTDOT)operator(\))operator(;) - ident(str)operator(.)ident(concat)operator(()ident(str2)operator(\))operator(;) - ident(str)operator(.)ident(infectBy)operator(()ident(str2)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(begin)operator(\))operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(RubyString) ident(str2) operator(=) ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(end)operator(\))operator(;) - - ident(str)operator(.)ident(cat)operator(()ident(isExclusive) operator(?) ident(DOTDOTDOT) operator(:) ident(DOTDOT)operator(\))operator(;) - ident(str)operator(.)ident(concat)operator(()ident(str2)operator(\))operator(;) - ident(str)operator(.)ident(infectBy)operator(()ident(str2)operator(\))operator(;) - keyword(return) ident(str)operator(;) - - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exclude_end?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(exclude_end_p)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isExclusive)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyRange)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - ident(RubyRange) ident(otherRange) operator(=) operator(()ident(RubyRange)operator(\)) ident(other)operator(;) - - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(begin)operator(,) ident(otherRange)operator(.)ident(begin)operator(\)) operator(&&) - ident(equalInternal)operator(()ident(context)operator(,) ident(end)operator(,) ident(otherRange)operator(.)ident(end)operator(\)) operator(&&) - ident(isExclusive) operator(==) ident(otherRange)operator(.)ident(isExclusive)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyRange)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - ident(RubyRange) ident(otherRange) operator(=) operator(()ident(RubyRange)operator(\))ident(other)operator(;) - - keyword(if) operator(()ident(eqlInternal)operator(()ident(context)operator(,) ident(begin)operator(,) ident(otherRange)operator(.)ident(begin)operator(\)) operator(&&) - ident(eqlInternal)operator(()ident(context)operator(,) ident(end)operator(,) ident(otherRange)operator(.)ident(end)operator(\)) operator(&&) - ident(isExclusive) operator(==) ident(otherRange)operator(.)ident(isExclusive)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(abstract) type(class) class(RangeCallBack) operator({) - directive(abstract) type(void) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(class) class(StepBlockCallBack) directive(extends) ident(RangeCallBack) directive(implements) ident(BlockCallback) operator({) - directive(final) ident(Block) ident(block)operator(;) - ident(IRubyObject) ident(iter)operator(;) - directive(final) ident(IRubyObject) ident(step)operator(;) - - ident(StepBlockCallBack)operator(()ident(Block) ident(block)operator(,) ident(IRubyObject) ident(iter)operator(,) ident(IRubyObject) ident(step)operator(\)) operator({) - local_variable(this)operator(.)ident(block) operator(=) ident(block)operator(;) - local_variable(this)operator(.)ident(iter) operator(=) ident(iter)operator(;) - local_variable(this)operator(.)ident(step) operator(=) ident(step)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(originalBlock)operator(\)) operator({) - ident(call)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - type(void) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(iter) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(iter) operator(=) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(iter)operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(-) integer(1)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(iter) operator(=) ident(iter)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(iter) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(arg)operator(\))operator(;) - ident(iter) operator(=) ident(step)operator(;) - operator(}) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(rangeLt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(a)operator(,) ident(IRubyObject) ident(b)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(a)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(b)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) pre_constant(null)operator(;) - keyword(return) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(a)operator(,) ident(b)operator(\)) operator(<) integer(0) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) pre_constant(null)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(rangeLe)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(a)operator(,) ident(IRubyObject) ident(b)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(a)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(b)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) pre_constant(null)operator(;) - type(int) ident(c) operator(=) ident(RubyComparable)operator(.)ident(cmpint)operator(()ident(context)operator(,) ident(result)operator(,) ident(a)operator(,) ident(b)operator(\))operator(;) - keyword(if) operator(()ident(c) operator(==) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(c) operator(<) integer(0) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) pre_constant(null)operator(;) - operator(}) - - directive(private) type(void) ident(rangeEach)operator(()ident(ThreadContext) ident(context)operator(,) ident(RangeCallBack) ident(callback)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(begin)operator(;) - keyword(if) operator(()ident(isExclusive)operator(\)) operator({) - keyword(while) operator(()ident(rangeLt)operator(()ident(context)operator(,) ident(v)operator(,) ident(end)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(callback)operator(.)ident(call)operator(()ident(context)operator(,) ident(v)operator(\))operator(;) - ident(v) operator(=) ident(v)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(succ)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(c)operator(;) - keyword(while) operator(()operator(()ident(c) operator(=) ident(rangeLe)operator(()ident(context)operator(,) ident(v)operator(,) ident(end)operator(\))operator(\)) operator(!=) pre_constant(null) operator(&&) ident(c)operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(callback)operator(.)ident(call)operator(()ident(context)operator(,) ident(v)operator(\))operator(;) - keyword(if) operator(()ident(c) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\)) keyword(break)operator(;) - ident(v) operator(=) ident(v)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(succ)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) directive(final) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(begin) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(end) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(lim) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(end)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isExclusive)operator(\)) ident(lim)operator(++)operator(;) - - keyword(for) operator(()type(long) ident(i) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(begin)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) ident(i) operator(<) ident(lim)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(begin) keyword(instanceof) ident(RubyString)operator(\)) operator({) - operator(()operator(()ident(RubyString)operator(\)) ident(begin)operator(\))operator(.)ident(upto)operator(()ident(context)operator(,) ident(end)operator(,) ident(isExclusive)operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)ident(begin)operator(.)ident(respondsTo)operator(()string<delimiter(")content(succ)delimiter(")>operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(() - string<delimiter(")content(can't iterate from )delimiter(")> operator(+) ident(begin)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - ident(rangeEach)operator(()ident(context)operator(,) keyword(new) ident(RangeCallBack)operator(()operator(\)) operator({) - annotation(@Override) - type(void) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(arg)operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(step)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(step)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(IRubyObject) ident(step)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(step) operator(=) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(step) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - - type(long) ident(unit) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(step)operator(\))operator(;) - keyword(if) operator(()ident(unit) operator(<) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step can't be negative)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(begin) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(end) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - keyword(if) operator(()ident(unit) operator(==) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step can't be 0)delimiter(")>operator(\))operator(;) - - type(long) ident(e) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(end)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isExclusive)operator(\)) ident(e)operator(++)operator(;) - - keyword(for) operator(()type(long) ident(i) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(begin)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) ident(i) operator(<) ident(e)operator(;) ident(i) operator(+=) ident(unit)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(i)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(begin)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(unit) operator(==) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step can't be 0)delimiter(")>operator(\))operator(;) - comment(// rb_iterate((VALUE(*\)_((VALUE\)\)\)str_step, (VALUE\)args, step_i, (VALUE\)iter\);) - ident(StepBlockCallBack) ident(callback) operator(=) keyword(new) ident(StepBlockCallBack)operator(()ident(block)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(,) ident(step)operator(\))operator(;) - ident(Block) ident(blockCallback) operator(=) ident(CallBlock)operator(.)ident(newCallClosure)operator(()local_variable(this)operator(,) ident(runtime)operator(.)ident(getRange)operator(()operator(\))operator(,) ident(Arity)operator(.)ident(singleArgument)operator(()operator(\))operator(,) ident(callback)operator(,) ident(context)operator(\))operator(;) - operator(()operator(()ident(RubyString)operator(\))ident(tmp)operator(\))operator(.)ident(upto)operator(()ident(context)operator(,) ident(end)operator(,) ident(isExclusive)operator(,) ident(blockCallback)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(begin) keyword(instanceof) ident(RubyNumeric)operator(\)) operator({) - keyword(if) operator(()ident(equalInternal)operator(()ident(context)operator(,) ident(step)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step can't be 0)delimiter(")>operator(\))operator(;) - operator(}) - directive(final) pre_type(String) ident(method)operator(;) - directive(final) type(int) ident(methodIndex)operator(;) - keyword(if) operator(()ident(isExclusive)operator(\)) operator({) - ident(method) operator(=) string<delimiter(")content(<)delimiter(")>operator(;) - ident(methodIndex) operator(=) ident(MethodIndex)operator(.)ident(OP_LT)operator(;) - operator(}) keyword(else) operator({) - ident(method) operator(=) string<delimiter(")content(<=)delimiter(")>operator(;) - ident(methodIndex) operator(=) ident(MethodIndex)operator(.)ident(OP_LE)operator(;) - operator(}) - ident(IRubyObject) ident(beg) operator(=) ident(begin)operator(;) - keyword(while) operator(()ident(beg)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(methodIndex)operator(,) ident(method)operator(,) ident(end)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(beg)operator(\))operator(;) - ident(beg) operator(=) ident(beg)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(step)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(unit) operator(==) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(step can't be 0)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(begin)operator(.)ident(respondsTo)operator(()string<delimiter(")content(succ)delimiter(")>operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(() - string<delimiter(")content(can't iterate from )delimiter(")> operator(+) ident(begin)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - comment(// range_each_func(range, step_i, b, e, args\);) - ident(rangeEach)operator(()ident(context)operator(,) keyword(new) ident(StepBlockCallBack)operator(()ident(block)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(,) ident(step)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(include?)delimiter(")>operator(,) string<delimiter(")content(member?)delimiter(")>operator(,) string<delimiter(")content(===)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(include_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(rangeLe)operator(()ident(context)operator(,) ident(begin)operator(,) ident(obj)operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(isExclusive)operator(\)) operator({) - keyword(if) operator(()ident(rangeLt)operator(()ident(context)operator(,) ident(obj)operator(,) ident(end)operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(rangeLe)operator(()ident(context)operator(,) ident(obj)operator(,) ident(end)operator(\)) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ObjectMarshal) ident(RANGE_MARSHAL) operator(=) keyword(new) ident(ObjectMarshal)operator(()operator(\)) operator({) - directive(public) type(void) ident(marshalTo)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Object) ident(obj)operator(,) ident(RubyClass) ident(type)operator(,) - ident(MarshalStream) ident(marshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyRange) ident(range) operator(=) operator(()ident(RubyRange)operator(\))ident(obj)operator(;) - - ident(marshalStream)operator(.)ident(registerLinkTarget)operator(()ident(range)operator(\))operator(;) - pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(attrs) operator(=) ident(range)operator(.)ident(getVariableList)operator(()operator(\))operator(;) - - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(begin)delimiter(")>operator(,) ident(range)operator(.)ident(begin)operator(\))operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(end)delimiter(")>operator(,) ident(range)operator(.)ident(end)operator(\))operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(excl)delimiter(")>operator(,) ident(range)operator(.)ident(isExclusive) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(\))operator(\))operator(;) - - ident(marshalStream)operator(.)ident(dumpVariables)operator(()ident(attrs)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(unmarshalFrom)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(,) - ident(UnmarshalStream) ident(unmarshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyRange) ident(range) operator(=) operator(()ident(RubyRange)operator(\))ident(type)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(registerLinkTarget)operator(()ident(range)operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(defaultVariablesUnmarshal)operator(()ident(range)operator(\))operator(;) - - ident(range)operator(.)ident(begin) operator(=) ident(range)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(begin)delimiter(")>operator(\))operator(;) - ident(range)operator(.)ident(end) operator(=) ident(range)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(end)delimiter(")>operator(\))operator(;) - ident(range)operator(.)ident(isExclusive) operator(=) ident(range)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(excl)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - - keyword(return) ident(range)operator(;) - operator(}) - operator(})operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.util.Numeric.f_add)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_cmp)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_div)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_equal_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_expt)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_floor)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_gcd)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_idiv)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_mul)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_negate)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_negative_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_one_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_rshift)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_sub)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_f)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_i)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_r)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_to_s)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_truncate)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_xor)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.f_zero_p)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.i_gcd)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.i_ilog2)operator(;) -keyword(import) include(static) include(org.jruby.util.Numeric.ldexp)operator(;) - -keyword(import) include(org.joni.encoding.specific.ASCIIEncoding)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.Numeric)operator(;) - -comment(/** - * 1.9 rational.c as of revision: 18876 - */) - -annotation(@JRubyClass)operator(()ident(name) operator(=) string<delimiter(")content(Rational)delimiter(")>operator(,) ident(parent) operator(=) string<delimiter(")content(Numeric)delimiter(")>operator(,) ident(include) operator(=) string<delimiter(")content(Precision)delimiter(")>operator(\)) -directive(public) type(class) class(RubyRational) directive(extends) ident(RubyNumeric) operator({) - - directive(public) directive(static) ident(RubyClass) ident(createRationalClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(rationalc) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Rational)delimiter(")>operator(,) ident(runtime)operator(.)ident(getNumeric)operator(()operator(\))operator(,) ident(RATIONAL_ALLOCATOR)operator(\))operator(;) comment(// because one can Complex.send(:allocate\)) - ident(runtime)operator(.)ident(setRational)operator(()ident(rationalc)operator(\))operator(;) - - ident(rationalc)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(RATIONAL)operator(;) - ident(rationalc)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyRational)operator(;) - operator(}) - operator(})operator(;) - - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(rationalc)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(private_class_method)delimiter(")>operator(,) ident(runtime)operator(.)ident(newSymbol)operator(()string<delimiter(")content(allocate)delimiter(")>operator(\))operator(\))operator(;) - - ident(rationalc)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyRational)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(rationalc)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(RATIONAL_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(})operator(;) - - comment(/** internal - * - */) - directive(private) ident(RubyRational)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(num)operator(,) ident(IRubyObject) ident(den)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\))ident(clazz)operator(\))operator(;) - local_variable(this)operator(.)ident(num) operator(=) ident(num)operator(;) - local_variable(this)operator(.)ident(den) operator(=) ident(den)operator(;) - operator(}) - - comment(/** rb_rational_raw - * - */) - directive(static) ident(RubyRational) ident(newRationalRaw)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(x)operator(,) ident(RubyObject) ident(y)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRational)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** rb_rational_raw1 - * - */) - directive(static) ident(RubyRational) ident(newRationalRaw)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRational)operator(()operator(\))operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_rational_new1 - * - */) - directive(static) ident(IRubyObject) ident(newRationalCanonicalize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newRationalCanonicalize)operator(()ident(context)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_rational_new - * - */) - directive(private) directive(static) ident(IRubyObject) ident(newRationalCanonicalize)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRational)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_rational_new2 - * - */) - directive(private) directive(static) ident(IRubyObject) ident(newRational)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyRational) operator(&&) ident(y) keyword(instanceof) ident(RubyRational)operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_rational_new1 - * - */) - directive(private) directive(static) ident(IRubyObject) ident(newRational)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyRational)operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** f_rational_new_no_reduce2 - * - */) - directive(private) directive(static) ident(IRubyObject) ident(newRationalNoReduce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyRational) operator(&&) ident(y) keyword(instanceof) ident(RubyRational)operator(;) - keyword(return) ident(canonicalizeInternalNoReduce)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_rational_new_no_reduce1 - * - */) - directive(private) directive(static) ident(IRubyObject) ident(newRationalNoReduce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(assert) ident(x) keyword(instanceof) ident(RubyRational)operator(;) - keyword(return) ident(canonicalizeInternalNoReduce)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** f_rational_new_bang2 - * - */) - directive(private) directive(static) ident(RubyRational) ident(newRationalBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(assert) operator(!)ident(f_negative_p)operator(()ident(context)operator(,) ident(y)operator(\)) operator(&&) operator(!)operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(y)operator(\))operator(\))operator(;) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - comment(/** f_rational_new_bang1 - * - */) - directive(private) directive(static) ident(RubyRational) ident(newRationalBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newRationalBang)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(num)operator(;) - directive(private) ident(IRubyObject) ident(den)operator(;) - - comment(/** nurat_s_new_bang - * - */) - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) keyword(return) ident(newInstanceBang)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(newInstanceBang)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new!)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(num)operator(\)) operator({) - keyword(return) ident(newInstanceBang)operator(()ident(context)operator(,) ident(recv)operator(,) ident(num)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new!)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstanceBang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(num)operator(,) ident(IRubyObject) ident(den)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(num) keyword(instanceof) ident(RubyInteger)operator(\))operator(\)) ident(num) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(den) keyword(instanceof) ident(RubyInteger)operator(\))operator(\)) ident(den) operator(=) ident(f_to_i)operator(()ident(context)operator(,) ident(den)operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(res) operator(=) ident(f_cmp)operator(()ident(context)operator(,) ident(den)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(\)) operator({) - ident(num) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - ident(den) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(den)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - keyword(return) keyword(new) ident(RubyRational)operator(()ident(runtime)operator(,) ident(recv)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_int_check - * - */) - directive(private) directive(static) type(void) ident(intCheck)operator(()ident(IRubyObject) ident(num)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(num) keyword(instanceof) ident(RubyFixnum) operator(\)) operator(&&) operator(!)operator(()ident(num) keyword(instanceof) ident(RubyBignum)operator(\))operator(\)) keyword(throw) ident(num)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(not an integer)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** nurat_s_canonicalize_internal - * - */) - directive(private) directive(static) ident(IRubyObject) ident(canonicalizeInternal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(num)operator(,) ident(IRubyObject) ident(den)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(res) operator(=) ident(f_cmp)operator(()ident(context)operator(,) ident(den)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(\)) operator({) - ident(num) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - ident(den) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(den)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(gcd) operator(=) ident(f_gcd)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - ident(num) operator(=) ident(f_idiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(gcd)operator(\))operator(;) - ident(den) operator(=) ident(f_idiv)operator(()ident(context)operator(,) ident(den)operator(,) ident(gcd)operator(\))operator(;) - - keyword(if) operator(()ident(f_one_p)operator(()ident(context)operator(,) ident(den)operator(\)) operator(&&) operator(()operator(()ident(RubyModule)operator(\))ident(clazz)operator(\))operator(.)ident(fastHasConstant)operator(()string<delimiter(")content(Unify)delimiter(")>operator(\))operator(\)) keyword(return) ident(num)operator(;) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_s_canonicalize_internal_no_reduce - * - */) - directive(private) directive(static) ident(IRubyObject) ident(canonicalizeInternalNoReduce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(num)operator(,) ident(IRubyObject) ident(den)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(res) operator(=) ident(f_cmp)operator(()ident(context)operator(,) ident(den)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(\)) operator({) - ident(num) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - ident(den) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(den)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(f_equal_p)operator(()ident(context)operator(,) ident(den)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\)) operator(&&) operator(()operator(()ident(RubyModule)operator(\))ident(clazz)operator(\))operator(.)ident(fastHasConstant)operator(()string<delimiter(")content(Unify)delimiter(")>operator(\))operator(\)) keyword(return) ident(num)operator(;) - keyword(return) keyword(new) ident(RubyRational)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(clazz)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_s_new - * - */) - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) keyword(return) ident(newInstance)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(newInstance)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(num)operator(\)) operator({) - ident(intCheck)operator(()ident(num)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(num)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject) ident(num)operator(,) ident(IRubyObject) ident(den)operator(\)) operator({) - ident(intCheck)operator(()ident(num)operator(\))operator(;) - ident(intCheck)operator(()ident(den)operator(\))operator(;) - keyword(return) ident(canonicalizeInternal)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** rb_Rational1 - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newRationalConvert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(\)) operator({) - keyword(return) ident(newRationalConvert)operator(()ident(context)operator(,) ident(x)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_Rational/rb_Rational2 - * - */) - directive(public) directive(static) ident(IRubyObject) ident(newRationalConvert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(x)operator(,) ident(IRubyObject) ident(y)operator(\)) operator({) - keyword(return) ident(convert)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRational)operator(()operator(\))operator(,) ident(x)operator(,) ident(y)operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(clazz)operator(,) ident(IRubyObject)type([])ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(\))operator(;) - keyword(case) integer(1)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) keyword(return) ident(convert)operator(()ident(context)operator(,) ident(clazz)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(/** nurat_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(IRubyObject) ident(nil) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(nil)operator(,) ident(nil)operator(\))operator(;) - operator(}) - - comment(/** nurat_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(\)) operator({) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_s_convert - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(convert)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(convert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(,) ident(IRubyObject) ident(a2)operator(\)) operator({) - keyword(return) ident(convertCommon)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(convertCommon)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(a1)operator(,) ident(IRubyObject) ident(a2)operator(\)) operator({) - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(a1Complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(a1)operator(;) - keyword(if) operator(()ident(a1Complex)operator(.)ident(getImage)operator(()operator(\)) keyword(instanceof) ident(RubyFloat) operator(||) operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(a1Complex)operator(.)ident(getImage)operator(()operator(\))operator(\))operator(\)) operator({) - ident(IRubyObject) ident(s) operator(=) ident(f_to_s)operator(()ident(context)operator(,) ident(a1)operator(\))operator(;) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't accept )delimiter(")> operator(+) ident(s)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(a1) operator(=) ident(a1Complex)operator(.)ident(getReal)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyComplex)operator(\)) operator({) - ident(RubyComplex) ident(a2Complex) operator(=) operator(()ident(RubyComplex)operator(\))ident(a2)operator(;) - keyword(if) operator(()ident(a2Complex)operator(.)ident(getImage)operator(()operator(\)) keyword(instanceof) ident(RubyFloat) operator(||) operator(!)ident(f_zero_p)operator(()ident(context)operator(,) ident(a2Complex)operator(.)ident(getImage)operator(()operator(\))operator(\))operator(\)) operator({) - ident(IRubyObject) ident(s) operator(=) ident(f_to_s)operator(()ident(context)operator(,) ident(a2)operator(\))operator(;) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(can't accept )delimiter(")> operator(+) ident(s)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(a2) operator(=) ident(a2Complex)operator(.)ident(getReal)operator(()operator(\))operator(;) - operator(}) - - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backref) operator(=) ident(frame)operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backref) operator(!=) pre_constant(null) operator(&&) ident(backref) keyword(instanceof) ident(RubyMatchData)operator(\)) operator(()operator(()ident(RubyMatchData)operator(\))ident(backref)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(a1) operator(=) ident(f_to_r)operator(()ident(context)operator(,) ident(a1)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(a1) operator(=) ident(str_to_r_strict)operator(()ident(context)operator(,) ident(a1)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - ident(a2) operator(=) ident(f_to_r)operator(()ident(context)operator(,) ident(a2)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(a2) operator(=) ident(str_to_r_strict)operator(()ident(context)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - ident(frame)operator(.)ident(setBackRef)operator(()ident(backref)operator(\))operator(;) - - keyword(if) operator(()ident(a1) keyword(instanceof) ident(RubyRational)operator(\)) operator({) - keyword(if) operator(()ident(a2)operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(f_zero_p)operator(()ident(context)operator(,) ident(a2)operator(\))operator(\)) keyword(return) ident(a1)operator(;) - keyword(return) ident(f_div)operator(()ident(context)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(a2) keyword(instanceof) ident(RubyRational)operator(\)) operator({) - keyword(return) ident(f_div)operator(()ident(context)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - keyword(return) ident(a2)operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(\)) operator(:) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(,) ident(a1)operator(,) ident(a2)operator(\))operator(;) - operator(}) - - comment(/** nurat_s_induced_from - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(induced_from)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(induced_from)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(f_to_r)operator(()ident(context)operator(,) ident(arg)operator(\))operator(;) - operator(}) - - comment(/** nurat_numerator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(numerator)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(numerator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(num)operator(;) - operator(}) - - comment(/** nurat_denominator - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(denominator)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(denominator)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(den)operator(;) - operator(}) - - comment(/** f_imul - * - */) - directive(private) directive(static) ident(IRubyObject) ident(f_imul)operator(()ident(ThreadContext) ident(context)operator(,) type(long) ident(a)operator(,) type(long) ident(b)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(a) operator(==) integer(0) operator(||) ident(b) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(a) operator(==) integer(1)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(b)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(b) operator(==) integer(1)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(a)operator(\))operator(;) - operator(}) - - type(long) ident(c) operator(=) ident(a) operator(*) ident(b)operator(;) - keyword(if)operator(()ident(c) operator(/) ident(a) operator(!=) ident(b)operator(\)) operator({) - keyword(return) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(runtime)operator(,) ident(a)operator(\))operator(.)ident(op_mul)operator(()ident(context)operator(,) ident(RubyBignum)operator(.)ident(newBignum)operator(()ident(runtime)operator(,) ident(b)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(c)operator(\))operator(;) - operator(}) - - comment(/** f_addsub - * - */) - directive(private) ident(IRubyObject) ident(f_addsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(anum)operator(,) ident(IRubyObject) ident(aden)operator(,) ident(IRubyObject) ident(bnum)operator(,) ident(IRubyObject) ident(bden)operator(,) type(boolean) ident(plus)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(num)operator(,) ident(den)operator(,) ident(g)operator(,) ident(a)operator(,) ident(b)operator(;) - keyword(if) operator(()ident(anum) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(aden) keyword(instanceof) ident(RubyFixnum) operator(&&) - ident(bnum) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(bden) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(an) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(anum)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(ad) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(aden)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(bn) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(bnum)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(bd) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(bden)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(ig) operator(=) ident(i_gcd)operator(()ident(ad)operator(,) ident(bd)operator(\))operator(;) - - ident(g) operator(=) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(ig)operator(\))operator(;) - ident(a) operator(=) ident(f_imul)operator(()ident(context)operator(,) ident(an)operator(,) ident(bd) operator(/) ident(ig)operator(\))operator(;) - ident(b) operator(=) ident(f_imul)operator(()ident(context)operator(,) ident(bn)operator(,) ident(ad) operator(/) ident(ig)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(g) operator(=) ident(f_gcd)operator(()ident(context)operator(,) ident(aden)operator(,) ident(bden)operator(\))operator(;) - ident(a) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(anum)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(bden)operator(,) ident(g)operator(\))operator(\))operator(;) - ident(b) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(bnum)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(aden)operator(,) ident(g)operator(\))operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(c) operator(=) ident(plus) operator(?) ident(f_add)operator(()ident(context)operator(,) ident(a)operator(,) ident(b)operator(\)) operator(:) ident(f_sub)operator(()ident(context)operator(,) ident(a)operator(,) ident(b)operator(\))operator(;) - - ident(b) operator(=) ident(f_idiv)operator(()ident(context)operator(,) ident(aden)operator(,) ident(g)operator(\))operator(;) - ident(g) operator(=) ident(f_gcd)operator(()ident(context)operator(,) ident(c)operator(,) ident(g)operator(\))operator(;) - ident(num) operator(=) ident(f_idiv)operator(()ident(context)operator(,) ident(c)operator(,) ident(g)operator(\))operator(;) - ident(a) operator(=) ident(f_idiv)operator(()ident(context)operator(,) ident(bden)operator(,) ident(g)operator(\))operator(;) - ident(den) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(a)operator(,) ident(b)operator(\))operator(;) - - keyword(return) ident(RubyRational)operator(.)ident(newRationalNoReduce)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_add - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_add)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(return) ident(f_addsub)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) pre_constant(true)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_add)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(return) ident(f_addsub)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(otherRational)operator(.)ident(num)operator(,) ident(otherRational)operator(.)ident(den)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nurat_sub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(return) ident(f_addsub)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) pre_constant(false)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_sub)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(return) ident(f_addsub)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(otherRational)operator(.)ident(num)operator(,) ident(otherRational)operator(.)ident(den)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** f_muldiv - * - */) - directive(private) ident(IRubyObject) ident(f_muldiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(anum)operator(,) ident(IRubyObject) ident(aden)operator(,) ident(IRubyObject) ident(bnum)operator(,) ident(IRubyObject) ident(bden)operator(,) type(boolean) ident(mult)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(mult)operator(\)) operator({) - keyword(if) operator(()ident(f_negative_p)operator(()ident(context)operator(,) ident(bnum)operator(\))operator(\)) operator({) - ident(anum) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(anum)operator(\))operator(;) - ident(bnum) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(bnum)operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(tmp) operator(=) ident(bnum)operator(;) - ident(bnum) operator(=) ident(bden)operator(;) - ident(bden) operator(=) ident(tmp)operator(;) - operator(}) - - directive(final) ident(IRubyObject) ident(num)operator(,) ident(den)operator(;) - keyword(if) operator(()ident(anum) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(aden) keyword(instanceof) ident(RubyFixnum) operator(&&) - ident(bnum) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(bden) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(an) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(anum)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(ad) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(aden)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(bn) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(bnum)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(bd) operator(=) operator(()operator(()ident(RubyFixnum)operator(\))ident(bden)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - type(long) ident(g1) operator(=) ident(i_gcd)operator(()ident(an)operator(,) ident(bd)operator(\))operator(;) - type(long) ident(g2) operator(=) ident(i_gcd)operator(()ident(ad)operator(,) ident(bn)operator(\))operator(;) - - ident(num) operator(=) ident(f_imul)operator(()ident(context)operator(,) ident(an) operator(/) ident(g1)operator(,) ident(bn) operator(/) ident(g2)operator(\))operator(;) - ident(den) operator(=) ident(f_imul)operator(()ident(context)operator(,) ident(ad) operator(/) ident(g2)operator(,) ident(bd) operator(/) ident(g1)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(g1) operator(=) ident(f_gcd)operator(()ident(context)operator(,) ident(anum)operator(,) ident(bden)operator(\))operator(;) - ident(IRubyObject) ident(g2) operator(=) ident(f_gcd)operator(()ident(context)operator(,) ident(aden)operator(,) ident(bnum)operator(\))operator(;) - - ident(num) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(anum)operator(,) ident(g1)operator(\))operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(bnum)operator(,) ident(g2)operator(\))operator(\))operator(;) - ident(den) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(aden)operator(,) ident(g2)operator(\))operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(bden)operator(,) ident(g1)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RubyRational)operator(.)ident(newRationalNoReduce)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - - operator(}) - - comment(/** nurat_mul - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(return) ident(f_muldiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) pre_constant(true)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_mul)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(return) ident(f_muldiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(otherRational)operator(.)ident(num)operator(,) ident(otherRational)operator(.)ident(den)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(*)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nurat_div - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(/)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_div)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - keyword(return) ident(f_muldiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(,) pre_constant(false)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(return) ident(f_muldiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(,) ident(otherRational)operator(.)ident(num)operator(,) ident(otherRational)operator(.)ident(den)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(/)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nurat_fdiv - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fdiv)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_fdiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(f_div)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nurat_expt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(**)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_expt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(other)operator(\))operator(\)) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyRational)operator(\)) operator({) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(f_one_p)operator(()ident(context)operator(,) ident(otherRational)operator(.)ident(den)operator(\))operator(\)) ident(other) operator(=) ident(otherRational)operator(.)ident(num)operator(;) - operator(}) - - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - directive(final) ident(IRubyObject) ident(tnum)operator(,) ident(tden)operator(;) - ident(IRubyObject) ident(res) operator(=) ident(f_cmp)operator(()ident(context)operator(,) ident(other)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\)) operator({) - ident(tnum) operator(=) ident(f_expt)operator(()ident(context)operator(,) ident(num)operator(,) ident(other)operator(\))operator(;) - ident(tden) operator(=) ident(f_expt)operator(()ident(context)operator(,) ident(den)operator(,) ident(other)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(res) operator(==) ident(RubyFixnum)operator(.)ident(minus_one)operator(()ident(runtime)operator(\))operator(\))operator({) - ident(tnum) operator(=) ident(f_expt)operator(()ident(context)operator(,) ident(den)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(;) - ident(tden) operator(=) ident(f_expt)operator(()ident(context)operator(,) ident(num)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(tnum) operator(=) ident(tden) operator(=) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyRational)operator(.)ident(newRational)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(tnum)operator(,) ident(tden)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - keyword(return) ident(f_expt)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(**)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - - comment(/** nurat_cmp - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(if) operator(()ident(den) keyword(instanceof) ident(RubyFixnum) operator(&&) operator(()operator(()ident(RubyFixnum)operator(\))ident(den)operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(==) integer(1)operator(\)) keyword(return) ident(f_cmp)operator(()ident(context)operator(,) ident(num)operator(,) ident(other)operator(\))operator(;) - keyword(return) ident(f_cmp)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(RubyRational)operator(.)ident(newRationalBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(other)operator(\))operator(\))operator(;) - - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_cmp)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\))operator(;) - - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - directive(final) ident(IRubyObject) ident(num1)operator(,) ident(num2)operator(;) - keyword(if) operator(()ident(num) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(den) keyword(instanceof) ident(RubyFixnum) operator(&&) - ident(otherRational)operator(.)ident(num) keyword(instanceof) ident(RubyFixnum) operator(&&) ident(otherRational)operator(.)ident(den) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(num1) operator(=) ident(f_imul)operator(()ident(context)operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(num)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(otherRational)operator(.)ident(den)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - ident(num2) operator(=) ident(f_imul)operator(()ident(context)operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(otherRational)operator(.)ident(num)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(,) operator(()operator(()ident(RubyFixnum)operator(\))ident(den)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(num1) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(num)operator(,) ident(otherRational)operator(.)ident(den)operator(\))operator(;) - ident(num2) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(otherRational)operator(.)ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - keyword(return) ident(f_cmp)operator(()ident(context)operator(,) ident(f_sub)operator(()ident(context)operator(,) ident(num1)operator(,) ident(num2)operator(\))operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(coerceBin)operator(()ident(context)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** nurat_equal_p - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(num)operator(\)) operator(&&) ident(f_zero_p)operator(()ident(context)operator(,) ident(den)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(den) keyword(instanceof) ident(RubyFixnum)operator(\)) operator(||) operator(()operator(()ident(RubyFixnum)operator(\))ident(den)operator(\))operator(.)ident(getLongValue)operator(()operator(\)) operator(!=) integer(1)operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(if) operator(()ident(f_equal_p)operator(()ident(context)operator(,) ident(num)operator(,) ident(other)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(f_equal_p)operator(()ident(context)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(,) ident(other)operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - - keyword(case) ident(ClassIndex)operator(.)ident(RATIONAL)operator(:) - ident(RubyRational) ident(otherRational) operator(=) operator(()ident(RubyRational)operator(\))ident(other)operator(;) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(num)operator(\)) operator(&&) ident(f_zero_p)operator(()ident(context)operator(,) ident(otherRational)operator(.)ident(num)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(f_equal_p)operator(()ident(context)operator(,) ident(num)operator(,) ident(otherRational)operator(.)ident(num)operator(\)) operator(&&) ident(f_equal_p)operator(()ident(context)operator(,) ident(den)operator(,) ident(otherRational)operator(.)ident(den)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(f_equal_p)operator(()ident(context)operator(,) ident(other)operator(,) local_variable(this)operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** nurat_coerce - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(coerce)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_coerce)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(switch) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(index)operator(\)) operator({) - keyword(case) ident(ClassIndex)operator(.)ident(FIXNUM)operator(:) - keyword(case) ident(ClassIndex)operator(.)ident(BIGNUM)operator(:) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(RubyRational)operator(.)ident(newRationalBang)operator(()ident(context)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(other)operator(\))operator(,) local_variable(this)operator(\))operator(;) - keyword(case) ident(ClassIndex)operator(.)ident(FLOAT)operator(:) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(other)operator(,) ident(f_to_f)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(\))operator(;) - operator(}) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( can't be coerced into )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_idiv - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(div)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_idiv)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(f_floor)operator(()ident(context)operator(,) ident(f_div)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_mod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(modulo)delimiter(")>operator(,) string<delimiter(")content(%)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(op_mod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(f_floor)operator(()ident(context)operator(,) ident(f_div)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - keyword(return) ident(f_sub)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(other)operator(,) ident(val)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_divmod - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(divmod)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_divmod)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(f_floor)operator(()ident(context)operator(,) ident(f_div)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(val)operator(,) ident(f_sub)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(other)operator(,) ident(val)operator(\))operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_rem - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(remainder)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_rem)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(f_truncate)operator(()ident(context)operator(,) ident(f_div)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - keyword(return) ident(f_sub)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(other)operator(,) ident(val)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_abs - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abs)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_abs)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(f_negative_p)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(f_negate)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** nurat_floor - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(floor)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_floor)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_idiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_ceil - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ceil)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_ceil)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_negate)operator(()ident(context)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(,) ident(den)operator(\))operator(\))operator(;) - operator(}) - - comment(/** nurat_truncate - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(truncate)delimiter(")>operator(,) string<delimiter(")content(to_i)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(op_truncate)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(f_negative_p)operator(()ident(context)operator(,) ident(num)operator(\))operator(\)) operator({) - keyword(return) ident(f_negate)operator(()ident(context)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(,) ident(den)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(f_idiv)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_round - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(round)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_round)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(IRubyObject) ident(two) operator(=) ident(RubyFixnum)operator(.)ident(two)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(f_negative_p)operator(()ident(context)operator(,) ident(num)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(tnum) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - ident(tnum) operator(=) ident(f_add)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(tnum)operator(,) ident(two)operator(\))operator(,) ident(den)operator(\))operator(;) - ident(IRubyObject) ident(tden) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(den)operator(,) ident(two)operator(\))operator(;) - keyword(return) ident(f_negate)operator(()ident(context)operator(,) ident(f_idiv)operator(()ident(context)operator(,) ident(tnum)operator(,) ident(tden)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(tnum) operator(=) ident(f_add)operator(()ident(context)operator(,) ident(f_mul)operator(()ident(context)operator(,) ident(num)operator(,) ident(two)operator(\))operator(,) ident(den)operator(\))operator(;) - ident(IRubyObject) ident(tden) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(den)operator(,) ident(two)operator(\))operator(;) - keyword(return) ident(f_idiv)operator(()ident(context)operator(,) ident(tnum)operator(,) ident(tden)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** nurat_to_f - * - */) - directive(private) directive(static) type(long) ident(ML) operator(=) operator(()type(long)operator(\))operator(()pre_type(Math)operator(.)ident(log)operator(()pre_type(Double)operator(.)ident(MAX_VALUE)operator(\)) operator(/) pre_type(Math)operator(.)ident(log)operator(()float(2.0)operator(\)) operator(-) integer(1)operator(\))operator(;) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(num)operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(newFloat)operator(()integer(0)operator(\))operator(;) - - ident(IRubyObject) ident(num) operator(=) local_variable(this)operator(.)ident(num)operator(;) - ident(IRubyObject) ident(den) operator(=) local_variable(this)operator(.)ident(den)operator(;) - - type(boolean) ident(minus) operator(=) pre_constant(false)operator(;) - keyword(if) operator(()ident(f_negative_p)operator(()ident(context)operator(,) ident(num)operator(\))operator(\)) operator({) - ident(num) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - ident(minus) operator(=) pre_constant(true)operator(;) - operator(}) - - type(long) ident(nl) operator(=) ident(i_ilog2)operator(()ident(context)operator(,) ident(num)operator(\))operator(;) - type(long) ident(dl) operator(=) ident(i_ilog2)operator(()ident(context)operator(,) ident(den)operator(\))operator(;) - - type(long) ident(ne) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(nl) operator(>) ident(ML)operator(\)) operator({) - ident(ne) operator(=) ident(nl) operator(-) ident(ML)operator(;) - ident(num) operator(=) ident(f_rshift)operator(()ident(context)operator(,) ident(num)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(ne)operator(\))operator(\))operator(;) - operator(}) - - type(long) ident(de) operator(=) integer(0)operator(;) - keyword(if) operator(()ident(dl) operator(>) ident(ML)operator(\)) operator({) - ident(de) operator(=) ident(dl) operator(-) ident(ML)operator(;) - ident(den) operator(=) ident(f_rshift)operator(()ident(context)operator(,) ident(den)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(de)operator(\))operator(\))operator(;) - operator(}) - - type(long) ident(e) operator(=) ident(ne) operator(-) ident(de)operator(;) - - keyword(if) operator(()ident(e) operator(>) integer(1023) operator(||) ident(e) operator(<) operator(-)integer(1022)operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(IRubyWarnings)operator(.)ident(ID)operator(.)ident(FLOAT_OUT_OF_RANGE)operator(,) string<delimiter(")content(out of Float range)delimiter(")>operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newFloat)operator(()ident(e) operator(>) integer(0) operator(?) pre_type(Double)operator(.)ident(MAX_VALUE) operator(:) integer(0)operator(\))operator(;) - operator(}) - - type(double) ident(f) operator(=) ident(RubyNumeric)operator(.)ident(num2dbl)operator(()ident(num)operator(\)) operator(/) ident(RubyNumeric)operator(.)ident(num2dbl)operator(()ident(den)operator(\))operator(;) - - keyword(if) operator(()ident(minus)operator(\)) operator({) - ident(f) operator(=) operator(-)ident(f)operator(;) - ident(f) operator(=) ident(ldexp)operator(()ident(f)operator(,) ident(e)operator(\))operator(;) - operator(}) - - keyword(if) operator(()pre_type(Double)operator(.)ident(isInfinite)operator(()ident(f)operator(\)) operator(||) pre_type(Double)operator(.)ident(isNaN)operator(()ident(f)operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(IRubyWarnings)operator(.)ident(ID)operator(.)ident(FLOAT_OUT_OF_RANGE)operator(,) string<delimiter(")content(out of Float range)delimiter(")>operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFloat)operator(()ident(f)operator(\))operator(;) - operator(}) - - comment(/** nurat_to_r - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** nurat_to_r - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(hash)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(f_xor)operator(()ident(context)operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_to_s - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_s)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getKernel)operator(()operator(\))operator(,) string<delimiter(")content(format)delimiter(")>operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(%d/%d)delimiter(")>operator(\))operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getKernel)operator(()operator(\))operator(,) string<delimiter(")content(format)delimiter(")>operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content((%d/%d\))delimiter(")>operator(\))operator(,) ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_marshal_dump - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(marshal_dump)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(marshal_dump)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(num)operator(,) ident(den)operator(\))operator(;) - operator(}) - - comment(/** nurat_marshal_load - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(marshal_load)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(marshal_load)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(arg)operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(num) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(>) integer(0) operator(?) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(den) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(>) integer(1) operator(?) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(f_zero_p)operator(()ident(context)operator(,) ident(den)operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newZeroDivisionError)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_gcd - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gcd)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(gcd)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(intCheck)operator(()ident(other)operator(\))operator(;) - keyword(return) ident(f_gcd)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_lcm - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lcm)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(lcm)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(intCheck)operator(()ident(other)operator(\))operator(;) - keyword(return) ident(Numeric)operator(.)ident(f_lcm)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_gcdlcm - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gcdlcm)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(gcdlcm)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(intCheck)operator(()ident(other)operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(f_gcd)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(,) ident(Numeric)operator(.)ident(f_lcm)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(\))operator(;) - operator(}) - - - directive(static) ident(RubyArray) ident(str_to_r_internal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(strip)delimiter(")>operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(ByteList) ident(bytes) operator(=) ident(s)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(bytes)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(recv)operator(\))operator(;) - - ident(IRubyObject) ident(m) operator(=) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(RationalPatterns)operator(.)ident(rat_pat)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(match)delimiter(")>operator(,) ident(s)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(m)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(si) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(one)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(nu) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(two)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(de) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(three)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(IRubyObject) ident(re) operator(=) ident(m)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(post_match)delimiter(")>operator(\))operator(;) - - ident(RubyArray) ident(a) operator(=) ident(nu)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(split)delimiter(")>operator(,) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(RationalPatterns)operator(.)ident(an_e_pat)operator(\))operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(ifp) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - ident(IRubyObject) ident(exp) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(!=) integer(2) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(;) - - ident(a) operator(=) ident(ifp)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(split)delimiter(")>operator(,) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(RationalPatterns)operator(.)ident(a_dot_pat)operator(\))operator(\))operator(.)ident(convertToArray)operator(()operator(\))operator(;) - ident(IRubyObject) ident(ip) operator(=) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - ident(IRubyObject) ident(fp) operator(=) ident(a)operator(.)ident(size)operator(()operator(\)) operator(!=) integer(2) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(;) - - ident(IRubyObject) ident(v) operator(=) ident(RubyRational)operator(.)ident(newRationalCanonicalize)operator(()ident(context)operator(,) ident(f_to_i)operator(()ident(context)operator(,) ident(ip)operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(fp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(bytes) operator(=) ident(fp)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - type(int) ident(count) operator(=) integer(0)operator(;) - type(byte)type([])ident(buf) operator(=) ident(bytes)operator(.)ident(bytes)operator(;) - type(int) ident(i) operator(=) ident(bytes)operator(.)ident(begin)operator(;) - type(int) ident(end) operator(=) ident(i) operator(+) ident(bytes)operator(.)ident(realSize)operator(;) - keyword(while) operator(()ident(i) operator(<) ident(end)operator(\)) keyword(if) operator(()ident(ASCIIEncoding)operator(.)ident(INSTANCE)operator(.)ident(isDigit)operator(()ident(buf)operator([)ident(i)operator(++)operator(])operator(\))operator(\)) ident(count)operator(++)operator(;) - ident(IRubyObject) ident(l) operator(=) ident(f_expt)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(10)operator(\))operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) ident(count)operator(\))operator(\))operator(;) - ident(v) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(v)operator(,) ident(l)operator(\))operator(;) - ident(v) operator(=) ident(f_add)operator(()ident(context)operator(,) ident(v)operator(,) ident(f_to_i)operator(()ident(context)operator(,) ident(fp)operator(\))operator(\))operator(;) - ident(v) operator(=) ident(f_div)operator(()ident(context)operator(,) ident(v)operator(,) ident(l)operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(exp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(v) operator(=) ident(f_mul)operator(()ident(context)operator(,) ident(v)operator(,) ident(f_expt)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(runtime)operator(,) integer(10)operator(\))operator(,) ident(f_to_i)operator(()ident(context)operator(,) ident(exp)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(si)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(bytes) operator(=) ident(si)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(bytes)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(&&) ident(bytes)operator(.)ident(get)operator(()integer(0)operator(\)) operator(==) string<delimiter(')content(-)delimiter(')>operator(\)) ident(v) operator(=) ident(f_negate)operator(()ident(context)operator(,) ident(v)operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(de)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(v) operator(=) ident(f_div)operator(()ident(context)operator(,) ident(v)operator(,) ident(f_to_i)operator(()ident(context)operator(,) ident(de)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(v)operator(,) ident(re)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(newArray)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(,) ident(recv)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(str_to_r_strict)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyArray) ident(a) operator(=) ident(str_to_r_internal)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - keyword(if) operator(()ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(a)operator(.)ident(eltInternal)operator(()integer(1)operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(s) operator(=) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(;) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(invalid value for Rational: )delimiter(")> operator(+) ident(s)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C\) 2006 Nick Sieger <nicksieger@gmail.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.ref.SoftReference)operator(;) -keyword(import) include(java.util.concurrent.ConcurrentHashMap)operator(;) -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(org.joni.Matcher)operator(;) -keyword(import) include(org.joni.NameEntry)operator(;) -keyword(import) include(org.joni.Option)operator(;) -keyword(import) include(org.joni.Regex)operator(;) -keyword(import) include(org.joni.Region)operator(;) -keyword(import) include(org.joni.Syntax)operator(;) -keyword(import) include(org.joni.WarnCallback)operator(;) -keyword(import) include(org.joni.encoding.Encoding)operator(;) -keyword(import) include(org.joni.exception.JOniException)operator(;) - -keyword(import) include(static) include(org.jruby.anno.FrameField)operator(.)operator(*)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.parser.ReOptions)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.KCode)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) - -comment(/** - * - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Regexp)delimiter(")>operator(\)) -directive(public) type(class) class(RubyRegexp) directive(extends) ident(RubyObject) directive(implements) ident(ReOptions)operator(,) ident(WarnCallback) operator({) - directive(private) ident(KCode) ident(kcode)operator(;) - directive(private) ident(Regex) ident(pattern)operator(;) - directive(private) ident(ByteList) ident(str)operator(;) - - directive(private) directive(static) directive(final) type(int) ident(REGEXP_LITERAL_F) operator(=) integer(1) operator(<)operator(<) integer(11)operator(;) - directive(private) directive(static) directive(final) type(int) ident(REGEXP_KCODE_DEFAULT) operator(=) integer(1) operator(<)operator(<) integer(12)operator(;) - - directive(public) type(void) ident(setLiteral)operator(()operator(\)) operator({) - ident(flags) operator(|=) ident(REGEXP_LITERAL_F)operator(;) - operator(}) - - directive(public) type(void) ident(clearLiteral)operator(()operator(\)) operator({) - ident(flags) operator(&=) operator(~)ident(REGEXP_LITERAL_F)operator(;) - operator(}) - - directive(public) type(boolean) ident(isLiteral)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(REGEXP_LITERAL_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(public) type(void) ident(setKCodeDefault)operator(()operator(\)) operator({) - ident(flags) operator(|=) ident(REGEXP_KCODE_DEFAULT)operator(;) - operator(}) - - directive(public) type(void) ident(clearKCodeDefault)operator(()operator(\)) operator({) - ident(flags) operator(&=) operator(~)ident(REGEXP_KCODE_DEFAULT)operator(;) - operator(}) - - directive(public) type(boolean) ident(isKCodeDefault)operator(()operator(\)) operator({) - keyword(return) operator(()ident(flags) operator(&) ident(REGEXP_KCODE_DEFAULT)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(public) ident(KCode) ident(getKCode)operator(()operator(\)) operator({) - keyword(return) ident(kcode)operator(;) - operator(}) - - directive(private) directive(static) pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>) ident(getPatternCache)operator(()operator(\)) operator({) - pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>) ident(cache) operator(=) ident(patternCache)operator(.)ident(get)operator(()operator(\))operator(;) - keyword(if) operator(()ident(cache) operator(==) pre_constant(null)operator(\)) operator({) - ident(cache) operator(=) keyword(new) pre_type(ConcurrentHashMap)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>)operator(()integer(5)operator(\))operator(;) - ident(patternCache) operator(=) keyword(new) pre_type(SoftReference)operator(<)pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>)operator(>)operator(()ident(cache)operator(\))operator(;) - operator(}) - keyword(return) ident(cache)operator(;) - operator(}) - - directive(static) directive(volatile) pre_type(SoftReference)operator(<)pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>)operator(>) ident(patternCache) operator(=) keyword(new) pre_type(SoftReference)operator(<)pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>)operator(>)operator(()pre_constant(null)operator(\))operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createRegexpClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(regexpClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Regexp)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(REGEXP_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setRegexp)operator(()ident(regexpClass)operator(\))operator(;) - ident(regexpClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(REGEXP)operator(;) - ident(regexpClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyRegexp)operator(;) - operator(}) - operator(})operator(;) - - ident(regexpClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(IGNORECASE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RE_OPTION_IGNORECASE)operator(\))operator(\))operator(;) - ident(regexpClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(EXTENDED)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RE_OPTION_EXTENDED)operator(\))operator(\))operator(;) - ident(regexpClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MULTILINE)delimiter(")>operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(RE_OPTION_MULTILINE)operator(\))operator(\))operator(;) - - ident(regexpClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyRegexp)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(regexpClass)operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(REGEXP_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyRegexp) ident(instance) operator(=) keyword(new) ident(RubyRegexp)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - comment(/** used by allocator - * - */) - directive(private) ident(RubyRegexp)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - - comment(/** default constructor - * - */) - directive(private) ident(RubyRegexp)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRegexp)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(// used only by the compiler/interpreter (will set the literal flag\)) - directive(public) directive(static) ident(RubyRegexp) ident(newRegexp)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(pattern)operator(,) type(int) ident(options)operator(\)) operator({) - keyword(return) ident(newRegexp)operator(()ident(runtime)operator(,) ident(ByteList)operator(.)ident(create)operator(()ident(pattern)operator(\))operator(,) ident(options)operator(\))operator(;) - operator(}) - - comment(// used only by the compiler/interpreter (will set the literal flag\)) - directive(public) directive(static) ident(RubyRegexp) ident(newRegexp)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(pattern)operator(,) type(int) ident(options)operator(\)) operator({) - ident(RubyRegexp) ident(regexp) operator(=) ident(newRegexp)operator(()ident(runtime)operator(,) ident(pattern)operator(,) ident(options)operator(,) pre_constant(false)operator(\))operator(;) - ident(regexp)operator(.)ident(setLiteral)operator(()operator(\))operator(;) - keyword(return) ident(regexp)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyRegexp) ident(newRegexp)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(pattern)operator(,) type(int) ident(options)operator(,) type(boolean) ident(quote)operator(\)) operator({) - ident(RubyRegexp) ident(regexp) operator(=) keyword(new) ident(RubyRegexp)operator(()ident(runtime)operator(\))operator(;) - ident(regexp)operator(.)ident(initialize)operator(()ident(pattern)operator(,) ident(options)operator(,) ident(quote)operator(\))operator(;) - keyword(return) ident(regexp)operator(;) - operator(}) - - comment(// internal usage) - directive(static) ident(RubyRegexp) ident(newRegexp)operator(()ident(Ruby) ident(runtime)operator(,) ident(Regex) ident(regex)operator(\)) operator({) - ident(RubyRegexp) ident(regexp) operator(=) keyword(new) ident(RubyRegexp)operator(()ident(runtime)operator(\))operator(;) - ident(regexp)operator(.)ident(pattern) operator(=) ident(regex)operator(;) - ident(regexp)operator(.)ident(str) operator(=) ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(;) - keyword(return) ident(regexp)operator(;) - operator(}) - - directive(public) type(void) ident(warn)operator(()pre_type(String) ident(message)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(MISCELLANEOUS)operator(,) ident(message)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(kcode)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(kcode)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) operator(()operator(!)ident(isKCodeDefault)operator(()operator(\)) operator(&&) ident(kcode) operator(!=) pre_constant(null)operator(\)) operator(?) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(kcode)operator(.)ident(name)operator(()operator(\))operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(REGEXP)operator(;) - operator(}) - - directive(public) ident(Regex) ident(getPattern)operator(()operator(\)) operator({) - keyword(return) ident(pattern)operator(;) - operator(}) - - directive(private) type(void) ident(check)operator(()operator(\)) operator({) - keyword(if) operator(()ident(pattern) operator(==) pre_constant(null) operator(||) ident(str) operator(==) pre_constant(null)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(uninitialized Regexp)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - type(int) ident(hashval) operator(=) operator(()type(int)operator(\))ident(pattern)operator(.)ident(getOptions)operator(()operator(\))operator(;) - type(int) ident(len) operator(=) local_variable(this)operator(.)ident(str)operator(.)ident(realSize)operator(;) - type(int) ident(p) operator(=) local_variable(this)operator(.)ident(str)operator(.)ident(begin)operator(;) - keyword(while) operator(()ident(len)operator(--)operator(>)integer(0)operator(\)) operator({) - ident(hashval) operator(=) ident(hashval) operator(*) integer(33) operator(+) ident(str)operator(.)ident(bytes)operator([)ident(p)operator(++)operator(])operator(;) - operator(}) - ident(hashval) operator(=) ident(hashval) operator(+) operator(()ident(hashval)operator(>)operator(>)integer(5)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(hashval)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(==)delimiter(")>operator(,) string<delimiter(")content(eql?)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if)operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyRegexp)operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - ident(RubyRegexp) ident(otherRegex) operator(=) operator(()ident(RubyRegexp)operator(\))ident(other)operator(;) - - ident(check)operator(()operator(\))operator(;) - ident(otherRegex)operator(.)ident(check)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(str)operator(.)ident(equal)operator(()ident(otherRegex)operator(.)ident(str)operator(\)) operator(&&) - ident(kcode) operator(==) ident(otherRegex)operator(.)ident(kcode) operator(&&) ident(pattern)operator(.)ident(getOptions)operator(()operator(\)) operator(==) ident(otherRegex)operator(.)ident(pattern)operator(.)ident(getOptions)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(~)delimiter(")>operator(,) ident(reads) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_match2)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(line) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getLastLine)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)operator(()ident(line) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - type(int) ident(start) operator(=) ident(search)operator(()ident(context)operator(,) operator(()ident(RubyString)operator(\))ident(line)operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - keyword(if)operator(()ident(start) operator(<) integer(0)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(start)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_reg_eqq - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(===)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(eqq)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)operator(()ident(str) keyword(instanceof) ident(RubyString)operator(\))operator(\)) ident(str) operator(=) ident(str)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - type(int) ident(start) operator(=) ident(search)operator(()ident(context)operator(,) operator(()ident(RubyString)operator(\))ident(str)operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - keyword(return) operator(()ident(start) operator(<) integer(0)operator(\)) operator(?) ident(runtime)operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(REGEX_QUOTED) operator(=) integer(1)operator(;) - directive(private) type(void) ident(initialize)operator(()ident(ByteList) ident(bytes)operator(,) type(int) ident(options)operator(,) type(boolean) ident(quote)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't modify regexp)delimiter(")>operator(\))operator(;) - ident(checkFrozen)operator(()operator(\))operator(;) - keyword(if) operator(()ident(isLiteral)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(can't modify literal regexp)delimiter(")>operator(\))operator(;) - - ident(setKCode)operator(()ident(options)operator(\))operator(;) - - pre_type(Map)operator(<)ident(ByteList)operator(,) ident(Regex)operator(>) ident(cache) operator(=) ident(getPatternCache)operator(()operator(\))operator(;) - ident(Regex) ident(pat) operator(=) ident(cache)operator(.)ident(get)operator(()ident(bytes)operator(\))operator(;) - - keyword(if) operator(()ident(pat) operator(!=) pre_constant(null) operator(&&) - ident(pat)operator(.)ident(getEncoding)operator(()operator(\)) operator(==) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\)) operator(&&) - ident(pat)operator(.)ident(getOptions)operator(()operator(\)) operator(==) operator(()ident(options) operator(&) hex(0xf)operator(\)) operator(&&) - operator(()operator(()ident(pat)operator(.)ident(getUserOptions)operator(()operator(\)) operator(&) ident(REGEX_QUOTED)operator(\)) operator(!=) integer(0)operator(\)) operator(==) ident(quote)operator(\)) operator({) comment(// cache hit) - ident(pattern) operator(=) ident(pat)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(quote)operator(\)) ident(bytes) operator(=) ident(quote)operator(()ident(bytes)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getKCode)operator(()operator(\))operator(\))operator(;) - ident(makeRegexp)operator(()ident(bytes)operator(,) ident(bytes)operator(.)ident(begin)operator(,) ident(bytes)operator(.)ident(realSize)operator(,) ident(options) operator(&) hex(0xf)operator(,) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(quote)operator(\)) ident(pattern)operator(.)ident(setUserOptions)operator(()ident(REGEX_QUOTED)operator(\))operator(;) - ident(cache)operator(.)ident(put)operator(()ident(bytes)operator(,) ident(pattern)operator(\))operator(;) - operator(}) - - ident(str) operator(=) ident(bytes)operator(;) - operator(}) - - directive(private) type(void) ident(makeRegexp)operator(()ident(ByteList) ident(bytes)operator(,) type(int) ident(start)operator(,) type(int) ident(len)operator(,) type(int) ident(flags)operator(,) ident(Encoding) ident(enc)operator(\)) operator({) - keyword(try) operator({) - ident(pattern) operator(=) keyword(new) ident(Regex)operator(()ident(bytes)operator(.)ident(bytes)operator(,) ident(start)operator(,) ident(start) operator(+) ident(len)operator(,) ident(flags)operator(,) ident(enc)operator(,) ident(Syntax)operator(.)ident(DEFAULT)operator(,) local_variable(this)operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(Exception) ident(e)operator(\)) operator({) - ident(rb_reg_raise)operator(()ident(bytes)operator(.)ident(bytes)operator(,) ident(start)operator(,) ident(len)operator(,) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(,) ident(flags)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(final) type(void) ident(rb_reg_raise)operator(()type(byte)type([]) ident(s)operator(,) type(int) ident(start)operator(,) type(int) ident(len)operator(,) pre_type(String) ident(err)operator(,)type(int) ident(flags)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRegexpError)operator(()ident(err) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(rb_reg_desc)operator(()ident(s)operator(,)ident(start)operator(,) ident(len)operator(,)ident(flags)operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(final) pre_type(StringBuilder) ident(rb_reg_desc)operator(()type(byte)type([]) ident(s)operator(,) type(int) ident(start)operator(,) type(int) ident(len)operator(,) type(int) ident(flags)operator(\)) operator({) - pre_type(StringBuilder) ident(sb) operator(=) keyword(new) pre_type(StringBuilder)operator(()string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - ident(rb_reg_expr_str)operator(()ident(sb)operator(,) ident(s)operator(,) ident(start)operator(,) ident(len)operator(\))operator(;) - ident(sb)operator(.)ident(append)operator(()string<delimiter(")content(/)delimiter(")>operator(\))operator(;) - - keyword(if)operator(()operator(()ident(flags) operator(&) ident(ReOptions)operator(.)ident(RE_OPTION_MULTILINE)operator(\)) operator(!=) integer(0)operator(\)) ident(sb)operator(.)ident(append)operator(()string<delimiter(")content(m)delimiter(")>operator(\))operator(;) - keyword(if)operator(()operator(()ident(flags) operator(&) ident(ReOptions)operator(.)ident(RE_OPTION_IGNORECASE)operator(\)) operator(!=) integer(0)operator(\)) ident(sb)operator(.)ident(append)operator(()string<delimiter(")content(i)delimiter(")>operator(\))operator(;) - keyword(if)operator(()operator(()ident(flags) operator(&) ident(ReOptions)operator(.)ident(RE_OPTION_EXTENDED)operator(\)) operator(!=) integer(0)operator(\)) ident(sb)operator(.)ident(append)operator(()string<delimiter(")content(x)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(kcode) operator(!=) pre_constant(null) operator(&&) operator(!)ident(isKCodeDefault)operator(()operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()ident(kcode)operator(.)ident(name)operator(()operator(\))operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(sb)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(rb_reg_expr_str)operator(()pre_type(StringBuilder) ident(sb)operator(,) type(byte)type([]) ident(s)operator(,) type(int) ident(start)operator(,) type(int) ident(len)operator(\)) operator({) - type(int) ident(p)operator(,)ident(pend)operator(;) - type(boolean) ident(need_escape) operator(=) pre_constant(false)operator(;) - ident(p) operator(=) ident(start)operator(;) - ident(pend) operator(=) ident(start)operator(+)ident(len)operator(;) - ident(Encoding) ident(enc) operator(=) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(;) - keyword(while)operator(()ident(p)operator(<)ident(pend)operator(\)) operator({) - keyword(if)operator(()ident(s)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(/)delimiter(')> operator(||) operator(()operator(!)operator(()string<delimiter(')content( )delimiter(')> operator(==) ident(s)operator([)ident(p)operator(]) operator(||) operator(()operator(!)pre_type(Character)operator(.)ident(isWhitespace)operator(()ident(s)operator([)ident(p)operator(])operator(\)) operator(&&) - operator(!)pre_type(Character)operator(.)ident(isISOControl)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(\))operator(\)) operator(&&) - ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(==)integer(1)operator(\))operator(\)) operator({) - ident(need_escape) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - operator(}) - ident(p) operator(+=) ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(need_escape)operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()keyword(new) ident(ByteList)operator(()ident(s)operator(,)ident(start)operator(,)ident(len)operator(,)pre_constant(false)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(p) operator(=) integer(0)operator(;) - keyword(while)operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - keyword(if)operator(()ident(s)operator([)ident(p)operator(]) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - type(int) ident(n) operator(=) ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(+)integer(1)operator(])operator(\)) operator(+) integer(1)operator(;) - ident(sb)operator(.)ident(append)operator(()keyword(new) ident(ByteList)operator(()ident(s)operator(,)ident(p)operator(,)ident(n)operator(,)pre_constant(false)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(p) operator(+=) ident(n)operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(s)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(")char(\\\\)content(/)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(!=)integer(1)operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()keyword(new) ident(ByteList)operator(()ident(s)operator(,)ident(p)operator(,)ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(,)pre_constant(false)operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(p) operator(+=) ident(enc)operator(.)ident(length)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) keyword(if)operator(()operator(()string<delimiter(')content( )delimiter(')> operator(==) ident(s)operator([)ident(p)operator(]) operator(||) operator(()operator(!)pre_type(Character)operator(.)ident(isWhitespace)operator(()ident(s)operator([)ident(p)operator(])operator(\)) operator(&&) - operator(!)pre_type(Character)operator(.)ident(isISOControl)operator(()ident(s)operator([)ident(p)operator(])operator(\))operator(\))operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()operator(()type(char)operator(\))operator(()ident(s)operator([)ident(p)operator(])operator(&)hex(0xFF)operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if)operator(()operator(!)pre_type(Character)operator(.)ident(isWhitespace)operator(()operator(()type(char)operator(\))operator(()ident(s)operator([)ident(p)operator(])operator(&)hex(0xFF)operator(\))operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(;) - ident(sb)operator(.)ident(append)operator(()pre_type(Integer)operator(.)ident(toString)operator(()operator(()type(int)operator(\))operator(()ident(s)operator([)ident(p)operator(])operator(&)oct(0377)operator(\))operator(,)integer(8)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(sb)operator(.)ident(append)operator(()operator(()type(char)operator(\))operator(()ident(s)operator([)ident(p)operator(])operator(&)hex(0xFF)operator(\))operator(\))operator(;) - operator(}) - ident(p)operator(++)operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** rb_reg_init_copy - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(re)operator(\)) operator({) - keyword(if)operator(()local_variable(this) operator(==) ident(re)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(checkFrozen)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(re)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyRegexp) ident(regexp) operator(=) operator(()ident(RubyRegexp)operator(\))ident(re)operator(;) - ident(regexp)operator(.)ident(check)operator(()operator(\))operator(;) - - ident(initialize)operator(()ident(regexp)operator(.)ident(str)operator(,) ident(regexp)operator(.)ident(getOptions)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_set_kcode - */) - directive(private) type(int) ident(getKcode)operator(()operator(\)) operator({) - keyword(if)operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(NONE)operator(\)) operator({) - keyword(return) integer(16)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(EUC)operator(\)) operator({) - keyword(return) integer(32)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(SJIS)operator(\)) operator({) - keyword(return) integer(48)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(UTF8)operator(\)) operator({) - keyword(return) integer(64)operator(;) - operator(}) - keyword(return) integer(0)operator(;) - operator(}) - - comment(/** - */) - directive(private) type(void) ident(setKCode)operator(()type(int) ident(options)operator(\)) operator({) - ident(clearKCodeDefault)operator(()operator(\))operator(;) - keyword(switch)operator(()ident(options) operator(&) operator(~)hex(0xf)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(default)operator(:) - ident(setKCodeDefault)operator(()operator(\))operator(;) - ident(kcode) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getKCode)operator(()operator(\))operator(;) - keyword(break)operator(;) - keyword(case) integer(16)operator(:) - ident(kcode) operator(=) ident(KCode)operator(.)ident(NONE)operator(;) - keyword(break)operator(;) - keyword(case) integer(32)operator(:) - ident(kcode) operator(=) ident(KCode)operator(.)ident(EUC)operator(;) - keyword(break)operator(;) - keyword(case) integer(48)operator(:) - ident(kcode) operator(=) ident(KCode)operator(.)ident(SJIS)operator(;) - keyword(break)operator(;) - keyword(case) integer(64)operator(:) - ident(kcode) operator(=) ident(KCode)operator(.)ident(UTF8)operator(;) - keyword(break)operator(;) - operator(}) - operator(}) - - comment(/** rb_reg_options - */) - directive(private) type(int) ident(getOptions)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - type(int) ident(options) operator(=) operator(()type(int)operator(\))operator(()ident(pattern)operator(.)ident(getOptions)operator(()operator(\)) operator(&) operator(()ident(RE_OPTION_IGNORECASE)operator(|)ident(RE_OPTION_MULTILINE)operator(|)ident(RE_OPTION_EXTENDED)operator(\))operator(\))operator(;) - keyword(if)operator(()operator(!)ident(isKCodeDefault)operator(()operator(\))operator(\)) operator({) - ident(options) operator(|=) ident(getKcode)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(options)operator(;) - operator(}) - - comment(/** rb_reg_initialize_m - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(3)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_m)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ByteList) ident(bytes)operator(;) - type(int) ident(regexFlags) operator(=) integer(0)operator(;) - - keyword(if)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(REGEXP_IGNORED_FLAGS)operator(,) string<delimiter(")content(flags)delimiter(")> operator(+) operator(()ident(args)operator(.)ident(length) operator(==) integer(3) operator(?) string<delimiter(")content( and encoding)delimiter(")> operator(:) string<delimiter(")delimiter(")>operator(\)) operator(+) string<delimiter(")content( ignored)delimiter(")>operator(\))operator(;) - operator(}) - ident(RubyRegexp) ident(regexp) operator(=) operator(()ident(RubyRegexp)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - ident(regexp)operator(.)ident(check)operator(()operator(\))operator(;) - - ident(regexFlags) operator(=) operator(()type(int)operator(\))ident(regexp)operator(.)ident(pattern)operator(.)ident(getOptions)operator(()operator(\)) operator(&) hex(0xF)operator(;) - keyword(if) operator(()operator(!)ident(regexp)operator(.)ident(isKCodeDefault)operator(()operator(\)) operator(&&) ident(regexp)operator(.)ident(kcode) operator(!=) pre_constant(null) operator(&&) ident(regexp)operator(.)ident(kcode) operator(!=) ident(KCode)operator(.)ident(NIL)operator(\)) operator({) - keyword(if) operator(()ident(regexp)operator(.)ident(kcode) operator(==) ident(KCode)operator(.)ident(NONE)operator(\)) operator({) - ident(regexFlags) operator(|=) integer(16)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(regexp)operator(.)ident(kcode) operator(==) ident(KCode)operator(.)ident(EUC)operator(\)) operator({) - ident(regexFlags) operator(|=) integer(32)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(regexp)operator(.)ident(kcode) operator(==) ident(KCode)operator(.)ident(SJIS)operator(\)) operator({) - ident(regexFlags) operator(|=) integer(48)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(regexp)operator(.)ident(kcode) operator(==) ident(KCode)operator(.)ident(UTF8)operator(\)) operator({) - ident(regexFlags) operator(|=) integer(64)operator(;) - operator(}) - operator(}) - ident(bytes) operator(=) ident(regexp)operator(.)ident(str)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>=) integer(2)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(regexFlags) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(1)operator(])operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(regexFlags) operator(=) ident(RE_OPTION_IGNORECASE)operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(3) operator(&&) operator(!)ident(args)operator([)integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(ByteList) ident(kcodeBytes) operator(=) ident(args)operator([)integer(2)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - type(char) ident(first) operator(=) ident(kcodeBytes)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0) operator(?) ident(kcodeBytes)operator(.)ident(charAt)operator(()integer(0)operator(\)) operator(:) integer(0)operator(;) - ident(regexFlags) operator(&=) operator(~)hex(0x70)operator(;) - keyword(switch) operator(()ident(first)operator(\)) operator({) - keyword(case) string<delimiter(')content(n)delimiter(')>operator(:) keyword(case) string<delimiter(')content(N)delimiter(')>operator(:) - ident(regexFlags) operator(|=) integer(16)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(e)delimiter(')>operator(:) keyword(case) string<delimiter(')content(E)delimiter(')>operator(:) - ident(regexFlags) operator(|=) integer(32)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(s)delimiter(')>operator(:) keyword(case) string<delimiter(')content(S)delimiter(')>operator(:) - ident(regexFlags) operator(|=) integer(48)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(u)delimiter(')>operator(:) keyword(case) string<delimiter(')content(U)delimiter(')>operator(:) - ident(regexFlags) operator(|=) integer(64)operator(;) - keyword(break)operator(;) - keyword(default)operator(:) - keyword(break)operator(;) - operator(}) - operator(}) - ident(bytes) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - ident(initialize)operator(()ident(bytes)operator(,) ident(regexFlags)operator(,) pre_constant(false)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content(compile)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyRegexp) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - ident(RubyRegexp) ident(re) operator(=) operator(()ident(RubyRegexp)operator(\)) ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(re)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(return) ident(re)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(options)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(options)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getOptions)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_reg_search - */) - directive(public) type(int) ident(search)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyString) ident(str)operator(,) type(int) ident(pos)operator(,) type(boolean) ident(reverse)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentRubyFrame)operator(()operator(\))operator(;) - - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>) ident(value)operator(.)ident(realSize) operator(||) ident(pos) operator(<) integer(0)operator(\)) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - - keyword(return) ident(performSearch)operator(()ident(reverse)operator(,) ident(pos)operator(,) ident(value)operator(,) ident(frame)operator(,) ident(runtime)operator(,) ident(context)operator(,) ident(str)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(performSearch)operator(()type(boolean) ident(reverse)operator(,) type(int) ident(pos)operator(,) ident(ByteList) ident(value)operator(,) pre_type(Frame) ident(frame)operator(,) ident(Ruby) ident(runtime)operator(,) ident(ThreadContext) ident(context)operator(,) ident(RubyString) ident(str)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - - type(int) ident(realSize) operator(=) ident(value)operator(.)ident(realSize)operator(;) - type(int) ident(begin) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(range) operator(=) ident(reverse) operator(?) operator(-)ident(pos) operator(:) ident(realSize) operator(-) ident(pos)operator(;) - - pre_type(Matcher) ident(matcher) operator(=) ident(pattern)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(begin)operator(,) ident(begin) operator(+) ident(realSize)operator(\))operator(;) - - type(int) ident(result) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(begin) operator(+) ident(pos)operator(,) ident(begin) operator(+) ident(pos) operator(+) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(;) - - keyword(if) operator(()ident(result) operator(<) integer(0)operator(\)) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - ident(updateBackRef)operator(()ident(context)operator(,) ident(str)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(final) ident(RubyMatchData) ident(updateBackRef)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyString) ident(str)operator(,) pre_type(Frame) ident(frame)operator(,) pre_type(Matcher) ident(matcher)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backref) operator(=) ident(frame)operator(.)ident(getBackRef)operator(()operator(\))operator(;) - directive(final) ident(RubyMatchData) ident(match)operator(;) - keyword(if) operator(()ident(backref) operator(==) pre_constant(null) operator(||) ident(backref)operator(.)ident(isNil)operator(()operator(\)) operator(||) operator(()operator(()ident(RubyMatchData)operator(\))ident(backref)operator(\))operator(.)ident(used)operator(()operator(\))operator(\)) operator({) - ident(match) operator(=) keyword(new) ident(RubyMatchData)operator(()ident(runtime)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(match) operator(=) operator(()ident(RubyMatchData)operator(\))ident(backref)operator(;) - ident(match)operator(.)ident(setTaint)operator(()ident(runtime)operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(3)operator(\))operator(;) - operator(}) - - ident(match)operator(.)ident(regs) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) comment(// lazy, null when no groups defined) - ident(match)operator(.)ident(begin) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - ident(match)operator(.)ident(end) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - - ident(match)operator(.)ident(str) operator(=) operator(()ident(RubyString)operator(\))ident(str)operator(.)ident(strDup)operator(()ident(runtime)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(match)operator(.)ident(pattern) operator(=) ident(pattern)operator(;) - - ident(frame)operator(.)ident(setBackRef)operator(()ident(match)operator(\))operator(;) - - ident(match)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - ident(match)operator(.)ident(infectBy)operator(()ident(str)operator(\))operator(;) - keyword(return) ident(match)operator(;) - operator(}) - - comment(/** rb_reg_match - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(=~)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_match)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - type(int) ident(start)operator(;) - keyword(if)operator(()ident(str)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - ident(start) operator(=) ident(search)operator(()ident(context)operator(,) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - - keyword(if) operator(()ident(start) operator(<) integer(0)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(start)operator(\))operator(;) - operator(}) - - comment(/** rb_reg_match_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(match)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(reads) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(match_m)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - keyword(if) operator(()ident(op_match)operator(()ident(context)operator(,) ident(str)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(result) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(result) keyword(instanceof) ident(RubyMatchData)operator(\)) operator({) - operator(()operator(()ident(RubyMatchData)operator(\))ident(result)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - - directive(public) ident(RubyString) ident(regsub)operator(()ident(RubyString) ident(str)operator(,) ident(RubyString) ident(src)operator(,) pre_type(Matcher) ident(matcher)operator(\)) operator({) - pre_type(Region) ident(regs) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - type(int) ident(mbeg) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - type(int) ident(mend) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - - type(int) ident(p)operator(,)ident(s)operator(,)ident(e)operator(;) - ident(p) operator(=) ident(s) operator(=) integer(0)operator(;) - type(int) ident(no) operator(=) operator(-)integer(1)operator(;) - ident(ByteList) ident(bs) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(ByteList) ident(srcbs) operator(=) ident(src)operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(e) operator(=) ident(bs)operator(.)ident(length)operator(()operator(\))operator(;) - ident(RubyString) ident(val) operator(=) pre_constant(null)operator(;) - ident(Encoding) ident(enc) operator(=) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(;) - - type(int) ident(beg)operator(,) ident(end)operator(;) - keyword(while)operator(()ident(s) operator(<) ident(e)operator(\)) operator({) - type(int) ident(ss) operator(=) ident(s)operator(;) - type(char) ident(c) operator(=) ident(bs)operator(.)ident(charAt)operator(()ident(s)operator(++)operator(\))operator(;) - keyword(if)operator(()ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\)) operator(!=) integer(1)operator(\)) operator({) - ident(s) operator(+=) ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\)) operator(-) integer(1)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(if) operator(()ident(c) operator(!=) string<delimiter(')char(\\\\)delimiter(')> operator(||) ident(s) operator(==) ident(e)operator(\)) keyword(continue)operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) ident(val) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(ss) operator(-) ident(p)operator(\))operator(\))operator(;) - - ident(val)operator(.)ident(cat)operator(()ident(bs)operator(.)ident(bytes)operator(,) ident(bs)operator(.)ident(begin) operator(+) ident(p)operator(,) ident(ss) operator(-) ident(p)operator(\))operator(;) - ident(c) operator(=) ident(bs)operator(.)ident(charAt)operator(()ident(s)operator(++)operator(\))operator(;) - ident(p) operator(=) ident(s)operator(;) - - keyword(switch)operator(()ident(c)operator(\)) operator({) - keyword(case) string<delimiter(')content(0)delimiter(')>operator(:) keyword(case) string<delimiter(')content(1)delimiter(')>operator(:) keyword(case) string<delimiter(')content(2)delimiter(')>operator(:) keyword(case) string<delimiter(')content(3)delimiter(')>operator(:) keyword(case) string<delimiter(')content(4)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(5)delimiter(')>operator(:) keyword(case) string<delimiter(')content(6)delimiter(')>operator(:) keyword(case) string<delimiter(')content(7)delimiter(')>operator(:) keyword(case) string<delimiter(')content(8)delimiter(')>operator(:) keyword(case) string<delimiter(')content(9)delimiter(')>operator(:) - ident(no) operator(=) ident(c) operator(-) string<delimiter(')content(0)delimiter(')>operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(&)delimiter(')>operator(:) - ident(no) operator(=) integer(0)operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content(`)delimiter(')>operator(:) - ident(beg) operator(=) ident(regs) operator(==) pre_constant(null) operator(?) ident(mbeg) operator(:) ident(regs)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - ident(val)operator(.)ident(cat)operator(()ident(srcbs)operator(.)ident(bytes)operator(,) ident(srcbs)operator(.)ident(begin)operator(,) ident(beg)operator(\))operator(;) - keyword(continue)operator(;) - - keyword(case) string<delimiter(')char(\\')delimiter(')>operator(:) - ident(end) operator(=) ident(regs) operator(==) pre_constant(null) operator(?) ident(mend) operator(:) ident(regs)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - ident(val)operator(.)ident(cat)operator(()ident(srcbs)operator(.)ident(bytes)operator(,) ident(srcbs)operator(.)ident(begin) operator(+) ident(end)operator(,) ident(src)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(-) ident(end)operator(\))operator(;) - keyword(continue)operator(;) - - keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(mbeg) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(no) operator(=) integer(0)operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(no) operator(=) ident(regs)operator(.)ident(numRegs)operator(-)integer(1)operator(;) - keyword(while)operator(()ident(regs)operator(.)ident(beg)operator([)ident(no)operator(]) operator(==) operator(-)integer(1) operator(&&) ident(no) operator(>) integer(0)operator(\)) ident(no)operator(--)operator(;) - keyword(if) operator(()ident(no) operator(==) integer(0)operator(\)) keyword(continue)operator(;) - operator(}) - keyword(break)operator(;) - keyword(case) string<delimiter(')char(\\\\)delimiter(')>operator(:) - ident(val)operator(.)ident(cat)operator(()ident(bs)operator(.)ident(bytes)operator(,) ident(s) operator(-) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(continue)operator(;) - keyword(default)operator(:) - ident(val)operator(.)ident(cat)operator(()ident(bs)operator(.)ident(bytes)operator(,) ident(s) operator(-) integer(2)operator(,) integer(2)operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - - keyword(if) operator(()ident(regs) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(no) operator(>=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(no) operator(>=) ident(regs)operator(.)ident(numRegs) operator(||) ident(regs)operator(.)ident(beg)operator([)ident(no)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(continue)operator(;) - ident(val)operator(.)ident(cat)operator(()ident(srcbs)operator(.)ident(bytes)operator(,) ident(srcbs)operator(.)ident(begin) operator(+) ident(regs)operator(.)ident(beg)operator([)ident(no)operator(])operator(,) ident(regs)operator(.)ident(end)operator([)ident(no)operator(]) operator(-) ident(regs)operator(.)ident(beg)operator([)ident(no)operator(])operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(no) operator(!=) integer(0) operator(||) ident(mbeg) operator(==) operator(-)integer(1)operator(\)) keyword(continue)operator(;) - ident(val)operator(.)ident(cat)operator(()ident(srcbs)operator(.)ident(bytes)operator(,) ident(srcbs)operator(.)ident(begin) operator(+) ident(mbeg)operator(,) ident(mend) operator(-) ident(mbeg)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if)operator(()ident(p) operator(<) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - ident(val) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(bs)operator(.)ident(makeShared)operator(()ident(p)operator(,) ident(e)operator(-)ident(p)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(val)operator(.)ident(cat)operator(()ident(bs)operator(.)ident(bytes)operator(,) ident(bs)operator(.)ident(begin) operator(+) ident(p)operator(,) ident(e) operator(-) ident(p)operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) keyword(return) ident(str)operator(;) - - keyword(return) ident(val)operator(;) - operator(}) - - directive(final) type(int) ident(adjustStartPos)operator(()ident(RubyString) ident(str)operator(,) type(int) ident(pos)operator(,) type(boolean) ident(reverse)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(return) ident(pattern)operator(.)ident(adjustStartPosition)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(value)operator(.)ident(realSize)operator(,) ident(pos)operator(,) ident(reverse)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(casefold?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(casefold_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(()ident(pattern)operator(.)ident(getOptions)operator(()operator(\)) operator(&) ident(RE_OPTION_IGNORECASE)operator(\)) operator(!=) integer(0)operator(\))operator(;) - operator(}) - - comment(/** rb_reg_source - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(source)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(source)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(check)operator(()operator(\))operator(;) - ident(RubyString) ident(str) operator(=) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(runtime)operator(,) local_variable(this)operator(.)ident(str)operator(\))operator(;) - keyword(if)operator(()ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(str)operator(.)ident(taint)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(str)operator(;) - operator(}) - - directive(final) type(int) ident(length)operator(()operator(\)) operator({) - keyword(return) ident(str)operator(.)ident(realSize)operator(;) - operator(}) - - comment(/** rb_reg_inspect - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(ByteList)operator(.)ident(create)operator(()ident(rb_reg_desc)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(str)operator(.)ident(begin)operator(,) ident(str)operator(.)ident(realSize)operator(,) ident(pattern)operator(.)ident(getOptions)operator(()operator(\))operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(final) directive(static) type(int) ident(EMBEDDABLE) operator(=) ident(RE_OPTION_MULTILINE)operator(|)ident(RE_OPTION_IGNORECASE)operator(|)ident(RE_OPTION_EXTENDED)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - ident(RubyString) ident(ss) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content((?)delimiter(")>operator(\))operator(;) - ident(check)operator(()operator(\))operator(;) - - type(int) ident(options) operator(=) ident(pattern)operator(.)ident(getOptions)operator(()operator(\))operator(;) - type(int) ident(ptr) operator(=) ident(str)operator(.)ident(begin)operator(;) - type(int) ident(len) operator(=) ident(str)operator(.)ident(realSize)operator(;) - type(byte)type([]) ident(bytes) operator(=) ident(str)operator(.)ident(bytes)operator(;) - ident(again)operator(:) keyword(do) operator({) - keyword(if) operator(()ident(len) operator(>=) integer(4) operator(&&) ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(()delimiter(')> operator(&&) ident(bytes)operator([)ident(ptr) operator(+) integer(1)operator(]) operator(==) string<delimiter(')content(?)delimiter(')>operator(\)) operator({) - type(boolean) ident(err) operator(=) pre_constant(true)operator(;) - ident(ptr) operator(+=) integer(2)operator(;) - keyword(if) operator(()operator(()ident(len) operator(-=) integer(2)operator(\)) operator(>) integer(0)operator(\)) operator({) - keyword(do) operator({) - keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(m)delimiter(')>operator(\)) operator({) - ident(options) operator(|=) ident(RE_OPTION_MULTILINE)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(i)delimiter(')>operator(\)) operator({) - ident(options) operator(|=) ident(RE_OPTION_IGNORECASE)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(x)delimiter(')>operator(\)) operator({) - ident(options) operator(|=) ident(RE_OPTION_EXTENDED)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - ident(ptr)operator(++)operator(;) - operator(}) keyword(while)operator(()operator(--)ident(len) operator(>) integer(0)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(len) operator(>) integer(1) operator(&&) ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(-)delimiter(')>operator(\)) operator({) - operator(++)ident(ptr)operator(;) - operator(--)ident(len)operator(;) - keyword(do) operator({) - keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(m)delimiter(')>operator(\)) operator({) - ident(options) operator(&=) operator(~)ident(RE_OPTION_MULTILINE)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(i)delimiter(')>operator(\)) operator({) - ident(options) operator(&=) operator(~)ident(RE_OPTION_IGNORECASE)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(x)delimiter(')>operator(\)) operator({) - ident(options) operator(&=) operator(~)ident(RE_OPTION_EXTENDED)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - ident(ptr)operator(++)operator(;) - operator(}) keyword(while)operator(()operator(--)ident(len) operator(>) integer(0)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(\))delimiter(')>operator(\)) operator({) - operator(--)ident(len)operator(;) - operator(++)ident(ptr)operator(;) - keyword(continue) ident(again)operator(;) - operator(}) - - keyword(if) operator(()ident(bytes)operator([)ident(ptr)operator(]) operator(==) string<delimiter(')content(:)delimiter(')> operator(&&) ident(bytes)operator([)ident(ptr) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) string<delimiter(')content(\))delimiter(')>operator(\)) operator({) - keyword(try) operator({) - keyword(new) ident(Regex)operator(()ident(bytes)operator(,) operator(++)ident(ptr)operator(,) ident(ptr) operator(+) operator(()ident(len)operator(-=)integer(2)operator(\)) operator(,)pre_type(Option)operator(.)ident(DEFAULT)operator(,) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(,) ident(Syntax)operator(.)ident(DEFAULT)operator(\))operator(;) - ident(err) operator(=) pre_constant(false)operator(;) - operator(}) keyword(catch) operator(()ident(JOniException) ident(e)operator(\)) operator({) - ident(err) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(err)operator(\)) operator({) - ident(options) operator(=) operator(()type(int)operator(\))ident(pattern)operator(.)ident(getOptions)operator(()operator(\))operator(;) - ident(ptr) operator(=) ident(str)operator(.)ident(begin)operator(;) - ident(len) operator(=) ident(str)operator(.)ident(realSize)operator(;) - operator(}) - operator(}) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_MULTILINE)operator(\)) operator(!=)integer(0) operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(m)delimiter(')>operator(\))operator(;) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_IGNORECASE)operator(\)) operator(!=)integer(0) operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(i)delimiter(')>operator(\))operator(;) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_EXTENDED)operator(\)) operator(!=)integer(0) operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(x)delimiter(')>operator(\))operator(;) - - keyword(if) operator(()operator(()ident(options) operator(&) ident(EMBEDDABLE)operator(\)) operator(!=) ident(EMBEDDABLE)operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(-)delimiter(')>operator(\))operator(;) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_MULTILINE)operator(\)) operator(==) integer(0)operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(m)delimiter(')>operator(\))operator(;) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_IGNORECASE)operator(\)) operator(==) integer(0)operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(i)delimiter(')>operator(\))operator(;) - keyword(if) operator(()operator(()ident(options) operator(&) ident(RE_OPTION_EXTENDED)operator(\)) operator(==) integer(0)operator(\)) ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(x)delimiter(')>operator(\))operator(;) - operator(}) - ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(:)delimiter(')>operator(\))operator(;) - ident(rb_reg_expr_str)operator(()ident(ss)operator(,) ident(ptr)operator(,) ident(len)operator(\))operator(;) - ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(\))delimiter(')>operator(\))operator(;) - ident(ss)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(ss)operator(;) - operator(}) keyword(while)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(rb_reg_expr_str)operator(()ident(RubyString) ident(ss)operator(,) type(int) ident(s)operator(,) type(int) ident(len)operator(\)) operator({) - type(int) ident(p) operator(=) ident(s)operator(;) - type(int) ident(pend) operator(=) ident(p) operator(+) ident(len)operator(;) - type(boolean) ident(need_escape) operator(=) pre_constant(false)operator(;) - ident(Encoding) ident(enc) operator(=) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(;) - keyword(while) operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - keyword(if) operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(/)delimiter(')> operator(||) operator(()operator(!)ident(enc)operator(.)ident(isPrint)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(&) hex(0xff)operator(\)) operator(&&) ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(])operator(\)) operator(==) integer(1)operator(\))operator(\)) operator({) - ident(need_escape) operator(=) pre_constant(true)operator(;) - keyword(break)operator(;) - operator(}) - ident(p) operator(+=) ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(])operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(!)ident(need_escape)operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(s)operator(,) ident(len)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(p) operator(=) ident(s)operator(;) - keyword(while) operator(()ident(p)operator(<)ident(pend)operator(\)) operator({) - keyword(if) operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - type(int) ident(n) operator(=) ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(+)integer(1)operator(])operator(\)) operator(+) integer(1)operator(;) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(p)operator(,) ident(n)operator(\))operator(;) - ident(p) operator(+=) ident(n)operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(/)delimiter(')>operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(;) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(p)operator(,) integer(1)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(])operator(\)) operator(!=) integer(1)operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(p)operator(,) ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(])operator(\))operator(\))operator(;) - ident(p) operator(+=) ident(enc)operator(.)ident(length)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(])operator(\))operator(;) - keyword(continue)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(enc)operator(.)ident(isPrint)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(&) hex(0xff)operator(\))operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,)ident(p)operator(,)integer(1)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)ident(enc)operator(.)ident(isSpace)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(&) hex(0xff)operator(\))operator(\)) operator({) - ident(ss)operator(.)ident(cat)operator(()ident(ByteList)operator(.)ident(create)operator(()pre_type(Integer)operator(.)ident(toString)operator(()ident(str)operator(.)ident(bytes)operator([)ident(p)operator(]) operator(&) oct(0377)operator(,) integer(8)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(ss)operator(.)ident(cat)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(p)operator(,) integer(1)operator(\))operator(;) - operator(}) - ident(p)operator(++)operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** rb_reg_s_quote - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(quote)delimiter(")>operator(,) string<delimiter(")content(escape)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyString) ident(quote)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(kcode) operator(=) ident(args)operator(.)ident(length) operator(==) integer(2) operator(?) ident(args)operator([)integer(1)operator(]) operator(:) pre_constant(null)operator(;) - ident(IRubyObject) ident(str) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(KCode) ident(code) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getKCode)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(kcode) operator(!=) pre_constant(null) operator(&&) operator(!)ident(kcode)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(code) operator(=) ident(KCode)operator(.)ident(create)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(kcode)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(RubyString) ident(src) operator(=) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(RubyString) ident(dst) operator(=) ident(RubyString)operator(.)ident(newString)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(quote)operator(()ident(src)operator(.)ident(getByteList)operator(()operator(\))operator(,) ident(code)operator(\))operator(\))operator(;) - ident(dst)operator(.)ident(infectBy)operator(()ident(src)operator(\))operator(;) - keyword(return) ident(dst)operator(;) - operator(}) - - comment(/** rb_reg_quote - * - */) - directive(public) directive(static) ident(ByteList) ident(quote)operator(()ident(ByteList) ident(str)operator(,) ident(KCode) ident(kcode)operator(\)) operator({) - ident(ByteList) ident(bs) operator(=) ident(str)operator(;) - type(int) ident(tix) operator(=) integer(0)operator(;) - type(int) ident(s) operator(=) ident(bs)operator(.)ident(begin)operator(;) - type(char) ident(c)operator(;) - type(int) ident(send) operator(=) ident(s)operator(+)ident(bs)operator(.)ident(length)operator(()operator(\))operator(;) - ident(Encoding) ident(enc) operator(=) ident(kcode)operator(.)ident(getEncoding)operator(()operator(\))operator(;) - ident(meta_found)operator(:) keyword(do) operator({) - keyword(for)operator(()operator(;) ident(s)operator(<)ident(send)operator(;) ident(s)operator(++)operator(\)) operator({) - ident(c) operator(=) operator(()type(char)operator(\))operator(()ident(bs)operator(.)ident(bytes)operator([)ident(s)operator(])operator(&)hex(0xFF)operator(\))operator(;) - keyword(if)operator(()ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\)) operator(!=) integer(1)operator(\)) operator({) - type(int) ident(n) operator(=) ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\))operator(;) - keyword(while)operator(()ident(n)operator(--) operator(>) integer(0) operator(&&) ident(s) operator(<) ident(send)operator(\)) operator({) - ident(s)operator(++)operator(;) - operator(}) - ident(s)operator(--)operator(;) - keyword(continue)operator(;) - operator(}) - keyword(switch) operator(()ident(c)operator(\)) operator({) - keyword(case) string<delimiter(')content([)delimiter(')>operator(:) keyword(case) string<delimiter(')content(])delimiter(')>operator(:) keyword(case) string<delimiter(')content({)delimiter(')>operator(:) keyword(case) string<delimiter(')content(})delimiter(')>operator(:) - keyword(case) string<delimiter(')content(()delimiter(')>operator(:) keyword(case) string<delimiter(')content(\))delimiter(')>operator(:) keyword(case) string<delimiter(')content(|)delimiter(')>operator(:) keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(*)delimiter(')>operator(:) keyword(case) string<delimiter(')content(.)delimiter(')>operator(:) keyword(case) string<delimiter(')char(\\\\)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(?)delimiter(')>operator(:) keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) keyword(case) string<delimiter(')content(^)delimiter(')>operator(:) keyword(case) string<delimiter(')content($)delimiter(')>operator(:) - keyword(case) string<delimiter(')content( )delimiter(')>operator(:) keyword(case) string<delimiter(')content(#)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(\\t)delimiter(')>operator(:) keyword(case) string<delimiter(')content(\\f)delimiter(')>operator(:) keyword(case) string<delimiter(')content(\\n)delimiter(')>operator(:) keyword(case) string<delimiter(')content(\\r)delimiter(')>operator(:) - keyword(break) ident(meta_found)operator(;) - operator(}) - operator(}) - keyword(return) ident(bs)operator(;) - operator(}) keyword(while)operator(()pre_constant(false)operator(\))operator(;) - ident(ByteList) ident(b1) operator(=) keyword(new) ident(ByteList)operator(()ident(send)operator(*)integer(2)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(bs)operator(.)ident(bytes)operator(,)ident(bs)operator(.)ident(begin)operator(,)ident(b1)operator(.)ident(bytes)operator(,)ident(b1)operator(.)ident(begin)operator(,)ident(s)operator(-)ident(bs)operator(.)ident(begin)operator(\))operator(;) - ident(tix) operator(+=) operator(()ident(s)operator(-)ident(bs)operator(.)ident(begin)operator(\))operator(;) - - keyword(for)operator(()operator(;) ident(s)operator(<)ident(send)operator(;) ident(s)operator(++)operator(\)) operator({) - ident(c) operator(=) operator(()type(char)operator(\))operator(()ident(bs)operator(.)ident(bytes)operator([)ident(s)operator(])operator(&)hex(0xFF)operator(\))operator(;) - keyword(if)operator(()ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\)) operator(!=) integer(1)operator(\)) operator({) - type(int) ident(n) operator(=) ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\))operator(;) - keyword(while)operator(()ident(n)operator(--) operator(>) integer(0) operator(&&) ident(s) operator(<) ident(send)operator(\)) operator({) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) ident(bs)operator(.)ident(bytes)operator([)ident(s)operator(++)operator(])operator(;) - operator(}) - ident(s)operator(--)operator(;) - keyword(continue)operator(;) - operator(}) - - keyword(switch)operator(()ident(c)operator(\)) operator({) - keyword(case) string<delimiter(')content([)delimiter(')>operator(:) keyword(case) string<delimiter(')content(])delimiter(')>operator(:) keyword(case) string<delimiter(')content({)delimiter(')>operator(:) keyword(case) string<delimiter(')content(})delimiter(')>operator(:) - keyword(case) string<delimiter(')content(()delimiter(')>operator(:) keyword(case) string<delimiter(')content(\))delimiter(')>operator(:) keyword(case) string<delimiter(')content(|)delimiter(')>operator(:) keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(*)delimiter(')>operator(:) keyword(case) string<delimiter(')content(.)delimiter(')>operator(:) keyword(case) string<delimiter(')char(\\\\)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(?)delimiter(')>operator(:) keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) keyword(case) string<delimiter(')content(^)delimiter(')>operator(:) keyword(case) string<delimiter(')content($)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(#)delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - keyword(break)operator(;) - keyword(case) string<delimiter(')content( )delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')content( )delimiter(')>operator(;) - keyword(continue)operator(;) - keyword(case) string<delimiter(')content(\\t)delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')content(t)delimiter(')>operator(;) - keyword(continue)operator(;) - keyword(case) string<delimiter(')content(\\n)delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')content(n)delimiter(')>operator(;) - keyword(continue)operator(;) - keyword(case) string<delimiter(')content(\\r)delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')content(r)delimiter(')>operator(;) - keyword(continue)operator(;) - keyword(case) string<delimiter(')content(\\f)delimiter(')>operator(:) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')char(\\\\)delimiter(')>operator(;) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) string<delimiter(')content(f)delimiter(')>operator(;) - keyword(continue)operator(;) - operator(}) - ident(b1)operator(.)ident(bytes)operator([)ident(tix)operator(++)operator(]) operator(=) operator(()type(byte)operator(\))ident(c)operator(;) - operator(}) - ident(b1)operator(.)ident(realSize) operator(=) ident(tix)operator(;) - keyword(return) ident(b1)operator(;) - operator(}) - - - comment(/** rb_reg_nth_match - * - */) - directive(public) directive(static) ident(IRubyObject) ident(nth_match)operator(()type(int) ident(nth)operator(,) ident(IRubyObject) ident(match)operator(\)) operator({) - keyword(if) operator(()ident(match)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(match)operator(;) - ident(RubyMatchData) ident(m) operator(=) operator(()ident(RubyMatchData)operator(\))ident(match)operator(;) - - type(int) ident(start)operator(,) ident(end)operator(;) - - keyword(if) operator(()ident(m)operator(.)ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(nth) operator(>=) integer(1)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(nth) operator(<) integer(0) operator(&&) operator(++)ident(nth) operator(<=) integer(0)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(start) operator(=) ident(m)operator(.)ident(begin)operator(;) - ident(end) operator(=) ident(m)operator(.)ident(end)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(nth) operator(>=) ident(m)operator(.)ident(regs)operator(.)ident(numRegs)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(nth) operator(<) integer(0) operator(&&) operator(()ident(nth)operator(+=)ident(m)operator(.)ident(regs)operator(.)ident(numRegs)operator(\)) operator(<=) integer(0)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(start) operator(=) ident(m)operator(.)ident(regs)operator(.)ident(beg)operator([)ident(nth)operator(])operator(;) - ident(end) operator(=) ident(m)operator(.)ident(regs)operator(.)ident(end)operator([)ident(nth)operator(])operator(;) - operator(}) - - keyword(if) operator(()ident(start) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(m)operator(.)ident(str)operator(.)ident(makeShared)operator(()ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(start)operator(,) ident(end) operator(-) ident(start)operator(\))operator(;) - ident(str)operator(.)ident(infectBy)operator(()ident(match)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_reg_last_match - * - */) - directive(public) directive(static) ident(IRubyObject) ident(last_match)operator(()ident(IRubyObject) ident(match)operator(\)) operator({) - keyword(return) ident(nth_match)operator(()integer(0)operator(,) ident(match)operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) directive(static) ident(IRubyObject) ident(last_match_s)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(last_match_s)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(last_match_s)operator(()ident(context)operator(,) ident(recv)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_reg_s_last_match / match_getter - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(last_match)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(last_match_s)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(IRubyObject) ident(match) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(match) keyword(instanceof) ident(RubyMatchData)operator(\)) operator(()operator(()ident(RubyMatchData)operator(\))ident(match)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - keyword(return) ident(match)operator(;) - operator(}) - - comment(/** rb_reg_s_last_match - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(last_match)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(last_match_s)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(nth)operator(\)) operator({) - ident(IRubyObject) ident(match) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(match)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(match)operator(;) - keyword(return) ident(nth_match)operator(()operator(()operator(()ident(RubyMatchData)operator(\))ident(match)operator(\))operator(.)ident(backrefNumber)operator(()ident(nth)operator(\))operator(,) ident(match)operator(\))operator(;) - operator(}) - - comment(/** rb_reg_match_pre - * - */) - directive(public) directive(static) ident(IRubyObject) ident(match_pre)operator(()ident(IRubyObject) ident(match)operator(\)) operator({) - keyword(if) operator(()ident(match)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(match)operator(;) - ident(RubyMatchData) ident(m) operator(=) operator(()ident(RubyMatchData)operator(\))ident(match)operator(;) - - type(int) ident(beg) operator(=) ident(m)operator(.)ident(regs) operator(==) pre_constant(null) operator(?) ident(m)operator(.)ident(begin) operator(:) ident(m)operator(.)ident(regs)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - - keyword(if)operator(()ident(beg) operator(==) operator(-)integer(1)operator(\)) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(RubyString) ident(str) operator(=) ident(m)operator(.)ident(str)operator(.)ident(makeShared)operator(()ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(0)operator(,) ident(beg)operator(\))operator(;) - ident(str)operator(.)ident(infectBy)operator(()ident(match)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_reg_match_post - * - */) - directive(public) directive(static) ident(IRubyObject) ident(match_post)operator(()ident(IRubyObject) ident(match)operator(\)) operator({) - keyword(if) operator(()ident(match)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(match)operator(;) - ident(RubyMatchData) ident(m) operator(=) operator(()ident(RubyMatchData)operator(\))ident(match)operator(;) - - type(int) ident(end)operator(;) - keyword(if) operator(()ident(m)operator(.)ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(m)operator(.)ident(begin) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(end) operator(=) ident(m)operator(.)ident(end)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(m)operator(.)ident(regs)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(end) operator(=) ident(m)operator(.)ident(regs)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - operator(}) - - ident(RubyString) ident(str) operator(=) ident(m)operator(.)ident(str)operator(.)ident(makeShared)operator(()ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(end)operator(,) ident(m)operator(.)ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(-) ident(end)operator(\))operator(;) - ident(str)operator(.)ident(infectBy)operator(()ident(match)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_reg_match_last - * - */) - directive(public) directive(static) ident(IRubyObject) ident(match_last)operator(()ident(IRubyObject) ident(match)operator(\)) operator({) - keyword(if) operator(()ident(match)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(match)operator(;) - ident(RubyMatchData) ident(m) operator(=) operator(()ident(RubyMatchData)operator(\))ident(match)operator(;) - - keyword(if) operator(()ident(m)operator(.)ident(regs) operator(==) pre_constant(null) operator(||) ident(m)operator(.)ident(regs)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - type(int) ident(i)operator(;) - keyword(for) operator(()ident(i)operator(=)ident(m)operator(.)ident(regs)operator(.)ident(numRegs)operator(-)integer(1)operator(;) ident(m)operator(.)ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(==)operator(-)integer(1) operator(&&) ident(i)operator(>)integer(0)operator(;) ident(i)operator(--)operator(\))operator(;) - keyword(if) operator(()ident(i) operator(==) integer(0)operator(\)) keyword(return) ident(match)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(nth_match)operator(()ident(i)operator(,)ident(match)operator(\))operator(;) - operator(}) - - comment(/** rb_reg_s_union - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(union)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(union)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(newRegexp)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(ByteList)operator(.)ident(create)operator(()string<delimiter(")content((?!\))delimiter(")>operator(\))operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(IRubyObject) ident(v) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRegexp)operator(()operator(\))operator(,) integer(0)operator(,) string<delimiter(")content(to_regexp)delimiter(")>operator(\))operator(;) - keyword(if)operator(()operator(!)ident(v)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(v)operator(;) - operator(}) keyword(else) operator({) - comment(// newInstance here) - keyword(return) ident(newRegexp)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(quote)operator(()ident(recv)operator(,)ident(args)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(KCode) ident(kcode) operator(=) pre_constant(null)operator(;) - ident(IRubyObject) ident(kcode_re) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(RubyString) ident(source) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()operator(\))operator(;) - ident(IRubyObject)type([]) ident(_args) operator(=) keyword(new) ident(IRubyObject)operator([)integer(3)operator(])operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()integer(0) operator(<) ident(i)operator(\)) operator({) - ident(source)operator(.)ident(cat)operator(()operator(()type(byte)operator(\))string<delimiter(')content(|)delimiter(')>operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(v) operator(=) ident(TypeConverter)operator(.)ident(convertToTypeWithCheck)operator(()ident(args)operator([)ident(i)operator(])operator(,) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getRegexp)operator(()operator(\))operator(,) integer(0)operator(,) string<delimiter(")content(to_regexp)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(v)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()operator(()ident(RubyRegexp)operator(\))ident(v)operator(\))operator(.)ident(isKCodeDefault)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(kcode) operator(==) pre_constant(null)operator(\)) operator({) - ident(kcode_re) operator(=) ident(v)operator(;) - ident(kcode) operator(=) operator(()operator(()ident(RubyRegexp)operator(\))ident(v)operator(\))operator(.)ident(kcode)operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(()operator(()ident(RubyRegexp)operator(\))ident(v)operator(\))operator(.)ident(kcode) operator(!=) ident(kcode)operator(\)) operator({) - ident(IRubyObject) ident(str1) operator(=) ident(kcode_re)operator(.)ident(inspect)operator(()operator(\))operator(;) - ident(IRubyObject) ident(str2) operator(=) ident(v)operator(.)ident(inspect)operator(()operator(\))operator(;) - keyword(throw) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(mixed kcode )delimiter(")> operator(+) ident(str1) operator(+) string<delimiter(")content( and )delimiter(")> operator(+) ident(str2)operator(\))operator(;) - operator(}) - operator(}) - ident(v) operator(=) operator(()operator(()ident(RubyRegexp)operator(\))ident(v)operator(\))operator(.)ident(to_s)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(v) operator(=) ident(quote)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(args)operator([)ident(i)operator(])operator(})operator(\))operator(;) - operator(}) - ident(source)operator(.)ident(append)operator(()ident(v)operator(\))operator(;) - operator(}) - - ident(_args)operator([)integer(0)operator(]) operator(=) ident(source)operator(;) - ident(_args)operator([)integer(1)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(kcode) operator(==) pre_constant(null)operator(\)) operator({) - ident(_args)operator([)integer(2)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(NONE)operator(\)) operator({) - ident(_args)operator([)integer(2)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(n)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(EUC)operator(\)) operator({) - ident(_args)operator([)integer(2)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(e)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(SJIS)operator(\)) operator({) - ident(_args)operator([)integer(2)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(s)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(kcode) operator(==) ident(KCode)operator(.)ident(UTF8)operator(\)) operator({) - ident(_args)operator([)integer(2)operator(]) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(u)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(new)delimiter(")>operator(,) ident(_args)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_reg_names - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(names)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(names)operator(()operator(\)) operator({) - keyword(if) operator(()ident(pattern)operator(.)ident(numberOfNames)operator(()operator(\)) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newEmptyArray)operator(()operator(\))operator(;) - - ident(RubyArray) ident(ary) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(pattern)operator(.)ident(numberOfNames)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()pre_type(Iterator)operator(<)ident(NameEntry)operator(>) ident(i) operator(=) ident(pattern)operator(.)ident(namedBackrefIterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(NameEntry) ident(e) operator(=) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - ident(ary)operator(.)ident(append)operator(()ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(e)operator(.)ident(name)operator(,) ident(e)operator(.)ident(nameP)operator(,) ident(e)operator(.)ident(nameEnd) operator(-) ident(e)operator(.)ident(nameP)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(ary)operator(;) - operator(}) - - comment(/** rb_reg_named_captures - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(named_captures)delimiter(")>operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(named_captures)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyHash) ident(hash) operator(=) ident(RubyHash)operator(.)ident(newHash)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(pattern)operator(.)ident(numberOfNames)operator(()operator(\)) operator(==) integer(0)operator(\)) keyword(return) ident(hash)operator(;) - - keyword(for) operator(()pre_type(Iterator)operator(<)ident(NameEntry)operator(>) ident(i) operator(=) ident(pattern)operator(.)ident(namedBackrefIterator)operator(()operator(\))operator(;) ident(i)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(NameEntry) ident(e) operator(=) ident(i)operator(.)ident(next)operator(()operator(\))operator(;) - type(int)type([])ident(backrefs) operator(=) ident(e)operator(.)ident(getBackRefs)operator(()operator(\))operator(;) - ident(RubyArray) ident(ary) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(backrefs)operator(.)ident(length)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(backref) operator(:) ident(backrefs)operator(\)) ident(ary)operator(.)ident(append)operator(()ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(backref)operator(\))operator(\))operator(;) - ident(hash)operator(.)ident(fastASet)operator(()ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(e)operator(.)ident(name)operator(,) ident(e)operator(.)ident(nameP)operator(,) ident(e)operator(.)ident(nameEnd) operator(-) ident(e)operator(.)ident(nameP)operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(,) ident(ary)operator(\))operator(;) - operator(}) - keyword(return) ident(hash)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyRegexp) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(RubyRegexp) ident(result) operator(=) ident(newRegexp)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(,) ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyRegexp) ident(regexp)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(regexp)operator(\))operator(;) - ident(output)operator(.)ident(writeString)operator(()keyword(new) pre_type(String)operator(()ident(regexp)operator(.)ident(str)operator(.)ident(bytes)operator(,)ident(regexp)operator(.)ident(str)operator(.)ident(begin)operator(,)ident(regexp)operator(.)ident(str)operator(.)ident(realSize)operator(\))operator(\))operator(;) - ident(output)operator(.)ident(writeInt)operator(()ident(regexp)operator(.)ident(pattern)operator(.)ident(getOptions)operator(()operator(\)) operator(&) ident(EMBEDDABLE)operator(\))operator(;) - operator(}) -operator(}) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * - * @author nicksieger - */) -directive(public) type(interface) class(RubyRuntimeAdapter) operator({) - ident(IRubyObject) ident(eval)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(script)operator(\))operator(;) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.CallType)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(org.jruby.util.SignalFacade)operator(;) -keyword(import) include(org.jruby.util.NoFunctionalitySignalFacade)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Signal)delimiter(")>operator(\)) -directive(public) type(class) class(RubySignal) operator({) - directive(private) directive(final) directive(static) ident(SignalFacade) ident(SIGNALS) operator(=) ident(getSignalFacade)operator(()operator(\))operator(;) - - directive(private) directive(final) directive(static) ident(SignalFacade) ident(getSignalFacade)operator(()operator(\)) operator({) - keyword(try) operator({) - pre_type(Class) ident(realFacadeClass) operator(=) pre_type(Class)operator(.)ident(forName)operator(()string<delimiter(")content(org.jruby.util.SunSignalFacade)delimiter(")>operator(\))operator(;) - keyword(return) operator(()ident(SignalFacade)operator(\))ident(realFacadeClass)operator(.)ident(newInstance)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()pre_type(Throwable) ident(e)operator(\)) operator({) - keyword(return) keyword(new) ident(NoFunctionalitySignalFacade)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// NOTE: The indicies here match exactly the signal values; do not reorder) - directive(public) directive(static) directive(final) pre_type(String)type([]) ident(NAMES) operator(=) operator({) - string<delimiter(")content(EXIT)delimiter(")>operator(,) string<delimiter(")content(HUP)delimiter(")>operator(,) string<delimiter(")content(INT)delimiter(")>operator(,) string<delimiter(")content(QUIT)delimiter(")>operator(,) string<delimiter(")content(ILL)delimiter(")>operator(,) string<delimiter(")content(TRAP)delimiter(")>operator(,) string<delimiter(")content(ABRT)delimiter(")>operator(,) string<delimiter(")content(EMT)delimiter(")>operator(,) - string<delimiter(")content(FPE)delimiter(")>operator(,) string<delimiter(")content(KILL)delimiter(")>operator(,) string<delimiter(")content(BUS)delimiter(")>operator(,) string<delimiter(")content(SEGV)delimiter(")>operator(,) string<delimiter(")content(SYS)delimiter(")>operator(,) string<delimiter(")content(PIPE)delimiter(")>operator(,) string<delimiter(")content(ALRM)delimiter(")>operator(,) string<delimiter(")content(TERM)delimiter(")>operator(,) string<delimiter(")content(URG)delimiter(")>operator(,) - string<delimiter(")content(STOP)delimiter(")>operator(,) string<delimiter(")content(TSTP)delimiter(")>operator(,) string<delimiter(")content(CONT)delimiter(")>operator(,) string<delimiter(")content(CHLD)delimiter(")>operator(,) string<delimiter(")content(TTIN)delimiter(")>operator(,) string<delimiter(")content(TTOU)delimiter(")>operator(,) string<delimiter(")content(IO)delimiter(")>operator(,) string<delimiter(")content(XCPU)delimiter(")>operator(,) - string<delimiter(")content(XFSZ)delimiter(")>operator(,) string<delimiter(")content(VTALRM)delimiter(")>operator(,) string<delimiter(")content(PROF)delimiter(")>operator(,) string<delimiter(")content(WINCH)delimiter(")>operator(,) string<delimiter(")content(INFO)delimiter(")>operator(,) string<delimiter(")content(USR1)delimiter(")>operator(,) string<delimiter(")content(USR2)delimiter(")>operator(})operator(;) - - directive(public) directive(static) type(void) ident(createSignal)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(mSignal) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Signal)delimiter(")>operator(\))operator(;) - - ident(mSignal)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubySignal)operator(.)ident(class)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(trap)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(trap)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getLoadService)operator(()operator(\))operator(.)ident(require)operator(()string<delimiter(")content(jsignal)delimiter(")>operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(,) string<delimiter(")content(__jtrap)delimiter(")>operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(list)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(list)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyHash) ident(names) operator(=) ident(RubyHash)operator(.)ident(newHash)operator(()ident(runtime)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(NAMES)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(names)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()ident(NAMES)operator([)ident(i)operator(])operator(\))operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(\))operator(;) - operator(}) - comment(// IOT is also 6) - ident(names)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(IOT)delimiter(")>operator(\))operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(6)operator(\))operator(\))operator(;) - comment(// CLD is also 20) - ident(names)operator(.)ident(op_aset)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(CLD)delimiter(")>operator(\))operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()integer(20)operator(\))operator(\))operator(;) - keyword(return) ident(names)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(__jtrap_kernel)delimiter(")>operator(,) ident(required) operator(=) integer(3)operator(,)ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(__jtrap_kernel)operator(()directive(final) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(,) ident(IRubyObject) ident(arg3)operator(\)) operator({) - keyword(return) ident(SIGNALS)operator(.)ident(trap)operator(()ident(recv)operator(,) ident(arg1)operator(,) ident(arg2)operator(,) ident(arg3)operator(\))operator(;) - operator(}) -operator(})comment(// RubySignal) -comment(/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2004 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C\) 2005 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * Copyright (C\) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(static) include(org.jruby.anno.FrameField.BACKREF)operator(;) -keyword(import) include(static) include(org.jruby.anno.FrameField.LASTLINE)operator(;) - -keyword(import) include(java.io.UnsupportedEncodingException)operator(;) -keyword(import) include(java.util.Locale)operator(;) - -keyword(import) include(org.joni.Matcher)operator(;) -keyword(import) include(org.joni.Option)operator(;) -keyword(import) include(org.joni.Regex)operator(;) -keyword(import) include(org.joni.Region)operator(;) -keyword(import) include(org.joni.encoding.Encoding)operator(;) -keyword(import) include(org.joni.encoding.specific.ASCIIEncoding)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.java.MiniJava)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.Numeric)operator(;) -keyword(import) include(org.jruby.util.Pack)operator(;) -keyword(import) include(org.jruby.util.Sprintf)operator(;) -keyword(import) include(org.jruby.util.string.JavaCrypt)operator(;) - -comment(/** - * Implementation of Ruby String class - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(String)delimiter(")>operator(,) ident(include)operator(=)operator({)string<delimiter(")content(Enumerable)delimiter(")>operator(,) string<delimiter(")content(Comparable)delimiter(")>operator(})operator(\)) -directive(public) type(class) class(RubyString) directive(extends) ident(RubyObject) operator({) - directive(private) directive(static) directive(final) ident(ASCIIEncoding) ident(ASCII) operator(=) ident(ASCIIEncoding)operator(.)ident(INSTANCE)operator(;) - - comment(// string doesn't share any resources) - directive(private) directive(static) directive(final) type(int) ident(SHARE_LEVEL_NONE) operator(=) integer(0)operator(;) - comment(// string has it's own ByteList, but it's pointing to a shared buffer (byte[]\)) - directive(private) directive(static) directive(final) type(int) ident(SHARE_LEVEL_BUFFER) operator(=) integer(1)operator(;) - comment(// string doesn't have it's own ByteList (values\)) - directive(private) directive(static) directive(final) type(int) ident(SHARE_LEVEL_BYTELIST) operator(=) integer(2)operator(;) - - directive(private) directive(volatile) type(int) ident(shareLevel) operator(=) ident(SHARE_LEVEL_NONE)operator(;) - - directive(private) ident(ByteList) ident(value)operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(STRING_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createStringClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(stringClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(String)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(STRING_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setString)operator(()ident(stringClass)operator(\))operator(;) - ident(stringClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(STRING)operator(;) - ident(stringClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - annotation(@Override) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubyString)operator(;) - operator(}) - operator(})operator(;) - - ident(stringClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getComparable)operator(()operator(\))operator(\))operator(;) - ident(stringClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - ident(stringClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyString)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(stringClass)operator(;) - operator(}) - - comment(/** short circuit for String key comparison - * - */) - annotation(@Override) - directive(public) directive(final) type(boolean) ident(eql)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other)operator(.)ident(getMetaClass)operator(()operator(\)) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getString)operator(()operator(\))operator(\)) keyword(return) ident(value)operator(.)ident(equal)operator(()operator(()operator(()ident(RubyString)operator(\))ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - keyword(return) local_variable(super)operator(.)ident(eql)operator(()ident(other)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(CharSequence) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - keyword(assert) ident(value) operator(!=) pre_constant(null)operator(;) - local_variable(this)operator(.)ident(value) operator(=) keyword(new) ident(ByteList)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(value)operator(\))operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) type(byte)type([]) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - keyword(assert) ident(value) operator(!=) pre_constant(null)operator(;) - local_variable(this)operator(.)ident(value) operator(=) keyword(new) ident(ByteList)operator(()ident(value)operator(\))operator(;) - operator(}) - - directive(private) ident(RubyString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) ident(ByteList) ident(value)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - keyword(assert) ident(value) operator(!=) pre_constant(null)operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - directive(private) ident(RubyString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) ident(ByteList) ident(value)operator(,) type(boolean) ident(objectSpace)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) ident(objectSpace)operator(\))operator(;) - keyword(assert) ident(value) operator(!=) pre_constant(null)operator(;) - local_variable(this)operator(.)ident(value) operator(=) ident(value)operator(;) - operator(}) - - - comment(/** Create a new String which uses the same Ruby runtime and the same - * class like this String. - * - * This method should be used to satisfy RCR #38. - * @deprecated - */) - directive(public) ident(RubyString) ident(newString)operator(()pre_type(CharSequence) ident(s)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getType)operator(()operator(\))operator(,) ident(s)operator(\))operator(;) - operator(}) - - comment(/** Create a new String which uses the same Ruby runtime and the same - * class like this String. - * - * This method should be used to satisfy RCR #38. - * @deprecated - */) - directive(public) ident(RubyString) ident(newString)operator(()ident(ByteList) ident(s)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(s)operator(\))operator(;) - operator(}) - - comment(// Methods of the String class (rb_str_*\):) - - comment(/** rb_str_new2 - * - */) - directive(public) directive(static) ident(RubyString) ident(newString)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(CharSequence) ident(str)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(str)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newEmptyString)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(newEmptyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newEmptyString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(metaClass)operator(\)) operator({) - ident(RubyString) ident(empty) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(metaClass)operator(,) ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(\))operator(;) - ident(empty)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - keyword(return) ident(empty)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newUnicodeString)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(str)operator(\)) operator({) - keyword(try) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(str)operator(.)ident(getBytes)operator(()string<delimiter(")content(UTF8)delimiter(")>operator(\))operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(UnsupportedEncodingException) ident(uee)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(str)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Deprecated) - directive(public) directive(static) ident(RubyString) ident(newString)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(clazz)operator(,) pre_type(CharSequence) ident(str)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(clazz)operator(,) ident(str)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newString)operator(()ident(Ruby) ident(runtime)operator(,) type(byte)type([]) ident(bytes)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(bytes)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newString)operator(()ident(Ruby) ident(runtime)operator(,) type(byte)type([]) ident(bytes)operator(,) type(int) ident(start)operator(,) type(int) ident(length)operator(\)) operator({) - type(byte)type([]) ident(copy) operator(=) keyword(new) type(byte)operator([)ident(length)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(bytes)operator(,) ident(start)operator(,) ident(copy)operator(,) integer(0)operator(,) ident(length)operator(\))operator(;) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(copy)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newString)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(bytes)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(bytes)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newStringLight)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(bytes)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(bytes)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newStringShared)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyString) ident(orig)operator(\)) operator({) - ident(orig)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - ident(RubyString) ident(str) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(orig)operator(.)ident(value)operator(\))operator(;) - ident(str)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newStringShared)operator(()ident(Ruby) ident(runtime)operator(,) ident(ByteList) ident(bytes)operator(\)) operator({) - keyword(return) ident(newStringShared)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) ident(bytes)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newStringShared)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(clazz)operator(,) ident(ByteList) ident(bytes)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(clazz)operator(,) ident(bytes)operator(\))operator(;) - ident(str)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(newStringShared)operator(()ident(Ruby) ident(runtime)operator(,) type(byte)type([]) ident(bytes)operator(,) type(int) ident(start)operator(,) type(int) ident(length)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(bytes)operator(,) ident(start)operator(,) ident(length)operator(,) pre_constant(false)operator(\))operator(\))operator(;) - ident(str)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BUFFER)operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(STRING)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) pre_type(String)operator(.)ident(class)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyString) ident(convertToString)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(String) ident(toString)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_dup - * - */) - annotation(@Deprecated) - directive(public) directive(final) ident(RubyString) ident(strDup)operator(()operator(\)) operator({) - keyword(return) ident(strDup)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(final) ident(RubyString) ident(strDup)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) ident(strDup)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Deprecated) - directive(final) ident(RubyString) ident(strDup)operator(()ident(RubyClass) ident(clazz)operator(\)) operator({) - keyword(return) ident(strDup)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(final) ident(RubyString) ident(strDup)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(clazz)operator(\)) operator({) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - ident(RubyString) ident(dup) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(clazz)operator(,) ident(value)operator(\))operator(;) - ident(dup)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - - ident(dup)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(dup)operator(;) - operator(}) - - directive(public) directive(final) ident(RubyString) ident(makeShared)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(index)operator(,) type(int) ident(len)operator(\)) operator({) - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - ident(s)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(s)operator(;) - operator(}) - - keyword(if) operator(()ident(shareLevel) operator(==) ident(SHARE_LEVEL_NONE)operator(\)) ident(shareLevel) operator(=) ident(SHARE_LEVEL_BUFFER)operator(;) - ident(RubyString) ident(shared) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(value)operator(.)ident(makeShared)operator(()ident(index)operator(,) ident(len)operator(\))operator(\))operator(;) - ident(shared)operator(.)ident(shareLevel) operator(=) ident(SHARE_LEVEL_BUFFER)operator(;) - - ident(shared)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(shared)operator(;) - operator(}) - - directive(final) type(void) ident(modifyCheck)operator(()operator(\)) operator({) - keyword(if) operator(()operator(()ident(flags) operator(&) ident(FROZEN_F)operator(\)) operator(!=) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newFrozenError)operator(()string<delimiter(")content(string)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't modify string)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(final) type(void) ident(modifyCheck)operator(()type(byte)type([]) ident(b)operator(,) type(int) ident(len)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(bytes) operator(!=) ident(b) operator(||) ident(value)operator(.)ident(realSize) operator(!=) ident(len)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(string modified)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(frozenCheck)operator(()operator(\)) operator({) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(string frozen)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_str_modify - * - */) - directive(public) directive(final) type(void) ident(modify)operator(()operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(shareLevel) operator(!=) ident(SHARE_LEVEL_NONE)operator(\)) operator({) - keyword(if) operator(()ident(shareLevel) operator(==) ident(SHARE_LEVEL_BYTELIST)operator(\)) operator({) - ident(value) operator(=) ident(value)operator(.)ident(dup)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(value)operator(.)ident(unshare)operator(()operator(\))operator(;) - operator(}) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_NONE)operator(;) - operator(}) - - ident(value)operator(.)ident(invalidate)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_modify (with length bytes ensured\) - * - */) - directive(public) directive(final) type(void) ident(modify)operator(()type(int) ident(length)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(shareLevel) operator(!=) ident(SHARE_LEVEL_NONE)operator(\)) operator({) - keyword(if) operator(()ident(shareLevel) operator(==) ident(SHARE_LEVEL_BYTELIST)operator(\)) operator({) - ident(value) operator(=) ident(value)operator(.)ident(dup)operator(()ident(length)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(value)operator(.)ident(unshare)operator(()ident(length)operator(\))operator(;) - operator(}) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_NONE)operator(;) - operator(}) keyword(else) operator({) - ident(value)operator(.)ident(ensure)operator(()ident(length)operator(\))operator(;) - operator(}) - - ident(value)operator(.)ident(invalidate)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(view)operator(()ident(ByteList) ident(bytes)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - ident(value) operator(=) ident(bytes)operator(;) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_NONE)operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(view)operator(()type(byte)type([])ident(bytes)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - ident(value)operator(.)ident(replace)operator(()ident(bytes)operator(\))operator(;) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_NONE)operator(;) - - ident(value)operator(.)ident(invalidate)operator(()operator(\))operator(;) - operator(}) - - directive(private) directive(final) type(void) ident(view)operator(()type(int) ident(index)operator(,) type(int) ident(len)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(shareLevel) operator(!=) ident(SHARE_LEVEL_NONE)operator(\)) operator({) - keyword(if) operator(()ident(shareLevel) operator(==) ident(SHARE_LEVEL_BYTELIST)operator(\)) operator({) - comment(// if len == 0 then shared empty) - ident(value) operator(=) ident(value)operator(.)ident(makeShared)operator(()ident(index)operator(,) ident(len)operator(\))operator(;) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_BUFFER)operator(;) - operator(}) keyword(else) operator({) - ident(value)operator(.)ident(view)operator(()ident(index)operator(,) ident(len)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(value)operator(.)ident(view)operator(()ident(index)operator(,) ident(len)operator(\))operator(;) - comment(// FIXME this below is temporary, but its much safer for COW (it prevents not shared Strings with begin != 0\)) - comment(// this allows now e.g.: ByteList#set not to be begin aware) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_BUFFER)operator(;) - operator(}) - - ident(value)operator(.)ident(invalidate)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) pre_type(String) ident(bytesToString)operator(()type(byte)type([]) ident(bytes)operator(,) type(int) ident(beg)operator(,) type(int) ident(len)operator(\)) operator({) - keyword(return) keyword(new) pre_type(String)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(bytes)operator(,) ident(beg)operator(,) ident(len)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) pre_type(String) ident(byteListToString)operator(()ident(ByteList) ident(bytes)operator(\)) operator({) - keyword(return) ident(bytesToString)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) pre_type(String) ident(bytesToString)operator(()type(byte)type([]) ident(bytes)operator(\)) operator({) - keyword(return) ident(bytesToString)operator(()ident(bytes)operator(,) integer(0)operator(,) ident(bytes)operator(.)ident(length)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(byte)type([]) ident(stringToBytes)operator(()pre_type(String) ident(string)operator(\)) operator({) - keyword(return) ident(ByteList)operator(.)ident(plain)operator(()ident(string)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isDigit)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(c) operator(>=) string<delimiter(')content(0)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(9)delimiter(')>operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isUpper)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(c) operator(>=) string<delimiter(')content(A)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(Z)delimiter(')>operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isLower)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(c) operator(>=) string<delimiter(')content(a)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(z)delimiter(')>operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isLetter)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(isUpper)operator(()ident(c)operator(\)) operator(||) ident(isLower)operator(()ident(c)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isAlnum)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(isUpper)operator(()ident(c)operator(\)) operator(||) ident(isLower)operator(()ident(c)operator(\)) operator(||) ident(isDigit)operator(()ident(c)operator(\))operator(;) - operator(}) - - directive(public) directive(static) type(boolean) ident(isPrint)operator(()type(int) ident(c)operator(\)) operator({) - keyword(return) ident(c) operator(>=) hex(0x20) operator(&&) ident(c) operator(<=) hex(0x7E)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyString) ident(asString)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(checkStringType)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_s)delimiter(")>operator(,) string<delimiter(")content(to_str)delimiter(")>operator(})operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(strDup)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/* rb_str_cmp_m */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(op_cmp)operator(()operator(()ident(RubyString)operator(\))ident(other)operator(\))operator(\))operator(;) - operator(}) - - comment(// deal with case when "other" is not a string) - keyword(if) operator(()ident(other)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\)) operator(&&) ident(other)operator(.)ident(respondsTo)operator(()string<delimiter(")content(<=>)delimiter(")>operator(\))operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - - keyword(if) operator(()ident(result) keyword(instanceof) ident(RubyNumeric)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyNumeric)operator(\)) ident(result)operator(\))operator(.)ident(op_uminus)operator(()ident(context)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)ident(other)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_str)delimiter(")>operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EQUALEQUAL)operator(,) string<delimiter(")content(==)delimiter(")>operator(,) local_variable(this)operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(value)operator(.)ident(equal)operator(()operator(()operator(()ident(RubyString)operator(\))ident(other)operator(\))operator(.)ident(value)operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(other)operator(.)ident(convertToString)operator(()operator(\))operator(;) - - ident(ByteList) ident(result) operator(=) keyword(new) ident(ByteList)operator(()ident(value)operator(.)ident(realSize) operator(+) ident(str)operator(.)ident(value)operator(.)ident(realSize)operator(\))operator(;) - ident(result)operator(.)ident(realSize) operator(=) ident(value)operator(.)ident(realSize) operator(+) ident(str)operator(.)ident(value)operator(.)ident(realSize)operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(result)operator(.)ident(bytes)operator(,) integer(0)operator(,) ident(value)operator(.)ident(realSize)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(str)operator(.)ident(value)operator(.)ident(bytes)operator(,) ident(str)operator(.)ident(value)operator(.)ident(begin)operator(,) ident(result)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(realSize)operator(,) ident(str)operator(.)ident(value)operator(.)ident(realSize)operator(\))operator(;) - - ident(RubyString) ident(resultStr) operator(=) ident(newString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(result)operator(\))operator(;) - keyword(if) operator(()ident(isTaint)operator(()operator(\)) operator(||) ident(str)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(resultStr)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - keyword(return) ident(resultStr)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(*)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_mul)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(RubyInteger) ident(otherInteger) operator(=) operator(()ident(RubyInteger)operator(\)) ident(other)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - type(long) ident(len) operator(=) ident(otherInteger)operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative argument)delimiter(")>operator(\))operator(;) - - comment(// we limit to int because ByteBuffer can only allocate int sizes) - keyword(if) operator(()ident(len) operator(>) integer(0) operator(&&) pre_type(Integer)operator(.)ident(MAX_VALUE) operator(/) ident(len) operator(<) ident(value)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument too big)delimiter(")>operator(\))operator(;) - operator(}) - ident(ByteList) ident(newBytes) operator(=) keyword(new) ident(ByteList)operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(*) operator(()type(int)operator(\))ident(len)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(newBytes)operator(.)ident(append)operator(()ident(value)operator(\))operator(;) - operator(}) - - ident(RubyString) ident(newString) operator(=) keyword(new) ident(RubyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(newBytes)operator(\))operator(;) - ident(newString)operator(.)ident(setTaint)operator(()ident(isTaint)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(newString)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(%)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_format)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - directive(final) ident(RubyString) ident(s)operator(;) - - ident(IRubyObject) ident(tmp) operator(=) ident(arg)operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(tmp) operator(=) ident(arg)operator(;) - operator(}) - - comment(// FIXME: Should we make this work with platform's locale,) - comment(// or continue hardcoding US?) - ident(s) operator(=) ident(Sprintf)operator(.)ident(sprintf)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) pre_type(Locale)operator(.)ident(US)operator(,) ident(value)operator(,) ident(tmp)operator(\))operator(;) - - ident(s)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(s)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(hashCode)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(hashCode)operator(()operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) pre_constant(true)operator(;) - - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(RubyString) ident(string) operator(=) operator(()ident(RubyString)operator(\)) ident(other)operator(;) - - keyword(if) operator(()ident(string)operator(.)ident(value)operator(.)ident(equal)operator(()ident(value)operator(\))operator(\)) keyword(return) pre_constant(true)operator(;) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - comment(/** rb_obj_as_string - * - */) - directive(public) directive(static) ident(RubyString) ident(objAsString)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubyString)operator(\)) keyword(return) operator(()ident(RubyString)operator(\)) ident(obj)operator(;) - - ident(IRubyObject) ident(str) operator(=) ident(obj)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)operator(()ident(str) keyword(instanceof) ident(RubyString)operator(\))operator(\)) keyword(return) operator(()ident(RubyString)operator(\)) ident(obj)operator(.)ident(anyToString)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(obj)operator(.)ident(isTaint)operator(()operator(\))operator(\)) ident(str)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - - keyword(return) operator(()ident(RubyString)operator(\)) ident(str)operator(;) - operator(}) - - comment(/** rb_str_cmp - * - */) - directive(public) type(int) ident(op_cmp)operator(()ident(RubyString) ident(other)operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(cmp)operator(()ident(other)operator(.)ident(value)operator(\))operator(;) - operator(}) - - comment(/** rb_to_id - * - */) - annotation(@Override) - directive(public) pre_type(String) ident(asJavaString)operator(()operator(\)) operator({) - comment(// TODO: This used to intern; but it didn't appear to change anything) - comment(// turning that off, and it's unclear if it was needed. Plus, we intern) - comment(// ) - keyword(return) ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(doClone)operator(()operator(\))operator({) - keyword(return) ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(dup)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(RubyString) ident(cat)operator(()type(byte)type([]) ident(str)operator(\)) operator({) - ident(modify)operator(()ident(value)operator(.)ident(realSize) operator(+) ident(str)operator(.)ident(length)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(str)operator(,) integer(0)operator(,) ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) ident(str)operator(.)ident(length)operator(\))operator(;) - ident(value)operator(.)ident(realSize) operator(+=) ident(str)operator(.)ident(length)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) ident(RubyString) ident(cat)operator(()type(byte)type([]) ident(str)operator(,) type(int) ident(beg)operator(,) type(int) ident(len)operator(\)) operator({) - ident(modify)operator(()ident(value)operator(.)ident(realSize) operator(+) ident(len)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(str)operator(,) ident(beg)operator(,) ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) ident(len)operator(\))operator(;) - ident(value)operator(.)ident(realSize) operator(+=) ident(len)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) ident(RubyString) ident(cat)operator(()ident(ByteList) ident(str)operator(\)) operator({) - ident(modify)operator(()ident(value)operator(.)ident(realSize) operator(+) ident(str)operator(.)ident(realSize)operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(str)operator(.)ident(bytes)operator(,) ident(str)operator(.)ident(begin)operator(,) ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) ident(str)operator(.)ident(realSize)operator(\))operator(;) - ident(value)operator(.)ident(realSize) operator(+=) ident(str)operator(.)ident(realSize)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) ident(RubyString) ident(cat)operator(()type(byte) ident(ch)operator(\)) operator({) - ident(modify)operator(()ident(value)operator(.)ident(realSize) operator(+) integer(1)operator(\))operator(;) - ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(]) operator(=) ident(ch)operator(;) - ident(value)operator(.)ident(realSize)operator(++)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_replace_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(replace)delimiter(")>operator(,) string<delimiter(")content(initialize_copy)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyString) ident(replace)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) local_variable(this)operator(;) - - ident(modifyCheck)operator(()operator(\))operator(;) - - ident(RubyString) ident(otherStr) operator(=) ident(stringValue)operator(()ident(other)operator(\))operator(;) - - ident(otherStr)operator(.)ident(shareLevel) operator(=) ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - - ident(value) operator(=) ident(otherStr)operator(.)ident(value)operator(;) - - ident(infectBy)operator(()ident(other)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reverse)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(reverse)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(<=) integer(1)operator(\)) keyword(return) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - ident(ByteList) ident(buf) operator(=) keyword(new) ident(ByteList)operator(()ident(value)operator(.)ident(length)operator(()operator(\))operator(+)integer(2)operator(\))operator(;) - ident(buf)operator(.)ident(realSize) operator(=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - type(int) ident(src) operator(=) ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(;) - type(int) ident(dst) operator(=) integer(0)operator(;) - - keyword(while) operator(()ident(src) operator(>=) integer(0)operator(\)) ident(buf)operator(.)ident(set)operator(()ident(dst)operator(++)operator(,) ident(value)operator(.)ident(get)operator(()ident(src)operator(--)operator(\))operator(\))operator(;) - - ident(RubyString) ident(rev) operator(=) keyword(new) ident(RubyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(buf)operator(\))operator(;) - ident(rev)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(rev)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reverse!)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(reverse_bang)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(>) integer(1)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(/) integer(2)operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - type(byte) ident(b) operator(=) operator(()type(byte)operator(\)) ident(value)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - - ident(value)operator(.)ident(set)operator(()ident(i)operator(,) ident(value)operator(.)ident(get)operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) ident(i) operator(-) integer(1)operator(\))operator(\))operator(;) - ident(value)operator(.)ident(set)operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) ident(i) operator(-) integer(1)operator(,) ident(b)operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_s_new - * - */) - directive(public) directive(static) ident(RubyString) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(newString) operator(=) ident(newStringShared)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(\))operator(;) - ident(newString)operator(.)ident(setMetaClass)operator(()operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(;) - ident(newString)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(newString)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with zero or one arguments - */) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) local_variable(this)operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(initialize)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - ident(replace)operator(()ident(arg0)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(casecmp)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - type(int) ident(compare) operator(=) ident(value)operator(.)ident(caseInsensitiveCmp)operator(()ident(stringValue)operator(()ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(compare)operator(\))operator(;) - operator(}) - - comment(/** rb_str_match - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(=~)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_match)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyRegexp)operator(\)) keyword(return) operator(()operator(()ident(RubyRegexp)operator(\)) ident(other)operator(\))operator(.)ident(op_match)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(type mismatch: String given)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(other)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(=~)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** rb_str_match2 - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(~)delimiter(")>operator(,) ident(reads) operator(=) operator({)ident(LASTLINE)operator(,) ident(BACKREF)operator(})operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_match2)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(,) integer(0)operator(,) pre_constant(false)operator(\))operator(.)ident(op_match2)operator(()ident(context)operator(\))operator(;) - operator(}) - - comment(/** - * String#match(pattern\) - * - * rb_str_match_m - * - * @param pattern Regexp or String - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(match)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(pattern)operator(\)) operator({) - keyword(return) ident(getPattern)operator(()ident(pattern)operator(,) pre_constant(false)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(match)delimiter(")>operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** rb_str_capitalize - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(capitalize)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(capitalize_bang)operator(()ident(context)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_capitalize_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(capitalize!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(capitalize_bang)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte)type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - - - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - - type(int) ident(c) operator(=) ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(;) - keyword(if) operator(()ident(ASCII)operator(.)ident(isLower)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToUpper)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - - keyword(while) operator(()operator(++)ident(s) operator(<) ident(send)operator(\)) operator({) - ident(c) operator(=) operator(()type(char)operator(\))operator(()ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(\))operator(;) - keyword(if) operator(()ident(ASCII)operator(.)ident(isUpper)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToLower)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(op_cmp)operator(()operator(()ident(RubyString)operator(\)) ident(other)operator(\)) operator(>=) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_ge)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(op_cmp)operator(()operator(()ident(RubyString)operator(\)) ident(other)operator(\)) operator(>) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_gt)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(op_cmp)operator(()operator(()ident(RubyString)operator(\)) ident(other)operator(\)) operator(<=) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_le)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(op_cmp)operator(()operator(()ident(RubyString)operator(\)) ident(other)operator(\)) operator(<) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_lt)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(str_eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyString)operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - ident(RubyString) ident(otherString) operator(=) operator(()ident(RubyString)operator(\))ident(other)operator(;) - keyword(return) ident(value)operator(.)ident(equal)operator(()ident(otherString)operator(.)ident(value)operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_upcase - * - */) - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(upcase)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(upcase_bang)operator(()ident(context)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_upcase_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(upcase!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(upcase_bang)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte) type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - type(int) ident(c) operator(=) ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(;) - keyword(if) operator(()ident(ASCII)operator(.)ident(isLower)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToUpper)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - ident(s)operator(++)operator(;) - operator(}) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_downcase - * - */) - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(downcase)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(downcase_bang)operator(()ident(context)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_downcase_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(downcase!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(downcase_bang)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte) type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - type(int) ident(c) operator(=) ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(;) - keyword(if) operator(()ident(ASCII)operator(.)ident(isUpper)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToLower)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - ident(s)operator(++)operator(;) - operator(}) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_swapcase - * - */) - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(swapcase)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(swapcase_bang)operator(()ident(context)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_swapcase_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(swapcase!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(swapcase_bang)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte)type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - type(int) ident(c) operator(=) ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(;) - keyword(if) operator(()ident(ASCII)operator(.)ident(isUpper)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToLower)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(ASCII)operator(.)ident(isLower)operator(()ident(c)operator(\))operator(\)) operator({) - ident(buf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))ident(ASCIIEncoding)operator(.)ident(asciiToUpper)operator(()ident(c)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - ident(s)operator(++)operator(;) - operator(}) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_dump - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(dump)operator(()operator(\)) operator({) - ident(RubyString) ident(s) operator(=) keyword(new) ident(RubyString)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(inspectIntoByteList)operator(()pre_constant(true)operator(\))operator(\))operator(;) - ident(s)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(s)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(insert)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(indexArg)operator(,) ident(IRubyObject) ident(stringArg)operator(\)) operator({) - comment(// MRI behavior: first check for ability to convert to String...) - ident(RubyString) ident(s) operator(=) operator(()ident(RubyString)operator(\))ident(stringArg)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(ByteList) ident(insert) operator(=) ident(s)operator(.)ident(value)operator(;) - - comment(// ... and then the index) - type(int) ident(index) operator(=) operator(()type(int)operator(\)) ident(indexArg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(index) operator(<) integer(0)operator(\)) ident(index) operator(+=) ident(value)operator(.)ident(length)operator(()operator(\)) operator(+) integer(1)operator(;) - - keyword(if) operator(()ident(index) operator(<) integer(0) operator(||) ident(index) operator(>) ident(value)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(index) operator(+) string<delimiter(")content( out of range)delimiter(")>operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - ident(value)operator(.)ident(unsafeReplace)operator(()ident(index)operator(,) integer(0)operator(,) ident(insert)operator(\))operator(;) - local_variable(this)operator(.)ident(infectBy)operator(()ident(s)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_inspect - * - */) - annotation(@JRubyMethod) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(inspectIntoByteList)operator(()pre_constant(false)operator(\))operator(\))operator(;) - ident(s)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(s)operator(;) - operator(}) - - directive(private) ident(ByteList) ident(inspectIntoByteList)operator(()type(boolean) ident(ignoreKCode)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(Encoding) ident(enc) operator(=) ident(runtime)operator(.)ident(getKCode)operator(()operator(\))operator(.)ident(getEncoding)operator(()operator(\))operator(;) - directive(final) type(int) ident(length) operator(=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - ident(ByteList) ident(sb) operator(=) keyword(new) ident(ByteList)operator(()ident(length) operator(+) integer(2) operator(+) ident(length) operator(/) integer(100)operator(\))operator(;) - - ident(sb)operator(.)ident(append)operator(()string<delimiter(')content(\\")delimiter(')>operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - type(int) ident(c) operator(=) ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(&) hex(0xFF)operator(;) - - keyword(if) operator(()operator(!)ident(ignoreKCode)operator(\)) operator({) - type(int) ident(seqLength) operator(=) ident(enc)operator(.)ident(length)operator(()operator(()type(byte)operator(\))ident(c)operator(\))operator(;) - - keyword(if) operator(()ident(seqLength) operator(>) integer(1) operator(&&) operator(()ident(i) operator(+) ident(seqLength) operator(-)integer(1) operator(<) ident(length)operator(\))operator(\)) operator({) - comment(// don't escape multi-byte characters, leave them as bytes) - ident(sb)operator(.)ident(append)operator(()ident(value)operator(,) ident(i)operator(,) ident(seqLength)operator(\))operator(;) - ident(i) operator(+=) ident(seqLength) operator(-) integer(1)operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(isAlnum)operator(()ident(c)operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()operator(()type(char)operator(\))ident(c)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\")delimiter(')> operator(||) ident(c) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()operator(()type(char)operator(\))ident(c)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(#)delimiter(')> operator(&&) ident(isEVStr)operator(()ident(i)operator(,) ident(length)operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()operator(()type(char)operator(\))ident(c)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(isPrint)operator(()ident(c)operator(\))operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()operator(()type(char)operator(\))ident(c)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(n)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\r)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(r)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\t)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(t)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\f)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(f)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\u000B)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(v)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\u0007)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(a)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\u0008)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(b)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(c) operator(==) string<delimiter(')content(\\u001B)delimiter(')>operator(\)) operator({) - ident(sb)operator(.)ident(append)operator(()string<delimiter(')char(\\\\)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content(e)delimiter(')>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(sb)operator(.)ident(append)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(Sprintf)operator(.)ident(sprintf)operator(()ident(runtime)operator(,)string<delimiter(")char(\\\\)content(%03o)delimiter(")>operator(,)ident(c)operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - - ident(sb)operator(.)ident(append)operator(()string<delimiter(')content(\\")delimiter(')>operator(\))operator(;) - keyword(return) ident(sb)operator(;) - operator(}) - - directive(private) type(boolean) ident(isEVStr)operator(()type(int) ident(i)operator(,) type(int) ident(length)operator(\)) operator({) - keyword(if) operator(()ident(i)operator(+)integer(1) operator(>=) ident(length)operator(\)) keyword(return) pre_constant(false)operator(;) - type(int) ident(c) operator(=) ident(value)operator(.)ident(get)operator(()ident(i)operator(+)integer(1)operator(\)) operator(&) hex(0xFF)operator(;) - - keyword(return) ident(c) operator(==) string<delimiter(')content($)delimiter(')> operator(||) ident(c) operator(==) string<delimiter(')content(@)delimiter(')> operator(||) ident(c) operator(==) string<delimiter(')content({)delimiter(')>operator(;) - operator(}) - - comment(/** rb_str_length - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(length)delimiter(")>operator(,) string<delimiter(")content(size)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyFixnum) ident(length)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_str_empty - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(empty?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(empty_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(isEmpty)operator(()operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(isEmpty)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(;) - operator(}) - - comment(/** rb_str_append - * - */) - directive(public) ident(RubyString) ident(append)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - ident(infectBy)operator(()ident(other)operator(\))operator(;) - keyword(return) ident(cat)operator(()ident(stringValue)operator(()ident(other)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - - comment(/** rb_str_concat - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(concat)delimiter(")>operator(,) string<delimiter(")content(<<)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyString) ident(concat)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(long) ident(value) operator(=) operator(()operator(()ident(RubyFixnum)operator(\)) ident(other)operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(value) operator(>=) integer(0) operator(&&) ident(value) operator(<) integer(256)operator(\)) keyword(return) ident(cat)operator(()operator(()type(byte)operator(\)) ident(value)operator(\))operator(;) - operator(}) - keyword(return) ident(append)operator(()ident(other)operator(\))operator(;) - operator(}) - - comment(/** rb_str_crypt - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(crypt)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(crypt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - ident(ByteList) ident(salt) operator(=) ident(stringValue)operator(()ident(other)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(salt)operator(.)ident(realSize) operator(<) integer(2)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(salt too short(need >=2 bytes\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(salt) operator(=) ident(salt)operator(.)ident(makeShared)operator(()integer(0)operator(,) integer(2)operator(\))operator(;) - ident(RubyString) ident(s) operator(=) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(JavaCrypt)operator(.)ident(crypt)operator(()ident(salt)operator(,) local_variable(this)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(\))operator(;) - ident(s)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - ident(s)operator(.)ident(infectBy)operator(()ident(other)operator(\))operator(;) - keyword(return) ident(s)operator(;) - operator(}) - - comment(/* RubyString aka rb_string_value */) - directive(public) directive(static) ident(RubyString) ident(stringValue)operator(()ident(IRubyObject) ident(object)operator(\)) operator({) - keyword(return) operator(()ident(RubyString)operator(\)) operator(()ident(object) keyword(instanceof) ident(RubyString) operator(?) ident(object) operator(:) - ident(object)operator(.)ident(convertToString)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args. - */) - directive(public) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_sub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_sub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(sub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(sub_bang)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */) - directive(public) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(sub_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(sub_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_sub_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(RubyRegexp) ident(rubyRegex) operator(=) ident(getPattern)operator(()ident(arg0)operator(,) pre_constant(true)operator(\))operator(;) - ident(Regex) ident(regex) operator(=) ident(rubyRegex)operator(.)ident(getPattern)operator(()operator(\))operator(;) - keyword(return) ident(subBangCommon)operator(()ident(regex)operator(,) ident(context)operator(,) pre_constant(true)operator(,) ident(rubyRegex)operator(,) ident(block)operator(,) pre_constant(null)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments (1 for 2\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/** rb_str_sub_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(sub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(repl) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(RubyRegexp) ident(rubyRegex) operator(=) ident(getPattern)operator(()ident(arg0)operator(,) pre_constant(true)operator(\))operator(;) - ident(Regex) ident(regex) operator(=) ident(rubyRegex)operator(.)ident(getPattern)operator(()operator(\))operator(;) - keyword(return) ident(subBangCommon)operator(()ident(regex)operator(,) ident(context)operator(,) pre_constant(false)operator(,) ident(rubyRegex)operator(,) ident(block)operator(,) ident(repl)operator(,) ident(repl)operator(.)ident(isTaint)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(subBangCommon)operator(()ident(Regex) ident(regex)operator(,) ident(ThreadContext) ident(context)operator(,) directive(final) type(boolean) ident(iter)operator(,) ident(RubyRegexp) ident(rubyRegex)operator(,) ident(Block) ident(block)operator(,) ident(RubyString) ident(repl)operator(,) type(boolean) ident(tainted)operator(\)) operator({) - - type(int) ident(range) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - pre_type(Matcher) ident(matcher) operator(=) ident(regex)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(range)operator(\))operator(;) - - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(;) - keyword(if) operator(()ident(matcher)operator(.)ident(search)operator(()ident(value)operator(.)ident(begin)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(iter)operator(\)) operator({) - type(byte)type([]) ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(size) operator(=) ident(value)operator(.)ident(realSize)operator(;) - ident(RubyMatchData) ident(match) operator(=) ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - ident(match)operator(.)ident(use)operator(()operator(\))operator(;) - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(repl) operator(=) ident(objAsString)operator(()ident(context)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(substr)operator(()ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(,) ident(matcher)operator(.)ident(getEnd)operator(()operator(\)) operator(-) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - ident(repl) operator(=) ident(objAsString)operator(()ident(context)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(substr)operator(()ident(region)operator(.)ident(beg)operator([)integer(0)operator(])operator(,) ident(region)operator(.)ident(end)operator([)integer(0)operator(]) operator(-) ident(region)operator(.)ident(beg)operator([)integer(0)operator(])operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(modifyCheck)operator(()ident(bytes)operator(,) ident(size)operator(\))operator(;) - ident(frozenCheck)operator(()operator(\))operator(;) - ident(frame)operator(.)ident(setBackRef)operator(()ident(match)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(repl) operator(=) ident(rubyRegex)operator(.)ident(regsub)operator(()ident(repl)operator(,) local_variable(this)operator(,) ident(matcher)operator(\))operator(;) - ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - operator(}) - - directive(final) type(int) ident(beg)operator(;) - directive(final) type(int) ident(plen)operator(;) - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(beg) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - ident(plen) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\)) operator(-) ident(beg)operator(;) - operator(}) keyword(else) operator({) - pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - ident(beg) operator(=) ident(region)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - ident(plen) operator(=) ident(region)operator(.)ident(end)operator([)integer(0)operator(]) operator(-) ident(beg)operator(;) - operator(}) - - ident(ByteList) ident(replValue) operator(=) ident(repl)operator(.)ident(value)operator(;) - keyword(if) operator(()ident(replValue)operator(.)ident(realSize) operator(>) ident(plen)operator(\)) operator({) - ident(modify)operator(()ident(value)operator(.)ident(realSize) operator(+) ident(replValue)operator(.)ident(realSize) operator(-) ident(plen)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modify)operator(()operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(repl)operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(tainted) operator(=) pre_constant(true)operator(;) - operator(}) - keyword(if) operator(()ident(replValue)operator(.)ident(realSize) operator(!=) ident(plen)operator(\)) operator({) - type(int) ident(src) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(beg) operator(+) ident(plen)operator(;) - type(int) ident(dst) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(beg) operator(+) ident(replValue)operator(.)ident(realSize)operator(;) - type(int) ident(length) operator(=) ident(value)operator(.)ident(realSize) operator(-) ident(beg) operator(-) ident(plen)operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(src)operator(,) ident(value)operator(.)ident(bytes)operator(,) ident(dst)operator(,) ident(length)operator(\))operator(;) - operator(}) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(replValue)operator(.)ident(bytes)operator(,) ident(replValue)operator(.)ident(begin)operator(,) ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(beg)operator(,) ident(replValue)operator(.)ident(realSize)operator(\))operator(;) - ident(value)operator(.)ident(realSize) operator(+=) ident(replValue)operator(.)ident(realSize) operator(-) ident(plen)operator(;) - keyword(if) operator(()ident(tainted)operator(\)) operator({) - ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) keyword(else) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */) - directive(public) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_gsub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** rb_str_gsub - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */) - directive(public) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(gsub_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(gsub_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(block)operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_gsub_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(block)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - comment(/** rb_str_gsub_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gsub!)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(gsub_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(gsub)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(block)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - directive(private) directive(final) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(Block) ident(block)operator(,) directive(final) type(boolean) ident(bang)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(RubyRegexp) ident(rubyRegex) operator(=) ident(getPattern)operator(()ident(arg0)operator(,) pre_constant(true)operator(\))operator(;) - ident(Regex) ident(regex) operator(=) ident(rubyRegex)operator(.)ident(getPattern)operator(()operator(\))operator(;) - keyword(return) ident(gsubCommon)operator(()ident(regex)operator(,) ident(context)operator(,) ident(bang)operator(,) pre_constant(true)operator(,) ident(rubyRegex)operator(,) ident(block)operator(,) pre_constant(null)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments (1 for 2\))delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(final) ident(IRubyObject) ident(gsub)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(Block) ident(block)operator(,) directive(final) type(boolean) ident(bang)operator(\)) operator({) - ident(IRubyObject) ident(repl) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(RubyRegexp) ident(rubyRegex) operator(=) ident(getPattern)operator(()ident(arg0)operator(,) pre_constant(true)operator(\))operator(;) - ident(Regex) ident(regex) operator(=) ident(rubyRegex)operator(.)ident(getPattern)operator(()operator(\))operator(;) - keyword(return) ident(gsubCommon)operator(()ident(regex)operator(,) ident(context)operator(,) ident(bang)operator(,) pre_constant(false)operator(,) ident(rubyRegex)operator(,) ident(block)operator(,) ident(repl)operator(,) ident(repl)operator(.)ident(isTaint)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(gsubCommon)operator(()ident(Regex) ident(regex)operator(,) ident(ThreadContext) ident(context)operator(,) directive(final) type(boolean) ident(bang)operator(,) directive(final) type(boolean) ident(iter)operator(,) ident(RubyRegexp) ident(rubyRegex)operator(,) ident(Block) ident(block)operator(,) ident(IRubyObject) ident(repl)operator(,) type(boolean) ident(tainted)operator(\)) operator({) - - type(int) ident(begin) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(range) operator(=) ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - pre_type(Matcher) ident(matcher) operator(=) ident(regex)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(begin)operator(,) ident(range)operator(\))operator(;) - - type(int) ident(beg) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(begin)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(;) - - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(bang) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) comment(/* bang: true, no match, no substitution */) - operator(}) - - type(int) ident(blen) operator(=) ident(value)operator(.)ident(realSize) operator(+) integer(30)operator(;) comment(/* len + margin */) - ident(ByteList) ident(dest) operator(=) keyword(new) ident(ByteList)operator(()ident(blen)operator(\))operator(;) - ident(dest)operator(.)ident(realSize) operator(=) ident(blen)operator(;) - type(int) ident(buf) operator(=) integer(0)operator(;) - type(int) ident(bp) operator(=) integer(0)operator(;) - type(int) ident(cp) operator(=) ident(value)operator(.)ident(begin)operator(;) - - type(int) ident(offset) operator(=) integer(0)operator(;) - ident(RubyString) ident(val)operator(;) - - ident(RubyMatchData) ident(match) operator(=) pre_constant(null)operator(;) - keyword(while) operator(()ident(beg) operator(>=) integer(0)operator(\)) operator({) - directive(final) type(int) ident(begz)operator(;) - directive(final) type(int) ident(endz)operator(;) - keyword(if) operator(()ident(iter)operator(\)) operator({) - type(byte)type([]) ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(size) operator(=) ident(value)operator(.)ident(realSize)operator(;) - ident(match) operator(=) ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - ident(match)operator(.)ident(use)operator(()operator(\))operator(;) - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(begz) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - ident(endz) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - ident(val) operator(=) ident(objAsString)operator(()ident(context)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(substr)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(begz)operator(,) ident(endz) operator(-) ident(begz)operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - ident(begz) operator(=) ident(region)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - ident(endz) operator(=) ident(region)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - ident(val) operator(=) ident(objAsString)operator(()ident(context)operator(,) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(substr)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(begz)operator(,) ident(endz) operator(-) ident(begz)operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(modifyCheck)operator(()ident(bytes)operator(,) ident(size)operator(\))operator(;) - keyword(if) operator(()ident(bang)operator(\)) operator({) - ident(frozenCheck)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(val) operator(=) ident(rubyRegex)operator(.)ident(regsub)operator(()operator(()ident(RubyString)operator(\)) ident(repl)operator(,) local_variable(this)operator(,) ident(matcher)operator(\))operator(;) - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(begz) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - ident(endz) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - ident(begz) operator(=) ident(region)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - ident(endz) operator(=) ident(region)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(val)operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(tainted) operator(=) pre_constant(true)operator(;) - operator(}) - ident(ByteList) ident(vbuf) operator(=) ident(val)operator(.)ident(value)operator(;) - type(int) ident(len) operator(=) operator(()ident(bp) operator(-) ident(buf)operator(\)) operator(+) operator(()ident(beg) operator(-) ident(offset)operator(\)) operator(+) ident(vbuf)operator(.)ident(realSize) operator(+) integer(3)operator(;) - keyword(if) operator(()ident(blen) operator(<) ident(len)operator(\)) operator({) - keyword(while) operator(()ident(blen) operator(<) ident(len)operator(\)) operator({) - ident(blen) operator(<)operator(<=) integer(1)operator(;) - operator(}) - ident(len) operator(=) ident(bp) operator(-) ident(buf)operator(;) - ident(dest)operator(.)ident(realloc)operator(()ident(blen)operator(\))operator(;) - ident(dest)operator(.)ident(realSize) operator(=) ident(blen)operator(;) - ident(bp) operator(=) ident(buf) operator(+) ident(len)operator(;) - operator(}) - ident(len) operator(=) ident(beg) operator(-) ident(offset)operator(;) comment(/* copy pre-match substr */) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(cp)operator(,) ident(dest)operator(.)ident(bytes)operator(,) ident(bp)operator(,) ident(len)operator(\))operator(;) - ident(bp) operator(+=) ident(len)operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(vbuf)operator(.)ident(bytes)operator(,) ident(vbuf)operator(.)ident(begin)operator(,) ident(dest)operator(.)ident(bytes)operator(,) ident(bp)operator(,) ident(vbuf)operator(.)ident(realSize)operator(\))operator(;) - ident(bp) operator(+=) ident(vbuf)operator(.)ident(realSize)operator(;) - ident(offset) operator(=) ident(endz)operator(;) - - keyword(if) operator(()ident(begz) operator(==) ident(endz)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(<=) ident(endz)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(len) operator(=) ident(regex)operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(begin) operator(+) ident(endz)operator(])operator(\))operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(begin) operator(+) ident(endz)operator(,) ident(dest)operator(.)ident(bytes)operator(,) ident(bp)operator(,) ident(len)operator(\))operator(;) - ident(bp) operator(+=) ident(len)operator(;) - ident(offset) operator(=) ident(endz) operator(+) ident(len)operator(;) - operator(}) - ident(cp) operator(=) ident(begin) operator(+) ident(offset)operator(;) - keyword(if) operator(()ident(offset) operator(>) ident(value)operator(.)ident(realSize)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(beg) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(cp)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) ident(offset)operator(\)) operator({) - type(int) ident(len) operator(=) ident(bp) operator(-) ident(buf)operator(;) - keyword(if) operator(()ident(blen) operator(-) ident(len) operator(<) ident(value)operator(.)ident(realSize) operator(-) ident(offset)operator(\)) operator({) - ident(blen) operator(=) ident(len) operator(+) ident(value)operator(.)ident(realSize) operator(-) ident(offset)operator(;) - ident(dest)operator(.)ident(realloc)operator(()ident(blen)operator(\))operator(;) - ident(bp) operator(=) ident(buf) operator(+) ident(len)operator(;) - operator(}) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(cp)operator(,) ident(dest)operator(.)ident(bytes)operator(,) ident(bp)operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(offset)operator(\))operator(;) - ident(bp) operator(+=) ident(value)operator(.)ident(realSize) operator(-) ident(offset)operator(;) - operator(}) - - keyword(if) operator(()ident(match) operator(!=) pre_constant(null)operator(\)) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(match)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - operator(}) - - ident(dest)operator(.)ident(realSize) operator(=) ident(bp) operator(-) ident(buf)operator(;) - keyword(if) operator(()ident(bang)operator(\)) operator({) - ident(view)operator(()ident(dest)operator(\))operator(;) - keyword(if) operator(()ident(tainted)operator(\)) operator({) - ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) keyword(else) operator({) - ident(RubyString) ident(destStr) operator(=) keyword(new) ident(RubyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(dest)operator(\))operator(;) - ident(destStr)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(tainted)operator(\)) operator({) - ident(destStr)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - keyword(return) ident(destStr)operator(;) - operator(}) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args. - */) - directive(public) ident(IRubyObject) ident(index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(index)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(index)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_index_m - * - */) - annotation(@JRubyMethod)operator(()ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(indexCommon)operator(()integer(0)operator(,) ident(arg0)operator(,) ident(context)operator(\))operator(;) - operator(}) - - comment(/** rb_str_index_m - * - */) - annotation(@JRubyMethod)operator(()ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(index)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - type(int) ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg1)operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) operator({) - ident(pos) operator(+=) ident(value)operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(indexCommon)operator(()ident(pos)operator(,) ident(arg0)operator(,) ident(context)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(indexCommon)operator(()type(int) ident(pos)operator(,) ident(IRubyObject) ident(sub)operator(,) ident(ThreadContext) ident(context)operator(\)) directive(throws) ident(RaiseException) operator({) - keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(RubyRegexp) ident(regSub) operator(=) operator(()ident(RubyRegexp)operator(\)) ident(sub)operator(;) - - ident(pos) operator(=) ident(regSub)operator(.)ident(adjustStartPos)operator(()local_variable(this)operator(,) ident(pos)operator(,) pre_constant(false)operator(\))operator(;) - ident(pos) operator(=) ident(regSub)operator(.)ident(search)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(pos)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(int) ident(c_int) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(sub)operator(\))operator(;) - keyword(if) operator(()ident(c_int) operator(<) hex(0x00) operator(||) ident(c_int) operator(>) hex(0xFF)operator(\)) operator({) - comment(// out of byte range) - comment(// there will be no match for sure) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - type(byte) ident(c) operator(=) operator(()type(byte)operator(\)) ident(c_int)operator(;) - type(byte)type([]) ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(end) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - - ident(pos) operator(+=) ident(value)operator(.)ident(begin)operator(;) - keyword(for) operator(()operator(;) ident(pos) operator(<) ident(end)operator(;) ident(pos)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(bytes)operator([)ident(pos)operator(]) operator(==) ident(c)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos) operator(-) ident(value)operator(.)ident(begin)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(pos) operator(=) ident(strIndex)operator(()operator(()ident(RubyString)operator(\)) ident(sub)operator(,) ident(pos)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(sub)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(type mismatch: )delimiter(")> operator(+) ident(sub)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - ident(pos) operator(=) ident(strIndex)operator(()operator(()ident(RubyString)operator(\)) ident(tmp)operator(,) ident(pos)operator(\))operator(;) - operator(}) - - keyword(return) ident(pos) operator(==) operator(-)integer(1) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(strIndex)operator(()ident(RubyString) ident(sub)operator(,) type(int) ident(offset)operator(\)) operator({) - keyword(if) operator(()ident(offset) operator(<) integer(0)operator(\)) operator({) - ident(offset) operator(+=) ident(value)operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(offset) operator(<) integer(0)operator(\)) keyword(return) operator(-)integer(1)operator(;) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(-) ident(offset) operator(<) ident(sub)operator(.)ident(value)operator(.)ident(realSize)operator(\)) keyword(return) operator(-)integer(1)operator(;) - keyword(if) operator(()ident(sub)operator(.)ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(offset)operator(;) - keyword(return) ident(value)operator(.)ident(indexOf)operator(()ident(sub)operator(.)ident(value)operator(,) ident(offset)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */) - directive(public) ident(IRubyObject) ident(rindex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(rindex)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(rindex)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_rindex_m - * - */) - annotation(@JRubyMethod)operator(()ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(rindex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(rindexCommon)operator(()ident(arg0)operator(,) ident(value)operator(.)ident(realSize)operator(,) ident(context)operator(\))operator(;) - operator(}) - - comment(/** rb_str_rindex_m - * - */) - annotation(@JRubyMethod)operator(()ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(rindex)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - type(int) ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg1)operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) operator({) - ident(pos) operator(+=) ident(value)operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(pos) operator(>) ident(value)operator(.)ident(realSize)operator(\)) ident(pos) operator(=) ident(value)operator(.)ident(realSize)operator(;) - - keyword(return) ident(rindexCommon)operator(()ident(arg0)operator(,) ident(pos)operator(,) ident(context)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(rindexCommon)operator(()directive(final) ident(IRubyObject) ident(sub)operator(,) type(int) ident(pos)operator(,) ident(ThreadContext) ident(context)operator(\)) directive(throws) ident(RaiseException) operator({) - - keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(RubyRegexp) ident(regSub) operator(=) operator(()ident(RubyRegexp)operator(\)) ident(sub)operator(;) - keyword(if) operator(()ident(regSub)operator(.)ident(length)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(pos) operator(=) ident(regSub)operator(.)ident(adjustStartPos)operator(()local_variable(this)operator(,) ident(pos)operator(,) pre_constant(true)operator(\))operator(;) - ident(pos) operator(=) ident(regSub)operator(.)ident(search)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(pos)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(pos) operator(>=) integer(0)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(\))operator(;) - operator(}) - operator(}) keyword(else) keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(pos) operator(=) ident(strRindex)operator(()operator(()ident(RubyString)operator(\)) ident(sub)operator(,) ident(pos)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(sub) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(int) ident(c_int) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(sub)operator(\))operator(;) - keyword(if) operator(()ident(c_int) operator(<) hex(0x00) operator(||) ident(c_int) operator(>) hex(0xFF)operator(\)) operator({) - comment(// out of byte range) - comment(// there will be no match for sure) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - type(byte) ident(c) operator(=) operator(()type(byte)operator(\)) ident(c_int)operator(;) - - type(byte)type([]) ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(pbeg) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(p) operator(=) ident(pbeg) operator(+) ident(pos)operator(;) - - keyword(if) operator(()ident(pos) operator(==) ident(value)operator(.)ident(realSize)operator(\)) operator({) - keyword(if) operator(()ident(pos) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(--)ident(p)operator(;) - operator(}) - keyword(while) operator(()ident(pbeg) operator(<=) ident(p)operator(\)) operator({) - keyword(if) operator(()ident(bytes)operator([)ident(p)operator(]) operator(==) ident(c)operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(p) operator(-) ident(value)operator(.)ident(begin)operator(\))operator(;) - operator(}) - ident(p)operator(--)operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(sub)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - keyword(if) operator(()ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(type mismatch: )delimiter(")> operator(+) ident(sub)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - ident(pos) operator(=) ident(strRindex)operator(()operator(()ident(RubyString)operator(\)) ident(tmp)operator(,) ident(pos)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) integer(0)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(strRindex)operator(()ident(RubyString) ident(sub)operator(,) type(int) ident(pos)operator(\)) operator({) - type(int) ident(subLength) operator(=) ident(sub)operator(.)ident(value)operator(.)ident(realSize)operator(;) - - comment(/* substring longer than string */) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(<) ident(subLength)operator(\)) keyword(return) operator(-)integer(1)operator(;) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(-) ident(pos) operator(<) ident(subLength)operator(\)) ident(pos) operator(=) ident(value)operator(.)ident(realSize) operator(-) ident(subLength)operator(;) - - keyword(return) ident(value)operator(.)ident(lastIndexOf)operator(()ident(sub)operator(.)ident(value)operator(,) ident(pos)operator(\))operator(;) - operator(}) - - comment(/* rb_str_substr */) - directive(public) ident(IRubyObject) ident(substr)operator(()type(int) ident(beg)operator(,) type(int) ident(len)operator(\)) operator({) - keyword(return) ident(substr)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(beg)operator(,) ident(len)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(substr)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(beg)operator(,) type(int) ident(len)operator(\)) operator({) - type(int) ident(length) operator(=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0) operator(||) ident(beg) operator(>) ident(length)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) operator({) - ident(beg) operator(+=) ident(length)operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - type(int) ident(end) operator(=) pre_type(Math)operator(.)ident(min)operator(()ident(length)operator(,) ident(beg) operator(+) ident(len)operator(\))operator(;) - keyword(return) ident(makeShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(beg)operator(,) ident(end) operator(-) ident(beg)operator(\))operator(;) - operator(}) - - - - comment(/* rb_str_replace */) - directive(public) ident(IRubyObject) ident(replace)operator(()type(int) ident(beg)operator(,) type(int) ident(len)operator(,) ident(RubyString) ident(replaceWith)operator(\)) operator({) - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>=) ident(value)operator(.)ident(length)operator(()operator(\))operator(\)) ident(len) operator(=) ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) ident(beg)operator(;) - - ident(modify)operator(()operator(\))operator(;) - ident(value)operator(.)ident(unsafeReplace)operator(()ident(beg)operator(,)ident(len)operator(,)ident(replaceWith)operator(.)ident(value)operator(\))operator(;) - - keyword(return) ident(infectBy)operator(()ident(replaceWith)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args - */) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(op_aref)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(op_aref)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_aref, rb_str_aref_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content([])delimiter(")>operator(,) string<delimiter(")content(slice)delimiter(")>operator(})operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - keyword(if) operator(()ident(arg1) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - keyword(if)operator(()operator(()operator(()ident(RubyRegexp)operator(\))ident(arg1)operator(\))operator(.)ident(search)operator(()ident(context)operator(,) local_variable(this)operator(,) integer(0)operator(,) pre_constant(false)operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg2)operator(\))operator(,) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(substr)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(\))operator(,) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg2)operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_str_aref, rb_str_aref_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content([])delimiter(")>operator(,) string<delimiter(")content(slice)delimiter(")>operator(})operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - keyword(if)operator(()operator(()operator(()ident(RubyRegexp)operator(\))ident(arg)operator(\))operator(.)ident(search)operator(()ident(context)operator(,) local_variable(this)operator(,) integer(0)operator(,) pre_constant(false)operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(return) ident(RubyRegexp)operator(.)ident(nth_match)operator(()integer(0)operator(,) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(indexOf)operator(()ident(stringValue)operator(()ident(arg)operator(\))operator(.)ident(value)operator(\)) operator(!=) operator(-)integer(1) operator(?) - ident(arg) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyRange)operator(\)) operator({) - type(long)type([]) ident(begLen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(arg)operator(\))operator(.)ident(begLen)operator(()ident(value)operator(.)ident(length)operator(()operator(\))operator(,) integer(0)operator(\))operator(;) - keyword(return) ident(begLen) operator(==) pre_constant(null) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) - ident(substr)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()type(int)operator(\)) ident(begLen)operator([)integer(0)operator(])operator(,) operator(()type(int)operator(\)) ident(begLen)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - type(int) ident(idx) operator(=) operator(()type(int)operator(\)) ident(arg)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(idx) operator(<) integer(0)operator(\)) ident(idx) operator(+=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(if) operator(()ident(idx) operator(<) integer(0) operator(||) ident(idx) operator(>=) ident(value)operator(.)ident(length)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(get)operator(()ident(idx)operator(\)) operator(&) hex(0xFF)operator(\))operator(;) - operator(}) - - comment(/** - * rb_str_subpat_set - * - */) - directive(private) type(void) ident(subpatSet)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyRegexp) ident(regexp)operator(,) type(int) ident(nth)operator(,) ident(IRubyObject) ident(repl)operator(\)) operator({) - ident(RubyMatchData) ident(match)operator(;) - type(int) ident(start)operator(,) ident(end)operator(,) ident(len)operator(;) - keyword(if) operator(()ident(regexp)operator(.)ident(search)operator(()ident(context)operator(,) local_variable(this)operator(,) integer(0)operator(,) pre_constant(false)operator(\)) operator(<) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(regexp not matched)delimiter(")>operator(\))operator(;) - - ident(match) operator(=) operator(()ident(RubyMatchData)operator(\))ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(getBackRef)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(match)operator(.)ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()ident(nth) operator(>=) integer(1)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( out of regexp)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(nth) operator(<) integer(0)operator(\)) operator({) - keyword(if)operator(()operator(-)ident(nth) operator(>=) integer(1)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( out of regexp)delimiter(")>operator(\))operator(;) - ident(nth) operator(+=) integer(1)operator(;) - operator(}) - ident(start) operator(=) ident(match)operator(.)ident(begin)operator(;) - keyword(if)operator(()ident(start) operator(==) operator(-)integer(1)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(regexp group )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( not matched)delimiter(")>operator(\))operator(;) - ident(end) operator(=) ident(match)operator(.)ident(end)operator(;) - operator(}) keyword(else) operator({) - keyword(if)operator(()ident(nth) operator(>=) ident(match)operator(.)ident(regs)operator(.)ident(numRegs)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( out of regexp)delimiter(")>operator(\))operator(;) - keyword(if)operator(()ident(nth) operator(<) integer(0)operator(\)) operator({) - keyword(if)operator(()operator(-)ident(nth) operator(>=) ident(match)operator(.)ident(regs)operator(.)ident(numRegs)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(index )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( out of regexp)delimiter(")>operator(\))operator(;) - ident(nth) operator(+=) ident(match)operator(.)ident(regs)operator(.)ident(numRegs)operator(;) - operator(}) - ident(start) operator(=) ident(match)operator(.)ident(regs)operator(.)ident(beg)operator([)ident(nth)operator(])operator(;) - keyword(if)operator(()ident(start) operator(==) operator(-)integer(1)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(regexp group )delimiter(")> operator(+) ident(nth) operator(+) string<delimiter(")content( not matched)delimiter(")>operator(\))operator(;) - ident(end) operator(=) ident(match)operator(.)ident(regs)operator(.)ident(end)operator([)ident(nth)operator(])operator(;) - operator(}) - - ident(len) operator(=) ident(end) operator(-) ident(start)operator(;) - ident(replace)operator(()ident(start)operator(,) ident(len)operator(,) ident(stringValue)operator(()ident(repl)operator(\))operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with two or three args. - */) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(2)operator(:) - keyword(return) ident(op_aset)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(case) integer(3)operator(:) - keyword(return) ident(op_aset)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(2)operator(,) integer(3)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_aset, rb_str_aset_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyFixnum) operator(||) ident(arg0)operator(.)ident(respondsTo)operator(()string<delimiter(")content(to_int)delimiter(")>operator(\))operator(\)) operator({) comment(// FIXME: RubyNumeric or RubyInteger instead?) - type(int) ident(idx) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg0)operator(\))operator(;) - - keyword(if) operator(()ident(idx) operator(<) integer(0)operator(\)) ident(idx) operator(+=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(idx) operator(<) integer(0) operator(||) ident(idx) operator(>=) ident(value)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(string index out of bounds)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(arg1) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - ident(value)operator(.)ident(set)operator(()ident(idx)operator(,) operator(()type(byte)operator(\)) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(replace)operator(()ident(idx)operator(,) integer(1)operator(,) ident(stringValue)operator(()ident(arg1)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(arg1)operator(;) - operator(}) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(RubyString) ident(repl) operator(=) ident(stringValue)operator(()ident(arg1)operator(\))operator(;) - ident(subpatSet)operator(()ident(context)operator(,) operator(()ident(RubyRegexp)operator(\)) ident(arg0)operator(,) integer(0)operator(,) ident(repl)operator(\))operator(;) - keyword(return) ident(repl)operator(;) - operator(}) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(RubyString) ident(orig) operator(=) operator(()ident(RubyString)operator(\))ident(arg0)operator(;) - type(int) ident(beg) operator(=) ident(value)operator(.)ident(indexOf)operator(()ident(orig)operator(.)ident(value)operator(\))operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(string not matched)delimiter(")>operator(\))operator(;) - ident(replace)operator(()ident(beg)operator(,) ident(orig)operator(.)ident(value)operator(.)ident(length)operator(()operator(\))operator(,) ident(stringValue)operator(()ident(arg1)operator(\))operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRange)operator(\)) operator({) - type(long)type([]) ident(begLen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(arg0)operator(\))operator(.)ident(begLen)operator(()ident(value)operator(.)ident(realSize)operator(,) integer(2)operator(\))operator(;) - ident(replace)operator(()operator(()type(int)operator(\)) ident(begLen)operator([)integer(0)operator(])operator(,) operator(()type(int)operator(\)) ident(begLen)operator([)integer(1)operator(])operator(,) ident(stringValue)operator(()ident(arg1)operator(\))operator(\))operator(;) - keyword(return) ident(arg1)operator(;) - operator(}) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** rb_str_aset, rb_str_aset_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - keyword(if) operator(()ident(arg0) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - ident(RubyString) ident(repl) operator(=) ident(stringValue)operator(()ident(arg2)operator(\))operator(;) - type(int) ident(nth) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(\))operator(;) - ident(subpatSet)operator(()ident(context)operator(,) operator(()ident(RubyRegexp)operator(\)) ident(arg0)operator(,) ident(nth)operator(,) ident(repl)operator(\))operator(;) - keyword(return) ident(repl)operator(;) - operator(}) - ident(RubyString) ident(repl) operator(=) ident(stringValue)operator(()ident(arg2)operator(\))operator(;) - type(int) ident(beg) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg0)operator(\))operator(;) - type(int) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(negative length)delimiter(")>operator(\))operator(;) - type(int) ident(strLen) operator(=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(if) operator(()ident(beg) operator(<) integer(0)operator(\)) ident(beg) operator(+=) ident(strLen)operator(;) - - keyword(if) operator(()ident(beg) operator(<) integer(0) operator(||) operator(()ident(beg) operator(>) integer(0) operator(&&) ident(beg) operator(>) ident(strLen)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(string index out of bounds)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(strLen)operator(\)) ident(len) operator(=) ident(strLen) operator(-) ident(beg)operator(;) - - ident(replace)operator(()ident(beg)operator(,) ident(len)operator(,) ident(repl)operator(\))operator(;) - keyword(return) ident(repl)operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound as a Ruby method. - * @deprecated Use the versions with one or two args. - */) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(slice_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(slice_bang)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_slice_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(slice!)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(op_aref)operator(()ident(context)operator(,) ident(arg0)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(result)operator(;) - - ident(op_aset)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** rb_str_slice_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(slice!)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(slice_bang)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(op_aref)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(\))operator(;) - keyword(if) operator(()ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(result)operator(;) - - ident(op_aset)operator(()ident(context)operator(,) ident(arg0)operator(,) ident(arg1)operator(,) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(succ)delimiter(")>operator(,) string<delimiter(")content(next)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(succ)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(succ_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(succ!)delimiter(")>operator(,) string<delimiter(")content(next!)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(succ_bang)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(boolean) ident(alnumSeen) operator(=) pre_constant(false)operator(;) - type(int) ident(pos) operator(=) operator(-)integer(1)operator(;) - type(int) ident(c) operator(=) integer(0)operator(;) - type(int) ident(n) operator(=) integer(0)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(c) operator(=) ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(&) hex(0xFF)operator(;) - keyword(if) operator(()ident(isAlnum)operator(()ident(c)operator(\))operator(\)) operator({) - ident(alnumSeen) operator(=) pre_constant(true)operator(;) - keyword(if) operator(()operator(()ident(isDigit)operator(()ident(c)operator(\)) operator(&&) ident(c) operator(<) string<delimiter(')content(9)delimiter(')>operator(\)) operator(||) operator(()ident(isLower)operator(()ident(c)operator(\)) operator(&&) ident(c) operator(<) string<delimiter(')content(z)delimiter(')>operator(\)) operator(||) operator(()ident(isUpper)operator(()ident(c)operator(\)) operator(&&) ident(c) operator(<) string<delimiter(')content(Z)delimiter(')>operator(\))operator(\)) operator({) - ident(value)operator(.)ident(set)operator(()ident(i)operator(,) operator(()type(byte)operator(\))operator(()ident(c) operator(+) integer(1)operator(\))operator(\))operator(;) - ident(pos) operator(=) operator(-)integer(1)operator(;) - keyword(break)operator(;) - operator(}) - ident(pos) operator(=) ident(i)operator(;) - ident(n) operator(=) ident(isDigit)operator(()ident(c)operator(\)) operator(?) string<delimiter(')content(1)delimiter(')> operator(:) operator(()ident(isLower)operator(()ident(c)operator(\)) operator(?) string<delimiter(')content(a)delimiter(')> operator(:) string<delimiter(')content(A)delimiter(')>operator(\))operator(;) - ident(value)operator(.)ident(set)operator(()ident(i)operator(,) operator(()type(byte)operator(\))operator(()ident(isDigit)operator(()ident(c)operator(\)) operator(?) string<delimiter(')content(0)delimiter(')> operator(:) operator(()ident(isLower)operator(()ident(c)operator(\)) operator(?) string<delimiter(')content(a)delimiter(')> operator(:) string<delimiter(')content(A)delimiter(')>operator(\))operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()operator(!)ident(alnumSeen)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) ident(value)operator(.)ident(length)operator(()operator(\)) operator(-) integer(1)operator(;) ident(i) operator(>=) integer(0)operator(;) ident(i)operator(--)operator(\)) operator({) - ident(c) operator(=) ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(&) hex(0xFF)operator(;) - keyword(if) operator(()ident(c) operator(<) hex(0xff)operator(\)) operator({) - ident(value)operator(.)ident(set)operator(()ident(i)operator(,) operator(()type(byte)operator(\))operator(()ident(c) operator(+) integer(1)operator(\))operator(\))operator(;) - ident(pos) operator(=) operator(-)integer(1)operator(;) - keyword(break)operator(;) - operator(}) - ident(pos) operator(=) ident(i)operator(;) - ident(n) operator(=) string<delimiter(')content(\\u0001)delimiter(')>operator(;) - ident(value)operator(.)ident(set)operator(()ident(i)operator(,) integer(0)operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(pos) operator(>) operator(-)integer(1)operator(\)) operator({) - comment(// This represents left most digit in a set of incremented) - comment(// values? Therefore leftmost numeric must be '1' and not '0') - comment(// 999 -> 1000, not 999 -> 0000. whereas chars should be) - comment(// zzz -> aaaa and non-alnum byte values should be "\\377" -> "\\001\\000") - ident(value)operator(.)ident(insert)operator(()ident(pos)operator(,) operator(()type(byte)operator(\)) ident(n)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_upto_m - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(upto)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(upto)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(upto)operator(()ident(context)operator(,) ident(str)operator(,) pre_constant(false)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/* rb_str_upto */) - directive(public) ident(IRubyObject) ident(upto)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(,) type(boolean) ident(excl)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyString) ident(end) operator(=) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(;) - - type(int) ident(n) operator(=) ident(value)operator(.)ident(cmp)operator(()ident(end)operator(.)ident(value)operator(\))operator(;) - keyword(if) operator(()ident(n) operator(>) integer(0) operator(||) operator(()ident(excl) operator(&&) ident(n) operator(==) integer(0)operator(\))operator(\)) keyword(return) local_variable(this)operator(;) - - ident(IRubyObject) ident(afterEnd) operator(=) ident(end)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(succ)delimiter(")>operator(\))operator(;) - ident(RubyString) ident(current) operator(=) local_variable(this)operator(;) - - keyword(while) operator(()operator(!)ident(current)operator(.)ident(op_equal)operator(()ident(context)operator(,) ident(afterEnd)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(current)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(excl) operator(&&) ident(current)operator(.)ident(op_equal)operator(()ident(context)operator(,) ident(end)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(break)operator(;) - ident(current) operator(=) ident(current)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(succ)delimiter(")>operator(\))operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(excl) operator(&&) ident(current)operator(.)ident(op_equal)operator(()ident(context)operator(,) ident(end)operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) keyword(break)operator(;) - keyword(if) operator(()ident(current)operator(.)ident(value)operator(.)ident(realSize) operator(>) ident(end)operator(.)ident(value)operator(.)ident(realSize) operator(||) ident(current)operator(.)ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(break)operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_include - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(include?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(include_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - type(int) ident(c) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(obj)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(==) operator(()type(byte)operator(\))ident(c)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - ident(ByteList) ident(str) operator(=) ident(stringValue)operator(()ident(obj)operator(\))operator(.)ident(value)operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(value)operator(.)ident(indexOf)operator(()ident(str)operator(\)) operator(!=) operator(-)integer(1)operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound as a Ruby method. - * @deprecated Use the versions with zero or one args. - */) - directive(public) ident(IRubyObject) ident(to_i)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(to_i)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(to_i)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_to_i - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_i)operator(()operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) integer(10)operator(\))operator(;) - operator(}) - - comment(/** rb_str_to_i - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_i)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - type(long) ident(base) operator(=) ident(arg0)operator(.)ident(convertToInteger)operator(()operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(return) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) operator(()type(int)operator(\)) ident(base)operator(\))operator(;) - operator(}) - - comment(/** rb_str_oct - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(oct)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(oct)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(isEmpty)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - - type(int) ident(base) operator(=) integer(8)operator(;) - - type(int) ident(ix) operator(=) ident(value)operator(.)ident(begin)operator(;) - - keyword(while)operator(()ident(ix) operator(<) ident(value)operator(.)ident(begin)operator(+)ident(value)operator(.)ident(realSize) operator(&&) ident(ASCII)operator(.)ident(isSpace)operator(()ident(value)operator(.)ident(bytes)operator([)ident(ix)operator(]) operator(&) hex(0xff)operator(\))operator(\)) operator({) - ident(ix)operator(++)operator(;) - operator(}) - - type(int) ident(pos) operator(=) operator(()ident(value)operator(.)ident(bytes)operator([)ident(ix)operator(]) operator(==) string<delimiter(')content(-)delimiter(')> operator(||) ident(value)operator(.)ident(bytes)operator([)ident(ix)operator(]) operator(==) string<delimiter(')content(+)delimiter(')>operator(\)) operator(?) ident(ix)operator(+)integer(1) operator(:) ident(ix)operator(;) - keyword(if)operator(()operator(()ident(pos)operator(+)integer(1)operator(\)) operator(<) ident(value)operator(.)ident(begin)operator(+)ident(value)operator(.)ident(realSize) operator(&&) ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(]) operator(==) string<delimiter(')content(0)delimiter(')>operator(\)) operator({) - keyword(if)operator(()ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(x)delimiter(')> operator(||) ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(X)delimiter(')>operator(\)) operator({) - ident(base) operator(=) integer(16)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(b)delimiter(')> operator(||) ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(B)delimiter(')>operator(\)) operator({) - ident(base) operator(=) integer(2)operator(;) - operator(}) keyword(else) keyword(if)operator(()ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(d)delimiter(')> operator(||) ident(value)operator(.)ident(bytes)operator([)ident(pos)operator(+)integer(1)operator(]) operator(==) string<delimiter(')content(D)delimiter(')>operator(\)) operator({) - ident(base) operator(=) integer(10)operator(;) - operator(}) - operator(}) - keyword(return) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) ident(base)operator(\))operator(;) - operator(}) - - comment(/** rb_str_hex - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hex)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(hex)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(,) integer(16)operator(\))operator(;) - operator(}) - - comment(/** rb_str_to_f - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_f)operator(()operator(\)) operator({) - keyword(return) ident(RubyNumeric)operator(.)ident(str2fnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(\))operator(;) - operator(}) - - comment(/** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */) - directive(public) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(split)operator(()ident(context)operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(split)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(split)operator(()ident(context)operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_split_m - * - */) - annotation(@JRubyMethod)operator(()ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) ident(split)operator(()ident(context)operator(,) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - - comment(/** rb_str_split_m - * - */) - annotation(@JRubyMethod)operator(()ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(splitCommon)operator(()ident(arg0)operator(,) pre_constant(false)operator(,) integer(0)operator(,) integer(0)operator(,) ident(context)operator(\))operator(;) - operator(}) - - comment(/** rb_str_split_m - * - */) - annotation(@JRubyMethod)operator(()ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - directive(final) type(int) ident(lim) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg1)operator(\))operator(;) - keyword(if) operator(()ident(lim) operator(<=) integer(0)operator(\)) operator({) - keyword(return) ident(splitCommon)operator(()ident(arg0)operator(,) pre_constant(false)operator(,) ident(lim)operator(,) integer(1)operator(,) ident(context)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(lim) operator(==) integer(1)operator(\)) keyword(return) ident(value)operator(.)ident(realSize) operator(==) integer(0) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(splitCommon)operator(()ident(arg0)operator(,) pre_constant(true)operator(,) ident(lim)operator(,) integer(1)operator(,) ident(context)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(RubyArray) ident(splitCommon)operator(()ident(IRubyObject) ident(spat)operator(,) directive(final) type(boolean) ident(limit)operator(,) directive(final) type(int) ident(lim)operator(,) directive(final) type(int) ident(i)operator(,) ident(ThreadContext) ident(context)operator(\)) operator({) - directive(final) ident(RubyArray) ident(result)operator(;) - keyword(if) operator(()ident(spat)operator(.)ident(isNil)operator(()operator(\)) operator(&&) operator(()ident(spat) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($;)delimiter(")>operator(\))operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(result) operator(=) ident(awkSplit)operator(()ident(limit)operator(,) ident(lim)operator(,) ident(i)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(spat) keyword(instanceof) ident(RubyString) operator(&&) operator(()operator(()ident(RubyString)operator(\)) ident(spat)operator(\))operator(.)ident(value)operator(.)ident(realSize) operator(==) integer(1)operator(\)) operator({) - ident(RubyString) ident(strSpat) operator(=) operator(()ident(RubyString)operator(\)) ident(spat)operator(;) - keyword(if) operator(()ident(strSpat)operator(.)ident(value)operator(.)ident(bytes)operator([)ident(strSpat)operator(.)ident(value)operator(.)ident(begin)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content( )delimiter(')>operator(\)) operator({) - ident(result) operator(=) ident(awkSplit)operator(()ident(limit)operator(,) ident(lim)operator(,) ident(i)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result) operator(=) ident(split)operator(()ident(context)operator(,) ident(spat)operator(,) ident(limit)operator(,) ident(lim)operator(,) ident(i)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(result) operator(=) ident(split)operator(()ident(context)operator(,) ident(spat)operator(,) ident(limit)operator(,) ident(lim)operator(,) ident(i)operator(\))operator(;) - operator(}) - operator(}) - - keyword(if) operator(()operator(!)ident(limit) operator(&&) ident(lim) operator(==) integer(0)operator(\)) operator({) - keyword(while) operator(()ident(result)operator(.)ident(size)operator(()operator(\)) operator(>) integer(0) operator(&&) operator(()operator(()ident(RubyString)operator(\)) ident(result)operator(.)ident(eltInternal)operator(()ident(result)operator(.)ident(size)operator(()operator(\)) operator(-) integer(1)operator(\))operator(\))operator(.)ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(result)operator(.)ident(pop)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) ident(RubyArray) ident(split)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(pat)operator(,) type(boolean) ident(limit)operator(,) type(int) ident(lim)operator(,) type(int) ident(i)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - directive(final) ident(Regex) ident(regex) operator(=) ident(getPattern)operator(()ident(pat)operator(,) pre_constant(true)operator(\))operator(.)ident(getPattern)operator(()operator(\))operator(;) - type(int) ident(beg)operator(,) ident(end)operator(,) ident(start)operator(;) - - type(int) ident(begin) operator(=) ident(value)operator(.)ident(begin)operator(;) - ident(start) operator(=) ident(begin)operator(;) - ident(beg) operator(=) integer(0)operator(;) - - type(int) ident(range) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - directive(final) pre_type(Matcher) ident(matcher) operator(=) ident(regex)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(range)operator(\))operator(;) - - type(boolean) ident(lastNull) operator(=) pre_constant(false)operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) comment(// shorter path, no captures defined, no region will be returned ) - keyword(while) operator(()operator(()ident(end) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(start)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(start) operator(==) ident(end) operator(+) ident(begin) operator(&&) ident(matcher)operator(.)ident(getBegin)operator(()operator(\)) operator(==) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(lastNull)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(runtime)operator(,) ident(beg)operator(,) ident(regex)operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(begin) operator(+) ident(beg)operator(])operator(\))operator(\))operator(\))operator(;) - ident(beg) operator(=) ident(start) operator(-) ident(begin)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(start) operator(==) ident(range)operator(\)) operator({) - ident(start)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(start) operator(+=) ident(regex)operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(start)operator(])operator(\))operator(;) - operator(}) - ident(lastNull) operator(=) pre_constant(true)operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(beg)operator(,) ident(end) operator(-) ident(beg)operator(\))operator(\))operator(;) - ident(beg) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - ident(start) operator(=) ident(begin) operator(+) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - operator(}) - ident(lastNull) operator(=) pre_constant(false)operator(;) - keyword(if) operator(()ident(limit) operator(&&) ident(lim) operator(<=) operator(++)ident(i)operator(\)) keyword(break)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(while) operator(()operator(()ident(end) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(start)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(\)) operator(>=) integer(0)operator(\)) operator({) - directive(final) pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - keyword(if) operator(()ident(start) operator(==) ident(end) operator(+) ident(begin) operator(&&) ident(region)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) ident(region)operator(.)ident(end)operator([)integer(0)operator(])operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(break)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(lastNull)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(beg)operator(,) ident(regex)operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(begin) operator(+) ident(beg)operator(])operator(\))operator(\))operator(\))operator(;) - ident(beg) operator(=) ident(start) operator(-) ident(begin)operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(start) operator(==) ident(range)operator(\)) operator({) - ident(start)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(start) operator(+=) ident(regex)operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(start)operator(])operator(\))operator(;) - operator(}) - ident(lastNull) operator(=) pre_constant(true)operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(beg)operator(,) ident(end) operator(-) ident(beg)operator(\))operator(\))operator(;) - ident(beg) operator(=) ident(start) operator(=) ident(region)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - ident(start) operator(+=) ident(begin)operator(;) - operator(}) - ident(lastNull) operator(=) pre_constant(false)operator(;) - - keyword(for) operator(()type(int) ident(idx)operator(=)integer(1)operator(;) ident(idx)operator(<)ident(region)operator(.)ident(numRegs)operator(;) ident(idx)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(region)operator(.)ident(beg)operator([)ident(idx)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(continue)operator(;) - keyword(if) operator(()ident(region)operator(.)ident(beg)operator([)ident(idx)operator(]) operator(==) ident(region)operator(.)ident(end)operator([)ident(idx)operator(])operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(region)operator(.)ident(beg)operator([)ident(idx)operator(])operator(,) ident(region)operator(.)ident(end)operator([)ident(idx)operator(]) operator(-) ident(region)operator(.)ident(beg)operator([)ident(idx)operator(])operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(limit) operator(&&) ident(lim) operator(<=) operator(++)ident(i)operator(\)) keyword(break)operator(;) - operator(}) - operator(}) - - comment(// only this case affects backrefs ) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) integer(0) operator(&&) operator(()ident(limit) operator(||) ident(value)operator(.)ident(realSize) operator(>) ident(beg) operator(||) ident(lim) operator(<) integer(0)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) ident(beg)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(beg)operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(beg)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) ident(RubyArray) ident(awkSplit)operator(()type(boolean) ident(limit)operator(,) type(int) ident(lim)operator(,) type(int) ident(i)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyArray) ident(result) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - type(byte)type([])ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(p) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(endp) operator(=) ident(p) operator(+) ident(value)operator(.)ident(realSize)operator(;) - - type(boolean) ident(skip) operator(=) pre_constant(true)operator(;) - - type(int) ident(end)operator(,) ident(beg) operator(=) integer(0)operator(;) - keyword(for) operator(()ident(end) operator(=) ident(beg) operator(=) integer(0)operator(;) ident(p) operator(<) ident(endp)operator(;) ident(p)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(skip)operator(\)) operator({) - keyword(if) operator(()ident(ASCII)operator(.)ident(isSpace)operator(()ident(bytes)operator([)ident(p)operator(]) operator(&) hex(0xff)operator(\))operator(\)) operator({) - ident(beg)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(end) operator(=) ident(beg) operator(+) integer(1)operator(;) - ident(skip) operator(=) pre_constant(false)operator(;) - keyword(if) operator(()ident(limit) operator(&&) ident(lim) operator(<=) ident(i)operator(\)) keyword(break)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(ASCII)operator(.)ident(isSpace)operator(()ident(bytes)operator([)ident(p)operator(]) operator(&) hex(0xff)operator(\))operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(makeShared)operator(()ident(runtime)operator(,) ident(beg)operator(,) ident(end) operator(-) ident(beg)operator(\))operator(\))operator(;) - ident(skip) operator(=) pre_constant(true)operator(;) - ident(beg) operator(=) ident(end) operator(+) integer(1)operator(;) - keyword(if) operator(()ident(limit)operator(\)) ident(i)operator(++)operator(;) - operator(}) keyword(else) operator({) - ident(end)operator(++)operator(;) - operator(}) - operator(}) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) integer(0) operator(&&) operator(()ident(limit) operator(||) ident(value)operator(.)ident(realSize) operator(>) ident(beg) operator(||) ident(lim) operator(<) integer(0)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) ident(beg)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(newEmptyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(makeShared)operator(()ident(runtime)operator(,) ident(beg)operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(beg)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** get_pat - * - */) - directive(private) directive(final) ident(RubyRegexp) ident(getPattern)operator(()ident(IRubyObject) ident(obj)operator(,) type(boolean) ident(quote)operator(\)) operator({) - keyword(if) operator(()ident(obj) keyword(instanceof) ident(RubyRegexp)operator(\)) operator({) - keyword(return) operator(()ident(RubyRegexp)operator(\))ident(obj)operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(!)operator(()ident(obj) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - ident(IRubyObject) ident(val) operator(=) ident(obj)operator(.)ident(checkStringType)operator(()operator(\))operator(;) - keyword(if) operator(()ident(val)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(obj)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Regexp\))delimiter(")>operator(\))operator(;) - ident(obj) operator(=) ident(val)operator(;) - operator(}) - - keyword(return) ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(()operator(()ident(RubyString)operator(\))ident(obj)operator(\))operator(.)ident(value)operator(,) integer(0)operator(,) ident(quote)operator(\))operator(;) - operator(}) - - comment(/** rb_str_scan - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scan)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(\)) - directive(public) ident(IRubyObject) ident(scan)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getPreviousFrame)operator(()operator(\))operator(;) - - directive(final) ident(RubyRegexp) ident(rubyRegex) operator(=) ident(getPattern)operator(()ident(arg)operator(,) pre_constant(true)operator(\))operator(;) - directive(final) ident(Regex) ident(regex) operator(=) ident(rubyRegex)operator(.)ident(getPattern)operator(()operator(\))operator(;) - - type(int) ident(range) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - directive(final) pre_type(Matcher) ident(matcher) operator(=) ident(regex)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(range)operator(\))operator(;) - ident(matcher)operator(.)ident(value) operator(=) integer(0)operator(;) comment(// implicit start argument to scanOnce(NG\)) - - ident(IRubyObject) ident(result)operator(;) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - ident(RubyArray) ident(ary) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(while) operator(()operator(()ident(result) operator(=) ident(scanOnceNG)operator(()ident(rubyRegex)operator(,) ident(matcher)operator(,) ident(range)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) ident(ary)operator(.)ident(append)operator(()ident(result)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(while) operator(()operator(()ident(result) operator(=) ident(scanOnce)operator(()ident(rubyRegex)operator(,) ident(matcher)operator(,) ident(range)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) ident(ary)operator(.)ident(append)operator(()ident(result)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(ary)operator(.)ident(size)operator(()operator(\)) operator(>) integer(0)operator(\)) operator({) - ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(frame)operator(.)ident(setBackRef)operator(()ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(ary)operator(;) - operator(}) keyword(else) operator({) - type(byte)type([])ident(bytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(size) operator(=) ident(value)operator(.)ident(realSize)operator(;) - ident(RubyMatchData) ident(match) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()ident(regex)operator(.)ident(numberOfCaptures)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(while) operator(()operator(()ident(result) operator(=) ident(scanOnceNG)operator(()ident(rubyRegex)operator(,) ident(matcher)operator(,) ident(range)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(match) operator(=) ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - ident(match)operator(.)ident(use)operator(()operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(result)operator(\))operator(;) - ident(modifyCheck)operator(()ident(bytes)operator(,) ident(size)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(while) operator(()operator(()ident(result) operator(=) ident(scanOnce)operator(()ident(rubyRegex)operator(,) ident(matcher)operator(,) ident(range)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - ident(match) operator(=) ident(rubyRegex)operator(.)ident(updateBackRef)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(frame)operator(,) ident(matcher)operator(\))operator(;) - ident(match)operator(.)ident(use)operator(()operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(result)operator(\))operator(;) - ident(modifyCheck)operator(()ident(bytes)operator(,) ident(size)operator(\))operator(;) - operator(}) - operator(}) - ident(frame)operator(.)ident(setBackRef)operator(()ident(match) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(match)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - comment(/** - * rb_enc_check - */) - annotation(@SuppressWarnings)operator(()string<delimiter(")content(unused)delimiter(")>operator(\)) - directive(private) ident(Encoding) ident(encodingCheck)operator(()ident(RubyRegexp) ident(pattern)operator(\)) operator({) - comment(// For 1.9 compatibility, should check encoding compat between string and pattern) - keyword(return) ident(pattern)operator(.)ident(getKCode)operator(()operator(\))operator(.)ident(getEncoding)operator(()operator(\))operator(;) - operator(}) - - comment(// no group version) - directive(private) ident(IRubyObject) ident(scanOnceNG)operator(()ident(RubyRegexp) ident(regex)operator(,) pre_type(Matcher) ident(matcher)operator(,) type(int) ident(range)operator(\)) operator({) - keyword(if) operator(()ident(matcher)operator(.)ident(search)operator(()ident(matcher)operator(.)ident(value) operator(+) ident(value)operator(.)ident(begin)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\)) operator(>=) integer(0)operator(\)) operator({) - type(int) ident(end) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - keyword(if) operator(()ident(matcher)operator(.)ident(getBegin)operator(()operator(\)) operator(==) ident(end)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) ident(end)operator(\)) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end) operator(+) ident(regex)operator(.)ident(getPattern)operator(()operator(\))operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(end)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end) operator(+) integer(1)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end)operator(;) - operator(}) - keyword(return) ident(substr)operator(()ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(,) ident(end) operator(-) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(\))operator(.)ident(infectBy)operator(()ident(regex)operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - comment(// group version) - directive(private) ident(IRubyObject) ident(scanOnce)operator(()ident(RubyRegexp) ident(regex)operator(,) pre_type(Matcher) ident(matcher)operator(,) type(int) ident(range)operator(\)) operator({) - keyword(if) operator(()ident(matcher)operator(.)ident(search)operator(()ident(matcher)operator(.)ident(value) operator(+) ident(value)operator(.)ident(begin)operator(,) ident(range)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\)) operator(>=) integer(0)operator(\)) operator({) - pre_type(Region) ident(region) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - type(int) ident(end) operator(=) ident(region)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - keyword(if) operator(()ident(region)operator(.)ident(beg)operator([)integer(0)operator(]) operator(==) ident(end)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) ident(end)operator(\)) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end) operator(+) ident(regex)operator(.)ident(getPattern)operator(()operator(\))operator(.)ident(getEncoding)operator(()operator(\))operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(end)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end) operator(+) integer(1)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(matcher)operator(.)ident(value) operator(=) ident(end)operator(;) - operator(}) - - ident(RubyArray) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(region)operator(.)ident(numRegs)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(1)operator(;) ident(i)operator(<)ident(region)operator(.)ident(numRegs)operator(;) ident(i)operator(++)operator(\)) operator({) - type(int) ident(beg) operator(=) ident(region)operator(.)ident(beg)operator([)ident(i)operator(])operator(;) - keyword(if) operator(()ident(beg) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(result)operator(.)ident(append)operator(()ident(substr)operator(()ident(beg)operator(,) ident(region)operator(.)ident(end)operator([)ident(i)operator(]) operator(-) ident(beg)operator(\))operator(.)ident(infectBy)operator(()ident(regex)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(private) directive(static) directive(final) ident(ByteList) ident(SPACE_BYTELIST) operator(=) keyword(new) ident(ByteList)operator(()ident(ByteList)operator(.)ident(plain)operator(()string<delimiter(")content( )delimiter(")>operator(\))operator(\))operator(;) - - directive(private) directive(final) ident(IRubyObject) ident(justify)operator(()ident(IRubyObject) ident(arg0)operator(,) type(char) ident(jflag)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - type(int) ident(width) operator(=) ident(RubyFixnum)operator(.)ident(num2int)operator(()ident(arg0)operator(\))operator(;) - - type(int) ident(f)operator(,) ident(flen) operator(=) integer(0)operator(;) - type(byte)type([])ident(fbuf)operator(;) - - ident(IRubyObject) ident(pad)operator(;) - - ident(f) operator(=) ident(SPACE_BYTELIST)operator(.)ident(begin)operator(;) - ident(flen) operator(=) ident(SPACE_BYTELIST)operator(.)ident(realSize)operator(;) - ident(fbuf) operator(=) ident(SPACE_BYTELIST)operator(.)ident(bytes)operator(;) - ident(pad) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(return) ident(justifyCommon)operator(()ident(width)operator(,) ident(jflag)operator(,) ident(flen)operator(,) ident(fbuf)operator(,) ident(f)operator(,) ident(runtime)operator(,) ident(pad)operator(\))operator(;) - operator(}) - - directive(private) directive(final) ident(IRubyObject) ident(justify)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(,) type(char) ident(jflag)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - type(int) ident(width) operator(=) ident(RubyFixnum)operator(.)ident(num2int)operator(()ident(arg0)operator(\))operator(;) - - type(int) ident(f)operator(,) ident(flen) operator(=) integer(0)operator(;) - type(byte)type([])ident(fbuf)operator(;) - - ident(IRubyObject) ident(pad)operator(;) - - ident(pad) operator(=) ident(arg1)operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(ByteList) ident(fList) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(pad)operator(\))operator(.)ident(value)operator(;) - ident(f) operator(=) ident(fList)operator(.)ident(begin)operator(;) - ident(flen) operator(=) ident(fList)operator(.)ident(realSize)operator(;) - - keyword(if) operator(()ident(flen) operator(==) integer(0)operator(\)) keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(zero width padding)delimiter(")>operator(\))operator(;) - - ident(fbuf) operator(=) ident(fList)operator(.)ident(bytes)operator(;) - - keyword(return) ident(justifyCommon)operator(()ident(width)operator(,) ident(jflag)operator(,) ident(flen)operator(,) ident(fbuf)operator(,) ident(f)operator(,) ident(runtime)operator(,) ident(pad)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(justifyCommon)operator(()type(int) ident(width)operator(,) type(char) ident(jflag)operator(,) type(int) ident(flen)operator(,) type(byte)type([]) ident(fbuf)operator(,) type(int) ident(f)operator(,) ident(Ruby) ident(runtime)operator(,) ident(IRubyObject) ident(pad)operator(\)) operator({) - keyword(if) operator(()ident(width) operator(<) integer(0) operator(||) ident(value)operator(.)ident(realSize) operator(>=) ident(width)operator(\)) keyword(return) ident(strDup)operator(()ident(runtime)operator(\))operator(;) - - ident(ByteList) ident(res) operator(=) keyword(new) ident(ByteList)operator(()ident(width)operator(\))operator(;) - ident(res)operator(.)ident(realSize) operator(=) ident(width)operator(;) - - type(int) ident(p) operator(=) ident(res)operator(.)ident(begin)operator(;) - type(int) ident(pend)operator(;) - type(byte)type([]) ident(pbuf) operator(=) ident(res)operator(.)ident(bytes)operator(;) - - keyword(if) operator(()ident(jflag) operator(!=) string<delimiter(')content(l)delimiter(')>operator(\)) operator({) - type(int) ident(n) operator(=) ident(width) operator(-) ident(value)operator(.)ident(realSize)operator(;) - ident(pend) operator(=) ident(p) operator(+) operator(()operator(()ident(jflag) operator(==) string<delimiter(')content(r)delimiter(')>operator(\)) operator(?) ident(n) operator(:) ident(n) operator(/) integer(2)operator(\))operator(;) - keyword(if) operator(()ident(flen) operator(<=) integer(1)operator(\)) operator({) - keyword(while) operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - ident(pbuf)operator([)ident(p)operator(++)operator(]) operator(=) ident(fbuf)operator([)ident(f)operator(])operator(;) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(q) operator(=) ident(f)operator(;) - keyword(while) operator(()ident(p) operator(+) ident(flen) operator(<=) ident(pend)operator(\)) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(fbuf)operator(,) ident(f)operator(,) ident(pbuf)operator(,) ident(p)operator(,) ident(flen)operator(\))operator(;) - ident(p) operator(+=) ident(flen)operator(;) - operator(}) - keyword(while) operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - ident(pbuf)operator([)ident(p)operator(++)operator(]) operator(=) ident(fbuf)operator([)ident(q)operator(++)operator(])operator(;) - operator(}) - operator(}) - operator(}) - - pre_type(System)operator(.)ident(arraycopy)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin)operator(,) ident(pbuf)operator(,) ident(p)operator(,) ident(value)operator(.)ident(realSize)operator(\))operator(;) - - keyword(if) operator(()ident(jflag) operator(!=) string<delimiter(')content(r)delimiter(')>operator(\)) operator({) - ident(p) operator(+=) ident(value)operator(.)ident(realSize)operator(;) - ident(pend) operator(=) ident(res)operator(.)ident(begin) operator(+) ident(width)operator(;) - keyword(if) operator(()ident(flen) operator(<=) integer(1)operator(\)) operator({) - keyword(while) operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - ident(pbuf)operator([)ident(p)operator(++)operator(]) operator(=) ident(fbuf)operator([)ident(f)operator(])operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(while) operator(()ident(p) operator(+) ident(flen) operator(<=) ident(pend)operator(\)) operator({) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(fbuf)operator(,) ident(f)operator(,) ident(pbuf)operator(,) ident(p)operator(,) ident(flen)operator(\))operator(;) - ident(p) operator(+=) ident(flen)operator(;) - operator(}) - keyword(while) operator(()ident(p) operator(<) ident(pend)operator(\)) operator({) - ident(pbuf)operator([)ident(p)operator(++)operator(]) operator(=) ident(fbuf)operator([)ident(f)operator(++)operator(])operator(;) - operator(}) - operator(}) - operator(}) - - ident(RubyString) ident(resStr) operator(=) keyword(new) ident(RubyString)operator(()ident(runtime)operator(,) ident(getMetaClass)operator(()operator(\))operator(,) ident(res)operator(\))operator(;) - ident(resStr)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - keyword(if) operator(()ident(flen) operator(>) integer(0)operator(\)) operator({) - ident(resStr)operator(.)ident(infectBy)operator(()ident(pad)operator(\))operator(;) - operator(}) - keyword(return) ident(resStr)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */) - directive(public) ident(IRubyObject) ident(ljust)operator(()ident(IRubyObject) type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(ljust)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(ljust)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_ljust - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(ljust)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) string<delimiter(')content(l)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** rb_str_ljust - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(ljust)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) ident(arg1)operator(,) string<delimiter(')content(l)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */) - directive(public) ident(IRubyObject) ident(rjust)operator(()ident(IRubyObject) type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(rjust)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(rjust)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_rjust - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(rjust)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) string<delimiter(')content(r)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** rb_str_rjust - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(rjust)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) ident(arg1)operator(,) string<delimiter(')content(r)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */) - directive(public) ident(IRubyObject) ident(center)operator(()ident(IRubyObject) type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(1)operator(:) - keyword(return) ident(center)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(case) integer(2)operator(:) - keyword(return) ident(center)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_center - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(center)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) string<delimiter(')content(c)delimiter(')>operator(\))operator(;) - operator(}) - - comment(/** rb_str_center - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(center)operator(()ident(IRubyObject) ident(arg0)operator(,) ident(IRubyObject) ident(arg1)operator(\)) operator({) - keyword(return) ident(justify)operator(()ident(arg0)operator(,) ident(arg1)operator(,) string<delimiter(')content(c)delimiter(')>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chop)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(chop)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(chop_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_chop_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chop!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(chop_bang)operator(()operator(\)) operator({) - type(int) ident(end) operator(=) ident(value)operator(.)ident(realSize) operator(-) integer(1)operator(;) - keyword(if) operator(()ident(end) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(end)operator(])operator(\)) operator(==) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - keyword(if) operator(()ident(end) operator(>) integer(0) operator(&&) operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(end) operator(-) integer(1)operator(])operator(\)) operator(==) string<delimiter(')content(\\r)delimiter(')>operator(\)) ident(end)operator(--)operator(;) - operator(}) - - ident(view)operator(()integer(0)operator(,) ident(end)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby - * - * @param args - * @return - * @deprecated Use the zero or one argument versions. - */) - directive(public) ident(RubyString) ident(chomp)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(chomp)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(chomp)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** rb_str_chop - * - */) - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(chomp)operator(()operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(chomp_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_chop - * - */) - annotation(@JRubyMethod) - directive(public) ident(RubyString) ident(chomp)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(chomp_bang)operator(()ident(arg0)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one argument versions. - */) - directive(public) ident(IRubyObject) ident(chomp_bang)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - keyword(return) ident(chomp_bang)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(return) ident(chomp_bang)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(default)operator(:) - ident(Arity)operator(.)ident(raiseArgumentError)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(.)ident(length)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(return) pre_constant(null)operator(;) comment(// not reached) - operator(}) - operator(}) - - comment(/** - * rb_str_chomp_bang - * - * In the common case, removes CR and LF characters in various ways depending on the value of - * the optional args[0]. - * If args.length==0 removes one instance of CR, CRLF or LF from the end of the string. - * If args.length>0 and args[0] is "\\n" then same behaviour as args.length==0 . - * If args.length>0 and args[0] is "" then removes trailing multiple LF or CRLF (but no CRs at - * all(!\)\). - * @param args See method description. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(chomp_bang)operator(()operator(\)) operator({) - ident(IRubyObject) ident(rsObj)operator(;) - - type(int) ident(len) operator(=) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - type(byte)type([])ident(buff) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - ident(rsObj) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()ident(rsObj) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(getDefaultSeparator)operator(()operator(\))operator(\)) operator({) - type(int) ident(realSize) operator(=) ident(value)operator(.)ident(realSize)operator(;) - type(int) ident(begin) operator(=) ident(value)operator(.)ident(begin)operator(;) - keyword(if) operator(()ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\))string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(realSize)operator(--)operator(;) - keyword(if) operator(()ident(realSize) operator(>) integer(0) operator(&&) ident(buff)operator([)ident(begin) operator(+) ident(realSize) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\))string<delimiter(')content(\\r)delimiter(')>operator(\)) ident(realSize)operator(--)operator(;) - ident(view)operator(()integer(0)operator(,) ident(realSize)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\))string<delimiter(')content(\\r)delimiter(')>operator(\)) operator({) - ident(realSize)operator(--)operator(;) - ident(view)operator(()integer(0)operator(,) ident(realSize)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(return) ident(chompBangCommon)operator(()ident(rsObj)operator(\))operator(;) - operator(}) - - comment(/** - * rb_str_chomp_bang - * - * In the common case, removes CR and LF characters in various ways depending on the value of - * the optional args[0]. - * If args.length==0 removes one instance of CR, CRLF or LF from the end of the string. - * If args.length>0 and args[0] is "\\n" then same behaviour as args.length==0 . - * If args.length>0 and args[0] is "" then removes trailing multiple LF or CRLF (but no CRs at - * all(!\)\). - * @param args See method description. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(chomp!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(chomp_bang)operator(()ident(IRubyObject) ident(arg0)operator(\)) operator({) - keyword(return) ident(chompBangCommon)operator(()ident(arg0)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(chompBangCommon)operator(()ident(IRubyObject) ident(rsObj)operator(\)) operator({) - - keyword(if) operator(()ident(rsObj)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(RubyString) ident(rs) operator(=) ident(rsObj)operator(.)ident(convertToString)operator(()operator(\))operator(;) - type(int) ident(len) operator(=) ident(value)operator(.)ident(realSize)operator(;) - type(int) ident(begin) operator(=) ident(value)operator(.)ident(begin)operator(;) - keyword(if) operator(()ident(len) operator(==) integer(0)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - type(byte)type([]) ident(buff) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(rslen) operator(=) ident(rs)operator(.)ident(value)operator(.)ident(realSize)operator(;) - - keyword(if) operator(()ident(rslen) operator(==) integer(0)operator(\)) operator({) - keyword(while) operator(()ident(len) operator(>) integer(0) operator(&&) ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(len)operator(--)operator(;) - keyword(if) operator(()ident(len) operator(>) integer(0) operator(&&) ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\r)delimiter(')>operator(\)) operator({) - ident(len)operator(--)operator(;) - operator(}) - operator(}) - keyword(if) operator(()ident(len) operator(<) ident(value)operator(.)ident(realSize)operator(\)) operator({) - ident(view)operator(()integer(0)operator(,) ident(len)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(rslen) operator(>) ident(len)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - type(byte) ident(newline) operator(=) ident(rs)operator(.)ident(value)operator(.)ident(bytes)operator([)ident(rslen) operator(-) integer(1)operator(])operator(;) - - keyword(if) operator(()ident(rslen) operator(==) integer(1) operator(&&) ident(newline) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(buff) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(realSize) operator(=) ident(value)operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(realSize)operator(--)operator(;) - keyword(if) operator(()ident(realSize) operator(>) integer(0) operator(&&) ident(buff)operator([)ident(begin) operator(+) ident(realSize) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\r)delimiter(')>operator(\)) operator({) - ident(realSize)operator(--)operator(;) - operator(}) - ident(view)operator(()integer(0)operator(,) ident(realSize)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\)) string<delimiter(')content(\\r)delimiter(')>operator(\)) operator({) - ident(realSize)operator(--)operator(;) - ident(view)operator(()integer(0)operator(,) ident(realSize)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(if) operator(()ident(buff)operator([)ident(begin) operator(+) ident(len) operator(-) integer(1)operator(]) operator(==) ident(newline) operator(&&) ident(rslen) operator(<=) integer(1) operator(||) ident(value)operator(.)ident(endsWith)operator(()ident(rs)operator(.)ident(value)operator(\))operator(\)) operator({) - ident(view)operator(()integer(0)operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(rslen)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_lstrip - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(lstrip)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(lstrip_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_lstrip_bang - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lstrip!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(lstrip_bang)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - type(int) ident(i)operator(=)integer(0)operator(;) - keyword(while) operator(()ident(i) operator(<) ident(value)operator(.)ident(realSize) operator(&&) ident(ASCII)operator(.)ident(isSpace)operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(i)operator(]) operator(&) hex(0xff)operator(\))operator(\)) ident(i)operator(++)operator(;) - - keyword(if) operator(()ident(i) operator(>) integer(0)operator(\)) operator({) - ident(view)operator(()ident(i)operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(i)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_rstrip - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(rstrip)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(rstrip_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_rstrip_bang - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rstrip!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rstrip_bang)operator(()operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - type(int) ident(i)operator(=)ident(value)operator(.)ident(realSize) operator(-) integer(1)operator(;) - - keyword(while) operator(()ident(i) operator(>=) integer(0) operator(&&) ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin)operator(+)ident(i)operator(]) operator(==) integer(0)operator(\)) ident(i)operator(--)operator(;) - keyword(while) operator(()ident(i) operator(>=) integer(0) operator(&&) ident(ASCII)operator(.)ident(isSpace)operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(i)operator(]) operator(&) hex(0xff)operator(\))operator(\)) ident(i)operator(--)operator(;) - - keyword(if) operator(()ident(i) operator(<) ident(value)operator(.)ident(realSize) operator(-) integer(1)operator(\)) operator({) - ident(view)operator(()integer(0)operator(,) ident(i) operator(+) integer(1)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_strip - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(strip)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(strip_bang)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_strip_bang - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(strip!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(strip_bang)operator(()operator(\)) operator({) - ident(IRubyObject) ident(l) operator(=) ident(lstrip_bang)operator(()operator(\))operator(;) - ident(IRubyObject) ident(r) operator(=) ident(rstrip_bang)operator(()operator(\))operator(;) - - keyword(if)operator(()ident(l)operator(.)ident(isNil)operator(()operator(\)) operator(&&) ident(r)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(l)operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_count - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(count)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(count)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(1)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(;) - - type(boolean)type([])ident(table) operator(=) keyword(new) type(boolean)operator([)ident(TRANS_SIZE)operator(])operator(;) - type(boolean) ident(init) operator(=) pre_constant(true)operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(s)operator(.)ident(setup_table)operator(()ident(table)operator(,) ident(init)operator(\))operator(;) - ident(init) operator(=) pre_constant(false)operator(;) - operator(}) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte)type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(i) operator(=) integer(0)operator(;) - - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) keyword(if) operator(()ident(table)operator([)ident(buf)operator([)ident(s)operator(++)operator(]) operator(&) hex(0xff)operator(])operator(\)) ident(i)operator(++)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(;) - operator(}) - - comment(/** rb_str_delete - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(delete)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(delete_bang)operator(()ident(args)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_delete_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(delete!)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(delete_bang)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(<) integer(1)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments)delimiter(")>operator(\))operator(;) - - type(boolean)type([])ident(squeeze) operator(=) keyword(new) type(boolean)operator([)ident(TRANS_SIZE)operator(])operator(;) - - type(boolean) ident(init) operator(=) pre_constant(true)operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(s)operator(.)ident(setup_table)operator(()ident(squeeze)operator(,) ident(init)operator(\))operator(;) - ident(init) operator(=) pre_constant(false)operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(t) operator(=) ident(s)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte)type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - keyword(if) operator(()ident(squeeze)operator([)ident(buf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(])operator(\)) operator({) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - ident(buf)operator([)ident(t)operator(++)operator(]) operator(=) ident(buf)operator([)ident(s)operator(])operator(;) - operator(}) - ident(s)operator(++)operator(;) - operator(}) - ident(value)operator(.)ident(realSize) operator(=) ident(t) operator(-) ident(value)operator(.)ident(begin)operator(;) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_squeeze - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(squeeze)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(squeeze)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(squeeze_bang)operator(()ident(args)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_squeeze_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(squeeze!)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(squeeze_bang)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(modifyCheck)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(final) type(boolean) ident(squeeze)type([]) operator(=) keyword(new) type(boolean)operator([)ident(TRANS_SIZE)operator(])operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(squeeze)operator([)ident(i)operator(]) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - type(boolean) ident(init) operator(=) pre_constant(true)operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubyString) ident(s) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(s)operator(.)ident(setup_table)operator(()ident(squeeze)operator(,) ident(init)operator(\))operator(;) - ident(init) operator(=) pre_constant(false)operator(;) - operator(}) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(t) operator(=) ident(s)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte)type([])ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - type(int) ident(save) operator(=) operator(-)integer(1)operator(;) - - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - type(int) ident(c) operator(=) ident(buf)operator([)ident(s)operator(++)operator(]) operator(&) hex(0xff)operator(;) - keyword(if) operator(()ident(c) operator(!=) ident(save) operator(||) operator(!)ident(squeeze)operator([)ident(c)operator(])operator(\)) ident(buf)operator([)ident(t)operator(++)operator(]) operator(=) operator(()type(byte)operator(\))operator(()ident(save) operator(=) ident(c)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(t) operator(-) ident(value)operator(.)ident(begin) operator(!=) ident(value)operator(.)ident(realSize)operator(\)) operator({) comment(// modified) - ident(value)operator(.)ident(realSize) operator(=) ident(t) operator(-) ident(value)operator(.)ident(begin)operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** rb_str_tr - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(tr)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(repl)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(tr_trans)operator(()ident(src)operator(,) ident(repl)operator(,) pre_constant(false)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_tr_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tr!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(tr_bang)operator(()ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(repl)operator(\)) operator({) - keyword(return) ident(tr_trans)operator(()ident(src)operator(,) ident(repl)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(class) class(TR) operator({) - type(int) ident(gen)operator(,) ident(now)operator(,) ident(max)operator(;) - type(int) ident(p)operator(,) ident(pend)operator(;) - type(byte)type([])ident(buf)operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(TRANS_SIZE) operator(=) integer(256)operator(;) - - comment(/** tr_setup_table - * - */) - directive(private) directive(final) type(void) ident(setup_table)operator(()type(boolean)type([])ident(table)operator(,) type(boolean) ident(init)operator(\)) operator({) - directive(final) type(boolean)type([])ident(buf) operator(=) keyword(new) type(boolean)operator([)ident(TRANS_SIZE)operator(])operator(;) - directive(final) ident(TR) ident(tr) operator(=) keyword(new) ident(TR)operator(()operator(\))operator(;) - type(int) ident(c)operator(;) - - type(boolean) ident(cflag) operator(=) pre_constant(false)operator(;) - - ident(tr)operator(.)ident(p) operator(=) ident(value)operator(.)ident(begin)operator(;) - ident(tr)operator(.)ident(pend) operator(=) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(;) - ident(tr)operator(.)ident(buf) operator(=) ident(value)operator(.)ident(bytes)operator(;) - ident(tr)operator(.)ident(gen) operator(=) ident(tr)operator(.)ident(now) operator(=) ident(tr)operator(.)ident(max) operator(=) integer(0)operator(;) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) integer(1) operator(&&) ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin)operator(]) operator(==) string<delimiter(')content(^)delimiter(')>operator(\)) operator({) - ident(cflag) operator(=) pre_constant(true)operator(;) - ident(tr)operator(.)ident(p)operator(++)operator(;) - operator(}) - - keyword(if) operator(()ident(init)operator(\)) keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(table)operator([)ident(i)operator(]) operator(=) pre_constant(true)operator(;) - - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(buf)operator([)ident(i)operator(]) operator(=) ident(cflag)operator(;) - keyword(while) operator(()operator(()ident(c) operator(=) ident(trnext)operator(()ident(tr)operator(\))operator(\)) operator(>=) integer(0)operator(\)) ident(buf)operator([)ident(c) operator(&) hex(0xff)operator(]) operator(=) operator(!)ident(cflag)operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(table)operator([)ident(i)operator(]) operator(=) ident(table)operator([)ident(i)operator(]) operator(&&) ident(buf)operator([)ident(i)operator(])operator(;) - operator(}) - - comment(/** tr_trans - * - */) - directive(private) directive(final) ident(IRubyObject) ident(tr_trans)operator(()ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(repl)operator(,) type(boolean) ident(sflag)operator(\)) operator({) - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(ByteList) ident(replList) operator(=) ident(repl)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(value)operator(;) - - keyword(if) operator(()ident(replList)operator(.)ident(realSize) operator(==) integer(0)operator(\)) keyword(return) ident(delete_bang)operator(()keyword(new) ident(IRubyObject)type([])operator({)ident(src)operator(})operator(\))operator(;) - - ident(ByteList) ident(srcList) operator(=) ident(src)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(value)operator(;) - - directive(final) ident(TR) ident(trsrc) operator(=) keyword(new) ident(TR)operator(()operator(\))operator(;) - directive(final) ident(TR) ident(trrepl) operator(=) keyword(new) ident(TR)operator(()operator(\))operator(;) - - type(boolean) ident(cflag) operator(=) pre_constant(false)operator(;) - type(boolean) ident(modify) operator(=) pre_constant(false)operator(;) - - ident(trsrc)operator(.)ident(p) operator(=) ident(srcList)operator(.)ident(begin)operator(;) - ident(trsrc)operator(.)ident(pend) operator(=) ident(srcList)operator(.)ident(begin) operator(+) ident(srcList)operator(.)ident(realSize)operator(;) - ident(trsrc)operator(.)ident(buf) operator(=) ident(srcList)operator(.)ident(bytes)operator(;) - keyword(if) operator(()ident(srcList)operator(.)ident(realSize) operator(>=) integer(2) operator(&&) ident(srcList)operator(.)ident(bytes)operator([)ident(srcList)operator(.)ident(begin)operator(]) operator(==) string<delimiter(')content(^)delimiter(')>operator(\)) operator({) - ident(cflag) operator(=) pre_constant(true)operator(;) - ident(trsrc)operator(.)ident(p)operator(++)operator(;) - operator(}) - - ident(trrepl)operator(.)ident(p) operator(=) ident(replList)operator(.)ident(begin)operator(;) - ident(trrepl)operator(.)ident(pend) operator(=) ident(replList)operator(.)ident(begin) operator(+) ident(replList)operator(.)ident(realSize)operator(;) - ident(trrepl)operator(.)ident(buf) operator(=) ident(replList)operator(.)ident(bytes)operator(;) - - ident(trsrc)operator(.)ident(gen) operator(=) ident(trrepl)operator(.)ident(gen) operator(=) integer(0)operator(;) - ident(trsrc)operator(.)ident(now) operator(=) ident(trrepl)operator(.)ident(now) operator(=) integer(0)operator(;) - ident(trsrc)operator(.)ident(max) operator(=) ident(trrepl)operator(.)ident(max) operator(=) integer(0)operator(;) - - type(int) ident(c)operator(;) - directive(final) type(int)type([])ident(trans) operator(=) keyword(new) type(int)operator([)ident(TRANS_SIZE)operator(])operator(;) - keyword(if) operator(()ident(cflag)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(trans)operator([)ident(i)operator(]) operator(=) integer(1)operator(;) - keyword(while) operator(()operator(()ident(c) operator(=) ident(trnext)operator(()ident(trsrc)operator(\))operator(\)) operator(>=) integer(0)operator(\)) ident(trans)operator([)ident(c) operator(&) hex(0xff)operator(]) operator(=) operator(-)integer(1)operator(;) - keyword(while) operator(()operator(()ident(c) operator(=) ident(trnext)operator(()ident(trrepl)operator(\))operator(\)) operator(>=) integer(0)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(trans)operator([)ident(i)operator(]) operator(>=) integer(0)operator(\)) ident(trans)operator([)ident(i)operator(]) operator(=) ident(trrepl)operator(.)ident(now)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(;) ident(i)operator(<)ident(TRANS_SIZE)operator(;) ident(i)operator(++)operator(\)) ident(trans)operator([)ident(i)operator(]) operator(=) operator(-)integer(1)operator(;) - keyword(while) operator(()operator(()ident(c) operator(=) ident(trnext)operator(()ident(trsrc)operator(\))operator(\)) operator(>=) integer(0)operator(\)) operator({) - type(int) ident(r) operator(=) ident(trnext)operator(()ident(trrepl)operator(\))operator(;) - keyword(if) operator(()ident(r) operator(==) operator(-)integer(1)operator(\)) ident(r) operator(=) ident(trrepl)operator(.)ident(now)operator(;) - ident(trans)operator([)ident(c) operator(&) hex(0xff)operator(]) operator(=) ident(r)operator(;) - operator(}) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(s) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(send) operator(=) ident(s) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(byte) ident(sbuf)type([]) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - keyword(if) operator(()ident(sflag)operator(\)) operator({) - type(int) ident(t) operator(=) ident(s)operator(;) - type(int) ident(c0)operator(,) ident(last) operator(=) operator(-)integer(1)operator(;) - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - ident(c0) operator(=) ident(sbuf)operator([)ident(s)operator(++)operator(])operator(;) - keyword(if) operator(()operator(()ident(c) operator(=) ident(trans)operator([)ident(c0) operator(&) hex(0xff)operator(])operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(last) operator(==) ident(c)operator(\)) keyword(continue)operator(;) - ident(last) operator(=) ident(c)operator(;) - ident(sbuf)operator([)ident(t)operator(++)operator(]) operator(=) operator(()type(byte)operator(\))operator(()ident(c) operator(&) hex(0xff)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) keyword(else) operator({) - ident(last) operator(=) operator(-)integer(1)operator(;) - ident(sbuf)operator([)ident(t)operator(++)operator(]) operator(=) operator(()type(byte)operator(\))ident(c0)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(value)operator(.)ident(realSize) operator(>) operator(()ident(t) operator(-) ident(value)operator(.)ident(begin)operator(\))operator(\)) operator({) - ident(value)operator(.)ident(realSize) operator(=) ident(t) operator(-) ident(value)operator(.)ident(begin)operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(while) operator(()ident(s) operator(<) ident(send)operator(\)) operator({) - keyword(if) operator(()operator(()ident(c) operator(=) ident(trans)operator([)ident(sbuf)operator([)ident(s)operator(]) operator(&) hex(0xff)operator(])operator(\)) operator(>=) integer(0)operator(\)) operator({) - ident(sbuf)operator([)ident(s)operator(]) operator(=) operator(()type(byte)operator(\))operator(()ident(c) operator(&) hex(0xff)operator(\))operator(;) - ident(modify) operator(=) pre_constant(true)operator(;) - operator(}) - ident(s)operator(++)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(modify)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** trnext - * - */) - directive(private) directive(final) type(int) ident(trnext)operator(()ident(TR) ident(t)operator(\)) operator({) - type(byte) type([]) ident(buf) operator(=) ident(t)operator(.)ident(buf)operator(;) - - keyword(for) operator(()operator(;)operator(;)operator(\)) operator({) - keyword(if) operator(()ident(t)operator(.)ident(gen) operator(==) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(t)operator(.)ident(p) operator(==) ident(t)operator(.)ident(pend)operator(\)) keyword(return) operator(-)integer(1)operator(;) - keyword(if) operator(()ident(t)operator(.)ident(p) operator(<) ident(t)operator(.)ident(pend) operator(-)integer(1) operator(&&) ident(buf)operator([)ident(t)operator(.)ident(p)operator(]) operator(==) string<delimiter(')char(\\\\)delimiter(')>operator(\)) ident(t)operator(.)ident(p)operator(++)operator(;) - ident(t)operator(.)ident(now) operator(=) ident(buf)operator([)ident(t)operator(.)ident(p)operator(++)operator(])operator(;) - keyword(if) operator(()ident(t)operator(.)ident(p) operator(<) ident(t)operator(.)ident(pend) operator(-) integer(1) operator(&&) ident(buf)operator([)ident(t)operator(.)ident(p)operator(]) operator(==) string<delimiter(')content(-)delimiter(')>operator(\)) operator({) - ident(t)operator(.)ident(p)operator(++)operator(;) - keyword(if) operator(()ident(t)operator(.)ident(p) operator(<) ident(t)operator(.)ident(pend)operator(\)) operator({) - keyword(if) operator(()ident(t)operator(.)ident(now) operator(>) operator(()operator(()type(int)operator(\))ident(buf)operator([)ident(t)operator(.)ident(p)operator(]) operator(&) hex(0xFF)operator(\))operator(\)) operator({) - ident(t)operator(.)ident(p)operator(++)operator(;) - keyword(continue)operator(;) - operator(}) - ident(t)operator(.)ident(gen) operator(=) integer(1)operator(;) - ident(t)operator(.)ident(max) operator(=) operator(()type(int)operator(\))ident(buf)operator([)ident(t)operator(.)ident(p)operator(++)operator(]) operator(&) hex(0xFF)operator(;) - operator(}) - operator(}) - keyword(return) ident(t)operator(.)ident(now) operator(&) hex(0xff)operator(;) - operator(}) keyword(else) keyword(if) operator(()operator(++)ident(t)operator(.)ident(now) operator(<) ident(t)operator(.)ident(max)operator(\)) operator({) - keyword(return) ident(t)operator(.)ident(now) operator(&) hex(0xff)operator(;) - operator(}) keyword(else) operator({) - ident(t)operator(.)ident(gen) operator(=) integer(0)operator(;) - keyword(return) ident(t)operator(.)ident(max) operator(&) hex(0xff)operator(;) - operator(}) - operator(}) - operator(}) - - comment(/** rb_str_tr_s - * - */) - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(tr_s)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(repl)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(str)operator(.)ident(tr_trans)operator(()ident(src)operator(,) ident(repl)operator(,) pre_constant(true)operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - comment(/** rb_str_tr_s_bang - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tr_s!)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(tr_s_bang)operator(()ident(IRubyObject) ident(src)operator(,) ident(IRubyObject) ident(repl)operator(\)) operator({) - keyword(return) ident(tr_trans)operator(()ident(src)operator(,) ident(repl)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - comment(/** rb_str_each_line - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(each_line)delimiter(")>operator(,) string<delimiter(")content(each)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(0)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_line)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(byte) ident(newline)operator(;) - type(int) ident(p) operator(=) ident(value)operator(.)ident(begin)operator(;) - type(int) ident(pend) operator(=) ident(p) operator(+) ident(value)operator(.)ident(realSize)operator(;) - type(int) ident(s)operator(;) - type(int) ident(ptr) operator(=) ident(p)operator(;) - type(int) ident(len) operator(=) ident(value)operator(.)ident(realSize)operator(;) - type(int) ident(rslen)operator(;) - ident(IRubyObject) ident(line)operator(;) - - - ident(IRubyObject) ident(_rsep)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(_rsep) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(_rsep) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - - keyword(if)operator(()ident(_rsep)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) local_variable(this)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - ident(RubyString) ident(rsep) operator(=) ident(stringValue)operator(()ident(_rsep)operator(\))operator(;) - ident(ByteList) ident(rsepValue) operator(=) ident(rsep)operator(.)ident(value)operator(;) - type(byte)type([]) ident(strBytes) operator(=) ident(value)operator(.)ident(bytes)operator(;) - - ident(rslen) operator(=) ident(rsepValue)operator(.)ident(realSize)operator(;) - - keyword(if)operator(()ident(rslen) operator(==) integer(0)operator(\)) operator({) - ident(newline) operator(=) string<delimiter(')content(\\n)delimiter(')>operator(;) - operator(}) keyword(else) operator({) - ident(newline) operator(=) ident(rsepValue)operator(.)ident(bytes)operator([)ident(rsepValue)operator(.)ident(begin) operator(+) ident(rslen)operator(-)integer(1)operator(])operator(;) - operator(}) - - ident(s) operator(=) ident(p)operator(;) - ident(p)operator(+=)ident(rslen)operator(;) - - keyword(for)operator(()operator(;) ident(p) operator(<) ident(pend)operator(;) ident(p)operator(++)operator(\)) operator({) - keyword(if)operator(()ident(rslen) operator(==) integer(0) operator(&&) ident(strBytes)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - keyword(if)operator(()ident(strBytes)operator([)operator(++)ident(p)operator(]) operator(!=) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - keyword(continue)operator(;) - operator(}) - keyword(while)operator(()ident(p) operator(<) ident(pend) operator(&&) ident(strBytes)operator([)ident(p)operator(]) operator(==) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(p)operator(++)operator(;) - operator(}) - operator(}) - keyword(if)operator(()ident(ptr)operator(<)ident(p) operator(&&) ident(strBytes)operator([)ident(p)operator(-)integer(1)operator(]) operator(==) ident(newline) operator(&&) - operator(()ident(rslen) operator(<=) integer(1) operator(||) - ident(ByteList)operator(.)ident(memcmp)operator(()ident(rsepValue)operator(.)ident(bytes)operator(,) ident(rsepValue)operator(.)ident(begin)operator(,) ident(rslen)operator(,) ident(strBytes)operator(,) ident(p)operator(-)ident(rslen)operator(,) ident(rslen)operator(\)) operator(==) integer(0)operator(\))operator(\)) operator({) - ident(line) operator(=) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) local_variable(this)operator(.)ident(value)operator(.)ident(makeShared)operator(()ident(s)operator(-)ident(ptr)operator(,) ident(p)operator(-)ident(s)operator(\))operator(\))operator(;) - ident(line)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(line)operator(\))operator(;) - ident(modifyCheck)operator(()ident(strBytes)operator(,)ident(len)operator(\))operator(;) - ident(s) operator(=) ident(p)operator(;) - operator(}) - operator(}) - - keyword(if)operator(()ident(s) operator(!=) ident(pend)operator(\)) operator({) - keyword(if)operator(()ident(p) operator(>) ident(pend)operator(\)) operator({) - ident(p) operator(=) ident(pend)operator(;) - operator(}) - ident(line) operator(=) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(,) local_variable(this)operator(.)ident(value)operator(.)ident(makeShared)operator(()ident(s)operator(-)ident(ptr)operator(,) ident(p)operator(-)ident(s)operator(\))operator(\))operator(;) - ident(line)operator(.)ident(infectBy)operator(()local_variable(this)operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(line)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** - * rb_str_each_byte - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_byte)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyString) ident(each_byte)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - comment(// Check the length every iteration, since) - comment(// the block can modify this string.) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(&) hex(0xFF)operator(\))operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/** rb_str_intern - * - */) - directive(public) ident(RubySymbol) ident(intern)operator(()operator(\)) operator({) - pre_type(String) ident(s) operator(=) ident(toString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(s)operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(interning empty string)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(s)operator(.)ident(indexOf)operator(()string<delimiter(')content(\\0)delimiter(')>operator(\)) operator(>=) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(symbol string may not contain ')char(\\\\)content(0')delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newSymbol)operator(()ident(s)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_sym)delimiter(")>operator(,) string<delimiter(")content(intern)delimiter(")>operator(})operator(\)) - directive(public) ident(RubySymbol) ident(to_sym)operator(()operator(\)) operator({) - keyword(return) ident(intern)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sum)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(RubyInteger) ident(sum)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(wrong number of arguments ()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+) string<delimiter(")content( for 1\))delimiter(")>operator(\))operator(;) - operator(}) - - type(long) ident(bitSize) operator(=) integer(16)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - type(long) ident(bitSizeArg) operator(=) operator(()operator(()ident(RubyInteger)operator(\)) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToInteger)operator(()operator(\))operator(\))operator(.)ident(getLongValue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(bitSizeArg) operator(>) integer(0)operator(\)) operator({) - ident(bitSize) operator(=) ident(bitSizeArg)operator(;) - operator(}) - operator(}) - - type(long) ident(result) operator(=) integer(0)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(value)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result) operator(+=) ident(value)operator(.)ident(get)operator(()ident(i)operator(\)) operator(&) hex(0xFF)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(bitSize) operator(==) integer(0) operator(?) ident(result) operator(:) ident(result) operator(%) operator(()type(long)operator(\)) pre_type(Math)operator(.)ident(pow)operator(()integer(2)operator(,) ident(bitSize)operator(\))operator(\))operator(;) - operator(}) - - comment(/** string_to_c - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_c)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(to_c)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backref) operator(=) ident(frame)operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backref) operator(!=) pre_constant(null) operator(&&) ident(backref) keyword(instanceof) ident(RubyMatchData)operator(\)) operator(()operator(()ident(RubyMatchData)operator(\))ident(backref)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(s) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(() - ident(context)operator(,) local_variable(this)operator(,) string<delimiter(")content(gsub)delimiter(")>operator(,) - ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(ComplexPatterns)operator(.)ident(underscores_pat)operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(_)delimiter(')>operator(})operator(\))operator(\))operator(\))operator(;) - - ident(RubyArray) ident(a) operator(=) ident(RubyComplex)operator(.)ident(str_to_c_internal)operator(()ident(context)operator(,) ident(s)operator(\))operator(;) - - ident(frame)operator(.)ident(setBackRef)operator(()ident(backref)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyComplex)operator(.)ident(newComplexCanonicalize)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - comment(/** string_to_r - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_r)delimiter(")>operator(,) ident(reads) operator(=) ident(BACKREF)operator(,) ident(writes) operator(=) ident(BACKREF)operator(,) ident(compat) operator(=) ident(CompatVersion)operator(.)ident(RUBY1_9)operator(\)) - directive(public) ident(IRubyObject) ident(to_r)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(IRubyObject) ident(backref) operator(=) ident(frame)operator(.)ident(getBackRef)operator(()operator(\))operator(;) - keyword(if) operator(()ident(backref) operator(!=) pre_constant(null) operator(&&) ident(backref) keyword(instanceof) ident(RubyMatchData)operator(\)) operator(()operator(()ident(RubyMatchData)operator(\))ident(backref)operator(\))operator(.)ident(use)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(s) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(() - ident(context)operator(,) local_variable(this)operator(,) string<delimiter(")content(gsub)delimiter(")>operator(,) - ident(RubyRegexp)operator(.)ident(newRegexp)operator(()ident(runtime)operator(,) ident(Numeric)operator(.)ident(ComplexPatterns)operator(.)ident(underscores_pat)operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()keyword(new) ident(ByteList)operator(()keyword(new) type(byte)type([])operator({)string<delimiter(')content(_)delimiter(')>operator(})operator(\))operator(\))operator(\))operator(;) - - ident(RubyArray) ident(a) operator(=) ident(RubyRational)operator(.)ident(str_to_r_internal)operator(()ident(context)operator(,) ident(s)operator(\))operator(;) - - ident(frame)operator(.)ident(setBackRef)operator(()ident(backref)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(a)operator(.)ident(eltInternal)operator(()integer(0)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RubyRational)operator(.)ident(newRationalCanonicalize)operator(()ident(context)operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(runtime)operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyString) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(RubyString) ident(result) operator(=) ident(newString)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - comment(/** - * @see org.jruby.util.Pack#unpack - */) - annotation(@JRubyMethod) - directive(public) ident(RubyArray) ident(unpack)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - keyword(return) ident(Pack)operator(.)ident(unpack)operator(()ident(getRuntime)operator(()operator(\))operator(,) local_variable(this)operator(.)ident(value)operator(,) ident(stringValue)operator(()ident(obj)operator(\))operator(.)ident(value)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(empty)operator(()operator(\)) operator({) - ident(value) operator(=) ident(ByteList)operator(.)ident(EMPTY_BYTELIST)operator(;) - ident(shareLevel) operator(=) ident(SHARE_LEVEL_BYTELIST)operator(;) - operator(}) - - comment(/** - * Mutator for internal string representation. - * - * @param value The new java.lang.String this RubyString should encapsulate - * @deprecated - */) - directive(public) type(void) ident(setValue)operator(()pre_type(CharSequence) ident(value)operator(\)) operator({) - ident(view)operator(()ident(ByteList)operator(.)ident(plain)operator(()ident(value)operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setValue)operator(()ident(ByteList) ident(value)operator(\)) operator({) - ident(view)operator(()ident(value)operator(\))operator(;) - operator(}) - - directive(public) pre_type(CharSequence) ident(getValue)operator(()operator(\)) operator({) - keyword(return) ident(toString)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(byte)type([]) ident(getBytes)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(.)ident(bytes)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(ByteList) ident(getByteList)operator(()operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - - comment(/** used by ar-jdbc - * - */) - directive(public) pre_type(String) ident(getUnicodeValue)operator(()operator(\)) operator({) - keyword(try) operator({) - keyword(return) keyword(new) pre_type(String)operator(()ident(value)operator(.)ident(bytes)operator(,)ident(value)operator(.)ident(begin)operator(,)ident(value)operator(.)ident(realSize)operator(,) string<delimiter(")content(UTF8)delimiter(")>operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(Exception) ident(e)operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(Something's seriously broken with encodings)delimiter(")>operator(,) ident(e)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_java)operator(()operator(\)) operator({) - keyword(return) ident(MiniJava)operator(.)ident(javaToRuby)operator(()ident(getRuntime)operator(()operator(\))operator(,) keyword(new) pre_type(String)operator(()ident(getBytes)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * Copyright (C\) 2006 Ryan Bell <ryan.l.bell@gmail.com> - * Copyright (C\) 2007 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2008 Vladimir Sizikov <vsizikov@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.ArrayList)operator(;) -keyword(import) include(java.util.List)operator(;) - -keyword(import) include(org.jruby.anno.FrameField)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.TypeConverter)operator(;) -keyword(import) include(org.jruby.util.io.InvalidValueException)operator(;) -keyword(import) include(org.jruby.util.io.ModeFlags)operator(;) -keyword(import) include(org.jruby.util.io.Stream)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(StringIO)delimiter(")>operator(\)) -directive(public) type(class) class(RubyStringIO) directive(extends) ident(RubyObject) operator({) - directive(private) directive(static) ident(ObjectAllocator) ident(STRINGIO_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyStringIO)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createStringIOClass)operator(()directive(final) ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(stringIOClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(() - string<delimiter(")content(StringIO)delimiter(")>operator(,) ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Data)delimiter(")>operator(\))operator(,) ident(STRINGIO_ALLOCATOR)operator(\))operator(;) - - ident(stringIOClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyStringIO)operator(.)ident(class)operator(\))operator(;) - ident(stringIOClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(stringIOClass)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyStringIO) ident(strio) operator(=) operator(()ident(RubyStringIO)operator(\))operator(()operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - ident(IRubyObject) ident(val) operator(=) ident(strio)operator(;) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(val) operator(=) ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(strio)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(strio)operator(.)ident(doFinalize)operator(()operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(val)operator(;) - operator(}) - - directive(protected) ident(RubyStringIO)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - - directive(private) type(long) ident(pos) operator(=) integer(0L)operator(;) - directive(private) type(int) ident(lineno) operator(=) integer(0)operator(;) - directive(private) type(boolean) ident(eof) operator(=) pre_constant(false)operator(;) - - comment(/** - * ATTN: the value of internal might be reset to null - * (during StringIO.open with block\), so watch out for that. - */) - directive(private) ident(RubyString) ident(internal)operator(;) - - comment(// Has read/write been closed or is it still open for business) - directive(private) type(boolean) ident(closedRead) operator(=) pre_constant(false)operator(;) - directive(private) type(boolean) ident(closedWrite) operator(=) pre_constant(false)operator(;) - - comment(// Support IO modes that this object was opened with) - ident(ModeFlags) ident(modes)operator(;) - - directive(private) type(void) ident(initializeModes)operator(()pre_type(Object) ident(modeArgument)operator(\)) operator({) - keyword(try) operator({) - keyword(if) operator(()ident(modeArgument) operator(==) pre_constant(null)operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(RubyIO)operator(.)ident(getIOModesIntFromString)operator(()ident(getRuntime)operator(()operator(\))operator(,) string<delimiter(")content(r+)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(modeArgument) keyword(instanceof) pre_type(Long)operator(\)) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()operator(()operator(()pre_type(Long)operator(\))ident(modeArgument)operator(\))operator(.)ident(longValue)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modes) operator(=) keyword(new) ident(ModeFlags)operator(()ident(RubyIO)operator(.)ident(getIOModesIntFromString)operator(()ident(getRuntime)operator(()operator(\))operator(,) operator(()pre_type(String)operator(\)) ident(modeArgument)operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(catch) operator(()ident(InvalidValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - operator(}) - ident(setupModes)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - pre_type(Object) ident(modeArgument) operator(=) pre_constant(null)operator(;) - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) - ident(internal) operator(=) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - ident(modeArgument) operator(=) string<delimiter(")content(r+)delimiter(")>operator(;) - keyword(break)operator(;) - keyword(case) integer(1)operator(:) - ident(internal) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - ident(modeArgument) operator(=) ident(internal)operator(.)ident(isFrozen)operator(()operator(\)) operator(?) string<delimiter(")content(r)delimiter(")> operator(:) string<delimiter(")content(r+)delimiter(")>operator(;) - keyword(break)operator(;) - keyword(case) integer(2)operator(:) - ident(internal) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator([)integer(1)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(modeArgument) operator(=) ident(RubyFixnum)operator(.)ident(fix2long)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(modeArgument) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - keyword(break)operator(;) - operator(}) - - ident(initializeModes)operator(()ident(modeArgument)operator(\))operator(;) - - keyword(if) operator(()ident(modes)operator(.)ident(isWritable)operator(()operator(\)) operator(&&) ident(internal)operator(.)ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEACCESError)operator(()string<delimiter(")content(Permission denied)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(modes)operator(.)ident(isTruncate)operator(()operator(\))operator(\)) operator({) - ident(internal)operator(.)ident(modifyCheck)operator(()operator(\))operator(;) - ident(internal)operator(.)ident(empty)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - - ident(RubyStringIO) ident(otherIO) operator(=) operator(()ident(RubyStringIO)operator(\)) ident(TypeConverter)operator(.)ident(convertToType)operator(() - ident(other)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(StringIO)delimiter(")>operator(\))operator(,) - ident(MethodIndex)operator(.)ident(getIndex)operator(()string<delimiter(")content(to_strio)delimiter(")>operator(\))operator(,) string<delimiter(")content(to_strio)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()local_variable(this) operator(==) ident(otherIO)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - ident(pos) operator(=) ident(otherIO)operator(.)ident(pos)operator(;) - ident(lineno) operator(=) ident(otherIO)operator(.)ident(lineno)operator(;) - ident(eof) operator(=) ident(otherIO)operator(.)ident(eof)operator(;) - ident(closedRead) operator(=) ident(otherIO)operator(.)ident(closedRead)operator(;) - ident(closedWrite) operator(=) ident(otherIO)operator(.)ident(closedWrite)operator(;) - ident(internal) operator(=) ident(otherIO)operator(.)ident(internal)operator(;) - ident(modes) operator(=) ident(otherIO)operator(.)ident(modes)operator(;) - keyword(if) operator(()ident(otherIO)operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(append)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(writeInternal)operator(()ident(context)operator(,) ident(arg)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(binmode)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(binmode)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - ident(checkOpen)operator(()operator(\))operator(;) - - ident(closedRead) operator(=) pre_constant(true)operator(;) - ident(closedWrite) operator(=) pre_constant(true)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(doFinalize)operator(()operator(\)) operator({) - ident(closedRead) operator(=) pre_constant(true)operator(;) - ident(closedWrite) operator(=) pre_constant(true)operator(;) - ident(internal) operator(=) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(closed_p)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(closedRead) operator(&&) ident(closedWrite)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close_read)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close_read)operator(()operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - ident(closedRead) operator(=) pre_constant(true)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed_read?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(closed_read_p)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(closedRead)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close_write)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close_write)operator(()operator(\)) operator({) - ident(checkWritable)operator(()operator(\))operator(;) - ident(closedWrite) operator(=) pre_constant(true)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed_write?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(closed_write_p)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(closedWrite)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - - keyword(while) operator(()operator(!)ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(line)operator(\))operator(;) - ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_byte)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_byte)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ByteList) ident(bytes) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - comment(// Check the length every iteration, since) - comment(// the block can modify this string.) - keyword(while) operator(()ident(pos) operator(<) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newFixnum)operator(()ident(bytes)operator(.)ident(get)operator(()operator(()type(int)operator(\)) ident(pos)operator(++)operator(\)) operator(&) hex(0xFF)operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_line)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_line)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(each)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(eof)delimiter(")>operator(,) string<delimiter(")content(eof?)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(eof)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isEOF)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isEOF)operator(()operator(\)) operator({) - keyword(return) operator(()ident(pos) operator(>=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\)) operator(||) ident(eof)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fcntl)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(fcntl)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(fcntl not implemented)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fileno)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(fileno)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flush)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(flush)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(fsync)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(fsync)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getc)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(getc)operator(()operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(get)operator(()operator(()type(int)operator(\))ident(pos)operator(++)operator(\)) operator(&) hex(0xFF)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(internalGets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(<) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(&&) operator(!)ident(eof)operator(\)) operator({) - type(boolean) ident(isParagraph) operator(=) pre_constant(false)operator(;) - - ident(ByteList) ident(sep)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(ByteList) ident(buf) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(makeShared)operator(() - operator(()type(int)operator(\))ident(pos)operator(,) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(-) operator(()type(int)operator(\))ident(pos)operator(\))operator(;) - ident(pos) operator(+=) ident(buf)operator(.)ident(realSize)operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,) ident(buf)operator(\))operator(;) - operator(}) - ident(sep) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(sep)operator(.)ident(realSize) operator(==) integer(0)operator(\)) operator({) - ident(isParagraph) operator(=) pre_constant(true)operator(;) - ident(sep) operator(=) ident(Stream)operator(.)ident(PARAGRAPH_SEPARATOR)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(sep) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - - ident(ByteList) ident(ss) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(isParagraph)operator(\)) operator({) - ident(swallowLF)operator(()ident(ss)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(==) ident(ss)operator(.)ident(realSize)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - type(int) ident(ix) operator(=) ident(ss)operator(.)ident(indexOf)operator(()ident(sep)operator(,) operator(()type(int)operator(\))ident(pos)operator(\))operator(;) - - ident(ByteList) ident(add)operator(;) - keyword(if) operator(()operator(-)integer(1) operator(==) ident(ix)operator(\)) operator({) - ident(ix) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(;) - ident(add) operator(=) keyword(new) ident(ByteList)operator(()keyword(new) type(byte)operator([)integer(0)operator(])operator(,) pre_constant(false)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(add) operator(=) ident(isParagraph)operator(?) ident(NEWLINE) operator(:) ident(sep)operator(;) - operator(}) - - ident(ByteList) ident(line) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(makeShared)operator(()operator(()type(int)operator(\))ident(pos)operator(,) ident(ix) operator(-) operator(()type(int)operator(\))ident(pos)operator(\))operator(;) - ident(line)operator(.)ident(unshare)operator(()operator(\))operator(;) - ident(line)operator(.)ident(append)operator(()ident(add)operator(\))operator(;) - ident(line)operator(.)ident(invalidate)operator(()operator(\))operator(;) - ident(pos) operator(=) ident(ix) operator(+) ident(add)operator(.)ident(realSize)operator(;) - ident(lineno)operator(++)operator(;) - - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(runtime)operator(,)ident(line)operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(swallowLF)operator(()ident(ByteList) ident(list)operator(\)) operator({) - keyword(while) operator(()ident(pos) operator(<) ident(list)operator(.)ident(realSize)operator(\)) operator({) - keyword(if) operator(()ident(list)operator(.)ident(get)operator(()operator(()type(int)operator(\))ident(pos)operator(\)) operator(==) string<delimiter(')content(\\n)delimiter(')>operator(\)) operator({) - ident(pos)operator(++)operator(;) - operator(}) keyword(else) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gets)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(gets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(result) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(result)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(tty?)delimiter(")>operator(,) string<delimiter(")content(isatty)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(isatty)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(length)delimiter(")>operator(,) string<delimiter(")content(size)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(length)operator(()operator(\)) operator({) - ident(checkFinalized)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(lineno)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(lineno)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_lineno)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(lineno) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(path)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(path)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pid)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pid)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(pos)delimiter(")>operator(,) string<delimiter(")content(tell)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(pos)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(pos)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_pos)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(pos) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(Invalid argument)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(print)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(print)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(0)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i)operator(=)integer(0)operator(,)ident(j)operator(=)ident(args)operator(.)ident(length)operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(append)operator(()ident(context)operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(arg) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($_)delimiter(")>operator(\))operator(;) - ident(append)operator(()ident(context)operator(,) ident(arg)operator(.)ident(isNil)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(nil)delimiter(")>operator(\)) operator(:) ident(arg)operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(sep) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($)char(\\\\)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(sep)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(append)operator(()ident(context)operator(,) ident(sep)operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(printf)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(printf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(append)operator(()ident(context)operator(,) ident(RubyKernel)operator(.)ident(sprintf)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(args)operator(\))operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(putc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(putc)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(checkWritable)operator(()operator(\))operator(;) - type(byte) ident(c) operator(=) ident(RubyNumeric)operator(.)ident(num2chr)operator(()ident(obj)operator(\))operator(;) - ident(checkFrozen)operator(()operator(\))operator(;) - - ident(internal)operator(.)ident(modify)operator(()operator(\))operator(;) - ident(ByteList) ident(bytes) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(modes)operator(.)ident(isAppendable)operator(()operator(\))operator(\)) operator({) - ident(pos) operator(=) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(;) - ident(bytes)operator(.)ident(append)operator(()ident(c)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(pos) operator(>=) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(bytes)operator(.)ident(length)operator(()operator(()type(int)operator(\))ident(pos) operator(+) integer(1)operator(\))operator(;) - operator(}) - - ident(bytes)operator(.)ident(set)operator(()operator(()type(int)operator(\)) ident(pos)operator(,) ident(c)operator(\))operator(;) - ident(pos)operator(++)operator(;) - operator(}) - - keyword(return) ident(obj)operator(;) - operator(}) - - directive(public) directive(static) directive(final) ident(ByteList) ident(NEWLINE) operator(=) ident(ByteList)operator(.)ident(create)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(puts)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(puts)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(checkWritable)operator(()operator(\))operator(;) - - comment(// FIXME: the code below is a copy of RubyIO.puts,) - comment(// and we should avoid copy-paste.) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(NEWLINE)operator(\))operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - pre_type(String) ident(line)operator(;) - - keyword(if) operator(()ident(args)operator([)ident(i)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(line) operator(=) string<delimiter(")content(nil)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(checkArrayType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(RubyArray) ident(arr) operator(=) operator(()ident(RubyArray)operator(\)) ident(tmp)operator(;) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(isInspecting)operator(()ident(arr)operator(\))operator(\)) operator({) - ident(line) operator(=) string<delimiter(")content([...])delimiter(")>operator(;) - operator(}) keyword(else) operator({) - ident(inspectPuts)operator(()ident(context)operator(,) ident(arr)operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(line) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - operator(}) - - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(line)operator(\))operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(line)operator(.)ident(endsWith)operator(()string<delimiter(")char(\\n)delimiter(")>operator(\))operator(\)) operator({) - ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(write)delimiter(")>operator(,) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(NEWLINE)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(inspectPuts)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyArray) ident(array)operator(\)) operator({) - keyword(try) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()ident(array)operator(\))operator(;) - keyword(return) ident(puts)operator(()ident(context)operator(,) ident(array)operator(.)ident(toJavaArray)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()ident(array)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@SuppressWarnings)operator(()string<delimiter(")content(fallthrough)delimiter(")>operator(\)) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - - ident(ByteList) ident(buf) operator(=) pre_constant(null)operator(;) - type(int) ident(length) operator(=) integer(0)operator(;) - type(int) ident(oldLength) operator(=) integer(0)operator(;) - ident(RubyString) ident(originalString) operator(=) pre_constant(null)operator(;) - - keyword(switch) operator(()ident(args)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(2)operator(:) - ident(originalString) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - comment(// must let original string know we're modifying, so shared buffers aren't damaged) - ident(originalString)operator(.)ident(modify)operator(()operator(\))operator(;) - ident(buf) operator(=) ident(originalString)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(case) integer(1)operator(:) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(length) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - ident(oldLength) operator(=) ident(length)operator(;) - - keyword(if) operator(()ident(length) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(length) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) - keyword(if) operator(()ident(length) operator(>) integer(0) operator(&&) ident(pos) operator(>=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(\)) operator({) - ident(eof) operator(=) pre_constant(true)operator(;) - keyword(if) operator(()ident(buf) operator(!=) pre_constant(null)operator(\)) ident(buf)operator(.)ident(realSize) operator(=) integer(0)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(eof)operator(\)) operator({) - keyword(if) operator(()ident(buf) operator(!=) pre_constant(null)operator(\)) ident(buf)operator(.)ident(realSize) operator(=) integer(0)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(break)operator(;) - operator(}) - keyword(case) integer(0)operator(:) - ident(oldLength) operator(=) operator(-)integer(1)operator(;) - ident(length) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(<=) ident(pos)operator(\)) operator({) - ident(eof) operator(=) pre_constant(true)operator(;) - keyword(if) operator(()ident(buf) operator(==) pre_constant(null)operator(\)) operator({) - ident(buf) operator(=) keyword(new) ident(ByteList)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(buf)operator(.)ident(realSize) operator(=) integer(0)operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buf)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(length) operator(-=) ident(pos)operator(;) - operator(}) - keyword(break)operator(;) - keyword(default)operator(:) - ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,) integer(0)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(buf) operator(==) pre_constant(null)operator(\)) operator({) - type(int) ident(internalLength) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(internalLength) operator(>) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(internalLength) operator(>=) ident(pos) operator(+) ident(length)operator(\)) operator({) - ident(buf) operator(=) keyword(new) ident(ByteList)operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(,) operator(()type(int)operator(\)) ident(pos)operator(,) ident(length)operator(\))operator(;) - operator(}) keyword(else) operator({) - type(int) ident(rest) operator(=) operator(()type(int)operator(\)) operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(-) ident(pos)operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(>) ident(rest)operator(\)) ident(length) operator(=) ident(rest)operator(;) - ident(buf) operator(=) keyword(new) ident(ByteList)operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(,) operator(()type(int)operator(\)) ident(pos)operator(,) ident(length)operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - type(int) ident(rest) operator(=) operator(()type(int)operator(\)) operator(()ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(-) ident(pos)operator(\))operator(;) - - keyword(if) operator(()ident(length) operator(>) ident(rest)operator(\)) ident(length) operator(=) ident(rest)operator(;) - - comment(// Yow...this is ugly) - ident(buf)operator(.)ident(realSize) operator(=) ident(length)operator(;) - ident(buf)operator(.)ident(replace)operator(()integer(0)operator(,) ident(length)operator(,) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(bytes)operator(,) operator(()type(int)operator(\)) ident(pos)operator(,) ident(length)operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(buf) operator(==) pre_constant(null)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(eof)operator(\)) ident(buf) operator(=) keyword(new) ident(ByteList)operator(()operator(\))operator(;) - ident(length) operator(=) integer(0)operator(;) - operator(}) keyword(else) operator({) - ident(length) operator(=) ident(buf)operator(.)ident(length)operator(()operator(\))operator(;) - ident(pos) operator(+=) ident(length)operator(;) - operator(}) - - keyword(if) operator(()ident(oldLength) operator(<) integer(0) operator(||) ident(oldLength) operator(>) ident(length)operator(\)) ident(eof) operator(=) pre_constant(true)operator(;) - - keyword(return) ident(originalString) operator(!=) pre_constant(null) operator(?) ident(originalString) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buf)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readchar)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(readchar)operator(()operator(\)) operator({) - ident(IRubyObject) ident(c) operator(=) ident(getc)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(c)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(c)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readline)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(readline)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(gets)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - - keyword(return) ident(line)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(readlines)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(arg)operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - - pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(lns) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - keyword(while) operator(()operator(!)operator(()ident(isEOF)operator(()operator(\))operator(\))operator(\)) operator({) - ident(IRubyObject) ident(line) operator(=) ident(internalGets)operator(()ident(context)operator(,) ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(line)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(lns)operator(.)ident(add)operator(()ident(line)operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(lns)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reopen)delimiter(")>operator(,) ident(required) operator(=) integer(0)operator(,) ident(optional) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(reopen)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1) operator(&&) operator(!)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(return) ident(initialize_copy)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - - comment(// reset the state) - ident(doRewind)operator(()operator(\))operator(;) - ident(closedRead) operator(=) pre_constant(false)operator(;) - ident(closedWrite) operator(=) pre_constant(false)operator(;) - keyword(return) ident(initialize)operator(()ident(args)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rewind)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rewind)operator(()operator(\)) operator({) - ident(doRewind)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(doRewind)operator(()operator(\)) operator({) - local_variable(this)operator(.)ident(pos) operator(=) integer(0L)operator(;) - local_variable(this)operator(.)ident(eof) operator(=) pre_constant(false)operator(;) - local_variable(this)operator(.)ident(lineno) operator(=) integer(0)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(seek)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame)operator(=)pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(seek)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - comment(// MRI 1.8.7 behavior:) - comment(// checkOpen(\);) - ident(checkFinalized)operator(()operator(\))operator(;) - type(long) ident(amount) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - type(int) ident(whence) operator(=) ident(Stream)operator(.)ident(SEEK_SET)operator(;) - type(long) ident(newPosition) operator(=) ident(pos)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1) operator(&&) operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(whence) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - - keyword(if) operator(()ident(whence) operator(==) ident(Stream)operator(.)ident(SEEK_CUR)operator(\)) operator({) - ident(newPosition) operator(+=) ident(amount)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(whence) operator(==) ident(Stream)operator(.)ident(SEEK_END)operator(\)) operator({) - ident(newPosition) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(+) ident(amount)operator(;) - operator(}) keyword(else) operator({) - ident(newPosition) operator(=) ident(amount)operator(;) - operator(}) - - keyword(if) operator(()ident(newPosition) operator(<) integer(0)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()operator(\))operator(;) - - ident(pos) operator(=) ident(newPosition)operator(;) - ident(eof) operator(=) pre_constant(false)operator(;) - - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(string=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_string)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(reopen)operator(()keyword(new) ident(IRubyObject)type([]) operator({) ident(arg)operator(.)ident(convertToString)operator(()operator(\)) operator(})operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_sync)operator(()ident(IRubyObject) ident(args)operator(\)) operator({) - keyword(return) ident(args)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(string)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(string)operator(()operator(\)) operator({) - keyword(if) operator(()ident(internal) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(internal)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sync)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sysread)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(sysread)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) ident(read)operator(()ident(args)operator(\))operator(;) - - keyword(if) operator(()ident(isEOF)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(obj)operator(.)ident(isNil)operator(()operator(\)) operator(||) operator(()operator(()ident(RubyString)operator(\)) ident(obj)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\)) operator(==) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(obj)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(truncate)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(truncate)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(checkWritable)operator(()operator(\))operator(;) - - type(int) ident(len) operator(=) ident(RubyFixnum)operator(.)ident(fix2int)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newErrnoEINVALError)operator(()string<delimiter(")content(negative legnth)delimiter(")>operator(\))operator(;) - operator(}) - - ident(internal)operator(.)ident(modify)operator(()operator(\))operator(;) - ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()ident(len)operator(\))operator(;) - keyword(return) ident(arg)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ungetc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(ungetc)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(checkReadable)operator(()operator(\))operator(;) - - type(int) ident(c) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(arg)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(internal)operator(.)ident(modify)operator(()operator(\))operator(;) - ident(pos)operator(--)operator(;) - - ident(ByteList) ident(bytes) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(bytes)operator(.)ident(length)operator(()operator(\)) operator(<=) ident(pos)operator(\)) operator({) - ident(bytes)operator(.)ident(length)operator(()operator(()type(int)operator(\))ident(pos) operator(+) integer(1)operator(\))operator(;) - operator(}) - - ident(bytes)operator(.)ident(set)operator(()operator(()type(int)operator(\)) ident(pos)operator(,) ident(c)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(write)delimiter(")>operator(,) string<delimiter(")content(syswrite)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(write)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(writeInternal)operator(()ident(context)operator(,) ident(arg)operator(\))operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(writeInternal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(checkWritable)operator(()operator(\))operator(;) - ident(checkFrozen)operator(()operator(\))operator(;) - - ident(RubyString) ident(val) operator(=) ident(arg)operator(.)ident(asString)operator(()operator(\))operator(;) - ident(internal)operator(.)ident(modify)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(modes)operator(.)ident(isAppendable)operator(()operator(\))operator(\)) operator({) - ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(append)operator(()ident(val)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(pos) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - type(int) ident(left) operator(=) ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(-)operator(()type(int)operator(\))ident(pos)operator(;) - ident(internal)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(replace)operator(()operator(()type(int)operator(\))ident(pos)operator(,)pre_type(Math)operator(.)ident(min)operator(()ident(val)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(,)ident(left)operator(\))operator(,)ident(val)operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(pos) operator(+=) ident(val)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(val)operator(.)ident(isTaint)operator(()operator(\))operator(\)) operator({) - ident(internal)operator(.)ident(setTaint)operator(()pre_constant(true)operator(\))operator(;) - operator(}) - - keyword(return) ident(val)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(length)operator(()operator(\))operator(;) - operator(}) - - comment(/* rb: check_modifiable */) - annotation(@Override) - directive(protected) type(void) ident(checkFrozen)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(if) operator(()ident(internal)operator(.)ident(isFrozen)operator(()operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(not modifiable string)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/* rb: readable */) - directive(private) type(void) ident(checkReadable)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(if) operator(()ident(closedRead) operator(||) operator(!)ident(modes)operator(.)ident(isReadable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(not opened for reading)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - comment(/* rb: writable */) - directive(private) type(void) ident(checkWritable)operator(()operator(\)) operator({) - ident(checkInitialized)operator(()operator(\))operator(;) - keyword(if) operator(()ident(closedWrite) operator(||) operator(!)ident(modes)operator(.)ident(isWritable)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(not opened for writing)delimiter(")>operator(\))operator(;) - operator(}) - - comment(// Tainting here if we ever want it. (secure 4\)) - operator(}) - - directive(private) type(void) ident(checkInitialized)operator(()operator(\)) operator({) - keyword(if) operator(()ident(modes) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(uninitialized stream)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(checkFinalized)operator(()operator(\)) operator({) - keyword(if) operator(()ident(internal) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(not opened)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(checkOpen)operator(()operator(\)) operator({) - keyword(if) operator(()ident(closedRead) operator(&&) ident(closedWrite)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIOError)operator(()string<delimiter(")content(closed stream)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) type(void) ident(setupModes)operator(()operator(\)) operator({) - ident(closedWrite) operator(=) pre_constant(false)operator(;) - ident(closedRead) operator(=) pre_constant(false)operator(;) - - keyword(if) operator(()ident(modes)operator(.)ident(isReadOnly)operator(()operator(\))operator(\)) ident(closedWrite) operator(=) pre_constant(true)operator(;) - keyword(if) operator(()operator(!)ident(modes)operator(.)ident(isReadable)operator(()operator(\))operator(\)) ident(closedRead) operator(=) pre_constant(true)operator(;) - operator(}) -operator(}) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.joni.Matcher)operator(;) -keyword(import) include(org.joni.Option)operator(;) -keyword(import) include(org.joni.Regex)operator(;) -keyword(import) include(org.joni.Region)operator(;) -keyword(import) include(org.joni.encoding.Encoding)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** - * @author kscott - * - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(StringScanner)delimiter(")>operator(\)) -directive(public) type(class) class(RubyStringScanner) directive(extends) ident(RubyObject) operator({) - - directive(private) ident(RubyString) ident(str)operator(;) - directive(private) type(int) ident(pos) operator(=) integer(0)operator(;) - directive(private) type(int) ident(lastPos) operator(=) operator(-)integer(1)operator(;) - - directive(private) pre_type(Region) ident(regs)operator(;) - directive(private) type(int) ident(beg) operator(=) operator(-)integer(1)operator(;) - directive(private) type(int) ident(end) operator(=) operator(-)integer(1)operator(;) - comment(// not to be confused with RubyObject's flags) - directive(private) type(int) ident(scannerFlags)operator(;) - - directive(private) directive(static) directive(final) type(int) ident(MATCHED_STR_SCN_F) operator(=) integer(1) operator(<)operator(<) integer(11)operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(STRINGSCANNER_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyStringScanner)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createScannerClass)operator(()directive(final) ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(scannerClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(StringScanner)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(STRINGSCANNER_ALLOCATOR)operator(\))operator(;) - ident(scannerClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyStringScanner)operator(.)ident(class)operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(scannerClass)operator(.)ident(setConstant)operator(()string<delimiter(")content(Version)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(0.7.0)delimiter(")>operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(\))operator(;) - ident(scannerClass)operator(.)ident(setConstant)operator(()string<delimiter(")content(Id)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content($Id: strscan.c 13506 2007-09-24 08:56:24Z nobu $)delimiter(")>operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(\))operator(;) - - ident(RubyClass) ident(standardError) operator(=) ident(runtime)operator(.)ident(getStandardError)operator(()operator(\))operator(;) - ident(RubyClass) ident(error) operator(=) ident(scannerClass)operator(.)ident(defineClassUnder)operator(() - string<delimiter(")content(Error)delimiter(")>operator(,) ident(standardError)operator(,) ident(standardError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - - ident(RubyClass) ident(objClass) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(objClass)operator(.)ident(isConstantDefined)operator(()string<delimiter(")content(ScanError)delimiter(")>operator(\))operator(\)) operator({) - ident(objClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ScanError)delimiter(")>operator(,) ident(error)operator(\))operator(;) - operator(}) - - keyword(return) ident(scannerClass)operator(;) - operator(}) - - directive(private) type(void) ident(clearMatched)operator(()operator(\)) operator({) - ident(scannerFlags) operator(&=) operator(~)ident(MATCHED_STR_SCN_F)operator(;) - operator(}) - - directive(private) type(void) ident(setMatched)operator(()operator(\)) operator({) - ident(scannerFlags) operator(|=) ident(MATCHED_STR_SCN_F)operator(;) - operator(}) - - directive(private) type(boolean) ident(isMatched)operator(()operator(\)) operator({) - keyword(return) operator(()ident(scannerFlags) operator(&) ident(MATCHED_STR_SCN_F)operator(\)) operator(!=) integer(0)operator(;) - operator(}) - - directive(private) type(void) ident(check)operator(()operator(\)) operator({) - keyword(if) operator(()ident(str) operator(==) pre_constant(null)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(uninitialized StringScanner object)delimiter(")>operator(\))operator(;) - operator(}) - - directive(protected) ident(RubyStringScanner)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - comment(// second argument is allowed, but ignored (MRI\)) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(str) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(frame)operator(=)pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) local_variable(this)operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyStringScanner)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> - operator(+) ident(other)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected StringScanner\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyStringScanner) ident(otherScanner) operator(=) operator(()ident(RubyStringScanner)operator(\))ident(other)operator(;) - ident(str) operator(=) ident(otherScanner)operator(.)ident(str)operator(;) - ident(pos) operator(=) ident(otherScanner)operator(.)ident(pos)operator(;) - ident(lastPos) operator(=) ident(otherScanner)operator(.)ident(lastPos)operator(;) - ident(scannerFlags) operator(=) ident(otherScanner)operator(.)ident(scannerFlags)operator(;) - - ident(regs) operator(=) ident(otherScanner)operator(.)ident(regs) operator(!=) pre_constant(null) operator(?) ident(otherScanner)operator(.)ident(regs)operator(.)ident(clone)operator(()operator(\)) operator(:) pre_constant(null)operator(;) - ident(beg) operator(=) ident(otherScanner)operator(.)ident(beg)operator(;) - ident(end) operator(=) ident(otherScanner)operator(.)ident(end)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reset)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(reset)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(pos) operator(=) integer(0)operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(terminate)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(terminate)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(pos) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clear)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(clear)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(StringScanner#clear is obsolete; use #terminate instead)delimiter(")>operator(,) string<delimiter(")content(StringScanner#clear)delimiter(")>operator(,) string<delimiter(")content(#terminate)delimiter(")>operator(\))operator(;) - keyword(return) ident(terminate)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(string)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(string)operator(()operator(\)) operator({) - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(string=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_string)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(str)operator(\)) operator({) - local_variable(this)operator(.)ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(str)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(strDup)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(freeze)operator(()ident(context)operator(\))operator(;) - ident(pos) operator(=) integer(0)operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(concat)delimiter(")>operator(,) string<delimiter(")content(<<)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(concat)operator(()ident(IRubyObject) ident(obj)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(str)operator(.)ident(append)operator(()ident(obj)operator(\))operator(;) comment(// append will call convertToString(\)) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(pos)delimiter(")>operator(,) string<delimiter(")content(pointer)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyFixnum) ident(pos)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(pos=)delimiter(")>operator(,) string<delimiter(")content(pointer=)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(set_pos)operator(()ident(IRubyObject) ident(pos)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - type(int) ident(i) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(pos)operator(\))operator(;) - type(int) ident(size) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(i) operator(<) integer(0)operator(\)) ident(i) operator(+=) ident(size)operator(;) - keyword(if) operator(()ident(i) operator(<) integer(0) operator(||) ident(i) operator(>) ident(size)operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newRangeError)operator(()string<delimiter(")content(index out of range.)delimiter(")>operator(\))operator(;) - local_variable(this)operator(.)ident(pos) operator(=) ident(i)operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(i)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(extractRange)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(beg)operator(,) type(int) ident(end)operator(\)) operator({) - type(int) ident(size) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(beg) operator(>) ident(size)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(end) operator(>) ident(size)operator(\)) ident(end) operator(=) ident(size)operator(;) - keyword(return) ident(str)operator(.)ident(makeShared)operator(()ident(runtime)operator(,) ident(beg)operator(,) ident(end) operator(-) ident(beg)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(extractBegLen)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(beg)operator(,) type(int) ident(len)operator(\)) operator({) - keyword(assert) ident(len) operator(>=) integer(0)operator(;) - type(int) ident(size) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(;) - keyword(if) operator(()ident(beg) operator(>) ident(size)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(beg) operator(+) ident(len) operator(>) ident(size)operator(\)) ident(len) operator(=) ident(size) operator(-) ident(beg)operator(;) - keyword(return) ident(str)operator(.)ident(makeShared)operator(()ident(runtime)operator(,) ident(beg)operator(,) ident(len)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(scan)operator(()ident(IRubyObject) ident(regex)operator(,) type(boolean) ident(succptr)operator(,) type(boolean) ident(getstr)operator(,) type(boolean) ident(headonly)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(regex) keyword(instanceof) ident(RubyRegexp)operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(wrong argument type )delimiter(")> operator(+) ident(regex)operator(.)ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( (expected Regexp\))delimiter(")>operator(\))operator(;) - ident(check)operator(()operator(\))operator(;) - - ident(Regex) ident(pattern) operator(=) operator(()operator(()ident(RubyRegexp)operator(\))ident(regex)operator(\))operator(.)ident(getPattern)operator(()operator(\))operator(;) - - ident(clearMatched)operator(()operator(\))operator(;) - type(int) ident(rest) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(-) ident(pos)operator(;) - keyword(if) operator(()ident(rest) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - pre_type(Matcher) ident(matcher) operator(=) ident(pattern)operator(.)ident(matcher)operator(()ident(value)operator(.)ident(bytes)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(pos)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(\))operator(;) - - directive(final) type(int) ident(ret)operator(;) - keyword(if) operator(()ident(headonly)operator(\)) operator({) - ident(ret) operator(=) ident(matcher)operator(.)ident(match)operator(()ident(value)operator(.)ident(begin) operator(+) ident(pos)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(ret) operator(=) ident(matcher)operator(.)ident(search)operator(()ident(value)operator(.)ident(begin) operator(+) ident(pos)operator(,) ident(value)operator(.)ident(begin) operator(+) ident(value)operator(.)ident(realSize)operator(,) pre_type(Option)operator(.)ident(NONE)operator(\))operator(;) - operator(}) - - ident(regs) operator(=) ident(matcher)operator(.)ident(getRegion)operator(()operator(\))operator(;) - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - ident(beg) operator(=) ident(matcher)operator(.)ident(getBegin)operator(()operator(\))operator(;) - ident(end) operator(=) ident(matcher)operator(.)ident(getEnd)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(beg) operator(=) ident(regs)operator(.)ident(beg)operator([)integer(0)operator(])operator(;) - ident(end) operator(=) ident(regs)operator(.)ident(end)operator([)integer(0)operator(])operator(;) - operator(}) - - keyword(if) operator(()ident(ret) operator(<) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(setMatched)operator(()operator(\))operator(;) - - ident(lastPos) operator(=) ident(pos)operator(;) - keyword(if) operator(()ident(succptr)operator(\)) ident(pos) operator(+=) ident(end)operator(;) - keyword(return) ident(getstr) operator(?) ident(extractBegLen)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos)operator(,) ident(end)operator(\)) operator(:) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(end)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scan)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(scan)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(true)operator(,) pre_constant(true)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(match?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(match_p)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(skip)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(skip)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(true)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(check)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(check)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scan_full)delimiter(")>operator(,) ident(required) operator(=) integer(3)operator(\)) - directive(public) ident(IRubyObject) ident(scan_full)operator(()ident(IRubyObject) ident(regex)operator(,) ident(IRubyObject) ident(s)operator(,) ident(IRubyObject) ident(f)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) ident(s)operator(.)ident(isTrue)operator(()operator(\))operator(,) ident(f)operator(.)ident(isTrue)operator(()operator(\))operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(scan_until)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(scan_until)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(true)operator(,) pre_constant(true)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exist?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(exist_p)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(skip_until)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(skip_until)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(true)operator(,) pre_constant(false)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(check_until)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(check_until)operator(()ident(IRubyObject) ident(regex)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) pre_constant(false)operator(,) pre_constant(true)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(search_full)delimiter(")>operator(,) ident(required) operator(=) integer(3)operator(\)) - directive(public) ident(IRubyObject) ident(search_full)operator(()ident(IRubyObject) ident(regex)operator(,) ident(IRubyObject) ident(s)operator(,) ident(IRubyObject) ident(f)operator(\)) operator({) - keyword(return) ident(scan)operator(()ident(regex)operator(,) ident(s)operator(.)ident(isTrue)operator(()operator(\))operator(,) ident(f)operator(.)ident(isTrue)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(adjustRegisters)operator(()operator(\)) operator({) - ident(beg) operator(=) integer(0)operator(;) - ident(end) operator(=) ident(pos) operator(-) ident(lastPos)operator(;) - ident(regs) operator(=) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getch)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(getch)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(pos) operator(>=) ident(value)operator(.)ident(realSize)operator(\)) keyword(return) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(Encoding) ident(enc) operator(=) ident(runtime)operator(.)ident(getKCode)operator(()operator(\))operator(.)ident(getEncoding)operator(()operator(\))operator(;) - - type(int) ident(len)operator(;) - keyword(if) operator(()ident(enc)operator(.)ident(isSingleByte)operator(()operator(\))operator(\)) operator({) - ident(len) operator(=) integer(1)operator(;) - operator(}) keyword(else) operator({) - ident(len) operator(=) ident(enc)operator(.)ident(length)operator(()ident(value)operator(.)ident(bytes)operator([)ident(value)operator(.)ident(begin) operator(+) ident(pos)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(pos) operator(+) ident(len) operator(>) ident(value)operator(.)ident(realSize)operator(\)) ident(len) operator(=) ident(value)operator(.)ident(realSize) operator(-) ident(pos)operator(;) - ident(lastPos) operator(=) ident(pos)operator(;) - ident(pos) operator(+=) ident(len)operator(;) - - ident(setMatched)operator(()operator(\))operator(;) - ident(adjustRegisters)operator(()operator(\))operator(;) - - keyword(return) ident(extractRange)operator(()ident(runtime)operator(,) ident(lastPos) operator(+) ident(beg)operator(,) ident(lastPos) operator(+) ident(end)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(get_byte)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(get_byte)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - ident(lastPos) operator(=) ident(pos)operator(;) - ident(pos)operator(++)operator(;) - - ident(setMatched)operator(()operator(\))operator(;) - ident(adjustRegisters)operator(()operator(\))operator(;) - - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos) operator(+) ident(beg)operator(,) ident(lastPos) operator(+) ident(end)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getbyte)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(getbyte)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) - string<delimiter(")content(StringScanner#getbyte is obsolete; use #get_byte instead)delimiter(")>operator(,) - string<delimiter(")content(StringScanner#getbyte)delimiter(")>operator(,) string<delimiter(")content(#get_byte)delimiter(")>operator(\))operator(;) - keyword(return) ident(get_byte)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(peek)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(peek)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(length)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - - type(int) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(length)operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative string size (or size too big\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(value)operator(.)ident(realSize)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(infectBy)operator(()ident(str)operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(+) ident(len) operator(>) ident(value)operator(.)ident(realSize)operator(\)) ident(len) operator(=) ident(value)operator(.)ident(realSize) operator(-) ident(pos)operator(;) - - keyword(return) ident(extractBegLen)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(,) ident(len)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(peep)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(peep)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(length)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(() - ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(StringScanner#peep is obsolete; use #peek instead)delimiter(")>operator(,) - string<delimiter(")content(StringScanner#peep)delimiter(")>operator(,) string<delimiter(")content(#peek)delimiter(")>operator(\))operator(;) - keyword(return) ident(peek)operator(()ident(context)operator(,) ident(length)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(unscan)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(unscan)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) operator({) - ident(RubyClass) ident(errorClass) operator(=) ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(StringScanner)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Error)delimiter(")>operator(\))operator(;) - keyword(throw) keyword(new) ident(RaiseException)operator(()ident(RubyException)operator(.)ident(newException)operator(() - ident(runtime)operator(,) ident(errorClass)operator(,) string<delimiter(")content(unscan failed: previous match had failed)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - ident(pos) operator(=) ident(lastPos)operator(;) - ident(clearMatched)operator(()operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(beginning_of_line?)delimiter(")>operator(,) ident(alias) operator(=) string<delimiter(")content(bol?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(bol_p)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>) ident(value)operator(.)ident(realSize)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(==) integer(0)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(value)operator(.)ident(bytes)operator([)operator(()ident(value)operator(.)ident(begin) operator(+) ident(pos)operator(\)) operator(-) integer(1)operator(]) operator(==) operator(()type(byte)operator(\))string<delimiter(')content(\\n)delimiter(')> operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eos?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(eos_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(return) ident(pos) operator(>=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(empty?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(empty_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(StringScanner#empty? is obsolete; use #eos? instead)delimiter(")>operator(,) string<delimiter(")content(StringScanner#empty?)delimiter(")>operator(,) string<delimiter(")content(#eos?)delimiter(")>operator(\))operator(;) - keyword(return) ident(eos_p)operator(()ident(context)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rest?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(rest_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(return) ident(pos) operator(>=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(matched?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(matched_p)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(return) ident(isMatched)operator(()operator(\)) operator(?) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(matched)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(matched)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos) operator(+) ident(beg)operator(,) ident(lastPos) operator(+) ident(end)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(matched_size)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(matched_size)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(end) operator(-) ident(beg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(matchedsize)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(matchedsize)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(StringScanner#matchedsize is obsolete; use #matched_size instead)delimiter(")>operator(,) - string<delimiter(")content(StringScanner#matchedize)delimiter(")>operator(,) string<delimiter(")content(#matched_size)delimiter(")>operator(\))operator(;) - keyword(return) ident(matched_size)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(idx)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - type(int) ident(i) operator(=) ident(RubyNumeric)operator(.)ident(num2int)operator(()ident(idx)operator(\))operator(;) - - type(int) ident(numRegs) operator(=) ident(regs) operator(==) pre_constant(null) operator(?) integer(1) operator(:) ident(regs)operator(.)ident(numRegs)operator(;) - keyword(if) operator(()ident(i) operator(<) integer(0)operator(\)) ident(i) operator(+=) ident(numRegs)operator(;) - keyword(if) operator(()ident(i) operator(<) integer(0) operator(||) ident(i) operator(>=) ident(numRegs)operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(regs) operator(==) pre_constant(null)operator(\)) operator({) - keyword(assert) ident(i) operator(==) integer(0)operator(;) - keyword(if) operator(()ident(beg) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos) operator(+) ident(beg)operator(,) ident(lastPos) operator(+) ident(end)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()ident(regs)operator(.)ident(beg)operator([)ident(i)operator(]) operator(==) operator(-)integer(1)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos) operator(+) ident(regs)operator(.)ident(beg)operator([)ident(i)operator(])operator(,) ident(lastPos) operator(+) ident(regs)operator(.)ident(end)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pre_match)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pre_match)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) integer(0)operator(,) ident(lastPos) operator(+) ident(beg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(post_match)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(post_match)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(isMatched)operator(()operator(\))operator(\)) keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(lastPos) operator(+) ident(end)operator(,) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rest)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rest)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(value)operator(.)ident(realSize)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(infectBy)operator(()ident(str)operator(\))operator(;) - keyword(return) ident(extractRange)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(pos)operator(,) ident(value)operator(.)ident(realSize)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rest_size)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(rest_size)operator(()operator(\)) operator({) - ident(check)operator(()operator(\))operator(;) - ident(ByteList) ident(value) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(value)operator(.)ident(realSize)operator(\)) keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(value)operator(.)ident(realSize) operator(-) ident(pos)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(restsize)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(restsize)operator(()operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warning)operator(()ident(ID)operator(.)ident(DEPRECATED_METHOD)operator(,) string<delimiter(")content(StringScanner#restsize is obsolete; use #rest_size instead)delimiter(")>operator(,) string<delimiter(")content(StringScanner#restsize)delimiter(")>operator(,) string<delimiter(")content(#rest_size)delimiter(")>operator(\))operator(;) - keyword(return) ident(rest_size)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - keyword(if) operator(()ident(str) operator(==) pre_constant(null)operator(\)) keyword(return) ident(inspect)operator(()string<delimiter(")content((uninitialized\))delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(\)) keyword(return) ident(inspect)operator(()string<delimiter(")content(fin)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(==) integer(0)operator(\)) keyword(return) ident(inspect)operator(()ident(pos) operator(+) string<delimiter(")content(/)delimiter(")> operator(+) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(+) string<delimiter(")content( @ )delimiter(")> operator(+) ident(inspect2)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(inspect)operator(()ident(pos) operator(+) string<delimiter(")content(/)delimiter(")> operator(+) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(inspect1)operator(()operator(\)) operator(+) string<delimiter(")content( @ )delimiter(")> operator(+) ident(inspect2)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(inspect)operator(()pre_type(String) ident(msg)operator(\)) operator({) - ident(IRubyObject) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(#<)delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\)) operator(+) string<delimiter(")content( )delimiter(")> operator(+) ident(msg) operator(+) string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(if) operator(()ident(str) operator(!=) pre_constant(null)operator(\)) ident(result)operator(.)ident(infectBy)operator(()ident(str)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) directive(static) directive(final) type(int) ident(INSPECT_LENGTH) operator(=) integer(5)operator(;) - - directive(private) ident(IRubyObject) ident(inspect1)operator(()operator(\)) operator({) - keyword(if) operator(()ident(pos) operator(==) integer(0)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(pos) operator(>) ident(INSPECT_LENGTH)operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,) string<delimiter(")content(...)delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(.)ident(append)operator(()ident(str)operator(.)ident(substr)operator(()ident(pos) operator(-) ident(INSPECT_LENGTH)operator(,) ident(INSPECT_LENGTH)operator(\))operator(\))operator(.)ident(inspect)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(str)operator(.)ident(substr)operator(()integer(0)operator(,) ident(pos)operator(\))operator(.)ident(inspect)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(private) ident(IRubyObject) ident(inspect2)operator(()operator(\)) operator({) - keyword(if) operator(()ident(pos) operator(>=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize)operator(\)) keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - type(int) ident(len) operator(=) ident(str)operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(realSize) operator(-) ident(pos)operator(;) - keyword(if) operator(()ident(len) operator(>) ident(INSPECT_LENGTH)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyString)operator(\))ident(str)operator(.)ident(substr)operator(()ident(pos)operator(,) ident(INSPECT_LENGTH)operator(\))operator(\))operator(.)ident(cat)operator(()string<delimiter(")content(...)delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(.)ident(inspect)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(str)operator(.)ident(substr)operator(()ident(pos)operator(,) ident(len)operator(\))operator(.)ident(inspect)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(must_C_version)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(mustCversion)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.List)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.Frame)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.IdUtil)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.CallConfiguration)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) - -comment(/** - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Struct)delimiter(")>operator(\)) -directive(public) type(class) class(RubyStruct) directive(extends) ident(RubyObject) operator({) - directive(private) ident(IRubyObject)type([]) ident(values)operator(;) - - comment(/** - * Constructor for RubyStruct. - * @param runtime - * @param rubyClass - */) - directive(public) ident(RubyStruct)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - - type(int) ident(size) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(getInternalVariable)operator(()operator(()ident(RubyClass)operator(\))ident(rubyClass)operator(,) string<delimiter(")content(__size__)delimiter(")>operator(\))operator(\))operator(;) - - ident(values) operator(=) keyword(new) ident(IRubyObject)operator([)ident(size)operator(])operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(size)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(values)operator([)ident(i)operator(]) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createStructClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// TODO: NOT_ALLOCATABLE_ALLOCATOR may be ok here, but it's unclear how Structs) - comment(// work with marshalling. Confirm behavior and ensure we're doing this correctly. JRUBY-415) - ident(RubyClass) ident(structClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Struct)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setStructClass)operator(()ident(structClass)operator(\))operator(;) - ident(structClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(STRUCT)operator(;) - ident(structClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - ident(structClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyStruct)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(structClass)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(STRUCT)operator(;) - operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(getInternalVariable)operator(()ident(RubyClass) ident(type)operator(,) pre_type(String) ident(internedName)operator(\)) operator({) - ident(RubyClass) ident(structClass) operator(=) ident(type)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getStructClass)operator(()operator(\))operator(;) - ident(IRubyObject) ident(variable)operator(;) - - keyword(while) operator(()ident(type) operator(!=) pre_constant(null) operator(&&) ident(type) operator(!=) ident(structClass)operator(\)) operator({) - keyword(if) operator(()operator(()ident(variable) operator(=) ident(type)operator(.)ident(fastGetInternalVariable)operator(()ident(internedName)operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(variable)operator(;) - operator(}) - - ident(type) operator(=) ident(type)operator(.)ident(getSuperClass)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(type)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(RubyClass) ident(classOf)operator(()operator(\)) operator({) - keyword(return) ident(getMetaClass)operator(()operator(\)) keyword(instanceof) ident(MetaClass) operator(?) ident(getMetaClass)operator(()operator(\))operator(.)ident(getSuperClass)operator(()operator(\)) operator(:) ident(getMetaClass)operator(()operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(modify)operator(()operator(\)) operator({) - ident(testFrozen)operator(()string<delimiter(")content(Struct is frozen)delimiter(")>operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isTaint)operator(()operator(\)) operator(&&) ident(getRuntime)operator(()operator(\))operator(.)ident(getSafeLevel)operator(()operator(\)) operator(>=) integer(4)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newSecurityError)operator(()string<delimiter(")content(Insecure: can't modify struct)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(RubyFixnum) ident(hash)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(h) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(hashCode)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(h) operator(=) operator(()ident(h) operator(<)operator(<) integer(1)operator(\)) operator(|) operator(()ident(h) operator(<) integer(0) operator(?) integer(1) operator(:) integer(0)operator(\))operator(;) - ident(h) operator(^=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(values)operator([)ident(i)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(HASH)operator(,) string<delimiter(")content(hash)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(runtime)operator(.)ident(newFixnum)operator(()ident(h)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(setByName)operator(()pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - ident(modify)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,)ident(k)operator(=)ident(member)operator(.)ident(getLength)operator(()operator(\))operator(;) ident(i) operator(<) ident(k)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(member)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(values)operator([)ident(i)operator(]) operator(=) ident(value)operator(;) - operator(}) - operator(}) - - keyword(throw) ident(notStructMemberError)operator(()ident(name)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(getByName)operator(()pre_type(String) ident(name)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,)ident(k)operator(=)ident(member)operator(.)ident(getLength)operator(()operator(\))operator(;) ident(i) operator(<) ident(k)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(member)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(.)ident(equals)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(values)operator([)ident(i)operator(])operator(;) - operator(}) - operator(}) - - keyword(throw) ident(notStructMemberError)operator(()ident(name)operator(\))operator(;) - operator(}) - - comment(// Struct methods) - - comment(/** Create new Struct class. - * - * MRI: rb_struct_s_def / make_struct - * - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyClass) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - pre_type(String) ident(name) operator(=) pre_constant(null)operator(;) - type(boolean) ident(nilName) operator(=) pre_constant(false)operator(;) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(firstArgAsString) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(checkStringType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(firstArgAsString)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(name) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(firstArgAsString)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(nilName) operator(=) pre_constant(true)operator(;) - operator(}) - operator(}) - - ident(RubyArray) ident(member) operator(=) ident(runtime)operator(.)ident(newArray)operator(()operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) operator(()ident(name) operator(==) pre_constant(null) operator(&&) operator(!)ident(nilName)operator(\)) operator(?) integer(0) operator(:) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(member)operator(.)ident(append)operator(()ident(runtime)operator(.)ident(newSymbol)operator(()ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - ident(RubyClass) ident(newStruct)operator(;) - ident(RubyClass) ident(superClass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - keyword(if) operator(()ident(name) operator(==) pre_constant(null) operator(||) ident(nilName)operator(\)) operator({) - ident(newStruct) operator(=) ident(RubyClass)operator(.)ident(newClass)operator(()ident(runtime)operator(,) ident(superClass)operator(\))operator(;) - ident(newStruct)operator(.)ident(setAllocator)operator(()ident(STRUCT_INSTANCE_ALLOCATOR)operator(\))operator(;) - ident(newStruct)operator(.)ident(makeMetaClass)operator(()ident(superClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - ident(newStruct)operator(.)ident(inherit)operator(()ident(superClass)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)ident(IdUtil)operator(.)ident(isConstant)operator(()ident(name)operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(identifier )delimiter(")> operator(+) ident(name) operator(+) string<delimiter(")content( needs to be constant)delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - ident(IRubyObject) ident(type) operator(=) ident(superClass)operator(.)ident(getConstantAt)operator(()ident(name)operator(\))operator(;) - keyword(if) operator(()ident(type) operator(!=) pre_constant(null)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(Frame) ident(frame) operator(=) ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(;) - ident(runtime)operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(STRUCT_CONSTANT_REDEFINED)operator(,) ident(frame)operator(.)ident(getFile)operator(()operator(\))operator(,) ident(frame)operator(.)ident(getLine)operator(()operator(\))operator(,) string<delimiter(")content(redefining constant Struct::)delimiter(")> operator(+) ident(name)operator(,) ident(name)operator(\))operator(;) - ident(superClass)operator(.)ident(remove_const)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(newString)operator(()ident(name)operator(\))operator(\))operator(;) - operator(}) - ident(newStruct) operator(=) ident(superClass)operator(.)ident(defineClassUnder)operator(()ident(name)operator(,) ident(superClass)operator(,) ident(STRUCT_INSTANCE_ALLOCATOR)operator(\))operator(;) - operator(}) - - ident(newStruct)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(STRUCT)operator(;) - - ident(newStruct)operator(.)ident(fastSetInternalVariable)operator(()string<delimiter(")content(__size__)delimiter(")>operator(,) ident(member)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - ident(newStruct)operator(.)ident(fastSetInternalVariable)operator(()string<delimiter(")content(__member__)delimiter(")>operator(,) ident(member)operator(\))operator(;) - - ident(newStruct)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineAnnotatedMethods)operator(()ident(StructMethods)operator(.)ident(class)operator(\))operator(;) - - comment(// define access methods.) - keyword(for) operator(()type(int) ident(i) operator(=) operator(()ident(name) operator(==) pre_constant(null) operator(&&) operator(!)ident(nilName)operator(\)) operator(?) integer(0) operator(:) integer(1)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - directive(final) pre_type(String) ident(memberName) operator(=) ident(args)operator([)ident(i)operator(])operator(.)ident(asJavaString)operator(()operator(\))operator(;) - comment(// if we are storing a name as well, index is one too high for values) - directive(final) type(int) ident(index) operator(=) operator(()ident(name) operator(==) pre_constant(null) operator(&&) operator(!)ident(nilName)operator(\)) operator(?) ident(i) operator(:) ident(i) operator(-) integer(1)operator(;) - ident(newStruct)operator(.)ident(addMethod)operator(()ident(memberName)operator(,) keyword(new) ident(DynamicMethod)operator(()ident(newStruct)operator(,) pre_type(Visibility)operator(.)ident(PUBLIC)operator(,) ident(CallConfiguration)operator(.)ident(NO_FRAME_NO_SCOPE)operator(\)) operator({) - annotation(@Override) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(0)operator(,) integer(0)operator(\))operator(;) - keyword(return) operator(()operator(()ident(RubyStruct)operator(\))ident(self)operator(\))operator(.)ident(get)operator(()ident(index)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyStruct)operator(\))ident(self)operator(\))operator(.)ident(get)operator(()ident(index)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(DynamicMethod) ident(dup)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(})operator(\))operator(;) - ident(newStruct)operator(.)ident(addMethod)operator(()ident(memberName) operator(+) string<delimiter(")content(=)delimiter(")>operator(,) keyword(new) ident(DynamicMethod)operator(()ident(newStruct)operator(,) pre_type(Visibility)operator(.)ident(PUBLIC)operator(,) ident(CallConfiguration)operator(.)ident(NO_FRAME_NO_SCOPE)operator(\)) operator({) - annotation(@Override) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(1)operator(,) integer(1)operator(\))operator(;) - keyword(return) operator(()operator(()ident(RubyStruct)operator(\))ident(self)operator(\))operator(.)ident(set)operator(()ident(args)operator([)integer(0)operator(])operator(,) ident(index)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(self)operator(,) ident(RubyModule) ident(clazz)operator(,) pre_type(String) ident(name)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyStruct)operator(\))ident(self)operator(\))operator(.)ident(set)operator(()ident(arg)operator(,) ident(index)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(DynamicMethod) ident(dup)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(})operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - comment(// Struct bodies should be public by default, so set block visibility to public. JRUBY-1185.) - ident(block)operator(.)ident(getBinding)operator(()operator(\))operator(.)ident(setVisibility)operator(()pre_type(Visibility)operator(.)ident(PUBLIC)operator(\))operator(;) - ident(block)operator(.)ident(yield)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) pre_constant(null)operator(,) ident(newStruct)operator(,) ident(newStruct)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - keyword(return) ident(newStruct)operator(;) - operator(}) - - comment(// For binding purposes on the newly created struct types) - directive(public) directive(static) type(class) class(StructMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newStruct)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RubyStruct)operator(.)ident(newStruct)operator(()ident(recv)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) directive(static) ident(IRubyObject) ident(members)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(RubyStruct)operator(.)ident(members)operator(()ident(recv)operator(,) ident(block)operator(\))operator(;) - operator(}) - operator(}) - - comment(/** Create new Structure. - * - * MRI: struct_alloc - * - */) - directive(public) directive(static) ident(RubyStruct) ident(newStruct)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyStruct) ident(struct) operator(=) keyword(new) ident(RubyStruct)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(;) - - ident(struct)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - - keyword(return) ident(struct)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(modify)operator(()operator(\))operator(;) - - type(int) ident(size) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(getInternalVariable)operator(()ident(getMetaClass)operator(()operator(\))operator(,) string<delimiter(")content(__size__)delimiter(")>operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) ident(size)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(struct size differs ()delimiter(")> operator(+) ident(args)operator(.)ident(length) operator(+)string<delimiter(")content( for )delimiter(")> operator(+) ident(size) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(values)operator([)ident(i)operator(]) operator(=) ident(args)operator([)ident(i)operator(])operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyArray) ident(members)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - ident(RubyArray) ident(result) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(member)operator(.)ident(getLength)operator(()operator(\))operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,)ident(k)operator(=)ident(member)operator(.)ident(getLength)operator(()operator(\))operator(;) ident(i) operator(<) ident(k)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(member)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(RubyArray) ident(members)operator(()operator(\)) operator({) - keyword(return) ident(members)operator(()ident(classOf)operator(()operator(\))operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(RubyArray) ident(select)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(array) operator(=) ident(RubyArray)operator(.)ident(newArray)operator(()ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(values)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(array)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(set)operator(()ident(IRubyObject) ident(value)operator(,) type(int) ident(index)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - ident(modify)operator(()operator(\))operator(;) - - keyword(return) ident(values)operator([)ident(index)operator(]) operator(=) ident(value)operator(;) - operator(}) - - directive(private) ident(RaiseException) ident(notStructMemberError)operator(()pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newNameError)operator(()ident(name) operator(+) string<delimiter(")content( is not struct member)delimiter(")>operator(,) ident(name)operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(get)operator(()type(int) ident(index)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - keyword(return) ident(values)operator([)ident(index)operator(])operator(;) - operator(}) - - annotation(@Override) - directive(public) type(void) ident(copySpecialInstanceVariables)operator(()ident(IRubyObject) ident(clone)operator(\)) operator({) - ident(RubyStruct) ident(struct) operator(=) operator(()ident(RubyStruct)operator(\))ident(clone)operator(;) - ident(struct)operator(.)ident(values) operator(=) keyword(new) ident(IRubyObject)operator([)ident(values)operator(.)ident(length)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(values)operator(,) integer(0)operator(,) ident(struct)operator(.)ident(values)operator(,) integer(0)operator(,) ident(values)operator(.)ident(length)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(==)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_equal)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyStruct)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(if) operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\)) operator(!=) ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyStruct) ident(otherStruct) operator(=) operator(()ident(RubyStruct)operator(\))ident(other)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(equalInternal)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(,) ident(otherStruct)operator(.)ident(values)operator([)ident(i)operator(])operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(other)operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)operator(()ident(other) keyword(instanceof) ident(RubyStruct)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - keyword(if) operator(()ident(getMetaClass)operator(()operator(\)) operator(!=) ident(other)operator(.)ident(getMetaClass)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyStruct) ident(otherStruct) operator(=) operator(()ident(RubyStruct)operator(\))ident(other)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(eqlInternal)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(,) ident(otherStruct)operator(.)ident(values)operator([)ident(i)operator(])operator(\))operator(\)) keyword(return) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(runtime)operator(.)ident(getTrue)operator(()operator(\))operator(;) - operator(}) - - comment(/** inspect_struct - * - */) - directive(private) ident(IRubyObject) ident(inspectStruct)operator(()directive(final) ident(ThreadContext) ident(context)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - ident(ByteList) ident(buffer) operator(=) keyword(new) ident(ByteList)operator(()string<delimiter(")content(#<struct )delimiter(")>operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(.)ident(getBytes)operator(()operator(\))operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content( )delimiter(')>operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,)ident(k)operator(=)ident(member)operator(.)ident(getLength)operator(()operator(\))operator(;) ident(i) operator(<) ident(k)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(i) operator(>) integer(0)operator(\)) ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(,)delimiter(')>operator(\))operator(.)ident(append)operator(()string<delimiter(')content( )delimiter(')>operator(\))operator(;) - comment(// FIXME: MRI has special case for constants here ) - ident(buffer)operator(.)ident(append)operator(()ident(RubyString)operator(.)ident(objAsString)operator(()ident(context)operator(,) ident(member)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(=)delimiter(')>operator(\))operator(;) - ident(buffer)operator(.)ident(append)operator(()ident(inspect)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(buffer)operator(.)ident(append)operator(()string<delimiter(')content(>)delimiter(')>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(buffer)operator(\))operator(;) comment(// OBJ_INFECT ) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(inspect)delimiter(")>operator(,) string<delimiter(")content(to_s)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(inspect)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(isInspecting)operator(()local_variable(this)operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(#<struct )delimiter(")> operator(+) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content(:...>)delimiter(")>operator(\))operator(;) - - keyword(try) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(registerInspecting)operator(()local_variable(this)operator(\))operator(;) - keyword(return) ident(inspectStruct)operator(()ident(context)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(unregisterInspecting)operator(()local_variable(this)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_a)delimiter(")>operator(,) string<delimiter(")content(values)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(values)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(size)delimiter(")>operator(,) string<delimiter(")content(length)delimiter(")>operator(}) operator(\)) - directive(public) ident(RubyFixnum) ident(size)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(values)operator(.)ident(length)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(backtrace) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(values)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_pair)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyArray) ident(member) operator(=) operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(;) - - keyword(assert) operator(!)ident(member)operator(.)ident(isNil)operator(()operator(\)) operator(:) string<delimiter(")content(uninitialized struct)delimiter(")>operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(values)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()keyword(new) ident(IRubyObject)type([])operator({)ident(member)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(,) ident(values)operator([)ident(i)operator(])operator(})operator(\))operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(aref)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - keyword(if) operator(()ident(key) keyword(instanceof) ident(RubyString) operator(||) ident(key) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - keyword(return) ident(getByName)operator(()ident(key)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - - type(int) ident(idx) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(key)operator(\))operator(;) - - ident(idx) operator(=) ident(idx) operator(<) integer(0) operator(?) ident(values)operator(.)ident(length) operator(+) ident(idx) operator(:) ident(idx)operator(;) - - keyword(if) operator(()ident(idx) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(offset )delimiter(")> operator(+) ident(idx) operator(+) string<delimiter(")content( too large for struct (size:)delimiter(")> operator(+) ident(values)operator(.)ident(length) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(idx) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(offset )delimiter(")> operator(+) ident(idx) operator(+) string<delimiter(")content( too large for struct (size:)delimiter(")> operator(+) ident(values)operator(.)ident(length) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(values)operator([)ident(idx)operator(])operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(aset)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - keyword(if) operator(()ident(key) keyword(instanceof) ident(RubyString) operator(||) ident(key) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - keyword(return) ident(setByName)operator(()ident(key)operator(.)ident(asJavaString)operator(()operator(\))operator(,) ident(value)operator(\))operator(;) - operator(}) - - type(int) ident(idx) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(key)operator(\))operator(;) - - ident(idx) operator(=) ident(idx) operator(<) integer(0) operator(?) ident(values)operator(.)ident(length) operator(+) ident(idx) operator(:) ident(idx)operator(;) - - keyword(if) operator(()ident(idx) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(offset )delimiter(")> operator(+) ident(idx) operator(+) string<delimiter(")content( too large for struct (size:)delimiter(")> operator(+) ident(values)operator(.)ident(length) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(idx) operator(>=) ident(values)operator(.)ident(length)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newIndexError)operator(()string<delimiter(")content(offset )delimiter(")> operator(+) ident(idx) operator(+) string<delimiter(")content( too large for struct (size:)delimiter(")> operator(+) ident(values)operator(.)ident(length) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - - ident(modify)operator(()operator(\))operator(;) - keyword(return) ident(values)operator([)ident(idx)operator(]) operator(=) ident(value)operator(;) - operator(}) - - comment(// FIXME: This is copied code from RubyArray. Both RE, Struct, and Array should share one impl) - comment(// This is also hacky since I construct ruby objects to access ruby arrays through aref instead) - comment(// of something lower.) - annotation(@JRubyMethod)operator(()ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(values_at)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(long) ident(olen) operator(=) ident(values)operator(.)ident(length)operator(;) - ident(RubyArray) ident(result) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(args)operator(.)ident(length)operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(args)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(aref)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - keyword(continue)operator(;) - operator(}) - - type(long) ident(beglen)type([])operator(;) - keyword(if) operator(()operator(!)operator(()ident(args)operator([)ident(i)operator(]) keyword(instanceof) ident(RubyRange)operator(\))operator(\)) operator({) - operator(}) keyword(else) keyword(if) operator(()operator(()ident(beglen) operator(=) operator(()operator(()ident(RubyRange)operator(\)) ident(args)operator([)ident(i)operator(])operator(\))operator(.)ident(begLen)operator(()ident(olen)operator(,) integer(0)operator(\))operator(\)) operator(==) pre_constant(null)operator(\)) operator({) - keyword(continue)operator(;) - operator(}) keyword(else) operator({) - type(int) ident(beg) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(0)operator(])operator(;) - type(int) ident(len) operator(=) operator(()type(int)operator(\)) ident(beglen)operator([)integer(1)operator(])operator(;) - type(int) ident(end) operator(=) ident(len)operator(;) - keyword(for) operator(()type(int) ident(j) operator(=) integer(0)operator(;) ident(j) operator(<) ident(end)operator(;) ident(j)operator(++)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()ident(aref)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(j) operator(+) ident(beg)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(continue)operator(;) - operator(}) - ident(result)operator(.)ident(append)operator(()ident(aref)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) directive(static) type(void) ident(marshalTo)operator(()ident(RubyStruct) ident(struct)operator(,) ident(MarshalStream) ident(output)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(output)operator(.)ident(registerLinkTarget)operator(()ident(struct)operator(\))operator(;) - ident(output)operator(.)ident(dumpDefaultObjectHeader)operator(()string<delimiter(')content(S)delimiter(')>operator(,) ident(struct)operator(.)ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - - pre_type(List) ident(members) operator(=) operator(()operator(()ident(RubyArray)operator(\)) ident(getInternalVariable)operator(()ident(struct)operator(.)ident(classOf)operator(()operator(\))operator(,) string<delimiter(")content(__member__)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(;) - ident(output)operator(.)ident(writeInt)operator(()ident(members)operator(.)ident(size)operator(()operator(\))operator(\))operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(members)operator(.)ident(size)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - ident(RubySymbol) ident(name) operator(=) operator(()ident(RubySymbol)operator(\)) ident(members)operator(.)ident(get)operator(()ident(i)operator(\))operator(;) - ident(output)operator(.)ident(dumpObject)operator(()ident(name)operator(\))operator(;) - ident(output)operator(.)ident(dumpObject)operator(()ident(struct)operator(.)ident(values)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(static) ident(RubyStruct) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(RubySymbol) ident(className) operator(=) operator(()ident(RubySymbol)operator(\)) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(;) - ident(RubyClass) ident(rbClass) operator(=) ident(pathToClass)operator(()ident(runtime)operator(,) ident(className)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(rbClass) operator(==) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newNameError)operator(()string<delimiter(")content(uninitialized constant )delimiter(")> operator(+) ident(className)operator(,) ident(className)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) - - ident(RubyArray) ident(mem) operator(=) ident(members)operator(()ident(rbClass)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - type(int) ident(len) operator(=) ident(input)operator(.)ident(unmarshalInt)operator(()operator(\))operator(;) - ident(IRubyObject)type([]) ident(values) operator(=) keyword(new) ident(IRubyObject)operator([)ident(len)operator(])operator(;) - keyword(for)operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(values)operator([)ident(i)operator(]) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(RubyStruct) ident(result) operator(=) ident(newStruct)operator(()ident(rbClass)operator(,) ident(values)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(for)operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(len)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(IRubyObject) ident(slot) operator(=) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)ident(mem)operator(.)ident(eltInternal)operator(()ident(i)operator(\))operator(.)ident(toString)operator(()operator(\))operator(.)ident(equals)operator(()ident(slot)operator(.)ident(toString)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(struct )delimiter(")> operator(+) ident(rbClass)operator(.)ident(getName)operator(()operator(\)) operator(+) string<delimiter(")content( not compatible (:)delimiter(")> operator(+) ident(slot) operator(+) string<delimiter(")content( for :)delimiter(")> operator(+) ident(mem)operator(.)ident(eltInternal)operator(()ident(i)operator(\)) operator(+) string<delimiter(")content(\))delimiter(")>operator(\))operator(;) - operator(}) - ident(result)operator(.)ident(aset)operator(()ident(runtime)operator(.)ident(newFixnum)operator(()ident(i)operator(\))operator(,) ident(input)operator(.)ident(unmarshalObject)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) directive(static) ident(RubyClass) ident(pathToClass)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(path)operator(\)) operator({) - comment(// FIXME: Throw the right ArgumentError's if the class is missing) - comment(// or if it's a module.) - keyword(return) operator(()ident(RubyClass)operator(\)) ident(runtime)operator(.)ident(getClassFromPath)operator(()ident(path)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(STRUCT_INSTANCE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyStruct) ident(instance) operator(=) keyword(new) ident(RubyStruct)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - - ident(instance)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - annotation(@Override) - annotation(@JRubyMethod)operator(()ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(arg)operator(\)) keyword(return) local_variable(this)operator(;) - ident(RubyStruct) ident(original) operator(=) operator(()ident(RubyStruct)operator(\)) ident(arg)operator(;) - - ident(values) operator(=) keyword(new) ident(IRubyObject)operator([)ident(original)operator(.)ident(values)operator(.)ident(length)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(original)operator(.)ident(values)operator(,) integer(0)operator(,) ident(values)operator(,) integer(0)operator(,) ident(original)operator(.)ident(values)operator(.)ident(length)operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - -operator(}) -comment(/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Derek Berner <derek.berner@state.nm.us> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C\) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.concurrent.locks.ReentrantLock)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.BlockCallback)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) - -comment(/** - * Represents a Ruby symbol (e.g. :bar\) - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Symbol)delimiter(")>operator(\)) -directive(public) type(class) class(RubySymbol) directive(extends) ident(RubyObject) operator({) - directive(private) directive(final) pre_type(String) ident(symbol)operator(;) - directive(private) directive(final) type(int) ident(id)operator(;) - directive(private) directive(final) ident(ByteList) ident(symbolBytes)operator(;) - - comment(/** - * - * @param runtime - * @param internedSymbol the String value of the new Symbol. This <em>must</em> - * have been previously interned - */) - directive(private) ident(RubySymbol)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(internedSymbol)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getSymbol)operator(()operator(\))operator(,) pre_constant(false)operator(\))operator(;) - comment(// symbol string *must* be interned) - - keyword(assert) ident(internedSymbol) operator(==) ident(internedSymbol)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedSymbol) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - - local_variable(this)operator(.)ident(symbol) operator(=) ident(internedSymbol)operator(;) - local_variable(this)operator(.)ident(symbolBytes) operator(=) ident(ByteList)operator(.)ident(create)operator(()ident(symbol)operator(\))operator(;) - - local_variable(this)operator(.)ident(id) operator(=) ident(runtime)operator(.)ident(allocSymbolId)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createSymbolClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(symbolClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Symbol)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setSymbol)operator(()ident(symbolClass)operator(\))operator(;) - ident(RubyClass) ident(symbolMetaClass) operator(=) ident(symbolClass)operator(.)ident(getMetaClass)operator(()operator(\))operator(;) - ident(symbolClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(SYMBOL)operator(;) - ident(symbolClass)operator(.)ident(kindOf) operator(=) keyword(new) ident(RubyModule)operator(.)ident(KindOf)operator(()operator(\)) operator({) - directive(public) type(boolean) ident(isKindOf)operator(()ident(IRubyObject) ident(obj)operator(,) ident(RubyModule) ident(type)operator(\)) operator({) - keyword(return) ident(obj) keyword(instanceof) ident(RubySymbol)operator(;) - operator(}) - operator(})operator(;) - - ident(symbolClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubySymbol)operator(.)ident(class)operator(\))operator(;) - ident(symbolMetaClass)operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - keyword(return) ident(symbolClass)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(getNativeTypeIndex)operator(()operator(\)) operator({) - keyword(return) ident(ClassIndex)operator(.)ident(SYMBOL)operator(;) - operator(}) - - comment(/** rb_to_id - * - * @return a String representation of the symbol - */) - annotation(@Override) - directive(public) pre_type(String) ident(asJavaString)operator(()operator(\)) operator({) - keyword(return) ident(symbol)operator(;) - operator(}) - - comment(/** short circuit for Symbol key comparison - * - */) - annotation(@Override) - directive(public) directive(final) type(boolean) ident(eql)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) ident(other) operator(==) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(isImmediate)operator(()operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyClass) ident(getSingletonClass)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't define singleton)delimiter(")>operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubySymbol) ident(getSymbolLong)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(id)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getSymbolTable)operator(()operator(\))operator(.)ident(lookup)operator(()ident(id)operator(\))operator(;) - operator(}) - - comment(/* Symbol class methods. - * - */) - - directive(public) directive(static) ident(RubySymbol) ident(newSymbol)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(String) ident(name)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getSymbolTable)operator(()operator(\))operator(.)ident(getSymbol)operator(()ident(name)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_i)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(to_i)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(id)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_int)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(to_int)operator(()operator(\)) operator({) - keyword(if) operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getVerbose)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(SYMBOL_AS_INTEGER)operator(,) string<delimiter(")content(treating Symbol as an integer)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(to_i)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(:)delimiter(")> operator(+) - operator(()ident(isSymbolName)operator(()ident(symbol)operator(\)) operator(?) ident(symbol) operator(:) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(runtime)operator(,) ident(symbolBytes)operator(\))operator(.)ident(dump)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_s)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - keyword(return) ident(RubyString)operator(.)ident(newStringShared)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(symbolBytes)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(id2name)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(id2name)operator(()operator(\)) operator({) - keyword(return) ident(to_s)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(===)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_eqq)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) local_variable(super)operator(.)ident(op_equal)operator(()ident(context)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(hashCode)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@Override) - directive(public) type(int) ident(hashCode)operator(()operator(\)) operator({) - keyword(return) ident(id)operator(;) - operator(}) - - directive(public) type(int) ident(getId)operator(()operator(\)) operator({) - keyword(return) ident(id)operator(;) - operator(}) - - annotation(@Override) - directive(public) type(boolean) ident(equals)operator(()pre_type(Object) ident(other)operator(\)) operator({) - keyword(return) ident(other) operator(==) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_sym)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_sym)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(freeze)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@Override) - directive(public) ident(IRubyObject) ident(taint)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) directive(static) type(class) class(ToProcCallback) directive(implements) ident(BlockCallback) operator({) - directive(private) ident(RubySymbol) ident(symbol)operator(;) - directive(public) ident(ToProcCallback)operator(()ident(RubySymbol) ident(symbol)operator(\)) operator({) - local_variable(this)operator(.)ident(symbol) operator(=) ident(symbol)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(ctx)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(blk)operator(\)) operator({) - ident(IRubyObject)type([]) ident(currentArgs) operator(=) ident(args)operator(;) - keyword(switch)operator(()ident(currentArgs)operator(.)ident(length)operator(\)) operator({) - keyword(case) integer(0)operator(:) keyword(throw) ident(symbol)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(no receiver given)delimiter(")>operator(\))operator(;) - keyword(case) integer(1)operator(:) operator({) - keyword(if)operator(()operator(()ident(currentArgs)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyArray)operator(\)) operator(&&) operator(()operator(()ident(RubyArray)operator(\))ident(currentArgs)operator([)integer(0)operator(])operator(\))operator(.)ident(getLength)operator(()operator(\)) operator(!=) integer(0)operator(\)) operator({) - comment(// This is needed to unpack stuff) - ident(currentArgs) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(currentArgs)operator([)integer(0)operator(])operator(\))operator(.)ident(toJavaArrayMaybeUnsafe)operator(()operator(\))operator(;) - ident(IRubyObject)type([]) ident(args2) operator(=) keyword(new) ident(IRubyObject)operator([)ident(currentArgs)operator(.)ident(length)operator(-)integer(1)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(currentArgs)operator(,) integer(1)operator(,) ident(args2)operator(,) integer(0)operator(,) ident(args2)operator(.)ident(length)operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(ctx)operator(,) ident(currentArgs)operator([)integer(0)operator(])operator(,) ident(symbol)operator(.)ident(symbol)operator(,) ident(args2)operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(ctx)operator(,) ident(currentArgs)operator([)integer(0)operator(])operator(,) ident(symbol)operator(.)ident(symbol)operator(\))operator(;) - operator(}) - operator(}) - keyword(default)operator(:) operator({) - ident(IRubyObject)type([]) ident(args2) operator(=) keyword(new) ident(IRubyObject)operator([)ident(currentArgs)operator(.)ident(length)operator(-)integer(1)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(currentArgs)operator(,) integer(1)operator(,) ident(args2)operator(,) integer(0)operator(,) ident(args2)operator(.)ident(length)operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(ctx)operator(,) ident(currentArgs)operator([)integer(0)operator(])operator(,) ident(symbol)operator(.)ident(symbol)operator(,) ident(args2)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - comment(/* - @JRubyMethod - public IRubyObject to_proc(\) { - return RubyProc.newProc(getRuntime(\), - CallBlock.newCallClosure(this, getRuntime(\).getSymbol(\), Arity.noArguments(\), new ToProcCallback(this\), getRuntime(\).getCurrentContext(\)\), - Block.Type.PROC\); - } - */) - directive(private) directive(static) type(boolean) ident(isIdentStart)operator(()type(char) ident(c)operator(\)) operator({) - keyword(return) operator(()operator(()ident(c) operator(>=) string<delimiter(')content(a)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(z)delimiter(')>operator(\))operator(||) operator(()ident(c) operator(>=) string<delimiter(')content(A)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(Z)delimiter(')>operator(\)) - operator(||) ident(c) operator(==) string<delimiter(')content(_)delimiter(')>operator(\))operator(;) - operator(}) - directive(private) directive(static) type(boolean) ident(isIdentChar)operator(()type(char) ident(c)operator(\)) operator({) - keyword(return) operator(()operator(()ident(c) operator(>=) string<delimiter(')content(a)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(z)delimiter(')>operator(\)) operator(||) operator(()ident(c) operator(>=) string<delimiter(')content(0)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(9)delimiter(')>operator(\)) operator(||) operator(()ident(c) operator(>=) string<delimiter(')content(A)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(Z)delimiter(')>operator(\)) - operator(||) ident(c) operator(==) string<delimiter(')content(_)delimiter(')>operator(\))operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(isIdentifier)operator(()pre_type(String) ident(s)operator(\)) operator({) - keyword(if) operator(()ident(s) operator(==) pre_constant(null) operator(||) ident(s)operator(.)ident(length)operator(()operator(\)) operator(<=) integer(0)operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(isIdentStart)operator(()ident(s)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(1)operator(;) ident(i) operator(<) ident(s)operator(.)ident(length)operator(()operator(\))operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(isIdentChar)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(\))operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(true)operator(;) - operator(}) - - comment(/** - * is_special_global_name from parse.c. - * @param s - * @return - */) - directive(private) directive(static) type(boolean) ident(isSpecialGlobalName)operator(()pre_type(String) ident(s)operator(\)) operator({) - keyword(if) operator(()ident(s) operator(==) pre_constant(null) operator(||) ident(s)operator(.)ident(length)operator(()operator(\)) operator(<=) integer(0)operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - type(int) ident(length) operator(=) ident(s)operator(.)ident(length)operator(()operator(\))operator(;) - - keyword(switch) operator(()ident(s)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(\)) operator({) - keyword(case) string<delimiter(')content(~)delimiter(')>operator(:) keyword(case) string<delimiter(')content(*)delimiter(')>operator(:) keyword(case) string<delimiter(')content($)delimiter(')>operator(:) keyword(case) string<delimiter(')content(?)delimiter(')>operator(:) keyword(case) string<delimiter(')content(!)delimiter(')>operator(:) keyword(case) string<delimiter(')content(@)delimiter(')>operator(:) keyword(case) string<delimiter(')content(/)delimiter(')>operator(:) keyword(case) string<delimiter(')char(\\\\)delimiter(')>operator(:) - keyword(case) string<delimiter(')content(;)delimiter(')>operator(:) keyword(case) string<delimiter(')content(,)delimiter(')>operator(:) keyword(case) string<delimiter(')content(.)delimiter(')>operator(:) keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) keyword(case) string<delimiter(')content(:)delimiter(')>operator(:) keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) keyword(case) string<delimiter(')content(\\")delimiter(')>operator(:) - keyword(case) string<delimiter(')content(&)delimiter(')>operator(:) keyword(case) string<delimiter(')content(`)delimiter(')>operator(:) keyword(case) string<delimiter(')char(\\')delimiter(')>operator(:) keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) keyword(case) string<delimiter(')content(0)delimiter(')>operator(:) - keyword(return) ident(length) operator(==) integer(1)operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) ident(isIdentChar)operator(()ident(s)operator(.)ident(charAt)operator(()integer(1)operator(\))operator(\))operator(\))operator(\))operator(;) - - keyword(default)operator(:) - comment(// we already confirmed above that length > 0) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)pre_type(Character)operator(.)ident(isDigit)operator(()ident(s)operator(.)ident(charAt)operator(()ident(i)operator(\))operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(true)operator(;) - operator(}) - - directive(private) directive(static) type(boolean) ident(isSymbolName)operator(()pre_type(String) ident(s)operator(\)) operator({) - keyword(if) operator(()ident(s) operator(==) pre_constant(null) operator(||) ident(s)operator(.)ident(length)operator(()operator(\)) operator(<) integer(1)operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - type(int) ident(length) operator(=) ident(s)operator(.)ident(length)operator(()operator(\))operator(;) - - type(char) ident(c) operator(=) ident(s)operator(.)ident(charAt)operator(()integer(0)operator(\))operator(;) - keyword(switch) operator(()ident(c)operator(\)) operator({) - keyword(case) string<delimiter(')content($)delimiter(')>operator(:) - keyword(if) operator(()ident(length) operator(>) integer(1) operator(&&) ident(isSpecialGlobalName)operator(()ident(s)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - keyword(return) ident(isIdentifier)operator(()ident(s)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(@)delimiter(')>operator(:) - type(int) ident(offset) operator(=) integer(1)operator(;) - keyword(if) operator(()ident(length) operator(>=) integer(2) operator(&&) ident(s)operator(.)ident(charAt)operator(()integer(1)operator(\)) operator(==) string<delimiter(')content(@)delimiter(')>operator(\)) operator({) - ident(offset)operator(++)operator(;) - operator(}) - - keyword(return) ident(isIdentifier)operator(()ident(s)operator(.)ident(substring)operator(()ident(offset)operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(<)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) operator(()ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(<<)delimiter(")>operator(\)) operator(||) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(<=)delimiter(")>operator(\))operator(\))operator(\)) operator(||) - operator(()ident(length) operator(==) integer(3) operator(&&) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(<=>)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(>)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1)operator(\)) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) operator(()ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(>>)delimiter(")>operator(\)) operator(||) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(>=)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(=)delimiter(')>operator(:) - keyword(return) operator(()operator(()ident(length) operator(==) integer(2) operator(&&) operator(()ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(==)delimiter(")>operator(\)) operator(||) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(=~)delimiter(")>operator(\))operator(\))operator(\)) operator(||) - operator(()ident(length) operator(==) integer(3) operator(&&) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(===)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(*)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(**)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(+)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(+@)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(-)delimiter(')>operator(:) - keyword(return) operator(()ident(length) operator(==) integer(1) operator(||) operator(()ident(length) operator(==) integer(2) operator(&&) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content(-@)delimiter(")>operator(\))operator(\))operator(\))operator(;) - keyword(case) string<delimiter(')content(|)delimiter(')>operator(:) keyword(case) string<delimiter(')content(^)delimiter(')>operator(:) keyword(case) string<delimiter(')content(&)delimiter(')>operator(:) keyword(case) string<delimiter(')content(/)delimiter(')>operator(:) keyword(case) string<delimiter(')content(%)delimiter(')>operator(:) keyword(case) string<delimiter(')content(~)delimiter(')>operator(:) keyword(case) string<delimiter(')content(`)delimiter(')>operator(:) - keyword(return) ident(length) operator(==) integer(1)operator(;) - keyword(case) string<delimiter(')content([)delimiter(')>operator(:) - keyword(return) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content([])delimiter(")>operator(\)) operator(||) ident(s)operator(.)ident(equals)operator(()string<delimiter(")content([]=)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(isIdentStart)operator(()ident(c)operator(\))operator(\)) operator({) - keyword(return) pre_constant(false)operator(;) - operator(}) - - type(boolean) ident(localID) operator(=) operator(()ident(c) operator(>=) string<delimiter(')content(a)delimiter(')> operator(&&) ident(c) operator(<=) string<delimiter(')content(z)delimiter(')>operator(\))operator(;) - type(int) ident(last) operator(=) integer(1)operator(;) - - keyword(for) operator(()operator(;) ident(last) operator(<) ident(length)operator(;) ident(last)operator(++)operator(\)) operator({) - type(char) ident(d) operator(=) ident(s)operator(.)ident(charAt)operator(()ident(last)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isIdentChar)operator(()ident(d)operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(last) operator(==) ident(length)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(localID) operator(&&) ident(last) operator(==) ident(length) operator(-) integer(1)operator(\)) operator({) - type(char) ident(d) operator(=) ident(s)operator(.)ident(charAt)operator(()ident(last)operator(\))operator(;) - - keyword(return) ident(d) operator(==) string<delimiter(')content(!)delimiter(')> operator(||) ident(d) operator(==) string<delimiter(')content(?)delimiter(')> operator(||) ident(d) operator(==) string<delimiter(')content(=)delimiter(')>operator(;) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(all_symbols)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(all_symbols)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getSymbolTable)operator(()operator(\))operator(.)ident(all_symbols)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubySymbol) ident(unmarshalFrom)operator(()ident(UnmarshalStream) ident(input)operator(\)) directive(throws) ident(java)operator(.)ident(io)operator(.)ident(IOException) operator({) - ident(RubySymbol) ident(result) operator(=) ident(newSymbol)operator(()ident(input)operator(.)ident(getRuntime)operator(()operator(\))operator(,) ident(RubyString)operator(.)ident(byteListToString)operator(()ident(input)operator(.)ident(unmarshalString)operator(()operator(\))operator(\))operator(\))operator(;) - ident(input)operator(.)ident(registerLinkTarget)operator(()ident(result)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - directive(public) directive(static) type(class) class(SymbolTable) operator({) - directive(static) directive(final) type(int) ident(DEFAULT_INITIAL_CAPACITY) operator(=) integer(2048)operator(;) comment(// *must* be power of 2!) - directive(static) directive(final) type(int) ident(MAXIMUM_CAPACITY) operator(=) integer(1) operator(<)operator(<) integer(30)operator(;) - directive(static) directive(final) type(float) ident(DEFAULT_LOAD_FACTOR) operator(=) float(0.75f)operator(;) - - directive(private) directive(final) pre_type(ReentrantLock) ident(tableLock) operator(=) keyword(new) pre_type(ReentrantLock)operator(()operator(\))operator(;) - directive(private) directive(volatile) ident(SymbolEntry)type([]) ident(symbolTable)operator(;) - directive(private) type(int) ident(size)operator(;) - directive(private) type(int) ident(threshold)operator(;) - directive(private) directive(final) type(float) ident(loadFactor)operator(;) - directive(private) directive(final) ident(Ruby) ident(runtime)operator(;) - - directive(public) ident(SymbolTable)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(this)operator(.)ident(runtime) operator(=) ident(runtime)operator(;) - local_variable(this)operator(.)ident(loadFactor) operator(=) ident(DEFAULT_LOAD_FACTOR)operator(;) - local_variable(this)operator(.)ident(threshold) operator(=) operator(()type(int)operator(\))operator(()ident(DEFAULT_INITIAL_CAPACITY) operator(*) ident(DEFAULT_LOAD_FACTOR)operator(\))operator(;) - local_variable(this)operator(.)ident(symbolTable) operator(=) keyword(new) ident(SymbolEntry)operator([)ident(DEFAULT_INITIAL_CAPACITY)operator(])operator(;) - operator(}) - - comment(// note all fields are final -- rehash creates new entries when necessary.) - comment(// as documented in java.util.concurrent.ConcurrentHashMap.java, that will) - comment(// statistically affect only a small percentage (< 20%\) of entries for a given rehash.) - directive(static) type(class) class(SymbolEntry) operator({) - directive(final) type(int) ident(hash)operator(;) - directive(final) pre_type(String) ident(name)operator(;) - directive(final) ident(RubySymbol) ident(symbol)operator(;) - directive(final) ident(SymbolEntry) ident(next)operator(;) - - ident(SymbolEntry)operator(()type(int) ident(hash)operator(,) pre_type(String) ident(name)operator(,) ident(RubySymbol) ident(symbol)operator(,) ident(SymbolEntry) ident(next)operator(\)) operator({) - local_variable(this)operator(.)ident(hash) operator(=) ident(hash)operator(;) - local_variable(this)operator(.)ident(name) operator(=) ident(name)operator(;) - local_variable(this)operator(.)ident(symbol) operator(=) ident(symbol)operator(;) - local_variable(this)operator(.)ident(next) operator(=) ident(next)operator(;) - operator(}) - operator(}) - - directive(public) ident(RubySymbol) ident(getSymbol)operator(()pre_type(String) ident(name)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - ident(SymbolEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(symbolTable)operator(\))operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(tableLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(size) operator(+) integer(1)operator(\)) operator(>) ident(threshold)operator(\)) operator({) - ident(table) operator(=) ident(rehash)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(table) operator(=) ident(symbolTable)operator(;) - operator(}) - type(int) ident(index)operator(;) - comment(// try lookup again under lock) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) ident(table)operator([)ident(index) operator(=) ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - pre_type(String) ident(internedName)operator(;) - ident(RubySymbol) ident(symbol) operator(=) keyword(new) ident(RubySymbol)operator(()ident(runtime)operator(,) ident(internedName) operator(=) ident(name)operator(.)ident(intern)operator(()operator(\))operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) keyword(new) ident(SymbolEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(symbol)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(size) operator(=) ident(potentialNewSize)operator(;) - comment(// write-volatile) - ident(symbolTable) operator(=) ident(table)operator(;) - keyword(return) ident(symbol)operator(;) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) ident(RubySymbol) ident(fastGetSymbol)operator(()pre_type(String) ident(internedName)operator(\)) operator({) - keyword(assert) ident(internedName) operator(==) ident(internedName)operator(.)ident(intern)operator(()operator(\)) operator(:) ident(internedName) operator(+) string<delimiter(")content( is not interned)delimiter(")>operator(;) - ident(SymbolEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(symbolTable)operator(\))operator([)ident(internedName)operator(.)ident(hashCode)operator(()operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - pre_type(ReentrantLock) ident(lock)operator(;) - operator(()ident(lock) operator(=) ident(tableLock)operator(\))operator(.)ident(lock)operator(()operator(\))operator(;) - keyword(try) operator({) - type(int) ident(potentialNewSize)operator(;) - keyword(if) operator(()operator(()ident(potentialNewSize) operator(=) ident(size) operator(+) integer(1)operator(\)) operator(>) ident(threshold)operator(\)) operator({) - ident(table) operator(=) ident(rehash)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(table) operator(=) ident(symbolTable)operator(;) - operator(}) - type(int) ident(index)operator(;) - type(int) ident(hash)operator(;) - comment(// try lookup again under lock) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) ident(table)operator([)ident(index) operator(=) operator(()ident(hash) operator(=) ident(internedName)operator(.)ident(hashCode)operator(()operator(\))operator(\)) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(internedName) operator(==) ident(e)operator(.)ident(name)operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - ident(RubySymbol) ident(symbol) operator(=) keyword(new) ident(RubySymbol)operator(()ident(runtime)operator(,) ident(internedName)operator(\))operator(;) - ident(table)operator([)ident(index)operator(]) operator(=) keyword(new) ident(SymbolEntry)operator(()ident(hash)operator(,) ident(internedName)operator(,) ident(symbol)operator(,) ident(table)operator([)ident(index)operator(])operator(\))operator(;) - ident(size) operator(=) ident(potentialNewSize)operator(;) - comment(// write-volatile) - ident(symbolTable) operator(=) ident(table)operator(;) - keyword(return) ident(symbol)operator(;) - operator(}) keyword(finally) operator({) - ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - operator(}) - - comment(// backwards-compatibility, but threadsafe now) - directive(public) ident(RubySymbol) ident(lookup)operator(()pre_type(String) ident(name)operator(\)) operator({) - type(int) ident(hash) operator(=) ident(name)operator(.)ident(hashCode)operator(()operator(\))operator(;) - ident(SymbolEntry)type([]) ident(table)operator(;) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) operator(()ident(table) operator(=) ident(symbolTable)operator(\))operator([)ident(hash) operator(&) operator(()ident(table)operator(.)ident(length) operator(-) integer(1)operator(\))operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(hash) operator(==) ident(e)operator(.)ident(hash) operator(&&) ident(name)operator(.)ident(equals)operator(()ident(e)operator(.)ident(name)operator(\))operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(public) ident(RubySymbol) ident(lookup)operator(()type(long) ident(id)operator(\)) operator({) - ident(SymbolEntry)type([]) ident(table) operator(=) ident(symbolTable)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - keyword(if) operator(()ident(id) operator(==) ident(e)operator(.)ident(symbol)operator(.)ident(id)operator(\)) operator({) - keyword(return) ident(e)operator(.)ident(symbol)operator(;) - operator(}) - operator(}) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - - directive(public) ident(RubyArray) ident(all_symbols)operator(()operator(\)) operator({) - ident(SymbolEntry)type([]) ident(table) operator(=) local_variable(this)operator(.)ident(symbolTable)operator(;) - ident(RubyArray) ident(array) operator(=) ident(runtime)operator(.)ident(newArray)operator(()local_variable(this)operator(.)ident(size)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(table)operator(.)ident(length)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - keyword(for) operator(()ident(SymbolEntry) ident(e) operator(=) ident(table)operator([)ident(i)operator(])operator(;) ident(e) operator(!=) pre_constant(null)operator(;) ident(e) operator(=) ident(e)operator(.)ident(next)operator(\)) operator({) - ident(array)operator(.)ident(append)operator(()ident(e)operator(.)ident(symbol)operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(array)operator(;) - operator(}) - - comment(// not so backwards-compatible here, but no one should have been) - comment(// calling this anyway.) - annotation(@Deprecated) - directive(public) type(void) ident(store)operator(()ident(RubySymbol) ident(symbol)operator(\)) operator({) - keyword(throw) keyword(new) exception(UnsupportedOperationException)operator(()operator(\))operator(;) - operator(}) - - directive(private) ident(SymbolEntry)type([]) ident(rehash)operator(()operator(\)) operator({) - ident(SymbolEntry)type([]) ident(oldTable) operator(=) ident(symbolTable)operator(;) - type(int) ident(oldCapacity)operator(;) - keyword(if) operator(()operator(()ident(oldCapacity) operator(=) ident(oldTable)operator(.)ident(length)operator(\)) operator(>=) ident(MAXIMUM_CAPACITY)operator(\)) operator({) - keyword(return) ident(oldTable)operator(;) - operator(}) - - type(int) ident(newCapacity) operator(=) ident(oldCapacity) operator(<)operator(<) integer(1)operator(;) - ident(SymbolEntry)type([]) ident(newTable) operator(=) keyword(new) ident(SymbolEntry)operator([)ident(newCapacity)operator(])operator(;) - ident(threshold) operator(=) operator(()type(int)operator(\))operator(()ident(newCapacity) operator(*) ident(loadFactor)operator(\))operator(;) - type(int) ident(sizeMask) operator(=) ident(newCapacity) operator(-) integer(1)operator(;) - ident(SymbolEntry) ident(e)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(oldCapacity)operator(;) operator(--)ident(i) operator(>=) integer(0)operator(;) operator(\)) operator({) - comment(// We need to guarantee that any existing reads of old Map can) - comment(// proceed. So we cannot yet null out each bin.) - ident(e) operator(=) ident(oldTable)operator([)ident(i)operator(])operator(;) - - keyword(if) operator(()ident(e) operator(!=) pre_constant(null)operator(\)) operator({) - ident(SymbolEntry) ident(next) operator(=) ident(e)operator(.)ident(next)operator(;) - type(int) ident(idx) operator(=) ident(e)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - - comment(// Single node on list) - keyword(if) operator(()ident(next) operator(==) pre_constant(null)operator(\)) - ident(newTable)operator([)ident(idx)operator(]) operator(=) ident(e)operator(;) - - keyword(else) operator({) - comment(// Reuse trailing consecutive sequence at same slot) - ident(SymbolEntry) ident(lastRun) operator(=) ident(e)operator(;) - type(int) ident(lastIdx) operator(=) ident(idx)operator(;) - keyword(for) operator(()ident(SymbolEntry) ident(last) operator(=) ident(next)operator(;) - ident(last) operator(!=) pre_constant(null)operator(;) - ident(last) operator(=) ident(last)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(last)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - keyword(if) operator(()ident(k) operator(!=) ident(lastIdx)operator(\)) operator({) - ident(lastIdx) operator(=) ident(k)operator(;) - ident(lastRun) operator(=) ident(last)operator(;) - operator(}) - operator(}) - ident(newTable)operator([)ident(lastIdx)operator(]) operator(=) ident(lastRun)operator(;) - - comment(// Clone all remaining nodes) - keyword(for) operator(()ident(SymbolEntry) ident(p) operator(=) ident(e)operator(;) ident(p) operator(!=) ident(lastRun)operator(;) ident(p) operator(=) ident(p)operator(.)ident(next)operator(\)) operator({) - type(int) ident(k) operator(=) ident(p)operator(.)ident(hash) operator(&) ident(sizeMask)operator(;) - ident(SymbolEntry) ident(n) operator(=) ident(newTable)operator([)ident(k)operator(])operator(;) - ident(newTable)operator([)ident(k)operator(]) operator(=) keyword(new) ident(SymbolEntry)operator(()ident(p)operator(.)ident(hash)operator(,) ident(p)operator(.)ident(name)operator(,) ident(p)operator(.)ident(symbol)operator(,) ident(n)operator(\))operator(;) - operator(}) - operator(}) - operator(}) - operator(}) - ident(symbolTable) operator(=) ident(newTable)operator(;) - keyword(return) ident(newTable)operator(;) - operator(}) - - operator(}) -operator(}) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(java.util.HashMap)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ObjectMarshal)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.builtin.Variable)operator(;) -keyword(import) include(org.jruby.runtime.component.VariableEntry)operator(;) -keyword(import) include(org.jruby.runtime.marshal.MarshalStream)operator(;) -keyword(import) include(org.jruby.runtime.marshal.UnmarshalStream)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(SystemCallError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(StandardError)delimiter(")>operator(\)) -directive(public) type(class) class(RubySystemCallError) directive(extends) ident(RubyException) operator({) - directive(private) ident(IRubyObject) ident(errno) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - directive(private) directive(final) directive(static) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(String)operator(>) ident(defaultMessages) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(String)operator(>)operator(()operator(\))operator(;) - directive(static) operator({) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPERM)delimiter(")>operator(,) string<delimiter(")content(Operation not permitted)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOENT)delimiter(")>operator(,) string<delimiter(")content(No such file or directory)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ESRCH)delimiter(")>operator(,) string<delimiter(")content(No such process)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EINTR)delimiter(")>operator(,) string<delimiter(")content(Interrupted system call)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EIO)delimiter(")>operator(,) string<delimiter(")content(Input/output error)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENXIO)delimiter(")>operator(,) string<delimiter(")content(Device not configured)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::E2BIG)delimiter(")>operator(,) string<delimiter(")content(Argument list too long)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOEXEC)delimiter(")>operator(,) string<delimiter(")content(Exec format error)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EBADF)delimiter(")>operator(,) string<delimiter(")content(Bad file descriptor)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ECHILD)delimiter(")>operator(,) string<delimiter(")content(No child processes)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EDEADLK)delimiter(")>operator(,) string<delimiter(")content(Resource deadlock avoided)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOMEM)delimiter(")>operator(,) string<delimiter(")content(Cannot allocate memory)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EACCES)delimiter(")>operator(,) string<delimiter(")content(Permission denied)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EFAULT)delimiter(")>operator(,) string<delimiter(")content(Bad address)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTBLK)delimiter(")>operator(,) string<delimiter(")content(Block device required)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EBUSY)delimiter(")>operator(,) string<delimiter(")content(Resource busy)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EEXIST)delimiter(")>operator(,) string<delimiter(")content(File exists)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EXDEV)delimiter(")>operator(,) string<delimiter(")content(Cross-device link)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENODEV)delimiter(")>operator(,) string<delimiter(")content(Operation not supported by device)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTDIR)delimiter(")>operator(,) string<delimiter(")content(Not a directory)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EISDIR)delimiter(")>operator(,) string<delimiter(")content(Is a directory)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EINVAL)delimiter(")>operator(,) string<delimiter(")content(Invalid argument)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENFILE)delimiter(")>operator(,) string<delimiter(")content(Too many open files in system)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EMFILE)delimiter(")>operator(,) string<delimiter(")content(Too many open files)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTTY)delimiter(")>operator(,) string<delimiter(")content(Inappropriate ioctl for device)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ETXTBSY)delimiter(")>operator(,) string<delimiter(")content(Text file busy)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EFBIG)delimiter(")>operator(,) string<delimiter(")content(File too large)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOSPC)delimiter(")>operator(,) string<delimiter(")content(No space left on device)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ESPIPE)delimiter(")>operator(,) string<delimiter(")content(Illegal seek)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EROFS)delimiter(")>operator(,) string<delimiter(")content(Read-only file system)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EMLINK)delimiter(")>operator(,) string<delimiter(")content(Too many links)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPIPE)delimiter(")>operator(,) string<delimiter(")content(Broken pipe)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EDOM)delimiter(")>operator(,) string<delimiter(")content(Numerical argument out of domain)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ERANGE)delimiter(")>operator(,) string<delimiter(")content(Result too large)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EAGAIN)delimiter(")>operator(,) string<delimiter(")content(Resource temporarily unavailable)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EWOULDBLOCK)delimiter(")>operator(,) string<delimiter(")content(Resource temporarily unavailable)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EINPROGRESS)delimiter(")>operator(,) string<delimiter(")content(Operation now in progress)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EALREADY)delimiter(")>operator(,) string<delimiter(")content(Operation already in progress)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTSOCK)delimiter(")>operator(,) string<delimiter(")content(Socket operation on non-socket)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EDESTADDRREQ)delimiter(")>operator(,) string<delimiter(")content(Destination address required)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EMSGSIZE)delimiter(")>operator(,) string<delimiter(")content(Message too long)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPROTOTYPE)delimiter(")>operator(,) string<delimiter(")content(Protocol wrong type for socket)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOPROTOOPT)delimiter(")>operator(,) string<delimiter(")content(Protocol not available)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPROTONOSUPPORT)delimiter(")>operator(,) string<delimiter(")content(Protocol not supported)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ESOCKTNOSUPPORT)delimiter(")>operator(,) string<delimiter(")content(Socket type not supported)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPFNOSUPPORT)delimiter(")>operator(,) string<delimiter(")content(Protocol family not supported)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EAFNOSUPPORT)delimiter(")>operator(,) string<delimiter(")content(Address family not supported by protocol family)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EADDRINUSE)delimiter(")>operator(,) string<delimiter(")content(Address already in use)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EADDRNOTAVAIL)delimiter(")>operator(,) string<delimiter(")content(Can't assign requested address)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENETDOWN)delimiter(")>operator(,) string<delimiter(")content(Network is down)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENETUNREACH)delimiter(")>operator(,) string<delimiter(")content(Network is unreachable)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENETRESET)delimiter(")>operator(,) string<delimiter(")content(Network dropped connection on reset)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ECONNABORTED)delimiter(")>operator(,) string<delimiter(")content(Software caused connection abort)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ECONNRESET)delimiter(")>operator(,) string<delimiter(")content(Connection reset by peer)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOBUFS)delimiter(")>operator(,) string<delimiter(")content(No buffer space available)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EISCONN)delimiter(")>operator(,) string<delimiter(")content(Socket is already connected)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTCONN)delimiter(")>operator(,) string<delimiter(")content(Socket is not connected)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ESHUTDOWN)delimiter(")>operator(,) string<delimiter(")content(Can't send after socket shutdown)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ETOOMANYREFS)delimiter(")>operator(,) string<delimiter(")content(Too many references: can't splice)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ETIMEDOUT)delimiter(")>operator(,) string<delimiter(")content(Operation timed out)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ECONNREFUSED)delimiter(")>operator(,) string<delimiter(")content(Connection refused)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ELOOP)delimiter(")>operator(,) string<delimiter(")content(Too many levels of symbolic links)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENAMETOOLONG)delimiter(")>operator(,) string<delimiter(")content(File name too long)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EHOSTDOWN)delimiter(")>operator(,) string<delimiter(")content(Host is down)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EHOSTUNREACH)delimiter(")>operator(,) string<delimiter(")content(No route to host)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOTEMPTY)delimiter(")>operator(,) string<delimiter(")content(Directory not empty)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EUSERS)delimiter(")>operator(,) string<delimiter(")content(Too many users)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EDQUOT)delimiter(")>operator(,) string<delimiter(")content(Disc quota exceeded)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ESTALE)delimiter(")>operator(,) string<delimiter(")content(Stale NFS file handle)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EREMOTE)delimiter(")>operator(,) string<delimiter(")content(Too many levels of remote in path)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOLCK)delimiter(")>operator(,) string<delimiter(")content(No locks available)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOSYS)delimiter(")>operator(,) string<delimiter(")content(Function not implemented)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EOVERFLOW)delimiter(")>operator(,) string<delimiter(")content(Value too large to be stored in data type)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EIDRM)delimiter(")>operator(,) string<delimiter(")content(Identifier removed)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOMSG)delimiter(")>operator(,) string<delimiter(")content(No message of desired type)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EILSEQ)delimiter(")>operator(,) string<delimiter(")content(Illegal byte sequence)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EBADMSG)delimiter(")>operator(,) string<delimiter(")content(Bad message)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EMULTIHOP)delimiter(")>operator(,) string<delimiter(")content(EMULTIHOP (Reserved\))delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENODATA)delimiter(")>operator(,) string<delimiter(")content(No message available on STREAM)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOLINK)delimiter(")>operator(,) string<delimiter(")content(ENOLINK (Reserved\))delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOSR)delimiter(")>operator(,) string<delimiter(")content(No STREAM resources)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ENOSTR)delimiter(")>operator(,) string<delimiter(")content(Not a STREAM)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EPROTO)delimiter(")>operator(,) string<delimiter(")content(Protocol error)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::ETIME)delimiter(")>operator(,) string<delimiter(")content(STREAM ioctl timeout)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EOPNOTSUPP)delimiter(")>operator(,) string<delimiter(")content(Operation not supported)delimiter(")>operator(\))operator(;) - ident(defaultMessages)operator(.)ident(put)operator(()string<delimiter(")content(Errno::EOPNOTSUPP_DARWIN)delimiter(")>operator(,) string<delimiter(")content(Operation not supported)delimiter(")>operator(\))operator(;) - operator(}) - - directive(protected) ident(RubySystemCallError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) pre_constant(null)operator(\))operator(;) - operator(}) - - directive(public) ident(RubySystemCallError)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) pre_type(String) ident(message)operator(,) type(int) ident(errno)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(,) ident(message)operator(\))operator(;) - local_variable(this)operator(.)ident(errno) operator(=) ident(runtime)operator(.)ident(newFixnum)operator(()ident(errno)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(ObjectAllocator) ident(SYSTEM_CALL_ERROR_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - ident(RubyException) ident(instance) operator(=) keyword(new) ident(RubySystemCallError)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - - ident(instance)operator(.)ident(setMetaClass)operator(()ident(klass)operator(\))operator(;) - - keyword(return) ident(instance)operator(;) - operator(}) - operator(})operator(;) - - directive(private) directive(static) directive(final) ident(ObjectMarshal) ident(SYSTEM_CALL_ERROR_MARSHAL) operator(=) keyword(new) ident(ObjectMarshal)operator(()operator(\)) operator({) - directive(public) type(void) ident(marshalTo)operator(()ident(Ruby) ident(runtime)operator(,) pre_type(Object) ident(obj)operator(,) ident(RubyClass) ident(type)operator(,) - ident(MarshalStream) ident(marshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubySystemCallError) ident(exc) operator(=) operator(()ident(RubySystemCallError)operator(\)) ident(obj)operator(;) - ident(marshalStream)operator(.)ident(registerLinkTarget)operator(()ident(exc)operator(\))operator(;) - - pre_type(List)operator(<)ident(Variable)operator(<)ident(IRubyObject)operator(>)operator(>) ident(attrs) operator(=) ident(exc)operator(.)ident(getVariableList)operator(()operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(() - string<delimiter(")content(mesg)delimiter(")>operator(,) ident(exc)operator(.)ident(message) operator(==) pre_constant(null) operator(?) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(exc)operator(.)ident(message)operator(\))operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(errno)delimiter(")>operator(,) ident(exc)operator(.)ident(errno)operator(\))operator(\))operator(;) - ident(attrs)operator(.)ident(add)operator(()keyword(new) ident(VariableEntry)operator(<)ident(IRubyObject)operator(>)operator(()string<delimiter(")content(bt)delimiter(")>operator(,) ident(exc)operator(.)ident(getBacktrace)operator(()operator(\))operator(\))operator(\))operator(;) - ident(marshalStream)operator(.)ident(dumpVariables)operator(()ident(attrs)operator(\))operator(;) - operator(}) - - directive(public) pre_type(Object) ident(unmarshalFrom)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(,) - ident(UnmarshalStream) ident(unmarshalStream)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubySystemCallError) ident(exc) operator(=) operator(()ident(RubySystemCallError)operator(\)) ident(type)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(unmarshalStream)operator(.)ident(registerLinkTarget)operator(()ident(exc)operator(\))operator(;) - ident(unmarshalStream)operator(.)ident(defaultVariablesUnmarshal)operator(()ident(exc)operator(\))operator(;) - - ident(exc)operator(.)ident(message) operator(=) ident(exc)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(mesg)delimiter(")>operator(\))operator(;) - ident(exc)operator(.)ident(errno) operator(=) ident(exc)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(errno)delimiter(")>operator(\))operator(;) - ident(exc)operator(.)ident(set_backtrace)operator(()ident(exc)operator(.)ident(removeInternalVariable)operator(()string<delimiter(")content(bt)delimiter(")>operator(\))operator(\))operator(;) - - keyword(return) ident(exc)operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createSystemCallErrorClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(standardError)operator(\)) operator({) - ident(RubyClass) ident(exceptionClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(SystemCallError)delimiter(")>operator(,) ident(standardError)operator(,) ident(SYSTEM_CALL_ERROR_ALLOCATOR)operator(\))operator(;) - - ident(exceptionClass)operator(.)ident(setMarshal)operator(()ident(SYSTEM_CALL_ERROR_MARSHAL)operator(\))operator(;) - - ident(runtime)operator(.)ident(callbackFactory)operator(()ident(RubyClass)operator(.)ident(class)operator(\))operator(;) - ident(exceptionClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubySystemCallError)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(exceptionClass)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(optional) operator(=) integer(2)operator(,) ident(required)operator(=)integer(0)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(sCallErorrClass) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getSystemCallError)operator(()operator(\))operator(;) - ident(RubyClass) ident(klass) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(;) - - ident(IRubyObject) ident(msg) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(IRubyObject) ident(err) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - - type(boolean) ident(isErrnoClass) operator(=) operator(!)ident(klass)operator(.)ident(equals)operator(()ident(sCallErorrClass)operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(isErrnoClass)operator(\)) operator({) - comment(// one optional, one required args) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(1)operator(,) integer(2)operator(\))operator(;) - ident(msg) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(2)operator(\)) operator({) - ident(err) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1) operator(&&) operator(()ident(msg) keyword(instanceof) ident(RubyFixnum)operator(\))operator(\)) operator({) - ident(err) operator(=) ident(msg)operator(;) - ident(msg) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - comment(// one optional and no required args) - ident(Arity)operator(.)ident(checkArgumentCount)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(args)operator(,) integer(0)operator(,) integer(1)operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - ident(msg) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - operator(}) - comment(// try to get errno out of the class ) - ident(err) operator(=) ident(klass)operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(Errno)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(err)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(errno) operator(=) ident(err)operator(.)ident(convertToInteger)operator(()operator(\))operator(;) - operator(}) - - pre_type(String) ident(val) operator(=) ident(defaultMessages)operator(.)ident(get)operator(()ident(klass)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(val) operator(==) pre_constant(null)operator(\)) operator({) - ident(val) operator(=) string<delimiter(")content(Unknown error)delimiter(")>operator(;) - operator(}) - - comment(// MRI behavior: we don't print errno for actual Errno errors) - keyword(if) operator(()operator(!)ident(errno)operator(.)ident(isNil)operator(()operator(\)) operator(&&) operator(!)ident(isErrnoClass)operator(\)) operator({) - ident(val) operator(+=) string<delimiter(")content( )delimiter(")> operator(+) ident(errno)operator(.)ident(toString)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(msg)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(val) operator(+=) string<delimiter(")content( - )delimiter(")> operator(+) ident(msg)operator(.)ident(convertToString)operator(()operator(\))operator(;) - operator(}) - - ident(message) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(val)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod) - directive(public) ident(IRubyObject) ident(errno)operator(()operator(\)) operator({) - keyword(return) ident(errno)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) - -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(SystemExit)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Exception)delimiter(")>operator(\)) -directive(public) type(class) class(RubySystemExit) directive(extends) ident(RubyException) operator({) - ident(IRubyObject) ident(status)operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(SYSTEMEXIT_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubySystemExit)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createSystemExitClass)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - ident(RubyClass) ident(systemExitClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(SystemExit)delimiter(")>operator(,) ident(exceptionClass)operator(,) ident(SYSTEMEXIT_ALLOCATOR)operator(\))operator(;) - - ident(systemExitClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubySystemExit)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(systemExitClass)operator(;) - operator(}) - - directive(public) directive(static) ident(RubySystemExit) ident(newInstance)operator(()ident(Ruby) ident(runtime)operator(,) type(int) ident(status)operator(\)) operator({) - ident(RubyClass) ident(exc) operator(=) ident(runtime)operator(.)ident(getSystemExit)operator(()operator(\))operator(;) - ident(IRubyObject)type([]) ident(exArgs) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) - ident(runtime)operator(.)ident(newFixnum)operator(()ident(status)operator(\))operator(,) - ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(exit)delimiter(")>operator(\)) operator(})operator(;) - keyword(return) operator(()ident(RubySystemExit)operator(\)) ident(exc)operator(.)ident(newInstance)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(exArgs)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - directive(protected) ident(RubySystemExit)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(exceptionClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(exceptionClass)operator(\))operator(;) - ident(status) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([])ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(status) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0) operator(&&) ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(status) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(IRubyObject)type([])ident(tmpArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(args)operator(.)ident(length) operator(-) integer(1)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(1)operator(,) ident(tmpArgs)operator(,) integer(0)operator(,) ident(tmpArgs)operator(.)ident(length)operator(\))operator(;) - ident(args) operator(=) ident(tmpArgs)operator(;) - operator(}) - local_variable(super)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(status)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(status)operator(()operator(\)) operator({) - keyword(return) ident(status)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(success?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(success_p)operator(()operator(\)) operator({) - keyword(if) operator(()ident(status)operator(.)ident(isNil)operator(()operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(if) operator(()ident(status)operator(.)ident(equals)operator(()ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(\)) keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Jason Voegele <jason@jvoegele.com> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) -keyword(import) include(java.nio.channels.Channel)operator(;) -keyword(import) include(java.nio.channels.SelectableChannel)operator(;) -keyword(import) include(java.nio.channels.SelectionKey)operator(;) -keyword(import) include(java.nio.channels.Selector)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(java.util.Set)operator(;) -keyword(import) include(org.jruby.common.IRubyWarnings.ID)operator(;) -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.exceptions.ThreadKill)operator(;) -keyword(import) include(org.jruby.internal.runtime.FutureThread)operator(;) -keyword(import) include(org.jruby.internal.runtime.NativeThread)operator(;) -keyword(import) include(org.jruby.internal.runtime.RubyRunnable)operator(;) -keyword(import) include(org.jruby.internal.runtime.ThreadLike)operator(;) -keyword(import) include(org.jruby.internal.runtime.ThreadService)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(java.util.concurrent.ExecutionException)operator(;) -keyword(import) include(java.util.concurrent.locks.ReentrantLock)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.runtime.ObjectMarshal)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) - -comment(/** - * Implementation of Ruby's <code>Thread</code> class. Each Ruby thread is - * mapped to an underlying Java Virtual Machine thread. - * <p> - * Thread encapsulates the behavior of a thread of execution, including the main - * thread of the Ruby script. In the descriptions that follow, the parameter - * <code>aSymbol</code> refers to a symbol, which is either a quoted string or a - * <code>Symbol</code> (such as <code>:name</code>\). - * - * Note: For CVS history, see ThreadClass.java. - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Thread)delimiter(")>operator(\)) -directive(public) type(class) class(RubyThread) directive(extends) ident(RubyObject) operator({) - directive(private) ident(ThreadLike) ident(threadImpl)operator(;) - directive(private) ident(RubyFixnum) ident(priority)operator(;) - directive(private) directive(transient) pre_type(Map)operator(<)ident(IRubyObject)operator(,) ident(IRubyObject)operator(>) ident(threadLocalVariables)operator(;) - directive(private) type(boolean) ident(abortOnException)operator(;) - directive(private) ident(IRubyObject) ident(finalResult)operator(;) - directive(private) ident(RaiseException) ident(exitingException)operator(;) - directive(private) ident(IRubyObject) ident(receivedException)operator(;) - directive(private) ident(RubyThreadGroup) ident(threadGroup)operator(;) - - directive(private) directive(final) ident(ThreadService) ident(threadService)operator(;) - directive(private) directive(volatile) type(boolean) ident(isStopped) operator(=) pre_constant(false)operator(;) - directive(private) directive(volatile) type(boolean) ident(isDead) operator(=) pre_constant(false)operator(;) - directive(public) pre_type(Object) ident(stopLock) operator(=) keyword(new) pre_type(Object)operator(()operator(\))operator(;) - - directive(private) directive(volatile) type(boolean) ident(killed) operator(=) pre_constant(false)operator(;) - directive(public) pre_type(Object) ident(killLock) operator(=) keyword(new) pre_type(Object)operator(()operator(\))operator(;) - - directive(public) directive(final) pre_type(ReentrantLock) ident(lock) operator(=) keyword(new) pre_type(ReentrantLock)operator(()operator(\))operator(;) - - directive(private) directive(static) directive(final) type(boolean) ident(DEBUG) operator(=) pre_constant(false)operator(;) - - directive(protected) ident(RubyThread)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - local_variable(this)operator(.)ident(threadService) operator(=) ident(runtime)operator(.)ident(getThreadService)operator(()operator(\))operator(;) - ident(finalResult) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Dispose of the current thread by removing it from its parent ThreadGroup. - */) - directive(public) type(void) ident(dispose)operator(()operator(\)) operator({) - ident(threadGroup)operator(.)ident(remove)operator(()local_variable(this)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(createThreadClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// FIXME: In order for Thread to play well with the standard 'new' behavior,) - comment(// it must provide an allocator that can create empty object instances which) - comment(// initialize then fills with appropriate data.) - ident(RubyClass) ident(threadClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Thread)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setThread)operator(()ident(threadClass)operator(\))operator(;) - - ident(threadClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyThread)operator(.)ident(class)operator(\))operator(;) - - ident(RubyThread) ident(rubyThread) operator(=) keyword(new) ident(RubyThread)operator(()ident(runtime)operator(,) ident(threadClass)operator(\))operator(;) - comment(// TODO: need to isolate the "current" thread from class creation) - ident(rubyThread)operator(.)ident(threadImpl) operator(=) keyword(new) ident(NativeThread)operator(()ident(rubyThread)operator(,) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(setMainThread)operator(()pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\))operator(,) ident(rubyThread)operator(\))operator(;) - - comment(// set to default thread group) - ident(runtime)operator(.)ident(getDefaultThreadGroup)operator(()operator(\))operator(.)ident(addDirectly)operator(()ident(rubyThread)operator(\))operator(;) - - ident(threadClass)operator(.)ident(setMarshal)operator(()ident(ObjectMarshal)operator(.)ident(NOT_MARSHALABLE_MARSHAL)operator(\))operator(;) - - keyword(return) ident(threadClass)operator(;) - operator(}) - - comment(/** - * <code>Thread.new</code> - * <p> - * Thread.new( <i>[ arg ]*</i> \) {| args | block } -> aThread - * <p> - * Creates a new thread to execute the instructions given in block, and - * begins running it. Any arguments passed to Thread.new are passed into the - * block. - * <pre> - * x = Thread.new { sleep .1; print "x"; print "y"; print "z" } - * a = Thread.new { print "a"; print "b"; sleep .2; print "c" } - * x.join # Let the threads finish before - * a.join # main thread exits... - * </pre> - * <i>produces:</i> abxyzc - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(new)delimiter(")>operator(,) string<delimiter(")content(fork)delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(startThread)operator(()ident(recv)operator(,) ident(args)operator(,) pre_constant(true)operator(,) ident(block)operator(\))operator(;) - operator(}) - - comment(/** - * Basically the same as Thread.new . However, if class Thread is - * subclassed, then calling start in that subclass will not invoke the - * subclass's initialize method. - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(start)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyThread) ident(start)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(startThread)operator(()ident(recv)operator(,) ident(args)operator(,) pre_constant(false)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyThread) ident(adopt)operator(()ident(IRubyObject) ident(recv)operator(,) pre_type(Thread) ident(t)operator(\)) operator({) - keyword(return) ident(adoptThread)operator(()ident(recv)operator(,) ident(t)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) - - directive(private) directive(static) ident(RubyThread) ident(adoptThread)operator(()directive(final) ident(IRubyObject) ident(recv)operator(,) pre_type(Thread) ident(t)operator(,) ident(Block) ident(block)operator(\)) operator({) - directive(final) ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyThread) ident(rubyThread) operator(=) keyword(new) ident(RubyThread)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(;) - - ident(rubyThread)operator(.)ident(threadImpl) operator(=) keyword(new) ident(NativeThread)operator(()ident(rubyThread)operator(,) ident(t)operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(registerNewThread)operator(()ident(rubyThread)operator(\))operator(;) - - ident(context)operator(.)ident(preAdoptThread)operator(()operator(\))operator(;) - - comment(// set to default thread group) - ident(runtime)operator(.)ident(getDefaultThreadGroup)operator(()operator(\))operator(.)ident(addDirectly)operator(()ident(rubyThread)operator(\))operator(;) - - keyword(return) ident(rubyThread)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) keyword(throw) ident(runtime)operator(.)ident(newThreadError)operator(()string<delimiter(")content(must be called with a block)delimiter(")>operator(\))operator(;) - - ident(RubyRunnable) ident(runnable) operator(=) keyword(new) ident(RubyRunnable)operator(()local_variable(this)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(if) operator(()ident(RubyInstanceConfig)operator(.)ident(POOLING_ENABLED)operator(\)) operator({) - ident(threadImpl) operator(=) keyword(new) ident(FutureThread)operator(()local_variable(this)operator(,) ident(runnable)operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(Thread) ident(thread) operator(=) keyword(new) pre_type(Thread)operator(()ident(runnable)operator(\))operator(;) - ident(thread)operator(.)ident(setDaemon)operator(()pre_constant(true)operator(\))operator(;) - ident(threadImpl) operator(=) keyword(new) ident(NativeThread)operator(()local_variable(this)operator(,) ident(thread)operator(\))operator(;) - operator(}) - - comment(// set to default thread group) - ident(runtime)operator(.)ident(getDefaultThreadGroup)operator(()operator(\))operator(.)ident(addDirectly)operator(()local_variable(this)operator(\))operator(;) - - ident(threadImpl)operator(.)ident(start)operator(()operator(\))operator(;) - - comment(// We yield here to hopefully permit the target thread to schedule) - comment(// MRI immediately schedules it, so this is close but not exact) - pre_type(Thread)operator(.)ident(yield)operator(()operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) directive(static) ident(RubyThread) ident(startThread)operator(()directive(final) ident(IRubyObject) ident(recv)operator(,) directive(final) ident(IRubyObject)type([]) ident(args)operator(,) type(boolean) ident(callInit)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyThread) ident(rubyThread) operator(=) keyword(new) ident(RubyThread)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(;) - - keyword(if) operator(()ident(callInit)operator(\)) operator({) - ident(rubyThread)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(else) operator({) - comment(// for Thread::start, which does not call the subclass's initialize) - ident(rubyThread)operator(.)ident(initialize)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - keyword(return) ident(rubyThread)operator(;) - operator(}) - - directive(private) type(void) ident(ensureNotCurrent)operator(()operator(\)) operator({) - keyword(if) operator(()local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(\)) operator({) - keyword(throw) keyword(new) exception(RuntimeException)operator(()string<delimiter(")content(internal thread method called from another thread)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(synchronized) type(void) ident(cleanTerminate)operator(()ident(IRubyObject) ident(result)operator(\)) operator({) - ident(finalResult) operator(=) ident(result)operator(;) - ident(isStopped) operator(=) pre_constant(true)operator(;) - ident(isDead) operator(=) pre_constant(true)operator(;) - operator(}) - - directive(public) type(void) ident(pollThreadEvents)operator(()operator(\)) operator({) - ident(pollThreadEvents)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(pollThreadEvents)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - comment(// check for criticalization *before* locking ourselves) - ident(threadService)operator(.)ident(waitForCritical)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(killed)operator(\)) ident(throwThreadKill)operator(()operator(\))operator(;) - keyword(if) operator(()ident(receivedException) operator(!=) pre_constant(null)operator(\)) ident(receivedAnException)operator(()ident(context)operator(\))operator(;) - operator(}) - - directive(private) type(void) ident(throwThreadKill)operator(()operator(\)) operator({) - keyword(throw) keyword(new) ident(ThreadKill)operator(()operator(\))operator(;) - operator(}) - - comment(/** - * Returns the status of the global ``abort on exception'' condition. The - * default is false. When set to true, will cause all threads to abort (the - * process will exit(0\)\) if an exception is raised in any thread. See also - * Thread.abort_on_exception= . - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort_on_exception)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyBoolean) ident(abort_on_exception_x)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(isGlobalAbortOnExceptionEnabled)operator(()operator(\)) operator(?) ident(runtime)operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(runtime)operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort_on_exception=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(abort_on_exception_set_x)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(setGlobalAbortOnExceptionEnabled)operator(()ident(value)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(current)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyThread) ident(current)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(main)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyThread) ident(main)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getMainThread)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pass)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(pass)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ThreadService) ident(ts) operator(=) ident(runtime)operator(.)ident(getThreadService)operator(()operator(\))operator(;) - type(boolean) ident(critical) operator(=) ident(ts)operator(.)ident(getCritical)operator(()operator(\))operator(;) - - ident(ts)operator(.)ident(setCritical)operator(()pre_constant(false)operator(\))operator(;) - - pre_type(Thread)operator(.)ident(yield)operator(()operator(\))operator(;) - - ident(ts)operator(.)ident(setCritical)operator(()ident(critical)operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(list)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyArray) ident(list)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(RubyThread)type([]) ident(activeThreads) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getActiveRubyThreads)operator(()operator(\))operator(;) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()ident(activeThreads)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(getSymbolKey)operator(()ident(IRubyObject) ident(originalKey)operator(\)) operator({) - keyword(if) operator(()ident(originalKey) keyword(instanceof) ident(RubySymbol)operator(\)) operator({) - keyword(return) ident(originalKey)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(originalKey) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newSymbol)operator(()ident(originalKey)operator(.)ident(asJavaString)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(originalKey) keyword(instanceof) ident(RubyFixnum)operator(\)) operator({) - ident(getRuntime)operator(()operator(\))operator(.)ident(getWarnings)operator(()operator(\))operator(.)ident(warn)operator(()ident(ID)operator(.)ident(FIXNUMS_NOT_SYMBOLS)operator(,) string<delimiter(")content(Do not use Fixnums as Symbols)delimiter(")>operator(\))operator(;) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(originalKey) operator(+) string<delimiter(")content( is not a symbol)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(originalKey) operator(+) string<delimiter(")content( is not a symbol)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(synchronized) pre_type(Map)operator(<)ident(IRubyObject)operator(,) ident(IRubyObject)operator(>) ident(getThreadLocals)operator(()operator(\)) operator({) - keyword(if) operator(()ident(threadLocalVariables) operator(==) pre_constant(null)operator(\)) operator({) - ident(threadLocalVariables) operator(=) keyword(new) pre_type(HashMap)operator(<)ident(IRubyObject)operator(,) ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(threadLocalVariables)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([])delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_aref)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - ident(IRubyObject) ident(value)operator(;) - keyword(if) operator(()operator(()ident(value) operator(=) ident(getThreadLocals)operator(()operator(\))operator(.)ident(get)operator(()ident(getSymbolKey)operator(()ident(key)operator(\))operator(\))operator(\)) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(value)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content([]=)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(op_aset)operator(()ident(IRubyObject) ident(key)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(key) operator(=) ident(getSymbolKey)operator(()ident(key)operator(\))operator(;) - - ident(getThreadLocals)operator(()operator(\))operator(.)ident(put)operator(()ident(key)operator(,) ident(value)operator(\))operator(;) - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort_on_exception)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(abort_on_exception)operator(()operator(\)) operator({) - keyword(return) ident(abortOnException) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(abort_on_exception=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(abort_on_exception_set)operator(()ident(IRubyObject) ident(val)operator(\)) operator({) - ident(abortOnException) operator(=) ident(val)operator(.)ident(isTrue)operator(()operator(\))operator(;) - keyword(return) ident(val)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(alive?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(alive_p)operator(()operator(\)) operator({) - keyword(return) operator(!)ident(isDead) operator(&&) ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(join)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(backtrace) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(join)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - type(long) ident(timeoutMillis) operator(=) pre_type(Long)operator(.)ident(MAX_VALUE)operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()ident(args)operator(.)ident(length)operator(,)integer(1)operator(\))operator(;) - operator(}) - comment(// MRI behavior: value given in seconds; converted to Float; less) - comment(// than or equal to zero returns immediately; returns nil) - ident(timeoutMillis) operator(=) operator(()type(long)operator(\))operator(()float(1000.0D) operator(*) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToFloat)operator(()operator(\))operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - keyword(if) operator(()ident(timeoutMillis) operator(<=) integer(0)operator(\)) operator({) - comment(// TODO: not sure that we should skip calling join(\) altogether.) - comment(// Thread.join(\) has some implications for Java Memory Model, etc.) - keyword(if) operator(()ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - operator(}) - keyword(if) operator(()ident(isCurrent)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newThreadError)operator(()string<delimiter(")content(thread tried to join itself)delimiter(")>operator(\))operator(;) - operator(}) - keyword(try) operator({) - keyword(if) operator(()ident(threadService)operator(.)ident(getCritical)operator(()operator(\))operator(\)) operator({) - comment(// If the target thread is sleeping or stopped, wake it) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(stopLock)operator(.)ident(notify)operator(()operator(\))operator(;) - operator(}) - - comment(// interrupt the target thread in case it's blocking or waiting) - comment(// WARNING: We no longer interrupt the target thread, since this usually means) - comment(// interrupting IO and with NIO that means the channel is no longer usable.) - comment(// We either need a new way to handle waking a target thread that's waiting) - comment(// on IO, or we need to accept that we can't wake such threads and must wait) - comment(// for them to complete their operation.) - comment(//threadImpl.interrupt(\);) - operator(}) - - ident(RubyThread) ident(currentThread) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - directive(final) type(long) ident(timeToWait) operator(=) pre_type(Math)operator(.)ident(min)operator(()ident(timeoutMillis)operator(,) integer(200)operator(\))operator(;) - - comment(// We need this loop in order to be able to "unblock" the) - comment(// join call without actually calling interrupt.) - type(long) ident(start) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - keyword(while)operator(()pre_constant(true)operator(\)) operator({) - ident(currentThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - ident(threadImpl)operator(.)ident(join)operator(()ident(timeToWait)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - keyword(break)operator(;) - operator(}) - keyword(if) operator(()pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\)) operator(-) ident(start) operator(>) ident(timeoutMillis)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - operator(}) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(ie)operator(\)) operator({) - ident(ie)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - keyword(assert) pre_constant(false) operator(:) ident(ie)operator(;) - operator(}) keyword(catch) operator(()exception(ExecutionException) ident(ie)operator(\)) operator({) - ident(ie)operator(.)ident(printStackTrace)operator(()operator(\))operator(;) - keyword(assert) pre_constant(false) operator(:) ident(ie)operator(;) - operator(}) - - keyword(if) operator(()ident(exitingException) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(throw) ident(exitingException)operator(;) - operator(}) - - keyword(if) operator(()ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(value)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(value)operator(()operator(\)) operator({) - ident(join)operator(()keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(\))operator(;) - directive(synchronized) operator(()local_variable(this)operator(\)) operator({) - keyword(return) ident(finalResult)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(group)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(group)operator(()operator(\)) operator({) - keyword(if) operator(()ident(threadGroup) operator(==) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(threadGroup)operator(;) - operator(}) - - type(void) ident(setThreadGroup)operator(()ident(RubyThreadGroup) ident(rubyThreadGroup)operator(\)) operator({) - ident(threadGroup) operator(=) ident(rubyThreadGroup)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inspect)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(inspect)operator(()operator(\)) operator({) - comment(// FIXME: There's some code duplication here with RubyObject#inspect) - pre_type(StringBuilder) ident(part) operator(=) keyword(new) pre_type(StringBuilder)operator(()operator(\))operator(;) - pre_type(String) ident(cname) operator(=) ident(getMetaClass)operator(()operator(\))operator(.)ident(getRealClass)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(;) - ident(part)operator(.)ident(append)operator(()string<delimiter(")content(#<)delimiter(")>operator(\))operator(.)ident(append)operator(()ident(cname)operator(\))operator(.)ident(append)operator(()string<delimiter(")content(:0x)delimiter(")>operator(\))operator(;) - ident(part)operator(.)ident(append)operator(()pre_type(Integer)operator(.)ident(toHexString)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()local_variable(this)operator(\))operator(\))operator(\))operator(;) - - keyword(if) operator(()ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(isStopped)operator(\)) operator({) - ident(part)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content( sleep)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(killed)operator(\)) operator({) - ident(part)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content( aborting)delimiter(")>operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(part)operator(.)ident(append)operator(()ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content( run)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - ident(part)operator(.)ident(append)operator(()string<delimiter(")content( dead)delimiter(")>operator(\))operator(;) - operator(}) - - ident(part)operator(.)ident(append)operator(()string<delimiter(")content(>)delimiter(")>operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(part)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(key?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyBoolean) ident(key_p)operator(()ident(IRubyObject) ident(key)operator(\)) operator({) - ident(key) operator(=) ident(getSymbolKey)operator(()ident(key)operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(getThreadLocals)operator(()operator(\))operator(.)ident(containsKey)operator(()ident(key)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(keys)delimiter(")>operator(\)) - directive(public) ident(RubyArray) ident(keys)operator(()operator(\)) operator({) - ident(IRubyObject)type([]) ident(keys) operator(=) keyword(new) ident(IRubyObject)operator([)ident(getThreadLocals)operator(()operator(\))operator(.)ident(size)operator(()operator(\))operator(])operator(;) - - keyword(return) ident(RubyArray)operator(.)ident(newArrayNoCopy)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getThreadLocals)operator(()operator(\))operator(.)ident(keySet)operator(()operator(\))operator(.)ident(toArray)operator(()ident(keys)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(critical=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(critical_set)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject) ident(value)operator(\)) operator({) - ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(setCritical)operator(()ident(value)operator(.)ident(isTrue)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(value)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(critical)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(critical)operator(()ident(IRubyObject) ident(receiver)operator(\)) operator({) - keyword(return) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getCritical)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(stop)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(stop)operator(()ident(IRubyObject) ident(receiver)operator(\)) operator({) - ident(RubyThread) ident(rubyThread) operator(=) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - pre_type(Object) ident(stopLock) operator(=) ident(rubyThread)operator(.)ident(stopLock)operator(;) - - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(rubyThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(rubyThread)operator(.)ident(isStopped) operator(=) pre_constant(true)operator(;) - comment(// attempt to decriticalize all if we're the critical thread) - ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(setCritical)operator(()pre_constant(false)operator(\))operator(;) - - ident(stopLock)operator(.)ident(wait)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(ie)operator(\)) operator({) - ident(rubyThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - operator(}) - ident(rubyThread)operator(.)ident(isStopped) operator(=) pre_constant(false)operator(;) - operator(}) - - keyword(return) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(kill)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(kill)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(IRubyObject) ident(rubyThread)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(rubyThread) keyword(instanceof) ident(RubyThread)operator(\))operator(\)) keyword(throw) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(rubyThread)operator(,) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(\))operator(;) - keyword(return) operator(()operator(()ident(RubyThread)operator(\))ident(rubyThread)operator(\))operator(.)ident(kill)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(exit)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(s_exit)operator(()ident(IRubyObject) ident(receiver)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyThread) ident(rubyThread) operator(=) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - - ident(rubyThread)operator(.)ident(killed) operator(=) pre_constant(true)operator(;) - comment(// attempt to decriticalize all if we're the critical thread) - ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(setCritical)operator(()pre_constant(false)operator(\))operator(;) - - keyword(throw) keyword(new) ident(ThreadKill)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(stop?)delimiter(")>operator(\)) - directive(public) ident(RubyBoolean) ident(stop_p)operator(()operator(\)) operator({) - comment(// not valid for "dead" state) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(isStopped)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(wakeup)delimiter(")>operator(\)) - directive(public) ident(RubyThread) ident(wakeup)operator(()operator(\)) operator({) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(stopLock)operator(.)ident(notifyAll)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(priority)delimiter(")>operator(\)) - directive(public) ident(RubyFixnum) ident(priority)operator(()operator(\)) operator({) - keyword(return) ident(priority)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(priority=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(priority_set)operator(()ident(IRubyObject) ident(priority)operator(\)) operator({) - comment(// FIXME: This should probably do some translation from Ruby priority levels to Java priority levels (until we have green threads\)) - type(int) ident(iPriority) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(priority)operator(\))operator(;) - - keyword(if) operator(()ident(iPriority) operator(<) pre_type(Thread)operator(.)ident(MIN_PRIORITY)operator(\)) operator({) - ident(iPriority) operator(=) pre_type(Thread)operator(.)ident(MIN_PRIORITY)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(iPriority) operator(>) pre_type(Thread)operator(.)ident(MAX_PRIORITY)operator(\)) operator({) - ident(iPriority) operator(=) pre_type(Thread)operator(.)ident(MAX_PRIORITY)operator(;) - operator(}) - - local_variable(this)operator(.)ident(priority) operator(=) ident(RubyFixnum)operator(.)ident(newFixnum)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(iPriority)operator(\))operator(;) - - keyword(if) operator(()ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - ident(threadImpl)operator(.)ident(setPriority)operator(()ident(iPriority)operator(\))operator(;) - operator(}) - keyword(return) local_variable(this)operator(.)ident(priority)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(raise)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(raise)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(ensureNotCurrent)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(getRuntime)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(thread )delimiter(")> operator(+) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\)) operator(+) string<delimiter(")content( before raising)delimiter(")>operator(\))operator(;) - ident(RubyThread) ident(currentThread) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - keyword(try) operator({) - keyword(while) operator(()operator(!)operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(tryLock)operator(()operator(\)) operator(&&) local_variable(this)operator(.)ident(lock)operator(.)ident(tryLock)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(if) operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) ident(currentThread)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - - ident(currentThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(thread )delimiter(")> operator(+) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\)) operator(+) string<delimiter(")content( raising)delimiter(")>operator(\))operator(;) - ident(receivedException) operator(=) ident(prepareRaiseException)operator(()ident(runtime)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - - comment(// If the target thread is sleeping or stopped, wake it) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(stopLock)operator(.)ident(notify)operator(()operator(\))operator(;) - operator(}) - - comment(// interrupt the target thread in case it's blocking or waiting) - comment(// WARNING: We no longer interrupt the target thread, since this usually means) - comment(// interrupting IO and with NIO that means the channel is no longer usable.) - comment(// We either need a new way to handle waking a target thread that's waiting) - comment(// on IO, or we need to accept that we can't wake such threads and must wait) - comment(// for them to complete their operation.) - comment(//threadImpl.interrupt(\);) - - comment(// new interrupt, to hopefully wake it out of any blocking IO) - local_variable(this)operator(.)ident(interrupt)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(if) operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) ident(currentThread)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - keyword(if) operator(()local_variable(this)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) local_variable(this)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(prepareRaiseException)operator(()ident(Ruby) ident(runtime)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(0)operator(\)) operator({) - ident(IRubyObject) ident(lastException) operator(=) ident(runtime)operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($!)delimiter(")>operator(\))operator(;) - keyword(if)operator(()ident(lastException)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(return) keyword(new) ident(RaiseException)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getRuntimeError)operator(()operator(\))operator(,) string<delimiter(")delimiter(")>operator(,) pre_constant(false)operator(\))operator(.)ident(getException)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(lastException)operator(;) - operator(}) - - ident(IRubyObject) ident(exception)operator(;) - ident(ThreadContext) ident(context) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - keyword(if)operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getRuntimeError)operator(()operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) ident(args)operator(,) ident(block)operator(\))operator(;) - operator(}) - - keyword(if)operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(respondsTo)operator(()string<delimiter(")content(exception)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception class/object expected)delimiter(")>operator(\))operator(.)ident(getException)operator(()operator(\))operator(;) - operator(}) - ident(exception) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(exception)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(respondsTo)operator(()string<delimiter(")content(exception)delimiter(")>operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception class/object expected)delimiter(")>operator(\))operator(.)ident(getException)operator(()operator(\))operator(;) - operator(}) - - ident(exception) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(exception)delimiter(")>operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - - keyword(if) operator(()operator(!)ident(runtime)operator(.)ident(getException)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(exception)operator(\))operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(exception object expected)delimiter(")>operator(\))operator(.)ident(getException)operator(()operator(\))operator(;) - operator(}) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(3)operator(\)) operator({) - operator(()operator(()ident(RubyException)operator(\)) ident(exception)operator(\))operator(.)ident(set_backtrace)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - operator(}) - - keyword(return) ident(exception)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(run)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(run)operator(()operator(\)) operator({) - comment(// if stopped, unstop) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - keyword(if) operator(()ident(isStopped)operator(\)) operator({) - ident(isStopped) operator(=) pre_constant(false)operator(;) - ident(stopLock)operator(.)ident(notifyAll)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - directive(public) type(void) ident(sleep)operator(()type(long) ident(millis)operator(\)) directive(throws) exception(InterruptedException) operator({) - keyword(assert) local_variable(this) operator(==) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(pollThreadEvents)operator(()operator(\))operator(;) - keyword(try) operator({) - ident(isStopped) operator(=) pre_constant(true)operator(;) - ident(stopLock)operator(.)ident(wait)operator(()ident(millis)operator(\))operator(;) - operator(}) keyword(finally) operator({) - ident(isStopped) operator(=) pre_constant(false)operator(;) - ident(pollThreadEvents)operator(()operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(status)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(status)operator(()operator(\)) operator({) - keyword(if) operator(()ident(threadImpl)operator(.)ident(isAlive)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()ident(isStopped) operator(||) ident(currentSelector) operator(!=) pre_constant(null) operator(&&) ident(currentSelector)operator(.)ident(isOpen)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(sleep)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(killed)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(aborting)delimiter(")>operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(run)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(exitingException) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(kill)delimiter(")>operator(,) string<delimiter(")content(exit)delimiter(")>operator(,) string<delimiter(")content(terminate)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(kill)operator(()operator(\)) operator({) - comment(// need to reexamine this) - ident(RubyThread) ident(currentThread) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(;) - - comment(// If the killee thread is the same as the killer thread, just die) - keyword(if) operator(()ident(currentThread) operator(==) local_variable(this)operator(\)) ident(throwThreadKill)operator(()operator(\))operator(;) - - keyword(try) operator({) - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(thread )delimiter(")> operator(+) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\)) operator(+) string<delimiter(")content( trying to kill)delimiter(")>operator(\))operator(;) - keyword(while) operator(()operator(!)operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(tryLock)operator(()operator(\)) operator(&&) local_variable(this)operator(.)ident(lock)operator(.)ident(tryLock)operator(()operator(\))operator(\))operator(\)) operator({) - keyword(if) operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) ident(currentThread)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - - ident(currentThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(DEBUG)operator(\)) pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(thread )delimiter(")> operator(+) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\)) operator(+) string<delimiter(")content( succeeded with kill)delimiter(")>operator(\))operator(;) - ident(killed) operator(=) pre_constant(true)operator(;) - - comment(// If the target thread is sleeping or stopped, wake it) - directive(synchronized) operator(()ident(stopLock)operator(\)) operator({) - ident(stopLock)operator(.)ident(notify)operator(()operator(\))operator(;) - operator(}) - - comment(// interrupt the target thread in case it's blocking or waiting) - comment(// WARNING: We no longer interrupt the target thread, since this usually means) - comment(// interrupting IO and with NIO that means the channel is no longer usable.) - comment(// We either need a new way to handle waking a target thread that's waiting) - comment(// on IO, or we need to accept that we can't wake such threads and must wait) - comment(// for them to complete their operation.) - comment(//threadImpl.interrupt(\);) - - comment(// new interrupt, to hopefully wake it out of any blocking IO) - local_variable(this)operator(.)ident(interrupt)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(if) operator(()ident(currentThread)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) ident(currentThread)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - keyword(if) operator(()local_variable(this)operator(.)ident(lock)operator(.)ident(isHeldByCurrentThread)operator(()operator(\))operator(\)) local_variable(this)operator(.)ident(lock)operator(.)ident(unlock)operator(()operator(\))operator(;) - operator(}) - - keyword(try) operator({) - ident(threadImpl)operator(.)ident(join)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(InterruptedException) ident(ie)operator(\)) operator({) - comment(// we were interrupted, check thread events again) - ident(currentThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(ExecutionException) ident(ie)operator(\)) operator({) - comment(// we were interrupted, check thread events again) - ident(currentThread)operator(.)ident(pollThreadEvents)operator(()operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(kill!)delimiter(")>operator(,) string<delimiter(")content(exit!)delimiter(")>operator(,) string<delimiter(")content(terminate!)delimiter(")>operator(})operator(\)) - directive(public) ident(IRubyObject) ident(kill_bang)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Thread#kill!, exit!, and terminate! are not safe and not supported)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(safe_level)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(safe_level)operator(()operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newNotImplementedError)operator(()string<delimiter(")content(Thread-specific SAFE levels are not supported)delimiter(")>operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isCurrent)operator(()operator(\)) operator({) - keyword(return) ident(threadImpl)operator(.)ident(isCurrent)operator(()operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(exceptionRaised)operator(()ident(RaiseException) ident(exception)operator(\)) operator({) - keyword(assert) ident(isCurrent)operator(()operator(\))operator(;) - - ident(RubyException) ident(rubyException) operator(=) ident(exception)operator(.)ident(getException)operator(()operator(\))operator(;) - ident(Ruby) ident(runtime) operator(=) ident(rubyException)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if) operator(()ident(runtime)operator(.)ident(getSystemExit)operator(()operator(\))operator(.)ident(isInstance)operator(()ident(rubyException)operator(\))operator(\)) operator({) - ident(threadService)operator(.)ident(getMainThread)operator(()operator(\))operator(.)ident(raise)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(rubyException)operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(abortOnException)operator(()ident(runtime)operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(printError)operator(()ident(rubyException)operator(\))operator(;) - ident(RubyException) ident(systemExit) operator(=) ident(RubySystemExit)operator(.)ident(newInstance)operator(()ident(runtime)operator(,) integer(1)operator(\))operator(;) - ident(systemExit)operator(.)ident(message) operator(=) ident(rubyException)operator(.)ident(message)operator(;) - ident(systemExit)operator(.)ident(set_backtrace)operator(()ident(rubyException)operator(.)ident(backtrace)operator(()operator(\))operator(\))operator(;) - ident(threadService)operator(.)ident(getMainThread)operator(()operator(\))operator(.)ident(raise)operator(()keyword(new) ident(IRubyObject)type([]) operator({)ident(systemExit)operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - keyword(return)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(runtime)operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(runtime)operator(.)ident(printError)operator(()ident(exception)operator(.)ident(getException)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(exitingException) operator(=) ident(exception)operator(;) - operator(}) - - directive(private) type(boolean) ident(abortOnException)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - keyword(return) operator(()ident(runtime)operator(.)ident(isGlobalAbortOnExceptionEnabled)operator(()operator(\)) operator(||) ident(abortOnException)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyThread) ident(mainThread)operator(()ident(IRubyObject) ident(receiver)operator(\)) operator({) - keyword(return) ident(receiver)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getThreadService)operator(()operator(\))operator(.)ident(getMainThread)operator(()operator(\))operator(;) - operator(}) - - directive(private) pre_type(Selector) ident(currentSelector)operator(;) - - annotation(@Deprecated) - directive(public) type(boolean) ident(selectForAccept)operator(()ident(RubyIO) ident(io)operator(\)) operator({) - keyword(return) ident(select)operator(()ident(io)operator(,) pre_type(SelectionKey)operator(.)ident(OP_ACCEPT)operator(\))operator(;) - operator(}) - - directive(public) type(boolean) ident(select)operator(()ident(RubyIO) ident(io)operator(,) type(int) ident(ops)operator(\)) operator({) - pre_type(Channel) ident(channel) operator(=) ident(io)operator(.)ident(getChannel)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(channel) keyword(instanceof) pre_type(SelectableChannel)operator(\)) operator({) - pre_type(SelectableChannel) ident(selectable) operator(=) operator(()pre_type(SelectableChannel)operator(\))ident(channel)operator(;) - - directive(synchronized) operator(()ident(selectable)operator(.)ident(blockingLock)operator(()operator(\))operator(\)) operator({) - type(boolean) ident(oldBlocking) operator(=) ident(selectable)operator(.)ident(isBlocking)operator(()operator(\))operator(;) - - keyword(try) operator({) - ident(selectable)operator(.)ident(configureBlocking)operator(()pre_constant(false)operator(\))operator(;) - - ident(io)operator(.)ident(addBlockingThread)operator(()local_variable(this)operator(\))operator(;) - ident(currentSelector) operator(=) ident(selectable)operator(.)ident(provider)operator(()operator(\))operator(.)ident(openSelector)operator(()operator(\))operator(;) - - pre_type(SelectionKey) ident(key) operator(=) ident(selectable)operator(.)ident(register)operator(()ident(currentSelector)operator(,) ident(ops)operator(\))operator(;) - - type(int) ident(result) operator(=) ident(currentSelector)operator(.)ident(select)operator(()operator(\))operator(;) - - comment(// check for thread events, in case we've been woken up to die) - ident(pollThreadEvents)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(result) operator(==) integer(1)operator(\)) operator({) - pre_type(Set)operator(<)pre_type(SelectionKey)operator(>) ident(keySet) operator(=) ident(currentSelector)operator(.)ident(selectedKeys)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(keySet)operator(.)ident(iterator)operator(()operator(\))operator(.)ident(next)operator(()operator(\)) operator(==) ident(key)operator(\)) operator({) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - keyword(return) pre_constant(false)operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(throw) ident(io)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(Error with selector: )delimiter(")> operator(+) ident(ioe)operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(if) operator(()ident(currentSelector) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - ident(currentSelector)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - keyword(throw) ident(io)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newRuntimeError)operator(()string<delimiter(")content(Could not close selector)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - ident(currentSelector) operator(=) pre_constant(null)operator(;) - ident(io)operator(.)ident(removeBlockingThread)operator(()local_variable(this)operator(\))operator(;) - keyword(try) operator({) - ident(selectable)operator(.)ident(configureBlocking)operator(()ident(oldBlocking)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(ioe)operator(\)) operator({) - comment(// ignore; I don't like doing it, but it seems like we) - comment(// really just need to make all channels non-blocking by) - comment(// default and use select when implementing blocking ops,) - comment(// so if this remains set non-blocking, perhaps it's not) - comment(// such a big deal...) - operator(}) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - comment(// can't select, just have to do a blocking call) - keyword(return) pre_constant(true)operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(interrupt)operator(()operator(\)) operator({) - keyword(if) operator(()ident(currentSelector) operator(!=) pre_constant(null)operator(\)) operator({) - ident(currentSelector)operator(.)ident(wakeup)operator(()operator(\))operator(;) - operator(}) - operator(}) - - directive(public) type(void) ident(beforeBlockingCall)operator(()operator(\)) operator({) - ident(isStopped) operator(=) pre_constant(true)operator(;) - operator(}) - - directive(public) type(void) ident(afterBlockingCall)operator(()operator(\)) operator({) - ident(isStopped) operator(=) pre_constant(false)operator(;) - operator(}) - - directive(private) type(void) ident(receivedAnException)operator(()ident(ThreadContext) ident(context)operator(\)) operator({) - comment(// clear this so we don't keep re-throwing) - ident(IRubyObject) ident(raiseException) operator(=) ident(receivedException)operator(;) - ident(receivedException) operator(=) pre_constant(null)operator(;) - ident(RubyModule) ident(kernelModule) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getKernel)operator(()operator(\))operator(;) - keyword(if) operator(()ident(DEBUG)operator(\)) operator({) - pre_type(System)operator(.)ident(out)operator(.)ident(println)operator(()string<delimiter(")content(thread )delimiter(")> operator(+) pre_type(Thread)operator(.)ident(currentThread)operator(()operator(\)) operator(+) string<delimiter(")content( before propagating exception: )delimiter(")> operator(+) ident(killed)operator(\))operator(;) - operator(}) - ident(kernelModule)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(raise)delimiter(")>operator(,) ident(raiseException)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * Implementation of Ruby's <code>ThreadGroup</code> class. This is currently - * just a stub. - * <p> - * - * @author Charles O Nutter (headius@headius.com\) - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(ThreadGroup)delimiter(")>operator(\)) -directive(public) type(class) class(RubyThreadGroup) directive(extends) ident(RubyObject) operator({) - directive(private) pre_type(Map)operator(<)pre_type(Integer)operator(,) ident(IRubyObject)operator(>) ident(rubyThreadList) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(Integer)operator(,) ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - directive(private) type(boolean) ident(enclosed) operator(=) pre_constant(false)operator(;) - - comment(// ENEBO: Can these be fast?) - directive(public) directive(static) ident(RubyClass) ident(createThreadGroupClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(threadGroupClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(ThreadGroup)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setThreadGroup)operator(()ident(threadGroupClass)operator(\))operator(;) - - ident(threadGroupClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyThreadGroup)operator(.)ident(class)operator(\))operator(;) - - comment(// create the default thread group) - ident(RubyThreadGroup) ident(defaultThreadGroup) operator(=) keyword(new) ident(RubyThreadGroup)operator(()ident(runtime)operator(,) ident(threadGroupClass)operator(\))operator(;) - ident(runtime)operator(.)ident(setDefaultThreadGroup)operator(()ident(defaultThreadGroup)operator(\))operator(;) - ident(threadGroupClass)operator(.)ident(defineConstant)operator(()string<delimiter(")content(Default)delimiter(")>operator(,) ident(defaultThreadGroup)operator(\))operator(;) - - keyword(return) ident(threadGroupClass)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyThreadGroup)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,) operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(add)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(synchronized) ident(IRubyObject) ident(add)operator(()ident(IRubyObject) ident(rubyThread)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(rubyThread) keyword(instanceof) ident(RubyThread)operator(\))operator(\)) keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()ident(rubyThread)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(getThread)operator(()operator(\))operator(\))operator(;) - - comment(// synchronize on the RubyThread for threadgroup updates) - keyword(if) operator(()ident(isFrozen)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't add to frozen ThreadGroup)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyThread) ident(thread) operator(=) operator(()ident(RubyThread)operator(\))ident(rubyThread)operator(;) - - comment(// we only add live threads) - keyword(if) operator(()ident(thread)operator(.)ident(alive_p)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(addDirectly)operator(()ident(thread)operator(\))operator(;) - operator(}) - - keyword(return) local_variable(this)operator(;) - operator(}) - - type(void) ident(addDirectly)operator(()ident(RubyThread) ident(rubyThread)operator(\)) operator({) - directive(synchronized) operator(()ident(rubyThread)operator(\)) operator({) - ident(IRubyObject) ident(oldGroup) operator(=) ident(rubyThread)operator(.)ident(group)operator(()operator(\))operator(;) - keyword(if) operator(()ident(oldGroup) operator(!=) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(\)) operator({) - ident(RubyThreadGroup) ident(threadGroup) operator(=) operator(()ident(RubyThreadGroup)operator(\)) ident(oldGroup)operator(;) - ident(threadGroup)operator(.)ident(rubyThreadList)operator(.)ident(remove)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()ident(rubyThread)operator(\))operator(\))operator(;) - operator(}) - - ident(rubyThread)operator(.)ident(setThreadGroup)operator(()local_variable(this)operator(\))operator(;) - ident(rubyThreadList)operator(.)ident(put)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()ident(rubyThread)operator(\))operator(,) ident(rubyThread)operator(\))operator(;) - operator(}) - operator(}) - - directive(public) directive(synchronized) type(void) ident(remove)operator(()ident(RubyThread) ident(rubyThread)operator(\)) operator({) - ident(rubyThread)operator(.)ident(setThreadGroup)operator(()pre_constant(null)operator(\))operator(;) - ident(rubyThreadList)operator(.)ident(remove)operator(()pre_type(System)operator(.)ident(identityHashCode)operator(()ident(rubyThread)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(enclose)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(enclose)operator(()ident(Block) ident(block)operator(\)) operator({) - ident(enclosed) operator(=) pre_constant(true)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(enclosed?)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(enclosed_p)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyBoolean)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(enclosed)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(list)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) directive(synchronized) ident(IRubyObject) ident(list)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()operator(()ident(IRubyObject)type([])operator(\)) ident(rubyThreadList)operator(.)ident(values)operator(()operator(\))operator(.)ident(toArray)operator(()keyword(new) ident(IRubyObject)operator([)ident(rubyThreadList)operator(.)ident(size)operator(()operator(\))operator(])operator(\))operator(\))operator(;) - operator(}) - - directive(private) ident(RubyThreadGroup)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C\) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C\) 2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2006 Ola Bini <ola.bini@ki.se> - * Copyright (C\) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.lang.ref.SoftReference)operator(;) -keyword(import) include(java.util.Date)operator(;) -keyword(import) include(java.util.HashMap)operator(;) -keyword(import) include(java.util.Locale)operator(;) -keyword(import) include(java.util.Map)operator(;) -keyword(import) include(java.util.TimeZone)operator(;) -keyword(import) include(java.util.regex.Matcher)operator(;) -keyword(import) include(java.util.regex.Pattern)operator(;) - -keyword(import) include(org.joda.time.DateTime)operator(;) -keyword(import) include(org.joda.time.DateTimeZone)operator(;) -keyword(import) include(org.joda.time.format.DateTimeFormat)operator(;) -keyword(import) include(org.joda.time.format.DateTimeFormatter)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ClassIndex)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.util.ByteList)operator(;) -keyword(import) include(org.jruby.util.RubyDateFormat)operator(;) - -comment(/** The Time class. - * - * @author chadfowler, jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Time)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Comparable)delimiter(")>operator(\)) -directive(public) type(class) class(RubyTime) directive(extends) ident(RubyObject) operator({) - directive(public) directive(static) directive(final) pre_type(String) ident(UTC) operator(=) string<delimiter(")content(UTC)delimiter(")>operator(;) - directive(private) ident(DateTime) ident(dt)operator(;) - directive(private) type(long) ident(usec)operator(;) - - directive(private) directive(final) directive(static) ident(DateTimeFormatter) ident(ONE_DAY_CTIME_FORMATTER) operator(=) ident(DateTimeFormat)operator(.)ident(forPattern)operator(()string<delimiter(")content(EEE MMM d HH:mm:ss yyyy)delimiter(")>operator(\))operator(.)ident(withLocale)operator(()pre_type(Locale)operator(.)ident(ENGLISH)operator(\))operator(;) - directive(private) directive(final) directive(static) ident(DateTimeFormatter) ident(TWO_DAY_CTIME_FORMATTER) operator(=) ident(DateTimeFormat)operator(.)ident(forPattern)operator(()string<delimiter(")content(EEE MMM dd HH:mm:ss yyyy)delimiter(")>operator(\))operator(.)ident(withLocale)operator(()pre_type(Locale)operator(.)ident(ENGLISH)operator(\))operator(;) - - directive(private) directive(final) directive(static) ident(DateTimeFormatter) ident(TO_S_FORMATTER) operator(=) ident(DateTimeFormat)operator(.)ident(forPattern)operator(()string<delimiter(")content(EEE MMM dd HH:mm:ss Z yyyy)delimiter(")>operator(\))operator(.)ident(withLocale)operator(()pre_type(Locale)operator(.)ident(ENGLISH)operator(\))operator(;) - directive(private) directive(final) directive(static) ident(DateTimeFormatter) ident(TO_S_UTC_FORMATTER) operator(=) ident(DateTimeFormat)operator(.)ident(forPattern)operator(()string<delimiter(")content(EEE MMM dd HH:mm:ss 'UTC' yyyy)delimiter(")>operator(\))operator(.)ident(withLocale)operator(()pre_type(Locale)operator(.)ident(ENGLISH)operator(\))operator(;) - - comment(// There are two different popular TZ formats: legacy (AST+3:00:00, GMT-3\), and) - comment(// newer one (US/Pacific, America/Los_Angeles\). This pattern is to detect) - comment(// the legacy TZ format in order to convert it to the newer format) - comment(// understood by Java API.) - directive(private) directive(static) directive(final) pre_type(Pattern) ident(TZ_PATTERN) - operator(=) pre_type(Pattern)operator(.)ident(compile)operator(()string<delimiter(")content(()char(\\\\)content(D+?\)([)char(\\\\)content(+-]?\)()char(\\\\)content(d+\)(:)char(\\\\)content(d+\)?(:)char(\\\\)content(d+\)?)delimiter(")>operator(\))operator(;) - - directive(private) directive(static) directive(final) ident(ByteList) ident(TZ_STRING) operator(=) ident(ByteList)operator(.)ident(create)operator(()string<delimiter(")content(TZ)delimiter(")>operator(\))operator(;) - - directive(public) directive(static) ident(DateTimeZone) ident(getLocalTimeZone)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyString) ident(tzVar) operator(=) ident(runtime)operator(.)ident(newString)operator(()ident(TZ_STRING)operator(\))operator(;) - ident(RubyHash) ident(h) operator(=) operator(()operator(()ident(RubyHash)operator(\))ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ENV)delimiter(")>operator(\))operator(\))operator(;) - ident(IRubyObject) ident(tz) operator(=) ident(h)operator(.)ident(op_aref)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(tzVar)operator(\))operator(;) - keyword(if) operator(()ident(tz) operator(==) pre_constant(null) operator(||) operator(!) operator(()ident(tz) keyword(instanceof) ident(RubyString)operator(\))operator(\)) operator({) - keyword(return) ident(DateTimeZone)operator(.)ident(getDefault)operator(()operator(\))operator(;) - operator(}) keyword(else) operator({) - pre_type(String) ident(zone) operator(=) ident(tz)operator(.)ident(toString)operator(()operator(\))operator(;) - ident(DateTimeZone) ident(cachedZone) operator(=) ident(runtime)operator(.)ident(getLocalTimezoneCache)operator(()operator(\))operator(.)ident(get)operator(()ident(zone)operator(\))operator(;) - - keyword(if) operator(()ident(cachedZone) operator(!=) pre_constant(null)operator(\)) keyword(return) ident(cachedZone)operator(;) - - pre_type(String) ident(originalZone) operator(=) ident(zone)operator(;) - - comment(// Value of "TZ" property is of a bit different format,) - comment(// which confuses the Java's TimeZone.getTimeZone(id\) method,) - comment(// and so, we need to convert it.) - - pre_type(Matcher) ident(tzMatcher) operator(=) ident(TZ_PATTERN)operator(.)ident(matcher)operator(()ident(zone)operator(\))operator(;) - keyword(if) operator(()ident(tzMatcher)operator(.)ident(matches)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(sign) operator(=) ident(tzMatcher)operator(.)ident(group)operator(()integer(2)operator(\))operator(;) - pre_type(String) ident(hours) operator(=) ident(tzMatcher)operator(.)ident(group)operator(()integer(3)operator(\))operator(;) - pre_type(String) ident(minutes) operator(=) ident(tzMatcher)operator(.)ident(group)operator(()integer(4)operator(\))operator(;) - - comment(// GMT+00:00 --> Etc/GMT, see "MRI behavior") - comment(// comment below.) - keyword(if) operator(()operator(()string<delimiter(")content(00)delimiter(")>operator(.)ident(equals)operator(()ident(hours)operator(\)) operator(||) string<delimiter(")content(0)delimiter(")>operator(.)ident(equals)operator(()ident(hours)operator(\))operator(\)) - operator(&&) operator(()ident(minutes) operator(==) pre_constant(null) operator(||) string<delimiter(")content(:00)delimiter(")>operator(.)ident(equals)operator(()ident(minutes)operator(\)) operator(||) string<delimiter(")content(:0)delimiter(")>operator(.)ident(equals)operator(()ident(minutes)operator(\))operator(\))operator(\)) operator({) - ident(zone) operator(=) string<delimiter(")content(Etc/GMT)delimiter(")>operator(;) - operator(}) keyword(else) operator({) - comment(// Invert the sign, since TZ format and Java format) - comment(// use opposite signs, sigh... Also, Java API requires) - comment(// the sign to be always present, be it "+" or "-".) - ident(sign) operator(=) operator(()string<delimiter(")content(-)delimiter(")>operator(.)ident(equals)operator(()ident(sign)operator(\))operator(?) string<delimiter(")content(+)delimiter(")> operator(:) string<delimiter(")content(-)delimiter(")>operator(\))operator(;) - - comment(// Always use "GMT" since that's required by Java API.) - ident(zone) operator(=) string<delimiter(")content(GMT)delimiter(")> operator(+) ident(sign) operator(+) ident(hours)operator(;) - - keyword(if) operator(()ident(minutes) operator(!=) pre_constant(null)operator(\)) operator({) - ident(zone) operator(+=) ident(minutes)operator(;) - operator(}) - operator(}) - operator(}) - - comment(// MRI behavior: With TZ equal to "GMT" or "UTC", Time.now) - comment(// is *NOT* considered as a proper GMT/UTC time:) - comment(// ENV['TZ']="GMT") - comment(// Time.now.gmt? ==> false) - comment(// ENV['TZ']="UTC") - comment(// Time.now.utc? ==> false) - comment(// Hence, we need to adjust for that.) - keyword(if) operator(()string<delimiter(")content(GMT)delimiter(")>operator(.)ident(equalsIgnoreCase)operator(()ident(zone)operator(\)) operator(||) string<delimiter(")content(UTC)delimiter(")>operator(.)ident(equalsIgnoreCase)operator(()ident(zone)operator(\))operator(\)) operator({) - ident(zone) operator(=) string<delimiter(")content(Etc/)delimiter(")> operator(+) ident(zone)operator(;) - operator(}) - - ident(DateTimeZone) ident(dtz) operator(=) ident(DateTimeZone)operator(.)ident(forTimeZone)operator(()pre_type(TimeZone)operator(.)ident(getTimeZone)operator(()ident(zone)operator(\))operator(\))operator(;) - ident(runtime)operator(.)ident(getLocalTimezoneCache)operator(()operator(\))operator(.)ident(put)operator(()ident(originalZone)operator(,) ident(dtz)operator(\))operator(;) - keyword(return) ident(dtz)operator(;) - operator(}) - operator(}) - - directive(public) ident(RubyTime)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyTime)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(rubyClass)operator(,) ident(DateTime) ident(dt)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(rubyClass)operator(\))operator(;) - local_variable(this)operator(.)ident(dt) operator(=) ident(dt)operator(;) - operator(}) - - comment(// We assume that these two time instances) - comment(// occurred at the same time.) - directive(private) directive(static) directive(final) type(long) ident(BASE_TIME_MILLIS) operator(=) pre_type(System)operator(.)ident(currentTimeMillis)operator(()operator(\))operator(;) - directive(private) directive(static) directive(final) type(long) ident(BASE_TIME_NANOS) operator(=) pre_type(System)operator(.)ident(nanoTime)operator(()operator(\))operator(;) - - directive(private) directive(static) ident(ObjectAllocator) ident(TIME_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - type(long) ident(usecsPassed) operator(=) operator(()pre_type(System)operator(.)ident(nanoTime)operator(()operator(\)) operator(-) ident(BASE_TIME_NANOS)operator(\)) operator(/) integer(1000L)operator(;) - type(long) ident(millisTime) operator(=) ident(BASE_TIME_MILLIS) operator(+) ident(usecsPassed) operator(/) integer(1000L)operator(;) - type(long) ident(usecs) operator(=) ident(usecsPassed) operator(%) integer(1000L)operator(;) - - ident(DateTimeZone) ident(dtz) operator(=) ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(;) - ident(DateTime) ident(dt) operator(=) keyword(new) ident(DateTime)operator(()ident(millisTime)operator(,) ident(dtz)operator(\))operator(;) - ident(RubyTime) ident(rt) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) ident(klass)operator(,) ident(dt)operator(\))operator(;) - ident(rt)operator(.)ident(setUSec)operator(()ident(usecs)operator(\))operator(;) - - keyword(return) ident(rt)operator(;) - operator(}) - operator(})operator(;) - - directive(public) directive(static) ident(RubyClass) ident(createTimeClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyClass) ident(timeClass) operator(=) ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(Time)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(TIME_ALLOCATOR)operator(\))operator(;) - ident(timeClass)operator(.)ident(index) operator(=) ident(ClassIndex)operator(.)ident(TIME)operator(;) - ident(runtime)operator(.)ident(setTime)operator(()ident(timeClass)operator(\))operator(;) - - ident(timeClass)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getComparable)operator(()operator(\))operator(\))operator(;) - - ident(timeClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyTime)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(timeClass)operator(;) - operator(}) - - directive(public) type(void) ident(setUSec)operator(()type(long) ident(usec)operator(\)) operator({) - local_variable(this)operator(.)ident(usec) operator(=) ident(usec)operator(;) - operator(}) - - directive(public) type(long) ident(getUSec)operator(()operator(\)) operator({) - keyword(return) ident(usec)operator(;) - operator(}) - - directive(public) type(void) ident(updateCal)operator(()ident(DateTime) ident(dt)operator(\)) operator({) - local_variable(this)operator(.)ident(dt) operator(=) ident(dt)operator(;) - operator(}) - - directive(protected) type(long) ident(getTimeInMillis)operator(()operator(\)) operator({) - keyword(return) ident(dt)operator(.)ident(getMillis)operator(()operator(\))operator(;) comment(// For JDK 1.4 we can use "cal.getTimeInMillis(\)") - operator(}) - - directive(public) directive(static) ident(RubyTime) ident(newTime)operator(()ident(Ruby) ident(runtime)operator(,) type(long) ident(milliseconds)operator(\)) operator({) - keyword(return) ident(newTime)operator(()ident(runtime)operator(,) keyword(new) ident(DateTime)operator(()ident(milliseconds)operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyTime) ident(newTime)operator(()ident(Ruby) ident(runtime)operator(,) ident(DateTime) ident(dt)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getTime)operator(()operator(\))operator(,) ident(dt)operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyTime) ident(newTime)operator(()ident(Ruby) ident(runtime)operator(,) ident(DateTime) ident(dt)operator(,) type(long) ident(usec)operator(\)) operator({) - ident(RubyTime) ident(t) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getTime)operator(()operator(\))operator(,) ident(dt)operator(\))operator(;) - ident(t)operator(.)ident(setUSec)operator(()ident(usec)operator(\))operator(;) - keyword(return) ident(t)operator(;) - operator(}) - - annotation(@Override) - directive(public) pre_type(Class)operator(<)operator(?)operator(>) ident(getJavaClass)operator(()operator(\)) operator({) - keyword(return) pre_type(Date)operator(.)ident(class)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize_copy)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(initialize_copy)operator(()ident(IRubyObject) ident(original)operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(original) keyword(instanceof) ident(RubyTime)operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(Expecting an instance of class Time)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyTime) ident(originalTime) operator(=) operator(()ident(RubyTime)operator(\)) ident(original)operator(;) - - comment(// We can just use dt, since it is immutable) - ident(dt) operator(=) ident(originalTime)operator(.)ident(dt)operator(;) - ident(usec) operator(=) ident(originalTime)operator(.)ident(usec)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(succ)delimiter(")>operator(\)) - directive(public) ident(RubyTime) ident(succ)operator(()operator(\)) operator({) - keyword(return) ident(newTime)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(dt)operator(.)ident(plusSeconds)operator(()integer(1)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(gmtime)delimiter(")>operator(,) string<delimiter(")content(utc)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyTime) ident(gmtime)operator(()operator(\)) operator({) - ident(dt) operator(=) ident(dt)operator(.)ident(withZone)operator(()ident(DateTimeZone)operator(.)ident(UTC)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(localtime)delimiter(")>operator(\)) - directive(public) ident(RubyTime) ident(localtime)operator(()operator(\)) operator({) - ident(dt) operator(=) ident(dt)operator(.)ident(withZone)operator(()ident(getLocalTimeZone)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(gmt?)delimiter(")>operator(,) string<delimiter(")content(utc?)delimiter(")>operator(,) string<delimiter(")content(gmtime?)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(gmt)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(.)ident(getID)operator(()operator(\))operator(.)ident(equals)operator(()string<delimiter(")content(UTC)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(getgm)delimiter(")>operator(,) string<delimiter(")content(getutc)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyTime) ident(getgm)operator(()operator(\)) operator({) - keyword(return) ident(newTime)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(dt)operator(.)ident(withZone)operator(()ident(DateTimeZone)operator(.)ident(UTC)operator(\))operator(,) ident(getUSec)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getlocal)delimiter(")>operator(\)) - directive(public) ident(RubyTime) ident(getlocal)operator(()operator(\)) operator({) - keyword(return) ident(newTime)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(dt)operator(.)ident(withZone)operator(()ident(getLocalTimeZone)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(,) ident(getUSec)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(strftime)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(RubyString) ident(strftime)operator(()ident(IRubyObject) ident(format)operator(\)) operator({) - directive(final) ident(RubyDateFormat) ident(rubyDateFormat) operator(=) keyword(new) ident(RubyDateFormat)operator(()string<delimiter(")content(-)delimiter(")>operator(,) pre_type(Locale)operator(.)ident(US)operator(\))operator(;) - ident(rubyDateFormat)operator(.)ident(applyPattern)operator(()ident(format)operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(rubyDateFormat)operator(.)ident(setDateTime)operator(()ident(dt)operator(\))operator(;) - pre_type(String) ident(result) operator(=) ident(rubyDateFormat)operator(.)ident(format)operator(()pre_constant(null)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_ge)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(cmp)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\)) operator(>=) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_ge)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_gt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(cmp)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\)) operator(>) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_gt)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_le)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(cmp)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\)) operator(<=) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_le)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_lt)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()ident(cmp)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\)) operator(<) integer(0)operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyComparable)operator(.)ident(op_lt)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(other)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(cmp)operator(()ident(RubyTime) ident(other)operator(\)) operator({) - type(long) ident(millis) operator(=) ident(getTimeInMillis)operator(()operator(\))operator(;) - type(long) ident(millis_other) operator(=) ident(other)operator(.)ident(getTimeInMillis)operator(()operator(\))operator(;) - type(long) ident(usec_other) operator(=) ident(other)operator(.)ident(usec)operator(;) - - keyword(if) operator(()ident(millis) operator(>) ident(millis_other) operator(||) operator(()ident(millis) operator(==) ident(millis_other) operator(&&) ident(usec) operator(>) ident(usec_other)operator(\))operator(\)) operator({) - keyword(return) integer(1)operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(millis) operator(<) ident(millis_other) operator(||) operator(()ident(millis) operator(==) ident(millis_other) operator(&&) ident(usec) operator(<) ident(usec_other)operator(\))operator(\)) operator({) - keyword(return) operator(-)integer(1)operator(;) - operator(}) - - keyword(return) integer(0)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(+)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_plus)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - type(long) ident(time) operator(=) ident(getTimeInMillis)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(time + time ?)delimiter(")>operator(\))operator(;) - operator(}) - type(long) ident(adjustment) operator(=) operator(()type(long)operator(\)) operator(()ident(RubyNumeric)operator(.)ident(num2dbl)operator(()ident(other)operator(\)) operator(*) integer(1000000)operator(\))operator(;) - type(int) ident(micro) operator(=) operator(()type(int)operator(\)) operator(()ident(adjustment) operator(%) integer(1000)operator(\))operator(;) - ident(adjustment) operator(=) ident(adjustment) operator(/) integer(1000)operator(;) - - ident(time) operator(+=) ident(adjustment)operator(;) - - ident(RubyTime) ident(newTime) operator(=) keyword(new) ident(RubyTime)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - ident(newTime)operator(.)ident(dt) operator(=) keyword(new) ident(DateTime)operator(()ident(time)operator(\))operator(.)ident(withZone)operator(()ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(\))operator(;) - ident(newTime)operator(.)ident(setUSec)operator(()ident(micro)operator(\))operator(;) - - keyword(return) ident(newTime)operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(opMinus)operator(()ident(RubyTime) ident(other)operator(\)) operator({) - type(long) ident(time) operator(=) ident(getTimeInMillis)operator(()operator(\)) operator(*) integer(1000) operator(+) ident(getUSec)operator(()operator(\))operator(;) - - ident(time) operator(-=) ident(other)operator(.)ident(getTimeInMillis)operator(()operator(\)) operator(*) integer(1000) operator(+) ident(other)operator(.)ident(getUSec)operator(()operator(\))operator(;) - - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(time) operator(/) float(1000000.0)operator(\))operator(;) comment(// float number of seconds) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(-)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_minus)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) keyword(return) ident(opMinus)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\))operator(;) - - type(long) ident(time) operator(=) ident(getTimeInMillis)operator(()operator(\))operator(;) - type(long) ident(adjustment) operator(=) operator(()type(long)operator(\)) operator(()ident(RubyNumeric)operator(.)ident(num2dbl)operator(()ident(other)operator(\)) operator(*) integer(1000000)operator(\))operator(;) - type(int) ident(micro) operator(=) operator(()type(int)operator(\)) operator(()ident(adjustment) operator(%) integer(1000)operator(\))operator(;) - ident(adjustment) operator(=) ident(adjustment) operator(/) integer(1000)operator(;) - - ident(time) operator(-=) ident(adjustment)operator(;) - - ident(RubyTime) ident(newTime) operator(=) keyword(new) ident(RubyTime)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(getMetaClass)operator(()operator(\))operator(\))operator(;) - ident(newTime)operator(.)ident(dt) operator(=) keyword(new) ident(DateTime)operator(()ident(time)operator(\))operator(.)ident(withZone)operator(()ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(\))operator(;) - ident(newTime)operator(.)ident(setUSec)operator(()ident(micro)operator(\))operator(;) - - keyword(return) ident(newTime)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(===)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(op_eqq)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(return) operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_SPACESHIP)operator(,) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(other)operator(\))operator(\)) operator(==) integer(0)operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<=>)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(op_cmp)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(cmp)operator(()operator(()ident(RubyTime)operator(\)) ident(other)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eql?)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(eql_p)operator(()ident(IRubyObject) ident(other)operator(\)) operator({) - keyword(if) operator(()ident(other) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - ident(RubyTime) ident(otherTime) operator(=) operator(()ident(RubyTime)operator(\))ident(other)operator(;) - keyword(return) operator(()ident(usec) operator(==) ident(otherTime)operator(.)ident(usec) operator(&&) ident(getTimeInMillis)operator(()operator(\)) operator(==) ident(otherTime)operator(.)ident(getTimeInMillis)operator(()operator(\))operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(asctime)delimiter(")>operator(,) string<delimiter(")content(ctime)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyString) ident(asctime)operator(()operator(\)) operator({) - ident(DateTimeFormatter) ident(simpleDateFormat)operator(;) - - keyword(if) operator(()ident(dt)operator(.)ident(getDayOfMonth)operator(()operator(\)) operator(<) integer(10)operator(\)) operator({) - ident(simpleDateFormat) operator(=) ident(ONE_DAY_CTIME_FORMATTER)operator(;) - operator(}) keyword(else) operator({) - ident(simpleDateFormat) operator(=) ident(TWO_DAY_CTIME_FORMATTER)operator(;) - operator(}) - pre_type(String) ident(result) operator(=) ident(simpleDateFormat)operator(.)ident(print)operator(()ident(dt)operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_s)delimiter(")>operator(,) string<delimiter(")content(inspect)delimiter(")>operator(})operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_s)operator(()operator(\)) operator({) - ident(DateTimeFormatter) ident(simpleDateFormat)operator(;) - keyword(if) operator(()ident(dt)operator(.)ident(getZone)operator(()operator(\)) operator(==) ident(DateTimeZone)operator(.)ident(UTC)operator(\)) operator({) - ident(simpleDateFormat) operator(=) ident(TO_S_UTC_FORMATTER)operator(;) - operator(}) keyword(else) operator({) - ident(simpleDateFormat) operator(=) ident(TO_S_FORMATTER)operator(;) - operator(}) - - pre_type(String) ident(result) operator(=) ident(simpleDateFormat)operator(.)ident(print)operator(()ident(dt)operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_a)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyArray) ident(to_a)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()keyword(new) ident(IRubyObject)type([]) operator({) ident(sec)operator(()operator(\))operator(,) ident(min)operator(()operator(\))operator(,) ident(hour)operator(()operator(\))operator(,) ident(mday)operator(()operator(\))operator(,) ident(month)operator(()operator(\))operator(,) - ident(year)operator(()operator(\))operator(,) ident(wday)operator(()operator(\))operator(,) ident(yday)operator(()operator(\))operator(,) ident(isdst)operator(()operator(\))operator(,) ident(zone)operator(()operator(\)) operator(})operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_f)delimiter(")>operator(\)) - directive(public) ident(RubyFloat) ident(to_f)operator(()operator(\)) operator({) - type(long) ident(time) operator(=) ident(getTimeInMillis)operator(()operator(\))operator(;) - ident(time) operator(=) ident(time) operator(*) integer(1000) operator(+) ident(usec)operator(;) - keyword(return) ident(RubyFloat)operator(.)ident(newFloat)operator(()ident(getRuntime)operator(()operator(\))operator(,) ident(time) operator(/) float(1000000.0)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(to_i)delimiter(")>operator(,) string<delimiter(")content(tv_sec)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(to_i)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(getTimeInMillis)operator(()operator(\)) operator(/) integer(1000)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(usec)delimiter(")>operator(,) string<delimiter(")content(tv_usec)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(usec)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getMillisOfSecond)operator(()operator(\)) operator(*) integer(1000) operator(+) ident(getUSec)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setMicroseconds)operator(()type(long) ident(mic)operator(\)) operator({) - type(long) ident(millis) operator(=) ident(getTimeInMillis)operator(()operator(\)) operator(%) integer(1000)operator(;) - type(long) ident(withoutMillis) operator(=) ident(getTimeInMillis)operator(()operator(\)) operator(-) ident(millis)operator(;) - ident(withoutMillis) operator(+=) operator(()ident(mic) operator(/) integer(1000)operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withMillis)operator(()ident(withoutMillis)operator(\))operator(;) - ident(usec) operator(=) ident(mic) operator(%) integer(1000)operator(;) - operator(}) - - directive(public) type(long) ident(microseconds)operator(()operator(\)) operator({) - keyword(return) ident(getTimeInMillis)operator(()operator(\)) operator(%) integer(1000) operator(*) integer(1000) operator(+) ident(usec)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sec)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(sec)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getSecondOfMinute)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(min)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(min)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getMinuteOfHour)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hour)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(hour)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getHourOfDay)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(mday)delimiter(")>operator(,) string<delimiter(")content(day)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(mday)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getDayOfMonth)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(month)delimiter(")>operator(,) string<delimiter(")content(mon)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(month)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getMonthOfYear)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(year)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(year)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getYear)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(wday)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(wday)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(()ident(dt)operator(.)ident(getDayOfWeek)operator(()operator(\))operator(%)integer(7)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(yday)delimiter(")>operator(\)) - directive(public) ident(RubyInteger) ident(yday)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(dt)operator(.)ident(getDayOfYear)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(gmt_offset)delimiter(")>operator(,) string<delimiter(")content(gmtoff)delimiter(")>operator(,) string<delimiter(")content(utc_offset)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyInteger) ident(gmt_offset)operator(()operator(\)) operator({) - type(int) ident(offset) operator(=) ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(.)ident(getOffsetFromLocal)operator(()ident(dt)operator(.)ident(getMillis)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(()type(int)operator(\))operator(()ident(offset)operator(/)integer(1000)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(isdst)delimiter(")>operator(,) string<delimiter(")content(dst?)delimiter(")>operator(})operator(\)) - directive(public) ident(RubyBoolean) ident(isdst)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newBoolean)operator(()operator(!)ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(.)ident(isStandardOffset)operator(()ident(dt)operator(.)ident(getMillis)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zone)delimiter(")>operator(\)) - directive(public) ident(RubyString) ident(zone)operator(()operator(\)) operator({) - pre_type(String) ident(zone) operator(=) ident(dt)operator(.)ident(getZone)operator(()operator(\))operator(.)ident(getShortName)operator(()ident(dt)operator(.)ident(getMillis)operator(()operator(\))operator(\))operator(;) - keyword(if)operator(()ident(zone)operator(.)ident(equals)operator(()string<delimiter(")content(+00:00)delimiter(")>operator(\))operator(\)) operator({) - ident(zone) operator(=) string<delimiter(")content(GMT)delimiter(")>operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(zone)operator(\))operator(;) - operator(}) - - directive(public) type(void) ident(setDateTime)operator(()ident(DateTime) ident(dt)operator(\)) operator({) - local_variable(this)operator(.)ident(dt) operator(=) ident(dt)operator(;) - operator(}) - - directive(public) ident(DateTime) ident(getDateTime)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(dt)operator(;) - operator(}) - - directive(public) pre_type(Date) ident(getJavaDate)operator(()operator(\)) operator({) - keyword(return) local_variable(this)operator(.)ident(dt)operator(.)ident(toDate)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(hash)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyFixnum) ident(hash)operator(()operator(\)) operator({) - comment(// modified to match how hash is calculated in 1.8.2) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()operator(()type(int)operator(\))operator(()operator(()operator(()ident(dt)operator(.)ident(getMillis)operator(()operator(\)) operator(/) integer(1000)operator(\)) operator(^) ident(microseconds)operator(()operator(\))operator(\)) operator(<)operator(<) integer(1)operator(\)) operator(>)operator(>) integer(1)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_dump)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyString) ident(dump)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(RubyString) ident(str) operator(=) operator(()ident(RubyString)operator(\)) ident(mdump)operator(()keyword(new) ident(IRubyObject)type([]) operator({) local_variable(this) operator(})operator(\))operator(;) - ident(str)operator(.)ident(syncVariables)operator(()local_variable(this)operator(.)ident(getVariableList)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(str)operator(;) - operator(}) - - directive(public) ident(RubyObject) ident(mdump)operator(()directive(final) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(RubyTime) ident(obj) operator(=) operator(()ident(RubyTime)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - ident(DateTime) ident(dateTime) operator(=) ident(obj)operator(.)ident(dt)operator(.)ident(withZone)operator(()ident(DateTimeZone)operator(.)ident(UTC)operator(\))operator(;) - type(byte) ident(dumpValue)type([]) operator(=) keyword(new) type(byte)operator([)integer(8)operator(])operator(;) - type(int) ident(pe) operator(=) - hex(0x1) operator(<)operator(<) integer(31) operator(|) - operator(()ident(dateTime)operator(.)ident(getYear)operator(()operator(\))operator(-)integer(1900)operator(\)) operator(<)operator(<) integer(14) operator(|) - operator(()ident(dateTime)operator(.)ident(getMonthOfYear)operator(()operator(\))operator(-)integer(1)operator(\)) operator(<)operator(<) integer(10) operator(|) - ident(dateTime)operator(.)ident(getDayOfMonth)operator(()operator(\)) operator(<)operator(<) integer(5) operator(|) - ident(dateTime)operator(.)ident(getHourOfDay)operator(()operator(\))operator(;) - type(int) ident(se) operator(=) - ident(dateTime)operator(.)ident(getMinuteOfHour)operator(()operator(\)) operator(<)operator(<) integer(26) operator(|) - ident(dateTime)operator(.)ident(getSecondOfMinute)operator(()operator(\)) operator(<)operator(<) integer(20) operator(|) - operator(()ident(dateTime)operator(.)ident(getMillisOfSecond)operator(()operator(\)) operator(*) integer(1000) operator(+) operator(()type(int)operator(\))ident(usec)operator(\))operator(;) comment(// dump usec, not msec) - - keyword(for)operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) integer(4)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(dumpValue)operator([)ident(i)operator(]) operator(=) operator(()type(byte)operator(\))operator(()ident(pe) operator(&) hex(0xFF)operator(\))operator(;) - ident(pe) operator(>)operator(>)operator(>=) integer(8)operator(;) - operator(}) - keyword(for)operator(()type(int) ident(i) operator(=) integer(4)operator(;) ident(i) operator(<) integer(8) operator(;)ident(i)operator(++)operator(\)) operator({) - ident(dumpValue)operator([)ident(i)operator(]) operator(=) operator(()type(byte)operator(\))operator(()ident(se) operator(&) hex(0xFF)operator(\))operator(;) - ident(se) operator(>)operator(>)operator(>=) integer(8)operator(;) - operator(}) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(obj)operator(.)ident(getRuntime)operator(()operator(\))operator(,) keyword(new) ident(ByteList)operator(()ident(dumpValue)operator(,)pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - comment(/* Time class methods */) - - directive(public) directive(static) ident(IRubyObject) ident(s_new)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyTime) ident(time) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) keyword(new) ident(DateTime)operator(()ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - ident(time)operator(.)ident(callInit)operator(()ident(args)operator(,)ident(block)operator(\))operator(;) - keyword(return) ident(time)operator(;) - operator(}) - - comment(/** - * @deprecated Use {@link #newInstance(ThreadContext, IRubyObject\)} - */) - annotation(@Deprecated) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(newInstance)operator(()ident(context)operator(,) ident(recv)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(now)delimiter(")>operator(,) ident(backtrace) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(newInstance)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) operator(()operator(()ident(RubyClass)operator(\)) ident(recv)operator(\))operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(obj)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseCallSites)operator(()operator(\))operator([)ident(RubyClass)operator(.)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(obj)operator(\))operator(;) - keyword(return) ident(obj)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(at)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(at)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - directive(final) ident(RubyTime) ident(time)operator(;) - - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyTime)operator(\)) operator({) - ident(RubyTime) ident(other) operator(=) operator(()ident(RubyTime)operator(\)) ident(arg)operator(;) - ident(time) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) ident(other)operator(.)ident(dt)operator(\))operator(;) - ident(time)operator(.)ident(setUSec)operator(()ident(other)operator(.)ident(getUSec)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(time) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) - keyword(new) ident(DateTime)operator(()integer(0L)operator(,) ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - - type(long) ident(seconds) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg)operator(\))operator(;) - type(long) ident(millisecs) operator(=) integer(0)operator(;) - type(long) ident(microsecs) operator(=) integer(0)operator(;) - - comment(// In the case of two arguments, MRI will discard the portion of) - comment(// the first argument after a decimal point (i.e., "floor"\).) - comment(// However in the case of a single argument, any portion after) - comment(// the decimal point is honored.) - keyword(if) operator(()ident(arg) keyword(instanceof) ident(RubyFloat)operator(\)) operator({) - type(double) ident(dbl) operator(=) operator(()operator(()ident(RubyFloat)operator(\)) ident(arg)operator(\))operator(.)ident(getDoubleValue)operator(()operator(\))operator(;) - type(long) ident(micro) operator(=) operator(()type(long)operator(\)) operator(()operator(()ident(dbl) operator(-) ident(seconds)operator(\)) operator(*) integer(1000000)operator(\))operator(;) - ident(millisecs) operator(=) ident(micro) operator(/) integer(1000)operator(;) - ident(microsecs) operator(=) ident(micro) operator(%) integer(1000)operator(;) - operator(}) - ident(time)operator(.)ident(setUSec)operator(()ident(microsecs)operator(\))operator(;) - ident(time)operator(.)ident(dt) operator(=) ident(time)operator(.)ident(dt)operator(.)ident(withMillis)operator(()ident(seconds) operator(*) integer(1000) operator(+) ident(millisecs)operator(\))operator(;) - operator(}) - - ident(time)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseCallSites)operator(()operator(\))operator([)ident(RubyClass)operator(.)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(time)operator(\))operator(;) - - keyword(return) ident(time)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(at)delimiter(")>operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(at)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(arg1)operator(,) ident(IRubyObject) ident(arg2)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(RubyTime) ident(time) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) - keyword(new) ident(DateTime)operator(()integer(0L)operator(,) ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(\))operator(\))operator(;) - - type(long) ident(seconds) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg1)operator(\))operator(;) - type(long) ident(millisecs) operator(=) integer(0)operator(;) - type(long) ident(microsecs) operator(=) integer(0)operator(;) - - type(long) ident(tmp) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(arg2)operator(\))operator(;) - ident(millisecs) operator(=) ident(tmp) operator(/) integer(1000)operator(;) - ident(microsecs) operator(=) ident(tmp) operator(%) integer(1000)operator(;) - - ident(time)operator(.)ident(setUSec)operator(()ident(microsecs)operator(\))operator(;) - ident(time)operator(.)ident(dt) operator(=) ident(time)operator(.)ident(dt)operator(.)ident(withMillis)operator(()ident(seconds) operator(*) integer(1000) operator(+) ident(millisecs)operator(\))operator(;) - - ident(time)operator(.)ident(getMetaClass)operator(()operator(\))operator(.)ident(getBaseCallSites)operator(()operator(\))operator([)ident(RubyClass)operator(.)ident(CS_IDX_INITIALIZE)operator(])operator(.)ident(call)operator(()ident(context)operator(,) ident(time)operator(\))operator(;) - - keyword(return) ident(time)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(local)delimiter(")>operator(,) string<delimiter(")content(mktime)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(9)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyTime) ident(new_local)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(createTime)operator(()ident(recv)operator(,) ident(args)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(utc)delimiter(")>operator(,) string<delimiter(")content(gm)delimiter(")>operator(})operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(9)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyTime) ident(new_utc)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(createTime)operator(()ident(recv)operator(,) ident(args)operator(,) pre_constant(true)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_load)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyTime) ident(load)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(from)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(s_mload)operator(()ident(recv)operator(,) operator(()ident(RubyTime)operator(\))operator(()operator(()operator(()ident(RubyClass)operator(\))ident(recv)operator(\))operator(.)ident(allocate)operator(()operator(\))operator(\))operator(,) ident(from)operator(\))operator(;) - operator(}) - - directive(protected) directive(static) ident(RubyTime) ident(s_mload)operator(()ident(IRubyObject) ident(recv)operator(,) ident(RubyTime) ident(time)operator(,) ident(IRubyObject) ident(from)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - - ident(DateTime) ident(dt) operator(=) keyword(new) ident(DateTime)operator(()ident(DateTimeZone)operator(.)ident(UTC)operator(\))operator(;) - - type(byte)type([]) ident(fromAsBytes) operator(=) pre_constant(null)operator(;) - ident(fromAsBytes) operator(=) ident(from)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getBytes)operator(()operator(\))operator(;) - keyword(if)operator(()ident(fromAsBytes)operator(.)ident(length) operator(!=) integer(8)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newTypeError)operator(()string<delimiter(")content(marshaled time format differ)delimiter(")>operator(\))operator(;) - operator(}) - type(int) ident(p)operator(=)integer(0)operator(;) - type(int) ident(s)operator(=)integer(0)operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) integer(4)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(p) operator(|=) operator(()operator(()type(int)operator(\))ident(fromAsBytes)operator([)ident(i)operator(]) operator(&) hex(0xFF)operator(\)) operator(<)operator(<) operator(()integer(8) operator(*) ident(i)operator(\))operator(;) - operator(}) - keyword(for) operator(()type(int) ident(i) operator(=) integer(4)operator(;) ident(i) operator(<) integer(8)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(s) operator(|=) operator(()operator(()type(int)operator(\))ident(fromAsBytes)operator([)ident(i)operator(]) operator(&) hex(0xFF)operator(\)) operator(<)operator(<) operator(()integer(8) operator(*) operator(()ident(i) operator(-) integer(4)operator(\))operator(\))operator(;) - operator(}) - keyword(if) operator(()operator(()ident(p) operator(&) operator(()integer(1)operator(<)operator(<)integer(31)operator(\))operator(\)) operator(==) integer(0)operator(\)) operator({) - ident(dt) operator(=) ident(dt)operator(.)ident(withMillis)operator(()ident(p) operator(*) integer(1000L) operator(+) ident(s)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(p) operator(&=) operator(~)operator(()integer(1)operator(<)operator(<)integer(31)operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withYear)operator(()operator(()operator(()ident(p) operator(>)operator(>)operator(>) integer(14)operator(\)) operator(&) hex(0xFFFF)operator(\)) operator(+) integer(1900)operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withMonthOfYear)operator(()operator(()operator(()ident(p) operator(>)operator(>)operator(>) integer(10)operator(\)) operator(&) hex(0xF)operator(\)) operator(+) integer(1)operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withDayOfMonth)operator(()operator(()operator(()ident(p) operator(>)operator(>)operator(>) integer(5)operator(\)) operator(&) hex(0x1F)operator(\))operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withHourOfDay)operator(()operator(()ident(p) operator(&) hex(0x1F)operator(\))operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withMinuteOfHour)operator(()operator(()operator(()ident(s) operator(>)operator(>)operator(>) integer(26)operator(\)) operator(&) hex(0x3F)operator(\))operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withSecondOfMinute)operator(()operator(()operator(()ident(s) operator(>)operator(>)operator(>) integer(20)operator(\)) operator(&) hex(0x3F)operator(\))operator(\))operator(;) - comment(// marsaling dumps usec, not msec) - ident(dt) operator(=) ident(dt)operator(.)ident(withMillisOfSecond)operator(()operator(()ident(s) operator(&) hex(0xFFFFF)operator(\)) operator(/) integer(1000)operator(\))operator(;) - ident(dt) operator(=) ident(dt)operator(.)ident(withZone)operator(()ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(\))operator(;) - ident(time)operator(.)ident(setUSec)operator(()operator(()ident(s) operator(&) hex(0xFFFFF)operator(\)) operator(%) integer(1000)operator(\))operator(;) - operator(}) - ident(time)operator(.)ident(setDateTime)operator(()ident(dt)operator(\))operator(;) - keyword(return) ident(time)operator(;) - operator(}) - - directive(private) directive(static) directive(final) pre_type(String)type([]) ident(MONTHS) operator(=) operator({)string<delimiter(")content(jan)delimiter(")>operator(,) string<delimiter(")content(feb)delimiter(")>operator(,) string<delimiter(")content(mar)delimiter(")>operator(,) string<delimiter(")content(apr)delimiter(")>operator(,) string<delimiter(")content(may)delimiter(")>operator(,) string<delimiter(")content(jun)delimiter(")>operator(,) - string<delimiter(")content(jul)delimiter(")>operator(,) string<delimiter(")content(aug)delimiter(")>operator(,) string<delimiter(")content(sep)delimiter(")>operator(,) string<delimiter(")content(oct)delimiter(")>operator(,) string<delimiter(")content(nov)delimiter(")>operator(,) string<delimiter(")content(dec)delimiter(")>operator(})operator(;) - - directive(private) directive(static) directive(final) pre_type(Map)operator(<)pre_type(String)operator(,) pre_type(Integer)operator(>) ident(MONTHS_MAP) operator(=) keyword(new) pre_type(HashMap)operator(<)pre_type(String)operator(,) pre_type(Integer)operator(>)operator(()operator(\))operator(;) - directive(static) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(i) operator(<) ident(MONTHS)operator(.)ident(length)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(MONTHS_MAP)operator(.)ident(put)operator(()ident(MONTHS)operator([)ident(i)operator(])operator(,) ident(i) operator(+) integer(1)operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) directive(final) type(int)type([]) ident(time_min) operator(=) operator({)integer(1)operator(,) integer(0)operator(,) integer(0)operator(,) integer(0)operator(,) pre_type(Integer)operator(.)ident(MIN_VALUE)operator(})operator(;) - directive(private) directive(static) directive(final) type(int)type([]) ident(time_max) operator(=) operator({)integer(31)operator(,) integer(23)operator(,) integer(59)operator(,) integer(60)operator(,) pre_type(Integer)operator(.)ident(MAX_VALUE)operator(})operator(;) - - directive(private) directive(static) directive(final) type(int) ident(ARG_SIZE) operator(=) integer(7)operator(;) - - directive(private) directive(static) ident(RubyTime) ident(createTime)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) type(boolean) ident(gmt)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - type(int) ident(len) operator(=) ident(ARG_SIZE)operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(10)operator(\)) operator({) - ident(args) operator(=) keyword(new) ident(IRubyObject)type([]) operator({) ident(args)operator([)integer(5)operator(])operator(,) ident(args)operator([)integer(4)operator(])operator(,) ident(args)operator([)integer(3)operator(])operator(,) ident(args)operator([)integer(2)operator(])operator(,) ident(args)operator([)integer(1)operator(])operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(runtime)operator(.)ident(getNil)operator(()operator(\)) operator(})operator(;) - operator(}) keyword(else) operator({) - comment(// MRI accepts additional wday argument which appears to be ignored.) - ident(len) operator(=) ident(args)operator(.)ident(length)operator(;) - - keyword(if) operator(()ident(len) operator(<) ident(ARG_SIZE)operator(\)) operator({) - ident(IRubyObject)type([]) ident(newArgs) operator(=) keyword(new) ident(IRubyObject)operator([)ident(ARG_SIZE)operator(])operator(;) - pre_type(System)operator(.)ident(arraycopy)operator(()ident(args)operator(,) integer(0)operator(,) ident(newArgs)operator(,) integer(0)operator(,) ident(args)operator(.)ident(length)operator(\))operator(;) - keyword(for) operator(()type(int) ident(i) operator(=) ident(len)operator(;) ident(i) operator(<) ident(ARG_SIZE)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(newArgs)operator([)ident(i)operator(]) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - ident(args) operator(=) ident(newArgs)operator(;) - ident(len) operator(=) ident(ARG_SIZE)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()ident(args)operator([)integer(0)operator(]) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(args)operator([)integer(0)operator(]) operator(=) ident(RubyNumeric)operator(.)ident(str2inum)operator(()ident(runtime)operator(,) operator(()ident(RubyString)operator(\)) ident(args)operator([)integer(0)operator(])operator(,) integer(10)operator(,) pre_constant(false)operator(\))operator(;) - operator(}) - - type(int) ident(year) operator(=) operator(()type(int)operator(\)) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - type(int) ident(month) operator(=) integer(1)operator(;) - - keyword(if) operator(()ident(len) operator(>) integer(1)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(tmp) operator(=) ident(args)operator([)integer(1)operator(])operator(.)ident(checkStringType)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(tmp)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - pre_type(String) ident(monthString) operator(=) ident(tmp)operator(.)ident(toString)operator(()operator(\))operator(.)ident(toLowerCase)operator(()operator(\))operator(;) - pre_type(Integer) ident(monthInt) operator(=) ident(MONTHS_MAP)operator(.)ident(get)operator(()ident(monthString)operator(\))operator(;) - - keyword(if) operator(()ident(monthInt) operator(!=) pre_constant(null)operator(\)) operator({) - ident(month) operator(=) ident(monthInt)operator(;) - operator(}) keyword(else) operator({) - keyword(try) operator({) - ident(month) operator(=) pre_type(Integer)operator(.)ident(parseInt)operator(()ident(monthString)operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(NumberFormatException) ident(nfExcptn)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(Argument out of range.)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - operator(}) keyword(else) operator({) - ident(month) operator(=) operator(()type(int)operator(\)) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(if) operator(()integer(1) operator(>) ident(month) operator(||) ident(month) operator(>) integer(12)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(Argument out of range: for month: )delimiter(")> operator(+) ident(month)operator(\))operator(;) - operator(}) - operator(}) - - type(int)type([]) ident(int_args) operator(=) operator({) integer(1)operator(,) integer(0)operator(,) integer(0)operator(,) integer(0)operator(,) integer(0)operator(,) integer(0) operator(})operator(;) - - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(;) ident(int_args)operator(.)ident(length) operator(>=) ident(i) operator(+) integer(2)operator(;) ident(i)operator(++)operator(\)) operator({) - keyword(if) operator(()operator(!)ident(args)operator([)ident(i) operator(+) integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(if) operator(()operator(!)operator(()ident(args)operator([)ident(i) operator(+) integer(2)operator(]) keyword(instanceof) ident(RubyNumeric)operator(\))operator(\)) operator({) - ident(args)operator([)ident(i) operator(+) integer(2)operator(]) operator(=) ident(args)operator([)ident(i) operator(+) integer(2)operator(])operator(.)ident(callMethod)operator(() - ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) string<delimiter(")content(to_i)delimiter(")>operator(\))operator(;) - operator(}) - - type(long) ident(value) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)ident(i) operator(+) integer(2)operator(])operator(\))operator(;) - keyword(if) operator(()ident(time_min)operator([)ident(i)operator(]) operator(>) ident(value) operator(||) ident(value) operator(>) ident(time_max)operator([)ident(i)operator(])operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(argument out of range.)delimiter(")>operator(\))operator(;) - operator(}) - ident(int_args)operator([)ident(i)operator(]) operator(=) operator(()type(int)operator(\)) ident(value)operator(;) - operator(}) - operator(}) - - keyword(if) operator(()integer(0) operator(<=) ident(year) operator(&&) ident(year) operator(<) integer(39)operator(\)) operator({) - ident(year) operator(+=) integer(2000)operator(;) - operator(}) keyword(else) keyword(if) operator(()integer(69) operator(<=) ident(year) operator(&&) ident(year) operator(<) integer(139)operator(\)) operator({) - ident(year) operator(+=) integer(1900)operator(;) - operator(}) - - ident(DateTimeZone) ident(dtz)operator(;) - keyword(if) operator(()ident(gmt)operator(\)) operator({) - ident(dtz) operator(=) ident(DateTimeZone)operator(.)ident(UTC)operator(;) - operator(}) keyword(else) operator({) - ident(dtz) operator(=) ident(getLocalTimeZone)operator(()ident(runtime)operator(\))operator(;) - operator(}) - - ident(DateTime) ident(dt)operator(;) - comment(// set up with min values and then add to allow rolling over) - keyword(try) operator({) - ident(dt) operator(=) keyword(new) ident(DateTime)operator(()ident(year)operator(,) integer(1)operator(,) integer(1)operator(,) integer(0)operator(,) integer(0) operator(,) integer(0)operator(,) integer(0)operator(,) ident(dtz)operator(\))operator(;) - - ident(dt) operator(=) ident(dt)operator(.)ident(plusMonths)operator(()ident(month) operator(-) integer(1)operator(\)) - operator(.)ident(plusDays)operator(()ident(int_args)operator([)integer(0)operator(]) operator(-) integer(1)operator(\)) - operator(.)ident(plusHours)operator(()ident(int_args)operator([)integer(1)operator(])operator(\)) - operator(.)ident(plusMinutes)operator(()ident(int_args)operator([)integer(2)operator(])operator(\)) - operator(.)ident(plusSeconds)operator(()ident(int_args)operator([)integer(3)operator(])operator(\))operator(;) - operator(}) keyword(catch) operator(()ident(org)operator(.)ident(joda)operator(.)ident(time)operator(.)ident(IllegalFieldValueException) ident(e)operator(\)) operator({) - keyword(throw) ident(runtime)operator(.)ident(newArgumentError)operator(()string<delimiter(")content(time out of range)delimiter(")>operator(\))operator(;) - operator(}) - - ident(RubyTime) ident(time) operator(=) keyword(new) ident(RubyTime)operator(()ident(runtime)operator(,) operator(()ident(RubyClass)operator(\)) ident(recv)operator(,) ident(dt)operator(\))operator(;) - comment(// Ignores usec if 8 args (for compatibility with parsedate\) or if not supplied.) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(8) operator(&&) operator(!)ident(args)operator([)integer(6)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - type(int) ident(usec) operator(=) ident(int_args)operator([)integer(4)operator(]) operator(%) integer(1000)operator(;) - type(int) ident(msec) operator(=) ident(int_args)operator([)integer(4)operator(]) operator(/) integer(1000)operator(;) - - keyword(if) operator(()ident(int_args)operator([)integer(4)operator(]) operator(<) integer(0)operator(\)) operator({) - ident(msec) operator(-=) integer(1)operator(;) - ident(usec) operator(+=) integer(1000)operator(;) - operator(}) - ident(time)operator(.)ident(dt) operator(=) ident(dt)operator(.)ident(withMillis)operator(()ident(dt)operator(.)ident(getMillis)operator(()operator(\)) operator(+) ident(msec)operator(\))operator(;) - ident(time)operator(.)ident(setUSec)operator(()ident(usec)operator(\))operator(;) - operator(}) - - ident(time)operator(.)ident(callInit)operator(()ident(IRubyObject)operator(.)ident(NULL_ARRAY)operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - keyword(return) ident(time)operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.internal.runtime.methods.DynamicMethod)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -comment(/** - * - * Note: This was renamed from UnboundMethod.java - * - * @author jpetersen - */) -annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(UnboundMethod)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Method)delimiter(")>operator(\)) -directive(public) type(class) class(RubyUnboundMethod) directive(extends) ident(RubyMethod) operator({) - directive(protected) ident(RubyUnboundMethod)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getUnboundMethod)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(RubyUnboundMethod) ident(newUnboundMethod)operator(() - ident(RubyModule) ident(implementationModule)operator(,) - pre_type(String) ident(methodName)operator(,) - ident(RubyModule) ident(originModule)operator(,) - pre_type(String) ident(originName)operator(,) - ident(DynamicMethod) ident(method)operator(\)) operator({) - ident(RubyUnboundMethod) ident(newMethod) operator(=) keyword(new) ident(RubyUnboundMethod)operator(()ident(implementationModule)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(;) - - ident(newMethod)operator(.)ident(implementationModule) operator(=) ident(implementationModule)operator(;) - ident(newMethod)operator(.)ident(methodName) operator(=) ident(methodName)operator(;) - ident(newMethod)operator(.)ident(originModule) operator(=) ident(originModule)operator(;) - ident(newMethod)operator(.)ident(originName) operator(=) ident(originName)operator(;) - ident(newMethod)operator(.)ident(method) operator(=) ident(method)operator(;) - - keyword(return) ident(newMethod)operator(;) - operator(}) - - directive(public) directive(static) ident(RubyClass) ident(defineUnboundMethodClass)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - comment(// TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415) - ident(RubyClass) ident(newClass) operator(=) - ident(runtime)operator(.)ident(defineClass)operator(()string<delimiter(")content(UnboundMethod)delimiter(")>operator(,) ident(runtime)operator(.)ident(getMethod)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(runtime)operator(.)ident(setUnboundMethod)operator(()ident(newClass)operator(\))operator(;) - - ident(newClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyUnboundMethod)operator(.)ident(class)operator(\))operator(;) - - keyword(return) ident(newClass)operator(;) - operator(}) - - comment(/** - * @see org.jruby.RubyMethod#call(IRubyObject[]\) - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) operator({)string<delimiter(")content(call)delimiter(")>operator(,) string<delimiter(")content([])delimiter(")>operator(})operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(call)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(you cannot call unbound method; bind first)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.RubyMethod#unbind(\) - */) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(unbind)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - annotation(@Override) - directive(public) ident(RubyUnboundMethod) ident(unbind)operator(()ident(Block) ident(block)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(bind)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(RubyMethod) ident(bind)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(aReceiver)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(receiverClass) operator(=) ident(aReceiver)operator(.)ident(getMetaClass)operator(()operator(\))operator(;) - - keyword(if) operator(()operator(!)ident(originModule)operator(.)ident(isInstance)operator(()ident(aReceiver)operator(\))operator(\)) operator({) - keyword(if) operator(()ident(originModule) keyword(instanceof) ident(MetaClass)operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(singleton method called for a different object)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(receiverClass) keyword(instanceof) ident(MetaClass) operator(&&) ident(receiverClass)operator(.)ident(getMethods)operator(()operator(\))operator(.)ident(containsKey)operator(()ident(originName)operator(\))operator(\)) operator({) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(method `)delimiter(")> operator(+) ident(originName) operator(+) string<delimiter(")content(' overridden)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(() - operator(!)operator(()ident(originModule)operator(.)ident(isModule)operator(()operator(\)) operator(?) ident(originModule)operator(.)ident(isInstance)operator(()ident(aReceiver)operator(\)) operator(:) ident(aReceiver)operator(.)ident(getType)operator(()operator(\)) operator(==) ident(originModule)operator(\))operator(\)) operator({) - comment(// FIX replace type(\) == ... with isInstanceOf(...\)) - keyword(throw) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(bind argument must be an instance of )delimiter(")> operator(+) ident(originModule)operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(RubyMethod)operator(.)ident(newMethod)operator(()ident(implementationModule)operator(,) ident(methodName)operator(,) ident(receiverClass)operator(,) ident(originName)operator(,) ident(method)operator(,) ident(aReceiver)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(clone)delimiter(")>operator(\)) - annotation(@Override) - directive(public) ident(RubyMethod) ident(rbClone)operator(()operator(\)) operator({) - keyword(return) ident(newUnboundMethod)operator(()ident(implementationModule)operator(,) ident(methodName)operator(,) ident(originModule)operator(,) ident(originName)operator(,) ident(method)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_proc)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - annotation(@Override) - directive(public) ident(IRubyObject) ident(to_proc)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) local_variable(super)operator(.)ident(to_proc)operator(()ident(context)operator(,) ident(unusedBlock)operator(\))operator(;) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2007 Ola Bini <ola.bini@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.IOException)operator(;) - -keyword(import) include(java.util.Iterator)operator(;) -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.Map)operator(;) - -keyword(import) include(java.util.regex.Pattern)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(org.jruby.javasupport.JavaEmbedUtils)operator(;) - -keyword(import) include(org.jruby.javasupport.JavaUtil)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.MethodIndex)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) - -keyword(import) include(org.jruby.yaml.JRubyRepresenter)operator(;) -keyword(import) include(org.jruby.yaml.JRubyConstructor)operator(;) -keyword(import) include(org.jruby.yaml.JRubySerializer)operator(;) -keyword(import) include(org.jruby.util.IOInputStream)operator(;) -keyword(import) include(org.jruby.util.IOOutputStream)operator(;) - -keyword(import) include(org.jvyamlb.Representer)operator(;) -keyword(import) include(org.jvyamlb.Constructor)operator(;) -keyword(import) include(org.jvyamlb.ParserImpl)operator(;) -keyword(import) include(org.jvyamlb.PositioningParserImpl)operator(;) -keyword(import) include(org.jvyamlb.Scanner)operator(;) -keyword(import) include(org.jvyamlb.ScannerImpl)operator(;) -keyword(import) include(org.jvyamlb.Composer)operator(;) -keyword(import) include(org.jvyamlb.ComposerImpl)operator(;) -keyword(import) include(org.jvyamlb.PositioningScannerImpl)operator(;) -keyword(import) include(org.jvyamlb.PositioningComposerImpl)operator(;) -keyword(import) include(org.jvyamlb.Serializer)operator(;) -keyword(import) include(org.jvyamlb.ResolverImpl)operator(;) -keyword(import) include(org.jvyamlb.EmitterImpl)operator(;) -keyword(import) include(org.jvyamlb.exceptions.YAMLException)operator(;) -keyword(import) include(org.jvyamlb.YAMLConfig)operator(;) -keyword(import) include(org.jvyamlb.YAML)operator(;) -keyword(import) include(org.jvyamlb.PositioningScanner)operator(;) -keyword(import) include(org.jvyamlb.Positionable)operator(;) -keyword(import) include(org.jvyamlb.Position)operator(;) - -comment(/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */) -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(YAML)delimiter(")>operator(\)) -directive(public) type(class) class(RubyYAML) operator({) - directive(public) directive(static) ident(RubyModule) ident(createYAMLModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(result) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(YAML)delimiter(")>operator(\))operator(;) - - ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(require)delimiter(")>operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(stringio)delimiter(")>operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyYAML)operator(.)ident(class)operator(\))operator(;) - - ident(RubyClass) ident(obj) operator(=) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(;) - ident(RubyClass) ident(clazz) operator(=) ident(runtime)operator(.)ident(getClassClass)operator(()operator(\))operator(;) - ident(RubyClass) ident(hash) operator(=) ident(runtime)operator(.)ident(getHash)operator(()operator(\))operator(;) - ident(RubyClass) ident(array) operator(=) ident(runtime)operator(.)ident(getArray)operator(()operator(\))operator(;) - ident(RubyClass) ident(struct) operator(=) ident(runtime)operator(.)ident(getStructClass)operator(()operator(\))operator(;) - ident(RubyClass) ident(exception) operator(=) ident(runtime)operator(.)ident(getException)operator(()operator(\))operator(;) - ident(RubyClass) ident(string) operator(=) ident(runtime)operator(.)ident(getString)operator(()operator(\))operator(;) - ident(RubyClass) ident(symbol) operator(=) ident(runtime)operator(.)ident(getSymbol)operator(()operator(\))operator(;) - ident(RubyClass) ident(range) operator(=) ident(runtime)operator(.)ident(getRange)operator(()operator(\))operator(;) - ident(RubyClass) ident(regexp) operator(=) ident(runtime)operator(.)ident(getRegexp)operator(()operator(\))operator(;) - ident(RubyClass) ident(time) operator(=) ident(runtime)operator(.)ident(getTime)operator(()operator(\))operator(;) - ident(RubyClass) ident(date) operator(=) ident(runtime)operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Date)delimiter(")>operator(\))operator(;) - ident(RubyClass) ident(fixnum) operator(=) ident(runtime)operator(.)ident(getFixnum)operator(()operator(\))operator(;) - ident(RubyClass) ident(bignum) operator(=) ident(runtime)operator(.)ident(getBignum)operator(()operator(\))operator(;) - ident(RubyClass) ident(flt) operator(=) ident(runtime)operator(.)ident(getFloat)operator(()operator(\))operator(;) - ident(RubyClass) ident(trueClass) operator(=) ident(runtime)operator(.)ident(getTrueClass)operator(()operator(\))operator(;) - ident(RubyClass) ident(falseClass) operator(=) ident(runtime)operator(.)ident(getFalseClass)operator(()operator(\))operator(;) - ident(RubyClass) ident(nilClass) operator(=) ident(runtime)operator(.)ident(getNilClass)operator(()operator(\))operator(;) - - ident(clazz)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLClassMethods)operator(.)ident(class)operator(\))operator(;) - - ident(obj)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLObjectMethods)operator(.)ident(class)operator(\))operator(;) - - ident(hash)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLHashMethods)operator(.)ident(class)operator(\))operator(;) - - ident(array)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLArrayMethods)operator(.)ident(class)operator(\))operator(;) - - ident(struct)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLStructMethods)operator(.)ident(class)operator(\))operator(;) - - ident(exception)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLExceptionMethods)operator(.)ident(class)operator(\))operator(;) - - ident(string)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLStringMethods)operator(.)ident(class)operator(\))operator(;) - - ident(symbol)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLSymbolMethods)operator(.)ident(class)operator(\))operator(;) - - ident(range)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLRangeMethods)operator(.)ident(class)operator(\))operator(;) - - ident(regexp)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLRegexpMethods)operator(.)ident(class)operator(\))operator(;) - - ident(time)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLTimeMethods)operator(.)ident(class)operator(\))operator(;) - - ident(date)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLDateMethods)operator(.)ident(class)operator(\))operator(;) - - ident(bignum)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLNumericMethods)operator(.)ident(class)operator(\))operator(;) - - ident(fixnum)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLNumericMethods)operator(.)ident(class)operator(\))operator(;) - - ident(flt)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLNumericMethods)operator(.)ident(class)operator(\))operator(;) - - ident(trueClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLTrueMethods)operator(.)ident(class)operator(\))operator(;) - - ident(falseClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLFalseMethods)operator(.)ident(class)operator(\))operator(;) - - ident(nilClass)operator(.)ident(defineAnnotatedMethods)operator(()ident(YAMLNilMethods)operator(.)ident(class)operator(\))operator(;) - - ident(runtime)operator(.)ident(setObjectToYamlMethod)operator(()ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(searchMethod)operator(()string<delimiter(")content(to_yaml)delimiter(")>operator(\))operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dump)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dump)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(IRubyObject) ident(obj) operator(=) ident(args)operator([)integer(0)operator(])operator(;) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(val) operator(=) ident(runtime)operator(.)ident(newArray)operator(()ident(obj)operator(\))operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length)operator(>)integer(1)operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(self)operator(,)string<delimiter(")content(dump_all)delimiter(")>operator(,) ident(val)operator(,) ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(self)operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(dump_all)delimiter(")>operator(,) ident(val)operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dump_all)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dump_all)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(RubyArray) ident(objs) operator(=) operator(()ident(RubyArray)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - ident(IRubyObject) ident(io) operator(=) pre_constant(null)operator(;) - ident(IRubyObject) ident(io2) operator(=) pre_constant(null)operator(;) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(2) operator(&&) ident(args)operator([)integer(1)operator(]) operator(!=) pre_constant(null) operator(&&) operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(io) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - operator(}) - ident(YAMLConfig) ident(cfg) operator(=) ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(;) - ident(IOOutputStream) ident(iox) operator(=) pre_constant(null)operator(;) - keyword(if)operator(()pre_constant(null) operator(==) ident(io)operator(\)) operator({) - ident(io2) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(StringIO)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - ident(iox) operator(=) keyword(new) ident(IOOutputStream)operator(()ident(io2)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(iox) operator(=) keyword(new) ident(IOOutputStream)operator(()ident(io)operator(\))operator(;) - operator(}) - ident(Serializer) ident(ser) operator(=) keyword(new) ident(JRubySerializer)operator(()keyword(new) ident(EmitterImpl)operator(()ident(iox)operator(,)ident(cfg)operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(,)ident(cfg)operator(\))operator(;) - keyword(try) operator({) - ident(ser)operator(.)ident(open)operator(()operator(\))operator(;) - ident(Representer) ident(r) operator(=) keyword(new) ident(JRubyRepresenter)operator(()ident(ser)operator(,) ident(cfg)operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) ident(objs)operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;)ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(r)operator(.)ident(represent)operator(()ident(iter)operator(.)ident(next)operator(()operator(\))operator(\))operator(;) - operator(}) - ident(ser)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newIOErrorFromException)operator(()ident(e)operator(\))operator(;) - operator(}) - keyword(if)operator(()pre_constant(null) operator(==) ident(io)operator(\)) operator({) - ident(io2)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(rewind)delimiter(")>operator(\))operator(;) - keyword(return) ident(io2)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(read)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(return) ident(io)operator(;) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(_parse_internal)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(parse_internal)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(boolean) ident(debug) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(check_yaml_port)operator(()ident(arg)operator(\))operator(;) - pre_type(Scanner) ident(scn) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - keyword(if)operator(()ident(io) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) - ident(Composer) ident(ctor) operator(=) - ident(debug) operator(?) - keyword(new) ident(PositioningComposerImpl)operator(()keyword(new) ident(PositioningParserImpl)operator(()operator(()ident(PositioningScanner)operator(\))ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\)) operator(:) - keyword(new) ident(ComposerImpl)operator(()keyword(new) ident(ParserImpl)operator(()ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\)) - operator(;) - keyword(if)operator(()ident(ctor)operator(.)ident(checkNode)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(JavaEmbedUtils)operator(.)ident(javaToRuby)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(ctor)operator(.)ident(getNode)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(YAMLException) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - pre_type(Position)operator(.)ident(Range) ident(range) operator(=) operator(()operator(()ident(Positionable)operator(\))ident(e)operator(\))operator(.)ident(getRange)operator(()operator(\))operator(;) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error on )delimiter(")> operator(+) ident(range)operator(.)ident(start) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(range)operator(.)ident(end) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error:)delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(load)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(boolean) ident(debug) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(check_yaml_port)operator(()ident(arg)operator(\))operator(;) - pre_type(Scanner) ident(scn) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - keyword(if)operator(()ident(io) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) - pre_type(Constructor) ident(ctor) operator(=) - ident(debug) operator(?) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(PositioningComposerImpl)operator(()keyword(new) ident(PositioningParserImpl)operator(()operator(()ident(PositioningScanner)operator(\))ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) operator(:) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(ComposerImpl)operator(()keyword(new) ident(ParserImpl)operator(()ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) - operator(;) - keyword(if)operator(()ident(ctor)operator(.)ident(checkData)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(JavaEmbedUtils)operator(.)ident(javaToRuby)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(ctor)operator(.)ident(getData)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(YAMLException) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - pre_type(Position)operator(.)ident(Range) ident(range) operator(=) operator(()operator(()ident(Positionable)operator(\))ident(e)operator(\))operator(.)ident(getRange)operator(()operator(\))operator(;) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error on )delimiter(")> operator(+) ident(range)operator(.)ident(start) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(range)operator(.)ident(end) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error:)delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(load_file)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load_file)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,)string<delimiter(")content(open)delimiter(")>operator(,) ident(arg)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(r)delimiter(")>operator(\))operator(\))operator(;) - ident(IRubyObject) ident(val) operator(=) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(load)delimiter(")>operator(,) ident(io)operator(\))operator(;) - ident(io)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(close)delimiter(")>operator(\))operator(;) - keyword(return) ident(val)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_document)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(each_document)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(boolean) ident(debug) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(arg)operator(;) - pre_type(Scanner) ident(scn) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - keyword(if)operator(()ident(io) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) - pre_type(Constructor) ident(ctor) operator(=) - ident(debug) operator(?) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(PositioningComposerImpl)operator(()keyword(new) ident(PositioningParserImpl)operator(()operator(()ident(PositioningScanner)operator(\))ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) operator(:) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(ComposerImpl)operator(()keyword(new) ident(ParserImpl)operator(()ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) - operator(;) - keyword(while)operator(()ident(ctor)operator(.)ident(checkData)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(JavaEmbedUtils)operator(.)ident(javaToRuby)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(ctor)operator(.)ident(getData)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(YAMLException) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - pre_type(Position)operator(.)ident(Range) ident(range) operator(=) operator(()operator(()ident(Positionable)operator(\))ident(e)operator(\))operator(.)ident(getRange)operator(()operator(\))operator(;) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error on )delimiter(")> operator(+) ident(range)operator(.)ident(start) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(range)operator(.)ident(end) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error:)delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(load_documents)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load_documents)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(,) ident(Block) ident(block)operator(\)) operator({) - type(boolean) ident(debug) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(check_yaml_port)operator(()ident(arg)operator(\))operator(;) - pre_type(Scanner) ident(scn) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - keyword(if)operator(()ident(io) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) - pre_type(Constructor) ident(ctor) operator(=) - ident(debug) operator(?) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(PositioningComposerImpl)operator(()keyword(new) ident(PositioningParserImpl)operator(()operator(()ident(PositioningScanner)operator(\))ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) operator(:) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(ComposerImpl)operator(()keyword(new) ident(ParserImpl)operator(()ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) - operator(;) - keyword(while)operator(()ident(ctor)operator(.)ident(checkData)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(JavaEmbedUtils)operator(.)ident(javaToRuby)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(ctor)operator(.)ident(getData)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(catch)operator(()ident(YAMLException) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - pre_type(Position)operator(.)ident(Range) ident(range) operator(=) operator(()operator(()ident(Positionable)operator(\))ident(e)operator(\))operator(.)ident(getRange)operator(()operator(\))operator(;) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error on )delimiter(")> operator(+) ident(range)operator(.)ident(start) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(range)operator(.)ident(end) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error:)delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(load_stream)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(load_stream)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - type(boolean) ident(debug) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(d) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(arg)operator(;) - pre_type(Scanner) ident(scn) operator(=) pre_constant(null)operator(;) - keyword(try) operator({) - keyword(if)operator(()ident(io) keyword(instanceof) ident(RubyString)operator(\)) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()operator(()operator(()ident(RubyString)operator(\))ident(io)operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(scn) operator(=) ident(debug) operator(?) keyword(new) ident(PositioningScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\)) operator(:) keyword(new) ident(ScannerImpl)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) - pre_type(Constructor) ident(ctor) operator(=) - ident(debug) operator(?) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(PositioningComposerImpl)operator(()keyword(new) ident(PositioningParserImpl)operator(()operator(()ident(PositioningScanner)operator(\))ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) operator(:) - keyword(new) ident(JRubyConstructor)operator(()ident(self)operator(,) keyword(new) ident(ComposerImpl)operator(()keyword(new) ident(ParserImpl)operator(()ident(scn)operator(,)ident(YAML)operator(.)ident(config)operator(()operator(\))operator(.)ident(version)operator(()string<delimiter(")content(1.0)delimiter(")>operator(\))operator(\))operator(,)keyword(new) ident(ResolverImpl)operator(()operator(\))operator(\))operator(\)) - operator(;) - keyword(while)operator(()ident(ctor)operator(.)ident(checkData)operator(()operator(\))operator(\)) operator({) - keyword(if)operator(()ident(d)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(d) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetModule)operator(()string<delimiter(")content(YAML)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Stream)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(new)delimiter(")>operator(,) ident(d)operator(\))operator(;) - operator(}) - ident(d)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(add)delimiter(")>operator(,) ident(JavaEmbedUtils)operator(.)ident(javaToRuby)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(ctor)operator(.)ident(getData)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(d)operator(;) - operator(}) keyword(catch)operator(()ident(YAMLException) ident(e)operator(\)) operator({) - keyword(if)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getDebug)operator(()operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - pre_type(Position)operator(.)ident(Range) ident(range) operator(=) operator(()operator(()ident(Positionable)operator(\))ident(e)operator(\))operator(.)ident(getRange)operator(()operator(\))operator(;) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error on )delimiter(")> operator(+) ident(range)operator(.)ident(start) operator(+) string<delimiter(")content(:)delimiter(")> operator(+) ident(range)operator(.)ident(end) operator(+) string<delimiter(")content(: )delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(syntax error:)delimiter(")> operator(+) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(dump_stream)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(dump_stream)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(stream) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetModule)operator(()string<delimiter(")content(YAML)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Stream)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(,)ident(j)operator(=)ident(args)operator(.)ident(length)operator(;)ident(i)operator(<)ident(j)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(stream)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(add)delimiter(")>operator(,) ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(stream)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(emit)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(quick_emit_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(quick_emit_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(block)operator(.)ident(yield)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - -comment(// @JRubyMethod(name = "quick_emit_node", rest = true, module = true, visibility = Visibility.PRIVATE\)) - directive(public) directive(static) ident(IRubyObject) ident(quick_emit)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - comment(// prepares IO port type for load (ported from ext/syck/rubyext.c\)) - directive(private) directive(static) ident(IRubyObject) ident(check_yaml_port)operator(()ident(IRubyObject) ident(port)operator(\)) operator({) - keyword(if) operator(()ident(port) keyword(instanceof) ident(RubyString)operator(\)) operator({) - comment(// OK) - operator(}) - keyword(else) keyword(if) operator(()ident(port)operator(.)ident(respondsTo)operator(()string<delimiter(")content(read)delimiter(")>operator(\))operator(\)) operator({) - keyword(if) operator(()ident(port)operator(.)ident(respondsTo)operator(()string<delimiter(")content(binmode)delimiter(")>operator(\))operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(port)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(port)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(binmode)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - keyword(else) operator({) - keyword(throw) ident(port)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(instance of IO needed)delimiter(")>operator(\))operator(;) - operator(}) - keyword(return) ident(port)operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Hash)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLHashMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(hash_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(ThreadContext) ident(context) operator(=) ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Object)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLObjectMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_to_yaml_properties)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(instance_variables)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(sort)delimiter(")>operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_to_yaml_style)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(Map) ident(mep) operator(=) operator(()pre_type(Map)operator(\))operator(()keyword(new) ident(RubyHash)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - ident(RubyArray) ident(props) operator(=) operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) ident(props)operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(String) ident(m) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(mep)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_to_yaml)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetModule)operator(()string<delimiter(")content(YAML)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(dump)delimiter(")>operator(,) ident(self)operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(obj_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(!ruby/object:)delimiter(")> operator(+) ident(self)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Class)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLClassMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(class_to_yaml)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) operator({) - keyword(throw) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newTypeError)operator(()string<delimiter(")content(can't dump anonymous class )delimiter(")> operator(+) ident(self)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Array)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLArrayMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(array_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(seq)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Struct)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLStructMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(struct_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(Map) ident(mep) operator(=) operator(()pre_type(Map)operator(\))operator(()keyword(new) ident(RubyHash)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(members)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;)ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - ident(IRubyObject) ident(key) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(key)operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)ident(MethodIndex)operator(.)ident(AREF)operator(,) string<delimiter(")content([])delimiter(")>operator(,) ident(key)operator(\))operator(\))operator(;) - operator(}) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(String) ident(m) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(mep)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(struct_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(!ruby/struct:)delimiter(")> operator(+) ident(self)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Exception)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLExceptionMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exception_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(Map) ident(mep) operator(=) operator(()pre_type(Map)operator(\))operator(()keyword(new) ident(RubyHash)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(message)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(message)delimiter(")>operator(\))operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(String) ident(m) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(mep)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(exception_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(!ruby/exception:)delimiter(")> operator(+) ident(self)operator(.)ident(getType)operator(()operator(\))operator(.)ident(getName)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) - - directive(private) directive(static) directive(final) pre_type(Pattern) ident(AFTER_NEWLINE) operator(=) pre_type(Pattern)operator(.)ident(compile)operator(()string<delimiter(")char(\\n)content(.+)delimiter(")>operator(,) pre_type(Pattern)operator(.)ident(DOTALL)operator(\))operator(;) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(String)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLStringMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(is_complex_yaml?)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(string_is_complex)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\)) operator(||) - operator(()operator(()pre_type(List)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(isEmpty)operator(()operator(\)) operator(||) - ident(AFTER_NEWLINE)operator(.)ident(matcher)operator(()ident(self)operator(.)ident(toString)operator(()operator(\))operator(\))operator(.)ident(find)operator(()operator(\))operator(\)) operator(?) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(is_binary_data?)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(string_is_binary)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(if)operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(EMPTY_P)operator(,) string<delimiter(")content(empty?)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(self)operator(.)ident(toString)operator(()operator(\))operator(.)ident(indexOf)operator(()string<delimiter(')content(\\0)delimiter(')>operator(\)) operator(!=) operator(-)integer(1) operator(?) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - directive(private) directive(static) ident(JRubyRepresenter) ident(into)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(IRubyObject) ident(jobj) operator(=) ident(arg)operator(.)ident(getInstanceVariables)operator(()operator(\))operator(.)ident(fastGetInstanceVariable)operator(()string<delimiter(")content(@java_object)delimiter(")>operator(\))operator(;) - keyword(if)operator(()ident(jobj) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(return) operator(()ident(JRubyRepresenter)operator(\))operator(()operator(()operator(()ident(org)operator(.)ident(jruby)operator(.)ident(javasupport)operator(.)ident(JavaObject)operator(\))ident(jobj)operator(\))operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - keyword(return) pre_constant(null)operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(string_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(Ruby) ident(rt) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - keyword(if)operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(is_binary_data?)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(rt)operator(.)ident(newString)operator(()string<delimiter(")content(tag:yaml.org,2002:binary)delimiter(")>operator(\))operator(,) ident(rt)operator(.)ident(newArray)operator(()ident(self)operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(pack)delimiter(")>operator(,) ident(rt)operator(.)ident(newString)operator(()string<delimiter(")content(m)delimiter(")>operator(\))operator(\))operator(,) ident(rt)operator(.)ident(newString)operator(()string<delimiter(")content(|)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(()operator(()pre_type(List)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(isEmpty)operator(()operator(\))operator(\)) operator({) - ident(JRubyRepresenter) ident(rep) operator(=) ident(into)operator(()ident(arg)operator(\))operator(;) - keyword(if)operator(()ident(rep) operator(!=) pre_constant(null)operator(\)) operator({) - keyword(try) operator({) - keyword(return) ident(JavaUtil)operator(.)ident(convertJavaToRuby)operator(()ident(rt)operator(,)ident(rep)operator(.)ident(scalar)operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(,)ident(self)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(,)ident(self)operator(.)ident(toString)operator(()operator(\))operator(.)ident(startsWith)operator(()string<delimiter(")content(:)delimiter(")>operator(\)) operator(?) string<delimiter(")char(\\")delimiter(")> operator(:) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) keyword(catch)operator(()exception(IOException) ident(e)operator(\)) operator({) - keyword(throw) ident(rt)operator(.)ident(newIOErrorFromException)operator(()ident(e)operator(\))operator(;) - operator(}) - operator(}) keyword(else) operator({) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(,) ident(self)operator(.)ident(toString)operator(()operator(\))operator(.)ident(startsWith)operator(()string<delimiter(")content(:)delimiter(")>operator(\)) operator(?) ident(rt)operator(.)ident(newString)operator(()string<delimiter(")char(\\")delimiter(")>operator(\)) operator(:) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - pre_type(Map) ident(mep) operator(=) operator(()pre_type(Map)operator(\))operator(()keyword(new) ident(RubyHash)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(str)delimiter(")>operator(\))operator(,)ident(rt)operator(.)ident(newString)operator(()ident(self)operator(.)ident(toString)operator(()operator(\))operator(\))operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(String) ident(m) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(mep)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Symbol)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLSymbolMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(symbol_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(symbol_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(tag:yaml.org,2002:str)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Numeric)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLNumericMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(numeric_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(String) ident(val) operator(=) ident(self)operator(.)ident(toString)operator(()operator(\))operator(;) - keyword(if)operator(()string<delimiter(")content(Infinity)delimiter(")>operator(.)ident(equals)operator(()ident(val)operator(\))operator(\)) operator({) - ident(val) operator(=) string<delimiter(")content(.Inf)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if)operator(()string<delimiter(")content(-Infinity)delimiter(")>operator(.)ident(equals)operator(()ident(val)operator(\))operator(\)) operator({) - ident(val) operator(=) string<delimiter(")content(-.Inf)delimiter(")>operator(;) - operator(}) keyword(else) keyword(if)operator(()string<delimiter(")content(NaN)delimiter(")>operator(.)ident(equals)operator(()ident(val)operator(\))operator(\)) operator({) - ident(val) operator(=) string<delimiter(")content(.NaN)delimiter(")>operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(val)operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Range)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLRangeMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(range_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - pre_type(Map) ident(mep) operator(=) operator(()pre_type(Map)operator(\))operator(()keyword(new) ident(RubyHash)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(begin)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(begin)delimiter(")>operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(end)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(end)delimiter(")>operator(\))operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(excl)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(exclude_end?)delimiter(")>operator(\))operator(\))operator(;) - keyword(for)operator(()pre_type(Iterator) ident(iter) operator(=) operator(()operator(()ident(RubyArray)operator(\))ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_properties)delimiter(")>operator(\))operator(\))operator(.)ident(getList)operator(()operator(\))operator(.)ident(iterator)operator(()operator(\))operator(;) ident(iter)operator(.)ident(hasNext)operator(()operator(\))operator(;)operator(\)) operator({) - pre_type(String) ident(m) operator(=) ident(iter)operator(.)ident(next)operator(()operator(\))operator(.)ident(toString)operator(()operator(\))operator(;) - ident(mep)operator(.)ident(put)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(.)ident(substring)operator(()integer(1)operator(\))operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(instance_variable_get)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(m)operator(\))operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(map)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) operator(()ident(IRubyObject)operator(\))ident(mep)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Regexp)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLRegexpMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(regexp_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(inspect)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Time)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLTimeMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(time_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - ident(IRubyObject) ident(tz) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(Z)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(difference_sign) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(-)delimiter(")>operator(\))operator(;) - ident(self) operator(=) ident(self)operator(.)ident(dup)operator(()operator(\))operator(;) - keyword(if)operator(()operator(!)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(utc?)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(IRubyObject) ident(utc_same_instant) operator(=) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(utc)delimiter(")>operator(\))operator(;) - ident(IRubyObject) ident(utc_same_writing) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getTime)operator(()operator(\))operator(,) string<delimiter(")content(utc)delimiter(")>operator(,) keyword(new) ident(IRubyObject)type([])operator({) - ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(year)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(month)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(day)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(hour)delimiter(")>operator(\))operator(,) - ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(min)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(sec)delimiter(")>operator(\))operator(,)ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(usec)delimiter(")>operator(\))operator(})operator(\))operator(;) - ident(IRubyObject) ident(difference_to_utc) operator(=) ident(utc_same_writing)operator(.)ident(callMethod)operator(()ident(context)operator(,)ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(utc_same_instant)operator(\))operator(;) - ident(IRubyObject) ident(absolute_difference)operator(;) - keyword(if)operator(()ident(difference_to_utc)operator(.)ident(callMethod)operator(()ident(context)operator(,)ident(MethodIndex)operator(.)ident(OP_LT)operator(,) string<delimiter(")content(<)delimiter(")>operator(,) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(difference_sign) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(-)delimiter(")>operator(\))operator(;) - ident(absolute_difference) operator(=) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)ident(MethodIndex)operator(.)ident(OP_MINUS)operator(,) string<delimiter(")content(-)delimiter(")>operator(,) ident(difference_to_utc)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(difference_sign) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(+)delimiter(")>operator(\))operator(;) - ident(absolute_difference) operator(=) ident(difference_to_utc)operator(;) - operator(}) - ident(IRubyObject) ident(difference_minutes) operator(=) ident(absolute_difference)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(/)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(60)operator(\))operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(round)delimiter(")>operator(\))operator(;) - ident(tz) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(%s%02d:%02d)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(%)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArrayNoCopy)operator(()keyword(new) ident(IRubyObject)type([])operator({)ident(difference_sign)operator(,)ident(difference_minutes)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(/)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(60)operator(\))operator(\))operator(,)ident(difference_minutes)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(%)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()integer(60)operator(\))operator(\))operator(})operator(\))operator(\))operator(;) - operator(}) - ident(IRubyObject) ident(standard) operator(=) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(strftime)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(%Y-%m-%d %H:%M:%S)delimiter(")>operator(\))operator(\))operator(;) - keyword(if)operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(usec)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(nonzero?)delimiter(")>operator(\))operator(.)ident(isTrue)operator(()operator(\))operator(\)) operator({) - ident(standard) operator(=) ident(standard)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(.%06d)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(%)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(usec)delimiter(")>operator(\))operator(\))operator(\))operator(\))operator(;) - operator(}) - ident(standard) operator(=) ident(standard)operator(.)ident(callMethod)operator(()ident(context)operator(,)ident(MethodIndex)operator(.)ident(OP_PLUS)operator(,) string<delimiter(")content(+)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content( %s)delimiter(")>operator(\))operator(.)ident(callMethod)operator(()ident(context)operator(,)string<delimiter(")content(%)delimiter(")>operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(tz)operator(\))operator(\))operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(standard)operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Date)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLDateMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(date_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(TrueClass)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLTrueMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(true_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(tag:yaml.org,2002:bool)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(FalseClass)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLFalseMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,) string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) ident(MethodIndex)operator(.)ident(TO_S)operator(,) string<delimiter(")content(to_s)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(taguri)delimiter(")>operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(false_taguri)operator(()ident(IRubyObject) ident(self)operator(\)) operator({) - keyword(return) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")content(tag:yaml.org,2002:bool)delimiter(")>operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(NilClass)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(YAMLNilMethods) operator({) - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_yaml_node)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(nil_to_yaml_node)operator(()ident(IRubyObject) ident(self)operator(,) ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(ThreadContext) ident(context) operator(=) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(;) - keyword(return) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(arg)operator(,)string<delimiter(")content(scalar)delimiter(")>operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(taguri)delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()string<delimiter(")delimiter(")>operator(\))operator(,) ident(self)operator(.)ident(callMethod)operator(()ident(context)operator(,) string<delimiter(")content(to_yaml_style)delimiter(")>operator(\))operator(\))operator(;) - operator(}) - operator(}) -operator(})comment(// RubyYAML) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(java.io.InputStream)operator(;) -keyword(import) include(java.io.IOException)operator(;) - -keyword(import) include(java.util.List)operator(;) -keyword(import) include(java.util.ArrayList)operator(;) - -keyword(import) include(java.util.zip.GZIPInputStream)operator(;) -keyword(import) include(java.util.zip.GZIPOutputStream)operator(;) -keyword(import) include(org.jruby.anno.FrameField)operator(;) -keyword(import) include(org.jruby.anno.JRubyMethod)operator(;) -keyword(import) include(org.jruby.anno.JRubyClass)operator(;) -keyword(import) include(org.jruby.anno.JRubyModule)operator(;) - -keyword(import) include(org.jruby.exceptions.RaiseException)operator(;) -keyword(import) include(org.jruby.javasupport.util.RuntimeHelpers)operator(;) -keyword(import) include(org.jruby.runtime.Arity)operator(;) - -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.ObjectAllocator)operator(;) -keyword(import) include(org.jruby.runtime.ThreadContext)operator(;) -keyword(import) include(org.jruby.runtime.Visibility)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) - -keyword(import) include(org.jruby.util.IOInputStream)operator(;) -keyword(import) include(org.jruby.util.IOOutputStream)operator(;) -keyword(import) include(org.jruby.util.CRC32Ext)operator(;) -keyword(import) include(org.jruby.util.Adler32Ext)operator(;) -keyword(import) include(org.jruby.util.ZlibInflate)operator(;) -keyword(import) include(org.jruby.util.ZlibDeflate)operator(;) - -keyword(import) include(org.jruby.util.ByteList)operator(;) - -annotation(@JRubyModule)operator(()ident(name)operator(=)string<delimiter(")content(Zlib)delimiter(")>operator(\)) -directive(public) type(class) class(RubyZlib) operator({) - comment(/** Create the Zlib module and add it to the Ruby runtime. - * - */) - directive(public) directive(static) ident(RubyModule) ident(createZlibModule)operator(()ident(Ruby) ident(runtime)operator(\)) operator({) - ident(RubyModule) ident(result) operator(=) ident(runtime)operator(.)ident(defineModule)operator(()string<delimiter(")content(Zlib)delimiter(")>operator(\))operator(;) - - ident(RubyClass) ident(gzfile) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(GzipFile)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(RubyGzipFile)operator(.)ident(GZIPFILE_ALLOCATOR)operator(\))operator(;) - ident(gzfile)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyGzipFile)operator(.)ident(class)operator(\))operator(;) - - ident(RubyClass) ident(gzreader) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(GzipReader)delimiter(")>operator(,) ident(gzfile)operator(,) ident(RubyGzipReader)operator(.)ident(GZIPREADER_ALLOCATOR)operator(\))operator(;) - ident(gzreader)operator(.)ident(includeModule)operator(()ident(runtime)operator(.)ident(getEnumerable)operator(()operator(\))operator(\))operator(;) - ident(gzreader)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyGzipReader)operator(.)ident(class)operator(\))operator(;) - - ident(RubyClass) ident(standardError) operator(=) ident(runtime)operator(.)ident(getStandardError)operator(()operator(\))operator(;) - ident(RubyClass) ident(zlibError) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Error)delimiter(")>operator(,) ident(standardError)operator(,) ident(standardError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(gzreader)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Error)delimiter(")>operator(,) ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - - ident(RubyClass) ident(gzwriter) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(GzipWriter)delimiter(")>operator(,) ident(gzfile)operator(,) ident(RubyGzipWriter)operator(.)ident(GZIPWRITER_ALLOCATOR)operator(\))operator(;) - ident(gzwriter)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyGzipWriter)operator(.)ident(class)operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ZLIB_VERSION)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(1.2.1)delimiter(")>operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(VERSION)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(0.6.0)delimiter(")>operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(BINARY)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(ASCII)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(UNKNOWN)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(DEF_MEM_LEVEL)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(8)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAX_MEM_LEVEL)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(9)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_UNIX)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(3)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_UNKNOWN)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(255)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_CODE)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(11)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_ZSYSTEM)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(8)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_VMCMS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(4)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_VMS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_RISCOS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(13)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_MACOS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(7)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_OS2)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(6)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_AMIGA)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_QDOS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(12)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_WIN32)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(11)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_ATARI)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(5)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_MSDOS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_CPM)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(9)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(OS_TOPS20)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(10)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(DEFAULT_STRATEGY)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(FILTERED)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(HUFFMAN_ONLY)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(NO_FLUSH)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(SYNC_FLUSH)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(2)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(FULL_FLUSH)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(3)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(FINISH)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(4)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(NO_COMPRESSION)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(0)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(BEST_SPEED)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(1)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(DEFAULT_COMPRESSION)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()operator(-)integer(1)operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(BEST_COMPRESSION)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(9)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineConstant)operator(()string<delimiter(")content(MAX_WBITS)delimiter(")>operator(,)ident(runtime)operator(.)ident(newFixnum)operator(()integer(15)operator(\))operator(\))operator(;) - - ident(result)operator(.)ident(defineAnnotatedMethods)operator(()ident(RubyZlib)operator(.)ident(class)operator(\))operator(;) - - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(StreamEnd)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(StreamError)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(BufError)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(NeedDict)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(MemError)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(VersionError)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(DataError)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - - ident(RubyClass) ident(gzError) operator(=) ident(gzfile)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Error)delimiter(")>operator(,)ident(zlibError)operator(,) ident(zlibError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(gzfile)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(CRCError)delimiter(")>operator(,)ident(gzError)operator(,) ident(gzError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(gzfile)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(NoFooter)delimiter(")>operator(,)ident(gzError)operator(,) ident(gzError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - ident(gzfile)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(LengthError)delimiter(")>operator(,)ident(gzError)operator(,) ident(gzError)operator(.)ident(getAllocator)operator(()operator(\))operator(\))operator(;) - - comment(// ZStream actually *isn't* allocatable) - ident(RubyClass) ident(zstream) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(ZStream)delimiter(")>operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(,) ident(ObjectAllocator)operator(.)ident(NOT_ALLOCATABLE_ALLOCATOR)operator(\))operator(;) - ident(zstream)operator(.)ident(defineAnnotatedMethods)operator(()ident(ZStream)operator(.)ident(class)operator(\))operator(;) - ident(zstream)operator(.)ident(undefineMethod)operator(()string<delimiter(")content(new)delimiter(")>operator(\))operator(;) - - ident(RubyClass) ident(infl) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Inflate)delimiter(")>operator(,) ident(zstream)operator(,) ident(Inflate)operator(.)ident(INFLATE_ALLOCATOR)operator(\))operator(;) - ident(infl)operator(.)ident(defineAnnotatedMethods)operator(()ident(Inflate)operator(.)ident(class)operator(\))operator(;) - - ident(RubyClass) ident(defl) operator(=) ident(result)operator(.)ident(defineClassUnder)operator(()string<delimiter(")content(Deflate)delimiter(")>operator(,) ident(zstream)operator(,) ident(Deflate)operator(.)ident(DEFLATE_ALLOCATOR)operator(\))operator(;) - ident(defl)operator(.)ident(defineAnnotatedMethods)operator(()ident(Deflate)operator(.)ident(class)operator(\))operator(;) - - ident(runtime)operator(.)ident(getKernel)operator(()operator(\))operator(.)ident(callMethod)operator(()ident(runtime)operator(.)ident(getCurrentContext)operator(()operator(\))operator(,)string<delimiter(")content(require)delimiter(")>operator(,)ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(stringio)delimiter(")>operator(\))operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(StandardError)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::StreamEnd)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(StreamEnd) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::StreamError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(StreamError) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::BufError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(BufError) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::NeedDict)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(NeedDict) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::MemError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(MemError) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::VersionError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(VersionError) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::DataError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(DataError) directive(extends) exception(Error) operator({)operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(zlib_version)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(zlib_version)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyModule)operator(\))ident(recv)operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(ZLIB_VERSION)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(version)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(version)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - keyword(return) operator(()operator(()ident(RubyModule)operator(\))ident(recv)operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(VERSION)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(crc32)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(crc32)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(0)operator(,)integer(2)operator(\))operator(;) - type(long) ident(crc) operator(=) integer(0)operator(;) - ident(ByteList) ident(bytes) operator(=) pre_constant(null)operator(;) - - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(bytes) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(crc) operator(=) ident(RubyNumeric)operator(.)ident(num2long)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - - ident(CRC32Ext) ident(ext) operator(=) keyword(new) ident(CRC32Ext)operator(()operator(()type(int)operator(\))ident(crc)operator(\))operator(;) - keyword(if) operator(()ident(bytes) operator(!=) pre_constant(null)operator(\)) operator({) - ident(ext)operator(.)ident(update)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(ext)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(adler32)delimiter(")>operator(,) ident(optional) operator(=) integer(2)operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(adler32)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(0)operator(,)integer(2)operator(\))operator(;) - type(int) ident(adler) operator(=) integer(1)operator(;) - ident(ByteList) ident(bytes) operator(=) pre_constant(null)operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(bytes) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) ident(adler) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - - ident(Adler32Ext) ident(ext) operator(=) keyword(new) ident(Adler32Ext)operator(()ident(adler)operator(\))operator(;) - keyword(if) operator(()ident(bytes) operator(!=) pre_constant(null)operator(\)) operator({) - ident(ext)operator(.)ident(update)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) comment(// it's safe since adler.update doesn't modify the array) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(ext)operator(.)ident(getValue)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(private) directive(final) directive(static) type(long)type([]) ident(crctab) operator(=) keyword(new) type(long)type([])operator({) - integer(0L)operator(,) integer(1996959894L)operator(,) integer(3993919788L)operator(,) integer(2567524794L)operator(,) integer(124634137L)operator(,) integer(1886057615L)operator(,) integer(3915621685L)operator(,) integer(2657392035L)operator(,) integer(249268274L)operator(,) integer(2044508324L)operator(,) integer(3772115230L)operator(,) integer(2547177864L)operator(,) integer(162941995L)operator(,) - integer(2125561021L)operator(,) integer(3887607047L)operator(,) integer(2428444049L)operator(,) integer(498536548L)operator(,) integer(1789927666L)operator(,) integer(4089016648L)operator(,) integer(2227061214L)operator(,) integer(450548861L)operator(,) integer(1843258603L)operator(,) integer(4107580753L)operator(,) integer(2211677639L)operator(,) integer(325883990L)operator(,) - integer(1684777152L)operator(,) integer(4251122042L)operator(,) integer(2321926636L)operator(,) integer(335633487L)operator(,) integer(1661365465L)operator(,) integer(4195302755L)operator(,) integer(2366115317L)operator(,) integer(997073096L)operator(,) integer(1281953886L)operator(,) integer(3579855332L)operator(,) integer(2724688242L)operator(,) integer(1006888145L)operator(,) - integer(1258607687L)operator(,) integer(3524101629L)operator(,) integer(2768942443L)operator(,) integer(901097722L)operator(,) integer(1119000684L)operator(,) integer(3686517206L)operator(,) integer(2898065728L)operator(,) integer(853044451L)operator(,) integer(1172266101L)operator(,) integer(3705015759L)operator(,) integer(2882616665L)operator(,) integer(651767980L)operator(,) - integer(1373503546L)operator(,) integer(3369554304L)operator(,) integer(3218104598L)operator(,) integer(565507253L)operator(,) integer(1454621731L)operator(,) integer(3485111705L)operator(,) integer(3099436303L)operator(,) integer(671266974L)operator(,) integer(1594198024L)operator(,) integer(3322730930L)operator(,) integer(2970347812L)operator(,) integer(795835527L)operator(,) - integer(1483230225L)operator(,) integer(3244367275L)operator(,) integer(3060149565L)operator(,) integer(1994146192L)operator(,) integer(31158534L)operator(,) integer(2563907772L)operator(,) integer(4023717930L)operator(,) integer(1907459465L)operator(,) integer(112637215L)operator(,) integer(2680153253L)operator(,) integer(3904427059L)operator(,) integer(2013776290L)operator(,) - integer(251722036L)operator(,) integer(2517215374L)operator(,) integer(3775830040L)operator(,) integer(2137656763L)operator(,) integer(141376813L)operator(,) integer(2439277719L)operator(,) integer(3865271297L)operator(,) integer(1802195444L)operator(,) integer(476864866L)operator(,) integer(2238001368L)operator(,) integer(4066508878L)operator(,) integer(1812370925L)operator(,) - integer(453092731L)operator(,) integer(2181625025L)operator(,) integer(4111451223L)operator(,) integer(1706088902L)operator(,) integer(314042704L)operator(,) integer(2344532202L)operator(,) integer(4240017532L)operator(,) integer(1658658271L)operator(,) integer(366619977L)operator(,) integer(2362670323L)operator(,) integer(4224994405L)operator(,) integer(1303535960L)operator(,) - integer(984961486L)operator(,) integer(2747007092L)operator(,) integer(3569037538L)operator(,) integer(1256170817L)operator(,) integer(1037604311L)operator(,) integer(2765210733L)operator(,) integer(3554079995L)operator(,) integer(1131014506L)operator(,) integer(879679996L)operator(,) integer(2909243462L)operator(,) integer(3663771856L)operator(,) integer(1141124467L)operator(,) - integer(855842277L)operator(,) integer(2852801631L)operator(,) integer(3708648649L)operator(,) integer(1342533948L)operator(,) integer(654459306L)operator(,) integer(3188396048L)operator(,) integer(3373015174L)operator(,) integer(1466479909L)operator(,) integer(544179635L)operator(,) integer(3110523913L)operator(,) integer(3462522015L)operator(,) integer(1591671054L)operator(,) - integer(702138776L)operator(,) integer(2966460450L)operator(,) integer(3352799412L)operator(,) integer(1504918807L)operator(,) integer(783551873L)operator(,) integer(3082640443L)operator(,) integer(3233442989L)operator(,) integer(3988292384L)operator(,) integer(2596254646L)operator(,) integer(62317068L)operator(,) integer(1957810842L)operator(,) integer(3939845945L)operator(,) - integer(2647816111L)operator(,) integer(81470997L)operator(,) integer(1943803523L)operator(,) integer(3814918930L)operator(,) integer(2489596804L)operator(,) integer(225274430L)operator(,) integer(2053790376L)operator(,) integer(3826175755L)operator(,) integer(2466906013L)operator(,) integer(167816743L)operator(,) integer(2097651377L)operator(,) integer(4027552580L)operator(,) - integer(2265490386L)operator(,) integer(503444072L)operator(,) integer(1762050814L)operator(,) integer(4150417245L)operator(,) integer(2154129355L)operator(,) integer(426522225L)operator(,) integer(1852507879L)operator(,) integer(4275313526L)operator(,) integer(2312317920L)operator(,) integer(282753626L)operator(,) integer(1742555852L)operator(,) integer(4189708143L)operator(,) - integer(2394877945L)operator(,) integer(397917763L)operator(,) integer(1622183637L)operator(,) integer(3604390888L)operator(,) integer(2714866558L)operator(,) integer(953729732L)operator(,) integer(1340076626L)operator(,) integer(3518719985L)operator(,) integer(2797360999L)operator(,) integer(1068828381L)operator(,) integer(1219638859L)operator(,) integer(3624741850L)operator(,) - integer(2936675148L)operator(,) integer(906185462L)operator(,) integer(1090812512L)operator(,) integer(3747672003L)operator(,) integer(2825379669L)operator(,) integer(829329135L)operator(,) integer(1181335161L)operator(,) integer(3412177804L)operator(,) integer(3160834842L)operator(,) integer(628085408L)operator(,) integer(1382605366L)operator(,) integer(3423369109L)operator(,) - integer(3138078467L)operator(,) integer(570562233L)operator(,) integer(1426400815L)operator(,) integer(3317316542L)operator(,) integer(2998733608L)operator(,) integer(733239954L)operator(,) integer(1555261956L)operator(,) integer(3268935591L)operator(,) integer(3050360625L)operator(,) integer(752459403L)operator(,) integer(1541320221L)operator(,) integer(2607071920L)operator(,) - integer(3965973030L)operator(,) integer(1969922972L)operator(,) integer(40735498L)operator(,) integer(2617837225L)operator(,) integer(3943577151L)operator(,) integer(1913087877L)operator(,) integer(83908371L)operator(,) integer(2512341634L)operator(,) integer(3803740692L)operator(,) integer(2075208622L)operator(,) integer(213261112L)operator(,) integer(2463272603L)operator(,) - integer(3855990285L)operator(,) integer(2094854071L)operator(,) integer(198958881L)operator(,) integer(2262029012L)operator(,) integer(4057260610L)operator(,) integer(1759359992L)operator(,) integer(534414190L)operator(,) integer(2176718541L)operator(,) integer(4139329115L)operator(,) integer(1873836001L)operator(,) integer(414664567L)operator(,) integer(2282248934L)operator(,) - integer(4279200368L)operator(,) integer(1711684554L)operator(,) integer(285281116L)operator(,) integer(2405801727L)operator(,) integer(4167216745L)operator(,) integer(1634467795L)operator(,) integer(376229701L)operator(,) integer(2685067896L)operator(,) integer(3608007406L)operator(,) integer(1308918612L)operator(,) integer(956543938L)operator(,) integer(2808555105L)operator(,) - integer(3495958263L)operator(,) integer(1231636301L)operator(,) integer(1047427035L)operator(,) integer(2932959818L)operator(,) integer(3654703836L)operator(,) integer(1088359270L)operator(,) integer(936918000L)operator(,) integer(2847714899L)operator(,) integer(3736837829L)operator(,) integer(1202900863L)operator(,) integer(817233897L)operator(,) integer(3183342108L)operator(,) - integer(3401237130L)operator(,) integer(1404277552L)operator(,) integer(615818150L)operator(,) integer(3134207493L)operator(,) integer(3453421203L)operator(,) integer(1423857449L)operator(,) integer(601450431L)operator(,) integer(3009837614L)operator(,) integer(3294710456L)operator(,) integer(1567103746L)operator(,) integer(711928724L)operator(,) integer(3020668471L)operator(,) - integer(3272380065L)operator(,) integer(1510334235L)operator(,) integer(755167117)operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(crc_table)delimiter(")>operator(,) ident(module) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(crc_table)operator(()ident(IRubyObject) ident(recv)operator(\)) operator({) - pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(ll) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()ident(crctab)operator(.)ident(length)operator(\))operator(;) - keyword(for)operator(()type(int) ident(i)operator(=)integer(0)operator(;)ident(i)operator(<)ident(crctab)operator(.)ident(length)operator(;)ident(i)operator(++)operator(\)) operator({) - ident(ll)operator(.)ident(add)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(crctab)operator([)ident(i)operator(])operator(\))operator(\))operator(;) - operator(}) - keyword(return) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(ll)operator(\))operator(;) - operator(}) - - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::ZStream)delimiter(")>operator(\)) - directive(public) directive(static) directive(abstract) type(class) class(ZStream) directive(extends) ident(RubyObject) operator({) - directive(protected) type(boolean) ident(closed) operator(=) pre_constant(false)operator(;) - directive(protected) type(boolean) ident(ended) operator(=) pre_constant(false)operator(;) - directive(protected) type(boolean) ident(finished) operator(=) pre_constant(false)operator(;) - - directive(protected) directive(abstract) type(int) ident(internalTotalOut)operator(()operator(\))operator(;) - directive(protected) directive(abstract) type(boolean) ident(internalStreamEndP)operator(()operator(\))operator(;) - directive(protected) directive(abstract) type(void) ident(internalEnd)operator(()operator(\))operator(;) - directive(protected) directive(abstract) type(void) ident(internalReset)operator(()operator(\))operator(;) - directive(protected) directive(abstract) type(int) ident(internalAdler)operator(()operator(\))operator(;) - directive(protected) directive(abstract) ident(IRubyObject) ident(internalFinish)operator(()operator(\)) directive(throws) exception(Exception)operator(;) - directive(protected) directive(abstract) type(int) ident(internalTotalIn)operator(()operator(\))operator(;) - directive(protected) directive(abstract) type(void) ident(internalClose)operator(()operator(\))operator(;) - - directive(public) ident(ZStream)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flust_next_out)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(flush_next_out)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(total_out)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(total_out)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(internalTotalOut)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(stream_end?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(stream_end_p)operator(()operator(\)) operator({) - keyword(return) ident(internalStreamEndP)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(data_type)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(data_type)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Zlib)delimiter(")>operator(\))operator(.)ident(fastGetConstant)operator(()string<delimiter(")content(UNKNOWN)delimiter(")>operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(closed_p)operator(()operator(\)) operator({) - keyword(return) ident(closed) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ended?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(ended_p)operator(()operator(\)) operator({) - keyword(return) ident(ended) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(end)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(end)operator(()operator(\)) operator({) - keyword(if)operator(()operator(!)ident(ended)operator(\)) operator({) - ident(internalEnd)operator(()operator(\))operator(;) - ident(ended) operator(=) pre_constant(true)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(reset)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(reset)operator(()operator(\)) operator({) - ident(internalReset)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(avail_out)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(avail_out)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(avail_out=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_avail_out)operator(()ident(IRubyObject) ident(p1)operator(\)) operator({) - keyword(return) ident(p1)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(adler)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(adler)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(internalAdler)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(finish)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(finish)operator(()operator(\)) directive(throws) exception(Exception) operator({) - keyword(if)operator(()operator(!)ident(finished)operator(\)) operator({) - ident(finished) operator(=) pre_constant(true)operator(;) - keyword(return) ident(internalFinish)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(avail_in)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(avail_in)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flush_next_in)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(flush_next_in)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(total_in)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(total_in)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(internalTotalIn)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(finished?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(finished_p)operator(()operator(\)) operator({) - keyword(return) ident(finished) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) operator({) - keyword(if)operator(()operator(!)ident(closed)operator(\)) operator({) - ident(internalClose)operator(()operator(\))operator(;) - ident(closed) operator(=) pre_constant(true)operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::Inflate)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::ZStream)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Inflate) directive(extends) ident(ZStream) operator({) - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(INFLATE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(Inflate)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inflate)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(s_inflate)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(string)operator(\)) directive(throws) exception(Exception) operator({) - keyword(return) ident(ZlibInflate)operator(.)ident(s_inflate)operator(()ident(recv)operator(,)ident(string)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - - directive(public) ident(Inflate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) ident(ZlibInflate) ident(infl)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(_initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(infl) operator(=) keyword(new) ident(ZlibInflate)operator(()local_variable(this)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(append)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - ident(infl)operator(.)ident(append)operator(()ident(arg)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync_point?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sync_point_p)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(sync_point)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(set_dictionary)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_dictionary)operator(()ident(IRubyObject) ident(arg)operator(\)) directive(throws) exception(Exception) operator({) - keyword(return) ident(infl)operator(.)ident(set_dictionary)operator(()ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(inflate)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(inflate)operator(()ident(IRubyObject) ident(string)operator(\)) directive(throws) exception(Exception) operator({) - keyword(return) ident(infl)operator(.)ident(inflate)operator(()ident(string)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(sync)operator(()ident(IRubyObject) ident(string)operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(sync)operator(()ident(string)operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalTotalOut)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(getTotalOut)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(boolean) ident(internalStreamEndP)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(finished)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalEnd)operator(()operator(\)) operator({) - ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(end)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalReset)operator(()operator(\)) operator({) - ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(reset)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalAdler)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(getAdler)operator(()operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(internalFinish)operator(()operator(\)) directive(throws) exception(Exception) operator({) - ident(infl)operator(.)ident(finish)operator(()operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finished_p)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(finished)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalTotalIn)operator(()operator(\)) operator({) - keyword(return) ident(infl)operator(.)ident(getInflater)operator(()operator(\))operator(.)ident(getTotalIn)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalClose)operator(()operator(\)) operator({) - ident(infl)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::Deflate)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::ZStream)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Deflate) directive(extends) ident(ZStream) operator({) - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(DEFLATE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(Deflate)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(deflate)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(s_deflate)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(1)operator(,)integer(1)operator(\))operator(;) - type(int) ident(level) operator(=) operator(-)integer(1)operator(;) - keyword(if)operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(level) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(ZlibDeflate)operator(.)ident(s_deflate)operator(()ident(recv)operator(,)ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(,)ident(level)operator(\))operator(;) - operator(}) - - directive(public) ident(Deflate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) ident(ZlibDeflate) ident(defl)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(optional) operator(=) integer(4)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(_initialize)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(0)operator(,)integer(4)operator(\))operator(;) - type(int) ident(level) operator(=) operator(-)integer(1)operator(;) - type(int) ident(window_bits) operator(=) integer(15)operator(;) - type(int) ident(memlevel) operator(=) integer(8)operator(;) - type(int) ident(strategy) operator(=) integer(0)operator(;) - keyword(if)operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(level) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(window_bits) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(args)operator([)integer(2)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(memlevel) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(2)operator(])operator(\))operator(;) - operator(}) - keyword(if)operator(()operator(!)ident(args)operator([)integer(3)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(strategy) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(3)operator(])operator(\))operator(;) - operator(}) - ident(defl) operator(=) keyword(new) ident(ZlibDeflate)operator(()local_variable(this)operator(,)ident(level)operator(,)ident(window_bits)operator(,)ident(memlevel)operator(,)ident(strategy)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(<<)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(append)operator(()ident(IRubyObject) ident(arg)operator(\)) directive(throws) exception(Exception) operator({) - ident(defl)operator(.)ident(append)operator(()ident(arg)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(params)delimiter(")>operator(,) ident(required) operator(=) integer(2)operator(\)) - directive(public) ident(IRubyObject) ident(params)operator(()ident(IRubyObject) ident(level)operator(,) ident(IRubyObject) ident(strategy)operator(\)) operator({) - ident(defl)operator(.)ident(params)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(level)operator(\))operator(,)ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(strategy)operator(\))operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(set_dictionary)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_dictionary)operator(()ident(IRubyObject) ident(arg)operator(\)) directive(throws) exception(Exception) operator({) - keyword(return) ident(defl)operator(.)ident(set_dictionary)operator(()ident(arg)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flush)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(flush)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - type(int) ident(flush) operator(=) integer(2)operator(;) comment(// SYNC_FLUSH) - keyword(if)operator(()ident(args)operator(.)ident(length) operator(==) integer(1)operator(\)) operator({) - keyword(if)operator(()operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(flush) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(defl)operator(.)ident(flush)operator(()ident(flush)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(deflate)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(deflate)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(Exception) operator({) - ident(args) operator(=) ident(Arity)operator(.)ident(scanArgs)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(args)operator(,)integer(1)operator(,)integer(1)operator(\))operator(;) - type(int) ident(flush) operator(=) integer(0)operator(;) comment(// NO_FLUSH) - keyword(if)operator(()operator(!)ident(args)operator([)integer(1)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(flush) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(1)operator(])operator(\))operator(;) - operator(}) - keyword(return) ident(defl)operator(.)ident(deflate)operator(()ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(,)ident(flush)operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalTotalOut)operator(()operator(\)) operator({) - keyword(return) ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(getTotalOut)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(boolean) ident(internalStreamEndP)operator(()operator(\)) operator({) - keyword(return) ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(finished)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalEnd)operator(()operator(\)) operator({) - ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(end)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalReset)operator(()operator(\)) operator({) - ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(reset)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalAdler)operator(()operator(\)) operator({) - keyword(return) ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(getAdler)operator(()operator(\))operator(;) - operator(}) - - directive(protected) ident(IRubyObject) ident(internalFinish)operator(()operator(\)) directive(throws) exception(Exception) operator({) - keyword(return) ident(defl)operator(.)ident(finish)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(int) ident(internalTotalIn)operator(()operator(\)) operator({) - keyword(return) ident(defl)operator(.)ident(getDeflater)operator(()operator(\))operator(.)ident(getTotalIn)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(void) ident(internalClose)operator(()operator(\)) operator({) - ident(defl)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipFile)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(RubyGzipFile) directive(extends) ident(RubyObject) operator({) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipFile::Error)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipFile::CRCError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipFile::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(CRCError) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipFile::NoFooter)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipFile::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(NoFooter) directive(extends) exception(Error) operator({)operator(}) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipFile::LengthError)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipFile::Error)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(LengthError) directive(extends) exception(Error) operator({)operator(}) - - directive(private) directive(static) ident(IRubyObject) ident(wrap)operator(()ident(ThreadContext) ident(context)operator(,) ident(RubyGzipFile) ident(instance)operator(,) - ident(IRubyObject) ident(io)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()ident(block)operator(.)ident(isGiven)operator(()operator(\))operator(\)) operator({) - keyword(try) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(instance)operator(\))operator(;) - - keyword(return) ident(instance)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) keyword(finally) operator({) - keyword(if) operator(()operator(!)ident(instance)operator(.)ident(isClosed)operator(()operator(\))operator(\)) ident(instance)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - operator(}) - - keyword(return) ident(io)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(wrap)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(wrap)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(io)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyGzipFile) ident(instance)operator(;) - - comment(// TODO: People extending GzipWriter/reader will break. Find better way here.) - keyword(if) operator(()ident(recv) operator(==) ident(runtime)operator(.)ident(getModule)operator(()string<delimiter(")content(Zlib)delimiter(")>operator(\))operator(.)ident(getClass)operator(()string<delimiter(")content(GzipWriter)delimiter(")>operator(\))operator(\)) operator({) - ident(instance) operator(=) ident(RubyGzipWriter)operator(.)ident(newGzipWriter)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(io) operator(})operator(,) ident(block)operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(instance) operator(=) ident(RubyGzipReader)operator(.)ident(newInstance)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([]) operator({) ident(io) operator(})operator(,) ident(block)operator(\))operator(;) - operator(}) - - keyword(return) ident(wrap)operator(()ident(context)operator(,) ident(instance)operator(,) ident(io)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(GZIPFILE_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyGzipFile)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyGzipFile) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - ident(RubyGzipFile) ident(result) operator(=) operator(()ident(RubyGzipFile)operator(\)) ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - - ident(result)operator(.)ident(callInit)operator(()keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(,) ident(block)operator(\))operator(;) - - keyword(return) ident(result)operator(;) - operator(}) - - directive(protected) type(boolean) ident(closed) operator(=) pre_constant(false)operator(;) - directive(protected) type(boolean) ident(finished) operator(=) pre_constant(false)operator(;) - directive(private) type(int) ident(os_code) operator(=) integer(255)operator(;) - directive(private) type(int) ident(level) operator(=) operator(-)integer(1)operator(;) - directive(private) pre_type(String) ident(orig_name)operator(;) - directive(private) pre_type(String) ident(comment)operator(;) - directive(protected) ident(IRubyObject) ident(realIo)operator(;) - directive(private) ident(IRubyObject) ident(mtime)operator(;) - - directive(public) ident(RubyGzipFile)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - ident(mtime) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(os_code)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(os_code)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(os_code)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(closed?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(closed_p)operator(()operator(\)) operator({) - keyword(return) ident(closed) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - directive(protected) type(boolean) ident(isClosed)operator(()operator(\)) operator({) - keyword(return) ident(closed)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(orig_name)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(orig_name)operator(()operator(\)) operator({) - keyword(return) ident(orig_name) operator(==) pre_constant(null) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(orig_name)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(to_io)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(to_io)operator(()operator(\)) operator({) - keyword(return) ident(realIo)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(comment)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(comment)operator(()operator(\)) operator({) - keyword(return) ident(comment) operator(==) pre_constant(null) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(newString)operator(()ident(comment)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(crc)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(crc)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mtime)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(mtime)operator(()operator(\)) operator({) - keyword(return) ident(mtime)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(sync)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(finish)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(finish)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()operator(!)ident(finished)operator(\)) operator({) - comment(//io.finish(\);) - operator(}) - ident(finished) operator(=) pre_constant(true)operator(;) - keyword(return) ident(realIo)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) pre_constant(null)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(level)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(level)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(level)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(sync=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_sync)operator(()ident(IRubyObject) ident(ignored)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipReader)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipFile)delimiter(")>operator(,) ident(include)operator(=)string<delimiter(")content(Enumerable)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(RubyGzipReader) directive(extends) ident(RubyGzipFile) operator({) - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipReader::Error)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipReader)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(Error) operator({)operator(}) - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(GZIPREADER_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyGzipReader)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyGzipReader) ident(newInstance)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - ident(RubyGzipReader) ident(result) operator(=) operator(()ident(RubyGzipReader)operator(\))ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(result)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject) ident(filename)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(io) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,) string<delimiter(")content(open)delimiter(")>operator(,) ident(filename)operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(rb)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyGzipFile) ident(instance) operator(=) ident(newInstance)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(io)operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(return) ident(RubyGzipFile)operator(.)ident(wrap)operator(()ident(context)operator(,) ident(instance)operator(,) ident(io)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyGzipReader)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) type(int) ident(line)operator(;) - directive(private) pre_type(InputStream) ident(io)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize)operator(()ident(IRubyObject) ident(io)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - ident(realIo) operator(=) ident(io)operator(;) - keyword(try) operator({) - local_variable(this)operator(.)ident(io) operator(=) keyword(new) pre_type(GZIPInputStream)operator(()keyword(new) ident(IOInputStream)operator(()ident(io)operator(\))operator(\))operator(;) - operator(}) keyword(catch) operator(()exception(IOException) ident(e)operator(\)) operator({) - ident(Ruby) ident(runtime) operator(=) ident(io)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(RubyClass) ident(errorClass) operator(=) ident(runtime)operator(.)ident(fastGetModule)operator(()string<delimiter(")content(Zlib)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(GzipReader)delimiter(")>operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(Error)delimiter(")>operator(\))operator(;) - keyword(throw) keyword(new) ident(RaiseException)operator(()ident(RubyException)operator(.)ident(newException)operator(()ident(runtime)operator(,) ident(errorClass)operator(,) ident(e)operator(.)ident(getMessage)operator(()operator(\))operator(\))operator(\))operator(;) - operator(}) - - ident(line) operator(=) integer(1)operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(rewind)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(rewind)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(lineno)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(line)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readline)delimiter(")>operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(readline)operator(()ident(ThreadContext) ident(context)operator(\)) directive(throws) exception(IOException) operator({) - ident(IRubyObject) ident(dst) operator(=) ident(gets)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(dst)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(dst)operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(internalGets)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - ident(ByteList) ident(sep) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(sep) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(internalSepGets)operator(()ident(sep)operator(\))operator(;) - operator(}) - - directive(private) ident(IRubyObject) ident(internalSepGets)operator(()ident(ByteList) ident(sep)operator(\)) directive(throws) exception(IOException) operator({) - ident(ByteList) ident(result) operator(=) keyword(new) ident(ByteList)operator(()operator(\))operator(;) - type(int) ident(ce) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - keyword(while) operator(()ident(ce) operator(!=) operator(-)integer(1) operator(&&) ident(sep)operator(.)ident(indexOf)operator(()ident(ce)operator(\)) operator(==) operator(-)integer(1)operator(\)) operator({) - ident(result)operator(.)ident(append)operator(()operator(()type(byte)operator(\))ident(ce)operator(\))operator(;) - ident(ce) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - operator(}) - ident(line)operator(++)operator(;) - ident(result)operator(.)ident(append)operator(()ident(sep)operator(\))operator(;) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(result)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(gets)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(writes) operator(=) ident(FrameField)operator(.)ident(LASTLINE)operator(\)) - directive(public) ident(IRubyObject) ident(gets)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - ident(IRubyObject) ident(result) operator(=) ident(internalGets)operator(()ident(args)operator(\))operator(;) - keyword(if) operator(()operator(!)ident(result)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(context)operator(.)ident(getCurrentFrame)operator(()operator(\))operator(.)ident(setLastLine)operator(()ident(result)operator(\))operator(;) - operator(}) - keyword(return) ident(result)operator(;) - operator(}) - - directive(private) directive(final) directive(static) type(int) ident(BUFF_SIZE) operator(=) integer(4096)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(read)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(read)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0) operator(||) ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(ByteList) ident(val) operator(=) keyword(new) ident(ByteList)operator(()integer(10)operator(\))operator(;) - type(byte)type([]) ident(buffer) operator(=) keyword(new) type(byte)operator([)ident(BUFF_SIZE)operator(])operator(;) - type(int) ident(read) operator(=) ident(io)operator(.)ident(read)operator(()ident(buffer)operator(\))operator(;) - keyword(while) operator(()ident(read) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(val)operator(.)ident(append)operator(()ident(buffer)operator(,)integer(0)operator(,)ident(read)operator(\))operator(;) - ident(read) operator(=) ident(io)operator(.)ident(read)operator(()ident(buffer)operator(\))operator(;) - operator(}) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,)ident(val)operator(\))operator(;) - operator(}) - - type(int) ident(len) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(;) - keyword(if) operator(()ident(len) operator(<) integer(0)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newArgumentError)operator(()string<delimiter(")content(negative length )delimiter(")> operator(+) ident(len) operator(+) string<delimiter(")content( given)delimiter(")>operator(\))operator(;) - operator(}) keyword(else) keyword(if) operator(()ident(len) operator(>) integer(0)operator(\)) operator({) - type(byte)type([]) ident(buffer) operator(=) keyword(new) type(byte)operator([)ident(len)operator(])operator(;) - type(int) ident(toRead) operator(=) ident(len)operator(;) - type(int) ident(offset) operator(=) integer(0)operator(;) - type(int) ident(read) operator(=) integer(0)operator(;) - keyword(while) operator(()ident(toRead) operator(>) integer(0)operator(\)) operator({) - ident(read) operator(=) ident(io)operator(.)ident(read)operator(()ident(buffer)operator(,)ident(offset)operator(,)ident(toRead)operator(\))operator(;) - keyword(if) operator(()ident(read) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(break)operator(;) - operator(}) - ident(toRead) operator(-=) ident(read)operator(;) - ident(offset) operator(+=) ident(read)operator(;) - operator(}) comment(// hmm...) - keyword(return) ident(RubyString)operator(.)ident(newString)operator(()ident(getRuntime)operator(()operator(\))operator(,)keyword(new) ident(ByteList)operator(()ident(buffer)operator(,)integer(0)operator(,)ident(len)operator(-)ident(toRead)operator(,)pre_constant(false)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(RubyString)operator(.)ident(newEmptyString)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(lineno=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_lineno)operator(()ident(IRubyObject) ident(lineArg)operator(\)) operator({) - ident(line) operator(=) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(lineArg)operator(\))operator(;) - keyword(return) ident(lineArg)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pos)operator(()operator(\)) operator({) - keyword(return) ident(RubyFixnum)operator(.)ident(zero)operator(()ident(getRuntime)operator(()operator(\))operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readchar)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(readchar)operator(()operator(\)) directive(throws) exception(IOException) operator({) - type(int) ident(value) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - keyword(if) operator(()ident(value) operator(==) operator(-)integer(1)operator(\)) operator({) - keyword(throw) ident(getRuntime)operator(()operator(\))operator(.)ident(newEOFError)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(getc)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(getc)operator(()operator(\)) directive(throws) exception(IOException) operator({) - type(int) ident(value) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - keyword(return) ident(value) operator(==) operator(-)integer(1) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(\))operator(;) - operator(}) - - directive(private) type(boolean) ident(isEof)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) operator(()operator(()pre_type(GZIPInputStream)operator(\))ident(io)operator(\))operator(.)ident(available)operator(()operator(\)) operator(!=) integer(1)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()operator(!)ident(closed)operator(\)) operator({) - ident(io)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(closed) operator(=) pre_constant(true)operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eof)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(eof)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) ident(isEof)operator(()operator(\)) operator(?) ident(getRuntime)operator(()operator(\))operator(.)ident(getTrue)operator(()operator(\)) operator(:) ident(getRuntime)operator(()operator(\))operator(.)ident(getFalse)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(eof?)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(eof_p)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(return) ident(eof)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(unused)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(unused)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tell)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(tell)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - ident(ByteList) ident(sep) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0) operator(&&) operator(!)ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(sep) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - - keyword(while) operator(()operator(!)ident(isEof)operator(()operator(\))operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(internalSepGets)operator(()ident(sep)operator(\))operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(ungetc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(ungetc)operator(()ident(IRubyObject) ident(arg)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(readlines)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(readlines)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - pre_type(List)operator(<)ident(IRubyObject)operator(>) ident(array) operator(=) keyword(new) pre_type(ArrayList)operator(<)ident(IRubyObject)operator(>)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(0) operator(&&) ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(array)operator(.)ident(add)operator(()ident(read)operator(()keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - operator(}) keyword(else) operator({) - ident(ByteList) ident(seperator) operator(=) operator(()operator(()ident(RubyString)operator(\))ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($/)delimiter(")>operator(\))operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(0)operator(\)) operator({) - ident(seperator) operator(=) ident(args)operator([)integer(0)operator(])operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - operator(}) - keyword(while) operator(()operator(!)ident(isEof)operator(()operator(\))operator(\)) operator({) - ident(array)operator(.)ident(add)operator(()ident(internalSepGets)operator(()ident(seperator)operator(\))operator(\))operator(;) - operator(}) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newArray)operator(()ident(array)operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(each_byte)delimiter(")>operator(,) ident(frame) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(each_byte)operator(()ident(ThreadContext) ident(context)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - type(int) ident(value) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - - keyword(while) operator(()ident(value) operator(!=) operator(-)integer(1)operator(\)) operator({) - ident(block)operator(.)ident(yield)operator(()ident(context)operator(,) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(value)operator(\))operator(\))operator(;) - ident(value) operator(=) ident(io)operator(.)ident(read)operator(()operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - operator(}) - - annotation(@JRubyClass)operator(()ident(name)operator(=)string<delimiter(")content(Zlib::GzipWriter)delimiter(")>operator(,) ident(parent)operator(=)string<delimiter(")content(Zlib::GzipFile)delimiter(")>operator(\)) - directive(public) directive(static) type(class) class(RubyGzipWriter) directive(extends) ident(RubyGzipFile) operator({) - directive(protected) directive(static) directive(final) ident(ObjectAllocator) ident(GZIPWRITER_ALLOCATOR) operator(=) keyword(new) ident(ObjectAllocator)operator(()operator(\)) operator({) - directive(public) ident(IRubyObject) ident(allocate)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(klass)operator(\)) operator({) - keyword(return) keyword(new) ident(RubyGzipWriter)operator(()ident(runtime)operator(,) ident(klass)operator(\))operator(;) - operator(}) - operator(})operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(new)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(RubyGzipWriter) ident(newGzipWriter)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(RubyClass) ident(klass) operator(=) operator(()ident(RubyClass)operator(\))ident(recv)operator(;) - - ident(RubyGzipWriter) ident(result) operator(=) operator(()ident(RubyGzipWriter)operator(\))ident(klass)operator(.)ident(allocate)operator(()operator(\))operator(;) - ident(result)operator(.)ident(callInit)operator(()ident(args)operator(,) ident(block)operator(\))operator(;) - keyword(return) ident(result)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(open)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(optional) operator(=) integer(2)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(meta) operator(=) pre_constant(true)operator(\)) - directive(public) directive(static) ident(IRubyObject) ident(open)operator(()directive(final) ident(ThreadContext) ident(context)operator(,) ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) directive(throws) exception(IOException) operator({) - ident(Ruby) ident(runtime) operator(=) ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(;) - ident(IRubyObject) ident(level) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - ident(IRubyObject) ident(strategy) operator(=) ident(runtime)operator(.)ident(getNil)operator(()operator(\))operator(;) - - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(1)operator(\)) operator({) - ident(level) operator(=) ident(args)operator([)integer(1)operator(])operator(;) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(>) integer(2)operator(\)) ident(strategy) operator(=) ident(args)operator([)integer(2)operator(])operator(;) - operator(}) - - ident(IRubyObject) ident(io) operator(=) ident(RuntimeHelpers)operator(.)ident(invoke)operator(()ident(context)operator(,) ident(runtime)operator(.)ident(getFile)operator(()operator(\))operator(,) string<delimiter(")content(open)delimiter(")>operator(,) ident(args)operator([)integer(0)operator(])operator(,) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(wb)delimiter(")>operator(\))operator(\))operator(;) - ident(RubyGzipFile) ident(instance) operator(=) ident(newGzipWriter)operator(()ident(recv)operator(,) keyword(new) ident(IRubyObject)type([])operator({)ident(io)operator(,) ident(level)operator(,) ident(strategy)operator(})operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - - keyword(return) ident(RubyGzipFile)operator(.)ident(wrap)operator(()ident(context)operator(,) ident(instance)operator(,) ident(io)operator(,) ident(block)operator(\))operator(;) - operator(}) - - directive(public) ident(RubyGzipWriter)operator(()ident(Ruby) ident(runtime)operator(,) ident(RubyClass) ident(type)operator(\)) operator({) - local_variable(super)operator(()ident(runtime)operator(,) ident(type)operator(\))operator(;) - operator(}) - - directive(private) pre_type(GZIPOutputStream) ident(io)operator(;) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(initialize)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(,) ident(frame) operator(=) pre_constant(true)operator(,) ident(visibility) operator(=) pre_type(Visibility)operator(.)ident(PRIVATE)operator(\)) - directive(public) ident(IRubyObject) ident(initialize2)operator(()ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) directive(throws) exception(IOException) operator({) - ident(realIo) operator(=) operator(()ident(RubyObject)operator(\))ident(args)operator([)integer(0)operator(])operator(;) - local_variable(this)operator(.)ident(io) operator(=) keyword(new) pre_type(GZIPOutputStream)operator(()keyword(new) ident(IOOutputStream)operator(()ident(args)operator([)integer(0)operator(])operator(\))operator(\))operator(;) - - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(close)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(close)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()operator(!)ident(closed)operator(\)) operator({) - ident(io)operator(.)ident(close)operator(()operator(\))operator(;) - operator(}) - local_variable(this)operator(.)ident(closed) operator(=) pre_constant(true)operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(append)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(append)operator(()ident(IRubyObject) ident(p1)operator(\)) directive(throws) exception(IOException) operator({) - local_variable(this)operator(.)ident(write)operator(()ident(p1)operator(\))operator(;) - keyword(return) local_variable(this)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(printf)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(printf)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - ident(write)operator(()ident(RubyKernel)operator(.)ident(sprintf)operator(()ident(context)operator(,) local_variable(this)operator(,) ident(args)operator(\))operator(\))operator(;) - keyword(return) ident(context)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(print)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(print)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(!=) integer(0)operator(\)) operator({) - keyword(for) operator(()type(int) ident(i) operator(=) integer(0)operator(,) ident(j) operator(=) ident(args)operator(.)ident(length)operator(;) ident(i) operator(<) ident(j)operator(;) ident(i)operator(++)operator(\)) operator({) - ident(write)operator(()ident(args)operator([)ident(i)operator(])operator(\))operator(;) - operator(}) - operator(}) - - ident(IRubyObject) ident(sep) operator(=) ident(getRuntime)operator(()operator(\))operator(.)ident(getGlobalVariables)operator(()operator(\))operator(.)ident(get)operator(()string<delimiter(")content($)char(\\\\)delimiter(")>operator(\))operator(;) - keyword(if) operator(()operator(!)ident(sep)operator(.)ident(isNil)operator(()operator(\))operator(\)) operator({) - ident(write)operator(()ident(sep)operator(\))operator(;) - operator(}) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(pos)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(pos)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(orig_name=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_orig_name)operator(()ident(IRubyObject) ident(ignored)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(comment=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_comment)operator(()ident(IRubyObject) ident(ignored)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(putc)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(putc)operator(()ident(IRubyObject) ident(p1)operator(\)) directive(throws) exception(IOException) operator({) - ident(io)operator(.)ident(write)operator(()ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(p1)operator(\))operator(\))operator(;) - keyword(return) ident(p1)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(puts)delimiter(")>operator(,) ident(rest) operator(=) pre_constant(true)operator(\)) - directive(public) ident(IRubyObject) ident(puts)operator(()ident(ThreadContext) ident(context)operator(,) ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - ident(RubyStringIO) ident(sio) operator(=) operator(()ident(RubyStringIO)operator(\))ident(getRuntime)operator(()operator(\))operator(.)ident(fastGetClass)operator(()string<delimiter(")content(StringIO)delimiter(")>operator(\))operator(.)ident(newInstance)operator(()ident(context)operator(,) keyword(new) ident(IRubyObject)operator([)integer(0)operator(])operator(,) ident(Block)operator(.)ident(NULL_BLOCK)operator(\))operator(;) - ident(sio)operator(.)ident(puts)operator(()ident(context)operator(,) ident(args)operator(\))operator(;) - ident(write)operator(()ident(sio)operator(.)ident(string)operator(()operator(\))operator(\))operator(;) - - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - directive(public) ident(IRubyObject) ident(finish)operator(()operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()operator(!)ident(finished)operator(\)) operator({) - ident(io)operator(.)ident(finish)operator(()operator(\))operator(;) - operator(}) - ident(finished) operator(=) pre_constant(true)operator(;) - keyword(return) ident(realIo)operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(flush)delimiter(")>operator(,) ident(optional) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(flush)operator(()ident(IRubyObject)type([]) ident(args)operator(\)) directive(throws) exception(IOException) operator({) - keyword(if) operator(()ident(args)operator(.)ident(length) operator(==) integer(0) operator(||) ident(args)operator([)integer(0)operator(])operator(.)ident(isNil)operator(()operator(\)) operator(||) ident(RubyNumeric)operator(.)ident(fix2int)operator(()ident(args)operator([)integer(0)operator(])operator(\)) operator(!=) integer(0)operator(\)) operator({) comment(// Zlib::NO_FLUSH) - ident(io)operator(.)ident(flush)operator(()operator(\))operator(;) - operator(}) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(mtime=)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(set_mtime)operator(()ident(IRubyObject) ident(ignored)operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(tell)delimiter(")>operator(\)) - directive(public) ident(IRubyObject) ident(tell)operator(()operator(\)) operator({) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(getNil)operator(()operator(\))operator(;) - operator(}) - - annotation(@JRubyMethod)operator(()ident(name) operator(=) string<delimiter(")content(write)delimiter(")>operator(,) ident(required) operator(=) integer(1)operator(\)) - directive(public) ident(IRubyObject) ident(write)operator(()ident(IRubyObject) ident(p1)operator(\)) directive(throws) exception(IOException) operator({) - ident(ByteList) ident(bytes) operator(=) ident(p1)operator(.)ident(convertToString)operator(()operator(\))operator(.)ident(getByteList)operator(()operator(\))operator(;) - ident(io)operator(.)ident(write)operator(()ident(bytes)operator(.)ident(unsafeBytes)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(begin)operator(()operator(\))operator(,) ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - keyword(return) ident(getRuntime)operator(()operator(\))operator(.)ident(newFixnum)operator(()ident(bytes)operator(.)ident(length)operator(()operator(\))operator(\))operator(;) - operator(}) - operator(}) -operator(}) -comment(/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"\); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C\) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C\) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C\) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C\) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"\), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"\), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/) -keyword(package) namespace(org.jruby)operator(;) - -keyword(import) include(org.jruby.runtime.Arity)operator(;) -keyword(import) include(org.jruby.runtime.Block)operator(;) -keyword(import) include(org.jruby.runtime.builtin.IRubyObject)operator(;) -keyword(import) include(org.jruby.runtime.callback.Callback)operator(;) - -comment(/** - * - * @author jpetersen - */) -directive(public) directive(final) type(class) class(TopSelfFactory) operator({) - - comment(/** - * Constructor for TopSelfFactory. - */) - directive(private) ident(TopSelfFactory)operator(()operator(\)) operator({) - local_variable(super)operator(()operator(\))operator(;) - operator(}) - - directive(public) directive(static) ident(IRubyObject) ident(createTopSelf)operator(()directive(final) ident(Ruby) ident(runtime)operator(\)) operator({) - ident(IRubyObject) ident(topSelf) operator(=) keyword(new) ident(RubyObject)operator(()ident(runtime)operator(,) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(\))operator(;) - - ident(topSelf)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastMethod)operator(()string<delimiter(")content(to_s)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - comment(/** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]\) - */) - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(newString)operator(()string<delimiter(")content(main)delimiter(")>operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.callback.Callback#getArity(\) - */) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(noArguments)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - comment(// The following three methods must be defined fast, since they expect to modify the current frame) - comment(// (i.e. they expect no frame will be allocated for them\). JRUBY-1185.) - ident(topSelf)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastPrivateMethod)operator(()string<delimiter(")content(include)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - comment(/** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]\) - */) - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(block)operator(\)) operator({) - ident(runtime)operator(.)ident(secure)operator(()integer(4)operator(\))operator(;) - keyword(return) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(include)operator(()ident(args)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.callback.Callback#getArity(\) - */) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(optional)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - ident(topSelf)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastPrivateMethod)operator(()string<delimiter(")content(public)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - comment(/** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]\) - */) - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(rbPublic)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.callback.Callback#getArity(\) - */) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(optional)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - ident(topSelf)operator(.)ident(getSingletonClass)operator(()operator(\))operator(.)ident(defineFastPrivateMethod)operator(()string<delimiter(")content(private)delimiter(")>operator(,) keyword(new) pre_type(Callback)operator(()operator(\)) operator({) - comment(/** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]\) - */) - directive(public) ident(IRubyObject) ident(execute)operator(()ident(IRubyObject) ident(recv)operator(,) ident(IRubyObject)type([]) ident(args)operator(,) ident(Block) ident(unusedBlock)operator(\)) operator({) - keyword(return) ident(runtime)operator(.)ident(getObject)operator(()operator(\))operator(.)ident(rbPrivate)operator(()ident(recv)operator(.)ident(getRuntime)operator(()operator(\))operator(.)ident(getCurrentContext)operator(()operator(\))operator(,) ident(args)operator(\))operator(;) - operator(}) - - comment(/** - * @see org.jruby.runtime.callback.Callback#getArity(\) - */) - directive(public) ident(Arity) ident(getArity)operator(()operator(\)) operator({) - keyword(return) ident(Arity)operator(.)ident(optional)operator(()operator(\))operator(;) - operator(}) - operator(})operator(\))operator(;) - - keyword(return) ident(topSelf)operator(;) - operator(}) -operator(}) diff --git a/test/scanners/java/jruby.in.java b/test/scanners/java/jruby.in.java deleted file mode 100644 index 538abfa..0000000 --- a/test/scanners/java/jruby.in.java +++ /dev/null @@ -1,51193 +0,0 @@ -package org.jruby; - -public enum CompatVersion { - - RUBY1_8, RUBY1_9, BOTH; - - public static CompatVersion getVersionFromString(String compatString) { - if (compatString.equalsIgnoreCase("RUBY1_8")) { - return CompatVersion.RUBY1_8; - } else if (compatString.equalsIgnoreCase("RUBY1_9")) { - return CompatVersion.RUBY1_9; - } else { - return null; - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Damian Steer <pldms@mac.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -/** - * An almost entirely useless interface for those objects that we _really_ want - * to finalise. - * - * @author pldms - * - */ -public interface Finalizable { - public void finalize(); -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; -/** - * Error numbers. - * @fixme - * this interface is a big hack defining a bunch of arbitrary valor as system call error numbers - * this is actually because I need them but will probably need to be changed to something smarter - * sooner or later. - * The purpose of this class it to help implement the Errno module which in turn in needed by rubicon. - * @author Benoit Cerrina - **/ -public interface IErrno -{ - int EPERM = 1; - int ENOENT = 2; - int ESRCH = 3; - int EINTR = 4; - int EIO = 5; - int ENXIO = 6; - int E2BIG = 7; - int ENOEXEC = 8; - int EBADF = 9; - int ECHILD = 10; - int EDEADLK = 11; - int ENOMEM = 12; - int EACCES = 13; - int EFAULT = 14; - int ENOTBLK = 15; - int EBUSY = 16; - int EEXIST = 17; - int EXDEV = 18; - int ENODEV = 19; - int ENOTDIR = 20; - int EISDIR = 21; - int EINVAL = 22; - int ENFILE = 23; - int EMFILE = 24; - int ENOTTY = 25; - int ETXTBSY = 26; - int EFBIG = 27; - int ENOSPC = 28; - int ESPIPE = 29; - int EROFS = 30; - int EMLINK = 31; - int EPIPE = 32; - int EDOM = 33; - int ERANGE = 34; - int EWOULDBLOCK = 35; - int EAGAIN = 35; - int EINPROGRESS = 36; - int EALREADY = 37; - int ENOTSOCK = 38; - int EDESTADDRREQ = 39; - int EMSGSIZE = 40; - int EPROTOTYPE = 41; - int ENOPROTOOPT = 42; - int EPROTONOSUPPORT = 43; - int ESOCKTNOSUPPORT = 44; - int EOPNOTSUPP = 45; - int EPFNOSUPPORT = 46; - int EAFNOSUPPORT = 47; - int EADDRINUSE = 48; - int EADDRNOTAVAIL = 49; - int ENETDOWN = 50; - int ENETUNREACH = 51; - int ENETRESET = 52; - int ECONNABORTED = 53; - int ECONNRESET = 54; - int ENOBUFS = 55; - int EISCONN = 56; - int ENOTCONN = 57; - int ESHUTDOWN = 58; - int ETOOMANYREFS = 59; - int ETIMEDOUT = 60; - int ECONNREFUSED = 61; - int ELOOP = 62; - int ENAMETOOLONG = 63; - int EHOSTDOWN = 64; - int EHOSTUNREACH = 65; - int ENOTEMPTY = 66; - int EUSERS = 68; - int EDQUOT = 69; - int ESTALE = 70; - int EREMOTE = 71; - int ENOLCK = 77; - int ENOSYS = 78; - int EOVERFLOW = 84; - int EIDRM = 90; - int ENOMSG = 91; - int EILSEQ = 92; - int EBADMSG = 94; - int EMULTIHOP = 95; - int ENODATA = 96; - int ENOLINK = 97; - int ENOSR = 98; - int ENOSTR = 99; - int EPROTO = 100; - int ETIME = 101; - int EOPNOTSUPP_DARWIN = 102; -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.List; -import java.util.Map; - -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; - -/** - * This class is used to provide an intermediate superclass for modules and classes that include - * other modules. It inserts itself as the immediate superClass of the includer, but defers all - * module methods to the actual superclass. Multiple of these intermediate superclasses can be - * added for multiple included modules. - * - * This allows the normal superclass-based searches (searchMethod, getConstant, etc) to traverse - * the superclass ancestors as normal while the included modules do not actually show up in - * direct inheritance traversal. - * - * @see org.jruby.RubyModule - */ -public final class IncludedModuleWrapper extends RubyClass { - private final RubyModule delegate; - - public IncludedModuleWrapper(Ruby runtime, RubyClass superClass, RubyModule delegate) { - super(runtime, superClass, false); - this.delegate = delegate; - this.metaClass = delegate.metaClass; - } - - /** - * Overridden newIncludeClass implementation to allow attaching future includes to the correct module - * (i.e. the one to which this is attached) - * - * @see org.jruby.RubyModule#newIncludeClass(RubyClass) - */ - @Override - public IncludedModuleWrapper newIncludeClass(RubyClass superClass) { - IncludedModuleWrapper includedModule = new IncludedModuleWrapper(getRuntime(), superClass, getNonIncludedClass()); - - // include its parent (and in turn that module's parents) - if (getSuperClass() != null) { - includedModule.includeModule(getSuperClass()); - } - - return includedModule; - } - - @Override - public boolean isModule() { - return false; - } - - @Override - public boolean isClass() { - return false; - } - - @Override - public boolean isIncluded() { - return true; - } - - @Override - public boolean isImmediate() { - return true; - } - - @Override - public void setMetaClass(RubyClass newRubyClass) { - throw new UnsupportedOperationException("An included class is only a wrapper for a module"); - } - - @Override - public Map<String, DynamicMethod> getMethods() { - return delegate.getMethods(); - } - - @Override - public void addMethod(String name, DynamicMethod method) { - throw new UnsupportedOperationException("An included class is only a wrapper for a module"); - } - - public void setMethods(Map newMethods) { - throw new UnsupportedOperationException("An included class is only a wrapper for a module"); - } - - @Override - public String getName() { - return delegate.getName(); - } - - @Override - public RubyModule getNonIncludedClass() { - return delegate; - } - - @Override - public RubyClass getRealClass() { - return getSuperClass().getRealClass(); - } - - @Override - protected boolean isSame(RubyModule module) { - return delegate.isSame(module); - } - - /** - * We don't want to reveal ourselves to Ruby code, so delegate this - * operation. - */ - @Override - public IRubyObject id() { - return delegate.id(); - } - - // - // VARIABLE TABLE METHODS - pass to delegate - // - - @Override - protected boolean variableTableContains(String name) { - return delegate.variableTableContains(name); - } - - @Override - protected boolean variableTableFastContains(String internedName) { - return delegate.variableTableFastContains(internedName); - } - - @Override - protected IRubyObject variableTableFetch(String name) { - return delegate.variableTableFetch(name); - } - - @Override - protected IRubyObject variableTableFastFetch(String internedName) { - return delegate.variableTableFastFetch(internedName); - } - - @Override - protected IRubyObject variableTableStore(String name, IRubyObject value) { - return delegate.variableTableStore(name, value); - } - - @Override - protected IRubyObject variableTableFastStore(String internedName, IRubyObject value) { - return delegate.variableTableFastStore(internedName, value); - } - - @Override - protected IRubyObject variableTableRemove(String name) { - return delegate.variableTableRemove(name); - } - - @Override - protected VariableTableEntry[] variableTableGetTable() { - return delegate.variableTableGetTable(); - } - - @Override - protected int variableTableGetSize() { - return delegate.variableTableGetSize(); - } - - @Override - protected void variableTableSync(List<Variable<IRubyObject>> vars) { - delegate.variableTableSync(vars); - } - - @Override - protected IRubyObject variableTableReadLocked(VariableTableEntry entry) { - return delegate.variableTableReadLocked(entry); - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated // born deprecated - protected Map variableTableGetMap() { - return delegate.variableTableGetMap(); - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated // born deprecated - protected Map variableTableGetMap(Map map) { - return delegate.variableTableGetMap(map); - } - - // - // CONSTANT TABLE METHODS - pass to delegate - // - - @Override - protected boolean constantTableContains(String name) { - return delegate.constantTableContains(name); - } - - @Override - protected boolean constantTableFastContains(String internedName) { - return delegate.constantTableFastContains(internedName); - } - - @Override - protected IRubyObject constantTableFetch(String name) { - return delegate.constantTableFetch(name); - } - - @Override - protected IRubyObject constantTableFastFetch(String internedName) { - return delegate.constantTableFastFetch(internedName); - } - - @Override - protected IRubyObject constantTableStore(String name, IRubyObject value) { - // FIXME: legal here? may want UnsupportedOperationException - return delegate.constantTableStore(name, value); - } - - @Override - protected IRubyObject constantTableFastStore(String internedName, IRubyObject value) { - // FIXME: legal here? may want UnsupportedOperationException - return delegate.constantTableFastStore(internedName, value); - } - - @Override - protected IRubyObject constantTableRemove(String name) { - // this _is_ legal (when removing an undef) - return delegate.constantTableRemove(name); - } - - @Override - protected ConstantTableEntry[] constantTableGetTable() { - return delegate.constantTableGetTable(); - } - - @Override - protected int constantTableGetSize() { - return delegate.constantTableGetSize(); - } - - @Override - protected void constantTableSync(List<Variable<IRubyObject>> vars) { - // FIXME: legal here? may want UnsupportedOperationException - delegate.constantTableSync(vars); - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated // born deprecated - protected Map constantTableGetMap() { - return delegate.constantTableGetMap(); - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - @Override - @Deprecated // born deprecated - protected Map constantTableGetMap(Map map) { - return delegate.constantTableGetMap(map); - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Charles Nutter <charles.o.nutter@sun.com> - * Copyright (C) 2008 MenTaLguY <mental@rydia.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.applet.Applet; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Container; -import java.awt.EventQueue; -import java.awt.Font; -import java.awt.Insets; -import java.awt.Graphics; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsEnvironment; -import java.awt.image.VolatileImage; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.net.URL; -import java.util.Arrays; - -import java.lang.reflect.InvocationTargetException; - -import org.jruby.anno.JRubyMethod; -import org.jruby.demo.TextAreaReadline; -import org.jruby.javasupport.JavaUtil; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -import javax.swing.JScrollPane; -import javax.swing.JTextPane; - -/** - * @author <a href="mailto:mental@rydia.net">MenTaLguY</a> - * - * The JRubyApplet class provides a simple way to write Java applets using - * JRuby without needing to create a custom Java applet class. At applet - * initialization time, JRubyApplet starts up a JRuby runtime, then evaluates - * the scriptlet given as the "eval" applet parameter. - * - * The Java applet instance is available to the Ruby script as - * JRUBY_APPLET; the script can define callbacks for applet start, stop, - * and destroy by passing blocks to JRUBY_APPLET.on_start, - * JRUBY_APPLET.on_stop, and JRUBY_APPLET.on_destroy, respectively. - * - * Ruby code can install a custom paint callback using JRUBY_APPLET.on_paint - * (the Graphics2D object is passed as an argument to the callback). By - * default, JRubyApplet painting is double-buffered, but you can select - * single-buffered painting via JRUBY_APPLET.double_buffered = false. - * - * The applet's background color can be set via JRUBY_APPLET.background_color=. - * You may want to set it to nil if you're not using double-buffering, so that - * no background color will be drawn (your own paint code is then responsible - * for filling the area). - * - * Beyond these things, you should be able to use JRuby's Java integration - * to do whatever you would do in Java with the applet instance. - * - */ -public class JRubyApplet extends Applet { - private Ruby runtime; - private boolean doubleBuffered = true; - private Color backgroundColor = Color.WHITE; - private RubyProc startProc; - private RubyProc stopProc; - private RubyProc destroyProc; - private RubyProc paintProc; - private Graphics priorGraphics; - private IRubyObject wrappedGraphics; - private VolatileImage backBuffer; - private Graphics backBufferGraphics; - private Facade facade; - - private interface Facade { - public InputStream getInputStream(); - public PrintStream getOutputStream(); - public PrintStream getErrorStream(); - public void attach(Ruby runtime, Applet applet); - public void destroy(); - } - - private static RubyProc blockToProc(Ruby runtime, Block block) { - if (block.isGiven()) { - RubyProc proc = block.getProcObject(); - if (proc == null) { - proc = RubyProc.newProc(runtime, block, block.type); - } - return proc; - } else { - return null; - } - } - - private boolean getBooleanParameter(String name, boolean defaultValue) { - String value = getParameter(name); - if ( value != null ) { - return value.equals("true"); - } else { - return defaultValue; - } - } - - private InputStream getCodeResourceAsStream(String name) { - if (name == null) { - return null; - } - try { - final URL directURL = new URL(getCodeBase(), name); - return directURL.openStream(); - } catch (IOException e) { - } - return JRubyApplet.class.getClassLoader().getResourceAsStream(name); - } - - private static void safeInvokeAndWait(Runnable runnable) throws InvocationTargetException, InterruptedException { - if (EventQueue.isDispatchThread()) { - try { - runnable.run(); - } catch (Exception e) { - throw new InvocationTargetException(e); - } - } else { - EventQueue.invokeAndWait(runnable); - } - } - - public static class RubyMethods { - @JRubyMethod - public static IRubyObject on_start(IRubyObject recv, Block block) { - JRubyApplet applet = (JRubyApplet)recv.dataGetStruct(); - synchronized (applet) { - applet.startProc = blockToProc(applet.runtime, block); - } - return recv; - } - - @JRubyMethod - public static IRubyObject on_stop(IRubyObject recv, Block block) { - JRubyApplet applet = (JRubyApplet)recv.dataGetStruct(); - synchronized (applet) { - applet.stopProc = blockToProc(applet.runtime, block); - } - return recv; - } - - @JRubyMethod - public static IRubyObject on_destroy(IRubyObject recv, Block block) { - JRubyApplet applet = (JRubyApplet)recv.dataGetStruct(); - synchronized (applet) { - applet.destroyProc = blockToProc(applet.runtime, block); - } - return recv; - } - - @JRubyMethod - public static IRubyObject on_paint(IRubyObject recv, Block block) { - JRubyApplet applet = (JRubyApplet)recv.dataGetStruct(); - synchronized (applet) { - applet.paintProc = blockToProc(applet.runtime, block); - applet.repaint(); - } - return recv; - } - } - - @Override - public void init() { - super.init(); - - if (getBooleanParameter("jruby.console", false)) { - facade = new ConsoleFacade(getParameter("jruby.banner")); - } else { - facade = new TrivialFacade(); - } - - synchronized (this) { - if (runtime != null) { - return; - } - - final RubyInstanceConfig config = new RubyInstanceConfig() {{ - setInput(facade.getInputStream()); - setOutput(facade.getOutputStream()); - setError(facade.getErrorStream()); - setObjectSpaceEnabled(getBooleanParameter("jruby.objectspace", false)); - }}; - Ruby.setSecurityRestricted(true); - runtime = Ruby.newInstance(config); - } - - final String scriptName = getParameter("jruby.script"); - final InputStream scriptStream = getCodeResourceAsStream(scriptName); - final String evalString = getParameter("jruby.eval"); - - try { - final JRubyApplet applet = this; - safeInvokeAndWait(new Runnable() { - public void run() { - applet.setLayout(new BorderLayout()); - applet.facade.attach(applet.runtime, applet); - if (scriptStream != null) { - applet.runtime.runFromMain(scriptStream, scriptName); - } - if (evalString != null) { - applet.runtime.evalScriptlet(evalString); - } - } - }); - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - throw new RuntimeException("Error running script", e.getCause()); - } - } - - private void invokeCallback(final RubyProc proc, final IRubyObject[] args) { - if (proc == null) { - return; - } - final Ruby runtime = this.runtime; - try { - safeInvokeAndWait(new Runnable() { - public void run() { - ThreadContext context = runtime.getCurrentContext(); - proc.call(context, args); - } - }); - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - throw new RuntimeException("Ruby callback failed", e.getCause()); - } - } - - public synchronized void setBackgroundColor(Color color) { - backgroundColor = color; - repaint(); - } - - public synchronized Color getBackgroundColor() { - return backgroundColor; - } - - public synchronized boolean isDoubleBuffered() { - return doubleBuffered; - } - - public synchronized void setDoubleBuffered(boolean shouldBuffer) { - doubleBuffered = shouldBuffer; - repaint(); - } - - @Override - public synchronized void start() { - super.start(); - invokeCallback(startProc, new IRubyObject[] {}); - } - - @Override - public synchronized void stop() { - invokeCallback(stopProc, new IRubyObject[] {}); - super.stop(); - } - - @Override - public synchronized void destroy() { - try { - invokeCallback(destroyProc, new IRubyObject[] {}); - } finally { - facade.destroy(); - final Ruby runtime = this.runtime; - this.runtime = null; - startProc = null; - stopProc = null; - destroyProc = null; - paintProc = null; - priorGraphics = null; - wrappedGraphics = null; - runtime.tearDown(); - super.destroy(); - } - } - - @Override - public void update(Graphics g) { - paint(g); - } - - @Override - public synchronized void paint(Graphics g) { - if (doubleBuffered) { - paintBuffered(g); - } else { - paintUnbuffered(g); - } - } - - private synchronized void paintBuffered(Graphics g) { - do { - GraphicsConfiguration config = getGraphicsConfiguration(); - int width = getWidth(); - int height = getHeight(); - if (backBuffer == null || width != backBuffer.getWidth() || height != backBuffer.getHeight() || backBuffer.validate(config) == VolatileImage.IMAGE_INCOMPATIBLE) { - if (backBuffer != null) { - backBufferGraphics.dispose(); - backBufferGraphics = null; - backBuffer.flush(); - backBuffer = null; - } - backBuffer = config.createCompatibleVolatileImage(width, height); - backBufferGraphics = backBuffer.createGraphics(); - } - backBufferGraphics.setClip(g.getClip()); - paintUnbuffered(backBufferGraphics); - g.drawImage(backBuffer, 0, 0, this); - } while (backBuffer.contentsLost()); - } - - private synchronized void paintUnbuffered(Graphics g) { - if (backgroundColor != null) { - g.setColor(backgroundColor); - g.fillRect(0, 0, getWidth(), getHeight()); - } - if (paintProc != null) { - if (priorGraphics != g) { - wrappedGraphics = JavaUtil.convertJavaToUsableRubyObject(runtime, g); - priorGraphics = g; - } - ThreadContext context = runtime.getCurrentContext(); - paintProc.call(context, new IRubyObject[] {wrappedGraphics}); - } - super.paint(g); - } - - private static class TrivialFacade implements Facade { - public TrivialFacade() {} - public InputStream getInputStream() { return System.in; } - public PrintStream getOutputStream() { return System.out; } - public PrintStream getErrorStream() { return System.err; } - public void attach(Ruby runtime, Applet applet) { - final IRubyObject wrappedApplet = JavaUtil.convertJavaToUsableRubyObject(runtime, applet); - wrappedApplet.dataWrapStruct(applet); - runtime.defineGlobalConstant("JRUBY_APPLET", wrappedApplet); - wrappedApplet.getMetaClass().defineAnnotatedMethods(RubyMethods.class); - } - public void destroy() {} - } - - private static class ConsoleFacade implements Facade { - private JTextPane textPane; - private JScrollPane scrollPane; - private TextAreaReadline adaptor; - private InputStream inputStream; - private PrintStream outputStream; - private PrintStream errorStream; - - public ConsoleFacade(String bannerText) { - textPane = new JTextPane(); - textPane.setMargin(new Insets(4, 4, 0, 4)); - textPane.setCaretColor(new Color(0xa4, 0x00, 0x00)); - textPane.setBackground(new Color(0xf2, 0xf2, 0xf2)); - textPane.setForeground(new Color(0xa4, 0x00, 0x00)); - - Font font = findFont("Monospaced", Font.PLAIN, 14, - new String[] {"Monaco", "Andale Mono"}); - - textPane.setFont(font); - - scrollPane = new JScrollPane(textPane); - scrollPane.setDoubleBuffered(true); - if ( bannerText != null ) { - bannerText = " " + bannerText + " \n\n"; - } - adaptor = new TextAreaReadline(textPane, bannerText); - inputStream = adaptor.getInputStream(); - outputStream = new PrintStream(adaptor.getOutputStream()); - errorStream = new PrintStream(adaptor.getOutputStream()); - } - - public InputStream getInputStream() { return inputStream; } - public PrintStream getOutputStream() { return outputStream; } - public PrintStream getErrorStream() { return errorStream; } - - public void attach(Ruby runtime, Applet applet) { - adaptor.hookIntoRuntime(runtime); - applet.add(scrollPane); - applet.validate(); - } - - public void destroy() { - Container parent = scrollPane.getParent(); - adaptor.shutdown(); - if (parent != null) { - parent.remove(scrollPane); - } - } - - private Font findFont(String otherwise, int style, int size, String[] families) { - String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - Arrays.sort(fonts); - for (int i = 0; i < families.length; i++) { - if (Arrays.binarySearch(fonts, families[i]) >= 0) { - return new Font(families[i], style, size); - } - } - return new Font(otherwise, style, size); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.BufferedWriter; -import java.io.OutputStreamWriter; - -import java.net.InetAddress; -import java.net.Socket; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -public class JRubyClient extends JRubyService { - public JRubyClient(String[] args) throws Exception { - Configuration conf = new Configuration(args[0]); - if(conf.isDebug()) { - System.err.println("Starting client with port " + conf.getPort() + ", key " + conf.getKey() + " and command " + conf.getCommand()); - } - Socket socket = new Socket(InetAddress.getLocalHost(), conf.getPort()); - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); - if(conf.terminate()) { - writer.write(CMD_TERM + " " + conf.getKey() + "\n"); - } else if(conf.noMore()) { - writer.write(CMD_NO_MORE + " " + conf.getKey() + "\n"); - } else { - writer.write(CMD_START + " " + conf.getKey() + " " + conf.getCommand() + "\n"); - } - writer.flush(); - writer.close(); - socket.close(); - } - - public static void main(String[] args) throws Exception { - new JRubyClient(args); - } -}// JRubyClient -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.BufferedReader; -import java.io.InputStreamReader; - -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; - -import java.util.List; -import java.util.ArrayList; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -public class JRubyServer extends JRubyService { - private Configuration conf; - - private boolean stillStarting = true; - - private JRubyServer(String[] args) throws Exception { - conf = new Configuration(args[0]); - if(conf.isDebug()) { - System.err.println("Starting server with port " + conf.getPort() + " and key " + conf.getKey()); - } - ServerSocket server = new ServerSocket(); - server.bind(new InetSocketAddress(InetAddress.getLocalHost(),conf.getPort())); - while(true) { - Thread t1 = new Thread(new Handler(server.accept())); - t1.setDaemon(true); - t1.start(); - } - } - - private class Handler implements Runnable { - private Socket socket; - - public Handler(Socket socket) { - this.socket = socket; - } - - public void run() { - try { - BufferedReader rr = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); - String command = rr.readLine(); - rr.close(); - this.socket.close(); - this.socket = null; - if(conf.isDebug()) { - System.err.println("Got command: " + command); - } - String[] cmds = command.split(" ", 3); - if(cmds[1].equals(conf.getKey())) { - if(cmds[0].equals(CMD_TERM)) { - if(conf.isDebug()) { - System.err.println("Terminating hard"); - } - System.exit(0); - } else if(cmds[0].equals(CMD_NO_MORE)) { - if(conf.isDebug()) { - System.err.println("Accepting no more START"); - } - stillStarting = false; - } else if(cmds[0].equals(CMD_START)) { - if(stillStarting) { - if(conf.isDebug()) { - System.err.println("Doing START on command " + cmds[2]); - } - new Main().run(intoCommandArguments(cmds[2].trim())); - } else { - if(conf.isDebug()) { - System.err.println("Not doing START anymore, invalid command"); - } - } - } else { - if(conf.isDebug()) { - System.err.println("Unrecognized command"); - } - } - } else { - if(conf.isDebug()) { - System.err.println("Invalid key"); - } - } - } catch(Exception e) {} - } - } - - protected static String[] intoCommandArguments(String str) { - List<String> args = new ArrayList<String>(); - boolean inSingle = false; - int contentStart = -1; - - for(int i=0,j=str.length();i<j;i++) { - if(str.charAt(i) == ' ' && !inSingle && contentStart != -1) { - args.add(str.substring(contentStart,i)); - contentStart = -1; - continue; - } - if(str.charAt(i) == ' ') { - continue; - } - if(str.charAt(i) == '\'' && !inSingle) { - inSingle = true; - contentStart = i+1; - continue; - } - if(str.charAt(i) == '\'') { - inSingle = false; - args.add(str.substring(contentStart,i)); - contentStart = -1; - continue; - } - if(contentStart == -1) { - contentStart = i; - } - } - if(contentStart != -1) { - args.add(str.substring(contentStart)); - } - return (String[])args.toArray(new String[0]); - } - - public static void main(String[] args) throws Exception { - new JRubyServer(args); - } -}// JRubyServer -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -public abstract class JRubyService { - protected static class Configuration { - private final static int DEFAULT_PORT = 19222; - - private String key; - private int port = DEFAULT_PORT; - private boolean terminate; - private boolean noMore; - private boolean debug; - private String command; - - public Configuration(String args) { - int i=0; - int stop; - loop: for(int j=args.length();i<j;i++) { - if(args.charAt(i) == '-' && i+1 < j) { - switch(args.charAt(++i)) { - case 'k': - stop = args.indexOf(" ", (++i) + 1); - if(stop == -1) { - stop = args.length(); - } - key = args.substring(i, stop).trim(); - i = stop; - break; - case 'p': - stop = args.indexOf(" ", (++i) + 1); - if(stop == -1) { - stop = args.length(); - } - port = Integer.parseInt(args.substring(i, stop).trim()); - i = stop; - break; - case 't': - terminate = true; - i++; - break; - case 'n': - noMore = true; - i++; - break; - case 'd': - debug = true; - i++; - break; - case '-': // handle everything after -- as arguments to the jruby process - i++; - break loop; - default: - i--; - break loop; - } - } else if(args.charAt(i) != ' ') { - break loop; - } - } - if(i<args.length()) { - command = args.substring(i).trim(); - } - } - - public String getKey() { - return key; - } - - public int getPort() { - return port; - } - - public boolean terminate() { - return terminate; - } - - public boolean noMore() { - return noMore; - } - - public boolean isDebug() { - return debug; - } - - public String getCommand() { - return command; - } - } - - public static final String CMD_START = "START"; - public static final String CMD_NO_MORE = "NO_MORE"; - public static final String CMD_TERM = "TERM"; -}// JRubyService -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2006 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Kiel Hodges <jruby-devel@selfsosoft.com> - * Copyright (C) 2005 Jason Voegele <jason@jvoegele.com> - * Copyright (C) 2005 Tim Azzopardi <tim@tigerfive.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.InputStream; -import java.io.PrintStream; - -import org.jruby.exceptions.MainExitException; -import org.jruby.exceptions.RaiseException; -import org.jruby.exceptions.ThreadKill; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.SafePropertyAccessor; -import org.jruby.util.SimpleSampler; - -/** - * Class used to launch the interpreter. - * This is the main class as defined in the jruby.mf manifest. - * It is very basic and does not support yet the same array of switches - * as the C interpreter. - * Usage: java -jar jruby.jar [switches] [rubyfile.rb] [arguments] - * -e 'command' one line of script. Several -e's allowed. Omit [programfile] - * @author jpetersen - */ -public class Main { - private boolean hasPrintedUsage = false; - private final RubyInstanceConfig config; - - public Main(RubyInstanceConfig config) { - this.config = config; - } - - public Main(final InputStream in, final PrintStream out, final PrintStream err) { - this(new RubyInstanceConfig(){{ - setInput(in); - setOutput(out); - setError(err); - }}); - } - - public Main() { - this(new RubyInstanceConfig()); - } - - public static void main(String[] args) { - Main main = new Main(); - - try { - int status = main.run(args); - if (status != 0) { - System.exit(status); - } - } catch (RaiseException re) { - throw re; - } catch (Throwable t) { - // print out as a nice Ruby backtrace - System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t)); - System.exit(1); - } - } - - public int run(String[] args) { - try { - config.processArguments(args); - return run(); - } catch (MainExitException mee) { - if (!mee.isAborted()) { - config.getOutput().println(mee.getMessage()); - if (mee.isUsageError()) { - printUsage(); - } - } - return mee.getStatus(); - } catch (OutOfMemoryError oome) { - // produce a nicer error since Rubyists aren't used to seeing this - System.gc(); - - String memoryMax = SafePropertyAccessor.getProperty("jruby.memory.max"); - String message = ""; - if (memoryMax != null) { - message = " of " + memoryMax; - } - System.err.println("Error: Your application used more memory than the safety cap" + message + "."); - System.err.println("Specify -J-Xmx####m to increase it (#### = cap size in MB)."); - - if (config.getVerbose()) { - System.err.println("Exception trace follows:"); - oome.printStackTrace(); - } else { - System.err.println("Specify -w for full OutOfMemoryError stack trace"); - } - return 1; - } catch (StackOverflowError soe) { - // produce a nicer error since Rubyists aren't used to seeing this - System.gc(); - - String stackMax = SafePropertyAccessor.getProperty("jruby.stack.max"); - String message = ""; - if (stackMax != null) { - message = " of " + stackMax; - } - System.err.println("Error: Your application used more stack memory than the safety cap" + message + "."); - System.err.println("Specify -J-Xss####k to increase it (#### = cap size in KB)."); - - if (config.getVerbose()) { - System.err.println("Exception trace follows:"); - soe.printStackTrace(); - } else { - System.err.println("Specify -w for full StackOverflowError stack trace"); - } - return 1; - } catch (UnsupportedClassVersionError ucve) { - System.err.println("Error: Some library (perhaps JRuby) was built with a later JVM version."); - System.err.println("Please use libraries built with the version you intend to use or an earlier one."); - - if (config.getVerbose()) { - System.err.println("Exception trace follows:"); - ucve.printStackTrace(); - } else { - System.err.println("Specify -w for full UnsupportedClassVersionError stack trace"); - } - return 1; - } catch (ThreadKill kill) { - return 0; - } - } - - public int run() { - if (config.isShowVersion()) { - showVersion(); - } - - if (config.isShowCopyright()) { - showCopyright(); - } - - if (!config.shouldRunInterpreter() ) { - if (config.shouldPrintUsage()) { - printUsage(); - } - if (config.shouldPrintProperties()) { - printProperties(); - } - return 0; - } - - InputStream in = config.getScriptSource(); - String filename = config.displayedFileName(); - Ruby runtime = Ruby.newInstance(config); - - // set thread context JRuby classloader here, for the main thread - try { - Thread.currentThread().setContextClassLoader(runtime.getJRubyClassLoader()); - } catch (SecurityException se) { - // can't set TC classloader - if (runtime.getInstanceConfig().isVerbose()) { - System.err.println("WARNING: Security restrictions disallowed setting context classloader for main thread."); - } - } - - if (in == null) { - // no script to run, return success below - } else if (config.isShouldCheckSyntax()) { - runtime.parseFromMain(in, filename); - config.getOutput().println("Syntax OK"); - } else { - long now = -1; - - try { - if (config.isBenchmarking()) { - now = System.currentTimeMillis(); - } - - if (config.isSamplingEnabled()) { - SimpleSampler.startSampleThread(); - } - - try { - runtime.runFromMain(in, filename); - } finally { - runtime.tearDown(); - - if (config.isBenchmarking()) { - config.getOutput().println("Runtime: " + (System.currentTimeMillis() - now) + " ms"); - } - - if (config.isSamplingEnabled()) { - org.jruby.util.SimpleSampler.report(); - } - } - } catch (RaiseException rj) { - RubyException raisedException = rj.getException(); - if (runtime.getSystemExit().isInstance(raisedException)) { - IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "status"); - - if (status != null && !status.isNil()) { - return RubyNumeric.fix2int(status); - } - } else { - runtime.printError(raisedException); - return 1; - } - } - } - return 0; - } - - private void showVersion() { - config.getOutput().print(config.getVersionString()); - } - - private void showCopyright() { - config.getOutput().print(config.getCopyrightString()); - } - - public void printUsage() { - if (!hasPrintedUsage) { - config.getOutput().print(config.getBasicUsageHelp()); - hasPrintedUsage = true; - } - } - - public void printProperties() { - config.getOutput().print(config.getPropertyHelp()); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.ref.SoftReference; - -import org.jruby.runtime.builtin.IRubyObject; - -public final class MetaClass extends RubyClass { - - private SoftReference<IRubyObject> attached = new SoftReference<IRubyObject>(null); - - /** NEWOBJ (in RubyObject#getSingletonClassClone()) - * - */ - public MetaClass(Ruby runtime) { - super(runtime, null, false); - } - - /** rb_class_boot (for MetaClasses) (in makeMetaClass(RubyClass)) - * - */ - public MetaClass(Ruby runtime, RubyClass superClass) { - super(runtime, superClass, false); - index = superClass.index; // use same ClassIndex as metaclass, since we're technically still of that type - } - - public boolean isSingleton() { - return true; - } - - /** - * If an object uses an anonymous class 'class << obj', then this grabs the original - * metaclass and not the one that get injected as a result of 'class << obj'. - */ - public RubyClass getRealClass() { - return superClass.getRealClass(); - } - - public final IRubyObject allocate(){ - throw getRuntime().newTypeError("can't create instance of virtual class"); - } - - public IRubyObject getAttached() { - return attached.get(); - } - - public void setAttached(IRubyObject attached) { - this.attached = new SoftReference<IRubyObject>(attached); - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2005 David Corbin <dcorbin@users.sourceforge.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.PrintStream; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.javasupport.Java; -import org.jruby.javasupport.JavaObject; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyClass(name = "NativeException", parent = "RuntimeError") -public class NativeException extends RubyException { - - private final Throwable cause; - public static final String CLASS_NAME = "NativeException"; - private final Ruby runtime; - - public NativeException(Ruby runtime, RubyClass rubyClass, Throwable cause) { - super(runtime, rubyClass, cause.getClass().getName() + ": " + cause.getMessage()); - this.runtime = runtime; - this.cause = cause; - } - - public static RubyClass createClass(Ruby runtime, RubyClass baseClass) { - // FIXME: If NativeException is expected to be used from Ruby code, it should provide - // a real allocator to be used. Otherwise Class.new will fail, as will marshalling. JRUBY-415 - RubyClass exceptionClass = runtime.defineClass(CLASS_NAME, baseClass, ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - - exceptionClass.defineAnnotatedMethods(NativeException.class); - - return exceptionClass; - } - - @JRubyMethod(frame = true) - public IRubyObject cause(Block unusedBlock) { - return Java.wrap(getRuntime(), JavaObject.wrap(getRuntime(), cause)); - } - - public IRubyObject backtrace() { - IRubyObject rubyTrace = super.backtrace(); - if (rubyTrace.isNil()) { - return rubyTrace; - } - RubyArray array = (RubyArray) rubyTrace.dup(); - StackTraceElement[] stackTrace = cause.getStackTrace(); - for (int i = stackTrace.length - 1; i >= 0; i--) { - StackTraceElement element = stackTrace[i]; - String className = element.getClassName(); - String line = null; - if (element.getFileName() == null) { - line = className + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'"; - } else { - int index = className.lastIndexOf("."); - String packageName = null; - if (index == -1) { - packageName = ""; - } else { - packageName = className.substring(0, index) + "/"; - } - line = packageName.replace(".", "/") + element.getFileName() + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'"; - } - RubyString string = runtime.newString(line); - array.unshift(string); - } - return array; - } - - public void printBacktrace(PrintStream errorStream) { - super.printBacktrace(errorStream); - errorStream.println("Complete Java stackTrace"); - cause.printStackTrace(errorStream); - } - - public Throwable getCause() { - return cause; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -public interface Profile { - Profile ALL = new Profile() { - public boolean allowBuiltin(String name) { return true; } - public boolean allowClass(String name) { return true; } - public boolean allowModule(String name) { return true; } - public boolean allowLoad(String name) { return true; } - public boolean allowRequire(String name) { return true; } - }; - Profile DEBUG_ALLOW = new Profile() { - public boolean allowBuiltin(String name) { System.err.println("allowBuiltin("+name+")"); return true; } - public boolean allowClass(String name) { System.err.println("allowClass("+name+")"); return true; } - public boolean allowModule(String name) { System.err.println("allowModule("+name+")"); return true; } - public boolean allowLoad(String name) { System.err.println("allowLoad("+name+")"); return true; } - public boolean allowRequire(String name) { System.err.println("allowRequire("+name+")"); return true; } - }; - Profile NO_FILE_CLASS = new Profile() { - public boolean allowBuiltin(String name) { return true; } - public boolean allowClass(String name) { return !name.equals("File"); } - public boolean allowModule(String name) { return true; } - public boolean allowLoad(String name) { return true; } - public boolean allowRequire(String name) { return true; } - }; - Profile ANY = ALL; - Profile DEFAULT = ALL; - - boolean allowBuiltin(String name); - boolean allowClass(String name); - boolean allowModule(String name); - boolean allowLoad(String name); - boolean allowRequire(String name); -}// Profile -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2006 Michael Studman <codehaus@michaelstudman.com> - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileDescriptor; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.Stack; -import java.util.Vector; -import java.util.WeakHashMap; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.joda.time.DateTimeZone; -import org.jruby.ast.Node; -import org.jruby.ast.executable.RubiniusRunner; -import org.jruby.ast.executable.Script; -import org.jruby.ast.executable.YARVCompiledRunner; -import org.jruby.common.RubyWarnings; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.compiler.ASTCompiler; -import org.jruby.compiler.ASTInspector; -import org.jruby.compiler.JITCompiler; -import org.jruby.compiler.NotCompilableException; -import org.jruby.compiler.impl.StandardASMCompiler; -import org.jruby.compiler.yarv.StandardYARVCompiler; -import org.jruby.exceptions.JumpException; -import org.jruby.exceptions.RaiseException; -import org.jruby.ext.JRubyPOSIXHandler; -import org.jruby.ext.LateLoadingLibrary; -import org.jruby.ext.posix.POSIX; -import org.jruby.ext.posix.POSIXFactory; -import org.jruby.internal.runtime.GlobalVariables; -import org.jruby.internal.runtime.ThreadService; -import org.jruby.internal.runtime.ValueAccessor; -import org.jruby.javasupport.JavaSupport; -import org.jruby.management.BeanManager; -import org.jruby.management.ClassCache; -import org.jruby.management.Config; -import org.jruby.parser.Parser; -import org.jruby.parser.ParserConfiguration; -import org.jruby.runtime.Binding; -import org.jruby.runtime.Block; -import org.jruby.runtime.CacheMap; -import org.jruby.runtime.CallSite; -import org.jruby.runtime.CallbackFactory; -import org.jruby.runtime.DynamicScope; -import org.jruby.runtime.EventHook; -import org.jruby.runtime.GlobalVariable; -import org.jruby.runtime.IAccessor; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ObjectSpace; -import org.jruby.runtime.RubyEvent; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.load.Library; -import org.jruby.runtime.load.LoadService; -import org.jruby.util.BuiltinScript; -import org.jruby.util.ByteList; -import org.jruby.util.IOInputStream; -import org.jruby.util.IOOutputStream; -import org.jruby.util.JRubyClassLoader; -import org.jruby.util.JavaNameMangler; -import org.jruby.util.KCode; -import org.jruby.util.SafePropertyAccessor; -import org.jruby.util.collections.WeakHashSet; -import org.jruby.util.io.ChannelDescriptor; - -/** - * The Ruby object represents the top-level of a JRuby "instance" in a given VM. - * JRuby supports spawning multiple instances in the same JVM. Generally, objects - * created under these instances are tied to a given runtime, for such details - * as identity and type, because multiple Ruby instances means there are - * multiple instances of each class. This means that in multi-runtime mode - * (or really, multi-VM mode, where each JRuby instance is a ruby "VM"), objects - * generally can't be transported across runtimes without marshaling. - * - * This class roots everything that makes the JRuby runtime function, and - * provides a number of utility methods for constructing global types and - * accessing global runtime structures. - */ -public final class Ruby { - /** - * Returns a new instance of the JRuby runtime configured with defaults. - * - * @return the JRuby runtime - * @see org.jruby.RubyInstanceConfig - */ - public static Ruby newInstance() { - return newInstance(new RubyInstanceConfig()); - } - - /** - * Returns a new instance of the JRuby runtime configured as specified. - * - * @param config The instance configuration - * @return The JRuby runtime - * @see org.jruby.RubyInstanceConfig - */ - public static Ruby newInstance(RubyInstanceConfig config) { - Ruby ruby = new Ruby(config); - ruby.init(); - return ruby; - } - - /** - * Returns a new instance of the JRuby runtime configured with the given - * input, output and error streams and otherwise default configuration - * (except where specified system properties alter defaults). - * - * @param in the custom input stream - * @param out the custom output stream - * @param err the custom error stream - * @return the JRuby runtime - * @see org.jruby.RubyInstanceConfig - */ - public static Ruby newInstance(InputStream in, PrintStream out, PrintStream err) { - RubyInstanceConfig config = new RubyInstanceConfig(); - config.setInput(in); - config.setOutput(out); - config.setError(err); - return newInstance(config); - } - - /** - * Create and initialize a new JRuby runtime. The properties of the - * specified RubyInstanceConfig will be used to determine various JRuby - * runtime characteristics. - * - * @param config The configuration to use for the new instance - * @see org.jruby.RubyInstanceConfig - */ - private Ruby(RubyInstanceConfig config) { - this.config = config; - this.threadService = new ThreadService(this); - if(config.isSamplingEnabled()) { - org.jruby.util.SimpleSampler.registerThreadContext(threadService.getCurrentContext()); - } - - this.in = config.getInput(); - this.out = config.getOutput(); - this.err = config.getError(); - this.objectSpaceEnabled = config.isObjectSpaceEnabled(); - this.profile = config.getProfile(); - this.currentDirectory = config.getCurrentDirectory(); - this.kcode = config.getKCode(); - this.beanManager = new BeanManager(this, config.isManagementEnabled()); - this.jitCompiler = new JITCompiler(this); - - this.beanManager.register(new Config(this)); - this.beanManager.register(new ClassCache(this)); - - this.cacheMap = new CacheMap(this); - } - - /** - * Evaluates a script under the current scope (perhaps the top-level - * scope) and returns the result (generally the last value calculated). - * This version goes straight into the interpreter, bypassing compilation - * and runtime preparation typical to normal script runs. - * - * @param script The scriptlet to run - * @returns The result of the eval - */ - public IRubyObject evalScriptlet(String script) { - ThreadContext context = getCurrentContext(); - Node node = parseEval(script, "<script>", context.getCurrentScope(), 0); - - try { - return node.interpret(this, context, context.getFrameSelf(), Block.NULL_BLOCK); - } catch (JumpException.ReturnJump rj) { - throw newLocalJumpError("return", (IRubyObject)rj.getValue(), "unexpected return"); - } catch (JumpException.BreakJump bj) { - throw newLocalJumpError("break", (IRubyObject)bj.getValue(), "unexpected break"); - } catch (JumpException.RedoJump rj) { - throw newLocalJumpError("redo", (IRubyObject)rj.getValue(), "unexpected redo"); - } - } - - /** - * Parse and execute the specified script - * This differs from the other methods in that it accepts a string-based script and - * parses and runs it as though it were loaded at a command-line. This is the preferred - * way to start up a new script when calling directly into the Ruby object (which is - * generally *dis*couraged. - * - * @param script The contents of the script to run as a normal, root script - * @return The last value of the script - */ - public IRubyObject executeScript(String script, String filename) { - byte[] bytes; - - try { - bytes = script.getBytes(KCode.NONE.getKCode()); - } catch (UnsupportedEncodingException e) { - bytes = script.getBytes(); - } - - Node node = parseInline(new ByteArrayInputStream(bytes), filename, null); - ThreadContext context = getCurrentContext(); - - String oldFile = context.getFile(); - int oldLine = context.getLine(); - try { - context.setFile(node.getPosition().getFile()); - context.setLine(node.getPosition().getStartLine()); - return runNormally(node, false); - } finally { - context.setFile(oldFile); - context.setLine(oldLine); - } - } - - /** - * Run the script contained in the specified input stream, using the - * specified filename as the name of the script being executed. The stream - * will be read fully before being parsed and executed. The given filename - * will be used for the ruby $PROGRAM_NAME and $0 global variables in this - * runtime. - * - * This method is intended to be called once per runtime, generally from - * Main or from main-like top-level entry points. - * - * As part of executing the script loaded from the input stream, various - * RubyInstanceConfig properties will be used to determine whether to - * compile the script before execution or run with various wrappers (for - * looping, printing, and so on, see jruby -help). - * - * @param inputStream The InputStream from which to read the script contents - * @param filename The filename to use when parsing, and for $PROGRAM_NAME - * and $0 ruby global variables. - */ - public void runFromMain(InputStream inputStream, String filename) { - IAccessor d = new ValueAccessor(newString(filename)); - getGlobalVariables().define("$PROGRAM_NAME", d); - getGlobalVariables().define("$0", d); - - for (Iterator i = config.getOptionGlobals().entrySet().iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - Object value = entry.getValue(); - IRubyObject varvalue; - if (value != null) { - varvalue = newString(value.toString()); - } else { - varvalue = getTrue(); - } - getGlobalVariables().set("$" + entry.getKey().toString(), varvalue); - } - - - if(config.isYARVEnabled()) { - if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode"); - new YARVCompiledRunner(this, inputStream, filename).run(); - } else if(config.isRubiniusEnabled()) { - if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode"); - new RubiniusRunner(this, inputStream, filename).run(); - } else { - Node scriptNode = parseFromMain(inputStream, filename); - ThreadContext context = getCurrentContext(); - - String oldFile = context.getFile(); - int oldLine = context.getLine(); - try { - context.setFile(scriptNode.getPosition().getFile()); - context.setLine(scriptNode.getPosition().getStartLine()); - - if (config.isAssumePrinting() || config.isAssumeLoop()) { - runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(), - config.isSplit(), config.isYARVCompileEnabled()); - } else { - runNormally(scriptNode, config.isYARVCompileEnabled()); - } - } finally { - context.setFile(oldFile); - context.setLine(oldLine); - } - } - } - - /** - * Parse the script contained in the given input stream, using the given - * filename as the name of the script, and return the root Node. This - * is used to verify that the script syntax is valid, for jruby -c. The - * current scope (generally the top-level scope) is used as the parent - * scope for parsing. - * - * @param inputStream The input stream from which to read the script - * @param filename The filename to use for parsing - * @returns The root node of the parsed script - */ - public Node parseFromMain(InputStream inputStream, String filename) { - if (config.isInlineScript()) { - return parseInline(inputStream, filename, getCurrentContext().getCurrentScope()); - } else { - return parseFile(inputStream, filename, getCurrentContext().getCurrentScope()); - } - } - - /** - * Run the given script with a "while gets; end" loop wrapped around it. - * This is primarily used for the -n command-line flag, to allow writing - * a short script that processes input lines using the specified code. - * - * @param scriptNode The root node of the script to execute - * @param printing Whether $_ should be printed after each loop (as in the - * -p command-line flag) - * @param processLineEnds Whether line endings should be processed by - * setting $\ to $/ and <code>chop!</code>ing every line read - * @param split Whether to split each line read using <code>String#split</code> - * @param yarvCompile Whether to compile the target script to YARV (Ruby 1.9) - * bytecode before executing. - * @return The result of executing the specified script - */ - public IRubyObject runWithGetsLoop(Node scriptNode, boolean printing, boolean processLineEnds, boolean split, boolean yarvCompile) { - ThreadContext context = getCurrentContext(); - - Script script = null; - YARVCompiledRunner runner = null; - boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI(); - if (compile || !yarvCompile) { - script = tryCompile(scriptNode); - if (compile && script == null) { - // terminate; tryCompile will have printed out an error and we're done - return getNil(); - } - } else if (yarvCompile) { - runner = tryCompileYarv(scriptNode); - } - - if (processLineEnds) { - getGlobalVariables().set("$\\", getGlobalVariables().get("$/")); - } - - while (RubyKernel.gets(context, getTopSelf(), IRubyObject.NULL_ARRAY).isTrue()) { - loop: while (true) { // Used for the 'redo' command - try { - if (processLineEnds) { - getGlobalVariables().get("$_").callMethod(context, "chop!"); - } - - if (split) { - getGlobalVariables().set("$F", getGlobalVariables().get("$_").callMethod(context, "split")); - } - - if (script != null) { - runScript(script); - } else if (runner != null) { - runYarv(runner); - } else { - runInterpreter(scriptNode); - } - - if (printing) RubyKernel.print(context, getKernel(), new IRubyObject[] {getGlobalVariables().get("$_")}); - break loop; - } catch (JumpException.RedoJump rj) { - // do nothing, this iteration restarts - } catch (JumpException.NextJump nj) { - // recheck condition - break loop; - } catch (JumpException.BreakJump bj) { - // end loop - return (IRubyObject) bj.getValue(); - } - } - } - - return getNil(); - } - - /** - * Run the specified script without any of the loop-processing wrapper - * code. - * - * @param scriptNode The root node of the script to be executed - * @param yarvCompile Whether to compile the script to YARV (Ruby 1.9) - * bytecode before execution - * @return The result of executing the script - */ - public IRubyObject runNormally(Node scriptNode, boolean yarvCompile) { - Script script = null; - YARVCompiledRunner runner = null; - boolean compile = getInstanceConfig().getCompileMode().shouldPrecompileCLI(); - boolean forceCompile = getInstanceConfig().getCompileMode().shouldPrecompileAll(); - if (yarvCompile) { - runner = tryCompileYarv(scriptNode); - } else if (compile) { - script = tryCompile(scriptNode); - if (forceCompile && script == null) { - System.err.println("Error, could not compile; pass -J-Djruby.jit.logging.verbose=true for more details"); - return getNil(); - } - } - - if (script != null) { - if (config.isShowBytecode()) { - return nilObject; - } else { - return runScript(script); - } - } else if (runner != null) { - return runYarv(runner); - } else { - if (config.isShowBytecode()) System.err.print("error: bytecode printing only works with JVM bytecode"); - return runInterpreter(scriptNode); - } - } - - private Script tryCompile(Node node) { - return tryCompile(node, new JRubyClassLoader(getJRubyClassLoader())); - } - - private Script tryCompile(Node node, JRubyClassLoader classLoader) { - Script script = null; - try { - String filename = node.getPosition().getFile(); - String classname = JavaNameMangler.mangledFilenameForStartupClasspath(filename); - - ASTInspector inspector = new ASTInspector(); - inspector.inspect(node); - - StandardASMCompiler asmCompiler = new StandardASMCompiler(classname, filename); - ASTCompiler compiler = new ASTCompiler(); - if (config.isShowBytecode()) { - compiler.compileRoot(node, asmCompiler, inspector, false, false); - asmCompiler.dumpClass(System.out); - } else { - compiler.compileRoot(node, asmCompiler, inspector, true, false); - } - script = (Script)asmCompiler.loadClass(classLoader).newInstance(); - - if (config.isJitLogging()) { - System.err.println("compiled: " + node.getPosition().getFile()); - } - } catch (NotCompilableException nce) { - if (config.isJitLoggingVerbose()) { - System.err.println("Error -- Not compileable: " + nce.getMessage()); - nce.printStackTrace(); - } - } catch (ClassNotFoundException e) { - if (config.isJitLoggingVerbose()) { - System.err.println("Error -- Not compileable: " + e.getMessage()); - e.printStackTrace(); - } - } catch (InstantiationException e) { - if (config.isJitLoggingVerbose()) { - System.err.println("Error -- Not compileable: " + e.getMessage()); - e.printStackTrace(); - } - } catch (IllegalAccessException e) { - if (config.isJitLoggingVerbose()) { - System.err.println("Error -- Not compileable: " + e.getMessage()); - e.printStackTrace(); - } - } catch (Throwable t) { - if (config.isJitLoggingVerbose()) { - System.err.println("could not compile: " + node.getPosition().getFile() + " because of: \"" + t.getMessage() + "\""); - t.printStackTrace(); - } - } - - return script; - } - - private YARVCompiledRunner tryCompileYarv(Node node) { - try { - StandardYARVCompiler compiler = new StandardYARVCompiler(this); - ASTCompiler.getYARVCompiler().compile(node, compiler); - org.jruby.lexer.yacc.ISourcePosition p = node.getPosition(); - if(p == null && node instanceof org.jruby.ast.RootNode) { - p = ((org.jruby.ast.RootNode)node).getBodyNode().getPosition(); - } - return new YARVCompiledRunner(this,compiler.getInstructionSequence("<main>",p.getFile(),"toplevel")); - } catch (NotCompilableException nce) { - System.err.println("Error -- Not compileable: " + nce.getMessage()); - return null; - } catch (JumpException.ReturnJump rj) { - return null; - } - } - - private IRubyObject runScript(Script script) { - ThreadContext context = getCurrentContext(); - - try { - return script.load(context, context.getFrameSelf(), IRubyObject.NULL_ARRAY, Block.NULL_BLOCK); - } catch (JumpException.ReturnJump rj) { - return (IRubyObject) rj.getValue(); - } - } - - private IRubyObject runYarv(YARVCompiledRunner runner) { - try { - return runner.run(); - } catch (JumpException.ReturnJump rj) { - return (IRubyObject) rj.getValue(); - } - } - - private IRubyObject runInterpreter(Node scriptNode) { - ThreadContext context = getCurrentContext(); - - assert scriptNode != null : "scriptNode is not null"; - - try { - return scriptNode.interpret(this, context, getTopSelf(), Block.NULL_BLOCK); - } catch (JumpException.ReturnJump rj) { - return (IRubyObject) rj.getValue(); - } - } - - public BeanManager getBeanManager() { - return beanManager; - } - - public JITCompiler getJITCompiler() { - return jitCompiler; - } - - /** - * @deprecated use #newInstance() - */ - public static Ruby getDefaultInstance() { - return newInstance(); - } - - @Deprecated - public static Ruby getCurrentInstance() { - return null; - } - - @Deprecated - public static void setCurrentInstance(Ruby runtime) { - } - - public int allocSymbolId() { - return symbolLastId.incrementAndGet(); - } - public int allocModuleId() { - return moduleLastId.incrementAndGet(); - } - - /** - * Retrieve the module with the given name from the Object namespace. - * - * @param name The name of the module - * @return The module or null if not found - */ - public RubyModule getModule(String name) { - return (RubyModule) objectClass.getConstantAt(name); - } - - /** - * Retrieve the module with the given name from the Object namespace. The - * module name must be an interned string, but this method will be faster - * than the non-interned version. - * - * @param internedName The name of the module; <em>must</em> be an interned String - * @return The module or null if not found - */ - public RubyModule fastGetModule(String internedName) { - return (RubyModule) objectClass.fastGetConstantAt(internedName); - } - - /** - * Retrieve the class with the given name from the Object namespace. - * - * @param name The name of the class - * @return The class - */ - public RubyClass getClass(String name) { - return objectClass.getClass(name); - } - - /** - * Retrieve the class with the given name from the Object namespace. The - * module name must be an interned string, but this method will be faster - * than the non-interned version. - * - * @param internedName the name of the class; <em>must</em> be an interned String! - * @return - */ - public RubyClass fastGetClass(String internedName) { - return objectClass.fastGetClass(internedName); - } - - /** - * Define a new class under the Object namespace. Roughly equivalent to - * rb_define_class in MRI. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @return The new class - */ - public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator) { - return defineClassUnder(name, superClass, allocator, objectClass); - } - - /** - * A variation of defineClass that allows passing in an array of subplementary - * call sites for improving dynamic invocation performance. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @return The new class - */ - public RubyClass defineClass(String name, RubyClass superClass, ObjectAllocator allocator, CallSite[] callSites) { - return defineClassUnder(name, superClass, allocator, objectClass, callSites); - } - - /** - * Define a new class with the given name under the given module or class - * namespace. Roughly equivalent to rb_define_class_under in MRI. - * - * If the name specified is already bound, its value will be returned if: - * * It is a class - * * No new superclass is being defined - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @param parent The namespace under which to define the new class - * @return The new class - */ - public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent) { - return defineClassUnder(name, superClass, allocator, parent, null); - } - - /** - * A variation of defineClassUnder that allows passing in an array of - * supplementary call sites to improve dynamic invocation. - * - * @param name The name for the new class - * @param superClass The super class for the new class - * @param allocator An ObjectAllocator instance that can construct - * instances of the new class. - * @param parent The namespace under which to define the new class - * @param callSites The array of call sites to add - * @return The new class - */ - public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator, RubyModule parent, CallSite[] callSites) { - IRubyObject classObj = parent.getConstantAt(name); - - if (classObj != null) { - if (!(classObj instanceof RubyClass)) throw newTypeError(name + " is not a class"); - RubyClass klazz = (RubyClass)classObj; - if (klazz.getSuperClass().getRealClass() != superClass) { - throw newNameError(name + " is already defined", name); - } - // If we define a class in Ruby, but later want to allow it to be defined in Java, - // the allocator needs to be updated - if (klazz.getAllocator() != allocator) { - klazz.setAllocator(allocator); - } - return klazz; - } - - boolean parentIsObject = parent == objectClass; - - if (superClass == null) { - String className = parentIsObject ? name : parent.getName() + "::" + name; - warnings.warn(ID.NO_SUPER_CLASS, "no super class for `" + className + "', Object assumed", className); - - superClass = objectClass; - } - - return RubyClass.newClass(this, superClass, name, allocator, parent, !parentIsObject, callSites); - } - - /** - * Define a new module under the Object namespace. Roughly equivalent to - * rb_define_module in MRI. - * - * @param name The name of the new module - * @returns The new module - */ - public RubyModule defineModule(String name) { - return defineModuleUnder(name, objectClass); - } - - /** - * Define a new module with the given name under the given module or - * class namespace. Roughly equivalent to rb_define_module_under in MRI. - * - * @param name The name of the new module - * @param parent The class or module namespace under which to define the - * module - * @returns The new module - */ - public RubyModule defineModuleUnder(String name, RubyModule parent) { - IRubyObject moduleObj = parent.getConstantAt(name); - - boolean parentIsObject = parent == objectClass; - - if (moduleObj != null ) { - if (moduleObj.isModule()) return (RubyModule)moduleObj; - - if (parentIsObject) { - throw newTypeError(moduleObj.getMetaClass().getName() + " is not a module"); - } else { - throw newTypeError(parent.getName() + "::" + moduleObj.getMetaClass().getName() + " is not a module"); - } - } - - return RubyModule.newModule(this, name, parent, !parentIsObject); - } - - /** - * From Object, retrieve the named module. If it doesn't exist a - * new module is created. - * - * @param name The name of the module - * @returns The existing or new module - */ - public RubyModule getOrCreateModule(String name) { - IRubyObject module = objectClass.getConstantAt(name); - if (module == null) { - module = defineModule(name); - } else if (getSafeLevel() >= 4) { - throw newSecurityError("Extending module prohibited."); - } else if (!module.isModule()) { - throw newTypeError(name + " is not a Module"); - } - - return (RubyModule) module; - } - - - /** - * Retrieve the current safe level. - * - * @see org.jruby.Ruby#setSaveLevel - */ - public int getSafeLevel() { - return this.safeLevel; - } - - - /** - * Set the current safe level: - * - * 0 - strings from streams/environment/ARGV are tainted (default) - * 1 - no dangerous operation by tainted value - * 2 - process/file operations prohibited - * 3 - all generated objects are tainted - * 4 - no global (non-tainted) variable modification/no direct output - * - * The safe level is set using $SAFE in Ruby code. It is not particularly - * well supported in JRuby. - */ - public void setSafeLevel(int safeLevel) { - this.safeLevel = safeLevel; - } - - public KCode getKCode() { - return kcode; - } - - public void setKCode(KCode kcode) { - this.kcode = kcode; - } - - public void secure(int level) { - if (level <= safeLevel) { - throw newSecurityError("Insecure operation '" + getCurrentContext().getFrameName() + "' at level " + safeLevel); - } - } - - // FIXME moved this here to get what's obviously a utility method out of IRubyObject. - // perhaps security methods should find their own centralized home at some point. - public void checkSafeString(IRubyObject object) { - if (getSafeLevel() > 0 && object.isTaint()) { - ThreadContext tc = getCurrentContext(); - if (tc.getFrameName() != null) { - throw newSecurityError("Insecure operation - " + tc.getFrameName()); - } - throw newSecurityError("Insecure operation: -r"); - } - secure(4); - if (!(object instanceof RubyString)) { - throw newTypeError( - "wrong argument type " + object.getMetaClass().getName() + " (expected String)"); - } - } - - /** rb_define_global_const - * - */ - public void defineGlobalConstant(String name, IRubyObject value) { - objectClass.defineConstant(name, value); - } - - public boolean isClassDefined(String name) { - return getModule(name) != null; - } - - /** - * A ThreadFactory for when we're using pooled threads; we want to create - * the threads with daemon = true so they don't keep us from shutting down. - */ - public static class DaemonThreadFactory implements ThreadFactory { - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable); - thread.setDaemon(true); - - return thread; - } - } - - /** - * This method is called immediately after constructing the Ruby instance. - * The main thread is prepared for execution, all core classes and libraries - * are initialized, and any libraries required on the command line are - * loaded. - */ - private void init() { - // Get the main threadcontext (gets constructed for us) - ThreadContext tc = getCurrentContext(); - - safeLevel = config.getSafeLevel(); - - // Construct key services - loadService = config.createLoadService(this); - posix = POSIXFactory.getPOSIX(new JRubyPOSIXHandler(this), RubyInstanceConfig.nativeEnabled); - javaSupport = new JavaSupport(this); - - if (RubyInstanceConfig.POOLING_ENABLED) { - Executors.newCachedThreadPool(); - executor = new ThreadPoolExecutor( - RubyInstanceConfig.POOL_MIN, - RubyInstanceConfig.POOL_MAX, - RubyInstanceConfig.POOL_TTL, - TimeUnit.SECONDS, - new SynchronousQueue<Runnable>(), - new DaemonThreadFactory()); - } - - // initialize the root of the class hierarchy completely - initRoot(tc); - - // Construct the top-level execution frame and scope for the main thread - tc.prepareTopLevel(objectClass, topSelf); - - // Initialize all the core classes - bootstrap(); - - // Create global constants and variables - RubyGlobal.createGlobals(tc, this); - - // Prepare LoadService and load path - getLoadService().init(config.loadPaths()); - - // initialize builtin libraries - initBuiltins(); - - // Require in all libraries specified on command line - for (String scriptName : config.requiredLibraries()) { - RubyKernel.require(getTopSelf(), newString(scriptName), Block.NULL_BLOCK); - } - } - - private void bootstrap() { - initCore(); - initExceptions(); - } - - private void initRoot(ThreadContext context) { - // Bootstrap the top of the hierarchy - objectClass = RubyClass.createBootstrapClass(this, "Object", null, RubyObject.OBJECT_ALLOCATOR); - moduleClass = RubyClass.createBootstrapClass(this, "Module", objectClass, RubyModule.MODULE_ALLOCATOR); - classClass = RubyClass.createBootstrapClass(this, "Class", moduleClass, RubyClass.CLASS_ALLOCATOR); - - objectClass.setMetaClass(classClass); - moduleClass.setMetaClass(classClass); - classClass.setMetaClass(classClass); - - RubyClass metaClass; - metaClass = objectClass.makeMetaClass(classClass); - metaClass = moduleClass.makeMetaClass(metaClass); - metaClass = classClass.makeMetaClass(metaClass); - - RubyObject.createObjectClass(this, objectClass); - RubyModule.createModuleClass(this, moduleClass); - RubyClass.createClassClass(this, classClass); - - // set constants now that they're initialized - objectClass.setConstant("Object", objectClass); - objectClass.setConstant("Class", classClass); - objectClass.setConstant("Module", moduleClass); - - // Initialize Kernel and include into Object - RubyKernel.createKernelModule(this); - objectClass.includeModule(kernelModule); - - // Initialize the "dummy" class used as a marker - dummyClass = new RubyClass(this); - dummyClass.freeze(context); - - // Object is ready, create top self - topSelf = TopSelfFactory.createTopSelf(this); - } - - private void initCore() { - // Pre-create all the core classes potentially referenced during startup - RubyNil.createNilClass(this); - RubyBoolean.createFalseClass(this); - RubyBoolean.createTrueClass(this); - - nilObject = new RubyNil(this); - falseObject = new RubyBoolean(this, false); - trueObject = new RubyBoolean(this, true); - - RubyComparable.createComparable(this); - RubyEnumerable.createEnumerableModule(this); - RubyString.createStringClass(this); - RubySymbol.createSymbolClass(this); - - if (profile.allowClass("ThreadGroup")) { - RubyThreadGroup.createThreadGroupClass(this); - } - if (profile.allowClass("Thread")) { - RubyThread.createThreadClass(this); - } - if (profile.allowClass("Exception")) { - RubyException.createExceptionClass(this); - } - if (profile.allowModule("Precision")) { - RubyPrecision.createPrecisionModule(this); - } - if (profile.allowClass("Numeric")) { - RubyNumeric.createNumericClass(this); - } - if (profile.allowClass("Integer")) { - RubyInteger.createIntegerClass(this); - } - if (profile.allowClass("Fixnum")) { - RubyFixnum.createFixnumClass(this); - } - - if (config.getCompatVersion() == CompatVersion.RUBY1_9) { - if (profile.allowClass("Complex")) { - RubyComplex.createComplexClass(this); - } - if (profile.allowClass("Rational")) { - RubyRational.createRationalClass(this); - } - } - - if (profile.allowClass("Hash")) { - RubyHash.createHashClass(this); - } - if (profile.allowClass("Array")) { - RubyArray.createArrayClass(this); - } - if (profile.allowClass("Float")) { - RubyFloat.createFloatClass(this); - } - if (profile.allowClass("Bignum")) { - RubyBignum.createBignumClass(this); - } - ioClass = RubyIO.createIOClass(this); - - if (profile.allowClass("Struct")) { - RubyStruct.createStructClass(this); - } - if (profile.allowClass("Tms")) { - tmsStruct = RubyStruct.newInstance(structClass, new IRubyObject[]{newString("Tms"), newSymbol("utime"), newSymbol("stime"), newSymbol("cutime"), newSymbol("cstime")}, Block.NULL_BLOCK); - } - - if (profile.allowClass("Binding")) { - RubyBinding.createBindingClass(this); - } - // Math depends on all numeric types - if (profile.allowModule("Math")) { - RubyMath.createMathModule(this); - } - if (profile.allowClass("Regexp")) { - RubyRegexp.createRegexpClass(this); - } - if (profile.allowClass("Range")) { - RubyRange.createRangeClass(this); - } - if (profile.allowModule("ObjectSpace")) { - RubyObjectSpace.createObjectSpaceModule(this); - } - if (profile.allowModule("GC")) { - RubyGC.createGCModule(this); - } - if (profile.allowClass("Proc")) { - RubyProc.createProcClass(this); - } - if (profile.allowClass("Method")) { - RubyMethod.createMethodClass(this); - } - if (profile.allowClass("MatchData")) { - RubyMatchData.createMatchDataClass(this); - } - if (profile.allowModule("Marshal")) { - RubyMarshal.createMarshalModule(this); - } - if (profile.allowClass("Dir")) { - RubyDir.createDirClass(this); - } - if (profile.allowModule("FileTest")) { - RubyFileTest.createFileTestModule(this); - } - // depends on IO, FileTest - if (profile.allowClass("File")) { - RubyFile.createFileClass(this); - } - if (profile.allowClass("File::Stat")) { - RubyFileStat.createFileStatClass(this); - } - if (profile.allowModule("Process")) { - RubyProcess.createProcessModule(this); - } - if (profile.allowClass("Time")) { - RubyTime.createTimeClass(this); - } - if (profile.allowClass("UnboundMethod")) { - RubyUnboundMethod.defineUnboundMethodClass(this); - } - if (profile.allowClass("Data")) { - defineClass("Data", objectClass, objectClass.getAllocator()); - } - if (!isSecurityRestricted()) { - // Signal uses sun.misc.* classes, this is not allowed - // in the security-sensitive environments - if (profile.allowModule("Signal")) { - RubySignal.createSignal(this); - } - } - if (profile.allowClass("Continuation")) { - RubyContinuation.createContinuation(this); - } - } - - private void initExceptions() { - standardError = defineClassIfAllowed("StandardError", exceptionClass); - runtimeError = defineClassIfAllowed("RuntimeError", standardError); - ioError = defineClassIfAllowed("IOError", standardError); - scriptError = defineClassIfAllowed("ScriptError", exceptionClass); - rangeError = defineClassIfAllowed("RangeError", standardError); - signalException = defineClassIfAllowed("SignalException", exceptionClass); - - if (profile.allowClass("NameError")) { - nameError = RubyNameError.createNameErrorClass(this, standardError); - nameErrorMessage = RubyNameError.createNameErrorMessageClass(this, nameError); - } - if (profile.allowClass("NoMethodError")) { - noMethodError = RubyNoMethodError.createNoMethodErrorClass(this, nameError); - } - if (profile.allowClass("SystemExit")) { - systemExit = RubySystemExit.createSystemExitClass(this, exceptionClass); - } - if (profile.allowClass("LocalJumpError")) { - localJumpError = RubyLocalJumpError.createLocalJumpErrorClass(this, standardError); - } - if (profile.allowClass("NativeException")) { - nativeException = NativeException.createClass(this, runtimeError); - } - if (profile.allowClass("SystemCallError")) { - systemCallError = RubySystemCallError.createSystemCallErrorClass(this, standardError); - } - - fatal = defineClassIfAllowed("Fatal", exceptionClass); - interrupt = defineClassIfAllowed("Interrupt", signalException); - typeError = defineClassIfAllowed("TypeError", standardError); - argumentError = defineClassIfAllowed("ArgumentError", standardError); - indexError = defineClassIfAllowed("IndexError", standardError); - syntaxError = defineClassIfAllowed("SyntaxError", scriptError); - loadError = defineClassIfAllowed("LoadError", scriptError); - notImplementedError = defineClassIfAllowed("NotImplementedError", scriptError); - securityError = defineClassIfAllowed("SecurityError", standardError); - noMemoryError = defineClassIfAllowed("NoMemoryError", exceptionClass); - regexpError = defineClassIfAllowed("RegexpError", standardError); - eofError = defineClassIfAllowed("EOFError", ioError); - threadError = defineClassIfAllowed("ThreadError", standardError); - concurrencyError = defineClassIfAllowed("ConcurrencyError", threadError); - systemStackError = defineClassIfAllowed("SystemStackError", standardError); - zeroDivisionError = defineClassIfAllowed("ZeroDivisionError", standardError); - floatDomainError = defineClassIfAllowed("FloatDomainError", rangeError); - - initErrno(); - } - - private RubyClass defineClassIfAllowed(String name, RubyClass superClass) { - // TODO: should probably apply the null object pattern for a - // non-allowed class, rather than null - if (superClass != null && profile.allowClass(name)) { - return defineClass(name, superClass, superClass.getAllocator()); - } - return null; - } - - private Map<Integer, RubyClass> errnos = new HashMap<Integer, RubyClass>(); - - public RubyClass getErrno(int n) { - return errnos.get(n); - } - - /** - * Create module Errno's Variables. We have this method since Errno does not have it's - * own java class. - */ - private void initErrno() { - if (profile.allowModule("Errno")) { - errnoModule = defineModule("Errno"); - - Field[] fields = IErrno.class.getFields(); - - for (int i = 0; i < fields.length; i++) { - try { - createSysErr(fields[i].getInt(IErrno.class), fields[i].getName()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Someone defined a non-public constant in IErrno.java", e); - } - } - } - } - - /** - * Creates a system error. - * @param i the error code (will probably use a java exception instead) - * @param name of the error to define. - **/ - private void createSysErr(int i, String name) { - if(profile.allowClass(name)) { - RubyClass errno = getErrno().defineClassUnder(name, systemCallError, systemCallError.getAllocator()); - errnos.put(i, errno); - errno.defineConstant("Errno", newFixnum(i)); - } - } - - private void initBuiltins() { - addLazyBuiltin("java.rb", "java", "org.jruby.javasupport.Java"); - addLazyBuiltin("jruby.rb", "jruby", "org.jruby.libraries.JRubyLibrary"); - - addLazyBuiltin("minijava.rb", "minijava", "org.jruby.java.MiniJava"); - - addLazyBuiltin("jruby/ext.rb", "jruby/ext", "org.jruby.RubyJRuby$ExtLibrary"); - addLazyBuiltin("jruby/type.rb", "jruby/type", "org.jruby.RubyJRuby$TypeLibrary"); - addLazyBuiltin("iconv.so", "iconv", "org.jruby.libraries.IConvLibrary"); - addLazyBuiltin("nkf.so", "nkf", "org.jruby.libraries.NKFLibrary"); - addLazyBuiltin("stringio.so", "stringio", "org.jruby.libraries.StringIOLibrary"); - addLazyBuiltin("strscan.so", "strscan", "org.jruby.libraries.StringScannerLibrary"); - addLazyBuiltin("zlib.so", "zlib", "org.jruby.libraries.ZlibLibrary"); - addLazyBuiltin("yaml_internal.rb", "yaml_internal", "org.jruby.libraries.YamlLibrary"); - addLazyBuiltin("enumerator.so", "enumerator", "org.jruby.libraries.EnumeratorLibrary"); - addLazyBuiltin("generator_internal.rb", "generator_internal", "org.jruby.ext.Generator$Service"); - addLazyBuiltin("readline.so", "readline", "org.jruby.ext.Readline$Service"); - addLazyBuiltin("thread.so", "thread", "org.jruby.libraries.ThreadLibrary"); - addLazyBuiltin("digest.so", "digest", "org.jruby.libraries.DigestLibrary"); - addLazyBuiltin("digest.rb", "digest", "org.jruby.libraries.DigestLibrary"); - addLazyBuiltin("digest/md5.so", "digest/md5", "org.jruby.libraries.DigestLibrary$MD5"); - addLazyBuiltin("digest/rmd160.so", "digest/rmd160", "org.jruby.libraries.DigestLibrary$RMD160"); - addLazyBuiltin("digest/sha1.so", "digest/sha1", "org.jruby.libraries.DigestLibrary$SHA1"); - addLazyBuiltin("digest/sha2.so", "digest/sha2", "org.jruby.libraries.DigestLibrary$SHA2"); - addLazyBuiltin("bigdecimal.so", "bigdecimal", "org.jruby.libraries.BigDecimalLibrary"); - addLazyBuiltin("io/wait.so", "io/wait", "org.jruby.libraries.IOWaitLibrary"); - addLazyBuiltin("etc.so", "etc", "org.jruby.libraries.EtcLibrary"); - addLazyBuiltin("weakref.rb", "weakref", "org.jruby.ext.WeakRef$WeakRefLibrary"); - addLazyBuiltin("socket.so", "socket", "org.jruby.ext.socket.RubySocket$Service"); - addLazyBuiltin("rbconfig.rb", "rbconfig", "org.jruby.libraries.RbConfigLibrary"); - addLazyBuiltin("jruby/serialization.rb", "serialization", "org.jruby.libraries.JRubySerializationLibrary"); - addLazyBuiltin("ffi.so", "ffi", "org.jruby.ext.ffi.Factory$Service"); - if(RubyInstanceConfig.NATIVE_NET_PROTOCOL) { - addLazyBuiltin("net/protocol.rb", "net/protocol", "org.jruby.libraries.NetProtocolBufferedIOLibrary"); - } - - if (config.getCompatVersion() == CompatVersion.RUBY1_9) { - addLazyBuiltin("fiber.so", "fiber", "org.jruby.libraries.FiberLibrary"); - } - - addBuiltinIfAllowed("openssl.so", new Library() { - public void load(Ruby runtime, boolean wrap) throws IOException { - runtime.getLoadService().require("jruby/openssl/stub"); - } - }); - - String[] builtins = {"fcntl", "yaml", "yaml/syck", "jsignal" }; - for (String library : builtins) { - addBuiltinIfAllowed(library + ".rb", new BuiltinScript(library)); - } - - getLoadService().require("builtin/core_ext/symbol"); - - RubyKernel.autoload(topSelf, newSymbol("Java"), newString("java")); - - getLoadService().require("enumerator"); - } - - private void addLazyBuiltin(String name, String shortName, String className) { - addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getJRubyClassLoader())); - } - - private void addBuiltinIfAllowed(String name, Library lib) { - if(profile.allowBuiltin(name)) { - loadService.addBuiltinLibrary(name,lib); - } - } - - Object getRespondToMethod() { - return respondToMethod; - } - - void setRespondToMethod(Object rtm) { - this.respondToMethod = rtm; - } - - public Object getObjectToYamlMethod() { - return objectToYamlMethod; - } - - void setObjectToYamlMethod(Object otym) { - this.objectToYamlMethod = otym; - } - - /** - * Retrieve mappings of cached methods to where they have been cached. When a cached - * method needs to be invalidated this map can be used to remove all places it has been - * cached. - * - * @return the mappings of where cached methods have been stored - */ - public CacheMap getCacheMap() { - return cacheMap; - } - - /** Getter for property rubyTopSelf. - * @return Value of property rubyTopSelf. - */ - public IRubyObject getTopSelf() { - return topSelf; - } - - public void setCurrentDirectory(String dir) { - currentDirectory = dir; - } - - public String getCurrentDirectory() { - return currentDirectory; - } - - public RubyModule getEtc() { - return etcModule; - } - - public void setEtc(RubyModule etcModule) { - this.etcModule = etcModule; - } - - public RubyClass getObject() { - return objectClass; - } - - public RubyClass getModule() { - return moduleClass; - } - - public RubyClass getClassClass() { - return classClass; - } - - public RubyModule getKernel() { - return kernelModule; - } - void setKernel(RubyModule kernelModule) { - this.kernelModule = kernelModule; - } - - public RubyClass getDummy() { - return dummyClass; - } - - public RubyModule getComparable() { - return comparableModule; - } - void setComparable(RubyModule comparableModule) { - this.comparableModule = comparableModule; - } - - public RubyClass getNumeric() { - return numericClass; - } - void setNumeric(RubyClass numericClass) { - this.numericClass = numericClass; - } - - public RubyClass getFloat() { - return floatClass; - } - void setFloat(RubyClass floatClass) { - this.floatClass = floatClass; - } - - public RubyClass getInteger() { - return integerClass; - } - void setInteger(RubyClass integerClass) { - this.integerClass = integerClass; - } - - public RubyClass getFixnum() { - return fixnumClass; - } - void setFixnum(RubyClass fixnumClass) { - this.fixnumClass = fixnumClass; - } - - public RubyClass getComplex() { - return complexClass; - } - void setComplex(RubyClass complexClass) { - this.complexClass = complexClass; - } - - public RubyClass getRational() { - return rationalClass; - } - void setRational(RubyClass rationalClass) { - this.rationalClass = rationalClass; - } - - public RubyModule getEnumerable() { - return enumerableModule; - } - void setEnumerable(RubyModule enumerableModule) { - this.enumerableModule = enumerableModule; - } - - public RubyModule getEnumerator() { - return enumeratorClass; - } - void setEnumerator(RubyClass enumeratorClass) { - this.enumeratorClass = enumeratorClass; - } - - public RubyClass getString() { - return stringClass; - } - void setString(RubyClass stringClass) { - this.stringClass = stringClass; - } - - public RubyClass getSymbol() { - return symbolClass; - } - void setSymbol(RubyClass symbolClass) { - this.symbolClass = symbolClass; - } - - public RubyClass getArray() { - return arrayClass; - } - void setArray(RubyClass arrayClass) { - this.arrayClass = arrayClass; - } - - public RubyClass getHash() { - return hashClass; - } - void setHash(RubyClass hashClass) { - this.hashClass = hashClass; - } - - public RubyClass getRange() { - return rangeClass; - } - void setRange(RubyClass rangeClass) { - this.rangeClass = rangeClass; - } - - /** Returns the "true" instance from the instance pool. - * @return The "true" instance. - */ - public RubyBoolean getTrue() { - return trueObject; - } - - /** Returns the "false" instance from the instance pool. - * @return The "false" instance. - */ - public RubyBoolean getFalse() { - return falseObject; - } - - /** Returns the "nil" singleton instance. - * @return "nil" - */ - public IRubyObject getNil() { - return nilObject; - } - - public RubyClass getNilClass() { - return nilClass; - } - void setNilClass(RubyClass nilClass) { - this.nilClass = nilClass; - } - - public RubyClass getTrueClass() { - return trueClass; - } - void setTrueClass(RubyClass trueClass) { - this.trueClass = trueClass; - } - - public RubyClass getFalseClass() { - return falseClass; - } - void setFalseClass(RubyClass falseClass) { - this.falseClass = falseClass; - } - - public RubyClass getProc() { - return procClass; - } - void setProc(RubyClass procClass) { - this.procClass = procClass; - } - - public RubyClass getBinding() { - return bindingClass; - } - void setBinding(RubyClass bindingClass) { - this.bindingClass = bindingClass; - } - - public RubyClass getMethod() { - return methodClass; - } - void setMethod(RubyClass methodClass) { - this.methodClass = methodClass; - } - - public RubyClass getUnboundMethod() { - return unboundMethodClass; - } - void setUnboundMethod(RubyClass unboundMethodClass) { - this.unboundMethodClass = unboundMethodClass; - } - - public RubyClass getMatchData() { - return matchDataClass; - } - void setMatchData(RubyClass matchDataClass) { - this.matchDataClass = matchDataClass; - } - - public RubyClass getRegexp() { - return regexpClass; - } - void setRegexp(RubyClass regexpClass) { - this.regexpClass = regexpClass; - } - - public RubyClass getTime() { - return timeClass; - } - void setTime(RubyClass timeClass) { - this.timeClass = timeClass; - } - - public RubyModule getMath() { - return mathModule; - } - void setMath(RubyModule mathModule) { - this.mathModule = mathModule; - } - - public RubyModule getMarshal() { - return marshalModule; - } - void setMarshal(RubyModule marshalModule) { - this.marshalModule = marshalModule; - } - - public RubyClass getBignum() { - return bignumClass; - } - void setBignum(RubyClass bignumClass) { - this.bignumClass = bignumClass; - } - - public RubyClass getDir() { - return dirClass; - } - void setDir(RubyClass dirClass) { - this.dirClass = dirClass; - } - - public RubyClass getFile() { - return fileClass; - } - void setFile(RubyClass fileClass) { - this.fileClass = fileClass; - } - - public RubyClass getFileStat() { - return fileStatClass; - } - void setFileStat(RubyClass fileStatClass) { - this.fileStatClass = fileStatClass; - } - - public RubyModule getFileTest() { - return fileTestModule; - } - void setFileTest(RubyModule fileTestModule) { - this.fileTestModule = fileTestModule; - } - - public RubyClass getIO() { - return ioClass; - } - void setIO(RubyClass ioClass) { - this.ioClass = ioClass; - } - - public RubyClass getThread() { - return threadClass; - } - void setThread(RubyClass threadClass) { - this.threadClass = threadClass; - } - - public RubyClass getThreadGroup() { - return threadGroupClass; - } - void setThreadGroup(RubyClass threadGroupClass) { - this.threadGroupClass = threadGroupClass; - } - - public RubyThreadGroup getDefaultThreadGroup() { - return defaultThreadGroup; - } - void setDefaultThreadGroup(RubyThreadGroup defaultThreadGroup) { - this.defaultThreadGroup = defaultThreadGroup; - } - - public RubyClass getContinuation() { - return continuationClass; - } - void setContinuation(RubyClass continuationClass) { - this.continuationClass = continuationClass; - } - - public RubyClass getStructClass() { - return structClass; - } - void setStructClass(RubyClass structClass) { - this.structClass = structClass; - } - - public IRubyObject getTmsStruct() { - return tmsStruct; - } - void setTmsStruct(RubyClass tmsStruct) { - this.tmsStruct = tmsStruct; - } - - public IRubyObject getPasswdStruct() { - return passwdStruct; - } - void setPasswdStruct(RubyClass passwdStruct) { - this.passwdStruct = passwdStruct; - } - - public IRubyObject getGroupStruct() { - return groupStruct; - } - void setGroupStruct(RubyClass groupStruct) { - this.groupStruct = groupStruct; - } - - public RubyModule getGC() { - return gcModule; - } - void setGC(RubyModule gcModule) { - this.gcModule = gcModule; - } - - public RubyModule getObjectSpaceModule() { - return objectSpaceModule; - } - void setObjectSpaceModule(RubyModule objectSpaceModule) { - this.objectSpaceModule = objectSpaceModule; - } - - public RubyModule getProcess() { - return processModule; - } - void setProcess(RubyModule processModule) { - this.processModule = processModule; - } - - public RubyClass getProcStatus() { - return procStatusClass; - } - void setProcStatus(RubyClass procStatusClass) { - this.procStatusClass = procStatusClass; - } - - public RubyModule getProcUID() { - return procUIDModule; - } - void setProcUID(RubyModule procUIDModule) { - this.procUIDModule = procUIDModule; - } - - public RubyModule getProcGID() { - return procGIDModule; - } - void setProcGID(RubyModule procGIDModule) { - this.procGIDModule = procGIDModule; - } - - public RubyModule getProcSysModule() { - return procSysModule; - } - void setProcSys(RubyModule procSysModule) { - this.procSysModule = procSysModule; - } - - public RubyModule getPrecision() { - return precisionModule; - } - void setPrecision(RubyModule precisionModule) { - this.precisionModule = precisionModule; - } - - public RubyModule getErrno() { - return errnoModule; - } - - public RubyClass getException() { - return exceptionClass; - } - void setException(RubyClass exceptionClass) { - this.exceptionClass = exceptionClass; - } - - public RubyClass getNameError() { - return nameError; - } - - public RubyClass getNameErrorMessage() { - return nameErrorMessage; - } - - public RubyClass getNoMethodError() { - return noMethodError; - } - - public RubyClass getSignalException() { - return signalException; - } - - public RubyClass getRangeError() { - return rangeError; - } - - public RubyClass getSystemExit() { - return systemExit; - } - - public RubyClass getLocalJumpError() { - return localJumpError; - } - - public RubyClass getNativeException() { - return nativeException; - } - - public RubyClass getSystemCallError() { - return systemCallError; - } - - public RubyClass getFatal() { - return fatal; - } - - public RubyClass getInterrupt() { - return interrupt; - } - - public RubyClass getTypeError() { - return typeError; - } - - public RubyClass getArgumentError() { - return argumentError; - } - - public RubyClass getIndexError() { - return indexError; - } - - public RubyClass getSyntaxError() { - return syntaxError; - } - - public RubyClass getStandardError() { - return standardError; - } - - public RubyClass getRuntimeError() { - return runtimeError; - } - - public RubyClass getIOError() { - return ioError; - } - - public RubyClass getLoadError() { - return loadError; - } - - public RubyClass getNotImplementedError() { - return notImplementedError; - } - - public RubyClass getSecurityError() { - return securityError; - } - - public RubyClass getNoMemoryError() { - return noMemoryError; - } - - public RubyClass getRegexpError() { - return regexpError; - } - - public RubyClass getEOFError() { - return eofError; - } - - public RubyClass getThreadError() { - return threadError; - } - - public RubyClass getConcurrencyError() { - return concurrencyError; - } - - public RubyClass getSystemStackError() { - return systemStackError; - } - - public RubyClass getZeroDivisionError() { - return zeroDivisionError; - } - - public RubyClass getFloatDomainError() { - return floatDomainError; - } - - private RubyHash charsetMap; - public RubyHash getCharsetMap() { - if (charsetMap == null) charsetMap = new RubyHash(this); - return charsetMap; - } - - /** Getter for property isVerbose. - * @return Value of property isVerbose. - */ - public IRubyObject getVerbose() { - return verbose; - } - - /** Setter for property isVerbose. - * @param verbose New value of property isVerbose. - */ - public void setVerbose(IRubyObject verbose) { - this.verbose = verbose; - } - - /** Getter for property isDebug. - * @return Value of property isDebug. - */ - public IRubyObject getDebug() { - return debug; - } - - /** Setter for property isDebug. - * @param debug New value of property isDebug. - */ - public void setDebug(IRubyObject debug) { - this.debug = debug; - } - - public JavaSupport getJavaSupport() { - return javaSupport; - } - - public static ClassLoader getClassLoader() { - // we try to get the classloader that loaded JRuby, falling back on System - ClassLoader loader = Ruby.class.getClassLoader(); - if (loader == null) { - loader = ClassLoader.getSystemClassLoader(); - } - - return loader; - } - - public synchronized JRubyClassLoader getJRubyClassLoader() { - // FIXME: Get rid of laziness and handle restricted access elsewhere - if (!Ruby.isSecurityRestricted() && jrubyClassLoader == null) { - jrubyClassLoader = new JRubyClassLoader(config.getLoader()); - } - - return jrubyClassLoader; - } - - /** Defines a global variable - */ - public void defineVariable(final GlobalVariable variable) { - globalVariables.define(variable.name(), new IAccessor() { - public IRubyObject getValue() { - return variable.get(); - } - - public IRubyObject setValue(IRubyObject newValue) { - return variable.set(newValue); - } - }); - } - - /** defines a readonly global variable - * - */ - public void defineReadonlyVariable(String name, IRubyObject value) { - globalVariables.defineReadonly(name, new ValueAccessor(value)); - } - - public Node parseFile(InputStream in, String file, DynamicScope scope) { - return parser.parse(file, in, scope, new ParserConfiguration(0, false, false, true)); - } - - public Node parseInline(InputStream in, String file, DynamicScope scope) { - return parser.parse(file, in, scope, new ParserConfiguration(0, false, true)); - } - - public Node parseEval(String content, String file, DynamicScope scope, int lineNumber) { - byte[] bytes; - - try { - bytes = content.getBytes(KCode.NONE.getKCode()); - } catch (UnsupportedEncodingException e) { - bytes = content.getBytes(); - } - - return parser.parse(file, new ByteArrayInputStream(bytes), scope, - new ParserConfiguration(lineNumber, false)); - } - - public Node parse(String content, String file, DynamicScope scope, int lineNumber, - boolean extraPositionInformation) { - byte[] bytes; - - try { - bytes = content.getBytes(KCode.NONE.getKCode()); - } catch (UnsupportedEncodingException e) { - bytes = content.getBytes(); - } - - return parser.parse(file, new ByteArrayInputStream(bytes), scope, - new ParserConfiguration(lineNumber, extraPositionInformation, false)); - } - - public Node parseEval(ByteList content, String file, DynamicScope scope, int lineNumber) { - return parser.parse(file, content, scope, new ParserConfiguration(lineNumber, false)); - } - - public Node parse(ByteList content, String file, DynamicScope scope, int lineNumber, - boolean extraPositionInformation) { - return parser.parse(file, content, scope, - new ParserConfiguration(lineNumber, extraPositionInformation, false)); - } - - - public ThreadService getThreadService() { - return threadService; - } - - public ThreadContext getCurrentContext() { - return threadService.getCurrentContext(); - } - - /** - * Returns the loadService. - * @return ILoadService - */ - public LoadService getLoadService() { - return loadService; - } - - public RubyWarnings getWarnings() { - return warnings; - } - - public PrintStream getErrorStream() { - // FIXME: We can't guarantee this will always be a RubyIO...so the old code here is not safe - /*java.io.OutputStream os = ((RubyIO) getGlobalVariables().get("$stderr")).getOutStream(); - if(null != os) { - return new PrintStream(os); - } else { - return new PrintStream(new org.jruby.util.SwallowingOutputStream()); - }*/ - return new PrintStream(new IOOutputStream(getGlobalVariables().get("$stderr"))); - } - - public InputStream getInputStream() { - return new IOInputStream(getGlobalVariables().get("$stdin")); - } - - public PrintStream getOutputStream() { - return new PrintStream(new IOOutputStream(getGlobalVariables().get("$stdout"))); - } - - public RubyModule getClassFromPath(String path) { - RubyModule c = getObject(); - if (path.length() == 0 || path.charAt(0) == '#') { - throw newTypeError("can't retrieve anonymous class " + path); - } - int pbeg = 0, p = 0; - for(int l=path.length(); p<l; ) { - while(p<l && path.charAt(p) != ':') { - p++; - } - String str = path.substring(pbeg, p); - - if(p<l && path.charAt(p) == ':') { - if(p+1 < l && path.charAt(p+1) != ':') { - throw newTypeError("undefined class/module " + path.substring(pbeg,p)); - } - p += 2; - pbeg = p; - } - - IRubyObject cc = c.getConstant(str); - if(!(cc instanceof RubyModule)) { - throw newTypeError("" + path + " does not refer to class/module"); - } - c = (RubyModule)cc; - } - return c; - } - - /** Prints an error with backtrace to the error stream. - * - * MRI: eval.c - error_print() - * - */ - public void printError(RubyException excp) { - if (excp == null || excp.isNil()) { - return; - } - - ThreadContext context = getCurrentContext(); - IRubyObject backtrace = excp.callMethod(context, "backtrace"); - - PrintStream errorStream = getErrorStream(); - if (backtrace.isNil() || !(backtrace instanceof RubyArray)) { - if (context.getFile() != null) { - errorStream.print(context.getFile() + ":" + context.getLine()); - } else { - errorStream.print(context.getLine()); - } - } else if (((RubyArray) backtrace).getLength() == 0) { - printErrorPos(context, errorStream); - } else { - IRubyObject mesg = ((RubyArray) backtrace).first(); - - if (mesg.isNil()) { - printErrorPos(context, errorStream); - } else { - errorStream.print(mesg); - } - } - - RubyClass type = excp.getMetaClass(); - String info = excp.toString(); - - if (type == getRuntimeError() && (info == null || info.length() == 0)) { - errorStream.print(": unhandled exception\n"); - } else { - String path = type.getName(); - - if (info.length() == 0) { - errorStream.print(": " + path + '\n'); - } else { - if (path.startsWith("#")) { - path = null; - } - - String tail = null; - if (info.indexOf("\n") != -1) { - tail = info.substring(info.indexOf("\n") + 1); - info = info.substring(0, info.indexOf("\n")); - } - - errorStream.print(": " + info); - - if (path != null) { - errorStream.print(" (" + path + ")\n"); - } - - if (tail != null) { - errorStream.print(tail + '\n'); - } - } - } - - excp.printBacktrace(errorStream); - } - - private void printErrorPos(ThreadContext context, PrintStream errorStream) { - if (context.getFile() != null) { - if (context.getFrameName() != null) { - errorStream.print(context.getFile() + ":" + context.getLine()); - errorStream.print(":in '" + context.getFrameName() + '\''); - } else if (context.getLine() != 0) { - errorStream.print(context.getFile() + ":" + context.getLine()); - } else { - errorStream.print(context.getFile()); - } - } - } - - public void loadFile(String scriptName, InputStream in, boolean wrap) { - IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this) : getTopSelf(); - ThreadContext context = getCurrentContext(); - String file = context.getFile(); - - try { - secure(4); /* should alter global state */ - - context.setFile(scriptName); - context.preNodeEval(objectClass, self, scriptName); - - parseFile(in, scriptName, null).interpret(this, context, self, Block.NULL_BLOCK); - } catch (JumpException.ReturnJump rj) { - return; - } finally { - context.postNodeEval(); - context.setFile(file); - } - } - - public void compileAndLoadFile(String filename, InputStream in, boolean wrap) { - IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this) : getTopSelf(); - ThreadContext context = getCurrentContext(); - String file = context.getFile(); - - try { - secure(4); /* should alter global state */ - - context.setFile(filename); - context.preNodeEval(objectClass, self, filename); - - Node scriptNode = parseFile(in, filename, null); - - Script script = tryCompile(scriptNode, new JRubyClassLoader(jrubyClassLoader)); - if (script == null) { - System.err.println("Error, could not compile; pass -J-Djruby.jit.logging.verbose=true for more details"); - } - - runScript(script); - } catch (JumpException.ReturnJump rj) { - return; - } finally { - context.postNodeEval(); - context.setFile(file); - } - } - - public void loadScript(Script script) { - IRubyObject self = getTopSelf(); - ThreadContext context = getCurrentContext(); - - try { - secure(4); /* should alter global state */ - - context.preNodeEval(objectClass, self); - - script.load(context, self, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK); - } catch (JumpException.ReturnJump rj) { - return; - } finally { - context.postNodeEval(); - } - } - - public class CallTraceFuncHook extends EventHook { - private RubyProc traceFunc; - - public void setTraceFunc(RubyProc traceFunc) { - this.traceFunc = traceFunc; - } - - public void eventHandler(ThreadContext context, String eventName, String file, int line, String name, IRubyObject type) { - if (!context.isWithinTrace()) { - if (file == null) file = "(ruby)"; - if (type == null) type = getFalse(); - - RubyBinding binding = RubyBinding.newBinding(Ruby.this); - - context.preTrace(); - try { - traceFunc.call(context, new IRubyObject[] { - newString(eventName), // event name - newString(file), // filename - newFixnum(line), // line numbers should be 1-based - name != null ? newSymbol(name) : getNil(), - binding, - type - }); - } finally { - context.postTrace(); - } - } - } - - public boolean isInterestedInEvent(RubyEvent event) { - return true; - } - }; - - private final CallTraceFuncHook callTraceFuncHook = new CallTraceFuncHook(); - - public void addEventHook(EventHook hook) { - eventHooks.add(hook); - hasEventHooks = true; - } - - public void removeEventHook(EventHook hook) { - eventHooks.remove(hook); - hasEventHooks = !eventHooks.isEmpty(); - } - - public void setTraceFunction(RubyProc traceFunction) { - removeEventHook(callTraceFuncHook); - - if (traceFunction == null) { - return; - } - - callTraceFuncHook.setTraceFunc(traceFunction); - addEventHook(callTraceFuncHook); - } - - public void callEventHooks(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type) { - for (EventHook eventHook : eventHooks) { - if (eventHook.isInterestedInEvent(event)) { - eventHook.event(context, event, file, line, name, type); - } - } - } - - public boolean hasEventHooks() { - return hasEventHooks; - } - - public GlobalVariables getGlobalVariables() { - return globalVariables; - } - - // For JSR 223 support: see http://scripting.java.net/ - public void setGlobalVariables(GlobalVariables globalVariables) { - this.globalVariables = globalVariables; - } - - public CallbackFactory callbackFactory(Class<?> type) { - return CallbackFactory.createFactory(this, type); - } - - /** - * Push block onto exit stack. When runtime environment exits - * these blocks will be evaluated. - * - * @return the element that was pushed onto stack - */ - public IRubyObject pushExitBlock(RubyProc proc) { - atExitBlocks.push(proc); - return proc; - } - - // use this for JRuby-internal finalizers - public void addInternalFinalizer(Finalizable finalizer) { - synchronized (internalFinalizersMutex) { - if (internalFinalizers == null) { - internalFinalizers = new WeakHashMap<Finalizable, Object>(); - } - internalFinalizers.put(finalizer, null); - } - } - - // this method is for finalizers registered via ObjectSpace - public void addFinalizer(Finalizable finalizer) { - synchronized (finalizersMutex) { - if (finalizers == null) { - finalizers = new WeakHashMap<Finalizable, Object>(); - } - finalizers.put(finalizer, null); - } - } - - public void removeInternalFinalizer(Finalizable finalizer) { - synchronized (internalFinalizersMutex) { - if (internalFinalizers != null) { - internalFinalizers.remove(finalizer); - } - } - } - - public void removeFinalizer(Finalizable finalizer) { - synchronized (finalizersMutex) { - if (finalizers != null) { - finalizers.remove(finalizer); - } - } - } - - /** - * Make sure Kernel#at_exit procs get invoked on runtime shutdown. - * This method needs to be explicitly called to work properly. - * I thought about using finalize(), but that did not work and I - * am not sure the runtime will be at a state to run procs by the - * time Ruby is going away. This method can contain any other - * things that need to be cleaned up at shutdown. - */ - public void tearDown() { - int status = 0; - - while (!atExitBlocks.empty()) { - RubyProc proc = atExitBlocks.pop(); - try { - proc.call(getCurrentContext(), IRubyObject.NULL_ARRAY); - } catch (RaiseException rj) { - RubyException raisedException = rj.getException(); - if (!getSystemExit().isInstance(raisedException)) { - status = 1; - printError(raisedException); - } else { - IRubyObject statusObj = raisedException.callMethod( - getCurrentContext(), "status"); - if (statusObj != null && !statusObj.isNil()) { - status = RubyNumeric.fix2int(statusObj); - } - } - } - } - - if (finalizers != null) { - synchronized (finalizers) { - for (Iterator<Finalizable> finalIter = new ArrayList<Finalizable>(finalizers.keySet()).iterator(); finalIter.hasNext();) { - finalIter.next().finalize(); - finalIter.remove(); - } - } - } - - synchronized (internalFinalizersMutex) { - if (internalFinalizers != null) { - for (Iterator<Finalizable> finalIter = new ArrayList<Finalizable>( - internalFinalizers.keySet()).iterator(); finalIter.hasNext();) { - finalIter.next().finalize(); - finalIter.remove(); - } - } - } - - getThreadService().disposeCurrentThread(); - - getBeanManager().unregisterCompiler(); - getBeanManager().unregisterConfig(); - getBeanManager().unregisterClassCache(); - getBeanManager().unregisterMethodCache(); - - if (status != 0) { - throw newSystemExit(status); - } - } - - // new factory methods ------------------------------------------------------------------------ - - public RubyArray newEmptyArray() { - return RubyArray.newEmptyArray(this); - } - - public RubyArray newArray() { - return RubyArray.newArray(this); - } - - public RubyArray newArrayLight() { - return RubyArray.newArrayLight(this); - } - - public RubyArray newArray(IRubyObject object) { - return RubyArray.newArray(this, object); - } - - public RubyArray newArray(IRubyObject car, IRubyObject cdr) { - return RubyArray.newArray(this, car, cdr); - } - - public RubyArray newArray(IRubyObject[] objects) { - return RubyArray.newArray(this, objects); - } - - public RubyArray newArrayNoCopy(IRubyObject[] objects) { - return RubyArray.newArrayNoCopy(this, objects); - } - - public RubyArray newArrayNoCopyLight(IRubyObject[] objects) { - return RubyArray.newArrayNoCopyLight(this, objects); - } - - public RubyArray newArray(List<IRubyObject> list) { - return RubyArray.newArray(this, list); - } - - public RubyArray newArray(int size) { - return RubyArray.newArray(this, size); - } - - public RubyBoolean newBoolean(boolean value) { - return RubyBoolean.newBoolean(this, value); - } - - public RubyFileStat newFileStat(String filename, boolean lstat) { - return RubyFileStat.newFileStat(this, filename, lstat); - } - - public RubyFileStat newFileStat(FileDescriptor descriptor) { - return RubyFileStat.newFileStat(this, descriptor); - } - - public RubyFixnum newFixnum(long value) { - return RubyFixnum.newFixnum(this, value); - } - - public RubyFixnum newFixnum(int value) { - return RubyFixnum.newFixnum(this, value); - } - - public RubyFloat newFloat(double value) { - return RubyFloat.newFloat(this, value); - } - - public RubyNumeric newNumeric() { - return RubyNumeric.newNumeric(this); - } - - public RubyProc newProc(Block.Type type, Block block) { - if (type != Block.Type.LAMBDA && block.getProcObject() != null) return block.getProcObject(); - - RubyProc proc = RubyProc.newProc(this, type); - - proc.callInit(IRubyObject.NULL_ARRAY, block); - - return proc; - } - - public RubyProc newBlockPassProc(Block.Type type, Block block) { - if (type != Block.Type.LAMBDA && block.getProcObject() != null) return block.getProcObject(); - - RubyProc proc = RubyProc.newProc(this, type); - proc.initialize(getCurrentContext(), block); - - return proc; - } - - public RubyBinding newBinding() { - return RubyBinding.newBinding(this); - } - - public RubyBinding newBinding(Binding binding) { - return RubyBinding.newBinding(this, binding); - } - - public RubyString newString() { - return RubyString.newString(this, new ByteList()); - } - - public RubyString newString(String string) { - return RubyString.newString(this, string); - } - - public RubyString newString(ByteList byteList) { - return RubyString.newString(this, byteList); - } - - @Deprecated - public RubyString newStringShared(ByteList byteList) { - return RubyString.newStringShared(this, byteList); - } - - public RubySymbol newSymbol(String name) { - return symbolTable.getSymbol(name); - } - - /** - * Faster than {@link #newSymbol(String)} if you already have an interned - * name String. Don't intern your string just to call this version - the - * overhead of interning will more than wipe out any benefit from the faster - * lookup. - * - * @param internedName the symbol name, <em>must</em> be interned! if in - * doubt, call {@link #newSymbol(String)} instead. - * @return the symbol for name - */ - public RubySymbol fastNewSymbol(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - - return symbolTable.fastGetSymbol(internedName); - } - - public RubyTime newTime(long milliseconds) { - return RubyTime.newTime(this, milliseconds); - } - - public RaiseException newRuntimeError(String message) { - return newRaiseException(getRuntimeError(), message); - } - - public RaiseException newArgumentError(String message) { - return newRaiseException(getArgumentError(), message); - } - - public RaiseException newArgumentError(int got, int expected) { - return newRaiseException(getArgumentError(), "wrong # of arguments(" + got + " for " + expected + ")"); - } - - public RaiseException newErrnoEBADFError() { - return newRaiseException(getErrno().fastGetClass("EBADF"), "Bad file descriptor"); - } - - public RaiseException newErrnoENOPROTOOPTError() { - return newRaiseException(getErrno().fastGetClass("ENOPROTOOPT"), "Protocol not available"); - } - - public RaiseException newErrnoEPIPEError() { - return newRaiseException(getErrno().fastGetClass("EPIPE"), "Broken pipe"); - } - - public RaiseException newErrnoECONNREFUSEDError() { - return newRaiseException(getErrno().fastGetClass("ECONNREFUSED"), "Connection refused"); - } - - public RaiseException newErrnoECONNRESETError() { - return newRaiseException(getErrno().fastGetClass("ECONNRESET"), "Connection reset by peer"); - } - - public RaiseException newErrnoEADDRINUSEError() { - return newRaiseException(getErrno().fastGetClass("EADDRINUSE"), "Address in use"); - } - - public RaiseException newErrnoEINVALError() { - return newRaiseException(getErrno().fastGetClass("EINVAL"), "Invalid file"); - } - - public RaiseException newErrnoENOENTError() { - return newRaiseException(getErrno().fastGetClass("ENOENT"), "File not found"); - } - - public RaiseException newErrnoEACCESError(String message) { - return newRaiseException(getErrno().fastGetClass("EACCES"), message); - } - - public RaiseException newErrnoEAGAINError(String message) { - return newRaiseException(getErrno().fastGetClass("EAGAIN"), message); - } - - public RaiseException newErrnoEISDirError() { - return newRaiseException(getErrno().fastGetClass("EISDIR"), "Is a directory"); - } - - public RaiseException newErrnoESPIPEError() { - return newRaiseException(getErrno().fastGetClass("ESPIPE"), "Illegal seek"); - } - - public RaiseException newErrnoEBADFError(String message) { - return newRaiseException(getErrno().fastGetClass("EBADF"), message); - } - - public RaiseException newErrnoEINVALError(String message) { - return newRaiseException(getErrno().fastGetClass("EINVAL"), message); - } - - public RaiseException newErrnoENOTDIRError(String message) { - return newRaiseException(getErrno().fastGetClass("ENOTDIR"), message); - } - - public RaiseException newErrnoENOTSOCKError(String message) { - return newRaiseException(getErrno().fastGetClass("ENOTSOCK"), message); - } - - public RaiseException newErrnoENOENTError(String message) { - return newRaiseException(getErrno().fastGetClass("ENOENT"), message); - } - - public RaiseException newErrnoESPIPEError(String message) { - return newRaiseException(getErrno().fastGetClass("ESPIPE"), message); - } - - public RaiseException newErrnoEEXISTError(String message) { - return newRaiseException(getErrno().fastGetClass("EEXIST"), message); - } - - public RaiseException newErrnoEDOMError(String message) { - return newRaiseException(getErrno().fastGetClass("EDOM"), "Domain error - " + message); - } - - public RaiseException newErrnoECHILDError() { - return newRaiseException(getErrno().fastGetClass("ECHILD"), "No child processes"); - } - - public RaiseException newIndexError(String message) { - return newRaiseException(getIndexError(), message); - } - - public RaiseException newSecurityError(String message) { - return newRaiseException(getSecurityError(), message); - } - - public RaiseException newSystemCallError(String message) { - return newRaiseException(getSystemCallError(), message); - } - - public RaiseException newTypeError(String message) { - return newRaiseException(getTypeError(), message); - } - - public RaiseException newThreadError(String message) { - return newRaiseException(getThreadError(), message); - } - - public RaiseException newConcurrencyError(String message) { - return newRaiseException(getConcurrencyError(), message); - } - - public RaiseException newSyntaxError(String message) { - return newRaiseException(getSyntaxError(), message); - } - - public RaiseException newRegexpError(String message) { - return newRaiseException(getRegexpError(), message); - } - - public RaiseException newRangeError(String message) { - return newRaiseException(getRangeError(), message); - } - - public RaiseException newNotImplementedError(String message) { - return newRaiseException(getNotImplementedError(), message); - } - - public RaiseException newInvalidEncoding(String message) { - return newRaiseException(fastGetClass("Iconv").fastGetClass("InvalidEncoding"), message); - } - - public RaiseException newNoMethodError(String message, String name, IRubyObject args) { - return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true); - } - - public RaiseException newNameError(String message, String name) { - return newNameError(message, name, null); - } - - public RaiseException newNameError(String message, String name, Throwable origException) { - return newNameError(message, name, origException, true); - } - - public RaiseException newNameError(String message, String name, Throwable origException, boolean printWhenVerbose) { - if (printWhenVerbose && origException != null && this.getVerbose().isTrue()) { - origException.printStackTrace(getErrorStream()); - } - return new RaiseException(new RubyNameError( - this, getNameError(), message, name), true); - } - - public RaiseException newLocalJumpError(String reason, IRubyObject exitValue, String message) { - return new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), message, reason, exitValue), true); - } - - public RaiseException newRedoLocalJumpError() { - return new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), "unexpected redo", "redo", getNil()), true); - } - - public RaiseException newLoadError(String message) { - return newRaiseException(getLoadError(), message); - } - - public RaiseException newFrozenError(String objectType) { - // TODO: Should frozen error have its own distinct class? If not should more share? - return newRaiseException(getTypeError(), "can't modify frozen " + objectType); - } - - public RaiseException newSystemStackError(String message) { - return newRaiseException(getSystemStackError(), message); - } - - public RaiseException newSystemExit(int status) { - return new RaiseException(RubySystemExit.newInstance(this, status)); - } - - public RaiseException newIOError(String message) { - return newRaiseException(getIOError(), message); - } - - public RaiseException newStandardError(String message) { - return newRaiseException(getStandardError(), message); - } - - public RaiseException newIOErrorFromException(IOException ioe) { - // TODO: this is kinda gross - if(ioe.getMessage() != null) { - if (ioe.getMessage().equals("Broken pipe")) { - throw newErrnoEPIPEError(); - } else if (ioe.getMessage().equals("Connection reset by peer")) { - throw newErrnoECONNRESETError(); - } - return newRaiseException(getIOError(), ioe.getMessage()); - } else { - return newRaiseException(getIOError(), "IO Error"); - } - } - - public RaiseException newTypeError(IRubyObject receivedObject, RubyClass expectedType) { - return newRaiseException(getTypeError(), "wrong argument type " + - receivedObject.getMetaClass().getRealClass() + " (expected " + expectedType + ")"); - } - - public RaiseException newEOFError() { - return newRaiseException(getEOFError(), "End of file reached"); - } - - public RaiseException newEOFError(String message) { - return newRaiseException(getEOFError(), message); - } - - public RaiseException newZeroDivisionError() { - return newRaiseException(getZeroDivisionError(), "divided by 0"); - } - - public RaiseException newFloatDomainError(String message){ - return newRaiseException(getFloatDomainError(), message); - } - - /** - * @param exceptionClass - * @param message - * @return - */ - private RaiseException newRaiseException(RubyClass exceptionClass, String message) { - RaiseException re = new RaiseException(this, exceptionClass, message, true); - return re; - } - - - public RubySymbol.SymbolTable getSymbolTable() { - return symbolTable; - } - - public void setStackTraces(int stackTraces) { - this.stackTraces = stackTraces; - } - - public int getStackTraces() { - return stackTraces; - } - - public void setRandomSeed(long randomSeed) { - this.randomSeed = randomSeed; - } - - public long getRandomSeed() { - return randomSeed; - } - - public Random getRandom() { - return random; - } - - public ObjectSpace getObjectSpace() { - return objectSpace; - } - - public Map<Integer, WeakReference<ChannelDescriptor>> getDescriptors() { - return descriptors; - } - - public long incrementRandomSeedSequence() { - return randomSeedSequence++; - } - - public InputStream getIn() { - return in; - } - - public PrintStream getOut() { - return out; - } - - public PrintStream getErr() { - return err; - } - - public boolean isGlobalAbortOnExceptionEnabled() { - return globalAbortOnExceptionEnabled; - } - - public void setGlobalAbortOnExceptionEnabled(boolean enable) { - globalAbortOnExceptionEnabled = enable; - } - - public boolean isDoNotReverseLookupEnabled() { - return doNotReverseLookupEnabled; - } - - public void setDoNotReverseLookupEnabled(boolean b) { - doNotReverseLookupEnabled = b; - } - - private ThreadLocal<Map<Object, Object>> inspect = new ThreadLocal<Map<Object, Object>>(); - public void registerInspecting(Object obj) { - Map<Object, Object> val = inspect.get(); - if (val == null) inspect.set(val = new IdentityHashMap<Object, Object>()); - val.put(obj, null); - } - - public boolean isInspecting(Object obj) { - Map<Object, Object> val = inspect.get(); - return val == null ? false : val.containsKey(obj); - } - - public void unregisterInspecting(Object obj) { - Map<Object, Object> val = inspect.get(); - if (val != null ) val.remove(obj); - } - - public boolean isObjectSpaceEnabled() { - return objectSpaceEnabled; - } - - // The method is intentionally not public, since it typically should - // not be used outside of the core. - /* package-private */ void setObjectSpaceEnabled(boolean objectSpaceEnabled) { - this.objectSpaceEnabled = objectSpaceEnabled; - } - - public long getStartTime() { - return startTime; - } - - public Profile getProfile() { - return profile; - } - - public String getJRubyHome() { - return config.getJRubyHome(); - } - - public void setJRubyHome(String home) { - config.setJRubyHome(home); - } - - public RubyInstanceConfig getInstanceConfig() { - return config; - } - - /** GET_VM_STATE_VERSION */ - public long getGlobalState() { - synchronized(this) { - return globalState; - } - } - - /** INC_VM_STATE_VERSION */ - public void incGlobalState() { - synchronized(this) { - globalState = (globalState+1) & 0x8fffffff; - } - } - - public static boolean isSecurityRestricted() { - return securityRestricted; - } - - public static void setSecurityRestricted(boolean restricted) { - securityRestricted = restricted; - } - - public POSIX getPosix() { - return posix; - } - - public void setRecordSeparatorVar(GlobalVariable recordSeparatorVar) { - this.recordSeparatorVar = recordSeparatorVar; - } - - public GlobalVariable getRecordSeparatorVar() { - return recordSeparatorVar; - } - - public Set<Script> getJittedMethods() { - return jittedMethods; - } - - public ExecutorService getExecutor() { - return executor; - } - - public Map<String, DateTimeZone> getLocalTimezoneCache() { - return localTimeZoneCache; - } - - private final CacheMap cacheMap; - private final ThreadService threadService; - private Hashtable<Object, Object> runtimeInformation; - - private POSIX posix; - - private int stackTraces = 0; - - private ObjectSpace objectSpace = new ObjectSpace(); - - private final RubySymbol.SymbolTable symbolTable = new RubySymbol.SymbolTable(this); - private Map<Integer, WeakReference<ChannelDescriptor>> descriptors = new ConcurrentHashMap<Integer, WeakReference<ChannelDescriptor>>(); - private long randomSeed = 0; - private long randomSeedSequence = 0; - private Random random = new Random(); - - private List<EventHook> eventHooks = new Vector<EventHook>(); - private boolean hasEventHooks; - private boolean globalAbortOnExceptionEnabled = false; - private boolean doNotReverseLookupEnabled = false; - private volatile boolean objectSpaceEnabled; - - private final Set<Script> jittedMethods = Collections.synchronizedSet(new WeakHashSet<Script>()); - - private static ThreadLocal<Ruby> currentRuntime = new ThreadLocal<Ruby>(); - - private long globalState = 1; - - private int safeLevel = -1; - - // Default objects - private IRubyObject topSelf; - private RubyNil nilObject; - private RubyBoolean trueObject; - private RubyBoolean falseObject; - public final RubyFixnum[] fixnumCache = new RubyFixnum[256]; - - private IRubyObject verbose; - private IRubyObject debug; - - private RubyThreadGroup defaultThreadGroup; - - /** - * All the core classes we keep hard references to. These are here largely - * so that if someone redefines String or Array we won't start blowing up - * creating strings and arrays internally. They also provide much faster - * access than going through normal hash lookup on the Object class. - */ - private RubyClass - objectClass, moduleClass, classClass, nilClass, trueClass, - falseClass, numericClass, floatClass, integerClass, fixnumClass, - complexClass, rationalClass, enumeratorClass, - arrayClass, hashClass, rangeClass, stringClass, symbolClass, - procClass, bindingClass, methodClass, unboundMethodClass, - matchDataClass, regexpClass, timeClass, bignumClass, dirClass, - fileClass, fileStatClass, ioClass, threadClass, threadGroupClass, - continuationClass, structClass, tmsStruct, passwdStruct, - groupStruct, procStatusClass, exceptionClass, runtimeError, ioError, - scriptError, nameError, nameErrorMessage, noMethodError, signalException, - rangeError, dummyClass, systemExit, localJumpError, nativeException, - systemCallError, fatal, interrupt, typeError, argumentError, indexError, - syntaxError, standardError, loadError, notImplementedError, securityError, noMemoryError, - regexpError, eofError, threadError, concurrencyError, systemStackError, zeroDivisionError, floatDomainError; - - /** - * All the core modules we keep direct references to, for quick access and - * to ensure they remain available. - */ - private RubyModule - kernelModule, comparableModule, enumerableModule, mathModule, - marshalModule, etcModule, fileTestModule, gcModule, - objectSpaceModule, processModule, procUIDModule, procGIDModule, - procSysModule, precisionModule, errnoModule; - - // record separator var, to speed up io ops that use it - private GlobalVariable recordSeparatorVar; - - // former java.lang.System concepts now internalized for MVM - private String currentDirectory; - - private long startTime = System.currentTimeMillis(); - - private RubyInstanceConfig config; - - private InputStream in; - private PrintStream out; - private PrintStream err; - - // Java support - private JavaSupport javaSupport; - private JRubyClassLoader jrubyClassLoader; - - // Management/monitoring - private BeanManager beanManager; - - // Compilation - private final JITCompiler jitCompiler; - - // Note: this field and the following static initializer - // must be located be in this order! - private volatile static boolean securityRestricted = false; - static { - if (SafePropertyAccessor.isSecurityProtected("jruby.reflection")) { - // can't read non-standard properties - securityRestricted = true; - } else { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - try { - sm.checkCreateClassLoader(); - } catch (SecurityException se) { - // can't create custom classloaders - securityRestricted = true; - } - } - } - } - - private Parser parser = new Parser(this); - - private LoadService loadService; - private GlobalVariables globalVariables = new GlobalVariables(this); - private RubyWarnings warnings = new RubyWarnings(this); - - // Contains a list of all blocks (as Procs) that should be called when - // the runtime environment exits. - private Stack<RubyProc> atExitBlocks = new Stack<RubyProc>(); - - private Profile profile; - - private KCode kcode = KCode.NONE; - - // Atomic integers for symbol and method IDs - private AtomicInteger symbolLastId = new AtomicInteger(128); - private AtomicInteger moduleLastId = new AtomicInteger(0); - - private Object respondToMethod; - private Object objectToYamlMethod; - - private Map<String, DateTimeZone> localTimeZoneCache = new HashMap<String,DateTimeZone>(); - /** - * A list of "external" finalizers (the ones, registered via ObjectSpace), - * weakly referenced, to be executed on tearDown. - */ - private Map<Finalizable, Object> finalizers; - - /** - * A list of JRuby-internal finalizers, weakly referenced, - * to be executed on tearDown. - */ - private Map<Finalizable, Object> internalFinalizers; - - // mutex that controls modifications of user-defined finalizers - private final Object finalizersMutex = new Object(); - - // mutex that controls modifications of internal finalizers - private final Object internalFinalizersMutex = new Object(); - - // A thread pool to use for executing this runtime's Ruby threads - private ExecutorService executor; -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.FrameField; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; - -public class RubyArgsFile { - private static final class ArgsFileData { - private final Ruby runtime; - public ArgsFileData(Ruby runtime) { - this.runtime = runtime; - } - - public IRubyObject currentFile; - public int currentLineNumber; - public boolean startedProcessing = false; - public boolean finishedProcessing = false; - - public boolean nextArgsFile(ThreadContext context) { - if (finishedProcessing) { - return false; - } - - RubyArray args = (RubyArray)runtime.getGlobalVariables().get("$*"); - if (args.getLength() == 0) { - if (!startedProcessing) { - currentFile = runtime.getGlobalVariables().get("$stdin"); - ((RubyString) runtime.getGlobalVariables().get("$FILENAME")).setValue(new ByteList(new byte[]{'-'})); - currentLineNumber = 0; - startedProcessing = true; - return true; - } else { - finishedProcessing = true; - return false; - } - } - - IRubyObject arg = args.shift(); - RubyString filename = (RubyString)((RubyObject)arg).to_s(); - ByteList filenameBytes = filename.getByteList(); - ((RubyString) runtime.getGlobalVariables().get("$FILENAME")).setValue(filenameBytes); - - if (filenameBytes.length() == 1 && filenameBytes.get(0) == '-') { - currentFile = runtime.getGlobalVariables().get("$stdin"); - } else { - currentFile = RubyFile.open(context, runtime.getFile(), - new IRubyObject[] {filename.strDup(context.getRuntime())}, Block.NULL_BLOCK); - } - - startedProcessing = true; - return true; - } - - public static ArgsFileData getDataFrom(IRubyObject recv) { - ArgsFileData data = (ArgsFileData)recv.dataGetStruct(); - if(data == null) { - data = new ArgsFileData(recv.getRuntime()); - recv.dataWrapStruct(data); - } - return data; - } - } - - public static void setCurrentLineNumber(IRubyObject recv, int newLineNumber) { - ArgsFileData.getDataFrom(recv).currentLineNumber = newLineNumber; - } - - public static void initArgsFile(Ruby runtime) { - RubyObject argsFile = new RubyObject(runtime, runtime.getObject()); - - runtime.getEnumerable().extend_object(argsFile); - - runtime.defineReadonlyVariable("$<", argsFile); - runtime.defineGlobalConstant("ARGF", argsFile); - - RubyClass argfClass = argsFile.getMetaClass(); - argfClass.defineAnnotatedMethods(RubyArgsFile.class); - runtime.defineReadonlyVariable("$FILENAME", runtime.newString("-")); - } - - @JRubyMethod(name = {"fileno", "to_i"}) - public static IRubyObject fileno(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - - if (data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream"); - } - return ((RubyIO) data.currentFile).fileno(context); - } - - @JRubyMethod(name = "to_io") - public static IRubyObject to_io(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - - if (data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream"); - } - return data.currentFile; - } - - public static IRubyObject internalGets(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - - if(data.currentFile == null && !data.nextArgsFile(context)) { - return context.getRuntime().getNil(); - } - - IRubyObject line = data.currentFile.callMethod(context, "gets", args); - - while (line instanceof RubyNil) { - data.currentFile.callMethod(context, "close"); - if (!data.nextArgsFile(context)) { - data.currentFile = null; - return line; - } - line = data.currentFile.callMethod(context, "gets", args); - } - - data.currentLineNumber++; - context.getRuntime().getGlobalVariables().set("$.", context.getRuntime().newFixnum(data.currentLineNumber)); - - return line; - } - - // ARGF methods - - /** Read a line. - * - */ - @JRubyMethod(name = "gets", optional = 1, frame = true, writes = FrameField.LASTLINE) - public static IRubyObject gets(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject result = internalGets(context, recv, args); - - if (!result.isNil()) { - context.getCurrentFrame().setLastLine(result); - } - - return result; - } - - /** Read a line. - * - */ - @JRubyMethod(name = "readline", optional = 1, frame = true, writes = FrameField.LASTLINE) - public static IRubyObject readline(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject line = gets(context, recv, args); - - if (line.isNil()) { - throw context.getRuntime().newEOFError(); - } - - return line; - } - - @JRubyMethod(name = "readlines", optional = 1, frame = true) - public static RubyArray readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject[] separatorArgument; - if (args.length > 0) { - if (!context.getRuntime().getNilClass().isInstance(args[0]) && - !context.getRuntime().getString().isInstance(args[0])) { - throw context.getRuntime().newTypeError(args[0], context.getRuntime().getString()); - } - separatorArgument = new IRubyObject[] { args[0] }; - } else { - separatorArgument = IRubyObject.NULL_ARRAY; - } - - RubyArray result = context.getRuntime().newArray(); - IRubyObject line; - while (! (line = internalGets(context, recv, separatorArgument)).isNil()) { - result.append(line); - } - return result; - } - - @JRubyMethod(name = "each_byte", frame = true) - public static IRubyObject each_byte(ThreadContext context, IRubyObject recv, Block block) { - IRubyObject bt; - - while(!(bt = getc(context, recv)).isNil()) { - block.yield(context, bt); - } - - return recv; - } - - /** Invoke a block for each line. - * - */ - @JRubyMethod(name = "each_line", alias = {"each"}, optional = 1, frame = true) - public static IRubyObject each_line(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - IRubyObject nextLine = internalGets(context, recv, args); - - while (!nextLine.isNil()) { - block.yield(context, nextLine); - nextLine = internalGets(context, recv, args); - } - - return recv; - } - - @JRubyMethod(name = "file") - public static IRubyObject file(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - - if(data.currentFile == null && !data.nextArgsFile(context)) { - return context.getRuntime().getNil(); - } - return data.currentFile; - } - - @JRubyMethod(name = "skip") - public static IRubyObject skip(IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - data.currentFile = null; - return recv; - } - - @JRubyMethod(name = "close") - public static IRubyObject close(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - return recv; - } - data.currentFile = null; - data.currentLineNumber = 0; - return recv; - } - - @JRubyMethod(name = "closed?") - public static IRubyObject closed_p(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - return recv; - } - return ((RubyIO)data.currentFile).closed_p(context); - } - - @JRubyMethod(name = "binmode") - public static IRubyObject binmode(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream"); - } - - return ((RubyIO)data.currentFile).binmode(); - } - - @JRubyMethod(name = "lineno") - public static IRubyObject lineno(ThreadContext context, IRubyObject recv) { - return context.getRuntime().newFixnum(ArgsFileData.getDataFrom(recv).currentLineNumber); - } - - @JRubyMethod(name = "tell", alias = {"pos"}) - public static IRubyObject tell(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream to tell"); - } - return ((RubyIO)data.currentFile).pos(context); - } - - @JRubyMethod(name = "rewind") - public static IRubyObject rewind(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream to rewind"); - } - return ((RubyIO)data.currentFile).rewind(context); - } - - @JRubyMethod(name = {"eof", "eof?"}) - public static IRubyObject eof(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if (data.currentFile == null && !data.nextArgsFile(context)) { - return context.getRuntime().getTrue(); - } - - return ((RubyIO) data.currentFile).eof_p(context); - } - - @JRubyMethod(name = "pos=", required = 1) - public static IRubyObject set_pos(ThreadContext context, IRubyObject recv, IRubyObject offset) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream to set position"); - } - return ((RubyIO)data.currentFile).pos_set(context, offset); - } - - @JRubyMethod(name = "seek", required = 1, optional = 1) - public static IRubyObject seek(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - if(data.currentFile == null && !data.nextArgsFile(context)) { - throw context.getRuntime().newArgumentError("no stream to seek"); - } - return ((RubyIO)data.currentFile).seek(context, args); - } - - @JRubyMethod(name = "lineno=", required = 1) - public static IRubyObject set_lineno(ThreadContext context, IRubyObject recv, IRubyObject line) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - data.currentLineNumber = RubyNumeric.fix2int(line); - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "readchar") - public static IRubyObject readchar(ThreadContext context, IRubyObject recv) { - IRubyObject c = getc(context, recv); - - if(c.isNil()) throw context.getRuntime().newEOFError(); - - return c; - } - - @JRubyMethod(name = "getc") - public static IRubyObject getc(ThreadContext context, IRubyObject recv) { - ArgsFileData data = ArgsFileData.getDataFrom(recv); - IRubyObject bt; - while(true) { - if(data.currentFile == null && !data.nextArgsFile(context)) { - return context.getRuntime().getNil(); - } - if(!(data.currentFile instanceof RubyFile)) { - bt = data.currentFile.callMethod(context,"getc"); - } else { - bt = ((RubyIO)data.currentFile).getc(); - } - if(bt.isNil()) { - data.currentFile = null; - continue; - } - return bt; - } - } - - @JRubyMethod(name = "read", optional = 2) - public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - ArgsFileData data = ArgsFileData.getDataFrom(recv); - IRubyObject tmp, str, length; - long len = 0; - if(args.length > 0) { - length = args[0]; - if(args.length > 1) { - str = args[1]; - } else { - str = runtime.getNil(); - } - } else { - length = str = runtime.getNil(); - } - - if(!length.isNil()) { - len = RubyNumeric.num2long(length); - } - if(!str.isNil()) { - str = str.convertToString(); - ((RubyString)str).modify(); - ((RubyString)str).getByteList().length(0); - args[1] = runtime.getNil(); - } - while(true) { - if(data.currentFile == null && !data.nextArgsFile(context)) { - return str; - } - if(!(data.currentFile instanceof RubyIO)) { - tmp = data.currentFile.callMethod(context, "read", args); - } else { - tmp = ((RubyIO)data.currentFile).read(args); - } - if(str.isNil()) { - str = tmp; - } else if(!tmp.isNil()) { - ((RubyString)str).append(tmp); - } - if(tmp.isNil() || length.isNil()) { - data.currentFile = null; - continue; - } else if(args.length >= 1) { - if(((RubyString)str).getByteList().length() < len) { - len -= ((RubyString)str).getByteList().length(); - args[0] = runtime.newFixnum(len); - continue; - } - } - return str; - } - } - - @JRubyMethod(name = "filename", alias = {"path"}) - public static RubyString filename(ThreadContext context, IRubyObject recv) { - return (RubyString) context.getRuntime().getGlobalVariables().get("$FILENAME"); - } - - @JRubyMethod(name = "to_s") - public static IRubyObject to_s(IRubyObject recv) { - return recv.getRuntime().newString("ARGF"); - } -} -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Ola Bini <Ola.Bini@ki.se> - * Copyright (C) 2006 Daniel Steer <damian.steer@hp.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.reflect.Array; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.javasupport.JavaUtil; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; -import org.jruby.util.Pack; - -/** - * The implementation of the built-in class Array in Ruby. - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */ -@JRubyClass(name="Array") -public class RubyArray extends RubyObject implements List { - - public static RubyClass createArrayClass(Ruby runtime) { - RubyClass arrayc = runtime.defineClass("Array", runtime.getObject(), ARRAY_ALLOCATOR); - runtime.setArray(arrayc); - arrayc.index = ClassIndex.ARRAY; - arrayc.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyArray; - } - }; - - arrayc.includeModule(runtime.getEnumerable()); - arrayc.defineAnnotatedMethods(RubyArray.class); - - return arrayc; - } - - private static ObjectAllocator ARRAY_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyArray(runtime, klass); - } - }; - - @Override - public int getNativeTypeIndex() { - return ClassIndex.ARRAY; - } - - private final void concurrentModification() { - throw getRuntime().newConcurrencyError("Detected invalid array contents due to unsynchronized modifications with concurrent users"); - } - - /** rb_ary_s_create - * - */ - @JRubyMethod(name = "[]", rest = true, frame = true, meta = true) - public static IRubyObject create(IRubyObject klass, IRubyObject[] args, Block block) { - RubyArray arr = (RubyArray) ((RubyClass) klass).allocate(); - arr.callInit(IRubyObject.NULL_ARRAY, block); - - if (args.length > 0) { - arr.alloc(args.length); - System.arraycopy(args, 0, arr.values, 0, args.length); - arr.realLength = args.length; - } - return arr; - } - - /** rb_ary_new2 - * - */ - public static final RubyArray newArray(final Ruby runtime, final long len) { - return new RubyArray(runtime, len); - } - public static final RubyArray newArrayLight(final Ruby runtime, final long len) { - return new RubyArray(runtime, len, false); - } - - /** rb_ary_new - * - */ - public static final RubyArray newArray(final Ruby runtime) { - return new RubyArray(runtime, ARRAY_DEFAULT_SIZE); - } - - /** rb_ary_new - * - */ - public static final RubyArray newArrayLight(final Ruby runtime) { - /* Ruby arrays default to holding 16 elements, so we create an - * ArrayList of the same size if we're not told otherwise - */ - RubyArray arr = new RubyArray(runtime, false); - arr.alloc(ARRAY_DEFAULT_SIZE); - return arr; - } - - public static RubyArray newArray(Ruby runtime, IRubyObject obj) { - return new RubyArray(runtime, new IRubyObject[] { obj }); - } - - public static RubyArray newArrayLight(Ruby runtime, IRubyObject obj) { - return new RubyArray(runtime, new IRubyObject[] { obj }, false); - } - - /** rb_assoc_new - * - */ - public static RubyArray newArray(Ruby runtime, IRubyObject car, IRubyObject cdr) { - return new RubyArray(runtime, new IRubyObject[] { car, cdr }); - } - - public static RubyArray newEmptyArray(Ruby runtime) { - return new RubyArray(runtime, NULL_ARRAY); - } - - /** rb_ary_new4, rb_ary_new3 - * - */ - public static RubyArray newArray(Ruby runtime, IRubyObject[] args) { - RubyArray arr = new RubyArray(runtime, args.length); - System.arraycopy(args, 0, arr.values, 0, args.length); - arr.realLength = args.length; - return arr; - } - - public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args) { - return new RubyArray(runtime, args); - } - - public static RubyArray newArrayNoCopy(Ruby runtime, IRubyObject[] args, int begin) { - return new RubyArray(runtime, args, begin); - } - - public static RubyArray newArrayNoCopyLight(Ruby runtime, IRubyObject[] args) { - RubyArray arr = new RubyArray(runtime, false); - arr.values = args; - arr.realLength = args.length; - return arr; - } - - public static RubyArray newArray(Ruby runtime, Collection collection) { - RubyArray arr = new RubyArray(runtime, collection.size()); - collection.toArray(arr.values); - arr.realLength = arr.values.length; - return arr; - } - - public static final int ARRAY_DEFAULT_SIZE = 16; - - // volatile to ensure that initial nil-fill is visible to other threads - private volatile IRubyObject[] values; - - private static final int TMPLOCK_ARR_F = 1 << 9; - private static final int TMPLOCK_OR_FROZEN_ARR_F = TMPLOCK_ARR_F | FROZEN_F; - - private volatile boolean isShared = false; - private int begin = 0; - private int realLength = 0; - - /* - * plain internal array assignment - */ - private RubyArray(Ruby runtime, IRubyObject[] vals) { - super(runtime, runtime.getArray()); - values = vals; - realLength = vals.length; - } - - /* - * plain internal array assignment - */ - private RubyArray(Ruby runtime, IRubyObject[] vals, boolean objectSpace) { - super(runtime, runtime.getArray(), objectSpace); - values = vals; - realLength = vals.length; - } - - /* - * plain internal array assignment - */ - private RubyArray(Ruby runtime, IRubyObject[] vals, int begin) { - super(runtime, runtime.getArray()); - this.values = vals; - this.begin = begin; - this.realLength = vals.length - begin; - this.isShared = true; - } - - /* rb_ary_new2 - * just allocates the internal array - */ - private RubyArray(Ruby runtime, long length) { - super(runtime, runtime.getArray()); - checkLength(length); - alloc((int) length); - } - - private RubyArray(Ruby runtime, long length, boolean objectspace) { - super(runtime, runtime.getArray(), objectspace); - checkLength(length); - alloc((int)length); - } - - /* rb_ary_new3, rb_ary_new4 - * allocates the internal array of size length and copies the 'length' elements - */ - public RubyArray(Ruby runtime, long length, IRubyObject[] vals) { - super(runtime, runtime.getArray()); - checkLength(length); - int ilength = (int) length; - alloc(ilength); - if (ilength > 0 && vals.length > 0) System.arraycopy(vals, 0, values, 0, ilength); - - realLength = ilength; - } - - /* NEWOBJ and OBJSETUP equivalent - * fastest one, for shared arrays, optional objectspace - */ - private RubyArray(Ruby runtime, boolean objectSpace) { - super(runtime, runtime.getArray(), objectSpace); - } - - private RubyArray(Ruby runtime) { - super(runtime, runtime.getArray()); - alloc(ARRAY_DEFAULT_SIZE); - } - - public RubyArray(Ruby runtime, RubyClass klass) { - super(runtime, klass); - alloc(ARRAY_DEFAULT_SIZE); - } - - /* Array constructors taking the MetaClass to fulfil MRI Array subclass behaviour - * - */ - private RubyArray(Ruby runtime, RubyClass klass, int length) { - super(runtime, klass); - alloc(length); - } - - private RubyArray(Ruby runtime, RubyClass klass, long length) { - super(runtime, klass); - checkLength(length); - alloc((int)length); - } - - private RubyArray(Ruby runtime, RubyClass klass, long length, boolean objectspace) { - super(runtime, klass, objectspace); - checkLength(length); - alloc((int)length); - } - - private RubyArray(Ruby runtime, RubyClass klass, boolean objectSpace) { - super(runtime, klass, objectSpace); - } - - private RubyArray(Ruby runtime, RubyClass klass, RubyArray original) { - super(runtime, klass); - realLength = original.realLength; - alloc(realLength); - try { - System.arraycopy(original.values, original.begin, values, 0, realLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - - private final IRubyObject[] reserve(int length) { - final IRubyObject[] arr = new IRubyObject[length]; - Arrays.fill(arr, getRuntime().getNil()); - return arr; - } - - private final void alloc(int length) { - final IRubyObject[] newValues = new IRubyObject[length]; - Arrays.fill(newValues, getRuntime().getNil()); - values = newValues; - } - - private final void realloc(int newLength) { - IRubyObject[] reallocated = new IRubyObject[newLength]; - Arrays.fill(reallocated, getRuntime().getNil()); - try { - System.arraycopy(values, 0, reallocated, 0, newLength > realLength ? realLength : newLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - values = reallocated; - } - - private final void checkLength(long length) { - if (length < 0) { - throw getRuntime().newArgumentError("negative array size (or size too big)"); - } - - if (length >= Integer.MAX_VALUE) { - throw getRuntime().newArgumentError("array size too big"); - } - } - - /** Getter for property list. - * @return Value of property list. - */ - public List getList() { - return Arrays.asList(toJavaArray()); - } - - public int getLength() { - return realLength; - } - - public IRubyObject[] toJavaArray() { - IRubyObject[] copy = reserve(realLength); - try { - System.arraycopy(values, begin, copy, 0, realLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - return copy; - } - - public IRubyObject[] toJavaArrayUnsafe() { - return !isShared ? values : toJavaArray(); - } - - public IRubyObject[] toJavaArrayMaybeUnsafe() { - return (!isShared && begin == 0 && values.length == realLength) ? values : toJavaArray(); - } - - /** rb_ary_make_shared - * - */ - private final RubyArray makeShared(int beg, int len, RubyClass klass) { - return makeShared(beg, len, klass, klass.getRuntime().isObjectSpaceEnabled()); - } - - /** rb_ary_make_shared - * - */ - private final RubyArray makeShared(int beg, int len, RubyClass klass, boolean objectSpace) { - RubyArray sharedArray = new RubyArray(getRuntime(), klass, objectSpace); - isShared = true; - sharedArray.values = values; - sharedArray.isShared = true; - sharedArray.begin = beg; - sharedArray.realLength = len; - return sharedArray; - } - - /** rb_ary_modify_check - * - */ - private final void modifyCheck() { - if ((flags & TMPLOCK_OR_FROZEN_ARR_F) != 0) { - if ((flags & FROZEN_F) != 0) throw getRuntime().newFrozenError("array"); - if ((flags & TMPLOCK_ARR_F) != 0) throw getRuntime().newTypeError("can't modify array during iteration"); - } - if (!isTaint() && getRuntime().getSafeLevel() >= 4) { - throw getRuntime().newSecurityError("Insecure: can't modify array"); - } - } - - /** rb_ary_modify - * - */ - private final void modify() { - modifyCheck(); - if (isShared) { - IRubyObject[] vals = reserve(realLength); - isShared = false; - try { - System.arraycopy(values, begin, vals, 0, realLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - begin = 0; - values = vals; - } - } - - /* ================ - * Instance Methods - * ================ - */ - - /** rb_ary_initialize - * - */ - @JRubyMethod(name = "initialize", required = 0, optional = 2, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) { - int argc = args.length; - Ruby runtime = getRuntime(); - - if (argc == 0) { - modifyCheck(); - realLength = 0; - if (block.isGiven()) runtime.getWarnings().warn(ID.BLOCK_UNUSED, "given block not used"); - - return this; - } - - if (argc == 1 && !(args[0] instanceof RubyFixnum)) { - IRubyObject val = args[0].checkArrayType(); - if (!val.isNil()) { - replace(val); - return this; - } - } - - long len = RubyNumeric.num2long(args[0]); - - if (len < 0) throw runtime.newArgumentError("negative array size"); - - if (len >= Integer.MAX_VALUE) throw runtime.newArgumentError("array size too big"); - - int ilen = (int) len; - - modify(); - - if (ilen > values.length) values = reserve(ilen); - - if (block.isGiven()) { - if (argc == 2) { - runtime.getWarnings().warn(ID.BLOCK_BEATS_DEFAULT_VALUE, "block supersedes default value argument"); - } - - for (int i = 0; i < ilen; i++) { - store(i, block.yield(context, new RubyFixnum(runtime, i))); - realLength = i + 1; - } - } else { - try { - Arrays.fill(values, 0, ilen, (argc == 2) ? args[1] : runtime.getNil()); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - realLength = ilen; - } - return this; - } - - /** rb_ary_initialize_copy - * - */ - @JRubyMethod(name = {"initialize_copy"}, required = 1, visibility=Visibility.PRIVATE) - @Override - public IRubyObject initialize_copy(IRubyObject orig) { - return this.replace(orig); - } - - /** rb_ary_replace - * - */ - @JRubyMethod(name = {"replace"}, required = 1) - public IRubyObject replace(IRubyObject orig) { - modifyCheck(); - - RubyArray origArr = orig.convertToArray(); - - if (this == orig) return this; - - origArr.isShared = true; - isShared = true; - values = origArr.values; - realLength = origArr.realLength; - begin = origArr.begin; - - - return this; - } - - /** rb_ary_to_s - * - */ - @JRubyMethod(name = "to_s") - @Override - public IRubyObject to_s() { - if (realLength == 0) return RubyString.newEmptyString(getRuntime()); - - return join(getRuntime().getCurrentContext(), getRuntime().getGlobalVariables().get("$,")); - } - - - public boolean includes(ThreadContext context, IRubyObject item) { - int begin = this.begin; - - for (int i = begin; i < begin + realLength; i++) { - final IRubyObject value; - try { - value = values[i]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - continue; - } - if (equalInternal(context, value, item)) return true; - } - - return false; - } - - /** rb_ary_hash - * - */ - @JRubyMethod(name = "hash") - public RubyFixnum hash(ThreadContext context) { - int h = realLength; - - Ruby runtime = getRuntime(); - int begin = this.begin; - for (int i = begin; i < begin + realLength; i++) { - h = (h << 1) | (h < 0 ? 1 : 0); - final IRubyObject value; - try { - value = values[i]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - continue; - } - h ^= RubyNumeric.num2long(value.callMethod(context, MethodIndex.HASH, "hash")); - } - - return runtime.newFixnum(h); - } - - /** rb_ary_store - * - */ - public final IRubyObject store(long index, IRubyObject value) { - if (index < 0) { - index += realLength; - if (index < 0) { - throw getRuntime().newIndexError("index " + (index - realLength) + " out of array"); - } - } - - modify(); - - if (index >= realLength) { - if (index >= values.length) { - long newLength = values.length >> 1; - - if (newLength < ARRAY_DEFAULT_SIZE) newLength = ARRAY_DEFAULT_SIZE; - - newLength += index; - if (index >= Integer.MAX_VALUE || newLength >= Integer.MAX_VALUE) { - throw getRuntime().newArgumentError("index too big"); - } - realloc((int) newLength); - } - - realLength = (int) index + 1; - } - - try { - values[(int) index] = value; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - return value; - } - - /** rb_ary_elt - * - */ - private final IRubyObject elt(long offset) { - if (offset < 0 || offset >= realLength) { - return getRuntime().getNil(); - } - try { - return values[begin + (int)offset]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - } - - /** rb_ary_entry - * - */ - public final IRubyObject entry(long offset) { - return (offset < 0 ) ? elt(offset + realLength) : elt(offset); - } - - - /** rb_ary_entry - * - */ - public final IRubyObject entry(int offset) { - return (offset < 0 ) ? elt(offset + realLength) : elt(offset); - } - - public final IRubyObject eltInternal(int offset) { - return values[begin + offset]; - } - - public final IRubyObject eltInternalSet(int offset, IRubyObject item) { - return values[begin + offset] = item; - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject fetch(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 1: - return fetch(context, args[0], block); - case 2: - return fetch(context, args[0], args[1], block); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_ary_fetch - * - */ - @JRubyMethod(name = "fetch", frame = true) - public IRubyObject fetch(ThreadContext context, IRubyObject arg0, Block block) { - long index = RubyNumeric.num2long(arg0); - - if (index < 0) index += realLength; - if (index < 0 || index >= realLength) { - if (block.isGiven()) return block.yield(context, arg0); - throw getRuntime().newIndexError("index " + index + " out of array"); - } - - try { - return values[begin + (int) index]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - } - - /** rb_ary_fetch - * - */ - @JRubyMethod(name = "fetch", frame = true) - public IRubyObject fetch(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - if (block.isGiven()) getRuntime().getWarnings().warn(ID.BLOCK_BEATS_DEFAULT_VALUE, "block supersedes default value argument"); - - long index = RubyNumeric.num2long(arg0); - - if (index < 0) index += realLength; - if (index < 0 || index >= realLength) { - if (block.isGiven()) return block.yield(context, arg0); - return arg1; - } - - try { - return values[begin + (int) index]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - } - - /** rb_ary_to_ary - * - */ - private static RubyArray aryToAry(IRubyObject obj) { - if (obj instanceof RubyArray) return (RubyArray) obj; - - if (obj.respondsTo("to_ary")) return obj.convertToArray(); - - RubyArray arr = new RubyArray(obj.getRuntime(), false); // possibly should not in object space - arr.alloc(1); - arr.values[0] = obj; - arr.realLength = 1; - return arr; - } - - /** rb_ary_splice - * - */ - private final void splice(long beg, long len, IRubyObject rpl) { - if (len < 0) throw getRuntime().newIndexError("negative length (" + len + ")"); - - if (beg < 0) { - beg += realLength; - if (beg < 0) { - beg -= realLength; - throw getRuntime().newIndexError("index " + beg + " out of array"); - } - } - - final RubyArray rplArr; - final int rlen; - - if (rpl == null || rpl.isNil()) { - rplArr = null; - rlen = 0; - } else { - rplArr = aryToAry(rpl); - rlen = rplArr.realLength; - } - - modify(); - - if (beg >= realLength) { - len = beg + rlen; - - if (len >= values.length) { - int tryNewLength = values.length + (values.length >> 1); - realloc(len > tryNewLength ? (int)len : tryNewLength); - } - - realLength = (int) len; - } else { - if (beg + len > realLength) len = realLength - beg; - - long alen = realLength + rlen - len; - if (alen >= values.length) { - int tryNewLength = values.length + (values.length >> 1); - realloc(alen > tryNewLength ? (int)alen : tryNewLength); - } - - if (len != rlen) { - try { - System.arraycopy(values, (int) (beg + len), values, (int) beg + rlen, realLength - (int) (beg + len)); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - realLength = (int) alen; - } - } - - if (rlen > 0) { - try { - System.arraycopy(rplArr.values, rplArr.begin, values, (int) beg, rlen); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - } - - /** rb_ary_splice - * - */ - private final void spliceOne(long beg, long len, IRubyObject rpl) { - if (len < 0) throw getRuntime().newIndexError("negative length (" + len + ")"); - - if (beg < 0) { - beg += realLength; - if (beg < 0) { - beg -= realLength; - throw getRuntime().newIndexError("index " + beg + " out of array"); - } - } - - modify(); - - if (beg >= realLength) { - len = beg + 1; - - if (len >= values.length) { - int tryNewLength = values.length + (values.length >> 1); - realloc(len > tryNewLength ? (int)len : tryNewLength); - } - - realLength = (int) len; - } else { - if (beg + len > realLength) len = realLength - beg; - - int alen = realLength + 1 - (int)len; - if (alen >= values.length) { - int tryNewLength = values.length + (values.length >> 1); - realloc(alen > tryNewLength ? alen : tryNewLength); - } - - if (len != 1) { - try { - System.arraycopy(values, (int) (beg + len), values, (int) beg + 1, realLength - (int) (beg + len)); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - realLength = alen; - } - } - - try { - values[(int)beg] = rpl; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - - @JRubyMethod - public IRubyObject insert() { - throw getRuntime().newArgumentError(0, 1); - } - - /** rb_ary_insert - * - */ - @JRubyMethod - public IRubyObject insert(IRubyObject arg) { - return this; - } - - /** rb_ary_insert - * - */ - @JRubyMethod - public IRubyObject insert(IRubyObject arg1, IRubyObject arg2) { - long pos = RubyNumeric.num2long(arg1); - - if (pos == -1) pos = realLength; - if (pos < 0) pos++; - - spliceOne(pos, 0, arg2); // rb_ary_new4 - - return this; - } - - /** rb_ary_insert - * - */ - @JRubyMethod(name = "insert", required = 1, rest = true) - public IRubyObject insert(IRubyObject[] args) { - if (args.length == 1) return this; - - long pos = RubyNumeric.num2long(args[0]); - - if (pos == -1) pos = realLength; - if (pos < 0) pos++; - - RubyArray inserted = new RubyArray(getRuntime(), false); - inserted.values = args; - inserted.begin = 1; - inserted.realLength = args.length - 1; - - splice(pos, 0, inserted); // rb_ary_new4 - - return this; - } - - /** rb_ary_dup - * - */ - public final RubyArray aryDup() { - RubyArray dup = new RubyArray(getRuntime(), getMetaClass(), this); - dup.flags |= flags & TAINTED_F; // from DUP_SETUP - // rb_copy_generic_ivar from DUP_SETUP here ...unlikely.. - return dup; - } - - /** rb_ary_transpose - * - */ - @JRubyMethod(name = "transpose") - public RubyArray transpose() { - RubyArray tmp, result = null; - - int alen = realLength; - if (alen == 0) return aryDup(); - - Ruby runtime = getRuntime(); - int elen = -1; - int end = begin + alen; - for (int i = begin; i < end; i++) { - tmp = elt(i).convertToArray(); - if (elen < 0) { - elen = tmp.realLength; - result = new RubyArray(runtime, elen); - for (int j = 0; j < elen; j++) { - result.store(j, new RubyArray(runtime, alen)); - } - } else if (elen != tmp.realLength) { - throw runtime.newIndexError("element size differs (" + tmp.realLength - + " should be " + elen + ")"); - } - for (int j = 0; j < elen; j++) { - ((RubyArray) result.elt(j)).store(i - begin, tmp.elt(j)); - } - } - return result; - } - - /** rb_values_at (internal) - * - */ - private final IRubyObject values_at(long olen, IRubyObject[] args) { - RubyArray result = new RubyArray(getRuntime(), args.length); - - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof RubyFixnum) { - result.append(entry(((RubyFixnum)args[i]).getLongValue())); - continue; - } - - long beglen[]; - if (!(args[i] instanceof RubyRange)) { - } else if ((beglen = ((RubyRange) args[i]).begLen(olen, 0)) == null) { - continue; - } else { - int beg = (int) beglen[0]; - int len = (int) beglen[1]; - int end = begin + len; - for (int j = begin; j < end; j++) { - result.append(entry(j + beg)); - } - continue; - } - result.append(entry(RubyNumeric.num2long(args[i]))); - } - - return result; - } - - /** rb_values_at - * - */ - @JRubyMethod(name = "values_at", rest = true) - public IRubyObject values_at(IRubyObject[] args) { - return values_at(realLength, args); - } - - /** rb_ary_subseq - * - */ - public IRubyObject subseq(long beg, long len) { - if (beg > realLength || beg < 0 || len < 0) return getRuntime().getNil(); - - if (beg + len > realLength) { - len = realLength - beg; - - if (len < 0) len = 0; - } - - if (len == 0) return new RubyArray(getRuntime(), getMetaClass(), 0); - - return makeShared(begin + (int) beg, (int) len, getMetaClass()); - } - - /** rb_ary_subseq - * - */ - public IRubyObject subseqLight(long beg, long len) { - if (beg > realLength || beg < 0 || len < 0) return getRuntime().getNil(); - - if (beg + len > realLength) { - len = realLength - beg; - - if (len < 0) len = 0; - } - - if (len == 0) return new RubyArray(getRuntime(), getMetaClass(), 0, false); - - return makeShared(begin + (int) beg, (int) len, getMetaClass(), false); - } - - /** rb_ary_length - * - */ - @JRubyMethod(name = "length", alias = "size") - public RubyFixnum length() { - return getRuntime().newFixnum(realLength); - } - - /** rb_ary_push - specialized rb_ary_store - * - */ - @JRubyMethod(name = "<<", required = 1) - public RubyArray append(IRubyObject item) { - modify(); - - if (realLength == values.length) { - if (realLength == Integer.MAX_VALUE) throw getRuntime().newArgumentError("index too big"); - - long newLength = values.length + (values.length >> 1); - if ( newLength > Integer.MAX_VALUE ) { - newLength = Integer.MAX_VALUE; - }else if ( newLength < ARRAY_DEFAULT_SIZE ) { - newLength = ARRAY_DEFAULT_SIZE; - } - - realloc((int) newLength); - } - - try { - values[realLength++] = item; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - return this; - } - - /** rb_ary_push_m - * FIXME: Whis is this named "push_m"? - */ - @JRubyMethod(name = "push", rest = true) - public RubyArray push_m(IRubyObject[] items) { - for (int i = 0; i < items.length; i++) { - append(items[i]); - } - - return this; - } - - /** rb_ary_pop - * - */ - @JRubyMethod(name = "pop") - public IRubyObject pop() { - modifyCheck(); - - if (realLength == 0) return getRuntime().getNil(); - - if (isShared) { - try { - return values[begin + --realLength]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - } else { - int index = begin + --realLength; - try { - final IRubyObject obj = values[index]; - values[index] = getRuntime().getNil(); - return obj; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - } - } - - /** rb_ary_shift - * - */ - @JRubyMethod(name = "shift") - public IRubyObject shift() { - modify(); - - if (realLength == 0) return getRuntime().getNil(); - - final IRubyObject obj; - try { - obj = values[begin]; - values[begin] = getRuntime().getNil(); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return getRuntime().getNil(); - } - - isShared = true; - - begin++; - realLength--; - - return obj; - } - - /** rb_ary_unshift - * - */ - public RubyArray unshift(IRubyObject item) { - modify(); - - if (realLength == values.length) { - int newLength = values.length >> 1; - if (newLength < ARRAY_DEFAULT_SIZE) newLength = ARRAY_DEFAULT_SIZE; - - newLength += values.length; - realloc(newLength); - } - try { - System.arraycopy(values, 0, values, 1, realLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - - realLength++; - values[0] = item; - - return this; - } - - /** rb_ary_unshift_m - * - */ - @JRubyMethod(name = "unshift", rest = true) - public RubyArray unshift_m(IRubyObject[] items) { - long len = realLength; - - if (items.length == 0) return this; - - store(len + items.length - 1, getRuntime().getNil()); - - try { - // it's safe to use zeroes here since modified by store() - System.arraycopy(values, 0, values, items.length, (int) len); - System.arraycopy(items, 0, values, 0, items.length); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - - return this; - } - - /** rb_ary_includes - * - */ - @JRubyMethod(name = "include?", required = 1) - public RubyBoolean include_p(ThreadContext context, IRubyObject item) { - return context.getRuntime().newBoolean(includes(context, item)); - } - - /** rb_ary_frozen_p - * - */ - @JRubyMethod(name = "frozen?") - @Override - public RubyBoolean frozen_p(ThreadContext context) { - return context.getRuntime().newBoolean(isFrozen() || (flags & TMPLOCK_ARR_F) != 0); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject aref(IRubyObject[] args) { - switch (args.length) { - case 1: - return aref(args[0]); - case 2: - return aref(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_ary_aref - */ - @JRubyMethod(name = {"[]", "slice"}) - public IRubyObject aref(IRubyObject arg0) { - if (arg0 instanceof RubyFixnum) return entry(((RubyFixnum)arg0).getLongValue()); - if (arg0 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as array index"); - - long[] beglen; - if (!(arg0 instanceof RubyRange)) { - } else if ((beglen = ((RubyRange) arg0).begLen(realLength, 0)) == null) { - return getRuntime().getNil(); - } else { - return subseq(beglen[0], beglen[1]); - } - return entry(RubyNumeric.num2long(arg0)); - } - - /** rb_ary_aref - */ - @JRubyMethod(name = {"[]", "slice"}) - public IRubyObject aref(IRubyObject arg0, IRubyObject arg1) { - if (arg0 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as array index"); - - long beg = RubyNumeric.num2long(arg0); - if (beg < 0) beg += realLength; - - return subseq(beg, RubyNumeric.num2long(arg1)); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject aset(IRubyObject[] args) { - switch (args.length) { - case 2: - return aset(args[0], args[1]); - case 3: - return aset(args[0], args[1], args[2]); - default: - throw getRuntime().newArgumentError("wrong number of arguments (" + args.length + " for 2)"); - } - } - - /** rb_ary_aset - * - */ - @JRubyMethod(name = "[]=") - public IRubyObject aset(IRubyObject arg0, IRubyObject arg1) { - if (arg0 instanceof RubyFixnum) { - store(((RubyFixnum)arg0).getLongValue(), arg1); - return arg1; - } - if (arg0 instanceof RubyRange) { - long[] beglen = ((RubyRange) arg0).begLen(realLength, 1); - splice(beglen[0], beglen[1], arg1); - return arg1; - } - if (arg0 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as array index"); - - store(RubyNumeric.num2long(arg0), arg1); - return arg1; - } - - /** rb_ary_aset - * - */ - @JRubyMethod(name = "[]=") - public IRubyObject aset(IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { - if (arg0 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as array index"); - if (arg1 instanceof RubySymbol) throw getRuntime().newTypeError("Symbol as subarray length"); - splice(RubyNumeric.num2long(arg0), RubyNumeric.num2long(arg1), arg2); - return arg2; - } - - /** rb_ary_at - * - */ - @JRubyMethod(name = "at", required = 1) - public IRubyObject at(IRubyObject pos) { - return entry(RubyNumeric.num2long(pos)); - } - - /** rb_ary_concat - * - */ - @JRubyMethod(name = "concat", required = 1) - public RubyArray concat(IRubyObject obj) { - RubyArray ary = obj.convertToArray(); - - if (ary.realLength > 0) splice(realLength, 0, ary); - - return this; - } - - /** inspect_ary - * - */ - private IRubyObject inspectAry(ThreadContext context) { - ByteList buffer = new ByteList(); - buffer.append('['); - boolean tainted = isTaint(); - - for (int i = 0; i < realLength; i++) { - if (i > 0) buffer.append(',').append(' '); - - RubyString str = inspect(context, values[begin + i]); - if (str.isTaint()) tainted = true; - buffer.append(str.getByteList()); - } - buffer.append(']'); - - RubyString str = getRuntime().newString(buffer); - if (tainted) str.setTaint(true); - - return str; - } - - /** rb_ary_inspect - * - */ - @JRubyMethod(name = "inspect") - @Override - public IRubyObject inspect() { - if (realLength == 0) return getRuntime().newString("[]"); - if (getRuntime().isInspecting(this)) return getRuntime().newString("[...]"); - - try { - getRuntime().registerInspecting(this); - return inspectAry(getRuntime().getCurrentContext()); - } finally { - getRuntime().unregisterInspecting(this); - } - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject first(IRubyObject[] args) { - switch (args.length) { - case 0: - return first(); - case 1: - return first(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** rb_ary_first - * - */ - @JRubyMethod(name = "first") - public IRubyObject first() { - if (realLength == 0) return getRuntime().getNil(); - return values[begin]; - } - - /** rb_ary_first - * - */ - @JRubyMethod(name = "first") - public IRubyObject first(IRubyObject arg0) { - long n = RubyNumeric.num2long(arg0); - if (n > realLength) { - n = realLength; - } else if (n < 0) { - throw getRuntime().newArgumentError("negative array size (or size too big)"); - } - - return makeShared(begin, (int) n, getRuntime().getArray()); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject last(IRubyObject[] args) { - switch (args.length) { - case 0: - return last(); - case 1: - return last(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** rb_ary_last - * - */ - @JRubyMethod(name = "last") - public IRubyObject last() { - if (realLength == 0) return getRuntime().getNil(); - return values[begin + realLength - 1]; - } - - /** rb_ary_last - * - */ - @JRubyMethod(name = "last") - public IRubyObject last(IRubyObject arg0) { - long n = RubyNumeric.num2long(arg0); - if (n > realLength) { - n = realLength; - } else if (n < 0) { - throw getRuntime().newArgumentError("negative array size (or size too big)"); - } - - return makeShared(begin + realLength - (int) n, (int) n, getRuntime().getArray()); - } - - /** rb_ary_each - * - */ - @JRubyMethod(name = "each", frame = true) - public IRubyObject each(ThreadContext context, Block block) { - for (int i = 0; i < realLength; i++) { - block.yield(context, values[begin + i]); - } - return this; - } - - /** rb_ary_each_index - * - */ - @JRubyMethod(name = "each_index", frame = true) - public IRubyObject each_index(ThreadContext context, Block block) { - Ruby runtime = getRuntime(); - for (int i = 0; i < realLength; i++) { - block.yield(context, runtime.newFixnum(i)); - } - return this; - } - - /** rb_ary_reverse_each - * - */ - @JRubyMethod(name = "reverse_each", frame = true) - public IRubyObject reverse_each(ThreadContext context, Block block) { - int len = realLength; - - while(len-- > 0) { - block.yield(context, values[begin + len]); - - if (realLength < len) len = realLength; - } - - return this; - } - - private IRubyObject inspectJoin(ThreadContext context, RubyArray tmp, IRubyObject sep) { - Ruby runtime = getRuntime(); - - // If already inspecting, there is no need to register/unregister again. - if (runtime.isInspecting(this)) { - return tmp.join(context, sep); - } - - try { - runtime.registerInspecting(this); - return tmp.join(context, sep); - } finally { - runtime.unregisterInspecting(this); - } - } - - /** rb_ary_join - * - */ - public RubyString join(ThreadContext context, IRubyObject sep) { - final Ruby runtime = getRuntime(); - - if (realLength == 0) return RubyString.newEmptyString(getRuntime()); - - boolean taint = isTaint() || sep.isTaint(); - - long len = 1; - for (int i = begin; i < begin + realLength; i++) { - IRubyObject value; - try { - value = values[i]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return runtime.newString(""); - } - IRubyObject tmp = value.checkStringType(); - len += tmp.isNil() ? 10 : ((RubyString) tmp).getByteList().length(); - } - - RubyString strSep = null; - if (!sep.isNil()) { - sep = strSep = sep.convertToString(); - len += strSep.getByteList().length() * (realLength - 1); - } - - ByteList buf = new ByteList((int)len); - for (int i = begin; i < begin + realLength; i++) { - IRubyObject tmp; - try { - tmp = values[i]; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - return runtime.newString(""); - } - if (tmp instanceof RubyString) { - // do nothing - } else if (tmp instanceof RubyArray) { - if (runtime.isInspecting(tmp)) { - tmp = runtime.newString("[...]"); - } else { - tmp = inspectJoin(context, (RubyArray)tmp, sep); - } - } else { - tmp = RubyString.objAsString(context, tmp); - } - - if (i > begin && !sep.isNil()) buf.append(strSep.getByteList()); - - buf.append(tmp.asString().getByteList()); - if (tmp.isTaint()) taint = true; - } - - RubyString result = runtime.newString(buf); - - if (taint) result.setTaint(true); - - return result; - } - - /** rb_ary_join_m - * - */ - @JRubyMethod(name = "join", optional = 1) - public RubyString join_m(ThreadContext context, IRubyObject[] args) { - int argc = args.length; - IRubyObject sep = (argc == 1) ? args[0] : getRuntime().getGlobalVariables().get("$,"); - - return join(context, sep); - } - - /** rb_ary_to_a - * - */ - @JRubyMethod(name = "to_a") - @Override - public RubyArray to_a() { - if(getMetaClass() != getRuntime().getArray()) { - RubyArray dup = new RubyArray(getRuntime(), getRuntime().isObjectSpaceEnabled()); - - isShared = true; - dup.isShared = true; - dup.values = values; - dup.realLength = realLength; - dup.begin = begin; - - return dup; - } - return this; - } - - @JRubyMethod(name = "to_ary") - public IRubyObject to_ary() { - return this; - } - - @Override - public RubyArray convertToArray() { - return this; - } - - @Override - public IRubyObject checkArrayType(){ - return this; - } - - /** rb_ary_equal - * - */ - @JRubyMethod(name = "==", required = 1) - @Override - public IRubyObject op_equal(ThreadContext context, IRubyObject obj) { - if (this == obj) return getRuntime().getTrue(); - - if (!(obj instanceof RubyArray)) { - if (!obj.respondsTo("to_ary")) { - return getRuntime().getFalse(); - } else { - if (equalInternal(context, obj.callMethod(context, "to_ary"), this)) return getRuntime().getTrue(); - return getRuntime().getFalse(); - } - } - - RubyArray ary = (RubyArray) obj; - if (realLength != ary.realLength) return getRuntime().getFalse(); - - Ruby runtime = getRuntime(); - for (long i = 0; i < realLength; i++) { - if (!equalInternal(context, elt(i), ary.elt(i))) return runtime.getFalse(); - } - return runtime.getTrue(); - } - - /** rb_ary_eql - * - */ - @JRubyMethod(name = "eql?", required = 1) - public RubyBoolean eql_p(ThreadContext context, IRubyObject obj) { - if (this == obj) return getRuntime().getTrue(); - if (!(obj instanceof RubyArray)) return getRuntime().getFalse(); - - RubyArray ary = (RubyArray) obj; - - if (realLength != ary.realLength) return getRuntime().getFalse(); - - Ruby runtime = getRuntime(); - for (int i = 0; i < realLength; i++) { - if (!eqlInternal(context, elt(i), ary.elt(i))) return runtime.getFalse(); - } - return runtime.getTrue(); - } - - /** rb_ary_compact_bang - * - */ - @JRubyMethod(name = "compact!") - public IRubyObject compact_bang() { - modify(); - - int p = 0; - int t = 0; - int end = p + realLength; - - while (t < end) { - if (values[t].isNil()) { - t++; - } else { - values[p++] = values[t++]; - } - } - - if (realLength == p) return getRuntime().getNil(); - - realloc(p); - realLength = p; - return this; - } - - /** rb_ary_compact - * - */ - @JRubyMethod(name = "compact") - public IRubyObject compact() { - RubyArray ary = aryDup(); - ary.compact_bang(); - return ary; - } - - /** rb_ary_empty_p - * - */ - @JRubyMethod(name = "empty?") - public IRubyObject empty_p() { - return realLength == 0 ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - /** rb_ary_clear - * - */ - @JRubyMethod(name = "clear") - public IRubyObject rb_clear() { - modifyCheck(); - - if(isShared) { - alloc(ARRAY_DEFAULT_SIZE); - isShared = true; - } else if (values.length > ARRAY_DEFAULT_SIZE << 1){ - alloc(ARRAY_DEFAULT_SIZE << 1); - } else { - final int begin = this.begin; - try { - Arrays.fill(values, begin, begin + realLength, getRuntime().getNil()); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - - begin = 0; - realLength = 0; - return this; - } - - /** rb_ary_fill - * - */ - @JRubyMethod(name = "fill", optional = 3, frame = true) - public IRubyObject fill(ThreadContext context, IRubyObject[] args, Block block) { - IRubyObject item = null; - IRubyObject begObj = null; - IRubyObject lenObj = null; - int argc = args.length; - - if (block.isGiven()) { - Arity.checkArgumentCount(getRuntime(), args, 0, 2); - item = null; - begObj = argc > 0 ? args[0] : null; - lenObj = argc > 1 ? args[1] : null; - argc++; - } else { - Arity.checkArgumentCount(getRuntime(), args, 1, 3); - item = args[0]; - begObj = argc > 1 ? args[1] : null; - lenObj = argc > 2 ? args[2] : null; - } - - int beg = 0, end = 0, len = 0; - switch (argc) { - case 1: - beg = 0; - len = realLength; - break; - case 2: - if (begObj instanceof RubyRange) { - long[] beglen = ((RubyRange) begObj).begLen(realLength, 1); - beg = (int) beglen[0]; - len = (int) beglen[1]; - break; - } - /* fall through */ - case 3: - beg = begObj.isNil() ? 0 : RubyNumeric.num2int(begObj); - if (beg < 0) { - beg = realLength + beg; - if (beg < 0) beg = 0; - } - len = (lenObj == null || lenObj.isNil()) ? realLength - beg : RubyNumeric.num2int(lenObj); - // TODO: In MRI 1.9, an explicit check for negative length is - // added here. IndexError is raised when length is negative. - // See [ruby-core:12953] for more details. - // - // New note: This is actually under re-evaluation, - // see [ruby-core:17483]. - break; - } - - modify(); - - // See [ruby-core:17483] - if (len < 0) { - return this; - } - - if (len > Integer.MAX_VALUE - beg) { - throw getRuntime().newArgumentError("argument too big"); - } - - end = beg + len; - if (end > realLength) { - if (end >= values.length) realloc(end); - - realLength = end; - } - - if (block.isGiven()) { - Ruby runtime = getRuntime(); - for (int i = beg; i < end; i++) { - IRubyObject v = block.yield(context, runtime.newFixnum(i)); - if (i >= realLength) break; - try { - values[i] = v; - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - } else { - if (len > 0) { - try { - Arrays.fill(values, beg, beg + len, item); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - } - } - - return this; - } - - /** rb_ary_index - * - */ - @JRubyMethod(name = "index", required = 1) - public IRubyObject index(ThreadContext context, IRubyObject obj) { - Ruby runtime = getRuntime(); - for (int i = begin; i < begin + realLength; i++) { - if (equalInternal(context, values[i], obj)) return runtime.newFixnum(i - begin); - } - - return runtime.getNil(); - } - - /** rb_ary_rindex - * - */ - @JRubyMethod(name = "rindex", required = 1) - public IRubyObject rindex(ThreadContext context, IRubyObject obj) { - Ruby runtime = getRuntime(); - int i = realLength; - - while (i-- > 0) { - if (i > realLength) { - i = realLength; - continue; - } - if (equalInternal(context, values[begin + i], obj)) return getRuntime().newFixnum(i); - } - - return runtime.getNil(); - } - - /** rb_ary_indexes - * - */ - @JRubyMethod(name = {"indexes", "indices"}, required = 1, rest = true) - public IRubyObject indexes(IRubyObject[] args) { - getRuntime().getWarnings().warn(ID.DEPRECATED_METHOD, "Array#indexes is deprecated; use Array#values_at", "Array#indexes", "Array#values_at"); - - RubyArray ary = new RubyArray(getRuntime(), args.length); - - IRubyObject[] arefArgs = new IRubyObject[1]; - for (int i = 0; i < args.length; i++) { - arefArgs[0] = args[i]; - ary.append(aref(arefArgs)); - } - - return ary; - } - - /** rb_ary_reverse_bang - * - */ - @JRubyMethod(name = "reverse!") - public IRubyObject reverse_bang() { - modify(); - - final int realLength = this.realLength; - final IRubyObject[] values = this.values; - try { - if (realLength > 1) { - int p1 = 0; - int p2 = p1 + realLength - 1; - - while (p1 < p2) { - final IRubyObject tmp = values[p1]; - values[p1++] = values[p2]; - values[p2--] = tmp; - } - } - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - return this; - } - - /** rb_ary_reverse_m - * - */ - @JRubyMethod(name = "reverse") - public IRubyObject reverse() { - return aryDup().reverse_bang(); - } - - /** rb_ary_collect - * - */ - @JRubyMethod(name = {"collect", "map"}, frame = true) - public RubyArray collect(ThreadContext context, Block block) { - Ruby runtime = getRuntime(); - - if (!block.isGiven()) return new RubyArray(getRuntime(), runtime.getArray(), this); - - RubyArray collect = new RubyArray(runtime, realLength); - - for (int i = begin; i < begin + realLength; i++) { - collect.append(block.yield(context, values[i])); - } - - return collect; - } - - /** rb_ary_collect_bang - * - */ - @JRubyMethod(name = {"collect!", "map!"}, frame = true) - public RubyArray collect_bang(ThreadContext context, Block block) { - modify(); - for (int i = 0, len = realLength; i < len; i++) { - store(i, block.yield(context, values[begin + i])); - } - return this; - } - - /** rb_ary_select - * - */ - @JRubyMethod(name = "select", frame = true) - public RubyArray select(ThreadContext context, Block block) { - Ruby runtime = getRuntime(); - RubyArray result = new RubyArray(runtime, realLength); - - if (isShared) { - for (int i = begin; i < begin + realLength; i++) { - if (block.yield(context, values[i]).isTrue()) result.append(elt(i - begin)); - } - } else { - for (int i = 0; i < realLength; i++) { - if (block.yield(context, values[i]).isTrue()) result.append(elt(i)); - } - } - return result; - } - - /** rb_ary_delete - * - */ - @JRubyMethod(name = "delete", required = 1, frame = true) - public IRubyObject delete(ThreadContext context, IRubyObject item, Block block) { - int i2 = 0; - - Ruby runtime = getRuntime(); - for (int i1 = 0; i1 < realLength; i1++) { - IRubyObject e = values[begin + i1]; - if (equalInternal(context, e, item)) continue; - if (i1 != i2) store(i2, e); - i2++; - } - - if (realLength == i2) { - if (block.isGiven()) return block.yield(context, item); - - return runtime.getNil(); - } - - modify(); - - final int realLength = this.realLength; - final int begin = this.begin; - final IRubyObject[] values = this.values; - if (realLength > i2) { - try { - Arrays.fill(values, begin + i2, begin + realLength, getRuntime().getNil()); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - this.realLength = i2; - if (i2 << 1 < values.length && values.length > ARRAY_DEFAULT_SIZE) realloc(i2 << 1); - } - - return item; - } - - /** rb_ary_delete_at - * - */ - private final IRubyObject delete_at(int pos) { - int len = realLength; - - if (pos >= len) return getRuntime().getNil(); - - if (pos < 0) pos += len; - - if (pos < 0) return getRuntime().getNil(); - - modify(); - - IRubyObject obj = values[pos]; - try { - System.arraycopy(values, pos + 1, values, pos, len - (pos + 1)); - values[realLength-1] = getRuntime().getNil(); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - realLength--; - - return obj; - } - - /** rb_ary_delete_at_m - * - */ - @JRubyMethod(name = "delete_at", required = 1) - public IRubyObject delete_at(IRubyObject obj) { - return delete_at((int) RubyNumeric.num2long(obj)); - } - - /** rb_ary_reject_bang - * - */ - @JRubyMethod(name = "reject", frame = true) - public IRubyObject reject(ThreadContext context, Block block) { - RubyArray ary = aryDup(); - ary.reject_bang(context, block); - return ary; - } - - /** rb_ary_reject_bang - * - */ - @JRubyMethod(name = "reject!", frame = true) - public IRubyObject reject_bang(ThreadContext context, Block block) { - int i2 = 0; - modify(); - - for (int i1 = 0; i1 < realLength; i1++) { - IRubyObject v = values[i1]; - if (block.yield(context, v).isTrue()) continue; - - if (i1 != i2) store(i2, v); - i2++; - } - if (realLength == i2) return getRuntime().getNil(); - - if (i2 < realLength) { - try { - Arrays.fill(values, i2, realLength, getRuntime().getNil()); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - realLength = i2; - } - - return this; - } - - /** rb_ary_delete_if - * - */ - @JRubyMethod(name = "delete_if", frame = true) - public IRubyObject delete_if(ThreadContext context, Block block) { - reject_bang(context, block); - return this; - } - - /** rb_ary_zip - * - */ - @JRubyMethod(name = "zip", optional = 1, rest = true, frame = true) - public IRubyObject zip(ThreadContext context, IRubyObject[] args, Block block) { - for (int i = 0; i < args.length; i++) { - args[i] = args[i].convertToArray(); - } - - Ruby runtime = getRuntime(); - if (block.isGiven()) { - for (int i = 0; i < realLength; i++) { - RubyArray tmp = new RubyArray(runtime, args.length + 1); - tmp.append(elt(i)); - for (int j = 0; j < args.length; j++) { - tmp.append(((RubyArray) args[j]).elt(i)); - } - block.yield(context, tmp); - } - return runtime.getNil(); - } - - int len = realLength; - RubyArray result = new RubyArray(runtime, len); - for (int i = 0; i < len; i++) { - RubyArray tmp = new RubyArray(runtime, args.length + 1); - tmp.append(elt(i)); - for (int j = 0; j < args.length; j++) { - tmp.append(((RubyArray) args[j]).elt(i)); - } - result.append(tmp); - } - return result; - } - - /** rb_ary_cmp - * - */ - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject obj) { - RubyArray ary2 = obj.convertToArray(); - - int len = realLength; - - if (len > ary2.realLength) len = ary2.realLength; - - Ruby runtime = getRuntime(); - for (int i = 0; i < len; i++) { - IRubyObject v = elt(i).callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", ary2.elt(i)); - if (!(v instanceof RubyFixnum) || ((RubyFixnum) v).getLongValue() != 0) return v; - } - len = realLength - ary2.realLength; - - if (len == 0) return RubyFixnum.zero(runtime); - if (len > 0) return RubyFixnum.one(runtime); - - return RubyFixnum.minus_one(runtime); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject slice_bang(IRubyObject[] args) { - switch (args.length) { - case 1: - return slice_bang(args[0]); - case 2: - return slice_bang(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_ary_slice_bang - * - */ - @JRubyMethod(name = "slice!") - public IRubyObject slice_bang(IRubyObject arg0) { - if (arg0 instanceof RubyRange) { - long[] beglen = ((RubyRange) arg0).begLen(realLength, 1); - long pos = beglen[0]; - long len = beglen[1]; - - if (pos < 0) pos = realLength + pos; - - arg0 = subseq(pos, len); - splice(pos, len, null); - return arg0; - } - return delete_at((int) RubyNumeric.num2long(arg0)); - } - - /** rb_ary_slice_bang - * - */ - @JRubyMethod(name = "slice!") - public IRubyObject slice_bang(IRubyObject arg0, IRubyObject arg1) { - long pos = RubyNumeric.num2long(arg0); - long len = RubyNumeric.num2long(arg1); - - if (pos < 0) pos = realLength + pos; - - arg1 = subseq(pos, len); - splice(pos, len, null); - - return arg1; - } - - /** rb_ary_assoc - * - */ - @JRubyMethod(name = "assoc", required = 1) - public IRubyObject assoc(ThreadContext context, IRubyObject key) { - Ruby runtime = getRuntime(); - - for (int i = begin; i < begin + realLength; i++) { - IRubyObject v = values[i]; - if (v instanceof RubyArray) { - RubyArray arr = (RubyArray)v; - if (arr.realLength > 0 && equalInternal(context, arr.values[arr.begin], key)) return arr; - } - } - - return runtime.getNil(); - } - - /** rb_ary_rassoc - * - */ - @JRubyMethod(name = "rassoc", required = 1) - public IRubyObject rassoc(ThreadContext context, IRubyObject value) { - Ruby runtime = getRuntime(); - - for (int i = begin; i < begin + realLength; i++) { - IRubyObject v = values[i]; - if (v instanceof RubyArray) { - RubyArray arr = (RubyArray)v; - if (arr.realLength > 1 && equalInternal(context, arr.values[arr.begin + 1], value)) return arr; - } - } - - return runtime.getNil(); - } - - /** flatten - * - */ - private final int flatten(ThreadContext context, int index, RubyArray ary2, RubyArray memo) { - int i = index; - int n; - int lim = index + ary2.realLength; - - IRubyObject id = ary2.id(); - - if (memo.includes(context, id)) throw getRuntime().newArgumentError("tried to flatten recursive array"); - - memo.append(id); - splice(index, 1, ary2); - while (i < lim) { - IRubyObject tmp = elt(i).checkArrayType(); - if (!tmp.isNil()) { - n = flatten(context, i, (RubyArray) tmp, memo); - i += n; - lim += n; - } - i++; - } - memo.pop(); - return lim - index - 1; /* returns number of increased items */ - } - - /** rb_ary_flatten_bang - * - */ - @JRubyMethod(name = "flatten!") - public IRubyObject flatten_bang(ThreadContext context) { - int i = 0; - RubyArray memo = null; - - while (i < realLength) { - IRubyObject ary2 = values[begin + i]; - IRubyObject tmp = ary2.checkArrayType(); - if (!tmp.isNil()) { - if (memo == null) { - memo = new RubyArray(getRuntime(), false); - memo.values = reserve(ARRAY_DEFAULT_SIZE); - } - - i += flatten(context, i, (RubyArray) tmp, memo); - } - i++; - } - if (memo == null) return getRuntime().getNil(); - - return this; - } - - /** rb_ary_flatten - * - */ - @JRubyMethod(name = "flatten") - public IRubyObject flatten(ThreadContext context) { - RubyArray ary = aryDup(); - ary.flatten_bang(context); - return ary; - } - - /** rb_ary_nitems - * - */ - @JRubyMethod(name = "nitems") - public IRubyObject nitems() { - int n = 0; - - for (int i = begin; i < begin + realLength; i++) { - if (!values[i].isNil()) n++; - } - - return getRuntime().newFixnum(n); - } - - /** rb_ary_plus - * - */ - @JRubyMethod(name = "+", required = 1) - public IRubyObject op_plus(IRubyObject obj) { - RubyArray y = obj.convertToArray(); - int len = realLength + y.realLength; - RubyArray z = new RubyArray(getRuntime(), len); - try { - System.arraycopy(values, begin, z.values, 0, realLength); - System.arraycopy(y.values, y.begin, z.values, realLength, y.realLength); - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - z.realLength = len; - return z; - } - - /** rb_ary_times - * - */ - @JRubyMethod(name = "*", required = 1) - public IRubyObject op_times(ThreadContext context, IRubyObject times) { - IRubyObject tmp = times.checkStringType(); - - if (!tmp.isNil()) return join(context, tmp); - - long len = RubyNumeric.num2long(times); - if (len == 0) return new RubyArray(getRuntime(), getMetaClass(), 0); - if (len < 0) throw getRuntime().newArgumentError("negative argument"); - - if (Long.MAX_VALUE / len < realLength) { - throw getRuntime().newArgumentError("argument too big"); - } - - len *= realLength; - - RubyArray ary2 = new RubyArray(getRuntime(), getMetaClass(), len); - ary2.realLength = (int) len; - - try { - for (int i = 0; i < len; i += realLength) { - System.arraycopy(values, begin, ary2.values, i, realLength); - } - } catch (ArrayIndexOutOfBoundsException e) { - concurrentModification(); - } - - ary2.infectBy(this); - - return ary2; - } - - /** ary_make_hash - * - */ - private final RubyHash makeHash(RubyArray ary2) { - RubyHash hash = new RubyHash(getRuntime(), false); - int begin = this.begin; - for (int i = begin; i < begin + realLength; i++) { - hash.fastASet(values[i], NEVER); - } - - if (ary2 != null) { - begin = ary2.begin; - for (int i = begin; i < begin + ary2.realLength; i++) { - hash.fastASet(ary2.values[i], NEVER); - } - } - return hash; - } - - /** rb_ary_uniq_bang - * - */ - @JRubyMethod(name = "uniq!") - public IRubyObject uniq_bang() { - RubyHash hash = makeHash(null); - - if (realLength == hash.size()) return getRuntime().getNil(); - - int j = 0; - for (int i = 0; i < realLength; i++) { - IRubyObject v = elt(i); - if (hash.fastDelete(v)) store(j++, v); - } - realLength = j; - return this; - } - - /** rb_ary_uniq - * - */ - @JRubyMethod(name = "uniq") - public IRubyObject uniq() { - RubyArray ary = aryDup(); - ary.uniq_bang(); - return ary; - } - - /** rb_ary_diff - * - */ - @JRubyMethod(name = "-", required = 1) - public IRubyObject op_diff(IRubyObject other) { - RubyHash hash = other.convertToArray().makeHash(null); - RubyArray ary3 = new RubyArray(getRuntime()); - - int begin = this.begin; - for (int i = begin; i < begin + realLength; i++) { - if (hash.fastARef(values[i]) != null) continue; - ary3.append(elt(i - begin)); - } - - return ary3; - } - - /** rb_ary_and - * - */ - @JRubyMethod(name = "&", required = 1) - public IRubyObject op_and(IRubyObject other) { - RubyArray ary2 = other.convertToArray(); - RubyHash hash = ary2.makeHash(null); - RubyArray ary3 = new RubyArray(getRuntime(), - realLength < ary2.realLength ? realLength : ary2.realLength); - - for (int i = 0; i < realLength; i++) { - IRubyObject v = elt(i); - if (hash.fastDelete(v)) ary3.append(v); - } - - return ary3; - } - - /** rb_ary_or - * - */ - @JRubyMethod(name = "|", required = 1) - public IRubyObject op_or(IRubyObject other) { - RubyArray ary2 = other.convertToArray(); - RubyHash set = makeHash(ary2); - - RubyArray ary3 = new RubyArray(getRuntime(), realLength + ary2.realLength); - - for (int i = 0; i < realLength; i++) { - IRubyObject v = elt(i); - if (set.fastDelete(v)) ary3.append(v); - } - for (int i = 0; i < ary2.realLength; i++) { - IRubyObject v = ary2.elt(i); - if (set.fastDelete(v)) ary3.append(v); - } - return ary3; - } - - /** rb_ary_sort - * - */ - @JRubyMethod(name = "sort", frame = true) - public RubyArray sort(Block block) { - RubyArray ary = aryDup(); - ary.sort_bang(block); - return ary; - } - - /** rb_ary_sort_bang - * - */ - @JRubyMethod(name = "sort!", frame = true) - public RubyArray sort_bang(Block block) { - modify(); - if (realLength > 1) { - flags |= TMPLOCK_ARR_F; - try { - if (block.isGiven()) { - Arrays.sort(values, 0, realLength, new BlockComparator(block)); - } else { - Arrays.sort(values, 0, realLength, new DefaultComparator()); - } - } finally { - flags &= ~TMPLOCK_ARR_F; - } - } - return this; - } - - final class BlockComparator implements Comparator { - private Block block; - - public BlockComparator(Block block) { - this.block = block; - } - - public int compare(Object o1, Object o2) { - ThreadContext context = getRuntime().getCurrentContext(); - IRubyObject obj1 = (IRubyObject) o1; - IRubyObject obj2 = (IRubyObject) o2; - IRubyObject ret = block.yield(context, getRuntime().newArray(obj1, obj2), null, null, true); - int n = RubyComparable.cmpint(context, ret, obj1, obj2); - //TODO: ary_sort_check should be done here - return n; - } - } - - static final class DefaultComparator implements Comparator { - public int compare(Object o1, Object o2) { - if (o1 instanceof RubyFixnum && o2 instanceof RubyFixnum) { - return compareFixnums(o1, o2); - } - if (o1 instanceof RubyString && o2 instanceof RubyString) { - return ((RubyString) o1).op_cmp((RubyString) o2); - } - //TODO: ary_sort_check should be done here - return compareOthers((IRubyObject)o1, (IRubyObject)o2); - } - - private int compareFixnums(Object o1, Object o2) { - long a = ((RubyFixnum) o1).getLongValue(); - long b = ((RubyFixnum) o2).getLongValue(); - if (a > b) { - return 1; - } - if (a < b) { - return -1; - } - return 0; - } - - private int compareOthers(IRubyObject o1, IRubyObject o2) { - ThreadContext context = o1.getRuntime().getCurrentContext(); - IRubyObject ret = o1.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", o2); - int n = RubyComparable.cmpint(context, ret, o1, o2); - //TODO: ary_sort_check should be done here - return n; - } - } - - public static void marshalTo(RubyArray array, MarshalStream output) throws IOException { - output.registerLinkTarget(array); - output.writeInt(array.getList().size()); - for (Iterator iter = array.getList().iterator(); iter.hasNext();) { - output.dumpObject((IRubyObject) iter.next()); - } - } - - public static RubyArray unmarshalFrom(UnmarshalStream input) throws IOException { - RubyArray result = input.getRuntime().newArray(); - input.registerLinkTarget(result); - int size = input.unmarshalInt(); - for (int i = 0; i < size; i++) { - result.append(input.unmarshalObject()); - } - return result; - } - - /** - * @see org.jruby.util.Pack#pack - */ - @JRubyMethod(name = "pack", required = 1) - public RubyString pack(ThreadContext context, IRubyObject obj) { - RubyString iFmt = RubyString.objAsString(context, obj); - return Pack.pack(getRuntime(), this, iFmt.getByteList()); - } - - @Override - public Class getJavaClass() { - return List.class; - } - - // Satisfy java.util.List interface (for Java integration) - public int size() { - return realLength; - } - - public boolean isEmpty() { - return realLength == 0; - } - - public boolean contains(Object element) { - return indexOf(element) != -1; - } - - public Object[] toArray() { - Object[] array = new Object[realLength]; - for (int i = begin; i < realLength; i++) { - array[i - begin] = JavaUtil.convertRubyToJava(values[i]); - } - return array; - } - - public Object[] toArray(final Object[] arg) { - Object[] array = arg; - if (array.length < realLength) { - Class type = array.getClass().getComponentType(); - array = (Object[]) Array.newInstance(type, realLength); - } - int length = realLength - begin; - - for (int i = 0; i < length; i++) { - array[i] = JavaUtil.convertRubyToJava(values[i + begin]); - } - return array; - } - - public boolean add(Object element) { - append(JavaUtil.convertJavaToRuby(getRuntime(), element)); - return true; - } - - public boolean remove(Object element) { - IRubyObject deleted = delete(getRuntime().getCurrentContext(), JavaUtil.convertJavaToRuby(getRuntime(), element), Block.NULL_BLOCK); - return deleted.isNil() ? false : true; // TODO: is this correct ? - } - - public boolean containsAll(Collection c) { - for (Iterator iter = c.iterator(); iter.hasNext();) { - if (indexOf(iter.next()) == -1) { - return false; - } - } - - return true; - } - - public boolean addAll(Collection c) { - for (Iterator iter = c.iterator(); iter.hasNext();) { - add(iter.next()); - } - return !c.isEmpty(); - } - - public boolean addAll(int index, Collection c) { - Iterator iter = c.iterator(); - for (int i = index; iter.hasNext(); i++) { - add(i, iter.next()); - } - return !c.isEmpty(); - } - - public boolean removeAll(Collection c) { - boolean listChanged = false; - for (Iterator iter = c.iterator(); iter.hasNext();) { - if (remove(iter.next())) { - listChanged = true; - } - } - return listChanged; - } - - public boolean retainAll(Collection c) { - boolean listChanged = false; - - for (Iterator iter = iterator(); iter.hasNext();) { - Object element = iter.next(); - if (!c.contains(element)) { - remove(element); - listChanged = true; - } - } - return listChanged; - } - - public Object get(int index) { - return JavaUtil.convertRubyToJava((IRubyObject) elt(index), Object.class); - } - - public Object set(int index, Object element) { - return store(index, JavaUtil.convertJavaToRuby(getRuntime(), element)); - } - - // TODO: make more efficient by not creating IRubyArray[] - public void add(int index, Object element) { - insert(new IRubyObject[]{RubyFixnum.newFixnum(getRuntime(), index), JavaUtil.convertJavaToRuby(getRuntime(), element)}); - } - - public Object remove(int index) { - return JavaUtil.convertRubyToJava(delete_at(index), Object.class); - } - - public int indexOf(Object element) { - int begin = this.begin; - - if (element != null) { - IRubyObject convertedElement = JavaUtil.convertJavaToRuby(getRuntime(), element); - - for (int i = begin; i < begin + realLength; i++) { - if (convertedElement.equals(values[i])) { - return i; - } - } - } - return -1; - } - - public int lastIndexOf(Object element) { - int begin = this.begin; - - if (element != null) { - IRubyObject convertedElement = JavaUtil.convertJavaToRuby(getRuntime(), element); - - for (int i = begin + realLength - 1; i >= begin; i--) { - if (convertedElement.equals(values[i])) { - return i; - } - } - } - - return -1; - } - - public class RubyArrayConversionIterator implements Iterator { - protected int index = 0; - protected int last = -1; - - public boolean hasNext() { - return index < realLength; - } - - public Object next() { - IRubyObject element = elt(index); - last = index++; - return JavaUtil.convertRubyToJava(element, Object.class); - } - - public void remove() { - if (last == -1) throw new IllegalStateException(); - - delete_at(last); - if (last < index) index--; - - last = -1; - - } - } - - public Iterator iterator() { - return new RubyArrayConversionIterator(); - } - - final class RubyArrayConversionListIterator extends RubyArrayConversionIterator implements ListIterator { - public RubyArrayConversionListIterator() { - } - - public RubyArrayConversionListIterator(int index) { - this.index = index; - } - - public boolean hasPrevious() { - return index >= 0; - } - - public Object previous() { - return JavaUtil.convertRubyToJava((IRubyObject) elt(last = --index), Object.class); - } - - public int nextIndex() { - return index; - } - - public int previousIndex() { - return index - 1; - } - - public void set(Object obj) { - if (last == -1) throw new IllegalStateException(); - - store(last, JavaUtil.convertJavaToRuby(getRuntime(), obj)); - } - - public void add(Object obj) { - insert(new IRubyObject[] { RubyFixnum.newFixnum(getRuntime(), index++), JavaUtil.convertJavaToRuby(getRuntime(), obj) }); - last = -1; - } - } - - public ListIterator listIterator() { - return new RubyArrayConversionListIterator(); - } - - public ListIterator listIterator(int index) { - return new RubyArrayConversionListIterator(index); - } - - // TODO: list.subList(from, to).clear() is supposed to clear the sublist from the list. - // How can we support this operation? - public List subList(int fromIndex, int toIndex) { - if (fromIndex < 0 || toIndex > size() || fromIndex > toIndex) { - throw new IndexOutOfBoundsException(); - } - - IRubyObject subList = subseq(fromIndex, toIndex - fromIndex + 1); - - return subList.isNil() ? null : (List) subList; - } - - public void clear() { - rb_clear(); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.math.MathContext; -import java.math.RoundingMode; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyConstant; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallbackFactory; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -@JRubyClass(name="BigDecimal", parent="Numeric") -public class RubyBigDecimal extends RubyNumeric { - private static final ObjectAllocator BIGDECIMAL_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyBigDecimal(runtime, klass); - } - }; - - @JRubyConstant - public final static int ROUND_DOWN = BigDecimal.ROUND_DOWN; - @JRubyConstant - public final static int ROUND_CEILING = BigDecimal.ROUND_CEILING; - @JRubyConstant - public final static int ROUND_UP = BigDecimal.ROUND_UP; - @JRubyConstant - public final static int ROUND_HALF_DOWN = BigDecimal.ROUND_HALF_DOWN; - @JRubyConstant - public final static int ROUND_HALF_EVEN = BigDecimal.ROUND_HALF_EVEN; - @JRubyConstant - public final static int ROUND_HALF_UP = BigDecimal.ROUND_HALF_UP; - @JRubyConstant - public final static int ROUND_FLOOR = BigDecimal.ROUND_FLOOR; - - @JRubyConstant - public final static int SIGN_POSITIVE_INFINITE=3; - @JRubyConstant - public final static int EXCEPTION_OVERFLOW=1; - @JRubyConstant - public final static int SIGN_POSITIVE_ZERO=1; - @JRubyConstant - public final static int EXCEPTION_ALL=255; - @JRubyConstant - public final static int SIGN_NEGATIVE_FINITE=-2; - @JRubyConstant - public final static int EXCEPTION_UNDERFLOW=4; - @JRubyConstant - public final static int SIGN_NaN=0; - @JRubyConstant - public final static int BASE=10000; - @JRubyConstant - public final static int ROUND_MODE=256; - @JRubyConstant - public final static int SIGN_POSITIVE_FINITE=2; - @JRubyConstant - public final static int EXCEPTION_INFINITY=1; - @JRubyConstant - public final static int SIGN_NEGATIVE_INFINITE=-3; - @JRubyConstant - public final static int EXCEPTION_ZERODIVIDE=1; - @JRubyConstant - public final static int SIGN_NEGATIVE_ZERO=-1; - @JRubyConstant - public final static int EXCEPTION_NaN=2; - - // Static constants - private static final BigDecimal TWO = new BigDecimal(2); - private static final double SQRT_10 = 3.162277660168379332; - - public static RubyClass createBigDecimal(Ruby runtime) { - RubyClass result = runtime.defineClass("BigDecimal",runtime.getNumeric(), BIGDECIMAL_ALLOCATOR); - - CallbackFactory callbackFactory = runtime.callbackFactory(RubyBigDecimal.class); - - runtime.getKernel().defineAnnotatedMethods(BigDecimalKernelMethods.class); - - result.setInternalModuleVariable("vpPrecLimit", RubyFixnum.zero(runtime)); - result.setInternalModuleVariable("vpExceptionMode", RubyFixnum.zero(runtime)); - result.setInternalModuleVariable("vpRoundingMode", runtime.newFixnum(ROUND_HALF_UP)); - - result.defineAnnotatedMethods(RubyBigDecimal.class); - result.defineAnnotatedConstants(RubyBigDecimal.class); - - return result; - } - - private boolean isNaN = false; - private int infinitySign = 0; - private int zeroSign = 0; - private BigDecimal value; - - public BigDecimal getValue() { - return value; - } - - public RubyBigDecimal(Ruby runtime, RubyClass klass) { - super(runtime, klass); - } - - public RubyBigDecimal(Ruby runtime, BigDecimal value) { - super(runtime, runtime.fastGetClass("BigDecimal")); - this.value = value; - } - - public static class BigDecimalKernelMethods { - @JRubyMethod(name = "BigDecimal", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject newBigDecimal(IRubyObject recv, IRubyObject[] args) { - return RubyBigDecimal.newBigDecimal(recv, args, Block.NULL_BLOCK); - } - } - - public static RubyBigDecimal newBigDecimal(IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - return newInstance(recv.getRuntime().fastGetClass("BigDecimal"), args); - } - - @JRubyMethod(name = "ver", meta = true) - public static IRubyObject ver(IRubyObject recv) { - return recv.getRuntime().newString("1.0.1"); - } - - @JRubyMethod(name = "_dump", optional = 1, frame = true) - public IRubyObject dump(IRubyObject[] args, Block unusedBlock) { - RubyString precision = RubyString.newUnicodeString(args[0].getRuntime(), "0:"); - RubyString str = this.asString(); - return precision.append(str); - } - - @JRubyMethod(name = "_load", required = 1, frame = true, meta = true) - public static RubyBigDecimal load(IRubyObject recv, IRubyObject from, Block block) { - RubyBigDecimal rubyBigDecimal = (RubyBigDecimal) (((RubyClass)recv).allocate()); - String precisionAndValue = from.convertToString().asJavaString(); - String value = precisionAndValue.substring(precisionAndValue.indexOf(":")+1); - rubyBigDecimal.value = new BigDecimal(value); - return rubyBigDecimal; - } - - @JRubyMethod(name = "double_fig", meta = true) - public static IRubyObject double_fig(IRubyObject recv) { - return recv.getRuntime().newFixnum(20); - } - - @JRubyMethod(name = "limit", optional = 1, meta = true) - public static IRubyObject limit(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - RubyModule c = (RubyModule)recv; - IRubyObject nCur = c.searchInternalModuleVariable("vpPrecLimit"); - - if (args.length > 0) { - IRubyObject arg = args[0]; - if (!arg.isNil()) { - if (!(arg instanceof RubyFixnum)) { - throw runtime.newTypeError(arg, runtime.getFixnum()); - } - if (0 > ((RubyFixnum)arg).getLongValue()) { - throw runtime.newArgumentError("argument must be positive"); - } - c.setInternalModuleVariable("vpPrecLimit", arg); - } - } - - return nCur; - } - - @JRubyMethod(name = "mode", required = 1, optional = 1, meta = true) - public static IRubyObject mode(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - // FIXME: I doubt any of the constants referenced in this method - // are ever redefined -- should compare to the known values, rather - // than do an expensive constant lookup. - Ruby runtime = recv.getRuntime(); - RubyClass clazz = runtime.fastGetClass("BigDecimal"); - RubyModule c = (RubyModule)recv; - - args = Arity.scanArgs(runtime, args, 1, 1); - - IRubyObject mode = args[0]; - IRubyObject value = args[1]; - - if (!(mode instanceof RubyFixnum)) { - throw runtime.newTypeError("wrong argument type " + mode.getMetaClass() + " (expected Fixnum)"); - } - - long longMode = ((RubyFixnum)mode).getLongValue(); - long EXCEPTION_ALL = ((RubyFixnum)clazz.fastGetConstant("EXCEPTION_ALL")).getLongValue(); - if ((longMode & EXCEPTION_ALL) != 0) { - if (value.isNil()) { - return c.searchInternalModuleVariable("vpExceptionMode"); - } - if (!(value.isNil()) && !(value instanceof RubyBoolean)) { - throw runtime.newTypeError("second argument must be true or false"); - } - - RubyFixnum currentExceptionMode = (RubyFixnum)c.searchInternalModuleVariable("vpExceptionMode"); - RubyFixnum newExceptionMode = new RubyFixnum(runtime, currentExceptionMode.getLongValue()); - - RubyFixnum EXCEPTION_INFINITY = (RubyFixnum)clazz.fastGetConstant("EXCEPTION_INFINITY"); - if ((longMode & EXCEPTION_INFINITY.getLongValue()) != 0) { - newExceptionMode = (value.isTrue()) ? (RubyFixnum)currentExceptionMode.callCoerced(context, "|", EXCEPTION_INFINITY) - : (RubyFixnum)currentExceptionMode.callCoerced(context, "&", new RubyFixnum(runtime, ~(EXCEPTION_INFINITY).getLongValue())); - } - - RubyFixnum EXCEPTION_NaN = (RubyFixnum)clazz.fastGetConstant("EXCEPTION_NaN"); - if ((longMode & EXCEPTION_NaN.getLongValue()) != 0) { - newExceptionMode = (value.isTrue()) ? (RubyFixnum)currentExceptionMode.callCoerced(context, "|", EXCEPTION_NaN) - : (RubyFixnum)currentExceptionMode.callCoerced(context, "&", new RubyFixnum(runtime, ~(EXCEPTION_NaN).getLongValue())); - } - c.setInternalModuleVariable("vpExceptionMode", newExceptionMode); - return newExceptionMode; - } - - long ROUND_MODE = ((RubyFixnum)clazz.fastGetConstant("ROUND_MODE")).getLongValue(); - if (longMode == ROUND_MODE) { - if (value.isNil()) { - return c.searchInternalModuleVariable("vpRoundingMode"); - } - if (!(value instanceof RubyFixnum)) { - throw runtime.newTypeError("wrong argument type " + mode.getMetaClass() + " (expected Fixnum)"); - } - - RubyFixnum roundingMode = (RubyFixnum)value; - if (roundingMode == clazz.fastGetConstant("ROUND_UP") || - roundingMode == clazz.fastGetConstant("ROUND_DOWN") || - roundingMode == clazz.fastGetConstant("ROUND_FLOOR") || - roundingMode == clazz.fastGetConstant("ROUND_CEILING") || - roundingMode == clazz.fastGetConstant("ROUND_HALF_UP") || - roundingMode == clazz.fastGetConstant("ROUND_HALF_DOWN") || - roundingMode == clazz.fastGetConstant("ROUND_HALF_EVEN")) { - c.setInternalModuleVariable("vpRoundingMode", roundingMode); - } else { - throw runtime.newTypeError("invalid rounding mode"); - } - return c.searchInternalModuleVariable("vpRoundingMode"); - } - throw runtime.newTypeError("first argument for BigDecimal#mode invalid"); - } - - private RoundingMode getRoundingMode(Ruby runtime) { - RubyFixnum roundingMode = (RubyFixnum)runtime.fastGetClass("BigDecimal") - .searchInternalModuleVariable("vpRoundingMode"); - return RoundingMode.valueOf((int)roundingMode.getLongValue()); - } - - private RubyBigDecimal getVpValue(IRubyObject v, boolean must) { - if(v instanceof RubyBigDecimal) { - return (RubyBigDecimal)v; - } else if(v instanceof RubyFixnum || v instanceof RubyBignum) { - String s = v.toString(); - return newInstance(getRuntime().fastGetClass("BigDecimal"),new IRubyObject[]{getRuntime().newString(s)}); - } - if(must) { - String err; - if (isImmediate()) { - ThreadContext context = getRuntime().getCurrentContext(); - err = inspect(context, this).toString(); - } else { - err = getMetaClass().getBaseName(); - } - throw getRuntime().newTypeError(err + " can't be coerced into BigDecimal"); - } - return null; - } - - private final static Pattern INFINITY_PATTERN = Pattern.compile("^([+-])?Infinity$"); - private final static Pattern NUMBER_PATTERN - = Pattern.compile("^([+-]?\\d*\\.?\\d*([eE][+-]?)?\\d*).*"); - - @JRubyMethod(name = "new", required = 1, optional = 1, meta = true) - public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args) { - BigDecimal decimal; - if (args.length == 0) { - decimal = new BigDecimal(0); - } else { - String strValue = args[0].convertToString().toString(); - strValue = strValue.trim(); - if ("NaN".equals(strValue)) { - return newNaN(recv.getRuntime()); - } - - Matcher m = INFINITY_PATTERN.matcher(strValue); - if (m.matches()) { - int sign = 1; - String signGroup = m.group(1); - if ("-".equals(signGroup)) { - sign = -1; - } - return newInfinity(recv.getRuntime(), sign); - } - - // Clean-up string representation so that it could be understood - // by Java's BigDecimal. Not terribly efficient for now. - // 1. MRI allows d and D as exponent separators - strValue = strValue.replaceFirst("[dD]", "E"); - // 2. MRI allows underscores anywhere - strValue = strValue.replaceAll("_", ""); - // 3. MRI ignores the trailing junk - strValue = NUMBER_PATTERN.matcher(strValue).replaceFirst("$1"); - - try { - decimal = new BigDecimal(strValue); - } catch(NumberFormatException e) { - decimal = new BigDecimal(0); - } - if (decimal.signum() == 0) { - // MRI behavior: -0 and +0 are two different things - if (strValue.matches("^\\s*-.*")) { - return newZero(recv.getRuntime(), -1); - } else { - return newZero(recv.getRuntime(), 1); - } - } - } - return new RubyBigDecimal(recv.getRuntime(), decimal); - } - - private static RubyBigDecimal newZero(Ruby runtime, int sign) { - RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO); - if (sign < 0) { - rbd.zeroSign = -1; - } else { - rbd.zeroSign = 1; - } - return rbd; - } - - private static RubyBigDecimal newNaN(Ruby runtime) { - RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO); - rbd.isNaN = true; - return rbd; - } - - private static RubyBigDecimal newInfinity(Ruby runtime, int sign) { - RubyBigDecimal rbd = new RubyBigDecimal(runtime, BigDecimal.ZERO); - if (sign < 0) { - rbd.infinitySign = -1; - } else { - rbd.infinitySign = 1; - } - return rbd; - } - - private RubyBigDecimal setResult() { - return setResult(0); - } - - private RubyBigDecimal setResult(int scale) { - int prec = RubyFixnum.fix2int(getRuntime().fastGetClass("BigDecimal").searchInternalModuleVariable("vpPrecLimit")); - int prec2 = Math.max(scale,prec); - if(prec2 > 0 && this.value.scale() > (prec2-getExponent())) { - this.value = this.value.setScale(prec2-getExponent(),BigDecimal.ROUND_HALF_UP); - } - return this; - } - - @JRubyMethod(name = "hash") - public RubyFixnum hash() { - return getRuntime().newFixnum(value.hashCode()); - } - - @JRubyMethod(name = {"%", "modulo"}, required = 1) - public IRubyObject op_mod(ThreadContext context, IRubyObject arg) { - // TODO: full-precision remainder is 1000x slower than MRI! - Ruby runtime = context.getRuntime(); - if (isInfinity() || isNaN()) { - return newNaN(runtime); - } - RubyBigDecimal val = getVpValue(arg, false); - if (val == null) { - return callCoerced(context, "%", arg, true); - } - if (val.isInfinity() || val.isNaN() || val.isZero()) { - return newNaN(runtime); - } - - // Java and MRI definitions of modulo are different. - BigDecimal modulo = value.remainder(val.value); - if (modulo.signum() * val.value.signum() < 0) { - modulo = modulo.add(val.value); - } - - return new RubyBigDecimal(runtime, modulo).setResult(); - } - - @JRubyMethod(name = "remainder", required = 1) - public IRubyObject remainder(ThreadContext context, IRubyObject arg) { - // TODO: full-precision remainder is 1000x slower than MRI! - Ruby runtime = context.getRuntime(); - if (isInfinity() || isNaN()) { - return newNaN(runtime); - } - RubyBigDecimal val = getVpValue(arg,false); - if (val == null) { - return callCoerced(context, "remainder", arg, true); - } - if (val.isInfinity() || val.isNaN() || val.isZero()) { - return newNaN(runtime); - } - - // Java and MRI definitions of remainder are the same. - return new RubyBigDecimal(runtime, value.remainder(val.value)).setResult(); - } - - @JRubyMethod(name = "*", required = 1) - public IRubyObject op_mul(ThreadContext context, IRubyObject arg) { - return mult2(context, arg, RubyFixnum.zero(context.getRuntime())); - } - - @JRubyMethod(name = "mult", required = 2) - public IRubyObject mult2(ThreadContext context, IRubyObject b, IRubyObject n) { - Ruby runtime = context.getRuntime(); - - RubyBigDecimal val = getVpValue(b,false); - if(val == null) { - // TODO: what about n arg? - return callCoerced(context, "*", b); - } - - int digits = RubyNumeric.fix2int(n); - - if (isNaN() || val.isNaN()) { - return newNaN(runtime); - } - - if ((isInfinity() && val.isZero()) || (isZero() && val.isInfinity())) { - return newNaN(runtime); - } - - if (isZero() || val.isZero()) { - int sign1 = isZero()? zeroSign : value.signum(); - int sign2 = val.isZero() ? val.zeroSign : val.value.signum(); - return newZero(runtime, sign1 * sign2); - } - - if (isInfinity() || val.isInfinity()) { - int sign1 = isInfinity() ? infinitySign : value.signum(); - int sign2 = val.isInfinity() ? val.infinitySign : val.value.signum(); - return newInfinity(runtime, sign1 * sign2); - } - - BigDecimal res = value.multiply(val.value); - if (res.precision() > digits) { - // TODO: rounding mode should not be hard-coded. See #mode. - res = res.round(new MathContext(digits, RoundingMode.HALF_UP)); - } - return new RubyBigDecimal(runtime, res).setResult(); - } - - @JRubyMethod(name = {"**", "power"}, required = 1) - public IRubyObject op_pow(IRubyObject arg) { - if (!(arg instanceof RubyFixnum)) { - throw getRuntime().newTypeError("wrong argument type " + arg.getMetaClass() + " (expected Fixnum)"); - } - - if (isNaN() || isInfinity()) { - return newNaN(getRuntime()); - } - - int times = RubyNumeric.fix2int(arg.convertToInteger()); - - if (times < 0) { - if (isZero()) { - return newInfinity(getRuntime(), value.signum()); - } - - // Note: MRI has a very non-trivial way of calculating the precision, - // so we use very simple approximation here: - int precision = (-times + 4) * (getAllDigits().length() + 4); - - return new RubyBigDecimal(getRuntime(), - value.pow(times, new MathContext(precision, RoundingMode.HALF_UP))); - } else { - return new RubyBigDecimal(getRuntime(), value.pow(times)); - } - } - - @JRubyMethod(name = "+", required = 1, frame=true) - public IRubyObject op_plus(ThreadContext context, IRubyObject b) { - return addInternal(context, b, "add", RubyFixnum.zero(context.getRuntime())); - } - - @JRubyMethod(name = "add", required = 2, frame=true) - public IRubyObject add2(ThreadContext context, IRubyObject b, IRubyObject digits) { - return addInternal(context, b, "add", digits); - } - - private IRubyObject addInternal(ThreadContext context, IRubyObject b, String op, IRubyObject digits) { - Ruby runtime = context.getRuntime(); - int prec = getPositiveInt(context, digits); - - RubyBigDecimal val = getVpValue(b, false); - if (val == null) { - // TODO: - // MRI behavior: Call "+" or "add", depending on the call. - // But this leads to exceptions when Floats are added. See: - // http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17374 - // return callCoerced(context, op, b, true); -- this is MRI behavior. - // We'll use ours for now, thus providing an ability to add Floats. - return callCoerced(context, "+", b, true); - } - - IRubyObject res = handleAddSpecialValues(val); - if (res != null) { - return res; - } - RoundingMode roundMode = getRoundingMode(runtime); - return new RubyBigDecimal(runtime, value.add( - val.value, new MathContext(prec, roundMode))); // TODO: why this: .setResult(); - } - - private int getPositiveInt(ThreadContext context, IRubyObject arg) { - Ruby runtime = context.getRuntime(); - - if (arg instanceof RubyFixnum) { - int value = RubyNumeric.fix2int(arg); - if (value < 0) { - throw runtime.newArgumentError("argument must be positive"); - } - return value; - } else { - throw runtime.newTypeError(arg, runtime.getFixnum()); - } - } - - private IRubyObject handleAddSpecialValues(RubyBigDecimal val) { - if (isNaN() || val.isNaN) { - return newNaN(getRuntime()); - } - // TODO: don't calculate the same value 3 times - if (infinitySign * val.infinitySign > 0) { - return isInfinity() ? this : val; - } - if (infinitySign * val.infinitySign < 0) { - return newNaN(getRuntime()); - } - if (infinitySign * val.infinitySign == 0) { - int sign = infinitySign + val.infinitySign; - if (sign != 0) { - return newInfinity(getRuntime(), sign); - } - } - return null; - } - - @JRubyMethod(name = "+@") - public IRubyObject op_uplus() { - return this; - } - - @JRubyMethod(name = "-", required = 1) - public IRubyObject op_minus(ThreadContext context, IRubyObject arg) { - RubyBigDecimal val = getVpValue(arg, false); - if(val == null) { - return callCoerced(context, "-", arg); - } - RubyBigDecimal res = handleMinusSpecialValues(val); - if (res != null) { - return res; - } - return new RubyBigDecimal(getRuntime(),value.subtract(val.value)).setResult(); - } - - @JRubyMethod(name = "sub", required = 2) - public IRubyObject sub2(ThreadContext context, IRubyObject b, IRubyObject n) { - RubyBigDecimal val = getVpValue(b, false); - if(val == null) { - return callCoerced(context, "-", b); - } - RubyBigDecimal res = handleMinusSpecialValues(val); - if (res != null) { - return res; - } - - return new RubyBigDecimal(getRuntime(),value.subtract(val.value)).setResult(); - } - - private RubyBigDecimal handleMinusSpecialValues(RubyBigDecimal val) { - if (isNaN() || val.isNaN()) { - return newNaN(getRuntime()); - } - - // TODO: 3 times calculate the same value below - if (infinitySign * val.infinitySign > 0) { - return newNaN(getRuntime()); - } - if (infinitySign * val.infinitySign < 0) { - return this; - } - if (infinitySign * val.infinitySign == 0) { - if (isInfinity()) { - return this; - } - if (val.isInfinity()) { - return newInfinity(getRuntime(), val.infinitySign * -1); - } - int sign = infinitySign + val.infinitySign; - if (sign != 0) { - return newInfinity(getRuntime(), sign); - } - } - return null; - } - - @JRubyMethod(name = "-@") - public IRubyObject op_uminus() { - Ruby runtime = getRuntime(); - if (isNaN()) { - return newNaN(runtime); - } - if (isInfinity()) { - return newInfinity(runtime, -infinitySign); - } - if (isZero()) { - return newZero(runtime, -zeroSign); - } - return new RubyBigDecimal(getRuntime(), value.negate()); - } - - @JRubyMethod(name = {"/", "quo"}) - public IRubyObject op_quo(ThreadContext context, IRubyObject other) { - // regular division with some default precision - // TODO: proper algorithm to set the precision - return op_div(context, other, getRuntime().newFixnum(200)); - } - - @JRubyMethod(name = "div") - public IRubyObject op_div(ThreadContext context, IRubyObject other) { - // integer division - RubyBigDecimal val = getVpValue(other, false); - if (val == null) { - return callCoerced(context, "div", other); - } - - if (isNaN() || val.isZero() || val.isNaN()) { - return newNaN(getRuntime()); - } - - if (isInfinity() || val.isInfinity()) { - return newNaN(getRuntime()); - } - - return new RubyBigDecimal(getRuntime(), - this.value.divideToIntegralValue(val.value)).setResult(); - } - - @JRubyMethod(name = "div") - public IRubyObject op_div(ThreadContext context, IRubyObject other, IRubyObject digits) { - // TODO: take BigDecimal.mode into account. - - int scale = RubyNumeric.fix2int(digits); - - RubyBigDecimal val = getVpValue(other, false); - if (val == null) { - return callCoerced(context, "/", other); - } - - if (isNaN() || (isZero() && val.isZero()) || val.isNaN()) { - return newNaN(getRuntime()); - } - - if (val.isZero()) { - int sign1 = isInfinity() ? infinitySign : value.signum(); - return newInfinity(getRuntime(), sign1 * val.zeroSign); - } - - if (isInfinity() && !val.isInfinity()) { - return newInfinity(getRuntime(), infinitySign * val.value.signum()); - } - - if (!isInfinity() && val.isInfinity()) { - return newZero(getRuntime(), value.signum() * val.infinitySign); - } - - if (isInfinity() && val.isInfinity()) { - return newNaN(getRuntime()); - } - - if (scale == 0) { - // MRI behavior: "If digits is 0, the result is the same as the / operator." - return op_quo(context, other); - } else { - // TODO: better algorithm to set precision needed - int prec = Math.max(200, scale); - return new RubyBigDecimal(getRuntime(), - value.divide(val.value, new MathContext(prec, RoundingMode.HALF_UP))).setResult(scale); - } - } - - private IRubyObject cmp(ThreadContext context, IRubyObject r, char op) { - int e = 0; - RubyBigDecimal rb = getVpValue(r,false); - if(rb == null) { - IRubyObject ee = callCoerced(context, "<=>",r); - if(ee.isNil()) { - return getRuntime().getNil(); - } - e = RubyNumeric.fix2int(ee); - } else { - if (isNaN() | rb.isNaN()) { - return getRuntime().getNil(); - } - if (infinitySign != 0 || rb.infinitySign != 0) { - e = infinitySign - rb.infinitySign; - } else { - e = value.compareTo(rb.value); - } - } - switch(op) { - case '*': return getRuntime().newFixnum(e); - case '=': return (e==0)?getRuntime().getTrue():getRuntime().getFalse(); - case '!': return (e!=0)?getRuntime().getTrue():getRuntime().getFalse(); - case 'G': return (e>=0)?getRuntime().getTrue():getRuntime().getFalse(); - case '>': return (e> 0)?getRuntime().getTrue():getRuntime().getFalse(); - case 'L': return (e<=0)?getRuntime().getTrue():getRuntime().getFalse(); - case '<': return (e< 0)?getRuntime().getTrue():getRuntime().getFalse(); - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'*'); - } - - @JRubyMethod(name = {"eql?", "==", "==="}, required = 1) - public IRubyObject eql_p(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'='); - } - - @JRubyMethod(name = "<", required = 1) - public IRubyObject op_lt(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'<'); - } - - @JRubyMethod(name = "<=", required = 1) - public IRubyObject op_le(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'L'); - } - - @JRubyMethod(name = ">", required = 1) - public IRubyObject op_gt(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'>'); - } - - @JRubyMethod(name = ">=", required = 1) - public IRubyObject op_ge(ThreadContext context, IRubyObject arg) { - return cmp(context, arg,'G'); - } - - @JRubyMethod(name = "abs") - public IRubyObject abs() { - Ruby runtime = getRuntime(); - if (isNaN) { - return newNaN(runtime); - } - if (isInfinity()) { - return newInfinity(runtime, 1); - } - return new RubyBigDecimal(getRuntime(), value.abs()).setResult(); - } - - @JRubyMethod(name = "ceil", optional = 1) - public IRubyObject ceil(IRubyObject[] args) { - if (isNaN) { - return newNaN(getRuntime()); - } - if (isInfinity()) { - return newInfinity(getRuntime(), infinitySign); - } - - int n = 0; - if (args.length > 0) { - n = RubyNumeric.fix2int(args[0]); - } - - if (value.scale() > n) { // rounding neccessary - return new RubyBigDecimal(getRuntime(), - value.setScale(n, RoundingMode.CEILING)); - } else { - return this; - } - } - - @JRubyMethod(name = "coerce", required = 1) - public IRubyObject coerce(IRubyObject other) { - IRubyObject obj; - if(other instanceof RubyFloat) { - obj = getRuntime().newArray(other,to_f()); - } else { - obj = getRuntime().newArray(getVpValue(other, true),this); - } - return obj; - } - - public double getDoubleValue() { return value.doubleValue(); } - public long getLongValue() { return value.longValue(); } - - public RubyNumeric multiplyWith(ThreadContext context, RubyInteger value) { - return (RubyNumeric)op_mul(context, value); - } - - public RubyNumeric multiplyWith(ThreadContext context, RubyFloat value) { - return (RubyNumeric)op_mul(context, value); - } - - public RubyNumeric multiplyWith(ThreadContext context, RubyBignum value) { - return (RubyNumeric)op_mul(context, value); - } - - @JRubyMethod(name = "divmod", required = 1) - public IRubyObject divmod(ThreadContext context, IRubyObject other) { - // TODO: full-precision divmod is 1000x slower than MRI! - Ruby runtime = context.getRuntime(); - if (isInfinity() || isNaN()) { - return RubyArray.newArray(runtime, newNaN(runtime), newNaN(runtime)); - } - RubyBigDecimal val = getVpValue(other, false); - if (val == null) { - return callCoerced(context, "divmod", other, true); - } - if (val.isInfinity() || val.isNaN() || val.isZero()) { - return RubyArray.newArray(runtime, newNaN(runtime), newNaN(runtime)); - } - - // Java and MRI definitions of divmod are different. - BigDecimal[] divmod = value.divideAndRemainder(val.value); - - BigDecimal div = divmod[0]; - BigDecimal mod = divmod[1]; - - if (mod.signum() * val.value.signum() < 0) { - div = div.subtract(BigDecimal.ONE); - mod = mod.add(val.value); - } - - return RubyArray.newArray(runtime, - new RubyBigDecimal(runtime, div), - new RubyBigDecimal(runtime, mod)); - } - - @JRubyMethod(name = "exponent") - public IRubyObject exponent() { - return getRuntime().newFixnum(getExponent()); - } - - @JRubyMethod(name = "finite?") - public IRubyObject finite_p() { - if (isNaN()) { - return getRuntime().getFalse(); - } - return getRuntime().newBoolean(!isInfinity()); - } - - @JRubyMethod(name = "floor", optional = 1) - public IRubyObject floor(IRubyObject[]args) { - if (isNaN) { - return newNaN(getRuntime()); - } - if (isInfinity()) { - return newInfinity(getRuntime(), infinitySign); - } - - int n = 0; - if (args.length > 0) { - n = RubyNumeric.fix2int(args[0]); - } - - if (value.scale() > n) { // rounding neccessary - return new RubyBigDecimal(getRuntime(), - value.setScale(n, RoundingMode.FLOOR)); - } else { - return this; - } - } - - @JRubyMethod(name = "frac") - public IRubyObject frac() { - if (isNaN) { - return newNaN(getRuntime()); - } - if (isInfinity()) { - return newInfinity(getRuntime(), infinitySign); - } - if (value.scale() > 0 && value.precision() < value.scale()) { - return new RubyBigDecimal(getRuntime(), value); - } - - BigDecimal val = value.subtract(((RubyBigDecimal)fix()).value); - return new RubyBigDecimal(getRuntime(), val); - } - - @JRubyMethod(name = "infinite?") - public IRubyObject infinite_p() { - if (infinitySign == 0) { - return getRuntime().getNil(); - } - return getRuntime().newFixnum(infinitySign); - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect(ThreadContext context) { - StringBuilder val = new StringBuilder("#<BigDecimal:").append(Integer.toHexString(System.identityHashCode(this))).append(","); - val.append("'").append(this.callMethod(context, MethodIndex.TO_S, "to_s")).append("'").append(","); - - val.append(getSignificantDigits().length()).append("("); - - int len = getAllDigits().length(); - int pow = len / 4; - val.append((pow + 1) * 4).append(")").append(">"); - - return getRuntime().newString(val.toString()); - } - - @JRubyMethod(name = "nan?") - public IRubyObject nan_p() { - return getRuntime().newBoolean(isNaN); - } - - @JRubyMethod(name = "nonzero?") - public IRubyObject nonzero_p() { - return isZero() ? getRuntime().getNil() : this; - } - - @JRubyMethod(name = "precs") - public IRubyObject precs() { - final Ruby runtime = getRuntime(); - final IRubyObject[] array = new IRubyObject[2]; - - array[0] = runtime.newFixnum(getSignificantDigits().length()); - - int len = getAllDigits().length(); - int pow = len / 4; - array[1] = runtime.newFixnum((pow + 1) * 4); - - return RubyArray.newArray(runtime, array); - } - - @JRubyMethod(name = "round", optional = 2) - public IRubyObject round(IRubyObject[] args) { - int scale = args.length > 0 ? num2int(args[0]) : 0; - int mode = (args.length > 1) ? javaRoundingModeFromRubyRoundingMode(args[1]) : BigDecimal.ROUND_HALF_UP; - // JRUBY-914: Java 1.4 BigDecimal does not allow a negative scale, so we have to simulate it - if (scale < 0) { - // shift the decimal point just to the right of the digit to be rounded to (divide by 10**(abs(scale))) - // -1 -> 10's digit, -2 -> 100's digit, etc. - BigDecimal normalized = value.movePointRight(scale); - // ...round to that digit - BigDecimal rounded = normalized.setScale(0,mode); - // ...and shift the result back to the left (multiply by 10**(abs(scale))) - return new RubyBigDecimal(getRuntime(), rounded.movePointLeft(scale)); - } else { - return new RubyBigDecimal(getRuntime(), value.setScale(scale, mode)); - } - } - - //this relies on the Ruby rounding enumerations == Java ones, which they (currently) all are - private int javaRoundingModeFromRubyRoundingMode(IRubyObject arg) { - return num2int(arg); - } - - @JRubyMethod(name = "sign") - public IRubyObject sign() { - if (isNaN()) { - return getMetaClass().fastGetConstant("SIGN_NaN"); - } - - if (isInfinity()) { - if (infinitySign < 0) { - return getMetaClass().fastGetConstant("SIGN_NEGATIVE_INFINITE"); - } else { - return getMetaClass().fastGetConstant("SIGN_POSITIVE_INFINITE"); - } - } - - if (isZero()) { - if (zeroSign < 0) { - return getMetaClass().fastGetConstant("SIGN_NEGATIVE_ZERO"); - } else { - return getMetaClass().fastGetConstant("SIGN_POSITIVE_ZERO"); - } - } - - if (value.signum() < 0) { - return getMetaClass().fastGetConstant("SIGN_NEGATIVE_FINITE"); - } else { - return getMetaClass().fastGetConstant("SIGN_POSITIVE_FINITE"); - } - } - - @JRubyMethod(name = "split") - public RubyArray split() { - final Ruby runtime = getRuntime(); - final IRubyObject[] array = new IRubyObject[4]; - - // sign - final RubyFixnum sign; - if (isNaN) { - sign = RubyFixnum.zero(runtime); - } else if (isInfinity()) { - sign = runtime.newFixnum(infinitySign); - } else if (isZero()){ - sign = runtime.newFixnum(zeroSign); - } else { - sign = runtime.newFixnum(value.signum()); - } - array[0] = sign; - - // significant digits and exponent - final RubyString digits; - final RubyFixnum exp; - if (isNaN()) { - digits = runtime.newString("NaN"); - exp = RubyFixnum.zero(runtime); - } else if (isInfinity()) { - digits = runtime.newString("Infinity"); - exp = RubyFixnum.zero(runtime); - } else if (isZero()){ - digits = runtime.newString("0"); - exp = RubyFixnum.zero(runtime); - } else { - // normalize the value - digits = runtime.newString(getSignificantDigits()); - exp = runtime.newFixnum(getExponent()); - } - array[1] = digits; - array[3] = exp; - - // base - array[2] = runtime.newFixnum(10); - - return RubyArray.newArray(runtime, array); - } - - // it doesn't handle special cases - private String getSignificantDigits() { - // TODO: no need to calculate every time. - BigDecimal val = value.abs().stripTrailingZeros(); - return val.unscaledValue().toString(); - } - - private String getAllDigits() { - // TODO: no need to calculate every time. - BigDecimal val = value.abs(); - return val.unscaledValue().toString(); - } - - // it doesn't handle special cases - private int getExponent() { - // TODO: no need to calculate every time. - if (isZero()) { - return 0; - } - BigDecimal val = value.abs().stripTrailingZeros(); - return val.precision() - val.scale(); - } - - @JRubyMethod(name = "sqrt", required = 1) - public IRubyObject sqrt(IRubyObject arg) { - Ruby runtime = getRuntime(); - if (isNaN()) { - throw runtime.newFloatDomainError("(VpSqrt) SQRT(NaN value)"); - } - if ((isInfinity() && infinitySign < 0) || value.signum() < 0) { - throw runtime.newFloatDomainError("(VpSqrt) SQRT(negative value)"); - } - if (isInfinity() && infinitySign > 0) { - return newInfinity(runtime, 1); - } - - // NOTE: MRI's sqrt precision is limited by 100, - // but we allow values more than 100. - int n = RubyNumeric.fix2int(arg); - if (n < 0) { - throw runtime.newArgumentError("argument must be positive"); - } - - n += 4; // just in case, add a bit of extra precision - - return new RubyBigDecimal(getRuntime(), - bigSqrt(this.value, new MathContext(n, RoundingMode.HALF_UP))).setResult(); - } - - @JRubyMethod(name = "to_f") - public IRubyObject to_f() { - if (isNaN()) { - return RubyFloat.newFloat(getRuntime(), Double.NaN); - } - if (isInfinity()) { - return RubyFloat.newFloat(getRuntime(), - infinitySign < 0 ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY); - } - if (isZero()) { - return RubyFloat.newFloat(getRuntime(), - zeroSign < 0 ? -0.0 : 0.0); - } - return RubyFloat.newFloat(getRuntime(), value.doubleValue()); - } - - @JRubyMethod(name = {"to_i", "to_int"}) - public IRubyObject to_int() { - if (isNaN() || infinitySign != 0) { - return getRuntime().getNil(); - } - try { - return RubyNumeric.int2fix(getRuntime(), value.longValueExact()); - } catch (ArithmeticException ae) { - return RubyBignum.bignorm(getRuntime(), value.toBigInteger()); - } - } - - private String removeTrailingZeroes(String in) { - while(in.length() > 0 && in.charAt(in.length()-1)=='0') { - in = in.substring(0,in.length()-1); - } - return in; - } - - public static boolean formatHasLeadingPlus(String format) { - return format.startsWith("+"); - } - - public static boolean formatHasLeadingSpace(String format) { - return format.startsWith(" "); - } - - public static boolean formatHasFloatingPointNotation(String format) { - return format.endsWith("F"); - } - - public static int formatFractionalDigitGroups(String format) { - int groups = 0; - Pattern p = Pattern.compile("(\\+| )?(\\d+)(E|F)?"); - Matcher m = p.matcher(format); - if (m.matches()) { - groups = Integer.parseInt(m.group(2)); - } - return groups; - } - - private boolean hasArg(IRubyObject[] args) { - return args.length != 0 && !args[0].isNil(); - } - - private String format(IRubyObject[] args) { - return args[0].toString(); - } - - private String firstArgument(IRubyObject[] args) { - if (hasArg(args)) { - return format(args); - } - return null; - } - - private boolean posSpace(String arg) { - if (null != arg) { - return formatHasLeadingSpace(arg); - } - return false; - } - - private boolean posSign(String arg) { - if (null != arg) { - return formatHasLeadingPlus(arg) || posSpace(arg); - } - return false; - } - - private boolean asEngineering(String arg) { - if (null != arg) { - return !formatHasFloatingPointNotation(arg); - } - return true; - } - - private int groups(String arg) { - if (null != arg) { - return formatFractionalDigitGroups(arg); - } - return 0; - } - - private boolean isZero() { - return !isNaN() && !isInfinity() && (value.signum() == 0); - } - - private boolean isNaN() { - return isNaN; - } - - private boolean isInfinity() { - return infinitySign != 0; - } - - private String unscaledValue() { - return value.abs().unscaledValue().toString(); - } - - private IRubyObject engineeringValue(String arg) { - int exponent = getExponent(); - int signum = value.signum(); - StringBuilder build = new StringBuilder(); - build.append(signum == -1 ? "-" : (signum == 1 ? (posSign(arg) ? (posSpace(arg) ? " " : "+") : "") : "")); - build.append("0."); - if (0 == groups(arg)) { - String s = removeTrailingZeroes(unscaledValue()); - if ("".equals(s)) { - build.append("0"); - } else { - build.append(s); - } - } else { - int index = 0; - String sep = ""; - while (index < unscaledValue().length()) { - int next = index + groups(arg); - if (next > unscaledValue().length()) { - next = unscaledValue().length(); - } - build.append(sep).append(unscaledValue().substring(index, next)); - sep = " "; - index += groups(arg); - } - } - build.append("E").append(exponent); - return getRuntime().newString(build.toString()); - } - - private IRubyObject floatingPointValue(String arg) { - String values[] = value.abs().stripTrailingZeros().toPlainString().split("\\."); - String whole = "0"; - if (values.length > 0) { - whole = values[0]; - } - String after = "0"; - if (values.length > 1) { - after = values[1]; - } - int signum = value.signum(); - StringBuilder build = new StringBuilder(); - build.append(signum == -1 ? "-" : (signum == 1 ? (posSign(arg) ? (posSpace(arg) ? " " : "+") : "") : "")); - if (groups(arg) == 0) { - build.append(whole); - if (null != after) { - build.append(".").append(after); - } - } else { - int index = 0; - String sep = ""; - while (index < whole.length()) { - int next = index + groups(arg); - if (next > whole.length()) { - next = whole.length(); - } - build.append(sep).append(whole.substring(index, next)); - sep = " "; - index += groups(arg); - } - if (null != after) { - build.append("."); - index = 0; - sep = ""; - while (index < after.length()) { - int next = index + groups(arg); - if (next > after.length()) { - next = after.length(); - } - build.append(sep).append(after.substring(index, next)); - sep = " "; - index += groups(arg); - } - } - } - return getRuntime().newString(build.toString()); - } - - @JRubyMethod(name = "to_s", optional = 1) - public IRubyObject to_s(IRubyObject[] args) { - String arg = firstArgument(args); - if (isNaN()) { - return getRuntime().newString("NaN"); - } - if (infinitySign != 0) { - if (infinitySign == -1) { - return getRuntime().newString("-Infinity"); - } else { - return getRuntime().newString("Infinity"); - } - } - if (isZero()) { - String zero = "0.0"; - if (zeroSign < 0) { - zero = "-" + zero; - } - return getRuntime().newString(zero); - } - if(asEngineering(arg)) { - return engineeringValue(arg); - } else { - return floatingPointValue(arg); - } - } - - // Note: #fix has only no-arg form, but truncate allows optional parameter. - - @JRubyMethod - public IRubyObject fix() { - return truncate(RubyFixnum.zero(getRuntime())); - } - - @JRubyMethod - public IRubyObject truncate() { - return truncate(RubyFixnum.zero(getRuntime())); - } - - @JRubyMethod - public IRubyObject truncate(IRubyObject arg) { - if (isNaN) { - return newNaN(getRuntime()); - } - if (isInfinity()) { - return newInfinity(getRuntime(), infinitySign); - } - - int n = RubyNumeric.fix2int(arg); - - int precision = value.precision() - value.scale() + n; - - if (precision > 0) { - return new RubyBigDecimal(getRuntime(), - value.round(new MathContext(precision, RoundingMode.DOWN))); - } else { - // TODO: proper sign - return new RubyBigDecimal(getRuntime(), BigDecimal.ZERO); - } - } - - @JRubyMethod(name = "zero?") - public IRubyObject zero_p() { - return getRuntime().newBoolean(isZero()); - } - - /** - * Returns the correctly rounded square root of a positive - * BigDecimal. This method performs the fast <i>Square Root by - * Coupled Newton Iteration</i> algorithm by Timm Ahrendt, from - * the book "Pi, unleashed" by Jörg Arndt in a neat loop. - * <p> - * The code is based on Frans Lelieveld's code , used here with - * permission. - * - * @param squarD The number to get the root from. - * @param rootMC Precision and rounding mode. - * @return the root of the argument number - * @throws ArithmeticException - * if the argument number is negative - * @throws IllegalArgumentException - * if rootMC has precision 0 - */ - public static BigDecimal bigSqrt(BigDecimal squarD, MathContext rootMC) { - // General number and precision checking - int sign = squarD.signum(); - if (sign == -1) { - throw new ArithmeticException("Square root of a negative number: " + squarD); - } else if(sign == 0) { - return squarD.round(rootMC); - } - - int prec = rootMC.getPrecision(); // the requested precision - if (prec == 0) { - throw new IllegalArgumentException("Most roots won't have infinite precision = 0"); - } - - // Initial precision is that of double numbers 2^63/2 ~ 4E18 - int BITS = 62; // 63-1 an even number of number bits - int nInit = 16; // precision seems 16 to 18 digits - MathContext nMC = new MathContext(18, RoundingMode.HALF_DOWN); - - // Iteration variables, for the square root x and the reciprocal v - BigDecimal x = null, e = null; // initial x: x0 ~ sqrt() - BigDecimal v = null, g = null; // initial v: v0 = 1/(2*x) - - // Estimate the square root with the foremost 62 bits of squarD - BigInteger bi = squarD.unscaledValue(); // bi and scale are a tandem - int biLen = bi.bitLength(); - int shift = Math.max(0, biLen - BITS + (biLen%2 == 0 ? 0 : 1)); // even shift.. - bi = bi.shiftRight(shift); // ..floors to 62 or 63 bit BigInteger - - double root = Math.sqrt(bi.doubleValue()); - BigDecimal halfBack = new BigDecimal(BigInteger.ONE.shiftLeft(shift/2)); - - int scale = squarD.scale(); - if (scale % 2 == 1) { - root *= SQRT_10; // 5 -> 2, -5 -> -3 need half a scale more.. - } - scale = (int) Math.floor(scale/2.); // ..where 100 -> 10 shifts the scale - - // Initial x - use double root - multiply by halfBack to unshift - set new scale - x = new BigDecimal(root, nMC); - x = x.multiply(halfBack, nMC); // x0 ~ sqrt() - if (scale != 0) { - x = x.movePointLeft(scale); - } - - if (prec < nInit) { // for prec 15 root x0 must surely be OK - return x.round(rootMC); // return small prec roots without iterations - } - - // Initial v - the reciprocal - v = BigDecimal.ONE.divide(TWO.multiply(x), nMC); // v0 = 1/(2*x) - - // Collect iteration precisions beforehand - List<Integer> nPrecs = new ArrayList<Integer>(); - - assert nInit > 3 : "Never ending loop!"; // assume nInit = 16 <= prec - - // Let m be the exact digits precision in an earlier! loop - for (int m = prec + 1; m > nInit; m = m/2 + (m > 100 ? 1 : 2)) { - nPrecs.add(m); - } - - // The loop of "Square Root by Coupled Newton Iteration" - for (int i = nPrecs.size() - 1; i > -1; i--) { - // Increase precision - next iteration supplies n exact digits - nMC = new MathContext(nPrecs.get(i), (i%2 == 1) ? RoundingMode.HALF_UP : - RoundingMode.HALF_DOWN); - - // Next x // e = d - x^2 - e = squarD.subtract(x.multiply(x, nMC), nMC); - if (i != 0) { - x = x.add(e.multiply(v, nMC)); // x += e*v ~ sqrt() - } else { - x = x.add(e.multiply(v, rootMC), rootMC); // root x is ready! - break; - } - - // Next v // g = 1 - 2*x*v - g = BigDecimal.ONE.subtract(TWO.multiply(x).multiply(v, nMC)); - - v = v.add(g.multiply(v, nMC)); // v += g*v ~ 1/2/sqrt() - } - - return x; // return sqrt(squarD) with precision of rootMC - } -}// RubyBigdecimal -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="Bignum", parent="Integer") -public class RubyBignum extends RubyInteger { - public static RubyClass createBignumClass(Ruby runtime) { - RubyClass bignum = runtime.defineClass("Bignum", runtime.getInteger(), - ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setBignum(bignum); - bignum.index = ClassIndex.BIGNUM; - - bignum.defineAnnotatedMethods(RubyBignum.class); - - return bignum; - } - - private static final int BIT_SIZE = 64; - private static final long MAX = (1L << (BIT_SIZE - 1)) - 1; - private static final BigInteger LONG_MAX = BigInteger.valueOf(MAX); - private static final BigInteger LONG_MIN = BigInteger.valueOf(-MAX - 1); - - private final BigInteger value; - - public RubyBignum(Ruby runtime, BigInteger value) { - super(runtime, runtime.getBignum()); - this.value = value; - } - - public int getNativeTypeIndex() { - return ClassIndex.BIGNUM; - } - - public Class<?> getJavaClass() { - return BigInteger.class; - } - - public static RubyBignum newBignum(Ruby runtime, long value) { - return newBignum(runtime, BigInteger.valueOf(value)); - } - - public static RubyBignum newBignum(Ruby runtime, double value) { - return newBignum(runtime, new BigDecimal(value).toBigInteger()); - } - - public static RubyBignum newBignum(Ruby runtime, BigInteger value) { - return new RubyBignum(runtime, value); - } - - public static RubyBignum newBignum(Ruby runtime, String value) { - return new RubyBignum(runtime, new BigInteger(value)); - } - - public double getDoubleValue() { - return big2dbl(this); - } - - public long getLongValue() { - return big2long(this); - } - - /** Getter for property value. - * @return Value of property value. - */ - public BigInteger getValue() { - return value; - } - - /* ================ - * Utility Methods - * ================ - */ - - /* If the value will fit in a Fixnum, return one of those. */ - /** rb_big_norm - * - */ - public static RubyInteger bignorm(Ruby runtime, BigInteger bi) { - if (bi.compareTo(LONG_MIN) < 0 || bi.compareTo(LONG_MAX) > 0) { - return newBignum(runtime, bi); - } - return runtime.newFixnum(bi.longValue()); - } - - /** rb_big2long - * - */ - public static long big2long(RubyBignum value) { - BigInteger big = value.getValue(); - - if (big.compareTo(LONG_MIN) < 0 || big.compareTo(LONG_MAX) > 0) { - throw value.getRuntime().newRangeError("bignum too big to convert into `long'"); - } - return big.longValue(); - } - - /** rb_big2dbl - * - */ - public static double big2dbl(RubyBignum value) { - BigInteger big = value.getValue(); - double dbl = convertToDouble(big); - if (dbl == Double.NEGATIVE_INFINITY || dbl == Double.POSITIVE_INFINITY) { - value.getRuntime().getWarnings().warn(ID.BIGNUM_FROM_FLOAT_RANGE, "Bignum out of Float range"); - } - return dbl; - } - - private IRubyObject checkShiftDown(RubyBignum other) { - if (other.value.signum() == 0) return RubyFixnum.zero(getRuntime()); - if (value.compareTo(LONG_MIN) < 0 || value.compareTo(LONG_MAX) > 0) { - return other.value.signum() >= 0 ? RubyFixnum.zero(getRuntime()) : RubyFixnum.minus_one(getRuntime()); - } - return getRuntime().getNil(); - } - - /** - * BigInteger#doubleValue is _really_ slow currently. - * This is faster, and mostly correct (?) - */ - static double convertToDouble(BigInteger bigint) { - byte[] arr = bigint.toByteArray(); - double res = 0; - double acc = 1; - for (int i = arr.length - 1; i > 0 ; i--) - { - res += (double) (arr[i] & 0xff) * acc; - acc *= 256; - } - res += (double) arr[0] * acc; // final byte sign is significant - return res; - } - - /** rb_int2big - * - */ - public static BigInteger fix2big(RubyFixnum arg) { - return BigInteger.valueOf(arg.getLongValue()); - } - - /* ================ - * Instance Methods - * ================ - */ - - /** rb_big_to_s - * - */ - @JRubyMethod(name = "to_s", optional = 1) - public IRubyObject to_s(IRubyObject[] args) { - int base = args.length == 0 ? 10 : num2int(args[0]); - if (base < 2 || base > 36) { - throw getRuntime().newArgumentError("illegal radix " + base); - } - return getRuntime().newString(getValue().toString(base)); - } - - /** rb_big_coerce - * - */ - @JRubyMethod(name = "coerce", required = 1) - public IRubyObject coerce(IRubyObject other) { - if (other instanceof RubyFixnum) { - return getRuntime().newArray(newBignum(getRuntime(), ((RubyFixnum) other).getLongValue()), this); - } else if (other instanceof RubyBignum) { - return getRuntime().newArray(newBignum(getRuntime(), ((RubyBignum) other).getValue()), this); - } - - throw getRuntime().newTypeError("Can't coerce " + other.getMetaClass().getName() + " to Bignum"); - } - - /** rb_big_uminus - * - */ - @JRubyMethod(name = "-@") - public IRubyObject op_uminus() { - return bignorm(getRuntime(), value.negate()); - } - - /** rb_big_plus - * - */ - @JRubyMethod(name = "+", required = 1) - public IRubyObject op_plus(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return addFixnum((RubyFixnum)other); - } else if (other instanceof RubyBignum) { - return addBignum((RubyBignum)other); - } else if (other instanceof RubyFloat) { - return addFloat((RubyFloat)other); - } - return addOther(context, other); - } - - private IRubyObject addFixnum(RubyFixnum other) { - return bignorm(getRuntime(), value.add(fix2big(other))); - } - - private IRubyObject addBignum(RubyBignum other) { - return bignorm(getRuntime(), value.add(other.value)); - } - - private IRubyObject addFloat(RubyFloat other) { - return RubyFloat.newFloat(getRuntime(), big2dbl(this) + other.getDoubleValue()); - } - - private IRubyObject addOther(ThreadContext context, IRubyObject other) { - return coerceBin(context, "+", other); - } - - /** rb_big_minus - * - */ - @JRubyMethod(name = "-", required = 1) - public IRubyObject op_minus(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return subtractFixnum((RubyFixnum)other); - } else if (other instanceof RubyBignum) { - return subtractBignum((RubyBignum)other); - } else if (other instanceof RubyFloat) { - return subtractFloat((RubyFloat)other); - } - return subtractOther(context, other); - } - - private IRubyObject subtractFixnum(RubyFixnum other) { - return bignorm(getRuntime(), value.subtract(fix2big(((RubyFixnum) other)))); - } - - private IRubyObject subtractBignum(RubyBignum other) { - return bignorm(getRuntime(), value.subtract(((RubyBignum) other).value)); - } - - private IRubyObject subtractFloat(RubyFloat other) { - return RubyFloat.newFloat(getRuntime(), big2dbl(this) - ((RubyFloat) other).getDoubleValue()); - } - - private IRubyObject subtractOther(ThreadContext context, IRubyObject other) { - return coerceBin(context, "-", other); - } - - /** rb_big_mul - * - */ - @JRubyMethod(name = "*", required = 1) - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return bignorm(getRuntime(), value.multiply(fix2big(((RubyFixnum) other)))); - } - if (other instanceof RubyBignum) { - return bignorm(getRuntime(), value.multiply(((RubyBignum) other).value)); - } else if (other instanceof RubyFloat) { - return RubyFloat.newFloat(getRuntime(), big2dbl(this) * ((RubyFloat) other).getDoubleValue()); - } - return coerceBin(context, "*", other); - } - - /** - * rb_big_divide. Shared part for both "/" and "div" operations. - */ - private IRubyObject op_divide(ThreadContext context, IRubyObject other, String op) { - assert ("/".equals(op) || "div".equals(op)); - - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big((RubyFixnum) other); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else if (other instanceof RubyFloat) { - double div = big2dbl(this) / ((RubyFloat) other).getDoubleValue(); - if ("/".equals(op)) { - return RubyFloat.newFloat(getRuntime(), - big2dbl(this) / ((RubyFloat) other).getDoubleValue()); - } else { - return RubyNumeric.dbl2num(getRuntime(), div); - } - } else { - return coerceBin(context, op, other); - } - - if (otherValue.equals(BigInteger.ZERO)) { - throw getRuntime().newZeroDivisionError(); - } - - BigInteger[] results = value.divideAndRemainder(otherValue); - - if ((value.signum() * otherValue.signum()) == -1 && results[1].signum() != 0) { - return bignorm(getRuntime(), results[0].subtract(BigInteger.ONE)); - } - return bignorm(getRuntime(), results[0]); - } - - /** rb_big_div - * - */ - @JRubyMethod(name = {"/"}, required = 1) - public IRubyObject op_div(ThreadContext context, IRubyObject other) { - return op_divide(context, other, "/"); - } - - /** rb_big_idiv - * - */ - @JRubyMethod(name = {"div"}, required = 1) - public IRubyObject op_idiv(ThreadContext context, IRubyObject other) { - return op_divide(context, other, "div"); - } - - /** rb_big_divmod - * - */ - @JRubyMethod(name = "divmod", required = 1) - public IRubyObject divmod(ThreadContext context, IRubyObject other) { - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big((RubyFixnum) other); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else { - return coerceBin(context, "divmod", other); - } - - if (otherValue.equals(BigInteger.ZERO)) { - throw getRuntime().newZeroDivisionError(); - } - - BigInteger[] results = value.divideAndRemainder(otherValue); - - if ((value.signum() * otherValue.signum()) == -1 && results[1].signum() != 0) { - results[0] = results[0].subtract(BigInteger.ONE); - results[1] = otherValue.add(results[1]); - } - final Ruby runtime = getRuntime(); - return RubyArray.newArray(getRuntime(), bignorm(runtime, results[0]), bignorm(runtime, results[1])); - } - - /** rb_big_modulo - * - */ - @JRubyMethod(name = {"%", "modulo"}, required = 1) - public IRubyObject op_mod(ThreadContext context, IRubyObject other) { - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big((RubyFixnum) other); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else { - return coerceBin(context, "%", other); - } - if (otherValue.equals(BigInteger.ZERO)) { - throw getRuntime().newZeroDivisionError(); - } - BigInteger result = value.mod(otherValue.abs()); - if (otherValue.signum() == -1 && result.signum() != 0) { - result = otherValue.add(result); - } - return bignorm(getRuntime(), result); - - } - - /** rb_big_remainder - * - */ - @JRubyMethod(name = "remainder", required = 1) - public IRubyObject remainder(ThreadContext context, IRubyObject other) { - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big(((RubyFixnum) other)); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else { - return coerceBin(context, "remainder", other); - } - if (otherValue.equals(BigInteger.ZERO)) { - throw getRuntime().newZeroDivisionError(); - } - return bignorm(getRuntime(), value.remainder(otherValue)); - } - - /** rb_big_quo - - * - */ - @JRubyMethod(name = "quo", required = 1) - public IRubyObject quo(ThreadContext context, IRubyObject other) { - if (other instanceof RubyNumeric) { - return RubyFloat.newFloat(getRuntime(), big2dbl(this) / ((RubyNumeric) other).getDoubleValue()); - } else { - return coerceBin(context, "quo", other); - } - } - - /** rb_big_pow - * - */ - @JRubyMethod(name = {"**", "power"}, required = 1) - public IRubyObject op_pow(ThreadContext context, IRubyObject other) { - double d; - if (other instanceof RubyFixnum) { - RubyFixnum fix = (RubyFixnum) other; - long fixValue = fix.getLongValue(); - // MRI issuses warning here on (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) - if (((value.bitLength() + 7) / 8) * 4 * Math.abs(fixValue) > 1024 * 1024) { - getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big", fixValue); - } - if (fixValue >= 0) { - return bignorm(getRuntime(), value.pow((int) fixValue)); // num2int is also implemented - } else { - return RubyFloat.newFloat(getRuntime(), Math.pow(big2dbl(this), (double)fixValue)); - } - } else if (other instanceof RubyBignum) { - d = ((RubyBignum) other).getDoubleValue(); - getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big", d); - } else if (other instanceof RubyFloat) { - d = ((RubyFloat) other).getDoubleValue(); - } else { - return coerceBin(context, "**", other); - - } - return RubyFloat.newFloat(getRuntime(), Math.pow(big2dbl(this), d)); - } - - /** rb_big_pow - * - */ - @JRubyMethod(name = {"**", "power"}, required = 1, compat = CompatVersion.RUBY1_9) - public IRubyObject op_pow_19(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - if (other == RubyFixnum.zero(runtime)) return RubyFixnum.one(runtime); - double d; - if (other instanceof RubyFixnum) { - RubyFixnum fix = (RubyFixnum) other; - long fixValue = fix.getLongValue(); - - if (fixValue < 0) { - return RubyRational.newRationalRaw(runtime, this).callMethod(context, "**", other); - } - // MRI issuses warning here on (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) - if (((value.bitLength() + 7) / 8) * 4 * Math.abs(fixValue) > 1024 * 1024) { - getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big", fixValue); - } - if (fixValue >= 0) { - return bignorm(runtime, value.pow((int) fixValue)); // num2int is also implemented - } else { - return RubyFloat.newFloat(runtime, Math.pow(big2dbl(this), (double)fixValue)); - } - } else if (other instanceof RubyBignum) { - if (other.callMethod(context, "<", RubyFixnum.zero(runtime)).isTrue()) { - return RubyRational.newRationalRaw(runtime, this).callMethod(context, "**", other); - } - d = ((RubyBignum) other).getDoubleValue(); - getRuntime().getWarnings().warn(ID.MAY_BE_TOO_BIG, "in a**b, b may be too big", d); - } else if (other instanceof RubyFloat) { - d = ((RubyFloat) other).getDoubleValue(); - } else { - return coerceBin(context, "**", other); - - } - return RubyNumeric.dbl2num(runtime, Math.pow(big2dbl(this), d)); - } - - /** rb_big_and - * - */ - @JRubyMethod(name = "&", required = 1) - public IRubyObject op_and(ThreadContext context, IRubyObject other) { - other = other.convertToInteger(); - if (other instanceof RubyBignum) { - return bignorm(getRuntime(), value.and(((RubyBignum) other).value)); - } else if(other instanceof RubyFixnum) { - return bignorm(getRuntime(), value.and(fix2big((RubyFixnum)other))); - } - return coerceBin(context, "&", other); - } - - /** rb_big_or - * - */ - @JRubyMethod(name = "|", required = 1) - public IRubyObject op_or(ThreadContext context, IRubyObject other) { - other = other.convertToInteger(); - if (other instanceof RubyBignum) { - return bignorm(getRuntime(), value.or(((RubyBignum) other).value)); - } - if (other instanceof RubyFixnum) { // no bignorm here needed - return bignorm(getRuntime(), value.or(fix2big((RubyFixnum)other))); - } - return coerceBin(context, "|", other); - } - - /** rb_big_xor - * - */ - @JRubyMethod(name = "^", required = 1) - public IRubyObject op_xor(ThreadContext context, IRubyObject other) { - other = other.convertToInteger(); - if (other instanceof RubyBignum) { - return bignorm(getRuntime(), value.xor(((RubyBignum) other).value)); - } - if (other instanceof RubyFixnum) { - return bignorm(getRuntime(), value.xor(BigInteger.valueOf(((RubyFixnum) other).getLongValue()))); - } - return coerceBin(context, "^", other); - } - - /** rb_big_neg - * - */ - @JRubyMethod(name = "~") - public IRubyObject op_neg() { - return RubyBignum.newBignum(getRuntime(), value.not()); - } - - /** rb_big_lshift - * - */ - @JRubyMethod(name = "<<", required = 1) - public IRubyObject op_lshift(IRubyObject other) { - long shift; - boolean neg = false; - - for (;;) { - if (other instanceof RubyFixnum) { - shift = ((RubyFixnum)other).getLongValue(); - if (shift < 0) { - neg = true; - shift = -shift; - } - break; - } else if (other instanceof RubyBignum) { - RubyBignum otherBignum = (RubyBignum)other; - if (otherBignum.value.signum() < 0) { - IRubyObject tmp = otherBignum.checkShiftDown(this); - if (!tmp.isNil()) return tmp; - neg = true; - } - shift = big2long(otherBignum); - break; - } - other = other.convertToInteger(); - } - - return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift)); - } - - /** rb_big_rshift - * - */ - @JRubyMethod(name = ">>", required = 1) - public IRubyObject op_rshift(IRubyObject other) { - long shift; - boolean neg = false; - - for (;;) { - if (other instanceof RubyFixnum) { - shift = ((RubyFixnum)other).getLongValue(); - if (shift < 0) { - neg = true; - shift = -shift; - } - break; - } else if (other instanceof RubyBignum) { - RubyBignum otherBignum = (RubyBignum)other; - if (otherBignum.value.signum() >= 0) { - IRubyObject tmp = otherBignum.checkShiftDown(this); - if (!tmp.isNil()) return tmp; - } else { - neg = true; - } - shift = big2long(otherBignum); - break; - } - other = other.convertToInteger(); - } - return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift)); - } - - /** rb_big_aref - * - */ - @JRubyMethod(name = "[]", required = 1) - public RubyFixnum op_aref(IRubyObject other) { - if (other instanceof RubyBignum) { - if (((RubyBignum) other).value.signum() >= 0 || value.signum() == -1) { - return RubyFixnum.zero(getRuntime()); - } - return RubyFixnum.one(getRuntime()); - } - long position = num2long(other); - if (position < 0 || position > Integer.MAX_VALUE) { - return RubyFixnum.zero(getRuntime()); - } - - return value.testBit((int)position) ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime()); - } - - /** rb_big_cmp - * - */ - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big((RubyFixnum) other); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else if (other instanceof RubyFloat) { - return dbl_cmp(getRuntime(), big2dbl(this), ((RubyFloat) other).getDoubleValue()); - } else { - return coerceCmp(context, "<=>", other); - } - - // wow, the only time we can use the java protocol ;) - return RubyFixnum.newFixnum(getRuntime(), value.compareTo(otherValue)); - } - - /** rb_big_eq - * - */ - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(IRubyObject other) { - final BigInteger otherValue; - if (other instanceof RubyFixnum) { - otherValue = fix2big((RubyFixnum) other); - } else if (other instanceof RubyBignum) { - otherValue = ((RubyBignum) other).value; - } else if (other instanceof RubyFloat) { - double a = ((RubyFloat) other).getDoubleValue(); - if (Double.isNaN(a)) { - return getRuntime().getFalse(); - } - return RubyBoolean.newBoolean(getRuntime(), a == big2dbl(this)); - } else { - return other.op_eqq(getRuntime().getCurrentContext(), this); - } - return RubyBoolean.newBoolean(getRuntime(), value.compareTo(otherValue) == 0); - } - - /** rb_big_eql - * - */ - @JRubyMethod(name = {"eql?", "==="}, required = 1) - public IRubyObject eql_p(IRubyObject other) { - if (other instanceof RubyBignum) { - return value.compareTo(((RubyBignum)other).value) == 0 ? getRuntime().getTrue() : getRuntime().getFalse(); - } - return getRuntime().getFalse(); - } - - /** rb_big_hash - * - */ - @JRubyMethod(name = "hash") - public RubyFixnum hash() { - return getRuntime().newFixnum(value.hashCode()); - } - - /** rb_big_to_f - * - */ - @JRubyMethod(name = "to_f") - public IRubyObject to_f() { - return RubyFloat.newFloat(getRuntime(), getDoubleValue()); - } - - /** rb_big_abs - * - */ - @JRubyMethod(name = "abs") - public IRubyObject abs() { - return RubyBignum.newBignum(getRuntime(), value.abs()); - } - - /** rb_big_size - * - */ - @JRubyMethod(name = "size") - public IRubyObject size() { - return getRuntime().newFixnum((value.bitLength() + 7) / 8); - } - - public static void marshalTo(RubyBignum bignum, MarshalStream output) throws IOException { - output.registerLinkTarget(bignum); - - output.write(bignum.value.signum() >= 0 ? '+' : '-'); - - BigInteger absValue = bignum.value.abs(); - - byte[] digits = absValue.toByteArray(); - - boolean oddLengthNonzeroStart = (digits.length % 2 != 0 && digits[0] != 0); - int shortLength = digits.length / 2; - if (oddLengthNonzeroStart) { - shortLength++; - } - output.writeInt(shortLength); - - for (int i = 1; i <= shortLength * 2 && i <= digits.length; i++) { - output.write(digits[digits.length - i]); - } - - if (oddLengthNonzeroStart) { - // Pad with a 0 - output.write(0); - } - } - - public static RubyNumeric unmarshalFrom(UnmarshalStream input) throws IOException { - boolean positive = input.readUnsignedByte() == '+'; - int shortLength = input.unmarshalInt(); - - // BigInteger required a sign byte in incoming array - byte[] digits = new byte[shortLength * 2 + 1]; - - for (int i = digits.length - 1; i >= 1; i--) { - digits[i] = input.readSignedByte(); - } - - BigInteger value = new BigInteger(digits); - if (!positive) { - value = value.negate(); - } - - RubyNumeric result = bignorm(input.getRuntime(), value); - input.registerLinkTarget(result); - return result; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Binding; -import org.jruby.runtime.Frame; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * @author jpetersen - */ -@JRubyClass(name="Binding") -public class RubyBinding extends RubyObject { - private Binding binding; - - public RubyBinding(Ruby runtime, RubyClass rubyClass, Binding binding) { - super(runtime, rubyClass); - - this.binding = binding; - } - - private RubyBinding(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass); - } - - private static ObjectAllocator BINDING_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyBinding instance = new RubyBinding(runtime, klass); - - return instance; - } - }; - - public static RubyClass createBindingClass(Ruby runtime) { - RubyClass bindingClass = runtime.defineClass("Binding", runtime.getObject(), BINDING_ALLOCATOR); - runtime.setBinding(bindingClass); - - bindingClass.defineAnnotatedMethods(RubyBinding.class); - - return bindingClass; - } - - public Binding getBinding() { - return binding; - } - - // Proc class - - public static RubyBinding newBinding(Ruby runtime, Binding binding) { - return new RubyBinding(runtime, runtime.getBinding(), binding); - } - - public static RubyBinding newBinding(Ruby runtime) { - ThreadContext context = runtime.getCurrentContext(); - - // FIXME: We should be cloning, not reusing: frame, scope, dynvars, and potentially iter/block info - Frame frame = context.getCurrentFrame(); - Binding binding = new Binding(frame, context.getBindingRubyClass(), context.getCurrentScope()); - - return new RubyBinding(runtime, runtime.getBinding(), binding); - } - - /** - * Create a binding appropriate for a bare "eval", by using the previous (caller's) frame and current - * scope. - */ - public static RubyBinding newBindingForEval(ThreadContext context) { - // This requires some explaining. We use Frame values when executing blocks to fill in - // various values in ThreadContext and EvalState.eval like rubyClass, cref, and self. - // Largely, for an eval that is using the logical binding at a place where the eval is - // called we mostly want to use the current frames value for this. Most importantly, - // we need that self (JRUBY-858) at this point. We also need to make sure that returns - // jump to the right place (which happens to be the previous frame). Lastly, we do not - // want the current frames klazz since that will be the klazz represented of self. We - // want the class right before the eval (well we could use cref class for this too I think). - // Once we end up having Frames created earlier I think the logic of stuff like this will - // be better since we won't be worried about setting Frame to setup other variables/stacks - // but just making sure Frame itself is correct... - - Frame previousFrame = context.getPreviousFrame(); - Frame currentFrame = context.getCurrentFrame(); - currentFrame.setKlazz(previousFrame.getKlazz()); - - // Set jump target to whatever the previousTarget thinks is good. -// currentFrame.setJumpTarget(previousFrame.getJumpTarget() != null ? previousFrame.getJumpTarget() : previousFrame); - - Binding binding = new Binding(previousFrame, context.getBindingRubyClass(), context.getCurrentScope()); - Ruby runtime = context.getRuntime(); - - return new RubyBinding(runtime, runtime.getBinding(), binding); - } - - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public IRubyObject initialize(ThreadContext context) { - // FIXME: We should be cloning, not reusing: frame, scope, dynvars, and potentially iter/block info - Frame frame = context.getCurrentFrame(); - binding = new Binding(frame, context.getBindingRubyClass(), context.getCurrentScope()); - - return this; - } - - @JRubyMethod(name = "initialize_copy", required = 1, visibility = Visibility.PRIVATE) - @Override - public IRubyObject initialize_copy(IRubyObject other) { - RubyBinding otherBinding = (RubyBinding)other; - - binding = otherBinding.binding; - - return this; - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; - -/** - * - * @author jpetersen - */ -@JRubyClass(name={"TrueClass", "FalseClass"}) -public class RubyBoolean extends RubyObject { - - public RubyBoolean(Ruby runtime, boolean value) { - super(runtime, (value ? runtime.getTrueClass() : runtime.getFalseClass()), // Don't initialize with class - false); // Don't put in object space - - if (!value) flags = FALSE_F; - } - - @Override - public int getNativeTypeIndex() { - return (flags & FALSE_F) == 0 ? ClassIndex.TRUE : ClassIndex.FALSE; - } - - @Override - public boolean isImmediate() { - return true; - } - - @Override - public RubyClass getSingletonClass() { - return metaClass; - } - - @Override - public Class<?> getJavaClass() { - return boolean.class; - } - - public static RubyClass createFalseClass(Ruby runtime) { - RubyClass falseClass = runtime.defineClass("FalseClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setFalseClass(falseClass); - falseClass.index = ClassIndex.FALSE; - - falseClass.defineAnnotatedMethods(False.class); - - falseClass.getMetaClass().undefineMethod("new"); - - return falseClass; - } - - public static RubyClass createTrueClass(Ruby runtime) { - RubyClass trueClass = runtime.defineClass("TrueClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setTrueClass(trueClass); - trueClass.index = ClassIndex.TRUE; - - trueClass.defineAnnotatedMethods(True.class); - - trueClass.getMetaClass().undefineMethod("new"); - - return trueClass; - } - - public static RubyBoolean newBoolean(Ruby runtime, boolean value) { - return value ? runtime.getTrue() : runtime.getFalse(); - } - - public static class False { - @JRubyMethod(name = "&") - public static IRubyObject false_and(IRubyObject f, IRubyObject oth) { - return f; - } - - @JRubyMethod(name = "|") - public static IRubyObject false_or(IRubyObject f, IRubyObject oth) { - return oth.isTrue() ? f.getRuntime().getTrue() : f; - } - - @JRubyMethod(name = "^") - public static IRubyObject false_xor(IRubyObject f, IRubyObject oth) { - return oth.isTrue() ? f.getRuntime().getTrue() : f; - } - - @JRubyMethod(name = "to_s") - public static IRubyObject false_to_s(IRubyObject f) { - return f.getRuntime().newString("false"); - } - } - - public static class True { - @JRubyMethod(name = "&") - public static IRubyObject true_and(IRubyObject t, IRubyObject oth) { - return oth.isTrue() ? t : t.getRuntime().getFalse(); - } - - @JRubyMethod(name = "|") - public static IRubyObject true_or(IRubyObject t, IRubyObject oth) { - return t; - } - - @JRubyMethod(name = "^") - public static IRubyObject true_xor(IRubyObject t, IRubyObject oth) { - return oth.isTrue() ? t.getRuntime().getFalse() : t; - } - - @JRubyMethod(name = "to_s") - public static IRubyObject true_to_s(IRubyObject t) { - return t.getRuntime().newString("true"); - } - } - - @Override - public RubyFixnum id() { - if ((flags & FALSE_F) == 0) { - return RubyFixnum.newFixnum(getRuntime(), 2); - } else { - return RubyFixnum.zero(getRuntime()); - } - } - - @Override - public IRubyObject taint(ThreadContext context) { - return this; - } - - @Override - public IRubyObject freeze(ThreadContext context) { - return this; - } - - public void marshalTo(MarshalStream output) throws java.io.IOException { - output.write(isTrue() ? 'T' : 'F'); - } -} - -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; - -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.internal.runtime.methods.JavaMethod; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallSite; -import org.jruby.runtime.CallSite.InlineCachingCallSite; -import org.jruby.runtime.CallType; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ObjectMarshal; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.collections.WeakHashSet; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="Class", parent="Module") -public class RubyClass extends RubyModule { - public static final int CS_IDX_INITIALIZE = 0; - public static final String[] CS_NAMES = { - "initialize" - }; - private final CallSite[] baseCallSites = new CallSite[CS_NAMES.length]; - { - for(int i = 0; i < CS_NAMES.length; i++) { - baseCallSites[i] = new InlineCachingCallSite(CS_NAMES[i], CallType.FUNCTIONAL); - } - } - - private CallSite[] extraCallSites; - - public static void createClassClass(Ruby runtime, RubyClass classClass) { - classClass.index = ClassIndex.CLASS; - classClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyClass; - } - }; - - classClass.undefineMethod("module_function"); - classClass.undefineMethod("append_features"); - classClass.undefineMethod("extend_object"); - - classClass.defineAnnotatedMethods(RubyClass.class); - - classClass.addMethod("new", new SpecificArityNew(classClass, Visibility.PUBLIC)); - - // This is a non-standard method; have we decided to start extending Ruby? - //classClass.defineFastMethod("subclasses", callbackFactory.getFastOptMethod("subclasses")); - - // FIXME: for some reason this dispatcher causes a VerifyError... - //classClass.dispatcher = callbackFactory.createDispatcher(classClass); - } - - public static final ObjectAllocator CLASS_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyClass clazz = new RubyClass(runtime); - clazz.allocator = ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR; // Class.allocate object is not allocatable before it is initialized - return clazz; - } - }; - - public ObjectAllocator getAllocator() { - return allocator; - } - - public void setAllocator(ObjectAllocator allocator) { - this.allocator = allocator; - } - - @JRubyMethod(name = "allocate") - public IRubyObject allocate() { - if (superClass == null) throw runtime.newTypeError("can't instantiate uninitialized class"); - IRubyObject obj = allocator.allocate(runtime, this); - if (obj.getMetaClass().getRealClass() != getRealClass()) throw runtime.newTypeError("wrong instance allocation"); - return obj; - } - - public CallSite[] getBaseCallSites() { - return baseCallSites; - } - - public CallSite[] getExtraCallSites() { - return extraCallSites; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.CLASS; - } - - @Override - public boolean isModule() { - return false; - } - - @Override - public boolean isClass() { - return true; - } - - @Override - public boolean isSingleton() { - return false; - } - - /** boot_defclass - * Create an initial Object meta class before Module and Kernel dependencies have - * squirreled themselves together. - * - * @param runtime we need it - * @return a half-baked meta class for object - */ - public static RubyClass createBootstrapClass(Ruby runtime, String name, RubyClass superClass, ObjectAllocator allocator) { - RubyClass obj; - - if (superClass == null ) { // boot the Object class - obj = new RubyClass(runtime); - obj.marshal = DEFAULT_OBJECT_MARSHAL; - } else { // boot the Module and Class classes - obj = new RubyClass(runtime, superClass); - } - obj.setAllocator(allocator); - obj.setBaseName(name); - return obj; - } - - private final Ruby runtime; - private ObjectAllocator allocator; // the default allocator - protected ObjectMarshal marshal; - private Set<RubyClass> subclasses; - - /** separate path for MetaClass and IncludedModuleWrapper construction - * (rb_class_boot version for MetaClasses) - * no marshal, allocator initialization and addSubclass(this) here! - */ - protected RubyClass(Ruby runtime, RubyClass superClass, boolean objectSpace) { - super(runtime, runtime.getClassClass(), objectSpace); - this.runtime = runtime; - this.superClass = superClass; // this is the only case it might be null here (in MetaClass construction) - } - - /** used by CLASS_ALLOCATOR (any Class' class will be a Class!) - * also used to bootstrap Object class - */ - protected RubyClass(Ruby runtime) { - super(runtime, runtime.getClassClass()); - this.runtime = runtime; - index = ClassIndex.CLASS; - } - - /** rb_class_boot (for plain Classes) - * also used to bootstrap Module and Class classes - */ - protected RubyClass(Ruby runtime, RubyClass superClazz) { - this(runtime); - superClass = superClazz; - marshal = superClazz.marshal; // use parent's marshal - superClazz.addSubclass(this); - - infectBy(superClass); - } - - /** - * A constructor which allows passing in an array of supplementary call sites. - */ - protected RubyClass(Ruby runtime, RubyClass superClazz, CallSite[] extraCallSites) { - this(runtime); - this.superClass = superClazz; - this.marshal = superClazz.marshal; // use parent's marshal - superClazz.addSubclass(this); - - this.extraCallSites = extraCallSites; - - infectBy(superClass); - } - - /** - * Construct a new class with the given name scoped under Object (global) - * and with Object as its immediate superclass. - * Corresponds to rb_class_new in MRI. - */ - public static RubyClass newClass(Ruby runtime, RubyClass superClass) { - if (superClass == runtime.getClassClass()) throw runtime.newTypeError("can't make subclass of Class"); - if (superClass.isSingleton()) throw runtime.newTypeError("can't make subclass of virtual class"); - return new RubyClass(runtime, superClass); - } - - /** - * A variation on newClass that allow passing in an array of supplementary - * call sites to improve dynamic invocation. - */ - public static RubyClass newClass(Ruby runtime, RubyClass superClass, CallSite[] extraCallSites) { - if (superClass == runtime.getClassClass()) throw runtime.newTypeError("can't make subclass of Class"); - if (superClass.isSingleton()) throw runtime.newTypeError("can't make subclass of virtual class"); - return new RubyClass(runtime, superClass, extraCallSites); - } - - /** - * Construct a new class with the given name, allocator, parent class, - * and containing class. If setParent is true, the class's parent will be - * explicitly set to the provided parent (rather than the new class just - * being assigned to a constant in that parent). - * Corresponds to rb_class_new/rb_define_class_id/rb_name_class/rb_set_class_path - * in MRI. - */ - public static RubyClass newClass(Ruby runtime, RubyClass superClass, String name, ObjectAllocator allocator, RubyModule parent, boolean setParent) { - RubyClass clazz = newClass(runtime, superClass); - clazz.setBaseName(name); - clazz.setAllocator(allocator); - clazz.makeMetaClass(superClass.getMetaClass()); - if (setParent) clazz.setParent(parent); - parent.setConstant(name, clazz); - clazz.inherit(superClass); - return clazz; - } - - /** - * A variation on newClass that allows passing in an array of supplementary - * call sites to improve dynamic invocation performance. - */ - public static RubyClass newClass(Ruby runtime, RubyClass superClass, String name, ObjectAllocator allocator, RubyModule parent, boolean setParent, CallSite[] extraCallSites) { - RubyClass clazz = newClass(runtime, superClass, extraCallSites); - clazz.setBaseName(name); - clazz.setAllocator(allocator); - clazz.makeMetaClass(superClass.getMetaClass()); - if (setParent) clazz.setParent(parent); - parent.setConstant(name, clazz); - clazz.inherit(superClass); - return clazz; - } - - /** rb_make_metaclass - * - */ - @Override - public RubyClass makeMetaClass(RubyClass superClass) { - if (isSingleton()) { // could be pulled down to RubyClass in future - MetaClass klass = new MetaClass(getRuntime(), superClass); // rb_class_boot - setMetaClass(klass); - - klass.setAttached(this); - klass.setMetaClass(klass); - klass.setSuperClass(getSuperClass().getRealClass().getMetaClass()); - - return klass; - } else { - return super.makeMetaClass(superClass); - } - } - - @Deprecated - public IRubyObject invoke(ThreadContext context, IRubyObject self, int methodIndex, String name, IRubyObject[] args, CallType callType, Block block) { - return invoke(context, self, name, args, callType, block); - } - - public boolean notVisibleAndNotMethodMissing(DynamicMethod method, String name, IRubyObject caller, CallType callType) { - return !method.isCallableFrom(caller, callType) && !name.equals("method_missing"); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - CallType callType, Block block) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, caller, callType, block); - } - return method.call(context, self, this, name, block); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, Block block) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, context.getFrameSelf(), CallType.FUNCTIONAL, block); - } - return method.call(context, self, this, name, block); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject[] args, CallType callType, Block block) { - assert args != null; - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, args, caller, callType, block); - } - return method.call(context, self, this, name, args, block); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject[] args, Block block) { - assert args != null; - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, args, context.getFrameSelf(), CallType.FUNCTIONAL, block); - } - return method.call(context, self, this, name, args, block); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg, CallType callType, Block block) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg, caller, callType, block); - } - return method.call(context, self, this, name, arg, block); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg, Block block) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg, context.getFrameSelf(), CallType.FUNCTIONAL, block); - } - return method.call(context, self, this, name, arg, block); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, CallType callType, Block block) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, caller, callType, block); - } - return method.call(context, self, this, name, arg0, arg1, block); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, Block block) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, context.getFrameSelf(), CallType.FUNCTIONAL, block); - } - return method.call(context, self, this, name, arg0, arg1, block); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType, Block block) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, arg2, caller, callType, block); - } - return method.call(context, self, this, name, arg0, arg1, arg2, block); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, arg2, context.getFrameSelf(), CallType.FUNCTIONAL, block); - } - return method.call(context, self, this, name, arg0, arg1, arg2, block); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - CallType callType) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, caller, callType, Block.NULL_BLOCK); - } - return method.call(context, self, this, name); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - return method.call(context, self, this, name); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject[] args, CallType callType) { - assert args != null; - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, args, caller, callType, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, args); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject[] args) { - assert args != null; - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, args, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, args); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg, CallType callType) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg, caller, callType, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, CallType callType) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, caller, callType, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg0, arg1); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg0, arg1); - } - - public IRubyObject invoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType) { - DynamicMethod method = searchMethod(name); - IRubyObject caller = context.getFrameSelf(); - if (shouldCallMethodMissing(method, name, caller, callType)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, arg2, caller, callType, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg0, arg1, arg2); - } - - public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, - IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { - DynamicMethod method = searchMethod(name); - if (shouldCallMethodMissing(method)) { - return RuntimeHelpers.callMethodMissing(context, self, method, name, arg0, arg1, arg2, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - return method.call(context, self, this, name, arg0, arg1, arg2); - } - - private boolean shouldCallMethodMissing(DynamicMethod method) { - return method.isUndefined(); - } - private boolean shouldCallMethodMissing(DynamicMethod method, String name, IRubyObject caller, CallType callType) { - return method.isUndefined() || notVisibleAndNotMethodMissing(method, name, caller, callType); - } - - public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) { - DynamicMethod method = getMetaClass().searchMethod("inherited"); - - if (method.isUndefined()) { - return RuntimeHelpers.callMethodMissing(context, self, method, "inherited", subclass, context.getFrameSelf(), CallType.FUNCTIONAL, Block.NULL_BLOCK); - } - - return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK); - } - - /** rb_class_new_instance - * - */ - public IRubyObject newInstance(ThreadContext context, IRubyObject[] args, Block block) { - IRubyObject obj = allocate(); - baseCallSites[CS_IDX_INITIALIZE].call(context, obj, args, block); - return obj; - } - - // TODO: replace this with a smarter generated invoker that can handle 0-N args - public static class SpecificArityNew extends JavaMethod { - public SpecificArityNew(RubyModule implClass, Visibility visibility) { - super(implClass, visibility); - } - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { - RubyClass cls = (RubyClass)self; - IRubyObject obj = cls.allocate(); - cls.baseCallSites[CS_IDX_INITIALIZE].call(context, obj, args, block); - return obj; - } - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { - RubyClass cls = (RubyClass)self; - IRubyObject obj = cls.allocate(); - cls.baseCallSites[CS_IDX_INITIALIZE].call(context, obj, block); - return obj; - } - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { - RubyClass cls = (RubyClass)self; - IRubyObject obj = cls.allocate(); - cls.baseCallSites[CS_IDX_INITIALIZE].call(context, obj, arg0, block); - return obj; - } - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) { - RubyClass cls = (RubyClass)self; - IRubyObject obj = cls.allocate(); - cls.baseCallSites[CS_IDX_INITIALIZE].call(context, obj, arg0, arg1, block); - return obj; - } - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - RubyClass cls = (RubyClass)self; - IRubyObject obj = cls.allocate(); - cls.baseCallSites[CS_IDX_INITIALIZE].call(context, obj, arg0, arg1, arg2, block); - return obj; - } - } - - /** rb_class_initialize - * - */ - @JRubyMethod(name = "initialize", optional = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block block) { - if (superClass != null) { - throw getRuntime().newTypeError("already initialized class"); - } - - IRubyObject superObject; - if (args.length == 0) { - superObject = getRuntime().getObject(); - } else { - superObject = args[0]; - checkInheritable(superObject); - } - - RubyClass superClazz = (RubyClass) superObject; - - superClass = superClazz; - allocator = superClazz.allocator; - makeMetaClass(superClazz.getMetaClass()); - - marshal = superClazz.marshal; - - superClazz.addSubclass(this); - - super.initialize(block); - - inherit(superClazz); - - return this; - } - - /** rb_class_init_copy - * - */ - @JRubyMethod(name = "initialize_copy", required = 1) - @Override - public IRubyObject initialize_copy(IRubyObject original){ - if (superClass != null) throw runtime.newTypeError("already initialized class"); - if (original instanceof MetaClass) throw getRuntime().newTypeError("can't copy singleton class"); - - super.initialize_copy(original); - allocator = ((RubyClass)original).allocator; - return this; - } - - // TODO: Someday, enable. - // @JRubyMethod(name = "subclasses", optional = 1) - public IRubyObject subclasses(ThreadContext context, IRubyObject[] args) { - boolean recursive = false; - if (args.length == 1) { - if (args[0] instanceof RubyBoolean) { - recursive = args[0].isTrue(); - } else { - context.getRuntime().newTypeError(args[0], context.getRuntime().fastGetClass("Boolean")); - } - } - - return RubyArray.newArray(context.getRuntime(), subclasses(recursive)).freeze(context); - } - - public Collection subclasses(boolean includeDescendants) { - if (subclasses != null) { - Collection<RubyClass> mine = new ArrayList<RubyClass>(subclasses); - if (includeDescendants) { - for (RubyClass i: subclasses) { - mine.addAll(i.subclasses(includeDescendants)); - } - } - - return mine; - } else { - return Collections.EMPTY_LIST; - } - } - - public synchronized void addSubclass(RubyClass subclass) { - if (subclasses == null) subclasses = new WeakHashSet<RubyClass>(); - subclasses.add(subclass); - } - - public Ruby getClassRuntime() { - return runtime; - } - - public RubyClass getRealClass() { - return this; - } - - @JRubyMethod(name = "inherited", required = 1) - public IRubyObject inherited(ThreadContext context, IRubyObject arg) { - return context.getRuntime().getNil(); - } - - /** rb_class_inherited (reversed semantics!) - * - */ - public void inherit(RubyClass superClazz) { - if (superClazz == null) superClazz = getRuntime().getObject(); - - superClazz.invokeInherited(getRuntime().getCurrentContext(), superClazz, this); - } - - /** Return the real super class of this class. - * - * rb_class_superclass - * - */ - @JRubyMethod(name = "superclass") - public IRubyObject superclass(ThreadContext context) { - RubyClass superClazz = superClass; - - if (superClazz == null) throw context.getRuntime().newTypeError("uninitialized class"); - - if (isSingleton()) superClazz = metaClass; - while (superClazz != null && superClazz.isIncluded()) superClazz = superClazz.superClass; - - return superClazz != null ? superClazz : context.getRuntime().getNil(); - } - - /** rb_check_inheritable - * - */ - public static void checkInheritable(IRubyObject superClass) { - if (!(superClass instanceof RubyClass)) { - throw superClass.getRuntime().newTypeError("superclass must be a Class (" + superClass.getMetaClass() + " given)"); - } - if (((RubyClass)superClass).isSingleton()) { - throw superClass.getRuntime().newTypeError("can't make subclass of virtual class"); - } - } - - public final ObjectMarshal getMarshal() { - return marshal; - } - - public final void setMarshal(ObjectMarshal marshal) { - this.marshal = marshal; - } - - public final void marshal(Object obj, MarshalStream marshalStream) throws IOException { - getMarshal().marshalTo(getRuntime(), obj, this, marshalStream); - } - - public final Object unmarshal(UnmarshalStream unmarshalStream) throws IOException { - return getMarshal().unmarshalFrom(getRuntime(), this, unmarshalStream); - } - - public static void marshalTo(RubyClass clazz, MarshalStream output) throws java.io.IOException { - output.registerLinkTarget(clazz); - output.writeString(MarshalStream.getPathFromClass(clazz)); - } - - public static RubyClass unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - String name = RubyString.byteListToString(input.unmarshalString()); - RubyClass result = UnmarshalStream.getClassFromPath(input.getRuntime(), name); - input.registerLinkTarget(result); - return result; - } - - protected static final ObjectMarshal DEFAULT_OBJECT_MARSHAL = new ObjectMarshal() { - public void marshalTo(Ruby runtime, Object obj, RubyClass type, - MarshalStream marshalStream) throws IOException { - IRubyObject object = (IRubyObject)obj; - - marshalStream.registerLinkTarget(object); - marshalStream.dumpVariables(object.getVariableList()); - } - - public Object unmarshalFrom(Ruby runtime, RubyClass type, - UnmarshalStream unmarshalStream) throws IOException { - IRubyObject result = type.allocate(); - - unmarshalStream.registerLinkTarget(result); - - unmarshalStream.defaultVariablesUnmarshal(result); - - return result; - } - }; -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import org.jruby.anno.JRubyMethod; - -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -public class RubyClassPathVariable extends RubyObject { - public static void createClassPathVariable(Ruby runtime) { - RubyClassPathVariable self = new RubyClassPathVariable(runtime); - runtime.getEnumerable().extend_object(self); - runtime.defineReadonlyVariable("$CLASSPATH", self); - - self.getMetaClass().defineAnnotatedMethods(RubyClassPathVariable.class); - } - - private RubyClassPathVariable(Ruby runtime) { - super(runtime, runtime.getObject()); - } - - @JRubyMethod(name = {"append", "<<"}, required = 1) - public IRubyObject append(IRubyObject obj) throws Exception { - String ss = obj.convertToString().toString(); - URL url = getURL(ss); - getRuntime().getJRubyClassLoader().addURL(url); - return this; - } - - private URL getURL(String target) throws MalformedURLException { - if(target.indexOf("://") == -1) { - return new File(target).toURI().toURL(); - } else { - return new URL(target); - } - } - - @JRubyMethod(name = {"size", "length"}) - public IRubyObject size() { - return getRuntime().newFixnum(getRuntime().getJRubyClassLoader().getURLs().length); - } - - @JRubyMethod(name = "each", frame = true) - public IRubyObject each(Block block) { - URL[] urls = getRuntime().getJRubyClassLoader().getURLs(); - ThreadContext ctx = getRuntime().getCurrentContext(); - for(int i=0,j=urls.length;i<j;i++) { - block.yield(ctx, getRuntime().newString(urls[i].toString())); - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - return callMethod(getRuntime().getCurrentContext(), "to_a").callMethod(getRuntime().getCurrentContext(), "to_s"); - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - return callMethod(getRuntime().getCurrentContext(), "to_a").callMethod(getRuntime().getCurrentContext(), "inspect"); - } -}// RubyClassPathVariable -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2006 Thomas E Enebo <enebo@acm.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.exceptions.RaiseException; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -/** Implementation of the Comparable module. - * - */ -@JRubyModule(name="Comparable") -public class RubyComparable { - public static RubyModule createComparable(Ruby runtime) { - RubyModule comparableModule = runtime.defineModule("Comparable"); - runtime.setComparable(comparableModule); - - comparableModule.defineAnnotatedMethods(RubyComparable.class); - - return comparableModule; - } - - /* ================ - * Utility Methods - * ================ - */ - - /** rb_cmpint - * - */ - public static int cmpint(ThreadContext context, IRubyObject val, IRubyObject a, IRubyObject b) { - if (val.isNil()) cmperr(a, b); - if (val instanceof RubyFixnum) return RubyNumeric.fix2int((RubyFixnum) val); - if (val instanceof RubyBignum) return ((RubyBignum) val).getValue().signum() == -1 ? 1 : -1; - - RubyFixnum zero = RubyFixnum.zero(context.getRuntime()); - - if (val.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue()) return 1; - if (val.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue()) return -1; - - return 0; - } - - /** rb_cmperr - * - */ - public static IRubyObject cmperr(IRubyObject recv, IRubyObject other) { - IRubyObject target; - if (other.isImmediate() || !(other.isNil() || other.isTrue() || other == recv.getRuntime().getFalse())) { - target = other.inspect(); - } else { - target = other.getType(); - } - - throw recv.getRuntime().newArgumentError("comparison of " + recv.getType() + " with " + target + " failed"); - } - - /* ================ - * Module Methods - * ================ - */ - - /** cmp_equal (cmp_eq inlined here) - * - */ - @JRubyMethod(name = "==", required = 1) - public static IRubyObject op_equal(ThreadContext context, IRubyObject recv, IRubyObject other) { - Ruby runtime = context.getRuntime(); - - if (recv == other) return runtime.getTrue(); - - try { - IRubyObject result = recv.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other); - - return RubyBoolean.newBoolean(runtime, cmpint(context, result, recv, other) == 0); - } catch (RaiseException e) { - if (e.getException().kind_of_p(context, runtime.getStandardError()).isTrue()) { - return runtime.getNil(); - } else { - throw e; - } - } - } - - /** cmp_gt - * - */ - // <=> may return nil in many circumstances, e.g. 3 <=> NaN - @JRubyMethod(name = ">", required = 1) - public static RubyBoolean op_gt(ThreadContext context, IRubyObject recv, IRubyObject other) { - IRubyObject result = recv.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other); - - if (result.isNil()) cmperr(recv, other); - - return RubyBoolean.newBoolean(context.getRuntime(), cmpint(context, result, recv, other) > 0); - } - - /** cmp_ge - * - */ - @JRubyMethod(name = ">=", required = 1) - public static RubyBoolean op_ge(ThreadContext context, IRubyObject recv, IRubyObject other) { - IRubyObject result = recv.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other); - - if (result.isNil()) cmperr(recv, other); - - return RubyBoolean.newBoolean(context.getRuntime(), cmpint(context, result, recv, other) >= 0); - } - - /** cmp_lt - * - */ - @JRubyMethod(name = "<", required = 1) - public static RubyBoolean op_lt(ThreadContext context, IRubyObject recv, IRubyObject other) { - IRubyObject result = recv.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other); - - if (result.isNil()) cmperr(recv, other); - - return RubyBoolean.newBoolean(context.getRuntime(), cmpint(context, result, recv, other) < 0); - } - - /** cmp_le - * - */ - @JRubyMethod(name = "<=", required = 1) - public static RubyBoolean op_le(ThreadContext context, IRubyObject recv, IRubyObject other) { - IRubyObject result = recv.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other); - - if (result.isNil()) cmperr(recv, other); - - return RubyBoolean.newBoolean(context.getRuntime(), cmpint(context, result, recv, other) <= 0); - } - - /** cmp_between - * - */ - @JRubyMethod(name = "between?", required = 2) - public static RubyBoolean between_p(ThreadContext context, IRubyObject recv, IRubyObject first, IRubyObject second) { - return context.getRuntime().newBoolean(op_lt(context, recv, first).isFalse() && op_gt(context, recv, second).isFalse()); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import static org.jruby.util.Numeric.f_abs; -import static org.jruby.util.Numeric.f_abs2; -import static org.jruby.util.Numeric.f_add; -import static org.jruby.util.Numeric.f_arg; -import static org.jruby.util.Numeric.f_conjugate; -import static org.jruby.util.Numeric.f_denominator; -import static org.jruby.util.Numeric.f_div; -import static org.jruby.util.Numeric.f_divmod; -import static org.jruby.util.Numeric.f_equal_p; -import static org.jruby.util.Numeric.f_exact_p; -import static org.jruby.util.Numeric.f_expt; -import static org.jruby.util.Numeric.f_gt_p; -import static org.jruby.util.Numeric.f_inspect; -import static org.jruby.util.Numeric.f_lcm; -import static org.jruby.util.Numeric.f_mul; -import static org.jruby.util.Numeric.f_negate; -import static org.jruby.util.Numeric.f_negative_p; -import static org.jruby.util.Numeric.f_numerator; -import static org.jruby.util.Numeric.f_one_p; -import static org.jruby.util.Numeric.f_polar; -import static org.jruby.util.Numeric.f_quo; -import static org.jruby.util.Numeric.f_scalar_p; -import static org.jruby.util.Numeric.f_sub; -import static org.jruby.util.Numeric.f_to_f; -import static org.jruby.util.Numeric.f_to_i; -import static org.jruby.util.Numeric.f_to_r; -import static org.jruby.util.Numeric.f_to_s; -import static org.jruby.util.Numeric.f_xor; -import static org.jruby.util.Numeric.f_zero_p; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Arity; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.Frame; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.Numeric; - -/** - * 1.9 complex.c as of revision: 18876 - */ - -@JRubyClass(name = "Complex", parent = "Numeric") -public class RubyComplex extends RubyNumeric { - - public static RubyClass createComplexClass(Ruby runtime) { - RubyClass complexc = runtime.defineClass("Complex", runtime.getNumeric(), COMPLEX_ALLOCATOR); // because one can Complex.send(:allocate) - runtime.setComplex(complexc); - - complexc.index = ClassIndex.COMPLEX; - complexc.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyComplex; - } - }; - - ThreadContext context = runtime.getCurrentContext(); - complexc.callMethod(context, "private_class_method", runtime.newSymbol("allocate")); - - complexc.defineAnnotatedMethods(RubyComplex.class); - - String[]undefined = {"<", "<=", "<=>", ">", ">=", "between?", "divmod", - "floor", "ceil", "modulo", "round", "step", "truncate"}; - - for (String undef : undefined) { - complexc.undefineMethod(undef); - } - - complexc.defineConstant("I", RubyComplex.newComplexConvert(context, RubyFixnum.zero(runtime), RubyFixnum.one(runtime))); - - return complexc; - } - - private static ObjectAllocator COMPLEX_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyComplex(runtime, klass, RubyFixnum.zero(runtime), RubyFixnum.zero(runtime)); - } - }; - - /** internal - * - */ - private RubyComplex(Ruby runtime, IRubyObject clazz, IRubyObject real, IRubyObject image) { - super(runtime, (RubyClass)clazz); - this.real = real; - this.image = image; - } - - /** rb_complex_raw - * - */ - static RubyComplex newComplexRaw(Ruby runtime, IRubyObject x, RubyObject y) { - return new RubyComplex(runtime, runtime.getComplex(), x, y); - } - - /** rb_complex_raw1 - * - */ - static RubyComplex newComplexRaw(Ruby runtime, IRubyObject x) { - return new RubyComplex(runtime, runtime.getComplex(), x, RubyFixnum.zero(runtime)); - } - - /** rb_complex_new1 - * - */ - public static IRubyObject newComplexCanonicalize(ThreadContext context, IRubyObject x) { - return newComplexCanonicalize(context, x, RubyFixnum.zero(context.getRuntime())); - } - - /** rb_complex_new - * - */ - public static IRubyObject newComplexCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) { - return canonicalizeInternal(context, context.getRuntime().getComplex(), x, y); - } - - /** rb_complex_polar - * - */ - static IRubyObject newComplexPolar(ThreadContext context, IRubyObject x, IRubyObject y) { - return polar(context, context.getRuntime().getComplex(), x, y); - } - - /** f_complex_new1 - * - */ - static IRubyObject newComplex(ThreadContext context, IRubyObject clazz, IRubyObject x) { - return newComplex(context, clazz, x, RubyFixnum.zero(context.getRuntime())); - } - - /** f_complex_new2 - * - */ - static IRubyObject newComplex(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert !(x instanceof RubyComplex); - return canonicalizeInternal(context, clazz, x, y); - } - - /** f_complex_new_bang2 - * - */ - static RubyComplex newComplexBang(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert x instanceof RubyComplex && y instanceof RubyComplex; - return new RubyComplex(context.getRuntime(), clazz, x, y); - } - - /** f_complex_new_bang1 - * - */ - public static RubyComplex newComplexBang(ThreadContext context, IRubyObject clazz, IRubyObject x) { - assert x instanceof RubyComplex; - return newComplexBang(context, clazz, x, RubyFixnum.zero(context.getRuntime())); - } - - private IRubyObject real; - private IRubyObject image; - - IRubyObject getImage() { - return image; - } - - IRubyObject getReal() { - return real; - } - - /** m_cos - * - */ - private static IRubyObject m_cos(ThreadContext context, IRubyObject x) { - if (f_scalar_p(context, x).isTrue()) return RubyMath.cos(x, x); - RubyComplex complex = (RubyComplex)x; - return newComplex(context, context.getRuntime().getComplex(), - f_mul(context, RubyMath.cos(x, complex.real), RubyMath.cosh(x, complex.image)), - f_mul(context, f_negate(context, RubyMath.sin(x, complex.real)), RubyMath.sinh(x, complex.image))); - } - - /** m_sin - * - */ - private static IRubyObject m_sin(ThreadContext context, IRubyObject x) { - if (f_scalar_p(context, x).isTrue()) return RubyMath.sin(x, x); - RubyComplex complex = (RubyComplex)x; - return newComplex(context, context.getRuntime().getComplex(), - f_mul(context, RubyMath.sin(x, complex.real), RubyMath.cosh(x, complex.image)), - f_mul(context, RubyMath.cos(x, complex.real), RubyMath.sinh(x, complex.image))); - } - - /** m_sqrt - * - */ - private static IRubyObject m_sqrt(ThreadContext context, IRubyObject x) { - if (f_scalar_p(context, x).isTrue()) { - if (!f_negative_p(context, x)) return RubyMath.sqrt(x, x); - return newComplex(context, context.getRuntime().getComplex(), - RubyFixnum.zero(context.getRuntime()), - RubyMath.sqrt(x, f_negate(context, x))); - } else { - RubyComplex complex = (RubyComplex)x; - if (f_negative_p(context, complex.image)) { - return f_conjugate(context, m_sqrt(context, f_conjugate(context, x))); - } else { - IRubyObject a = f_abs(context, x); - IRubyObject two = RubyFixnum.two(context.getRuntime()); - return newComplex(context, context.getRuntime().getComplex(), - RubyMath.sqrt(x, f_div(context, f_add(context, a, complex.real), two)), - RubyMath.sqrt(x, f_div(context, f_sub(context, a, complex.real), two))); - } - } - } - - /** nucomp_s_new_bang - * - */ - @Deprecated - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject[]args) { - switch (args.length) { - case 1: return newInstanceBang(context, recv, args[0]); - case 2: return newInstanceBang(context, recv, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 1); - return null; - } - - @JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject real) { - if (!(real instanceof RubyNumeric)) real = f_to_i(context, real); - return new RubyComplex(context.getRuntime(), recv, real, RubyFixnum.zero(context.getRuntime())); - } - - @JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject real, IRubyObject image) { - if (!(real instanceof RubyNumeric)) real = f_to_i(context, real); - if (!(image instanceof RubyNumeric)) image = f_to_i(context, image); - return new RubyComplex(context.getRuntime(), recv, real, image); - } - - /** nucomp_real_check (might go to bimorphic) - * - */ - private static void realCheck(ThreadContext context, IRubyObject num) { - switch (num.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - case ClassIndex.RATIONAL: - break; - default: - if (!(num instanceof RubyNumeric ) || !f_scalar_p(context, num).isTrue()) { - throw context.getRuntime().newArgumentError("not a real"); - } - } - } - - /** nucomp_s_canonicalize_internal - * - */ - private static final boolean CL_CANNON = true; - private static IRubyObject canonicalizeInternal(ThreadContext context, IRubyObject clazz, IRubyObject real, IRubyObject image) { - if (f_zero_p(context, image) && - ((RubyModule)clazz).fastHasConstant("Unify") && - (!CL_CANNON || - (!(real instanceof RubyFloat) && - !(image instanceof RubyFloat)))) { - return real; - } else if (f_scalar_p(context, real).isTrue() && - f_scalar_p(context, image).isTrue()) { - return new RubyComplex(context.getRuntime(), clazz, real, image); - } else if (f_scalar_p(context, real).isTrue()) { - RubyComplex complex = (RubyComplex)image; - return new RubyComplex(context.getRuntime(), clazz, - f_sub(context, real, complex.image), - f_add(context, RubyFixnum.zero(context.getRuntime()), complex.real)); - } else if (f_scalar_p(context, image).isTrue()) { - RubyComplex complex = (RubyComplex)real; - return new RubyComplex(context.getRuntime(), clazz, - complex.real, - f_add(context, complex.image, image)); - } else { - RubyComplex complex1 = (RubyComplex)real; - RubyComplex complex2 = (RubyComplex)image; - return new RubyComplex(context.getRuntime(), clazz, - f_sub(context, complex1.real, complex2.image), - f_add(context, complex1.image, complex2.real)); - } - } - - /** nucomp_s_new - * - */ - @Deprecated - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[]args) { - switch (args.length) { - case 1: return newInstance(context, recv, args[0]); - case 2: return newInstance(context, recv, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 1); - return null; - } - - @JRubyMethod(name = {"new", "rect", "rectangular"}, meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject real) { - realCheck(context, real); - return canonicalizeInternal(context, recv, real, RubyFixnum.zero(context.getRuntime())); - } - - @JRubyMethod(name = {"new", "rect", "rectangular"}, meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject real, IRubyObject image) { - realCheck(context, real); - realCheck(context, image); - return canonicalizeInternal(context, recv, real, image); - } - - /** f_complex_polar - * - */ - private static IRubyObject f_complex_polar(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert !(x instanceof RubyComplex) && !(y instanceof RubyComplex); - return canonicalizeInternal(context, clazz, - f_mul(context, x, m_cos(context, y)), - f_mul(context, x, m_sin(context, y))); - } - - /** nucomp_s_polar - * - */ - @JRubyMethod(name = "polar", meta = true) - public static IRubyObject polar(ThreadContext context, IRubyObject clazz, IRubyObject abs, IRubyObject arg) { - return f_complex_polar(context, clazz, abs, arg); - } - - /** rb_Complex1 - * - */ - public static IRubyObject newComplexConvert(ThreadContext context, IRubyObject x) { - return newComplexConvert(context, x, RubyFixnum.zero(context.getRuntime())); - } - - /** rb_Complex/rb_Complex2 - * - */ - public static IRubyObject newComplexConvert(ThreadContext context, IRubyObject x, IRubyObject y) { - return convert(context, context.getRuntime().getComplex(), x, y); - } - - @Deprecated - public static IRubyObject convert(ThreadContext context, IRubyObject clazz, IRubyObject[]args) { - switch (args.length) { - case 0: return convert(context, clazz); - case 1: return convert(context, clazz, args[0]); - case 2: return convert(context, clazz, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 0, 2); - return null; - } - - /** nucomp_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv) { - IRubyObject nil = context.getRuntime().getNil(); - return convertCommon(context, recv, nil, nil); - } - - /** nucomp_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1) { - return convertCommon(context, recv, a1, context.getRuntime().getNil()); - } - - /** nucomp_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) { - return convertCommon(context, recv, a1, a2); - } - - private static IRubyObject convertCommon(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) { - Frame frame = context.getCurrentFrame(); - IRubyObject backref = frame.getBackRef(); - if (backref != null && backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); - - if (a1 instanceof RubyString) a1 = str_to_c_strict(context, a1); - if (a2 instanceof RubyString) a2 = str_to_c_strict(context, a2); - - frame.setBackRef(backref); - - if (a1 instanceof RubyComplex) { - RubyComplex a1Complex = (RubyComplex)a1; - if (!(a1Complex.image instanceof RubyFloat) && f_zero_p(context, a1Complex.image)) { - a1 = a1Complex.real; - } - } - - if (a2 instanceof RubyComplex) { - RubyComplex a2Complex = (RubyComplex)a2; - if (!(a2Complex.image instanceof RubyFloat) && f_zero_p(context, a2Complex.image)) { - a2 = a2Complex.real; - } - } - - if (a1 instanceof RubyComplex) { - if (a2.isNil() || f_zero_p(context, a2)) return a1; - } - return a2.isNil() ? newInstance(context, recv, a1) : newInstance(context, recv, a1, a2); - } - - /** nucomp_real - * - */ - @JRubyMethod(name = "real") - public IRubyObject real() { - return real; - } - - /** nucomp_image - * - */ - @JRubyMethod(name = {"image", "imag"}) - public IRubyObject image() { - return image; - } - - /** nucomp_add - * - */ - @JRubyMethod(name = "+") - public IRubyObject op_add(ThreadContext context, IRubyObject other) { - if (other instanceof RubyComplex) { - RubyComplex otherComplex = (RubyComplex)other; - return newComplex(context, getMetaClass(), - f_add(context, real, otherComplex.real), - f_add(context, image, otherComplex.image)); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - return newComplex(context, getMetaClass(), f_add(context, real, other), image); - } - return coerceBin(context, "+", other); - } - - /** nucomp_sub - * - */ - @JRubyMethod(name = "-") - public IRubyObject op_sub(ThreadContext context, IRubyObject other) { - if (other instanceof RubyComplex) { - RubyComplex otherComplex = (RubyComplex)other; - return newComplex(context, getMetaClass(), - f_sub(context, real, otherComplex.real), - f_sub(context, image, otherComplex.image)); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - return newComplex(context, getMetaClass(), f_sub(context, real, other), image); - } - return coerceBin(context, "-", other); - } - - /** nucomp_mul - * - */ - @JRubyMethod(name = "*") - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - if (other instanceof RubyComplex) { - RubyComplex otherComplex = (RubyComplex)other; - IRubyObject realp = f_sub(context, - f_mul(context, real, otherComplex.real), - f_mul(context, image, otherComplex.image)); - IRubyObject imagep = f_add(context, - f_mul(context, real, otherComplex.image), - f_mul(context, image, otherComplex.real)); - - return newComplex(context, getMetaClass(), realp, imagep); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - return newComplex(context, getMetaClass(), - f_mul(context, real, other), - f_mul(context, image, other)); - } - return coerceBin(context, "*", other); - } - - /** nucomp_div - * - */ - @JRubyMethod(name = "/") - public IRubyObject op_div(ThreadContext context, IRubyObject other) { - if (other instanceof RubyComplex) { - RubyComplex otherComplex = (RubyComplex)other; - if (real instanceof RubyFloat || image instanceof RubyFloat || - otherComplex.real instanceof RubyFloat || otherComplex.image instanceof RubyFloat) { - IRubyObject magn = RubyMath.hypot(this, otherComplex.real, otherComplex.image); - IRubyObject tmp = newComplexBang(context, getMetaClass(), - f_quo(context, otherComplex.real, magn), - f_quo(context, otherComplex.image, magn)); - return f_quo(context, f_mul(context, this, f_conjugate(context, tmp)), magn); - } - return f_quo(context, f_mul(context, this, f_conjugate(context, other)), f_abs2(context, other)); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - return newComplex(context, getMetaClass(), - f_quo(context, real, other), - f_quo(context, image, other)); - } - return coerceBin(context, "/", other); - } - - /** nucomp_fdiv / nucomp_quo - * - */ - @JRubyMethod(name = {"fdiv", "quo"}) - public IRubyObject fdiv(ThreadContext context, IRubyObject other) { - IRubyObject complex = newComplex(context, getMetaClass(), - f_to_f(context, real), - f_to_f(context, image)); - - return f_div(context, complex, other); - } - - /** nucomp_expt - * - */ - @JRubyMethod(name = "**") - public IRubyObject op_expt(ThreadContext context, IRubyObject other) { - if (f_zero_p(context, other)) { - return newComplexBang(context, getMetaClass(), RubyFixnum.one(context.getRuntime())); - } else if (other instanceof RubyRational && f_one_p(context, f_denominator(context, other))) { - other = f_numerator(context, other); - } - - if (other instanceof RubyComplex) { - RubyArray a = f_polar(context, this).convertToArray(); - IRubyObject r = a.eltInternal(0); - IRubyObject theta = a.eltInternal(1); - RubyComplex otherComplex = (RubyComplex)other; - IRubyObject nr = RubyMath.exp(this, f_sub(context, - f_mul(context, otherComplex.real, RubyMath.log(this, r)), - f_mul(context, otherComplex.image, theta))); - IRubyObject ntheta = f_add(context, - f_mul(context, theta, otherComplex.real), - f_mul(context, otherComplex.image, RubyMath.log(this, r))); - return polar(context, getMetaClass(), nr, ntheta); - } else if (other instanceof RubyInteger) { - IRubyObject one = RubyFixnum.one(context.getRuntime()); - if (f_gt_p(context, other, RubyFixnum.zero(context.getRuntime())).isTrue()) { - IRubyObject x = this; - IRubyObject z = x; - IRubyObject n = f_sub(context, other, one); - - IRubyObject two = RubyFixnum.two(context.getRuntime()); - - while (!f_zero_p(context, n)) { - - RubyArray a = f_divmod(context, n, two).convertToArray(); - - while (f_zero_p(context, a.eltInternal(1))) { - RubyComplex xComplex = (RubyComplex)x; - x = newComplex(context, getMetaClass(), - f_sub(context, f_mul(context, xComplex.real, xComplex.real), - f_mul(context, xComplex.image, xComplex.image)), - f_mul(context, f_mul(context, two, xComplex.real), xComplex.image)); - - n = a.eltInternal(0); - a = f_divmod(context, n, two).convertToArray(); - } - z = f_mul(context, z, x); - n = f_sub(context, n, one); - } - return z; - } - return f_expt(context, f_div(context, f_to_r(context, one), this), f_negate(context, other)); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - RubyArray a = f_polar(context, this).convertToArray(); - IRubyObject r = a.eltInternal(0); - IRubyObject theta = a.eltInternal(1); - return f_complex_polar(context, getMetaClass(), f_expt(context, r, other), f_mul(context, theta, other)); - } - return coerceBin(context, "**", other); - } - - /** nucomp_equal_p - * - */ - @JRubyMethod(name = "==") - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if (other instanceof RubyComplex) { - RubyComplex otherComplex = (RubyComplex)other; - if (f_equal_p(context, real, otherComplex.real) && f_equal_p(context, image, otherComplex.image)) return context.getRuntime().getTrue(); - return context.getRuntime().getFalse(); - } else if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - if (f_equal_p(context, real, other) && f_zero_p(context, image)) return context.getRuntime().getTrue(); - return context.getRuntime().getFalse(); - } - return f_equal_p(context, other, this) ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - /** nucomp_coerce - * - */ - @JRubyMethod(name = "coerce") - public IRubyObject coerce(ThreadContext context, IRubyObject other) { - if (other instanceof RubyNumeric && f_scalar_p(context, other).isTrue()) { - return context.getRuntime().newArray(newComplexBang(context, getMetaClass(), other), this); - } - throw context.getRuntime().newTypeError(other.getMetaClass().getName() + " can't be coerced into " + getMetaClass().getName()); - } - - /** nucomp_abs - * - */ - @JRubyMethod(name = {"abs", "magnitude"}) - public IRubyObject abs(ThreadContext context) { - return RubyMath.hypot(this, real, image); - } - - /** nucomp_abs2 - * - */ - @JRubyMethod(name = "abs2") - public IRubyObject abs2(ThreadContext context) { - return f_add(context, - f_mul(context, real, real), - f_mul(context, image, image)); - } - - /** nucomp_arg - * - */ - @JRubyMethod(name = {"arg", "angle"}) - public IRubyObject arg(ThreadContext context) { - return RubyMath.atan2(this, image, real); - } - - /** nucomp_polar - * - */ - @JRubyMethod(name = "polar") - public IRubyObject polar(ThreadContext context) { - return context.getRuntime().newArray(f_abs(context, this), f_arg(context, this)); - } - - /** nucomp_conjugate - * - */ - @JRubyMethod(name = {"conjugate", "conj", "~"}) - public IRubyObject conjugate(ThreadContext context) { - return newComplex(context, getMetaClass(), real, f_negate(context, image)); - } - - /** nucomp_real_p - * - */ - //@JRubyMethod(name = "real?") - public IRubyObject real_p(ThreadContext context) { - return context.getRuntime().getFalse(); - } - - /** nucomp_complex_p - * - */ - // @JRubyMethod(name = "complex?") - public IRubyObject complex_p(ThreadContext context) { - return context.getRuntime().getTrue(); - } - - /** nucomp_exact_p - * - */ - // @JRubyMethod(name = "exact?") - public IRubyObject exact_p(ThreadContext context) { - return (f_exact_p(context, real).isTrue() && f_exact_p(context, image).isTrue()) ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - /** nucomp_exact_p - * - */ - // @JRubyMethod(name = "inexact?") - public IRubyObject inexact_p(ThreadContext context) { - return exact_p(context).isTrue() ? context.getRuntime().getFalse() : context.getRuntime().getTrue(); - } - - /** nucomp_denominator - * - */ - @JRubyMethod(name = "denominator") - public IRubyObject demoninator(ThreadContext context) { - return f_lcm(context, f_denominator(context, real), f_denominator(context, image)); - } - - /** nucomp_numerator - * - */ - @JRubyMethod(name = "numerator") - public IRubyObject numerator(ThreadContext context) { - IRubyObject cd = callMethod(context, "denominator"); - return newComplex(context, getMetaClass(), - f_mul(context, - f_numerator(context, real), - f_div(context, cd, f_denominator(context, real))), - f_mul(context, - f_numerator(context, image), - f_div(context, cd, f_denominator(context, image)))); - } - - /** nucomp_hash - * - */ - @JRubyMethod(name = "hash") - public IRubyObject hash(ThreadContext context) { - return f_xor(context, real, image); - } - - /** f_signbit - * - */ - private static boolean signbit(ThreadContext context, IRubyObject x) { - if (x instanceof RubyFloat) { - return Double.doubleToLongBits(((RubyFloat)x).getDoubleValue()) < 0; - } - return f_negative_p(context, x); - } - - /** f_tpositive_p - * - */ - private static boolean tpositive_p(ThreadContext context, IRubyObject x) { - return !signbit(context, x); - } - - /** nucomp_to_s - * - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s(ThreadContext context) { - boolean impos = tpositive_p(context, image); - - RubyString str = f_to_s(context, real).convertToString(); - str.cat(impos ? (byte)'+' : (byte)'-'); - str.cat(f_to_s(context, f_abs(context, image)).convertToString().getByteList()); - str.cat((byte)'i'); - return str; - } - - /** nucomp_inspect - * - */ - @JRubyMethod(name = "inspect") - public IRubyObject inspect(ThreadContext context) { - boolean impos = tpositive_p(context, image); - RubyString str = context.getRuntime().newString(); - str.cat((byte)'('); - str.cat(f_inspect(context, real).convertToString().getByteList()); - str.cat(impos ? (byte)'+' : (byte)'-'); - str.cat(f_inspect(context, f_abs(context, image)).convertToString().getByteList()); - str.cat((byte)'i'); - str.cat((byte)')'); - return str; - } - - /** nucomp_marshal_dump - * - */ - @JRubyMethod(name = "marshal_dump") - public IRubyObject marshal_dump(ThreadContext context) { - return context.getRuntime().newArray(real, image); - } - - /** nucomp_marshal_load - * - */ - @JRubyMethod(name = "marshal_load") - public IRubyObject marshal_load(ThreadContext context, IRubyObject arg) { - RubyArray a = arg.convertToArray(); - real = a.size() > 0 ? a.eltInternal(0) : context.getRuntime().getNil(); - image = a.size() > 1 ? a.eltInternal(1) : context.getRuntime().getNil(); - return this; - } - - /** nucomp_scalar_p - * - */ - @JRubyMethod(name = "scalar?") - public IRubyObject scalar_p(ThreadContext context) { - return context.getRuntime().getFalse(); - } - - /** nucomp_to_i - * - */ - @JRubyMethod(name = "to_i") - public IRubyObject to_i(ThreadContext context) { - if (image instanceof RubyFloat || !f_zero_p(context, image)) { - throw context.getRuntime().newRangeError("can't convert " + f_to_s(context, this).convertToString() + " into Integer"); - } - return f_to_i(context, real); - } - - /** nucomp_to_f - * - */ - @JRubyMethod(name = "to_f") - public IRubyObject to_f(ThreadContext context) { - if (image instanceof RubyFloat || !f_zero_p(context, image)) { - throw context.getRuntime().newRangeError("can't convert " + f_to_s(context, this).convertToString() + " into Float"); - } - return f_to_f(context, real); - } - - /** nucomp_to_f - * - */ - @JRubyMethod(name = "to_r") - public IRubyObject to_r(ThreadContext context) { - if (image instanceof RubyFloat || !f_zero_p(context, image)) { - throw context.getRuntime().newRangeError("can't convert " + f_to_s(context, this).convertToString() + " into Rational"); - } - return f_to_r(context, real); - } - - static RubyArray str_to_c_internal(ThreadContext context, IRubyObject recv) { - RubyString s = recv.callMethod(context, "strip").convertToString(); - ByteList bytes = s.getByteList(); - - Ruby runtime = context.getRuntime(); - if (bytes.realSize == 0) return runtime.newArray(runtime.getNil(), recv); - - IRubyObject sr, si, re; - sr = si = re = runtime.getNil(); - boolean po = false; - IRubyObject m = RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.comp_pat0).callMethod(context, "match", s); - - if (!m.isNil()) { - sr = m.callMethod(context, "[]", RubyFixnum.one(runtime)); - si = m.callMethod(context, "[]", RubyFixnum.two(runtime)); - re = m.callMethod(context, "post_match"); - po = true; - } - - if (m.isNil()) { - m = RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.comp_pat1).callMethod(context, "match", s); - - if (!m.isNil()) { - sr = runtime.getNil(); - si = m.callMethod(context, "[]", RubyFixnum.one(runtime)); - if (si.isNil()) si = runtime.newString(); - IRubyObject t = m.callMethod(context, "[]", RubyFixnum.two(runtime)); - if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'})); - si.convertToString().cat(t.convertToString().getByteList()); - re = m.callMethod(context, "post_match"); - po = false; - } - } - - if (m.isNil()) { - m = RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.comp_pat2).callMethod(context, "match", s); - if (m.isNil()) return runtime.newArray(runtime.getNil(), recv); - sr = m.callMethod(context, "[]", RubyFixnum.one(runtime)); - if (m.callMethod(context, "[]", RubyFixnum.two(runtime)).isNil()) { - si = runtime.getNil(); - } else { - si = m.callMethod(context, "[]", RubyFixnum.three(runtime)); - IRubyObject t = m.callMethod(context, "[]", RubyFixnum.four(runtime)); - if (t.isNil()) t = runtime.newString(new ByteList(new byte[]{'1'})); - si.convertToString().cat(t.convertToString().getByteList()); - } - re = m.callMethod(context, "post_match"); - po = false; - } - - IRubyObject r = RubyFixnum.zero(runtime); - IRubyObject i = r; - - if (!sr.isNil()) { - if (sr.callMethod(context, "include?", runtime.newString(new ByteList(new byte[]{'/'}))).isTrue()) { - r = f_to_r(context, sr); - } else if (f_gt_p(context, sr.callMethod(context, "count", runtime.newString(".eE")), RubyFixnum.zero(runtime)).isTrue()) { - r = f_to_f(context, sr); - } else { - r = f_to_i(context, sr); - } - } - - if (!si.isNil()) { - if (si.callMethod(context, "include?", runtime.newString(new ByteList(new byte[]{'/'}))).isTrue()) { - i = f_to_r(context, si); - } else if (f_gt_p(context, si.callMethod(context, "count", runtime.newString(".eE")), RubyFixnum.zero(runtime)).isTrue()) { - i = f_to_f(context, si); - } else { - i = f_to_i(context, si); - } - } - return runtime.newArray(po ? newComplexPolar(context, r, i) : newComplexCanonicalize(context, r, i), re); - } - - private static IRubyObject str_to_c_strict(ThreadContext context, IRubyObject recv) { - RubyArray a = str_to_c_internal(context, recv); - if (a.eltInternal(0).isNil() || a.eltInternal(1).convertToString().getByteList().length() > 0) { - IRubyObject s = recv.callMethod(context, "inspect"); - throw context.getRuntime().newArgumentError("invalid value for Complex: " + s.convertToString()); - } - return a.eltInternal(0); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Block; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * Placeholder until/if we can support this - * - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -@JRubyClass(name="Continuation") -public class RubyContinuation { - public static void createContinuation(Ruby runtime) { - RubyClass cContinuation = runtime.defineClass("Continuation",runtime.getObject(),runtime.getObject().getAllocator()); - cContinuation.defineAnnotatedMethods(RubyContinuation.class); - runtime.setContinuation(cContinuation); - } - - @JRubyMethod(name = {"call", "[]"}, rest = true, frame = true) - public static IRubyObject call(IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - throw recv.getRuntime().newNotImplementedError("Continuations are not implemented in JRuby and will not work"); - } -}// RubyContinuation -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006, 2007 Ola Bini <ola@ologix.com> - * Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com> - * Copyright (C) 2008 Vladimir Sizikov <vsizikov@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.security.Provider; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.anno.JRubyClass; - -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.callback.Callback; -import org.jruby.util.ByteList; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -@JRubyModule(name="Digest") -public class RubyDigest { - private static Provider provider = null; - - public static void createDigest(Ruby runtime) { - try { - provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch(Exception e) { - // provider is not available - } - - RubyModule mDigest = runtime.defineModule("Digest"); - RubyClass cDigestBase = mDigest.defineClassUnder("Base",runtime.getObject(), Base.BASE_ALLOCATOR); - - cDigestBase.defineAnnotatedMethods(Base.class); - } - - private static MessageDigest createMessageDigest(Ruby runtime, String providerName) throws NoSuchAlgorithmException { - if(provider != null) { - try { - return MessageDigest.getInstance(providerName, provider); - } catch(NoSuchAlgorithmException e) { - // bouncy castle doesn't support algorithm - } - } - // fall back to system JCA providers - return MessageDigest.getInstance(providerName); - } - - @JRubyClass(name="Digest::MD5", parent="Digest::Base") - public static class MD5 {} - @JRubyClass(name="Digest::RMD160", parent="Digest::Base") - public static class RMD160 {} - @JRubyClass(name="Digest::SHA1", parent="Digest::Base") - public static class SHA1 {} - @JRubyClass(name="Digest::SHA256", parent="Digest::Base") - public static class SHA256 {} - @JRubyClass(name="Digest::SHA384", parent="Digest::Base") - public static class SHA384 {} - @JRubyClass(name="Digest::SHA512", parent="Digest::Base") - public static class SHA512 {} - - public static void createDigestMD5(Ruby runtime) { - runtime.getLoadService().require("digest.so"); - RubyModule mDigest = runtime.fastGetModule("Digest"); - RubyClass cDigestBase = mDigest.fastGetClass("Base"); - RubyClass cDigest_MD5 = mDigest.defineClassUnder("MD5",cDigestBase,cDigestBase.getAllocator()); - cDigest_MD5.defineFastMethod("block_length", new Callback() { - public Arity getArity() { - return Arity.NO_ARGUMENTS; - } - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) { - return RubyFixnum.newFixnum(recv.getRuntime(), 64); - } - }); - cDigest_MD5.setInternalModuleVariable("metadata",runtime.newString("MD5")); - } - - public static void createDigestRMD160(Ruby runtime) { - runtime.getLoadService().require("digest.so"); - if(provider == null) { - throw runtime.newLoadError("RMD160 not supported without BouncyCastle"); - } - - RubyModule mDigest = runtime.fastGetModule("Digest"); - RubyClass cDigestBase = mDigest.fastGetClass("Base"); - RubyClass cDigest_RMD160 = mDigest.defineClassUnder("RMD160",cDigestBase,cDigestBase.getAllocator()); - cDigest_RMD160.setInternalModuleVariable("metadata",runtime.newString("RIPEMD160")); - } - - public static void createDigestSHA1(Ruby runtime) { - runtime.getLoadService().require("digest.so"); - RubyModule mDigest = runtime.fastGetModule("Digest"); - RubyClass cDigestBase = mDigest.fastGetClass("Base"); - RubyClass cDigest_SHA1 = mDigest.defineClassUnder("SHA1",cDigestBase,cDigestBase.getAllocator()); - cDigest_SHA1.setInternalModuleVariable("metadata",runtime.newString("SHA1")); - } - - public static void createDigestSHA2(Ruby runtime) { - runtime.getLoadService().require("digest.so"); - try { - createMessageDigest(runtime, "SHA-256"); - } catch(NoSuchAlgorithmException e) { - throw runtime.newLoadError("SHA2 not supported"); - } - - RubyModule mDigest = runtime.fastGetModule("Digest"); - RubyClass cDigestBase = mDigest.fastGetClass("Base"); - RubyClass cDigest_SHA2_256 = mDigest.defineClassUnder("SHA256",cDigestBase,cDigestBase.getAllocator()); - cDigest_SHA2_256.setInternalModuleVariable("metadata",runtime.newString("SHA-256")); - RubyClass cDigest_SHA2_384 = mDigest.defineClassUnder("SHA384",cDigestBase,cDigestBase.getAllocator()); - cDigest_SHA2_384.setInternalModuleVariable("metadata",runtime.newString("SHA-384")); - RubyClass cDigest_SHA2_512 = mDigest.defineClassUnder("SHA512",cDigestBase,cDigestBase.getAllocator()); - cDigest_SHA2_512.setInternalModuleVariable("metadata",runtime.newString("SHA-512")); - } - - @JRubyClass(name="Digest::Base") - public static class Base extends RubyObject { - protected static final ObjectAllocator BASE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Base(runtime, klass); - } - }; - - @JRubyMethod(name = "digest", required = 1, meta = true) - public static IRubyObject s_digest(IRubyObject recv, IRubyObject str) { - Ruby runtime = recv.getRuntime(); - String name = ((RubyClass)recv).searchInternalModuleVariable("metadata").toString(); - try { - MessageDigest md = createMessageDigest(runtime, name); - return RubyString.newString(runtime, md.digest(str.convertToString().getBytes())); - } catch(NoSuchAlgorithmException e) { - throw recv.getRuntime().newNotImplementedError("Unsupported digest algorithm (" + name + ")"); - } - } - - @JRubyMethod(name = "hexdigest", required = 1, meta = true) - public static IRubyObject s_hexdigest(IRubyObject recv, IRubyObject str) { - Ruby runtime = recv.getRuntime(); - String name = ((RubyClass)recv).searchInternalModuleVariable("metadata").toString(); - try { - MessageDigest md = createMessageDigest(runtime, name); - return RubyString.newString(runtime, ByteList.plain(toHex(md.digest(str.convertToString().getBytes())))); - } catch(NoSuchAlgorithmException e) { - throw recv.getRuntime().newNotImplementedError("Unsupported digest algorithm (" + name + ")"); - } - } - - private MessageDigest algo; - private StringBuffer data; - - public Base(Ruby runtime, RubyClass type) { - super(runtime,type); - data = new StringBuffer(); - - if(type == runtime.fastGetModule("Digest").fastGetClass("Base")) { - throw runtime.newNotImplementedError("Digest::Base is an abstract class"); - } - if(!type.hasInternalModuleVariable("metadata")) { - throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); - } - try { - setAlgorithm(type.searchInternalModuleVariable("metadata")); - } catch(NoSuchAlgorithmException e) { - throw runtime.newNotImplementedError("the " + type + "() function is unimplemented on this machine"); - } - - } - - @JRubyMethod(name = "initialize", optional = 1, frame = true) - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - if(args.length > 0 && !args[0].isNil()) { - update(args[0]); - } - return this; - } - - @JRubyMethod(name = "initialize_copy", required = 1) - public IRubyObject initialize_copy(IRubyObject obj) { - if(this == obj) { - return this; - } - ((RubyObject)obj).checkFrozen(); - - data = new StringBuffer(((Base)obj).data.toString()); - String name = ((Base)obj).algo.getAlgorithm(); - try { - algo = createMessageDigest(getRuntime(), name); - } catch(NoSuchAlgorithmException e) { - throw getRuntime().newNotImplementedError("Unsupported digest algorithm (" + name + ")"); - } - return this; - } - - @JRubyMethod(name = {"update", "<<"}, required = 1) - public IRubyObject update(IRubyObject obj) { - data.append(obj); - return this; - } - - @JRubyMethod(name = "digest", optional = 1) - public IRubyObject digest(IRubyObject[] args) { - if (args.length == 1) { - reset(); - data.append(args[0]); - } - - IRubyObject digest = getDigest(); - - if (args.length == 1) { - reset(); - } - return digest; - } - - private IRubyObject getDigest() { - algo.reset(); - return RubyString.newString(getRuntime(), algo.digest(ByteList.plain(data))); - } - - @JRubyMethod(name = "digest!") - public IRubyObject digest_bang() { - algo.reset(); - byte[] digest = algo.digest(ByteList.plain(data)); - reset(); - return RubyString.newString(getRuntime(), digest); - } - - @JRubyMethod(name = {"hexdigest"}, optional = 1) - public IRubyObject hexdigest(IRubyObject[] args) { - algo.reset(); - if (args.length == 1) { - reset(); - data.append(args[0]); - } - - byte[] digest = ByteList.plain(toHex(algo.digest(ByteList.plain(data)))); - - if (args.length == 1) { - reset(); - } - return RubyString.newString(getRuntime(), digest); - } - - @JRubyMethod(name = {"to_s"}) - public IRubyObject to_s() { - algo.reset(); - return RubyString.newString(getRuntime(), ByteList.plain(toHex(algo.digest(ByteList.plain(data))))); - } - - @JRubyMethod(name = {"hexdigest!"}) - public IRubyObject hexdigest_bang() { - algo.reset(); - byte[] digest = ByteList.plain(toHex(algo.digest(ByteList.plain(data)))); - reset(); - return RubyString.newString(getRuntime(), digest); - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - algo.reset(); - return RubyString.newString(getRuntime(), ByteList.plain("#<" + getMetaClass().getRealClass().getName() + ": " + toHex(algo.digest(ByteList.plain(data))) + ">")); - } - - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(IRubyObject oth) { - boolean ret = this == oth; - if(!ret) { - if (oth instanceof Base) { - Base b = (Base)oth; - ret = this.algo.getAlgorithm().equals(b.algo.getAlgorithm()) && - this.getDigest().equals(b.getDigest()); - } else { - IRubyObject str = oth.convertToString(); - ret = this.to_s().equals(str); - } - } - - return ret ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = {"length", "size", "digest_length"}) - public IRubyObject length() { - return RubyFixnum.newFixnum(getRuntime(), algo.getDigestLength()); - } - - @JRubyMethod(name = {"block_length"}) - public IRubyObject block_length() { - throw getRuntime().newRuntimeError( - this.getMetaClass() + " doesn't implement block_length()"); - } - - @JRubyMethod(name = {"reset"}) - public IRubyObject reset() { - algo.reset(); - data = new StringBuffer(); - return getRuntime().getNil(); - } - - private void setAlgorithm(IRubyObject algo) throws NoSuchAlgorithmException { - this.algo = createMessageDigest(getRuntime(), algo.toString()); - } - - private static String toHex(byte[] val) { - StringBuilder out = new StringBuilder(); - for(int i=0,j=val.length;i<j;i++) { - String ve = Integer.toString((((int)((char)val[i])) & 0xFF),16); - if(ve.length() == 1) { - ve = "0" + ve; - } - out.append(ve); - } - return out.toString(); - } - } -}// RubyDigest -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.ext.posix.util.Platform; - -import org.jruby.javasupport.JavaUtil; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.Dir; -import org.jruby.util.JRubyFile; -import org.jruby.util.ByteList; - -/** - * .The Ruby built-in class Dir. - * - * @author jvoegele - */ -@JRubyClass(name="Dir", include="Enumerable") -public class RubyDir extends RubyObject { - // What we passed to the constructor for method 'path' - private RubyString path; - protected JRubyFile dir; - private String[] snapshot; // snapshot of contents of directory - private int pos; // current position in directory - private boolean isOpen = true; - - public RubyDir(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private static final ObjectAllocator DIR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyDir(runtime, klass); - } - }; - - public static RubyClass createDirClass(Ruby runtime) { - RubyClass dirClass = runtime.defineClass("Dir", runtime.getObject(), DIR_ALLOCATOR); - runtime.setDir(dirClass); - - dirClass.includeModule(runtime.getEnumerable()); - - dirClass.defineAnnotatedMethods(RubyDir.class); - - return dirClass; - } - - private final void checkDir() { - if (!isTaint() && getRuntime().getSafeLevel() >= 4) throw getRuntime().newSecurityError("Insecure: operation on untainted Dir"); - - testFrozen(""); - - if (!isOpen) throw getRuntime().newIOError("closed directory"); - } - - /** - * Creates a new <code>Dir</code>. This method takes a snapshot of the - * contents of the directory at creation time, so changes to the contents - * of the directory will not be reflected during the lifetime of the - * <code>Dir</code> object returned, so a new <code>Dir</code> instance - * must be created to reflect changes to the underlying file system. - */ - @JRubyMethod(name = "initialize", required = 1, frame = true) - public IRubyObject initialize(IRubyObject _newPath, Block unusedBlock) { - RubyString newPath = _newPath.convertToString(); - getRuntime().checkSafeString(newPath); - - String adjustedPath = RubyFile.adjustRootPathOnWindows(getRuntime(), newPath.toString(), null); - checkDirIsTwoSlashesOnWindows(getRuntime(), adjustedPath); - - dir = JRubyFile.create(getRuntime().getCurrentDirectory(), adjustedPath); - if (!dir.isDirectory()) { - dir = null; - throw getRuntime().newErrnoENOENTError(newPath.toString() + " is not a directory"); - } - path = newPath; - List<String> snapshotList = new ArrayList<String>(); - snapshotList.add("."); - snapshotList.add(".."); - snapshotList.addAll(getContents(dir)); - snapshot = (String[]) snapshotList.toArray(new String[snapshotList.size()]); - pos = 0; - - return this; - } - -// ----- Ruby Class Methods ---------------------------------------------------- - - private static List<ByteList> dirGlobs(String cwd, IRubyObject[] args, int flags) { - List<ByteList> dirs = new ArrayList<ByteList>(); - - for (int i = 0; i < args.length; i++) { - ByteList globPattern = args[i].convertToString().getByteList(); - dirs.addAll(Dir.push_glob(cwd, globPattern, flags)); - } - - return dirs; - } - - private static IRubyObject asRubyStringList(Ruby runtime, List<ByteList> dirs) { - List<RubyString> allFiles = new ArrayList<RubyString>(); - - for (ByteList dir: dirs) { - allFiles.add(RubyString.newString(runtime, dir)); - } - - IRubyObject[] tempFileList = new IRubyObject[allFiles.size()]; - allFiles.toArray(tempFileList); - - return runtime.newArrayNoCopy(tempFileList); - } - - private static String getCWD(Ruby runtime) { - try { - return new org.jruby.util.NormalizedFile(runtime.getCurrentDirectory()).getCanonicalPath(); - } catch(Exception e) { - return runtime.getCurrentDirectory(); - } - } - - @JRubyMethod(name = "[]", required = 1, rest=true, meta = true) - public static IRubyObject aref(IRubyObject recv, IRubyObject[] args) { - List<ByteList> dirs; - if (args.length == 1) { - ByteList globPattern = args[0].convertToString().getByteList(); - dirs = Dir.push_glob(getCWD(recv.getRuntime()), globPattern, 0); - } else { - dirs = dirGlobs(getCWD(recv.getRuntime()), args, 0); - } - - return asRubyStringList(recv.getRuntime(), dirs); - } - - /** - * Returns an array of filenames matching the specified wildcard pattern - * <code>pat</code>. If a block is given, the array is iterated internally - * with each filename is passed to the block in turn. In this case, Nil is - * returned. - */ - @JRubyMethod(name = "glob", required = 1, optional = 1, frame = true, meta = true) - public static IRubyObject glob(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = recv.getRuntime(); - int flags = args.length == 2 ? RubyNumeric.num2int(args[1]) : 0; - - List<ByteList> dirs; - IRubyObject tmp = args[0].checkArrayType(); - if (tmp.isNil()) { - ByteList globPattern = args[0].convertToString().getByteList(); - dirs = Dir.push_glob(recv.getRuntime().getCurrentDirectory(), globPattern, flags); - } else { - dirs = dirGlobs(getCWD(runtime), ((RubyArray) tmp).toJavaArray(), flags); - } - - if (block.isGiven()) { - for (int i = 0; i < dirs.size(); i++) { - block.yield(context, RubyString.newString(runtime, dirs.get(i))); - } - - return recv.getRuntime().getNil(); - } - - return asRubyStringList(recv.getRuntime(), dirs); - } - - /** - * @return all entries for this Dir - */ - @JRubyMethod(name = "entries") - public RubyArray entries() { - return getRuntime().newArrayNoCopy(JavaUtil.convertJavaArrayToRuby(getRuntime(), snapshot)); - } - - /** - * Returns an array containing all of the filenames in the given directory. - */ - @JRubyMethod(name = "entries", required = 1, meta = true) - public static RubyArray entries(IRubyObject recv, IRubyObject path) { - Ruby runtime = recv.getRuntime(); - - String adjustedPath = RubyFile.adjustRootPathOnWindows( - runtime, path.convertToString().toString(), null); - checkDirIsTwoSlashesOnWindows(runtime, adjustedPath); - - final JRubyFile directory = JRubyFile.create( - recv.getRuntime().getCurrentDirectory(), adjustedPath); - - if (!directory.isDirectory()) { - throw recv.getRuntime().newErrnoENOENTError("No such directory"); - } - List<String> fileList = getContents(directory); - fileList.add(0, "."); - fileList.add(1, ".."); - Object[] files = fileList.toArray(); - return recv.getRuntime().newArrayNoCopy(JavaUtil.convertJavaArrayToRuby(recv.getRuntime(), files)); - } - - // MRI behavior: just plain '//' or '\\\\' are considered illegal on Windows. - private static void checkDirIsTwoSlashesOnWindows(Ruby runtime, String path) { - if (Platform.IS_WINDOWS && ("//".equals(path) || "\\\\".equals(path))) { - throw runtime.newErrnoEINVALError("Invalid argument - " + path); - } - } - - /** Changes the current directory to <code>path</code> */ - @JRubyMethod(name = "chdir", optional = 1, frame = true, meta = true) - public static IRubyObject chdir(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyString path = args.length == 1 ? - (RubyString) args[0].convertToString() : getHomeDirectoryPath(context); - String adjustedPath = RubyFile.adjustRootPathOnWindows( - recv.getRuntime(), path.toString(), null); - checkDirIsTwoSlashesOnWindows(recv.getRuntime(), adjustedPath); - JRubyFile dir = getDir(recv.getRuntime(), adjustedPath, true); - String realPath = null; - String oldCwd = recv.getRuntime().getCurrentDirectory(); - - // We get canonical path to try and flatten the path out. - // a dir '/subdir/..' should return as '/' - // cnutter: Do we want to flatten path out? - try { - realPath = dir.getCanonicalPath(); - } catch (IOException e) { - realPath = dir.getAbsolutePath(); - } - - IRubyObject result = null; - if (block.isGiven()) { - // FIXME: Don't allow multiple threads to do this at once - recv.getRuntime().setCurrentDirectory(realPath); - try { - result = block.yield(context, path); - } finally { - dir = getDir(recv.getRuntime(), oldCwd, true); - recv.getRuntime().setCurrentDirectory(oldCwd); - } - } else { - recv.getRuntime().setCurrentDirectory(realPath); - result = recv.getRuntime().newFixnum(0); - } - - return result; - } - - /** - * Changes the root directory (only allowed by super user). Not available - * on all platforms. - */ - @JRubyMethod(name = "chroot", required = 1, meta = true) - public static IRubyObject chroot(IRubyObject recv, IRubyObject path) { - throw recv.getRuntime().newNotImplementedError("chroot not implemented: chroot is non-portable and is not supported."); - } - - /** - * Deletes the directory specified by <code>path</code>. The directory must - * be empty. - */ - @JRubyMethod(name = {"rmdir", "unlink", "delete"}, required = 1, meta = true) - public static IRubyObject rmdir(IRubyObject recv, IRubyObject path) { - JRubyFile directory = getDir(recv.getRuntime(), path.convertToString().toString(), true); - - if (!directory.delete()) { - throw recv.getRuntime().newSystemCallError("No such directory"); - } - - return recv.getRuntime().newFixnum(0); - } - - /** - * Executes the block once for each file in the directory specified by - * <code>path</code>. - */ - @JRubyMethod(name = "foreach", required = 1, frame = true, meta = true) - public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject _path, Block block) { - RubyString path = _path.convertToString(); - recv.getRuntime().checkSafeString(path); - - RubyClass dirClass = recv.getRuntime().getDir(); - RubyDir dir = (RubyDir) dirClass.newInstance(context, new IRubyObject[] { path }, block); - - dir.each(context, block); - return recv.getRuntime().getNil(); - } - - /** Returns the current directory. */ - @JRubyMethod(name = {"getwd", "pwd"}, meta = true) - public static RubyString getwd(IRubyObject recv) { - Ruby ruby = recv.getRuntime(); - - return RubyString.newUnicodeString(ruby, ruby.getCurrentDirectory()); - } - - /** - * Creates the directory specified by <code>path</code>. Note that the - * <code>mode</code> parameter is provided only to support existing Ruby - * code, and is ignored. - */ - @JRubyMethod(name = "mkdir", required = 1, optional = 1, meta = true) - public static IRubyObject mkdir(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - runtime.checkSafeString(args[0]); - String path = args[0].toString(); - - File newDir = getDir(runtime, path, false); - if (File.separatorChar == '\\') { - newDir = new File(newDir.getPath()); - } - - int mode = args.length == 2 ? ((int) args[1].convertToInteger().getLongValue()) : 0777; - - if (runtime.getPosix().mkdir(newDir.getAbsolutePath(), mode) < 0) { - // FIXME: This is a system error based on errno - throw recv.getRuntime().newSystemCallError("mkdir failed"); - } - - return RubyFixnum.zero(recv.getRuntime()); - } - - /** - * Returns a new directory object for <code>path</code>. If a block is - * provided, a new directory object is passed to the block, which closes the - * directory object before terminating. - */ - @JRubyMethod(name = "open", required = 1, frame = true, meta = true) - public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject path, Block block) { - RubyDir directory = - (RubyDir) recv.getRuntime().getDir().newInstance(context, - new IRubyObject[] { path }, Block.NULL_BLOCK); - - if (!block.isGiven()) return directory; - - try { - return block.yield(context, directory); - } finally { - directory.close(); - } - } - -// ----- Ruby Instance Methods ------------------------------------------------- - - /** - * Closes the directory stream. - */ - @JRubyMethod(name = "close") - public IRubyObject close() { - // Make sure any read()s after close fail. - checkDir(); - - isOpen = false; - - return getRuntime().getNil(); - } - - /** - * Executes the block once for each entry in the directory. - */ - @JRubyMethod(name = "each", frame = true) - public IRubyObject each(ThreadContext context, Block block) { - checkDir(); - - String[] contents = snapshot; - for (int i=0; i<contents.length; i++) { - block.yield(context, getRuntime().newString(contents[i])); - } - return this; - } - - /** - * Returns the current position in the directory. - */ - @JRubyMethod(name = {"tell", "pos"}) - public RubyInteger tell() { - checkDir(); - return getRuntime().newFixnum(pos); - } - - /** - * Moves to a position <code>d</code>. <code>pos</code> must be a value - * returned by <code>tell</code> or 0. - */ - @JRubyMethod(name = "seek", required = 1) - public IRubyObject seek(IRubyObject newPos) { - checkDir(); - - set_pos(newPos); - return this; - } - - @JRubyMethod(name = "pos=", required = 1) - public IRubyObject set_pos(IRubyObject newPos) { - this.pos = RubyNumeric.fix2int(newPos); - return newPos; - } - - @JRubyMethod(name = "path") - public IRubyObject path(ThreadContext context) { - checkDir(); - - return path.strDup(context.getRuntime()); - } - - /** Returns the next entry from this directory. */ - @JRubyMethod(name = "read") - public IRubyObject read() { - checkDir(); - - if (pos >= snapshot.length) { - return getRuntime().getNil(); - } - RubyString result = getRuntime().newString(snapshot[pos]); - pos++; - return result; - } - - /** Moves position in this directory to the first entry. */ - @JRubyMethod(name = "rewind") - public IRubyObject rewind() { - if (!isTaint() && getRuntime().getSafeLevel() >= 4) throw getRuntime().newSecurityError("Insecure: can't close"); - checkDir(); - - pos = 0; - return this; - } - -// ----- Helper Methods -------------------------------------------------------- - - /** Returns a Java <code>File</code> object for the specified path. If - * <code>path</code> is not a directory, throws <code>IOError</code>. - * - * @param path path for which to return the <code>File</code> object. - * @param mustExist is true the directory must exist. If false it must not. - * @throws IOError if <code>path</code> is not a directory. - */ - protected static JRubyFile getDir(final Ruby runtime, final String path, final boolean mustExist) { - JRubyFile result = JRubyFile.create(runtime.getCurrentDirectory(),path); - if (mustExist && !result.exists()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + path); - } - boolean isDirectory = result.isDirectory(); - - if (mustExist && !isDirectory) { - throw runtime.newErrnoENOTDIRError(path + " is not a directory"); - } else if (!mustExist && isDirectory) { - throw runtime.newErrnoEEXISTError("File exists - " + path); - } - - return result; - } - - /** - * Returns the contents of the specified <code>directory</code> as an - * <code>ArrayList</code> containing the names of the files as Java Strings. - */ - protected static List<String> getContents(File directory) { - String[] contents = directory.list(); - List<String> result = new ArrayList<String>(); - - // If an IO exception occurs (something odd, but possible) - // A directory may return null. - if (contents != null) { - for (int i=0; i<contents.length; i++) { - result.add(contents[i]); - } - } - return result; - } - - /** - * Returns the contents of the specified <code>directory</code> as an - * <code>ArrayList</code> containing the names of the files as Ruby Strings. - */ - protected static List<RubyString> getContents(File directory, Ruby runtime) { - List<RubyString> result = new ArrayList<RubyString>(); - String[] contents = directory.list(); - - for (int i = 0; i < contents.length; i++) { - result.add(runtime.newString(contents[i])); - } - return result; - } - - /** - * Returns the home directory of the specified <code>user</code> on the - * system. If the home directory of the specified user cannot be found, - * an <code>ArgumentError it thrown</code>. - */ - public static IRubyObject getHomeDirectoryPath(ThreadContext context, String user) { - /* - * TODO: This version is better than the hackish previous one. Windows - * behavior needs to be defined though. I suppose this version - * could be improved more too. - * TODO: /etc/passwd is also inadequate for MacOSX since it does not - * use /etc/passwd for regular user accounts - */ - - String passwd = null; - try { - FileInputStream stream = new FileInputStream("/etc/passwd"); - int totalBytes = stream.available(); - byte[] bytes = new byte[totalBytes]; - stream.read(bytes); - stream.close(); - passwd = new String(bytes); - } catch (IOException e) { - return context.getRuntime().getNil(); - } - - String[] rows = passwd.split("\n"); - int rowCount = rows.length; - for (int i = 0; i < rowCount; i++) { - String[] fields = rows[i].split(":"); - if (fields[0].equals(user)) { - return context.getRuntime().newString(fields[5]); - } - } - - throw context.getRuntime().newArgumentError("user " + user + " doesn't exist"); - } - - public static RubyString getHomeDirectoryPath(ThreadContext context) { - Ruby runtime = context.getRuntime(); - RubyHash systemHash = (RubyHash) runtime.getObject().fastGetConstant("ENV_JAVA"); - RubyHash envHash = (RubyHash) runtime.getObject().fastGetConstant("ENV"); - IRubyObject home = envHash.op_aref(context, runtime.newString("HOME")); - - if (home == null || home.isNil()) { - home = systemHash.op_aref(context, runtime.newString("user.home")); - } - - if (home == null || home.isNil()) { - home = envHash.op_aref(context, runtime.newString("LOGDIR")); - } - - if (home == null || home.isNil()) { - throw runtime.newArgumentError("user.home/LOGDIR not set"); - } - - return (RubyString) home; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.Comparator; -import java.util.Arrays; -import java.util.concurrent.atomic.AtomicInteger; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; - -import org.jruby.exceptions.JumpException; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallBlock; -import org.jruby.runtime.BlockCallback; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.TypeConverter; - -/** - * The implementation of Ruby's Enumerable module. - */ - -@JRubyModule(name="Enumerable") -public class RubyEnumerable { - - public static RubyModule createEnumerableModule(Ruby runtime) { - RubyModule enumModule = runtime.defineModule("Enumerable"); - runtime.setEnumerable(enumModule); - - enumModule.defineAnnotatedMethods(RubyEnumerable.class); - - return enumModule; - } - - public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObject self, - BlockCallback callback) { - return RuntimeHelpers.invoke(context, self, "each", CallBlock.newCallClosure(self, runtime.getEnumerable(), - Arity.noArguments(), callback, context)); - } - - private static class ExitIteration extends RuntimeException { - public Throwable fillInStackTrace() { - return this; - } - } - - @JRubyMethod(name = "first") - public static IRubyObject first_0(ThreadContext context, IRubyObject self) { - Ruby runtime = self.getRuntime(); - final ThreadContext localContext = context; - - final IRubyObject[] holder = new IRubyObject[]{runtime.getNil()}; - - try { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw ctx.getRuntime().newThreadError("Enumerable#first cannot be parallelized"); - } - holder[0] = largs[0]; - throw new ExitIteration(); - } - }); - } catch(ExitIteration ei) {} - - return holder[0]; - } - - @JRubyMethod(name = "first") - public static IRubyObject first_1(ThreadContext context, IRubyObject self, final IRubyObject num) { - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(); - final ThreadContext localContext = context; - - if(RubyNumeric.fix2int(num) < 0) { - throw runtime.newArgumentError("negative index"); - } - - try { - callEach(runtime, context, self, new BlockCallback() { - private int iter = RubyNumeric.fix2int(num); - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#first cannot be parallelized"); - } - if(iter-- == 0) { - throw new ExitIteration(); - } - result.append(largs[0]); - return runtime.getNil(); - } - }); - } catch(ExitIteration ei) {} - - return result; - } - - @JRubyMethod(name = {"to_a", "entries"}) - public static IRubyObject to_a(ThreadContext context, IRubyObject self) { - Ruby runtime = self.getRuntime(); - RubyArray result = runtime.newArray(); - - callEach(runtime, context, self, new AppendBlockCallback(runtime, result)); - - return result; - } - - @JRubyMethod(name = "sort", frame = true) - public static IRubyObject sort(ThreadContext context, IRubyObject self, final Block block) { - Ruby runtime = self.getRuntime(); - RubyArray result = runtime.newArray(); - - callEach(runtime, context, self, new AppendBlockCallback(runtime, result)); - result.sort_bang(block); - - return result; - } - - @JRubyMethod(name = "sort_by", frame = true) - public static IRubyObject sort_by(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final ThreadContext localContext = context; // MUST NOT be used across threads - - if (self instanceof RubyArray) { - RubyArray selfArray = (RubyArray) self; - final IRubyObject[][] valuesAndCriteria = new IRubyObject[selfArray.size()][2]; - - callEach(runtime, context, self, new BlockCallback() { - AtomicInteger i = new AtomicInteger(0); - - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - IRubyObject[] myVandC = valuesAndCriteria[i.getAndIncrement()]; - myVandC[0] = largs[0]; - myVandC[1] = block.yield(ctx, largs[0]); - return runtime.getNil(); - } - }); - - Arrays.sort(valuesAndCriteria, new Comparator<IRubyObject[]>() { - public int compare(IRubyObject[] o1, IRubyObject[] o2) { - return RubyFixnum.fix2int(o1[1].callMethod(localContext, MethodIndex.OP_SPACESHIP, "<=>", o2[1])); - } - }); - - IRubyObject dstArray[] = new IRubyObject[selfArray.size()]; - for (int i = 0; i < dstArray.length; i++) { - dstArray[i] = valuesAndCriteria[i][0]; - } - - return runtime.newArrayNoCopy(dstArray); - } else { - final RubyArray result = runtime.newArray(); - callEach(runtime, context, self, new AppendBlockCallback(runtime, result)); - - final IRubyObject[][] valuesAndCriteria = new IRubyObject[result.size()][2]; - for (int i = 0; i < valuesAndCriteria.length; i++) { - IRubyObject val = result.eltInternal(i); - valuesAndCriteria[i][0] = val; - valuesAndCriteria[i][1] = block.yield(context, val); - } - - Arrays.sort(valuesAndCriteria, new Comparator<IRubyObject[]>() { - public int compare(IRubyObject[] o1, IRubyObject[] o2) { - return RubyFixnum.fix2int(o1[1].callMethod(localContext, MethodIndex.OP_SPACESHIP, "<=>", o2[1])); - } - }); - - for (int i = 0; i < valuesAndCriteria.length; i++) { - result.eltInternalSet(i, valuesAndCriteria[i][0]); - } - - return result; - } - } - - @JRubyMethod(name = "grep", required = 1, frame = true) - public static IRubyObject grep(ThreadContext context, IRubyObject self, final IRubyObject pattern, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(); - - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - ctx.setRubyFrameDelta(ctx.getRubyFrameDelta()+2); - if (pattern.callMethod(ctx, MethodIndex.OP_EQQ, "===", largs[0]).isTrue()) { - IRubyObject value = block.yield(ctx, largs[0]); - synchronized (result) { - result.append(value); - } - } - ctx.setRubyFrameDelta(ctx.getRubyFrameDelta()-2); - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (pattern.callMethod(ctx, MethodIndex.OP_EQQ, "===", largs[0]).isTrue()) { - synchronized (result) { - result.append(largs[0]); - } - } - return runtime.getNil(); - } - }); - } - - return result; - } - - @JRubyMethod(name = {"detect", "find"}, optional = 1, frame = true) - public static IRubyObject detect(ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) { - final Ruby runtime = self.getRuntime(); - final IRubyObject result[] = new IRubyObject[] { null }; - final ThreadContext localContext = context; - IRubyObject ifnone = null; - - if (args.length == 1) ifnone = args[0]; - - try { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#detect/find cannot be parallelized"); - } - if (block.yield(ctx, largs[0]).isTrue()) { - result[0] = largs[0]; - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } catch (JumpException.SpecialJump sj) { - return result[0]; - } - - return ifnone != null ? ifnone.callMethod(context, "call") : runtime.getNil(); - } - - @JRubyMethod(name = {"select", "find_all"}, frame = true) - public static IRubyObject select(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(); - - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (block.yield(ctx, largs[0]).isTrue()) { - synchronized (result) { - result.append(largs[0]); - } - } - return runtime.getNil(); - } - }); - - return result; - } - - @JRubyMethod(name = "reject", frame = true) - public static IRubyObject reject(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(); - - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (!block.yield(ctx, largs[0]).isTrue()) { - synchronized (result) { - result.append(largs[0]); - } - } - return runtime.getNil(); - } - }); - - return result; - } - - @JRubyMethod(name = {"collect", "map"}, frame = true) - public static IRubyObject collect(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(); - - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - IRubyObject value = block.yield(ctx, largs[0]); - synchronized (result) { - result.append(value); - } - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new AppendBlockCallback(runtime, result)); - } - return result; - } - - @JRubyMethod(name = "inject", optional = 1, frame = true) - public static IRubyObject inject(ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) { - final Ruby runtime = self.getRuntime(); - final IRubyObject result[] = new IRubyObject[] { null }; - final ThreadContext localContext = context; - - if (args.length == 1) result[0] = args[0]; - - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#inject cannot be parallelized"); - } - result[0] = result[0] == null ? - largs[0] : block.yield(ctx, runtime.newArray(result[0], largs[0]), null, null, true); - - return runtime.getNil(); - } - }); - - return result[0] == null ? runtime.getNil() : result[0]; - } - - @JRubyMethod(name = "partition", frame = true) - public static IRubyObject partition(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyArray arr_true = runtime.newArray(); - final RubyArray arr_false = runtime.newArray(); - - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (block.yield(ctx, largs[0]).isTrue()) { - synchronized (arr_true) { - arr_true.append(largs[0]); - } - } else { - synchronized (arr_false) { - arr_false.append(largs[0]); - } - } - - return runtime.getNil(); - } - }); - - return runtime.newArray(arr_true, arr_false); - } - - private static class EachWithIndex implements BlockCallback { - private int index = 0; - private final Block block; - private final Ruby runtime; - - public EachWithIndex(ThreadContext ctx, Block block) { - this.block = block; - this.runtime = ctx.getRuntime(); - } - - public IRubyObject call(ThreadContext context, IRubyObject[] iargs, Block block) { - this.block.call(context, new IRubyObject[] { runtime.newArray(iargs[0], runtime.newFixnum(index++)) }); - return runtime.getNil(); - } - } - - @JRubyMethod(name = "each_with_index", frame = true) - public static IRubyObject each_with_index(ThreadContext context, IRubyObject self, Block block) { - RuntimeHelpers.invoke(context, self, "each", CallBlock.newCallClosure(self, self.getRuntime().getEnumerable(), - Arity.noArguments(), new EachWithIndex(context, block), context)); - - return self; - } - - @JRubyMethod(name = {"include?", "member?"}, required = 1, frame = true) - public static IRubyObject include_p(ThreadContext context, IRubyObject self, final IRubyObject arg) { - final Ruby runtime = context.getRuntime(); - final ThreadContext localContext = context; - - try { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#include?/member? cannot be parallelized"); - } - if (RubyObject.equalInternal(ctx, largs[0], arg)) { - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } catch (JumpException.SpecialJump sj) { - return runtime.getTrue(); - } - - return runtime.getFalse(); - } - - @JRubyMethod(name = "max", frame = true) - public static IRubyObject max(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final IRubyObject result[] = new IRubyObject[] { null }; - final ThreadContext localContext = context; - - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#max{} cannot be parallelized"); - } - if (result[0] == null || RubyComparable.cmpint(ctx, block.yield(ctx, - runtime.newArray(largs[0], result[0])), largs[0], result[0]) > 0) { - result[0] = largs[0]; - } - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - synchronized (result) { - if (result[0] == null || RubyComparable.cmpint(ctx, largs[0].callMethod(ctx, - MethodIndex.OP_SPACESHIP, "<=>", result[0]), largs[0], result[0]) > 0) { - result[0] = largs[0]; - } - } - return runtime.getNil(); - } - }); - } - - return result[0] == null ? runtime.getNil() : result[0]; - } - - @JRubyMethod(name = "min", frame = true) - public static IRubyObject min(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final IRubyObject result[] = new IRubyObject[] { null }; - final ThreadContext localContext = context; - - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#min{} cannot be parallelized"); - } - if (result[0] == null || RubyComparable.cmpint(ctx, block.yield(ctx, - runtime.newArray(largs[0], result[0])), largs[0], result[0]) < 0) { - result[0] = largs[0]; - } - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - synchronized (result) { - if (result[0] == null || RubyComparable.cmpint(ctx, largs[0].callMethod(ctx, - MethodIndex.OP_SPACESHIP, "<=>", result[0]), largs[0], result[0]) < 0) { - result[0] = largs[0]; - } - } - return runtime.getNil(); - } - }); - } - - return result[0] == null ? runtime.getNil() : result[0]; - } - - @JRubyMethod(name = "all?", frame = true) - public static IRubyObject all_p(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final ThreadContext localContext = context; - - try { - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#all? cannot be parallelized"); - } - if (!block.yield(ctx, largs[0]).isTrue()) { - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#all? cannot be parallelized"); - } - if (!largs[0].isTrue()) { - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } - } catch (JumpException.SpecialJump sj) { - return runtime.getFalse(); - } - - return runtime.getTrue(); - } - - @JRubyMethod(name = "any?", frame = true) - public static IRubyObject any_p(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final ThreadContext localContext = context; - - try { - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#any? cannot be parallelized"); - } - if (block.yield(ctx, largs[0]).isTrue()) { - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } else { - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (localContext != ctx) { - throw runtime.newThreadError("Enumerable#any? cannot be parallelized"); - } - if (largs[0].isTrue()) { - throw JumpException.SPECIAL_JUMP; - } - return runtime.getNil(); - } - }); - } - } catch (JumpException.SpecialJump sj) { - return runtime.getTrue(); - } - - return runtime.getFalse(); - } - - @JRubyMethod(name = "zip", rest = true, frame = true) - public static IRubyObject zip(ThreadContext context, IRubyObject self, final IRubyObject[] args, final Block block) { - final Ruby runtime = self.getRuntime(); - - for (int i = 0; i < args.length; i++) { - args[i] = TypeConverter.convertToType(args[i], runtime.getArray(), MethodIndex.TO_A, "to_a"); - } - - final int aLen = args.length + 1; - - if (block.isGiven()) { - callEach(runtime, context, self, new BlockCallback() { - AtomicInteger ix = new AtomicInteger(0); - - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - RubyArray array = runtime.newArray(aLen); - int myIx = ix.getAndIncrement(); - array.append(largs[0]); - for (int i = 0, j = args.length; i < j; i++) { - array.append(((RubyArray) args[i]).entry(myIx)); - } - block.yield(ctx, array); - return runtime.getNil(); - } - }); - return runtime.getNil(); - } else { - final RubyArray zip = runtime.newArray(); - callEach(runtime, context, self, new BlockCallback() { - AtomicInteger ix = new AtomicInteger(0); - - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - RubyArray array = runtime.newArray(aLen); - array.append(largs[0]); - int myIx = ix.getAndIncrement(); - for (int i = 0, j = args.length; i < j; i++) { - array.append(((RubyArray) args[i]).entry(myIx)); - } - synchronized (zip) { - zip.append(array); - } - return runtime.getNil(); - } - }); - return zip; - } - } - - @JRubyMethod(name = "group_by", frame = true) - public static IRubyObject group_by(ThreadContext context, IRubyObject self, final Block block) { - final Ruby runtime = self.getRuntime(); - final RubyHash result = new RubyHash(runtime); - - callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - IRubyObject key = block.yield(ctx, largs[0]); - synchronized (result) { - IRubyObject curr = result.fastARef(key); - - if (curr == null) { - curr = runtime.newArray(); - result.fastASet(key, curr); - } - curr.callMethod(ctx, MethodIndex.OP_LSHIFT, "<<", largs[0]); - } - return runtime.getNil(); - } - }); - - return result; - } - - public static final class AppendBlockCallback implements BlockCallback { - private Ruby runtime; - private RubyArray result; - - public AppendBlockCallback(Ruby runtime, RubyArray result) { - this.runtime = runtime; - this.result = result; - } - - public IRubyObject call(ThreadContext context, IRubyObject[] largs, Block blk) { - result.append(largs[0]); - - return runtime.getNil(); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Michael Studman <me@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.BlockCallback; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * Implementation of Ruby's Enumerator module. - */ -@JRubyModule(name="Enumerable::Enumerator", include="Enumerable") -public class RubyEnumerator extends RubyObject { - /** target for each operation */ - private IRubyObject object; - - /** method to invoke for each operation */ - private IRubyObject method; - - /** args to each method */ - private IRubyObject[] methodArgs; - - private static ObjectAllocator ENUMERATOR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyEnumerator(runtime, klass); - } - }; - - public static void defineEnumerator(Ruby runtime) { - RubyModule kernel = runtime.getKernel(); - kernel.defineAnnotatedMethod(RubyEnumerator.class, "obj_to_enum"); - - RubyModule enm = runtime.getClassFromPath("Enumerable"); - enm.defineAnnotatedMethod(RubyEnumerator.class, "each_with_index"); - enm.defineAnnotatedMethod(RubyEnumerator.class, "each_slice"); - enm.defineAnnotatedMethod(RubyEnumerator.class, "enum_slice"); - enm.defineAnnotatedMethod(RubyEnumerator.class, "each_cons"); - enm.defineAnnotatedMethod(RubyEnumerator.class, "enum_cons"); - - RubyClass enmr = enm.defineClassUnder("Enumerator", runtime.getObject(), ENUMERATOR_ALLOCATOR); - - enmr.includeModule(enm); - - enmr.defineAnnotatedMethod(RubyEnumerator.class, "initialize"); - enmr.defineAnnotatedMethod(RubyEnumerator.class, "each"); - - runtime.setEnumerator(enmr); - } - - @JRubyMethod(name = {"to_enum", "enum_for"}, optional = 1, rest = true, frame = true) - public static IRubyObject obj_to_enum(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) { - IRubyObject[] newArgs = new IRubyObject[args.length + 1]; - newArgs[0] = self; - System.arraycopy(args, 0, newArgs, 1, args.length); - - return self.getRuntime().getEnumerator().callMethod(context, "new", newArgs); - } - - private RubyEnumerator(Ruby runtime, RubyClass type) { - super(runtime, type); - object = method = runtime.getNil(); - } - - @JRubyMethod(name = "initialize", required = 1, rest = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args) { - object = args[0]; - method = args.length > 1 ? args[1] : getRuntime().fastNewSymbol("each"); - if (args.length > 2) { - methodArgs = new IRubyObject[Math.max(0, args.length - 2)]; - System.arraycopy(args, 2, methodArgs, 0, args.length - 2); - } else { - methodArgs = new IRubyObject[0]; - } - return this; - } - - /** - * Send current block and supplied args to method on target. According to MRI - * Block may not be given and "each" should just ignore it and call on through to - * underlying method. - */ - @JRubyMethod(name = "each", frame = true) - public IRubyObject each(ThreadContext context, Block block) { - return object.callMethod(context, method.asJavaString(), methodArgs, block); - } - - @JRubyMethod(name = "enum_with_index") - public static IRubyObject each_with_index(ThreadContext context, IRubyObject self) { - IRubyObject enumerator = self.getRuntime().getEnumerator(); - return RuntimeHelpers.invoke(context, enumerator, "new", self, self.getRuntime().fastNewSymbol("each_with_index")); - } - - @JRubyMethod(name = "each_slice", required = 1, frame = true) - public static IRubyObject each_slice(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) { - final int size = (int)RubyNumeric.num2long(arg); - - if (size <= 0) throw self.getRuntime().newArgumentError("invalid slice size"); - - final Ruby runtime = self.getRuntime(); - final RubyArray result[] = new RubyArray[]{runtime.newArray(size)}; - - RubyEnumerable.callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - result[0].append(largs[0]); - if (result[0].size() == size) { - block.yield(ctx, result[0]); - result[0] = runtime.newArray(size); - } - return runtime.getNil(); - } - }); - - if (result[0].size() > 0) block.yield(context, result[0]); - return self.getRuntime().getNil(); - } - - @JRubyMethod(name = "each_cons", required = 1, frame = true) - public static IRubyObject each_cons(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) { - final int size = (int)RubyNumeric.num2long(arg); - - if (size <= 0) throw self.getRuntime().newArgumentError("invalid size"); - - final Ruby runtime = self.getRuntime(); - final RubyArray result = runtime.newArray(size); - - RubyEnumerable.callEach(runtime, context, self, new BlockCallback() { - public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) { - if (result.size() == size) result.shift(); - result.append(largs[0]); - if (result.size() == size) block.yield(ctx, result.aryDup()); - return runtime.getNil(); - } - }); - - return runtime.getNil(); - } - - @JRubyMethod(name = "enum_slice", required = 1) - public static IRubyObject enum_slice(ThreadContext context, IRubyObject self, IRubyObject arg) { - IRubyObject enumerator = self.getRuntime().getEnumerator(); - return RuntimeHelpers.invoke(context, enumerator, "new", self, self.getRuntime().fastNewSymbol("each_slice"), arg); - } - - @JRubyMethod(name = "enum_cons", required = 1) - public static IRubyObject enum_cons(ThreadContext context, IRubyObject self, IRubyObject arg) { - IRubyObject enumerator = self.getRuntime().getEnumerator(); - return RuntimeHelpers.invoke(context, enumerator, "new", self, self.getRuntime().fastNewSymbol("each_cons"), arg); - } -} -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.ext.posix.Passwd; -import org.jruby.ext.posix.Group; -import org.jruby.ext.posix.POSIX; -import org.jruby.ext.posix.util.Platform; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyModule(name="Etc") -public class RubyEtc { - public static RubyModule createEtcModule(Ruby runtime) { - RubyModule etcModule = runtime.defineModule("Etc"); - - runtime.setEtc(etcModule); - - etcModule.defineAnnotatedMethods(RubyEtc.class); - - definePasswdStruct(runtime); - defineGroupStruct(runtime); - - return etcModule; - } - - private static void definePasswdStruct(Ruby runtime) { - IRubyObject[] args = new IRubyObject[] { - runtime.newString("Passwd"), - runtime.newSymbol("name"), - runtime.newSymbol("passwd"), - runtime.newSymbol("uid"), - runtime.newSymbol("gid"), - runtime.newSymbol("gecos"), - runtime.newSymbol("dir"), - runtime.newSymbol("shell"), - runtime.newSymbol("change"), - runtime.newSymbol("uclass"), - runtime.newSymbol("expire") - }; - - runtime.setPasswdStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); - } - - private static void defineGroupStruct(Ruby runtime) { - IRubyObject[] args = new IRubyObject[] { - runtime.newString("Group"), - runtime.newSymbol("name"), - runtime.newSymbol("passwd"), - runtime.newSymbol("gid"), - runtime.newSymbol("mem") - }; - - runtime.setGroupStruct(RubyStruct.newInstance(runtime.getStructClass(), args, Block.NULL_BLOCK)); - } - - private static IRubyObject setupPasswd(Ruby runtime, Passwd passwd) { - IRubyObject[] args = new IRubyObject[] { - runtime.newString(passwd.getLoginName()), - runtime.newString(passwd.getPassword()), - runtime.newFixnum(passwd.getUID()), - runtime.newFixnum(passwd.getGID()), - runtime.newString(passwd.getGECOS()), - runtime.newString(passwd.getHome()), - runtime.newString(passwd.getShell()), - runtime.newFixnum(passwd.getPasswdChangeTime()), - runtime.newString(passwd.getAccessClass()), - runtime.newFixnum(passwd.getExpire()) - - }; - - return RubyStruct.newStruct(runtime.getPasswdStruct(), args, Block.NULL_BLOCK); - } - - - private static IRubyObject setupGroup(Ruby runtime, Group group) { - IRubyObject[] args = new IRubyObject[] { - runtime.newString(group.getName()), - runtime.newString(group.getPassword()), - runtime.newFixnum(group.getGID()), - intoStringArray(runtime, group.getMembers()) - }; - - return RubyStruct.newStruct(runtime.getGroupStruct(), args, Block.NULL_BLOCK); - } - - private static IRubyObject intoStringArray(Ruby runtime, String[] members) { - IRubyObject[] arr = new IRubyObject[members.length]; - for(int i = 0; i<arr.length; i++) { - arr[i] = runtime.newString(members[i]); - } - return runtime.newArrayNoCopy(arr); - } - - - @JRubyMethod(name = "getpwuid", optional=1, module = true) - public static IRubyObject getpwuid(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - POSIX posix = runtime.getPosix(); - int uid = args.length == 0 ? posix.getuid() : RubyNumeric.fix2int(args[0]); - Passwd pwd = posix.getpwuid(uid); - if(pwd == null) { - if (Platform.IS_WINDOWS) { // MRI behavior - return recv.getRuntime().getNil(); - } - throw runtime.newArgumentError("can't find user for " + uid); - } - return setupPasswd(runtime, pwd); - } - - @JRubyMethod(name = "getpwnam", required=1, module = true) - public static IRubyObject getpwnam(IRubyObject recv, IRubyObject name) { - String nam = name.convertToString().toString(); - Passwd pwd = recv.getRuntime().getPosix().getpwnam(nam); - if(pwd == null) { - if (Platform.IS_WINDOWS) { // MRI behavior - return recv.getRuntime().getNil(); - } - throw recv.getRuntime().newArgumentError("can't find user for " + nam); - } - return setupPasswd(recv.getRuntime(), pwd); - } - - @JRubyMethod(name = "passwd", module = true, frame=true) - public static IRubyObject passwd(IRubyObject recv, Block block) { - Ruby runtime = recv.getRuntime(); - POSIX posix = runtime.getPosix(); - if(block.isGiven()) { - ThreadContext context = runtime.getCurrentContext(); - posix.setpwent(); - Passwd pw; - while((pw = posix.getpwent()) != null) { - block.yield(context, setupPasswd(runtime, pw)); - } - posix.endpwent(); - } - - Passwd pw = posix.getpwent(); - if (pw != null) { - return setupPasswd(runtime, pw); - } else { - return runtime.getNil(); - } - } - - @JRubyMethod(name = "getlogin", module = true) - public static IRubyObject getlogin(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - - String login = runtime.getPosix().getlogin(); - - if (login != null) { - return runtime.newString(login); - } else { - return runtime.getNil(); - } - } - - @JRubyMethod(name = "endpwent", module = true) - public static IRubyObject endpwent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - runtime.getPosix().endpwent(); - return runtime.getNil(); - } - - @JRubyMethod(name = "setpwent", module = true) - public static IRubyObject setpwent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - runtime.getPosix().setpwent(); - return runtime.getNil(); - } - - @JRubyMethod(name = "getpwent", module = true) - public static IRubyObject getpwent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - Passwd passwd = runtime.getPosix().getpwent(); - if (passwd != null) { - return setupPasswd(recv.getRuntime(), passwd); - } else { - return runtime.getNil(); - } - } - - @JRubyMethod(name = "getgrnam", required=1, module = true) - public static IRubyObject getgrnam(IRubyObject recv, IRubyObject name) { - String nam = name.convertToString().toString(); - Group grp = recv.getRuntime().getPosix().getgrnam(nam); - if(grp == null) { - if (Platform.IS_WINDOWS) { // MRI behavior - return recv.getRuntime().getNil(); - } - throw recv.getRuntime().newArgumentError("can't find group for " + nam); - } - return setupGroup(recv.getRuntime(), grp); - } - - @JRubyMethod(name = "getgrgid", optional=1, module = true) - public static IRubyObject getgrgid(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - POSIX posix = runtime.getPosix(); - int gid = args.length == 0 ? posix.getgid() : RubyNumeric.fix2int(args[0]); - Group gr = posix.getgrgid(gid); - if(gr == null) { - if (Platform.IS_WINDOWS) { // MRI behavior - return runtime.getNil(); - } - throw runtime.newArgumentError("can't find group for " + gid); - } - return setupGroup(runtime, gr); - } - - @JRubyMethod(name = "endgrent", module = true) - public static IRubyObject endgrent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - runtime.getPosix().endgrent(); - return runtime.getNil(); - } - - @JRubyMethod(name = "setgrent", module = true) - public static IRubyObject setgrent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - runtime.getPosix().setgrent(); - return runtime.getNil(); - } - - @JRubyMethod(name = "group", module = true, frame=true) - public static IRubyObject group(IRubyObject recv, Block block) { - Ruby runtime = recv.getRuntime(); - POSIX posix = runtime.getPosix(); - if(block.isGiven()) { - ThreadContext context = runtime.getCurrentContext(); - posix.setgrent(); - Group gr; - while((gr = posix.getgrent()) != null) { - block.yield(context, setupGroup(runtime, gr)); - } - posix.endgrent(); - } - - Group gr = posix.getgrent(); - if (gr != null) { - return setupGroup(runtime, gr); - } else { - return runtime.getNil(); - } - } - - @JRubyMethod(name = "getgrent", module = true) - public static IRubyObject getgrent(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - Group gr = runtime.getPosix().getgrent(); - if (gr != null) { - return setupGroup(recv.getRuntime(), gr); - } else { - return runtime.getNil(); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 David Corbin <dcorbin@users.sf.net> - * Copyright (C) 2006 Michael Studman <codehaus@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.io.PrintStream; -import java.util.List; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; - -import org.jruby.runtime.Block; -import org.jruby.runtime.Frame; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ObjectMarshal; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; -import org.jruby.runtime.component.VariableEntry; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.SafePropertyAccessor; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="Exception") -public class RubyException extends RubyObject { - private StackTraceElement[] backtraceFrames; - private StackTraceElement[] javaStackTrace; - private IRubyObject backtrace; - public IRubyObject message; - public static final int TRACE_HEAD = 8; - public static final int TRACE_TAIL = 4; - public static final int TRACE_MAX = TRACE_HEAD + TRACE_TAIL + 6; - - protected RubyException(Ruby runtime, RubyClass rubyClass) { - this(runtime, rubyClass, null); - } - - public RubyException(Ruby runtime, RubyClass rubyClass, String message) { - super(runtime, rubyClass); - - this.message = message == null ? runtime.getNil() : runtime.newString(message); - } - - private static ObjectAllocator EXCEPTION_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyException instance = new RubyException(runtime, klass); - - // for future compatibility as constructors move toward not accepting metaclass? - instance.setMetaClass(klass); - - return instance; - } - }; - - private static final ObjectMarshal EXCEPTION_MARSHAL = new ObjectMarshal() { - public void marshalTo(Ruby runtime, Object obj, RubyClass type, - MarshalStream marshalStream) throws IOException { - RubyException exc = (RubyException)obj; - - marshalStream.registerLinkTarget(exc); - List<Variable<IRubyObject>> attrs = exc.getVariableList(); - attrs.add(new VariableEntry<IRubyObject>( - "mesg", exc.message == null ? runtime.getNil() : exc.message)); - attrs.add(new VariableEntry<IRubyObject>("bt", exc.getBacktrace())); - marshalStream.dumpVariables(attrs); - } - - public Object unmarshalFrom(Ruby runtime, RubyClass type, - UnmarshalStream unmarshalStream) throws IOException { - RubyException exc = (RubyException)type.allocate(); - - unmarshalStream.registerLinkTarget(exc); - unmarshalStream.defaultVariablesUnmarshal(exc); - - exc.message = exc.removeInternalVariable("mesg"); - exc.set_backtrace(exc.removeInternalVariable("bt")); - - return exc; - } - }; - - public static RubyClass createExceptionClass(Ruby runtime) { - RubyClass exceptionClass = runtime.defineClass("Exception", runtime.getObject(), EXCEPTION_ALLOCATOR); - runtime.setException(exceptionClass); - - exceptionClass.setMarshal(EXCEPTION_MARSHAL); - exceptionClass.defineAnnotatedMethods(RubyException.class); - - return exceptionClass; - } - - public static RubyException newException(Ruby runtime, RubyClass excptnClass, String msg) { - return new RubyException(runtime, excptnClass, msg); - } - - public void setBacktraceFrames(StackTraceElement[] backtraceFrames) { - this.backtraceFrames = backtraceFrames; - if (TRACE_TYPE == RAW || - TRACE_TYPE == RAW_FILTERED || - TRACE_TYPE == RUBY_COMPILED || - TRACE_TYPE == RUBY_HYBRID) { - javaStackTrace = Thread.currentThread().getStackTrace(); - } - } - - public static final int RAW = 0; - public static final int RAW_FILTERED = 1; - public static final int RUBY_FRAMED = 2; - public static final int RUBY_COMPILED = 3; - public static final int RUBY_HYBRID = 4; - - public static final int TRACE_TYPE; - - static { - String style = SafePropertyAccessor.getProperty("jruby.backtrace.style", "ruby_framed").toLowerCase(); - - if (style.equals("raw")) TRACE_TYPE = RAW; - else if (style.equals("raw_filtered")) TRACE_TYPE = RAW_FILTERED; - else if (style.equals("ruby_framed")) TRACE_TYPE = RUBY_FRAMED; - else if (style.equals("ruby_compiled")) TRACE_TYPE = RUBY_COMPILED; - else if (style.equals("ruby_hybrid")) TRACE_TYPE = RUBY_HYBRID; - else TRACE_TYPE = RUBY_FRAMED; - } - - public IRubyObject getBacktrace() { - if (backtrace == null) { - initBacktrace(); - } - return backtrace; - } - - public void initBacktrace() { - switch (TRACE_TYPE) { - case RAW: - backtrace = ThreadContext.createRawBacktrace(getRuntime(), javaStackTrace, false); - break; - case RAW_FILTERED: - backtrace = ThreadContext.createRawBacktrace(getRuntime(), javaStackTrace, true); - break; - case RUBY_FRAMED: - backtrace = backtraceFrames == null ? getRuntime().getNil() : ThreadContext.createBacktraceFromFrames(getRuntime(), backtraceFrames); - break; - case RUBY_COMPILED: - backtrace = ThreadContext.createRubyCompiledBacktrace(getRuntime(), javaStackTrace); - break; - case RUBY_HYBRID: - backtrace = ThreadContext.createRubyHybridBacktrace(getRuntime(), backtraceFrames, javaStackTrace, getRuntime().getDebug().isTrue()); - break; - } - } - - @JRubyMethod(optional = 2, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block block) { - if (args.length == 1) message = args[0]; - return this; - } - - @JRubyMethod - public IRubyObject backtrace() { - return getBacktrace(); - } - - @JRubyMethod(required = 1) - public IRubyObject set_backtrace(IRubyObject obj) { - if (obj.isNil()) { - backtrace = null; - } else if (!isArrayOfStrings(obj)) { - throw getRuntime().newTypeError("backtrace must be Array of String"); - } else { - backtrace = (RubyArray) obj; - } - return backtrace(); - } - - @JRubyMethod(name = "exception", optional = 1, rest = true, meta = true) - public static IRubyObject exception(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - return ((RubyClass) recv).newInstance(context, args, block); - } - - @JRubyMethod(optional = 1) - public RubyException exception(IRubyObject[] args) { - switch (args.length) { - case 0 : - return this; - case 1 : - if(args[0] == this) { - return this; - } - RubyException ret = (RubyException)rbClone(); - ret.initialize(args, Block.NULL_BLOCK); // This looks wrong, but it's the way MRI does it. - return ret; - default : - throw getRuntime().newArgumentError("Wrong argument count"); - } - } - - @JRubyMethod - public IRubyObject to_s() { - if (message.isNil()) return getRuntime().newString(getMetaClass().getName()); - message.setTaint(isTaint()); - return message; - } - - @JRubyMethod(name = {"to_str", "message"}) - public IRubyObject to_str(ThreadContext context) { - return callMethod(context, MethodIndex.TO_S, "to_s"); - } - - /** inspects an object and return a kind of debug information - * - *@return A RubyString containing the debug information. - */ - @JRubyMethod - public IRubyObject inspect(ThreadContext context) { - RubyModule rubyClass = getMetaClass(); - RubyString exception = RubyString.objAsString(context, this); - - if (exception.getByteList().realSize == 0) return getRuntime().newString(rubyClass.getName()); - StringBuilder sb = new StringBuilder("#<"); - sb.append(rubyClass.getName()).append(": ").append(exception.getByteList()).append(">"); - return getRuntime().newString(sb.toString()); - } - - public void printBacktrace(PrintStream errorStream) { - IRubyObject backtrace = callMethod(getRuntime().getCurrentContext(), "backtrace"); - boolean debug = getRuntime().getDebug().isTrue(); - if (!backtrace.isNil() && backtrace instanceof RubyArray) { - IRubyObject[] elements = backtrace.convertToArray().toJavaArray(); - - for (int i = 1; i < elements.length; i++) { - IRubyObject stackTraceLine = elements[i]; - if (stackTraceLine instanceof RubyString) { - printStackTraceLine(errorStream, stackTraceLine); - } - - if (!debug && i == RubyException.TRACE_HEAD && elements.length > RubyException.TRACE_MAX) { - int hiddenLevels = elements.length - RubyException.TRACE_HEAD - RubyException.TRACE_TAIL; - errorStream.print("\t ... " + hiddenLevels + " levels...\n"); - i = elements.length - RubyException.TRACE_TAIL; - } - } - } - } - - private void printStackTraceLine(PrintStream errorStream, IRubyObject stackTraceLine) { - errorStream.print("\tfrom " + stackTraceLine + '\n'); - } - - private boolean isArrayOfStrings(IRubyObject backtrace) { - if (!(backtrace instanceof RubyArray)) return false; - - IRubyObject[] elements = ((RubyArray) backtrace).toJavaArray(); - - for (int i = 0 ; i < elements.length ; i++) { - if (!(elements[i] instanceof RubyString)) return false; - } - - return true; - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2003 Joey Gibson <joey@joeygibson.com> - * Copyright (C) 2004-2007 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2007 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.util.io.OpenFile; -import org.jruby.util.io.ChannelDescriptor; -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.FileLock; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.ext.posix.util.Platform; -import org.jruby.runtime.Block; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.io.DirectoryAsFileException; -import org.jruby.util.io.Stream; -import org.jruby.util.io.ChannelStream; -import org.jruby.util.io.ModeFlags; -import org.jruby.util.JRubyFile; -import org.jruby.util.TypeConverter; -import org.jruby.util.io.BadDescriptorException; -import org.jruby.util.io.FileExistsException; -import org.jruby.util.io.InvalidValueException; -import org.jruby.util.io.PipeException; - -/** - * Ruby File class equivalent in java. - **/ -@JRubyClass(name="File", parent="IO", include="FileTest") -public class RubyFile extends RubyIO { - private static final long serialVersionUID = 1L; - - public static final int LOCK_SH = 1; - public static final int LOCK_EX = 2; - public static final int LOCK_NB = 4; - public static final int LOCK_UN = 8; - - private static final int FNM_NOESCAPE = 1; - private static final int FNM_PATHNAME = 2; - private static final int FNM_DOTMATCH = 4; - private static final int FNM_CASEFOLD = 8; - private static final int FNM_SYSCASE; - - static { - if (Platform.IS_WINDOWS) { - FNM_SYSCASE = FNM_CASEFOLD; - } else { - FNM_SYSCASE = 0; - } - } - - private static boolean startsWithDriveLetterOnWindows(String path) { - return (path != null) - && Platform.IS_WINDOWS && - ((path.length()>1 && path.charAt(0) == '/') ? - (path.length() > 2 - && isWindowsDriveLetter(path.charAt(1)) - && path.charAt(2) == ':') : - (path.length() > 1 - && isWindowsDriveLetter(path.charAt(0)) - && path.charAt(1) == ':')); - } - // adjusts paths started with '/' or '\\', on windows. - static String adjustRootPathOnWindows(Ruby runtime, String path, String dir) { - if (path == null) return path; - if (Platform.IS_WINDOWS) { - // MRI behavior on Windows: it treats '/' as a root of - // a current drive (but only if SINGLE slash is present!): - // E.g., if current work directory is - // 'D:/home/directory', then '/' means 'D:/'. - // - // Basically, '/path' is treated as a *RELATIVE* path, - // relative to the current drive. '//path' is treated - // as absolute one. - if ((path.startsWith("/") && !(path.length()>2 && path.charAt(2) == ':')) || path.startsWith("\\")) { - if (path.length() > 1 && (path.charAt(1) == '/' || path.charAt(1) == '\\')) { - return path; - } - - // First try to use drive letter from supplied dir value, - // then try current work dir. - if (!startsWithDriveLetterOnWindows(dir)) { - dir = runtime.getCurrentDirectory(); - } - if (dir.length() >= 2) { - path = dir.substring(0, 2) + path; - } - } else if (startsWithDriveLetterOnWindows(path) && path.length() == 2) { - // compensate for missing slash after drive letter on windows - path += "/"; - } - } - return path; - } - - protected String path; - private FileLock currentLock; - - public RubyFile(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - // XXX This constructor is a hack to implement the __END__ syntax. - // Converting a reader back into an InputStream doesn't generally work. - public RubyFile(Ruby runtime, String path, final Reader reader) { - this(runtime, path, new InputStream() { - public int read() throws IOException { - return reader.read(); - } - }); - } - - public RubyFile(Ruby runtime, String path, InputStream in) { - super(runtime, runtime.getFile()); - this.path = path; - try { - this.openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(in), getNewFileno(), new FileDescriptor()))); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } - this.openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags()); - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - private static ObjectAllocator FILE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyFile instance = new RubyFile(runtime, klass); - - instance.setMetaClass(klass); - - return instance; - } - }; - - @JRubyModule(name="File::Constants") - public static class Constants {} - - public static RubyClass createFileClass(Ruby runtime) { - RubyClass fileClass = runtime.defineClass("File", runtime.getIO(), FILE_ALLOCATOR); - runtime.setFile(fileClass); - RubyString separator = runtime.newString("/"); - ThreadContext context = runtime.getCurrentContext(); - - fileClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyFile; - } - }; - - separator.freeze(context); - fileClass.defineConstant("SEPARATOR", separator); - fileClass.defineConstant("Separator", separator); - - if (File.separatorChar == '\\') { - RubyString altSeparator = runtime.newString("\\"); - altSeparator.freeze(context); - fileClass.defineConstant("ALT_SEPARATOR", altSeparator); - } else { - fileClass.defineConstant("ALT_SEPARATOR", runtime.getNil()); - } - - RubyString pathSeparator = runtime.newString(File.pathSeparator); - pathSeparator.freeze(context); - fileClass.defineConstant("PATH_SEPARATOR", pathSeparator); - - // TODO: why are we duplicating the constants here, and then in - // File::Constants below? File::Constants is included in IO. - - // TODO: These were missing, so we're not handling them elsewhere? - // FIXME: The old value, 32786, didn't match what IOModes expected, so I reference - // the constant here. THIS MAY NOT BE THE CORRECT VALUE. - fileClass.fastSetConstant("BINARY", runtime.newFixnum(ModeFlags.BINARY)); - fileClass.fastSetConstant("FNM_NOESCAPE", runtime.newFixnum(FNM_NOESCAPE)); - fileClass.fastSetConstant("FNM_CASEFOLD", runtime.newFixnum(FNM_CASEFOLD)); - fileClass.fastSetConstant("FNM_SYSCASE", runtime.newFixnum(FNM_SYSCASE)); - fileClass.fastSetConstant("FNM_DOTMATCH", runtime.newFixnum(FNM_DOTMATCH)); - fileClass.fastSetConstant("FNM_PATHNAME", runtime.newFixnum(FNM_PATHNAME)); - - // Create constants for open flags - fileClass.fastSetConstant("RDONLY", runtime.newFixnum(ModeFlags.RDONLY)); - fileClass.fastSetConstant("WRONLY", runtime.newFixnum(ModeFlags.WRONLY)); - fileClass.fastSetConstant("RDWR", runtime.newFixnum(ModeFlags.RDWR)); - fileClass.fastSetConstant("CREAT", runtime.newFixnum(ModeFlags.CREAT)); - fileClass.fastSetConstant("EXCL", runtime.newFixnum(ModeFlags.EXCL)); - fileClass.fastSetConstant("NOCTTY", runtime.newFixnum(ModeFlags.NOCTTY)); - fileClass.fastSetConstant("TRUNC", runtime.newFixnum(ModeFlags.TRUNC)); - fileClass.fastSetConstant("APPEND", runtime.newFixnum(ModeFlags.APPEND)); - fileClass.fastSetConstant("NONBLOCK", runtime.newFixnum(ModeFlags.NONBLOCK)); - - // Create constants for flock - fileClass.fastSetConstant("LOCK_SH", runtime.newFixnum(RubyFile.LOCK_SH)); - fileClass.fastSetConstant("LOCK_EX", runtime.newFixnum(RubyFile.LOCK_EX)); - fileClass.fastSetConstant("LOCK_NB", runtime.newFixnum(RubyFile.LOCK_NB)); - fileClass.fastSetConstant("LOCK_UN", runtime.newFixnum(RubyFile.LOCK_UN)); - - // Create Constants class - RubyModule constants = fileClass.defineModuleUnder("Constants"); - - // TODO: These were missing, so we're not handling them elsewhere? - constants.fastSetConstant("BINARY", runtime.newFixnum(ModeFlags.BINARY)); - constants.fastSetConstant("SYNC", runtime.newFixnum(0x1000)); - constants.fastSetConstant("FNM_NOESCAPE", runtime.newFixnum(FNM_NOESCAPE)); - constants.fastSetConstant("FNM_CASEFOLD", runtime.newFixnum(FNM_CASEFOLD)); - constants.fastSetConstant("FNM_SYSCASE", runtime.newFixnum(FNM_SYSCASE)); - constants.fastSetConstant("FNM_DOTMATCH", runtime.newFixnum(FNM_DOTMATCH)); - constants.fastSetConstant("FNM_PATHNAME", runtime.newFixnum(FNM_PATHNAME)); - - // Create constants for open flags - constants.fastSetConstant("RDONLY", runtime.newFixnum(ModeFlags.RDONLY)); - constants.fastSetConstant("WRONLY", runtime.newFixnum(ModeFlags.WRONLY)); - constants.fastSetConstant("RDWR", runtime.newFixnum(ModeFlags.RDWR)); - constants.fastSetConstant("CREAT", runtime.newFixnum(ModeFlags.CREAT)); - constants.fastSetConstant("EXCL", runtime.newFixnum(ModeFlags.EXCL)); - constants.fastSetConstant("NOCTTY", runtime.newFixnum(ModeFlags.NOCTTY)); - constants.fastSetConstant("TRUNC", runtime.newFixnum(ModeFlags.TRUNC)); - constants.fastSetConstant("APPEND", runtime.newFixnum(ModeFlags.APPEND)); - constants.fastSetConstant("NONBLOCK", runtime.newFixnum(ModeFlags.NONBLOCK)); - - // Create constants for flock - constants.fastSetConstant("LOCK_SH", runtime.newFixnum(RubyFile.LOCK_SH)); - constants.fastSetConstant("LOCK_EX", runtime.newFixnum(RubyFile.LOCK_EX)); - constants.fastSetConstant("LOCK_NB", runtime.newFixnum(RubyFile.LOCK_NB)); - constants.fastSetConstant("LOCK_UN", runtime.newFixnum(RubyFile.LOCK_UN)); - - // File::Constants module is included in IO. - runtime.getIO().includeModule(constants); - - runtime.getFileTest().extend_object(fileClass); - - fileClass.defineAnnotatedMethods(RubyFile.class); - - return fileClass; - } - - @JRubyMethod - @Override - public IRubyObject close() { - // Make sure any existing lock is released before we try and close the file - if (currentLock != null) { - try { - currentLock.release(); - } catch (IOException e) { - throw getRuntime().newIOError(e.getMessage()); - } - } - return super.close(); - } - - @JRubyMethod(required = 1) - public IRubyObject flock(ThreadContext context, IRubyObject lockingConstant) { - // TODO: port exact behavior from MRI, and move most locking logic into ChannelDescriptor - // TODO: for all LOCK_NB cases, return false if they would block - ChannelDescriptor descriptor = openFile.getMainStream().getDescriptor(); - - // null channel always succeeds for all locking operations - if (descriptor.isNull()) return RubyFixnum.zero(context.getRuntime()); - - FileChannel fileChannel = (FileChannel)descriptor.getChannel(); - int lockMode = RubyNumeric.num2int(lockingConstant); - - // Exclusive locks in Java require the channel to be writable, otherwise - // an exception is thrown (terminating JRuby execution). - // But flock behavior of MRI is that it allows - // exclusive locks even on non-writable file. So we convert exclusive - // lock to shared lock if the channel is not writable, to better match - // the MRI behavior. - if (!openFile.isWritable() && (lockMode & LOCK_EX) > 0) { - lockMode = (lockMode ^ LOCK_EX) | LOCK_SH; - } - - try { - switch (lockMode) { - case LOCK_UN: - case LOCK_UN | LOCK_NB: - if (currentLock != null) { - currentLock.release(); - currentLock = null; - - return RubyFixnum.zero(context.getRuntime()); - } - break; - case LOCK_EX: - if (currentLock != null) { - currentLock.release(); - currentLock = null; - } - currentLock = fileChannel.lock(); - if (currentLock != null) { - return RubyFixnum.zero(context.getRuntime()); - } - - break; - case LOCK_EX | LOCK_NB: - if (currentLock != null) { - currentLock.release(); - currentLock = null; - } - currentLock = fileChannel.tryLock(); - if (currentLock != null) { - return RubyFixnum.zero(context.getRuntime()); - } - - break; - case LOCK_SH: - if (currentLock != null) { - currentLock.release(); - currentLock = null; - } - - currentLock = fileChannel.lock(0L, Long.MAX_VALUE, true); - if (currentLock != null) { - return RubyFixnum.zero(context.getRuntime()); - } - - break; - case LOCK_SH | LOCK_NB: - if (currentLock != null) { - currentLock.release(); - currentLock = null; - } - - currentLock = fileChannel.tryLock(0L, Long.MAX_VALUE, true); - if (currentLock != null) { - return RubyFixnum.zero(context.getRuntime()); - } - - break; - default: - } - } catch (IOException ioe) { - if (context.getRuntime().getDebug().isTrue()) { - ioe.printStackTrace(System.err); - } - // Return false here - } catch (java.nio.channels.OverlappingFileLockException ioe) { - if (context.getRuntime().getDebug().isTrue()) { - ioe.printStackTrace(System.err); - } - // Return false here - } - - return context.getRuntime().getFalse(); - } - - @JRubyMethod(required = 1, optional = 2, frame = true, visibility = Visibility.PRIVATE) - @Override - public IRubyObject initialize(IRubyObject[] args, Block block) { - if (openFile == null) { - throw getRuntime().newRuntimeError("reinitializing File"); - } - - if (args.length > 0 && args.length < 3) { - IRubyObject fd = TypeConverter.convertToTypeWithCheck(args[0], getRuntime().getFixnum(), MethodIndex.TO_INT, "to_int"); - if (!fd.isNil()) { - args[0] = fd; - return super.initialize(args, block); - } - } - - return openFile(args); - } - - private IRubyObject openFile(IRubyObject args[]) { - IRubyObject filename = args[0].convertToString(); - getRuntime().checkSafeString(filename); - - path = filename.convertToString().getUnicodeValue(); - - String modeString; - ModeFlags modes; - int perm; - - try { - if ((args.length > 1 && args[1] instanceof RubyFixnum) || (args.length > 2 && !args[2].isNil())) { - if (args[1] instanceof RubyFixnum) { - modes = new ModeFlags(RubyNumeric.num2int(args[1])); - } else { - modeString = args[1].convertToString().toString(); - modes = getIOModes(getRuntime(), modeString); - } - if (args.length > 2 && !args[2].isNil()) { - perm = RubyNumeric.num2int(args[2]); - } else { - perm = 438; // 0666 - } - - sysopenInternal(path, modes, perm); - } else { - modeString = "r"; - if (args.length > 1) { - if (!args[1].isNil()) { - modeString = args[1].convertToString().toString(); - } - } - openInternal(path, modeString); - } - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } finally {} - - return this; - } - - private void sysopenInternal(String path, ModeFlags modes, int perm) throws InvalidValueException { - openFile = new OpenFile(); - - openFile.setPath(path); - openFile.setMode(modes.getOpenFileFlags()); - - ChannelDescriptor descriptor = sysopen(path, modes, perm); - openFile.setMainStream(fdopen(descriptor, modes)); - - registerDescriptor(descriptor); - } - - private void openInternal(String path, String modeString) throws InvalidValueException { - openFile = new OpenFile(); - - openFile.setMode(getIOModes(getRuntime(), modeString).getOpenFileFlags()); - openFile.setPath(path); - openFile.setMainStream(fopen(path, modeString)); - - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - private ChannelDescriptor sysopen(String path, ModeFlags modes, int perm) throws InvalidValueException { - try { - ChannelDescriptor descriptor = ChannelDescriptor.open( - getRuntime().getCurrentDirectory(), - path, - modes, - perm, - getRuntime().getPosix()); - - // TODO: check if too many open files, GC and try again - - return descriptor; - } catch (FileNotFoundException fnfe) { - throw getRuntime().newErrnoENOENTError(); - } catch (DirectoryAsFileException dafe) { - throw getRuntime().newErrnoEISDirError(); - } catch (FileExistsException fee) { - throw getRuntime().newErrnoEEXISTError("file exists: " + path); - } catch (IOException ioe) { - throw getRuntime().newIOErrorFromException(ioe); - } - } - - private Stream fopen(String path, String modeString) { - try { - Stream stream = ChannelStream.fopen( - getRuntime(), - path, - getIOModes(getRuntime(), modeString)); - - if (stream == null) { - // TODO - // if (errno == EMFILE || errno == ENFILE) { - // rb_gc(); - // file = fopen(fname, mode); - // } - // if (!file) { - // rb_sys_fail(fname); - // } - } - - // Do we need to be in SETVBUF mode for buffering to make sense? This comes up elsewhere. - // #ifdef USE_SETVBUF - // if (setvbuf(file, NULL, _IOFBF, 0) != 0) - // rb_warn("setvbuf() can't be honoured for %s", fname); - // #endif - // #ifdef __human68k__ - // fmode(file, _IOTEXT); - // #endif - return stream; - } catch (BadDescriptorException e) { - throw getRuntime().newErrnoEBADFError(); - } catch (FileNotFoundException ex) { - // FNFException can be thrown in both cases, when the file - // is not found, or when permission is denied. - if (Ruby.isSecurityRestricted() || new File(path).exists()) { - throw getRuntime().newErrnoEACCESError( - "Permission denied - " + path); - } - throw getRuntime().newErrnoENOENTError( - "File not found - " + path); - } catch (DirectoryAsFileException ex) { - throw getRuntime().newErrnoEISDirError(); - } catch (FileExistsException ex) { - throw getRuntime().newErrnoEEXISTError(path); - } catch (IOException ex) { - throw getRuntime().newIOErrorFromException(ex); - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } catch (PipeException ex) { - throw getRuntime().newErrnoEPIPEError(); - } - } - - @JRubyMethod(required = 1) - public IRubyObject chmod(ThreadContext context, IRubyObject arg) { - int mode = (int) arg.convertToInteger().getLongValue(); - - if (!new File(path).exists()) { - throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); - } - - return context.getRuntime().newFixnum(context.getRuntime().getPosix().chmod(path, mode)); - } - - @JRubyMethod(required = 2) - public IRubyObject chown(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { - int owner = -1; - if (!arg1.isNil()) { - owner = RubyNumeric.num2int(arg1); - } - - int group = -1; - if (!arg2.isNil()) { - group = RubyNumeric.num2int(arg2); - } - - if (!new File(path).exists()) { - throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); - } - - return context.getRuntime().newFixnum(context.getRuntime().getPosix().chown(path, owner, group)); - } - - @JRubyMethod - public IRubyObject atime(ThreadContext context) { - return context.getRuntime().newFileStat(path, false).atime(); - } - - @JRubyMethod - public IRubyObject ctime(ThreadContext context) { - return context.getRuntime().newFileStat(path, false).ctime(); - } - - @JRubyMethod(required = 1) - public IRubyObject lchmod(ThreadContext context, IRubyObject arg) { - int mode = (int) arg.convertToInteger().getLongValue(); - - if (!new File(path).exists()) { - throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); - } - - return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchmod(path, mode)); - } - - // TODO: this method is not present in MRI! - @JRubyMethod(required = 2) - public IRubyObject lchown(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { - int owner = -1; - if (!arg1.isNil()) { - owner = RubyNumeric.num2int(arg1); - } - - int group = -1; - if (!arg2.isNil()) { - group = RubyNumeric.num2int(arg2); - } - - if (!new File(path).exists()) { - throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); - } - - return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchown(path, owner, group)); - } - - @JRubyMethod - public IRubyObject lstat(ThreadContext context) { - return context.getRuntime().newFileStat(path, true); - } - - @JRubyMethod - public IRubyObject mtime(ThreadContext context) { - return getLastModified(context.getRuntime(), path); - } - - @JRubyMethod - public RubyString path(ThreadContext context) { - return context.getRuntime().newString(path); - } - - @JRubyMethod - @Override - public IRubyObject stat(ThreadContext context) { - openFile.checkClosed(context.getRuntime()); - return context.getRuntime().newFileStat(path, false); - } - - @JRubyMethod(required = 1) - public IRubyObject truncate(ThreadContext context, IRubyObject arg) { - RubyInteger newLength = arg.convertToInteger(); - if (newLength.getLongValue() < 0) { - throw context.getRuntime().newErrnoEINVALError("invalid argument: " + path); - } - try { - openFile.checkWritable(context.getRuntime()); - openFile.getMainStream().ftruncate(newLength.getLongValue()); - } catch (BadDescriptorException e) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (InvalidValueException ex) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (IOException e) { - // Should we do anything? - } - - return RubyFixnum.zero(context.getRuntime()); - } - - @Override - public String toString() { - return "RubyFile(" + path + ", " + openFile.getMode() + ", " + openFile.getMainStream().getDescriptor().getFileno() + ")"; - } - - // TODO: This is also defined in the MetaClass too...Consolidate somewhere. - private static ModeFlags getModes(Ruby runtime, IRubyObject object) throws InvalidValueException { - if (object instanceof RubyString) { - return getIOModes(runtime, ((RubyString) object).toString()); - } else if (object instanceof RubyFixnum) { - return new ModeFlags(((RubyFixnum) object).getLongValue()); - } - - throw runtime.newTypeError("Invalid type for modes"); - } - - @JRubyMethod - @Override - public IRubyObject inspect() { - StringBuilder val = new StringBuilder(); - val.append("#<File:").append(path); - if(!openFile.isOpen()) { - val.append(" (closed)"); - } - val.append(">"); - return getRuntime().newString(val.toString()); - } - - /* File class methods */ - - @JRubyMethod(required = 1, optional = 1, meta = true) - public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - String name = RubyString.stringValue(args[0]).toString(); - - // MRI-compatible basename handling for windows drive letter paths - if (Platform.IS_WINDOWS) { - if (name.length() > 1 && name.charAt(1) == ':' && Character.isLetter(name.charAt(0))) { - switch (name.length()) { - case 2: - return RubyString.newEmptyString(context.getRuntime()).infectBy(args[0]); - case 3: - return context.getRuntime().newString(name.substring(2)).infectBy(args[0]); - default: - switch (name.charAt(2)) { - case '/': - case '\\': - break; - default: - // strip c: away from relative-pathed name - name = name.substring(2); - break; - } - break; - } - } - } - - while (name.length() > 1 && name.charAt(name.length() - 1) == '/') { - name = name.substring(0, name.length() - 1); - } - - // Paths which end in "/" or "\\" must be stripped off. - int slashCount = 0; - int length = name.length(); - for (int i = length - 1; i >= 0; i--) { - char c = name.charAt(i); - if (c != '/' && c != '\\') { - break; - } - slashCount++; - } - if (slashCount > 0 && length > 1) { - name = name.substring(0, name.length() - slashCount); - } - - int index = name.lastIndexOf('/'); - if (index == -1) { - // XXX actually only on windows... - index = name.lastIndexOf('\\'); - } - - if (!name.equals("/") && index != -1) { - name = name.substring(index + 1); - } - - if (args.length == 2) { - String ext = RubyString.stringValue(args[1]).toString(); - if (".*".equals(ext)) { - index = name.lastIndexOf('.'); - if (index > 0) { // -1 no match; 0 it is dot file not extension - name = name.substring(0, index); - } - } else if (name.endsWith(ext)) { - name = name.substring(0, name.length() - ext.length()); - } - } - return context.getRuntime().newString(name).infectBy(args[0]); - } - - @JRubyMethod(required = 2, rest = true, meta = true) - public static IRubyObject chmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - int count = 0; - RubyInteger mode = args[0].convertToInteger(); - for (int i = 1; i < args.length; i++) { - IRubyObject filename = args[i]; - - if (!RubyFileTest.exist_p(filename, filename.convertToString()).isTrue()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + filename); - } - - boolean result = 0 == runtime.getPosix().chmod(filename.toString(), (int)mode.getLongValue()); - if (result) { - count++; - } - } - - return runtime.newFixnum(count); - } - - @JRubyMethod(required = 3, rest = true, meta = true) - public static IRubyObject chown(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - int count = 0; - int owner = -1; - if (!args[0].isNil()) { - owner = RubyNumeric.num2int(args[0]); - } - - int group = -1; - if (!args[1].isNil()) { - group = RubyNumeric.num2int(args[1]); - } - for (int i = 2; i < args.length; i++) { - IRubyObject filename = args[i]; - - if (!RubyFileTest.exist_p(filename, filename.convertToString()).isTrue()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + filename); - } - - boolean result = 0 == runtime.getPosix().chown(filename.toString(), owner, group); - if (result) { - count++; - } - } - - return runtime.newFixnum(count); - } - - @JRubyMethod(required = 1, meta = true) - public static IRubyObject dirname(ThreadContext context, IRubyObject recv, IRubyObject arg) { - RubyString filename = RubyString.stringValue(arg); - String jfilename = filename.toString(); - String name = jfilename.replace('\\', '/'); - int minPathLength = 1; - boolean trimmedSlashes = false; - - boolean startsWithDriveLetterOnWindows = startsWithDriveLetterOnWindows(name); - - if (startsWithDriveLetterOnWindows) { - minPathLength = 3; - } - - while (name.length() > minPathLength && name.charAt(name.length() - 1) == '/') { - trimmedSlashes = true; - name = name.substring(0, name.length() - 1); - } - - String result; - if (startsWithDriveLetterOnWindows && name.length() == 2) { - if (trimmedSlashes) { - // C:\ is returned unchanged - result = jfilename.substring(0, 3); - } else { - result = jfilename.substring(0, 2) + '.'; - } - } else { - //TODO deal with UNC names - int index = name.lastIndexOf('/'); - if (index == -1) { - if (startsWithDriveLetterOnWindows) { - return context.getRuntime().newString(jfilename.substring(0, 2) + "."); - } else { - return context.getRuntime().newString("."); - } - } - if (index == 0) return context.getRuntime().newString("/"); - - if (startsWithDriveLetterOnWindows && index == 2) { - // Include additional path separator - // (so that dirname of "C:\file.txt" is "C:\", not "C:") - index++; - } - - result = jfilename.substring(0, index); - } - - char endChar; - // trim trailing slashes - while (result.length() > minPathLength) { - endChar = result.charAt(result.length() - 1); - if (endChar == '/' || endChar == '\\') { - result = result.substring(0, result.length() - 1); - } else { - break; - } - } - - return context.getRuntime().newString(result).infectBy(filename); - } - - private static boolean isWindowsDriveLetter(char c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); - } - - - /** - * Returns the extension name of the file. An empty string is returned if - * the filename (not the entire path) starts or ends with a dot. - * @param recv - * @param arg Path to get extension name of - * @return Extension, including the dot, or an empty string - */ - @JRubyMethod(required = 1, meta = true) - public static IRubyObject extname(ThreadContext context, IRubyObject recv, IRubyObject arg) { - IRubyObject baseFilename = basename(context, recv, new IRubyObject[]{arg}); - String filename = RubyString.stringValue(baseFilename).toString(); - String result = ""; - - int dotIndex = filename.lastIndexOf("."); - if (dotIndex > 0 && dotIndex != (filename.length() - 1)) { - // Dot is not at beginning and not at end of filename. - result = filename.substring(dotIndex); - } - - return context.getRuntime().newString(result); - } - - /** - * Converts a pathname to an absolute pathname. Relative paths are - * referenced from the current working directory of the process unless - * a second argument is given, in which case it will be used as the - * starting point. If the second argument is also relative, it will - * first be converted to an absolute pathname. - * @param recv - * @param args - * @return Resulting absolute path as a String - */ - @JRubyMethod(required = 1, optional = 1, meta = true) - public static IRubyObject expand_path(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - String relativePath = RubyString.stringValue(args[0]).toString(); - - boolean isAbsoluteWithFilePrefix = relativePath.startsWith("file:"); - - String cwd = null; - - // Handle ~user paths - relativePath = expandUserPath(context, relativePath); - - // If there's a second argument, it's the path to which the first - // argument is relative. - if (args.length == 2 && !args[1].isNil()) { - - String cwdArg = RubyString.stringValue(args[1]).toString(); - - // Handle ~user paths. - cwd = expandUserPath(context, cwdArg); - - cwd = adjustRootPathOnWindows(runtime, cwd, null); - - boolean startsWithSlashNotOnWindows = (cwd != null) - && !Platform.IS_WINDOWS && cwd.length() > 0 - && cwd.charAt(0) == '/'; - - // TODO: better detection when path is absolute or not. - // If the path isn't absolute, then prepend the current working - // directory to the path. - if (!startsWithSlashNotOnWindows && !startsWithDriveLetterOnWindows(cwd)) { - cwd = new File(runtime.getCurrentDirectory(), cwd).getAbsolutePath(); - } - } else { - // If there's no second argument, simply use the working directory - // of the runtime. - cwd = runtime.getCurrentDirectory(); - } - - // Something wrong we don't know the cwd... - // TODO: Is this behavior really desirable? /mov - if (cwd == null) return runtime.getNil(); - - /* The counting of slashes that follows is simply a way to adhere to - * Ruby's UNC (or something) compatibility. When Ruby's expand_path is - * called with "//foo//bar" it will return "//foo/bar". JRuby uses - * java.io.File, and hence returns "/foo/bar". In order to retain - * java.io.File in the lower layers and provide full Ruby - * compatibility, the number of extra slashes must be counted and - * prepended to the result. - */ - - // TODO: special handling on windows for some corner cases -// if (IS_WINDOWS) { -// if (relativePath.startsWith("//")) { -// if (relativePath.length() > 2 && relativePath.charAt(2) != '/') { -// int nextSlash = relativePath.indexOf('/', 3); -// if (nextSlash != -1) { -// return runtime.newString( -// relativePath.substring(0, nextSlash) -// + canonicalize(relativePath.substring(nextSlash))); -// } else { -// return runtime.newString(relativePath); -// } -// } -// } -// } - - // Find out which string to check. - String padSlashes = ""; - if (!Platform.IS_WINDOWS) { - if (relativePath.length() > 0 && relativePath.charAt(0) == '/') { - padSlashes = countSlashes(relativePath); - } else if (cwd.length() > 0 && cwd.charAt(0) == '/') { - padSlashes = countSlashes(cwd); - } - } - - JRubyFile path; - - if (relativePath.length() == 0) { - path = JRubyFile.create(relativePath, cwd); - } else { - relativePath = adjustRootPathOnWindows(runtime, relativePath, cwd); - path = JRubyFile.create(cwd, relativePath); - } - - String tempResult = padSlashes + canonicalize(path.getAbsolutePath()); - - if(isAbsoluteWithFilePrefix) { - tempResult = tempResult.substring(tempResult.indexOf("file:")); - } - - return runtime.newString(tempResult); - } - - /** - * This method checks a path, and if it starts with ~, then it expands - * the path to the absolute path of the user's home directory. If the - * string does not begin with ~, then the string is simply returned. - * unaltered. - * @param recv - * @param path Path to check - * @return Expanded path - */ - public static String expandUserPath(ThreadContext context, String path) { - - int pathLength = path.length(); - - if (pathLength >= 1 && path.charAt(0) == '~') { - // Enebo : Should ~frogger\\foo work (it doesnt in linux ruby)? - int userEnd = path.indexOf('/'); - - if (userEnd == -1) { - if (pathLength == 1) { - // Single '~' as whole path to expand - path = RubyDir.getHomeDirectoryPath(context).toString(); - } else { - // No directory delimeter. Rest of string is username - userEnd = pathLength; - } - } - - if (userEnd == 1) { - // '~/...' as path to expand - path = RubyDir.getHomeDirectoryPath(context).toString() + - path.substring(1); - } else if (userEnd > 1){ - // '~user/...' as path to expand - String user = path.substring(1, userEnd); - IRubyObject dir = RubyDir.getHomeDirectoryPath(context, user); - - if (dir.isNil()) { - throw context.getRuntime().newArgumentError("user " + user + " does not exist"); - } - - path = "" + dir + (pathLength == userEnd ? "" : path.substring(userEnd)); - } - } - return path; - } - - /** - * Returns a string consisting of <code>n-1</code> slashes, where - * <code>n</code> is the number of slashes at the beginning of the input - * string. - * @param stringToCheck - * @return - */ - private static String countSlashes( String stringToCheck ) { - - // Count number of extra slashes in the beginning of the string. - int slashCount = 0; - for (int i = 0; i < stringToCheck.length(); i++) { - if (stringToCheck.charAt(i) == '/') { - slashCount++; - } else { - break; - } - } - - // If there are N slashes, then we want N-1. - if (slashCount > 0) { - slashCount--; - } - - // Prepare a string with the same number of redundant slashes so that - // we easily can prepend it to the result. - byte[] slashes = new byte[slashCount]; - for (int i = 0; i < slashCount; i++) { - slashes[i] = '/'; - } - return new String(slashes); - - } - - private static String canonicalize(String path) { - return canonicalize(null, path); - } - - private static String canonicalize(String canonicalPath, String remaining) { - if (remaining == null) { - if ("".equals(canonicalPath)) { - return "/"; - } else { - // compensate for missing slash after drive letter on windows - if (startsWithDriveLetterOnWindows(canonicalPath) - && canonicalPath.length() == 2) { - canonicalPath += "/"; - } - } - return canonicalPath; - } - - String child; - int slash = remaining.indexOf('/'); - if (slash == -1) { - child = remaining; - remaining = null; - } else { - child = remaining.substring(0, slash); - remaining = remaining.substring(slash + 1); - } - - if (child.equals(".")) { - // skip it - if (canonicalPath != null && canonicalPath.length() == 0 ) canonicalPath += "/"; - } else if (child.equals("..")) { - if (canonicalPath == null) throw new IllegalArgumentException("Cannot have .. at the start of an absolute path"); - int lastDir = canonicalPath.lastIndexOf('/'); - if (lastDir == -1) { - if (startsWithDriveLetterOnWindows(canonicalPath)) { - // do nothing, we should not delete the drive letter - } else { - canonicalPath = ""; - } - } else { - canonicalPath = canonicalPath.substring(0, lastDir); - } - } else if (canonicalPath == null) { - canonicalPath = child; - } else { - canonicalPath += "/" + child; - } - - return canonicalize(canonicalPath, remaining); - } - - /** - * Returns true if path matches against pattern The pattern is not a regular expression; - * instead it follows rules similar to shell filename globbing. It may contain the following - * metacharacters: - * *: Glob - match any sequence chars (re: .*). If like begins with '.' then it doesn't. - * ?: Matches a single char (re: .). - * [set]: Matches a single char in a set (re: [...]). - * - */ - @JRubyMethod(name = {"fnmatch", "fnmatch?"}, required = 2, optional = 1, meta = true) - public static IRubyObject fnmatch(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - int flags = args.length == 3 ? RubyNumeric.num2int(args[2]) : 0; - - ByteList pattern = args[0].convertToString().getByteList(); - ByteList path = args[1].convertToString().getByteList(); - - if (org.jruby.util.Dir.fnmatch(pattern.bytes, pattern.begin, pattern.begin+pattern.realSize, - path.bytes, path.begin, path.begin+path.realSize, flags) == 0) { - return context.getRuntime().getTrue(); - } - return context.getRuntime().getFalse(); - } - - @JRubyMethod(name = "ftype", required = 1, meta = true) - public static IRubyObject ftype(ThreadContext context, IRubyObject recv, IRubyObject filename) { - return context.getRuntime().newFileStat(filename.convertToString().toString(), true).ftype(); - } - - private static String inspectJoin(ThreadContext context, IRubyObject recv, RubyArray parent, RubyArray array) { - Ruby runtime = context.getRuntime(); - - // If already inspecting, there is no need to register/unregister again. - if (runtime.isInspecting(parent)) return join(context, recv, array).toString(); - - try { - runtime.registerInspecting(parent); - return join(context, recv, array).toString(); - } finally { - runtime.unregisterInspecting(parent); - } - } - - private static RubyString join(ThreadContext context, IRubyObject recv, RubyArray ary) { - IRubyObject[] args = ary.toJavaArray(); - boolean isTainted = false; - StringBuilder buffer = new StringBuilder(); - Ruby runtime = context.getRuntime(); - - for (int i = 0; i < args.length; i++) { - if (args[i].isTaint()) { - isTainted = true; - } - String element; - if (args[i] instanceof RubyString) { - element = args[i].toString(); - } else if (args[i] instanceof RubyArray) { - if (runtime.isInspecting(args[i])) { - element = "[...]"; - } else { - element = inspectJoin(context, recv, ary, ((RubyArray)args[i])); - } - } else { - element = args[i].convertToString().toString(); - } - - chomp(buffer); - if (i > 0 && !element.startsWith("/") && !element.startsWith("\\")) { - buffer.append("/"); - } - buffer.append(element); - } - - RubyString fixedStr = RubyString.newString(runtime, buffer.toString()); - fixedStr.setTaint(isTainted); - return fixedStr; - } - - /* - * Fixme: This does not have exact same semantics as RubyArray.join, but they - * probably could be consolidated (perhaps as join(args[], sep, doChomp)). - */ - @JRubyMethod(rest = true, meta = true) - public static RubyString join(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return join(context, recv, RubyArray.newArrayNoCopyLight(context.getRuntime(), args)); - } - - private static void chomp(StringBuilder buffer) { - int lastIndex = buffer.length() - 1; - - while (lastIndex >= 0 && (buffer.lastIndexOf("/") == lastIndex || buffer.lastIndexOf("\\") == lastIndex)) { - buffer.setLength(lastIndex); - lastIndex--; - } - } - - @JRubyMethod(name = "lstat", required = 1, meta = true) - public static IRubyObject lstat(ThreadContext context, IRubyObject recv, IRubyObject filename) { - String f = filename.convertToString().toString(); - if(f.startsWith("file:") && f.indexOf('!') != -1) { - f = f.substring(5, f.indexOf("!")); - } - return context.getRuntime().newFileStat(f, true); - } - - @JRubyMethod(name = "stat", required = 1, meta = true) - public static IRubyObject stat(ThreadContext context, IRubyObject recv, IRubyObject filename) { - String f = filename.convertToString().toString(); - if(f.startsWith("file:") && f.indexOf('!') != -1) { - f = f.substring(5, f.indexOf("!")); - } - return context.getRuntime().newFileStat(f, false); - } - - @JRubyMethod(name = "atime", required = 1, meta = true) - public static IRubyObject atime(ThreadContext context, IRubyObject recv, IRubyObject filename) { - String f = filename.convertToString().toString(); - if(f.startsWith("file:") && f.indexOf('!') != -1) { - f = f.substring(5, f.indexOf("!")); - } - return context.getRuntime().newFileStat(f, false).atime(); - } - - @JRubyMethod(name = "ctime", required = 1, meta = true) - public static IRubyObject ctime(ThreadContext context, IRubyObject recv, IRubyObject filename) { - String f = filename.convertToString().toString(); - if(f.startsWith("file:") && f.indexOf('!') != -1) { - f = f.substring(5, f.indexOf("!")); - } - return context.getRuntime().newFileStat(f, false).ctime(); - } - - @JRubyMethod(required = 2, rest = true, meta = true) - public static IRubyObject lchmod(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - int count = 0; - RubyInteger mode = args[0].convertToInteger(); - for (int i = 1; i < args.length; i++) { - IRubyObject filename = args[i]; - - if (!RubyFileTest.exist_p(filename, filename.convertToString()).isTrue()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + filename); - } - - boolean result = 0 == runtime.getPosix().lchmod(filename.toString(), (int)mode.getLongValue()); - if (result) { - count++; - } - } - - return runtime.newFixnum(count); - } - - @JRubyMethod(required = 3, rest = true, meta = true) - public static IRubyObject lchown(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - int owner = !args[0].isNil() ? RubyNumeric.num2int(args[0]) : -1; - int group = !args[1].isNil() ? RubyNumeric.num2int(args[1]) : -1; - int count = 0; - - for (int i = 2; i < args.length; i++) { - IRubyObject filename = args[i]; - - if (!RubyFileTest.exist_p(filename, filename.convertToString()).isTrue()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + filename); - } - - boolean result = 0 == runtime.getPosix().lchown(filename.toString(), owner, group); - if (result) { - count++; - } - } - - return runtime.newFixnum(count); - } - - @JRubyMethod(required = 2, meta = true) - public static IRubyObject link(ThreadContext context, IRubyObject recv, IRubyObject from, IRubyObject to) { - Ruby runtime = context.getRuntime(); - RubyString fromStr = RubyString.stringValue(from); - RubyString toStr = RubyString.stringValue(to); - try { - if (runtime.getPosix().link( - fromStr.toString(),toStr.toString()) == -1) { - // FIXME: When we get JNA3 we need to properly write this to errno. - throw runtime.newErrnoEEXISTError("File exists - " - + fromStr + " or " + toStr); - } - } catch (java.lang.UnsatisfiedLinkError ule) { - throw runtime.newNotImplementedError("link() function is unimplemented on this machine"); - } - - return runtime.newFixnum(0); - } - - @JRubyMethod(name = "mtime", required = 1, meta = true) - public static IRubyObject mtime(ThreadContext context, IRubyObject recv, IRubyObject filename) { - return getLastModified(context.getRuntime(), filename.convertToString().toString()); - } - - @JRubyMethod(required = 2, meta = true) - public static IRubyObject rename(ThreadContext context, IRubyObject recv, IRubyObject oldName, IRubyObject newName) { - Ruby runtime = context.getRuntime(); - RubyString oldNameString = RubyString.stringValue(oldName); - RubyString newNameString = RubyString.stringValue(newName); - runtime.checkSafeString(oldNameString); - runtime.checkSafeString(newNameString); - JRubyFile oldFile = JRubyFile.create(runtime.getCurrentDirectory(), oldNameString.toString()); - JRubyFile newFile = JRubyFile.create(runtime.getCurrentDirectory(), newNameString.toString()); - - if (!oldFile.exists() || !newFile.getParentFile().exists()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + oldNameString + - " or " + newNameString); - } - - JRubyFile dest = JRubyFile.create(runtime.getCurrentDirectory(), newNameString.toString()); - - if (oldFile.renameTo(dest)) { // rename is successful - return RubyFixnum.zero(runtime); - } - - // rename via Java API call wasn't successful, let's try some tricks, similar to MRI - - if (newFile.exists()) { - runtime.getPosix().chmod(newNameString.toString(), 0666); - newFile.delete(); - } - - if (oldFile.renameTo(dest)) { // try to rename one more time - return RubyFixnum.zero(runtime); - } - - throw runtime.newErrnoEACCESError("Permission denied - " + oldNameString + " or " + - newNameString); - } - - @JRubyMethod(required = 1, meta = true) - public static RubyArray split(ThreadContext context, IRubyObject recv, IRubyObject arg) { - RubyString filename = RubyString.stringValue(arg); - - return context.getRuntime().newArray(dirname(context, recv, filename), - basename(context, recv, new IRubyObject[] { filename })); - } - - @JRubyMethod(required = 2, meta = true) - public static IRubyObject symlink(ThreadContext context, IRubyObject recv, IRubyObject from, IRubyObject to) { - Ruby runtime = context.getRuntime(); - RubyString fromStr = RubyString.stringValue(from); - RubyString toStr = RubyString.stringValue(to); - try { - if (runtime.getPosix().symlink( - fromStr.toString(), toStr.toString()) == -1) { - // FIXME: When we get JNA3 we need to properly write this to errno. - throw runtime.newErrnoEEXISTError("File exists - " - + fromStr + " or " + toStr); - } - } catch (java.lang.UnsatisfiedLinkError ule) { - throw runtime.newNotImplementedError("symlink() function is unimplemented on this machine"); - } - - return runtime.newFixnum(0); - } - - @JRubyMethod(required = 1, meta = true) - public static IRubyObject readlink(ThreadContext context, IRubyObject recv, IRubyObject path) { - Ruby runtime = context.getRuntime(); - - try { - String realPath = runtime.getPosix().readlink(path.toString()); - - if (!RubyFileTest.exist_p(recv, path).isTrue()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + path); - } - - if (!RubyFileTest.symlink_p(recv, path).isTrue()) { - throw runtime.newErrnoEINVALError("invalid argument - " + path); - } - - if (realPath == null) { - //FIXME: When we get JNA3 we need to properly write this to errno. - } - - return runtime.newString(realPath); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - // Can we produce IOError which bypasses a close? - @JRubyMethod(required = 2, meta = true) - public static IRubyObject truncate(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { - Ruby runtime = context.getRuntime(); - RubyString filename = arg1.convertToString(); // TODO: SafeStringValue here - RubyInteger newLength = arg2.convertToInteger(); - - if (!new File(runtime.getCurrentDirectory(), filename.getByteList().toString()).exists()) { - throw runtime.newErrnoENOENTError( - "No such file or directory - " + filename.getByteList().toString()); - } - - if (newLength.getLongValue() < 0) { - throw runtime.newErrnoEINVALError("invalid argument: " + filename); - } - - IRubyObject[] args = new IRubyObject[] { filename, runtime.newString("r+") }; - RubyFile file = (RubyFile) open(context, recv, args, Block.NULL_BLOCK); - file.truncate(context, newLength); - file.close(); - - return RubyFixnum.zero(runtime); - } - - @JRubyMethod(meta = true, optional = 1) - public static IRubyObject umask(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - int oldMask = 0; - if (args.length == 0) { - oldMask = runtime.getPosix().umask(0); - runtime.getPosix().umask(oldMask); - } else if (args.length == 1) { - oldMask = runtime.getPosix().umask((int) args[0].convertToInteger().getLongValue()); - } else { - runtime.newArgumentError("wrong number of arguments"); - } - - return runtime.newFixnum(oldMask); - } - - /** - * This method does NOT set atime, only mtime, since Java doesn't support anything else. - */ - @JRubyMethod(required = 2, rest = true, meta = true) - public static IRubyObject utime(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - // Ignore access_time argument since Java does not support it. - - long mtime; - if (args[1] instanceof RubyTime) { - mtime = ((RubyTime) args[1]).getJavaDate().getTime(); - } else if (args[1] instanceof RubyNumeric) { - mtime = RubyNumeric.num2long(args[1]); - } else if (args[1] == runtime.getNil()) { - mtime = System.currentTimeMillis(); - } else { - RubyTime time = (RubyTime) TypeConverter.convertToType(args[1], runtime.getTime(), MethodIndex.NO_INDEX,"to_time", true); - mtime = time.getJavaDate().getTime(); - } - - for (int i = 2, j = args.length; i < j; i++) { - RubyString filename = RubyString.stringValue(args[i]); - runtime.checkSafeString(filename); - JRubyFile fileToTouch = JRubyFile.create(runtime.getCurrentDirectory(),filename.toString()); - - if (!fileToTouch.exists()) { - throw runtime.newErrnoENOENTError(" No such file or directory - \"" + filename + "\""); - } - - fileToTouch.setLastModified(mtime); - } - - return runtime.newFixnum(args.length - 2); - } - - @JRubyMethod(name = {"unlink", "delete"}, rest = true, meta = true) - public static IRubyObject unlink(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - for (int i = 0; i < args.length; i++) { - RubyString filename = RubyString.stringValue(args[i]); - runtime.checkSafeString(filename); - JRubyFile lToDelete = JRubyFile.create(runtime.getCurrentDirectory(),filename.toString()); - - boolean isSymlink = RubyFileTest.symlink_p(recv, filename).isTrue(); - // Broken symlinks considered by exists() as non-existing, - // so we need to check for symlinks explicitly. - if (!lToDelete.exists() && !isSymlink) { - throw runtime.newErrnoENOENTError(" No such file or directory - \"" + filename + "\""); - } - - if (!lToDelete.delete()) { - throw runtime.newErrnoEACCESError("Permission denied - \"" + filename + "\""); - } - } - - return runtime.newFixnum(args.length); - } - - // Fast path since JNA stat is about 10x slower than this - private static IRubyObject getLastModified(Ruby runtime, String path) { - JRubyFile file = JRubyFile.create(runtime.getCurrentDirectory(), path); - - if (!file.exists()) { - throw runtime.newErrnoENOENTError("No such file or directory - " + path); - } - - return runtime.newTime(file.lastModified()); - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.FileDescriptor; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.ext.posix.FileStat; -import org.jruby.ext.posix.util.Platform; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.JRubyFile; - -/** - * Implements File::Stat - */ -@JRubyClass(name="File::Stat", include="Comparable") -public class RubyFileStat extends RubyObject { - private static final long serialVersionUID = 1L; - - private JRubyFile file; - private FileStat stat; - - private static ObjectAllocator ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyFileStat(runtime, klass); - } - }; - - public static RubyClass createFileStatClass(Ruby runtime) { - // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415 - final RubyClass fileStatClass = runtime.getFile().defineClassUnder("Stat",runtime.getObject(), ALLOCATOR); - runtime.setFileStat(fileStatClass); - - fileStatClass.includeModule(runtime.fastGetModule("Comparable")); - fileStatClass.defineAnnotatedMethods(RubyFileStat.class); - - return fileStatClass; - } - - protected RubyFileStat(Ruby runtime, RubyClass clazz) { - super(runtime, clazz); - - } - - public static RubyFileStat newFileStat(Ruby runtime, String filename, boolean lstat) { - RubyFileStat stat = new RubyFileStat(runtime, runtime.getFileStat()); - - stat.setup(filename, lstat); - - return stat; - } - - public static RubyFileStat newFileStat(Ruby runtime, FileDescriptor descriptor) { - RubyFileStat stat = new RubyFileStat(runtime, runtime.getFileStat()); - - stat.setup(descriptor); - - return stat; - } - - private void setup(FileDescriptor descriptor) { - stat = getRuntime().getPosix().fstat(descriptor); - } - - private void setup(String filename, boolean lstat) { - if (Platform.IS_WINDOWS && filename.length() == 2 - && filename.charAt(1) == ':' && Character.isLetter(filename.charAt(0))) { - filename += "/"; - } - - file = JRubyFile.create(getRuntime().getCurrentDirectory(), filename); - - if (lstat) { - stat = getRuntime().getPosix().lstat(file.getAbsolutePath()); - } else { - stat = getRuntime().getPosix().stat(file.getAbsolutePath()); - } - } - - @JRubyMethod(name = "initialize", required = 1, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject fname, Block unusedBlock) { - setup(fname.convertToString().toString(), false); - - return this; - } - - @JRubyMethod(name = "atime") - public IRubyObject atime() { - return getRuntime().newTime(stat.atime() * 1000); - } - - @JRubyMethod(name = "blksize") - public RubyFixnum blksize() { - return getRuntime().newFixnum(stat.blockSize()); - } - - @JRubyMethod(name = "blockdev?") - public IRubyObject blockdev_p() { - return getRuntime().newBoolean(stat.isBlockDev()); - } - - @JRubyMethod(name = "blocks") - public IRubyObject blocks() { - return getRuntime().newFixnum(stat.blocks()); - } - - @JRubyMethod(name = "chardev?") - public IRubyObject chardev_p() { - return getRuntime().newBoolean(stat.isCharDev()); - } - - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject cmp(IRubyObject other) { - if (!(other instanceof RubyFileStat)) getRuntime().getNil(); - - long time1 = stat.mtime(); - long time2 = ((RubyFileStat) other).stat.mtime(); - - if (time1 == time2) { - return getRuntime().newFixnum(0); - } else if (time1 < time2) { - return getRuntime().newFixnum(-1); - } - - return getRuntime().newFixnum(1); - } - - @JRubyMethod(name = "ctime") - public IRubyObject ctime() { - return getRuntime().newTime(stat.ctime() * 1000); - } - - @JRubyMethod(name = "dev") - public IRubyObject dev() { - return getRuntime().newFixnum(stat.dev()); - } - - @JRubyMethod(name = "dev_major") - public IRubyObject devMajor() { - return getRuntime().newFixnum(stat.major(stat.dev())); - } - - @JRubyMethod(name = "dev_minor") - public IRubyObject devMinor() { - return getRuntime().newFixnum(stat.minor(stat.dev())); - } - - @JRubyMethod(name = "directory?") - public RubyBoolean directory_p() { - return getRuntime().newBoolean(stat.isDirectory()); - } - - @JRubyMethod(name = "executable?") - public IRubyObject executable_p() { - return getRuntime().newBoolean(stat.isExecutable()); - } - - @JRubyMethod(name = "executable_real?") - public IRubyObject executableReal_p() { - return getRuntime().newBoolean(stat.isExecutableReal()); - } - - @JRubyMethod(name = "file?") - public RubyBoolean file_p() { - return getRuntime().newBoolean(stat.isFile()); - } - - @JRubyMethod(name = "ftype") - public RubyString ftype() { - return getRuntime().newString(stat.ftype()); - } - - @JRubyMethod(name = "gid") - public IRubyObject gid() { - return getRuntime().newFixnum(stat.gid()); - } - - @JRubyMethod(name = "grpowned?") - public IRubyObject group_owned_p() { - return getRuntime().newBoolean(stat.isGroupOwned()); - } - - @JRubyMethod(name = "initialize_copy", required = 1) - public IRubyObject initialize_copy(IRubyObject original) { - if (!(original instanceof RubyFileStat)) { - throw getRuntime().newTypeError("wrong argument class"); - } - - RubyFileStat originalFileStat = (RubyFileStat) original; - - file = originalFileStat.file; - stat = originalFileStat.stat; - - return this; - } - - @JRubyMethod(name = "ino") - public IRubyObject ino() { - return getRuntime().newFixnum(stat.ino()); - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - StringBuilder buf = new StringBuilder("#<"); - buf.append(getMetaClass().getRealClass().getName()); - buf.append(" "); - // FIXME: Obvious issue that not all platforms can display all attributes. Ugly hacks. - // Using generic posix library makes pushing inspect behavior into specific system impls - // rather painful. - try { buf.append("dev=0x").append(Long.toHexString(stat.dev())).append(", "); } catch (Exception e) {} - try { buf.append("ino=").append(stat.ino()).append(", "); } catch (Exception e) {} - buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); - try { buf.append("nlink=").append(stat.nlink()).append(", "); } catch (Exception e) {} - try { buf.append("uid=").append(stat.uid()).append(", "); } catch (Exception e) {} - try { buf.append("gid=").append(stat.gid()).append(", "); } catch (Exception e) {} - try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())).append(", "); } catch (Exception e) {} - buf.append("size=").append(stat.st_size()).append(", "); - try { buf.append("blksize=").append(stat.blockSize()).append(", "); } catch (Exception e) {} - try { buf.append("blocks=").append(stat.blocks()).append(", "); } catch (Exception e) {} - - buf.append("atime=").append(atime()).append(", "); - buf.append("mtime=").append(mtime()).append(", "); - buf.append("ctime=").append(ctime()); - buf.append(">"); - - return getRuntime().newString(buf.toString()); - } - - @JRubyMethod(name = "uid") - public IRubyObject uid() { - return getRuntime().newFixnum(stat.uid()); - } - - @JRubyMethod(name = "mode") - public IRubyObject mode() { - return getRuntime().newFixnum(stat.mode()); - } - - @JRubyMethod(name = "mtime") - public IRubyObject mtime() { - return getRuntime().newTime(stat.mtime() * 1000); - } - - public IRubyObject mtimeEquals(IRubyObject other) { - return getRuntime().newBoolean(stat.mtime() == newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime()); - } - - public IRubyObject mtimeGreaterThan(IRubyObject other) { - return getRuntime().newBoolean(stat.mtime() > newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime()); - } - - public IRubyObject mtimeLessThan(IRubyObject other) { - return getRuntime().newBoolean(stat.mtime() < newFileStat(getRuntime(), other.convertToString().toString(), false).stat.mtime()); - } - - @JRubyMethod(name = "nlink") - public IRubyObject nlink() { - return getRuntime().newFixnum(stat.nlink()); - } - - @JRubyMethod(name = "owned?") - public IRubyObject owned_p() { - return getRuntime().newBoolean(stat.isOwned()); - } - - @JRubyMethod(name = "pipe?") - public IRubyObject pipe_p() { - return getRuntime().newBoolean(stat.isNamedPipe()); - } - - @JRubyMethod(name = "rdev") - public IRubyObject rdev() { - return getRuntime().newFixnum(stat.rdev()); - } - - @JRubyMethod(name = "rdev_major") - public IRubyObject rdevMajor() { - return getRuntime().newFixnum(stat.major(stat.rdev())); - } - - @JRubyMethod(name = "rdev_minor") - public IRubyObject rdevMinor() { - return getRuntime().newFixnum(stat.minor(stat.rdev())); - } - - @JRubyMethod(name = "readable?") - public IRubyObject readable_p() { - return getRuntime().newBoolean(stat.isReadable()); - } - - @JRubyMethod(name = "readable_real?") - public IRubyObject readableReal_p() { - return getRuntime().newBoolean(stat.isReadableReal()); - } - - @JRubyMethod(name = "setgid?") - public IRubyObject setgid_p() { - return getRuntime().newBoolean(stat.isSetgid()); - } - - @JRubyMethod(name = "setuid?") - public IRubyObject setuid_p() { - return getRuntime().newBoolean(stat.isSetuid()); - } - - @JRubyMethod(name = "size") - public IRubyObject size() { - return getRuntime().newFixnum(stat.st_size()); - } - - @JRubyMethod(name = "size?") - public IRubyObject size_p() { - long size = stat.st_size(); - - if (size == 0) return getRuntime().getNil(); - - return getRuntime().newFixnum(size); - } - - @JRubyMethod(name = "socket?") - public IRubyObject socket_p() { - return getRuntime().newBoolean(stat.isSocket()); - } - - @JRubyMethod(name = "sticky?") - public IRubyObject sticky_p() { - return getRuntime().newBoolean(stat.isSticky()); - } - - @JRubyMethod(name = "symlink?") - public IRubyObject symlink_p() { - return getRuntime().newBoolean(stat.isSymlink()); - } - - @JRubyMethod(name = "writable?") - public IRubyObject writable_p() { - return getRuntime().newBoolean(stat.isWritable()); - } - - @JRubyMethod(name = "writable_real?") - public IRubyObject writableReal_p() { - return getRuntime().newBoolean(stat.isWritableReal()); - } - - @JRubyMethod(name = "zero?") - public IRubyObject zero_p() { - return getRuntime().newBoolean(stat.isEmpty()); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.exceptions.RaiseException; - -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.JRubyFile; - -@JRubyModule(name="FileTest") -public class RubyFileTest { - public static RubyModule createFileTestModule(Ruby runtime) { - RubyModule fileTestModule = runtime.defineModule("FileTest"); - runtime.setFileTest(fileTestModule); - - fileTestModule.defineAnnotatedMethods(RubyFileTest.class); - - return fileTestModule; - } - - @JRubyMethod(name = "blockdev?", required = 1, module = true) - public static IRubyObject blockdev_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isBlockDev()); - } - - @JRubyMethod(name = "chardev?", required = 1, module = true) - public static IRubyObject chardev_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isCharDev()); - } - - @JRubyMethod(name = "directory?", required = 1, module = true) - public static IRubyObject directory_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isDirectory()); - } - - @JRubyMethod(name = "executable?", required = 1, module = true) - public static IRubyObject executable_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutable()); - } - - @JRubyMethod(name = "executable_real?", required = 1, module = true) - public static IRubyObject executable_real_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isExecutableReal()); - } - - @JRubyMethod(name = {"exist?", "exists?"}, required = 1, module = true) - public static IRubyObject exist_p(IRubyObject recv, IRubyObject filename) { - if (Ruby.isSecurityRestricted()) { - return recv.getRuntime().getFalse(); - } - - if(filename.convertToString().toString().startsWith("file:")) { - String file = filename.convertToString().toString().substring(5); - int bang = file.indexOf('!'); - if (bang == -1 || bang == file.length() - 1) { - return recv.getRuntime().getFalse(); - } - String jar = file.substring(0, bang); - String after = file.substring(bang + 2); - try { - java.util.jar.JarFile jf = new java.util.jar.JarFile(jar); - if(jf.getJarEntry(after) != null) { - return recv.getRuntime().getTrue(); - } else { - return recv.getRuntime().getFalse(); - } - } catch(Exception e) { - return recv.getRuntime().getFalse(); - } - } - - return recv.getRuntime().newBoolean(file(filename).exists()); - } - - @JRubyMethod(name = "file?", required = 1, module = true) - public static RubyBoolean file_p(IRubyObject recv, IRubyObject filename) { - JRubyFile file = file(filename); - - return filename.getRuntime().newBoolean(file.exists() && file.isFile()); - } - - @JRubyMethod(name = "grpowned?", required = 1, module = true) - public static IRubyObject grpowned_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isGroupOwned()); - } - - @JRubyMethod(name = "identical?", required = 2, module = true) - public static IRubyObject identical_p(IRubyObject recv, IRubyObject filename1, IRubyObject filename2) { - Ruby runtime = recv.getRuntime(); - JRubyFile file1 = file(filename1); - JRubyFile file2 = file(filename2); - - return runtime.newBoolean(file1.exists() && file2.exists() && - runtime.getPosix().stat(file1.getAbsolutePath()).isIdentical(runtime.getPosix().stat(file2.getAbsolutePath()))); - } - - @JRubyMethod(name = "owned?", required = 1, module = true) - public static IRubyObject owned_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isOwned()); - } - - @JRubyMethod(name = "pipe?", required = 1, module = true) - public static IRubyObject pipe_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isNamedPipe()); - } - - // We use file test since it is faster than a stat; also euid == uid in Java always - @JRubyMethod(name = {"readable?", "readable_real?"}, required = 1, module = true) - public static IRubyObject readable_p(IRubyObject recv, IRubyObject filename) { - JRubyFile file = file(filename); - - return recv.getRuntime().newBoolean(file.exists() && file.canRead()); - } - - // Not exposed by filetest, but so similiar in nature that it is stored here - public static IRubyObject rowned_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isROwned()); - } - - @JRubyMethod(name = "setgid?", required = 1, module = true) - public static IRubyObject setgid_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetgid()); - } - - @JRubyMethod(name = "setuid?", required = 1, module = true) - public static IRubyObject setuid_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSetuid()); - } - - @JRubyMethod(name = "size", required = 1, module = true) - public static IRubyObject size(IRubyObject recv, IRubyObject filename) { - JRubyFile file = file(filename); - - if (!file.exists()) noFileError(filename); - - return recv.getRuntime().newFixnum(file.length()); - } - - @JRubyMethod(name = "size?", required = 1, module = true) - public static IRubyObject size_p(IRubyObject recv, IRubyObject filename) { - JRubyFile file = file(filename); - - if (!file.exists()) { - return recv.getRuntime().getNil(); - } - - long length = file.length(); - if (length > 0) { - return recv.getRuntime().newFixnum(length); - } else { - return recv.getRuntime().getNil(); - } - } - - @JRubyMethod(name = "socket?", required = 1, module = true) - public static IRubyObject socket_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSocket()); - } - - @JRubyMethod(name = "sticky?", required = 1, module = true) - public static IRubyObject sticky_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - return runtime.newBoolean(file.exists() && runtime.getPosix().stat(file.getAbsolutePath()).isSticky()); - } - - @JRubyMethod(name = "symlink?", required = 1, module = true) - public static RubyBoolean symlink_p(IRubyObject recv, IRubyObject filename) { - Ruby runtime = recv.getRuntime(); - JRubyFile file = file(filename); - - try { - // Note: We can't use file.exists() to check whether the symlink - // exists or not, because that method returns false for existing - // but broken symlink. So, we try without the existence check, - // but in the try-catch block. - // MRI behavior: symlink? on broken symlink should return true. - return runtime.newBoolean(runtime.getPosix().lstat(file.getAbsolutePath()).isSymlink()); - } catch (RaiseException re) { - return runtime.getFalse(); - } - } - - // We do both writable and writable_real through the same method because - // in our java process effective and real userid will always be the same. - @JRubyMethod(name = {"writable?", "writable_real?"}, required = 1, module = true) - public static RubyBoolean writable_p(IRubyObject recv, IRubyObject filename) { - return filename.getRuntime().newBoolean(file(filename).canWrite()); - } - - @JRubyMethod(name = "zero?", required = 1, module = true) - public static RubyBoolean zero_p(IRubyObject recv, IRubyObject filename) { - JRubyFile file = file(filename); - - return filename.getRuntime().newBoolean(file.exists() && file.length() == 0L); - } - - private static JRubyFile file(IRubyObject path) { - String filename = path.convertToString().toString(); - - return JRubyFile.create(path.getRuntime().getCurrentDirectory(), filename); - } - - private static void noFileError(IRubyObject filename) { - throw filename.getRuntime().newErrnoENOENTError("No such file or directory - " + - filename.convertToString()); - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C) 2006 Antti Karanta <antti.karanta@napa.fi> - * Copyright (C) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.java.MiniJava; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.Convert; -import org.jruby.util.Numeric; -import org.jruby.util.TypeCoercer; - -/** - * Implementation of the Fixnum class. - */ -@JRubyClass(name="Fixnum", parent="Integer", include="Precision") -public class RubyFixnum extends RubyInteger { - - public static RubyClass createFixnumClass(Ruby runtime) { - RubyClass fixnum = runtime.defineClass("Fixnum", runtime.getInteger(), - ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setFixnum(fixnum); - fixnum.index = ClassIndex.FIXNUM; - fixnum.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyFixnum; - } - }; - - fixnum.includeModule(runtime.getPrecision()); - - fixnum.defineAnnotatedMethods(RubyFixnum.class); - - for (int i = 0; i < runtime.fixnumCache.length; i++) { - runtime.fixnumCache[i] = new RubyFixnum(runtime, fixnum, i - 128); - } - - return fixnum; - } - - private final long value; - private static final int BIT_SIZE = 64; - public static final long SIGN_BIT = (1L << (BIT_SIZE - 1)); - public static final long MAX = (1L<<(BIT_SIZE - 1)) - 1; - public static final long MIN = -1 * MAX - 1; - public static final long MAX_MARSHAL_FIXNUM = (1L << 30) - 1; // 0x3fff_ffff - public static final long MIN_MARSHAL_FIXNUM = - (1L << 30); // -0x4000_0000 - - private static IRubyObject fixCoerce(IRubyObject x) { - do { - x = x.convertToInteger(); - } while (!(x instanceof RubyFixnum) && !(x instanceof RubyBignum)); - return x; - } - - public RubyFixnum(Ruby runtime) { - this(runtime, 0); - } - - public RubyFixnum(Ruby runtime, long value) { - super(runtime, runtime.getFixnum(), false); - this.value = value; - } - - private RubyFixnum(Ruby runtime, RubyClass klazz, long value) { - super(runtime, klazz, false); - this.value = value; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.FIXNUM; - } - - /** - * short circuit for Fixnum key comparison - */ - @Override - public final boolean eql(IRubyObject other) { - return other instanceof RubyFixnum && value == ((RubyFixnum)other).value; - } - - @Override - public boolean isImmediate() { - return true; - } - - @Override - public RubyClass getSingletonClass() { - throw getRuntime().newTypeError("can't define singleton"); - } - - @Override - public Class<?> getJavaClass() { - // this precision-guessing needs to be thought out more, since in the - // case of coercing to Object we generally want to get the same type - // always -// if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { -// return byte.class; -// } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { -// return short.class; -// } else if (value >= Character.MIN_VALUE && value <= Character.MAX_VALUE) { -// return char.class; -// } else if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE) { -// return int.class; -// } - return long.class; - } - - @Override - public double getDoubleValue() { - return value; - } - - @Override - public long getLongValue() { - return value; - } - - private static final int CACHE_OFFSET = 128; - - public static RubyFixnum newFixnum(Ruby runtime, long value) { - if (isInCacheRange(value)) { - return runtime.fixnumCache[(int) value + CACHE_OFFSET]; - } - return new RubyFixnum(runtime, value); - } - - private static boolean isInCacheRange(long value) { - return value <= 127 && value >= -128; - } - - public RubyFixnum newFixnum(long newValue) { - return newFixnum(getRuntime(), newValue); - } - - public static RubyFixnum zero(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET]; - } - - public static RubyFixnum one(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET + 1]; - } - - public static RubyFixnum two(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET + 2]; - } - - public static RubyFixnum three(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET + 3]; - } - - public static RubyFixnum four(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET + 4]; - } - - public static RubyFixnum five(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET + 5]; - } - - public static RubyFixnum minus_one(Ruby runtime) { - return runtime.fixnumCache[CACHE_OFFSET - 1]; - } - - @Override - public RubyFixnum hash() { - return newFixnum(hashCode()); - } - - @Override - public final int hashCode() { - return (int)(value ^ value >>> 32); - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - if (other instanceof RubyFixnum) { - RubyFixnum num = (RubyFixnum)other; - - if (num.value == value) { - return true; - } - } - - return false; - } - - /* ================ - * Instance Methods - * ================ - */ - - /** fix_to_s - * - */ - public RubyString to_s(IRubyObject[] args) { - switch (args.length) { - case 0: return to_s(); - case 1: return to_s(args[0]); - default: throw getRuntime().newArgumentError(args.length, 1); - } - } - - @JRubyMethod - @Override - public RubyString to_s() { - int base = 10; - return getRuntime().newString(Convert.longToByteList(value, base)); - } - - @JRubyMethod - public RubyString to_s(IRubyObject arg0) { - int base = num2int(arg0); - if (base < 2 || base > 36) { - throw getRuntime().newArgumentError("illegal radix " + base); - } - return getRuntime().newString(Convert.longToByteList(value, base)); - } - - /** fix_id2name - * - */ - @JRubyMethod - public IRubyObject id2name() { - RubySymbol symbol = RubySymbol.getSymbolLong(getRuntime(), value); - - if (symbol != null) return getRuntime().newString(symbol.asJavaString()); - - return getRuntime().getNil(); - } - - /** fix_to_sym - * - */ - @JRubyMethod - public IRubyObject to_sym() { - RubySymbol symbol = RubySymbol.getSymbolLong(getRuntime(), value); - - return symbol != null ? symbol : getRuntime().getNil(); - } - - /** fix_uminus - * - */ - @JRubyMethod(name = "-@") - public IRubyObject op_uminus() { - if (value == MIN) { // a gotcha - return RubyBignum.newBignum(getRuntime(), BigInteger.valueOf(value).negate()); - } - return RubyFixnum.newFixnum(getRuntime(), -value); - } - - /** fix_plus - * - */ - @JRubyMethod(name = "+") - public IRubyObject op_plus(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return addFixnum(context, (RubyFixnum)other); - } - return addOther(context, other); - } - - private IRubyObject addFixnum(ThreadContext context, RubyFixnum other) { - long otherValue = other.value; - long result = value + otherValue; - if (additionOverflowed(value, otherValue, result)) { - return addAsBignum(context, other); - } - return newFixnum(context.getRuntime(), result); - } - - private static boolean additionOverflowed(long original, long other, long result) { - return (~(original ^ other) & (original ^ result) & SIGN_BIT) != 0; - } - - private static boolean subtractionOverflowed(long original, long other, long result) { - return (~(original ^ ~other) & (original ^ result) & SIGN_BIT) != 0; - } - - private IRubyObject addAsBignum(ThreadContext context, RubyFixnum other) { - return RubyBignum.newBignum(context.getRuntime(), value).op_plus(context, other); - } - - private IRubyObject addOther(ThreadContext context, IRubyObject other) { - if (other instanceof RubyBignum) { - return ((RubyBignum) other).op_plus(context, this); - } - if (other instanceof RubyFloat) { - return context.getRuntime().newFloat((double) value + ((RubyFloat) other).getDoubleValue()); - } - return coerceBin(context, "+", other); - } - - /** fix_minus - * - */ - @JRubyMethod(name = "-") - public IRubyObject op_minus(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return subtractFixnum(context, (RubyFixnum)other); - } - return subtractOther(context, other); - } - - private IRubyObject subtractFixnum(ThreadContext context, RubyFixnum other) { - long otherValue = other.value; - long result = value - otherValue; - if (subtractionOverflowed(value, otherValue, result)) { - return subtractAsBignum(context, other); - } - return newFixnum(context.getRuntime(), result); - } - - private IRubyObject subtractAsBignum(ThreadContext context, RubyFixnum other) { - return RubyBignum.newBignum(context.getRuntime(), value).op_minus(context, other); - } - - private IRubyObject subtractOther(ThreadContext context, IRubyObject other) { - if (other instanceof RubyBignum) { - return RubyBignum.newBignum(context.getRuntime(), value).op_minus(context, other); - } else if (other instanceof RubyFloat) { - return context.getRuntime().newFloat((double) value - ((RubyFloat) other).getDoubleValue()); - } - return coerceBin(context, "-", other); - } - - /** fix_mul - * - */ - @JRubyMethod(name = "*") - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - if (other instanceof RubyFixnum) { - long otherValue = ((RubyFixnum) other).value; - if (value == 0) { - return RubyFixnum.zero(runtime); - } - long result = value * otherValue; - if (result / value != otherValue) { - return RubyBignum.newBignum(runtime, value).op_mul(context, other); - } - return newFixnum(runtime, result); - } else if (other instanceof RubyBignum) { - return ((RubyBignum) other).op_mul(context, this); - } else if (other instanceof RubyFloat) { - return runtime.newFloat((double) value * ((RubyFloat) other).getDoubleValue()); - } - return coerceBin(context, "*", other); - } - - /** fix_div - * here is terrible MRI gotcha: - * 1.div 3.0 -> 0 - * 1 / 3.0 -> 0.3333333333333333 - * - * MRI is also able to do it in one place by looking at current frame in rb_num_coerce_bin: - * rb_funcall(x, ruby_frame->orig_func, 1, y); - * - * also note that RubyFloat doesn't override Numeric.div - */ - @JRubyMethod(name = "div") - public IRubyObject div_div(ThreadContext context, IRubyObject other) { - return idiv(context, other, "div"); - } - - @JRubyMethod(name = "/") - public IRubyObject op_div(ThreadContext context, IRubyObject other) { - return idiv(context, other, "/"); - } - - @JRubyMethod(name = {"odd?"}) - public RubyBoolean odd_p() { - if(value%2 != 0) { - return getRuntime().getTrue(); - } - return getRuntime().getFalse(); - } - - @JRubyMethod(name = {"even?"}) - public RubyBoolean even_p() { - if(value%2 == 0) { - return getRuntime().getTrue(); - } - return getRuntime().getFalse(); - } - - @JRubyMethod - public IRubyObject pred() { - return getRuntime().newFixnum(value-1); - } - - public IRubyObject idiv(ThreadContext context, IRubyObject other, String method) { - if (other instanceof RubyFixnum) { - long x = value; - long y = ((RubyFixnum) other).value; - - if (y == 0) { - throw context.getRuntime().newZeroDivisionError(); - } - - long div = x / y; - long mod = x % y; - - if (mod < 0 && y > 0 || mod > 0 && y < 0) { - div -= 1; - } - - return context.getRuntime().newFixnum(div); - } - return coerceBin(context, method, other); - } - - /** fix_mod - * - */ - @JRubyMethod(name = {"%", "modulo"}) - public IRubyObject op_mod(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - // Java / and % are not the same as ruby - long x = value; - long y = ((RubyFixnum) other).value; - - if (y == 0) { - throw context.getRuntime().newZeroDivisionError(); - } - - long mod = x % y; - - if (mod < 0 && y > 0 || mod > 0 && y < 0) { - mod += y; - } - - return context.getRuntime().newFixnum(mod); - } - return coerceBin(context, "%", other); - } - - /** fix_divmod - * - */ - @JRubyMethod - @Override - public IRubyObject divmod(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - long x = value; - long y = ((RubyFixnum) other).value; - final Ruby runtime = context.getRuntime(); - - if (y == 0) { - throw runtime.newZeroDivisionError(); - } - - long div = x / y; - long mod = x % y; - - if (mod < 0 && y > 0 || mod > 0 && y < 0) { - div -= 1; - mod += y; - } - - IRubyObject fixDiv = RubyFixnum.newFixnum(runtime, div); - IRubyObject fixMod = RubyFixnum.newFixnum(runtime, mod); - - return RubyArray.newArray(runtime, fixDiv, fixMod); - - } - return coerceBin(context, "divmod", other); - } - - /** fix_quo - * - */ - @JRubyMethod(name = "quo", compat = CompatVersion.RUBY1_8) - public IRubyObject quo(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyFloat.newFloat(context.getRuntime(), (double) value / (double) ((RubyFixnum) other).value); - } - return coerceBin(context, "quo", other); - } - - /** fix_pow - * - */ - @JRubyMethod(name = "**") - public IRubyObject op_pow(ThreadContext context, IRubyObject other) { - if(other instanceof RubyFixnum) { - long b = ((RubyFixnum) other).value; - - if (b == 0) { - return RubyFixnum.one(context.getRuntime()); - } - if (b == 1) { - return this; - } - if (b > 0) { - return RubyBignum.newBignum(context.getRuntime(), value).op_pow(context, other); - } - return RubyFloat.newFloat(context.getRuntime(), Math.pow(value, b)); - } else if (other instanceof RubyFloat) { - return RubyFloat.newFloat(context.getRuntime(), Math.pow(value, ((RubyFloat) other) - .getDoubleValue())); - } - return coerceBin(context, "**", other); - } - - /** fix_pow - * - */ - @JRubyMethod(name = "**", compat = CompatVersion.RUBY1_9) - public IRubyObject op_pow_19(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - long a = value; - if (other instanceof RubyFixnum) { - long b = ((RubyFixnum) other).value; - - if (b < 0) { - return RubyRational.newRationalRaw(context.getRuntime(), this).callMethod(context, "**", other); - } - - if (b == 0) return RubyFixnum.one(runtime); - if (b == 1) return this; - - if (a == 0) { - return b > 0 ? RubyFixnum.zero(runtime) : RubyNumeric.dbl2num(runtime, 1.0 / 0.0); - } - if (a == 1) return RubyFixnum.one(runtime); - if (a == -1) { - return b % 2 == 0 ? RubyFixnum.one(runtime) : RubyFixnum.minus_one(runtime); - } - return Numeric.int_pow(context, a, b); - } else if (other instanceof RubyBignum) { - if (other.callMethod(context, "<", RubyFixnum.zero(runtime)).isTrue()) { - return RubyRational.newRationalRaw(runtime, this).callMethod(context, "**", other); - } - if (a == 0) return RubyFixnum.zero(runtime); - if (a == 1) return RubyFixnum.one(runtime); - if (a == -1) { - return RubyInteger.even_p(context, other).isTrue() ? RubyFixnum.one(runtime) : RubyFixnum.minus_one(runtime); - } - RubyBignum.newBignum(runtime, RubyBignum.fix2big(this)).op_pow(context, other); - } else if (other instanceof RubyFloat) { - return RubyFloat.newFloat(context.getRuntime(), Math.pow(a, ((RubyFloat) other).getDoubleValue())); - } - return coerceBin(context, "**", other); - } - - - /** fix_abs - * - */ - @JRubyMethod - public IRubyObject abs() { - if (value < 0) { - // A gotcha for Long.MIN_VALUE: value = -value - if (value == Long.MIN_VALUE) { - return RubyBignum.newBignum( - getRuntime(), BigInteger.valueOf(value).negate()); - } - return RubyFixnum.newFixnum(getRuntime(), -value); - } - return this; - } - - /** fix_equal - * - */ - @JRubyMethod(name = "==") - @Override - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyBoolean.newBoolean(context.getRuntime(), value == ((RubyFixnum) other).value); - } - return super.op_num_equal(context, other); - } - - /** fix_cmp - * - */ - @JRubyMethod(name = "<=>") - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return compareFixnum(context, (RubyFixnum)other); - } - return coerceCmp(context, "<=>", other); - } - - private IRubyObject compareFixnum(ThreadContext context, RubyFixnum other) { - long otherValue = ((RubyFixnum) other).value; - if (value == otherValue) { - return RubyFixnum.zero(context.getRuntime()); - } - if (value > otherValue) { - return RubyFixnum.one(context.getRuntime()); - } - return RubyFixnum.minus_one(context.getRuntime()); - } - - /** fix_gt - * - */ - @JRubyMethod(name = ">") - public IRubyObject op_gt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyBoolean.newBoolean(context.getRuntime(), value > ((RubyFixnum) other).value); - } - return coerceRelOp(context, ">", other); - } - - /** fix_ge - * - */ - @JRubyMethod(name = ">=") - public IRubyObject op_ge(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyBoolean.newBoolean(context.getRuntime(), value >= ((RubyFixnum) other).value); - } - return coerceRelOp(context, ">=", other); - } - - /** fix_lt - * - */ - @JRubyMethod(name = "<") - public IRubyObject op_lt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyBoolean.newBoolean(context.getRuntime(), value < ((RubyFixnum) other).value); - } - - return coerceRelOp(context, "<", other); - } - - /** fix_le - * - */ - @JRubyMethod(name = "<=") - public IRubyObject op_le(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum) { - return RubyBoolean.newBoolean(context.getRuntime(), value <= ((RubyFixnum) other).value); - } - - return coerceRelOp(context, "<=", other); - } - - /** fix_rev - * - */ - @JRubyMethod(name = "~") - public IRubyObject op_neg() { - return newFixnum(~value); - } - - /** fix_and - * - */ - @JRubyMethod(name = "&") - public IRubyObject op_and(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum || (other = fixCoerce(other)) instanceof RubyFixnum) { - return newFixnum(context.getRuntime(), value & ((RubyFixnum) other).value); - } - return ((RubyBignum) other).op_and(context, this); - } - - /** fix_or - * - */ - @JRubyMethod(name = "|") - public IRubyObject op_or(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum || (other = fixCoerce(other)) instanceof RubyFixnum) { - return newFixnum(context.getRuntime(), value | ((RubyFixnum) other).value); - } - return ((RubyBignum) other).op_or(context, this); - } - - /** fix_xor - * - */ - @JRubyMethod(name = "^") - public IRubyObject op_xor(ThreadContext context, IRubyObject other) { - if (other instanceof RubyFixnum || (other = fixCoerce(other)) instanceof RubyFixnum) { - return newFixnum(context.getRuntime(), value ^ ((RubyFixnum) other).value); - } - return ((RubyBignum) other).op_xor(context, this); - } - - /** fix_aref - * - */ - @JRubyMethod(name = "[]") - public IRubyObject op_aref(IRubyObject other) { - if(!(other instanceof RubyFixnum) && !((other = fixCoerce(other)) instanceof RubyFixnum)) { - RubyBignum big = (RubyBignum) other; - RubyObject tryFix = RubyBignum.bignorm(getRuntime(), big.getValue()); - if (!(tryFix instanceof RubyFixnum)) { - return big.getValue().signum() == 0 || value >= 0 ? RubyFixnum.zero(getRuntime()) : RubyFixnum.one(getRuntime()); - } - } - - long otherValue = fix2long(other); - - if (otherValue < 0) return RubyFixnum.zero(getRuntime()); - - if (BIT_SIZE - 1 < otherValue) { - return value < 0 ? RubyFixnum.one(getRuntime()) : RubyFixnum.zero(getRuntime()); - } - - return (value & (1L << otherValue)) == 0 ? RubyFixnum.zero(getRuntime()) : RubyFixnum.one(getRuntime()); - } - - /** fix_lshift - * - */ - @JRubyMethod(name = "<<") - public IRubyObject op_lshift(IRubyObject other) { - if (!(other instanceof RubyFixnum)) return RubyBignum.newBignum(getRuntime(), value).op_lshift(other); - - long width = ((RubyFixnum)other).getLongValue(); - - return width < 0 ? rshift(-width) : lshift(width); - } - - private IRubyObject lshift(long width) { - if (width > BIT_SIZE - 1 || ((~0L << BIT_SIZE - width - 1) & value) != 0) { - return RubyBignum.newBignum(getRuntime(), value).op_lshift(RubyFixnum.newFixnum(getRuntime(), width)); - } - return RubyFixnum.newFixnum(getRuntime(), value << width); - } - - /** fix_rshift - * - */ - @JRubyMethod(name = ">>") - public IRubyObject op_rshift(IRubyObject other) { - if (!(other instanceof RubyFixnum)) return RubyBignum.newBignum(getRuntime(), value).op_rshift(other); - - long width = ((RubyFixnum)other).getLongValue(); - - if (width == 0) return this; - - return width < 0 ? lshift(-width) : rshift(width); - } - - private IRubyObject rshift(long width) { - if (width >= BIT_SIZE - 1) { - return value < 0 ? RubyFixnum.minus_one(getRuntime()) : RubyFixnum.zero(getRuntime()); - } - return RubyFixnum.newFixnum(getRuntime(), value >> width); - } - - /** fix_to_f - * - */ - @JRubyMethod - public IRubyObject to_f() { - return RubyFloat.newFloat(getRuntime(), (double) value); - } - - /** fix_size - * - */ - @JRubyMethod - public IRubyObject size() { - return newFixnum((long) ((BIT_SIZE + 7) / 8)); - } - - /** fix_zero_p - * - */ - @JRubyMethod(name = "zero?") - public IRubyObject zero_p() { - return RubyBoolean.newBoolean(getRuntime(), value == 0); - } - - @JRubyMethod - @Override - public IRubyObject id() { - if (value <= Long.MAX_VALUE / 2 && value >= Long.MIN_VALUE / 2) { - return newFixnum(2 * value + 1); - } - - return super.id(); - } - - @Override - public IRubyObject taint(ThreadContext context) { - return this; - } - - @Override - public IRubyObject freeze(ThreadContext context) { - return this; - } - - // Piece of mri rb_to_id - @Override - public String asJavaString() { - getRuntime().getWarnings().warn(ID.FIXNUMS_NOT_SYMBOLS, "do not use Fixnums as Symbols"); - - // FIXME: I think this chunk is equivalent to MRI id2name (and not our public method - // id2name). Make into method if used more than once. - RubySymbol symbol = RubySymbol.getSymbolLong(getRuntime(), value); - - if (symbol == null) { - throw getRuntime().newArgumentError("" + value + " is not a symbol"); - } - - return symbol.asJavaString(); - } - - public static RubyFixnum unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - return input.getRuntime().newFixnum(input.unmarshalInt()); - } - - /* ================ - * Singleton Methods - * ================ - */ - - /** rb_fix_induced_from - * - */ - @JRubyMethod(meta = true) - public static IRubyObject induced_from(IRubyObject recv, IRubyObject other) { - return RubyNumeric.num2fix(other); - } - - @Override - public IRubyObject to_java() { - return MiniJava.javaToRuby(getRuntime(), Long.valueOf(value)); - } - - @Override - public IRubyObject as(Class javaClass) { - return MiniJava.javaToRuby(getRuntime(), coerceToJavaType(getRuntime(), this, javaClass)); - } - - private static Object coerceToJavaType(Ruby ruby, RubyFixnum self, Class javaClass) { - if (!Number.class.isAssignableFrom(javaClass)) { - throw ruby.newTypeError(javaClass.getCanonicalName() + " is not a numeric type"); - } - - TypeCoercer coercer = JAVA_COERCERS.get(javaClass); - - if (coercer == null) { - throw ruby.newTypeError("Cannot coerce Fixnum to " + javaClass.getCanonicalName()); - } - - return coercer.coerce(self); - } - - private static final Map<Class, TypeCoercer> JAVA_COERCERS = new HashMap<Class, TypeCoercer>(); - - static { - TypeCoercer intCoercer = new TypeCoercer() { - public Object coerce(IRubyObject self) { - RubyFixnum fixnum = (RubyFixnum)self; - - if (fixnum.value > Integer.MAX_VALUE) { - throw self.getRuntime().newRangeError("Fixnum " + fixnum.value + " is too large for Java int"); - } - - return Integer.valueOf((int)fixnum.value); - } - }; - JAVA_COERCERS.put(int.class, intCoercer); - JAVA_COERCERS.put(Integer.class, intCoercer); - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Don Schwartz <schwardo@users.sourceforge.net> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import static org.jruby.util.Numeric.f_expt; -import static org.jruby.util.Numeric.f_mul; -import static org.jruby.util.Numeric.f_to_i; -import static org.jruby.util.Numeric.frexp; -import static org.jruby.util.Numeric.ldexp; - -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; - -/** - * A representation of a float object - */ -@JRubyClass(name="Float", parent="Numeric", include="Precision") -public class RubyFloat extends RubyNumeric { - - public static RubyClass createFloatClass(Ruby runtime) { - RubyClass floatc = runtime.defineClass("Float", runtime.getNumeric(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setFloat(floatc); - floatc.index = ClassIndex.FLOAT; - floatc.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyFloat; - } - }; - - floatc.getSingletonClass().undefineMethod("new"); - floatc.includeModule(runtime.getPrecision()); - - // Java Doubles are 64 bit long: - floatc.defineConstant("ROUNDS", RubyFixnum.newFixnum(runtime, 1)); - floatc.defineConstant("RADIX", RubyFixnum.newFixnum(runtime, 2)); - floatc.defineConstant("MANT_DIG", RubyFixnum.newFixnum(runtime, 53)); - floatc.defineConstant("DIG", RubyFixnum.newFixnum(runtime, 15)); - // Double.MAX_EXPONENT since Java 1.6 - floatc.defineConstant("MIN_EXP", RubyFixnum.newFixnum(runtime, -1021)); - // Double.MAX_EXPONENT since Java 1.6 - floatc.defineConstant("MAX_EXP", RubyFixnum.newFixnum(runtime, 1024)); - floatc.defineConstant("MIN_10_EXP", RubyFixnum.newFixnum(runtime, -307)); - floatc.defineConstant("MAX_10_EXP", RubyFixnum.newFixnum(runtime, 308)); - floatc.defineConstant("MIN", RubyFloat.newFloat(runtime, Double.MIN_VALUE)); - floatc.defineConstant("MAX", RubyFloat.newFloat(runtime, Double.MAX_VALUE)); - floatc.defineConstant("EPSILON", RubyFloat.newFloat(runtime, 2.2204460492503131e-16)); - - floatc.defineAnnotatedMethods(RubyFloat.class); - - return floatc; - } - - private final double value; - - public int getNativeTypeIndex() { - return ClassIndex.FLOAT; - } - - public RubyFloat(Ruby runtime) { - this(runtime, 0.0); - } - - public RubyFloat(Ruby runtime, double value) { - super(runtime, runtime.getFloat()); - this.value = value; - } - - public Class<?> getJavaClass() { - // this needs to be thought out more along with the changes in RubyFixnum - // since "to Object" coercion will generally want to produce the same - // type every time -// if (value >= Float.MIN_VALUE && value <= Float.MAX_VALUE) { -// return float.class; -// } - return double.class; - } - - /** Getter for property value. - * @return Value of property value. - */ - public double getValue() { - return this.value; - } - - public double getDoubleValue() { - return value; - } - - public long getLongValue() { - return (long) value; - } - - public RubyFloat convertToFloat() { - return this; - } - - protected int compareValue(RubyNumeric other) { - double otherVal = other.getDoubleValue(); - return getValue() > otherVal ? 1 : getValue() < otherVal ? -1 : 0; - } - - public static RubyFloat newFloat(Ruby runtime, double value) { - return new RubyFloat(runtime, value); - } - - /* ================ - * Instance Methods - * ================ - */ - - /** rb_flo_induced_from - * - */ - @JRubyMethod(required = 1, meta = true) - public static IRubyObject induced_from(ThreadContext context, IRubyObject recv, IRubyObject number) { - if (number instanceof RubyFixnum || number instanceof RubyBignum || number instanceof RubyRational) { - return number.callMethod(context, MethodIndex.TO_F, "to_f"); - } else if (number instanceof RubyFloat) { - return number; - } - throw recv.getRuntime().newTypeError( - "failed to convert " + number.getMetaClass() + " into Float"); - } - - private final static DecimalFormat FORMAT = new DecimalFormat("##############0.0##############", - new DecimalFormatSymbols(Locale.ENGLISH)); - - /** flo_to_s - * - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - if (Double.isInfinite(value)) { - return RubyString.newString(getRuntime(), value < 0 ? "-Infinity" : "Infinity"); - } - - if (Double.isNaN(value)) { - return RubyString.newString(getRuntime(), "NaN"); - } - - String val = ""+value; - - if(val.indexOf('E') != -1) { - String v2 = FORMAT.format(value); - int ix = v2.length()-1; - while(v2.charAt(ix) == '0' && v2.charAt(ix-1) != '.') { - ix--; - } - if(ix > 15 || "0.0".equals(v2.substring(0,ix+1))) { - val = val.replaceFirst("E(\\d)","e+$1").replaceFirst("E-","e-"); - } else { - val = v2.substring(0,ix+1); - } - } - - return RubyString.newString(getRuntime(), val); - } - - /** flo_coerce - * - */ - @JRubyMethod(name = "coerce", required = 1) - public IRubyObject coerce(IRubyObject other) { - return getRuntime().newArray(RubyKernel.new_float(this, other), this); - } - - /** flo_uminus - * - */ - @JRubyMethod(name = "-@") - public IRubyObject op_uminus() { - return RubyFloat.newFloat(getRuntime(), -value); - } - - /** flo_plus - * - */ - @JRubyMethod(name = "+", required = 1) - public IRubyObject op_plus(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyFloat.newFloat(getRuntime(), value + ((RubyNumeric) other).getDoubleValue()); - default: - return coerceBin(context, "+", other); - } - } - - /** flo_minus - * - */ - @JRubyMethod(name = "-", required = 1) - public IRubyObject op_minus(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyFloat.newFloat(getRuntime(), value - ((RubyNumeric) other).getDoubleValue()); - default: - return coerceBin(context, "-", other); - } - } - - /** flo_mul - * - */ - @JRubyMethod(name = "*", required = 1) - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyFloat.newFloat( - getRuntime(), value * ((RubyNumeric) other).getDoubleValue()); - default: - return coerceBin(context, "*", other); - } - } - - /** flo_div - * - */ - @JRubyMethod(name = "/", required = 1) - public IRubyObject op_fdiv(ThreadContext context, IRubyObject other) { // don't override Numeric#div ! - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyFloat.newFloat(getRuntime(), value / ((RubyNumeric) other).getDoubleValue()); - default: - return coerceBin(context, "/", other); - } - } - - /** flo_mod - * - */ - @JRubyMethod(name = {"%", "modulo"}, required = 1) - public IRubyObject op_mod(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double y = ((RubyNumeric) other).getDoubleValue(); - // Modelled after c ruby implementation (java /,% not same as ruby) - double x = value; - - double mod = Math.IEEEremainder(x, y); - if (y * mod < 0) { - mod += y; - } - - return RubyFloat.newFloat(getRuntime(), mod); - default: - return coerceBin(context, "%", other); - } - } - - /** flo_divmod - * - */ - @JRubyMethod(name = "divmod", required = 1) - public IRubyObject divmod(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double y = ((RubyNumeric) other).getDoubleValue(); - double x = value; - - double mod = Math.IEEEremainder(x, y); - // MRI behavior: - if (Double.isNaN(mod)) { - throw getRuntime().newFloatDomainError("NaN"); - } - double div = Math.floor(x / y); - - if (y * mod < 0) { - mod += y; - } - final Ruby runtime = getRuntime(); - IRubyObject car = dbl2num(runtime, div); - RubyFloat cdr = RubyFloat.newFloat(runtime, mod); - return RubyArray.newArray(runtime, car, cdr); - default: - return coerceBin(context, "divmod", other); - } - } - - /** flo_pow - * - */ - @JRubyMethod(name = "**", required = 1) - public IRubyObject op_pow(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyFloat.newFloat(getRuntime(), Math.pow(value, ((RubyNumeric) other) - .getDoubleValue())); - default: - return coerceBin(context, "**", other); - } - } - - /** flo_eq - * - */ - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if (Double.isNaN(value)) { - return getRuntime().getFalse(); - } - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - return RubyBoolean.newBoolean(getRuntime(), value == ((RubyNumeric) other) - .getDoubleValue()); - default: - // Numeric.equal - return super.op_num_equal(context, other); - } - } - - /** flo_cmp - * - */ - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double b = ((RubyNumeric) other).getDoubleValue(); - return dbl_cmp(getRuntime(), value, b); - default: - return coerceCmp(context, "<=>", other); - } - } - - /** flo_gt - * - */ - @JRubyMethod(name = ">", required = 1) - public IRubyObject op_gt(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double b = ((RubyNumeric) other).getDoubleValue(); - return RubyBoolean.newBoolean(getRuntime(), !Double.isNaN(b) && value > b); - default: - return coerceRelOp(context, ">", other); - } - } - - /** flo_ge - * - */ - @JRubyMethod(name = ">=", required = 1) - public IRubyObject op_ge(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double b = ((RubyNumeric) other).getDoubleValue(); - return RubyBoolean.newBoolean(getRuntime(), !Double.isNaN(b) && value >= b); - default: - return coerceRelOp(context, ">=", other); - } - } - - /** flo_lt - * - */ - @JRubyMethod(name = "<", required = 1) - public IRubyObject op_lt(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double b = ((RubyNumeric) other).getDoubleValue(); - return RubyBoolean.newBoolean(getRuntime(), !Double.isNaN(b) && value < b); - default: - return coerceRelOp(context, "<", other); - } - } - - /** flo_le - * - */ - @JRubyMethod(name = "<=", required = 1) - public IRubyObject op_le(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - case ClassIndex.FLOAT: - double b = ((RubyNumeric) other).getDoubleValue(); - return RubyBoolean.newBoolean(getRuntime(), !Double.isNaN(b) && value <= b); - default: - return coerceRelOp(context, "<=", other); - } - } - - /** flo_eql - * - */ - @JRubyMethod(name = "eql?", required = 1) - public IRubyObject eql_p(IRubyObject other) { - if (other instanceof RubyFloat) { - double b = ((RubyFloat) other).value; - if (Double.isNaN(value) || Double.isNaN(b)) { - return getRuntime().getFalse(); - } - if (value == b) { - return getRuntime().getTrue(); - } - } - return getRuntime().getFalse(); - } - - /** flo_hash - * - */ - @JRubyMethod(name = "hash") - public RubyFixnum hash() { - return getRuntime().newFixnum(hashCode()); - } - - public final int hashCode() { - long l = Double.doubleToLongBits(value); - return (int)(l ^ l >>> 32); - } - - /** flo_fo - * - */ - @JRubyMethod(name = "to_f") - public IRubyObject to_f() { - return this; - } - - /** flo_abs - * - */ - @JRubyMethod(name = "abs") - public IRubyObject abs() { - if (Double.doubleToLongBits(value) < 0) { - return RubyFloat.newFloat(getRuntime(), Math.abs(value)); - } - return this; - } - - /** flo_zero_p - * - */ - @JRubyMethod(name = "zero?") - public IRubyObject zero_p() { - return RubyBoolean.newBoolean(getRuntime(), value == 0.0); - } - - /** flo_truncate - * - */ - @JRubyMethod(name = {"truncate", "to_i", "to_int"}) - public IRubyObject truncate() { - double f = value; - if (f > 0.0) f = Math.floor(f); - if (f < 0.0) f = Math.ceil(f); - - return dbl2num(getRuntime(), f); - } - - /** float_to_r, float_decode - * - */ - static final int DBL_MANT_DIG = 53; - static final int FLT_RADIX = 2; - @JRubyMethod(name = "to_r", compat = CompatVersion.RUBY1_9) - public IRubyObject to_r(ThreadContext context) { - long[]exp = new long[1]; - double f = frexp(value, exp); - f = ldexp(f, DBL_MANT_DIG); - long n = exp[0] - DBL_MANT_DIG; - Ruby runtime = context.getRuntime(); - IRubyObject x = f_mul(context, f_to_i(context, runtime.newFloat(f)), - f_expt(context, - RubyFixnum.newFixnum(context.getRuntime(), FLT_RADIX), - RubyFixnum.newFixnum(runtime, n))); - return x; - } - - /** floor - * - */ - @JRubyMethod(name = "floor") - public IRubyObject floor() { - return dbl2num(getRuntime(), Math.floor(value)); - } - - /** flo_ceil - * - */ - @JRubyMethod(name = "ceil") - public IRubyObject ceil() { - return dbl2num(getRuntime(), Math.ceil(value)); - } - - /** flo_round - * - */ - @JRubyMethod(name = "round") - public IRubyObject round() { - double f = value; - if (f > 0.0) { - f = Math.floor(f + 0.5); - } - if (f < 0.0) { - f = Math.ceil(f - 0.5); - } - return dbl2num(getRuntime(), f); - } - - /** flo_is_nan_p - * - */ - @JRubyMethod(name = "nan?") - public IRubyObject nan_p() { - return RubyBoolean.newBoolean(getRuntime(), Double.isNaN(value)); - } - - /** flo_is_infinite_p - * - */ - @JRubyMethod(name = "infinite?") - public IRubyObject infinite_p() { - if (Double.isInfinite(value)) { - return RubyFixnum.newFixnum(getRuntime(), value < 0 ? -1 : 1); - } - return getRuntime().getNil(); - } - - /** flo_is_finite_p - * - */ - @JRubyMethod(name = "finite?") - public IRubyObject finite_p() { - if (Double.isInfinite(value) || Double.isNaN(value)) { - return getRuntime().getFalse(); - } - return getRuntime().getTrue(); - } - - public static void marshalTo(RubyFloat aFloat, MarshalStream output) throws java.io.IOException { - output.registerLinkTarget(aFloat); - - String strValue = aFloat.toString(); - - if (Double.isInfinite(aFloat.value)) { - strValue = aFloat.value < 0 ? "-inf" : "inf"; - } else if (Double.isNaN(aFloat.value)) { - strValue = "nan"; - } - output.writeString(strValue); - } - - public static RubyFloat unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - RubyFloat result = RubyFloat.newFloat(input.getRuntime(), org.jruby.util.Convert.byteListToDouble(input.unmarshalString(),false)); - input.registerLinkTarget(result); - return result; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * GC (Garbage Collection) Module - * - * Note: Since we rely on Java's memory model we can't provide the - * kind of control over garbage collection that MRI provides. - * - * @author Anders - */ -@JRubyModule(name="GC") -public class RubyGC { - public static RubyModule createGCModule(Ruby runtime) { - RubyModule result = runtime.defineModule("GC"); - runtime.setGC(result); - - result.defineAnnotatedMethods(RubyGC.class); - - return result; - } - - @JRubyMethod(module = true, visibility = Visibility.PRIVATE) - public static IRubyObject start(IRubyObject recv) { - System.gc(); - return recv.getRuntime().getNil(); - } - - @JRubyMethod - public static IRubyObject garbage_collect(IRubyObject recv) { - System.gc(); - return recv.getRuntime().getNil(); - } - - @JRubyMethod(module = true, visibility = Visibility.PRIVATE) - public static IRubyObject enable(IRubyObject recv) { - recv.getRuntime().getWarnings().warn(ID.EMPTY_IMPLEMENTATION, "GC.enable will not work on JRuby", "GC.enable"); - return recv.getRuntime().getNil(); - } - - @JRubyMethod(module = true, visibility = Visibility.PRIVATE) - public static IRubyObject disable(IRubyObject recv) { - recv.getRuntime().getWarnings().warn(ID.EMPTY_IMPLEMENTATION, "GC.disable will not work on JRuby", "GC.disable"); - return recv.getRuntime().getNil(); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2006 Michael Studman <codehaus@michaelstudman.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.util.io.STDIO; -import java.util.HashMap; -import java.util.Map; - -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.environment.OSEnvironmentReaderExcepton; -import org.jruby.environment.OSEnvironment; -import org.jruby.internal.runtime.ValueAccessor; -import org.jruby.javasupport.JavaUtil; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Constants; -import org.jruby.runtime.GlobalVariable; -import org.jruby.runtime.IAccessor; -import org.jruby.runtime.ReadonlyGlobalVariable; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.KCode; - -/** This class initializes global variables and constants. - * - * @author jpetersen - */ -public class RubyGlobal { - - /** - * Obligate string-keyed and string-valued hash, used for ENV and ENV_JAVA - * - */ - public static class StringOnlyRubyHash extends RubyHash { - - public StringOnlyRubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) { - super(runtime, valueMap, defaultValue); - } - - @Override - public RubyHash to_hash() { - Ruby runtime = getRuntime(); - RubyHash hash = RubyHash.newHash(runtime); - hash.replace(runtime.getCurrentContext(), this); - return hash; - } - - @Override - public IRubyObject op_aref(ThreadContext context, IRubyObject key) { - return super.op_aref(context, key.convertToString()); - } - - @Override - public IRubyObject op_aset(ThreadContext context, IRubyObject key, IRubyObject value) { - if (!key.respondsTo("to_str")) { - throw getRuntime().newTypeError("can't convert " + key.getMetaClass() + " into String"); - } - if (!value.respondsTo("to_str") && !value.isNil()) { - throw getRuntime().newTypeError("can't convert " + value.getMetaClass() + " into String"); - } - - if (value.isNil()) { - return super.delete(context, key, org.jruby.runtime.Block.NULL_BLOCK); - } - - //return super.aset(getRuntime().newString("sadfasdF"), getRuntime().newString("sadfasdF")); - return super.op_aset(context, RuntimeHelpers.invoke(context, key, "to_str"), - value.isNil() ? getRuntime().getNil() : RuntimeHelpers.invoke(context, value, "to_str")); - } - - @JRubyMethod - @Override - public IRubyObject to_s(){ - return getRuntime().newString("ENV"); - } - } - - public static void createGlobals(ThreadContext context, Ruby runtime) { - runtime.defineGlobalConstant("TOPLEVEL_BINDING", runtime.newBinding()); - - runtime.defineGlobalConstant("TRUE", runtime.getTrue()); - runtime.defineGlobalConstant("FALSE", runtime.getFalse()); - runtime.defineGlobalConstant("NIL", runtime.getNil()); - - // define ARGV and $* for this runtime - RubyArray argvArray = runtime.newArray(); - String[] argv = runtime.getInstanceConfig().getArgv(); - for (int i = 0; i < argv.length; i++) { - argvArray.append(RubyString.newString(runtime, argv[i].getBytes())); - } - runtime.defineGlobalConstant("ARGV", argvArray); - runtime.getGlobalVariables().defineReadonly("$*", new ValueAccessor(argvArray)); - - IAccessor d = new ValueAccessor(runtime.newString( - runtime.getInstanceConfig().displayedFileName())); - runtime.getGlobalVariables().define("$PROGRAM_NAME", d); - runtime.getGlobalVariables().define("$0", d); - - // Version information: - IRubyObject version = runtime.newString(Constants.RUBY_VERSION).freeze(context); - IRubyObject release = runtime.newString(Constants.COMPILE_DATE).freeze(context); - IRubyObject platform = runtime.newString(Constants.PLATFORM).freeze(context); - IRubyObject engine = runtime.newString(Constants.ENGINE).freeze(context); - - runtime.defineGlobalConstant("RUBY_VERSION", version); - runtime.defineGlobalConstant("RUBY_PATCHLEVEL", runtime.newString(Constants.RUBY_PATCHLEVEL).freeze(context)); - runtime.defineGlobalConstant("RUBY_RELEASE_DATE", release); - runtime.defineGlobalConstant("RUBY_PLATFORM", platform); - runtime.defineGlobalConstant("RUBY_ENGINE", engine); - - runtime.defineGlobalConstant("VERSION", version); - runtime.defineGlobalConstant("RELEASE_DATE", release); - runtime.defineGlobalConstant("PLATFORM", platform); - - IRubyObject jrubyVersion = runtime.newString(Constants.VERSION).freeze(context); - runtime.defineGlobalConstant("JRUBY_VERSION", jrubyVersion); - - GlobalVariable kcodeGV = new KCodeGlobalVariable(runtime, "$KCODE", runtime.newString("NONE")); - runtime.defineVariable(kcodeGV); - runtime.defineVariable(new GlobalVariable.Copy(runtime, "$-K", kcodeGV)); - IRubyObject defaultRS = runtime.newString(runtime.getInstanceConfig().getRecordSeparator()).freeze(context); - GlobalVariable rs = new StringGlobalVariable(runtime, "$/", defaultRS); - runtime.defineVariable(rs); - runtime.setRecordSeparatorVar(rs); - runtime.getGlobalVariables().setDefaultSeparator(defaultRS); - runtime.defineVariable(new StringGlobalVariable(runtime, "$\\", runtime.getNil())); - runtime.defineVariable(new StringGlobalVariable(runtime, "$,", runtime.getNil())); - - runtime.defineVariable(new LineNumberGlobalVariable(runtime, "$.", RubyFixnum.one(runtime))); - runtime.defineVariable(new LastlineGlobalVariable(runtime, "$_")); - runtime.defineVariable(new LastExitStatusVariable(runtime, "$?")); - - runtime.defineVariable(new ErrorInfoGlobalVariable(runtime, "$!", runtime.getNil())); - runtime.defineVariable(new NonEffectiveGlobalVariable(runtime, "$=", runtime.getFalse())); - - if(runtime.getInstanceConfig().getInputFieldSeparator() == null) { - runtime.defineVariable(new GlobalVariable(runtime, "$;", runtime.getNil())); - } else { - runtime.defineVariable(new GlobalVariable(runtime, "$;", RubyRegexp.newRegexp(runtime, runtime.getInstanceConfig().getInputFieldSeparator(), 0))); - } - - Boolean verbose = runtime.getInstanceConfig().getVerbose(); - IRubyObject verboseValue = null; - if (verbose == null) { - verboseValue = runtime.getNil(); - } else if(verbose == Boolean.TRUE) { - verboseValue = runtime.getTrue(); - } else { - verboseValue = runtime.getFalse(); - } - runtime.defineVariable(new VerboseGlobalVariable(runtime, "$VERBOSE", verboseValue)); - - IRubyObject debug = runtime.newBoolean(runtime.getInstanceConfig().isDebug()); - runtime.defineVariable(new DebugGlobalVariable(runtime, "$DEBUG", debug)); - runtime.defineVariable(new DebugGlobalVariable(runtime, "$-d", debug)); - - runtime.defineVariable(new SafeGlobalVariable(runtime, "$SAFE")); - - runtime.defineVariable(new BacktraceGlobalVariable(runtime, "$@")); - - IRubyObject stdin = new RubyIO(runtime, STDIO.IN); - IRubyObject stdout = new RubyIO(runtime, STDIO.OUT); - IRubyObject stderr = new RubyIO(runtime, STDIO.ERR); - - runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", stdin)); - - runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", stdout)); - runtime.getGlobalVariables().alias("$>", "$stdout"); - runtime.getGlobalVariables().alias("$defout", "$stdout"); - - runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", stderr)); - runtime.getGlobalVariables().alias("$deferr", "$stderr"); - - runtime.defineGlobalConstant("STDIN", stdin); - runtime.defineGlobalConstant("STDOUT", stdout); - runtime.defineGlobalConstant("STDERR", stderr); - - runtime.defineVariable(new LoadedFeatures(runtime, "$\"")); - runtime.defineVariable(new LoadedFeatures(runtime, "$LOADED_FEATURES")); - - runtime.defineVariable(new LoadPath(runtime, "$:")); - runtime.defineVariable(new LoadPath(runtime, "$-I")); - runtime.defineVariable(new LoadPath(runtime, "$LOAD_PATH")); - - runtime.defineVariable(new MatchMatchGlobalVariable(runtime, "$&")); - runtime.defineVariable(new PreMatchGlobalVariable(runtime, "$`")); - runtime.defineVariable(new PostMatchGlobalVariable(runtime, "$'")); - runtime.defineVariable(new LastMatchGlobalVariable(runtime, "$+")); - runtime.defineVariable(new BackRefGlobalVariable(runtime, "$~")); - - // On platforms without a c-library accessable through JNA, getpid will return hashCode - // as $$ used to. Using $$ to kill processes could take down many runtimes, but by basing - // $$ on getpid() where available, we have the same semantics as MRI. - runtime.getGlobalVariables().defineReadonly("$$", new ValueAccessor(runtime.newFixnum(runtime.getPosix().getpid()))); - - // after defn of $stderr as the call may produce warnings - defineGlobalEnvConstants(runtime); - - // Fixme: Do we need the check or does Main.java not call this...they should consolidate - if (runtime.getGlobalVariables().get("$*").isNil()) { - runtime.getGlobalVariables().defineReadonly("$*", new ValueAccessor(runtime.newArray())); - } - - runtime.getGlobalVariables().defineReadonly("$-p", - new ValueAccessor(runtime.getInstanceConfig().isAssumePrinting() ? runtime.getTrue() : runtime.getNil())); - runtime.getGlobalVariables().defineReadonly("$-n", - new ValueAccessor(runtime.getInstanceConfig().isAssumeLoop() ? runtime.getTrue() : runtime.getNil())); - runtime.getGlobalVariables().defineReadonly("$-a", - new ValueAccessor(runtime.getInstanceConfig().isSplit() ? runtime.getTrue() : runtime.getNil())); - runtime.getGlobalVariables().defineReadonly("$-l", - new ValueAccessor(runtime.getInstanceConfig().isProcessLineEnds() ? runtime.getTrue() : runtime.getNil())); - - // ARGF, $< object - RubyArgsFile.initArgsFile(runtime); - } - - private static void defineGlobalEnvConstants(Ruby runtime) { - - Map environmentVariableMap = null; - OSEnvironment environment = new OSEnvironment(); - try { - environmentVariableMap = environment.getEnvironmentVariableMap(runtime); - } catch (OSEnvironmentReaderExcepton e) { - // If the environment variables are not accessible shouldn't terminate - runtime.getWarnings().warn(ID.MISCELLANEOUS, e.getMessage()); - } - - if (environmentVariableMap == null) { - // if the environment variables can't be obtained, define an empty ENV - environmentVariableMap = new HashMap(); - } - - StringOnlyRubyHash h1 = new StringOnlyRubyHash(runtime, - environmentVariableMap, runtime.getNil()); - h1.getSingletonClass().defineAnnotatedMethods(StringOnlyRubyHash.class); - runtime.defineGlobalConstant("ENV", h1); - - // Define System.getProperties() in ENV_JAVA - Map systemProps = environment.getSystemPropertiesMap(runtime); - runtime.defineGlobalConstant("ENV_JAVA", new StringOnlyRubyHash( - runtime, systemProps, runtime.getNil())); - - } - - private static class NonEffectiveGlobalVariable extends GlobalVariable { - public NonEffectiveGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, value); - } - - @Override - public IRubyObject set(IRubyObject value) { - runtime.getWarnings().warn(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective; ignored", name); - return value; - } - - @Override - public IRubyObject get() { - runtime.getWarnings().warn(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective", name); - return runtime.getFalse(); - } - } - - private static class LastExitStatusVariable extends GlobalVariable { - public LastExitStatusVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - IRubyObject lastExitStatus = runtime.getCurrentContext().getLastExitStatus(); - return lastExitStatus == null ? runtime.getNil() : lastExitStatus; - } - - @Override - public IRubyObject set(IRubyObject lastExitStatus) { - runtime.getCurrentContext().setLastExitStatus(lastExitStatus); - - return lastExitStatus; - } - } - - private static class MatchMatchGlobalVariable extends GlobalVariable { - public MatchMatchGlobalVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - return RubyRegexp.last_match(runtime.getCurrentContext().getCurrentFrame().getBackRef()); - } - } - - private static class PreMatchGlobalVariable extends GlobalVariable { - public PreMatchGlobalVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - return RubyRegexp.match_pre(runtime.getCurrentContext().getCurrentFrame().getBackRef()); - } - } - - private static class PostMatchGlobalVariable extends GlobalVariable { - public PostMatchGlobalVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - return RubyRegexp.match_post(runtime.getCurrentContext().getCurrentFrame().getBackRef()); - } - } - - private static class LastMatchGlobalVariable extends GlobalVariable { - public LastMatchGlobalVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - return RubyRegexp.match_last(runtime.getCurrentContext().getCurrentFrame().getBackRef()); - } - } - - private static class BackRefGlobalVariable extends GlobalVariable { - public BackRefGlobalVariable(Ruby runtime, String name) { - super(runtime, name, runtime.getNil()); - } - - @Override - public IRubyObject get() { - return RuntimeHelpers.getBackref(runtime, runtime.getCurrentContext()); - } - - @Override - public IRubyObject set(IRubyObject value) { - RuntimeHelpers.setBackref(runtime, runtime.getCurrentContext(), value); - return value; - } - } - - // Accessor methods. - - private static class LineNumberGlobalVariable extends GlobalVariable { - public LineNumberGlobalVariable(Ruby runtime, String name, RubyFixnum value) { - super(runtime, name, value); - } - - @Override - public IRubyObject set(IRubyObject value) { - RubyArgsFile.setCurrentLineNumber(runtime.getGlobalVariables().get("$<"),RubyNumeric.fix2int(value)); - return super.set(value); - } - } - - private static class ErrorInfoGlobalVariable extends GlobalVariable { - public ErrorInfoGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, null); - set(value); - } - - @Override - public IRubyObject set(IRubyObject value) { - if (!value.isNil() && - !runtime.getException().isInstance(value) && - !(JavaUtil.isJavaObject(value) && JavaUtil.unwrapJavaObject(value) instanceof Exception)) { - throw runtime.newTypeError("assigning non-exception to $!"); - } - - return runtime.getCurrentContext().setErrorInfo(value); - } - - @Override - public IRubyObject get() { - return runtime.getCurrentContext().getErrorInfo(); - } - } - - // FIXME: move out of this class! - public static class StringGlobalVariable extends GlobalVariable { - public StringGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, value); - } - - @Override - public IRubyObject set(IRubyObject value) { - if (!value.isNil() && ! (value instanceof RubyString)) { - throw runtime.newTypeError("value of " + name() + " must be a String"); - } - return super.set(value); - } - } - - public static class KCodeGlobalVariable extends GlobalVariable { - public KCodeGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, value); - } - - @Override - public IRubyObject get() { - return runtime.getKCode().kcode(runtime); - } - - @Override - public IRubyObject set(IRubyObject value) { - runtime.setKCode(KCode.create(runtime, value.convertToString().toString())); - return value; - } - } - - private static class SafeGlobalVariable extends GlobalVariable { - public SafeGlobalVariable(Ruby runtime, String name) { - super(runtime, name, null); - } - - @Override - public IRubyObject get() { - return runtime.newFixnum(runtime.getSafeLevel()); - } - - @Override - public IRubyObject set(IRubyObject value) { -// int level = RubyNumeric.fix2int(value); -// if (level < runtime.getSafeLevel()) { -// throw runtime.newSecurityError("tried to downgrade safe level from " + -// runtime.getSafeLevel() + " to " + level); -// } -// runtime.setSafeLevel(level); - // thread.setSafeLevel(level); - runtime.getWarnings().warn(ID.SAFE_NOT_SUPPORTED, "SAFE levels are not supported in JRuby"); - return RubyFixnum.newFixnum(runtime, runtime.getSafeLevel()); - } - } - - private static class VerboseGlobalVariable extends GlobalVariable { - public VerboseGlobalVariable(Ruby runtime, String name, IRubyObject initialValue) { - super(runtime, name, initialValue); - set(initialValue); - } - - @Override - public IRubyObject get() { - return runtime.getVerbose(); - } - - @Override - public IRubyObject set(IRubyObject newValue) { - if (newValue.isNil()) { - runtime.setVerbose(newValue); - } else { - runtime.setVerbose(runtime.newBoolean(newValue.isTrue())); - } - - return newValue; - } - } - - private static class DebugGlobalVariable extends GlobalVariable { - public DebugGlobalVariable(Ruby runtime, String name, IRubyObject initialValue) { - super(runtime, name, initialValue); - set(initialValue); - } - - @Override - public IRubyObject get() { - return runtime.getDebug(); - } - - @Override - public IRubyObject set(IRubyObject newValue) { - if (newValue.isNil()) { - runtime.setDebug(newValue); - } else { - runtime.setDebug(runtime.newBoolean(newValue.isTrue())); - } - - return newValue; - } - } - - private static class BacktraceGlobalVariable extends GlobalVariable { - public BacktraceGlobalVariable(Ruby runtime, String name) { - super(runtime, name, null); - } - - @Override - public IRubyObject get() { - IRubyObject errorInfo = runtime.getGlobalVariables().get("$!"); - IRubyObject backtrace = errorInfo.isNil() ? runtime.getNil() : errorInfo.callMethod(errorInfo.getRuntime().getCurrentContext(), "backtrace"); - //$@ returns nil if $!.backtrace is not an array - if (!(backtrace instanceof RubyArray)) { - backtrace = runtime.getNil(); - } - return backtrace; - } - - @Override - public IRubyObject set(IRubyObject value) { - if (runtime.getGlobalVariables().get("$!").isNil()) { - throw runtime.newArgumentError("$! not set."); - } - runtime.getGlobalVariables().get("$!").callMethod(value.getRuntime().getCurrentContext(), "set_backtrace", value); - return value; - } - } - - private static class LastlineGlobalVariable extends GlobalVariable { - public LastlineGlobalVariable(Ruby runtime, String name) { - super(runtime, name, null); - } - - @Override - public IRubyObject get() { - return RuntimeHelpers.getLastLine(runtime, runtime.getCurrentContext()); - } - - @Override - public IRubyObject set(IRubyObject value) { - RuntimeHelpers.setLastLine(runtime, runtime.getCurrentContext(), value); - return value; - } - } - - private static class InputGlobalVariable extends GlobalVariable { - public InputGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, value); - } - - @Override - public IRubyObject set(IRubyObject value) { - if (value == get()) { - return value; - } - - return super.set(value); - } - } - - private static class OutputGlobalVariable extends GlobalVariable { - public OutputGlobalVariable(Ruby runtime, String name, IRubyObject value) { - super(runtime, name, value); - } - - @Override - public IRubyObject set(IRubyObject value) { - if (value == get()) { - return value; - } - if (value instanceof RubyIO) { - RubyIO io = (RubyIO)value; - - // HACK: in order to have stdout/err act like ttys and flush always, - // we set anything assigned to stdout/stderr to sync - io.getHandler().setSync(true); - } - - if (!value.respondsTo("write")) { - throw runtime.newTypeError(name() + " must have write method, " + - value.getType().getName() + " given"); - } - - return super.set(value); - } - } - - private static class LoadPath extends ReadonlyGlobalVariable { - public LoadPath(Ruby runtime, String name) { - super(runtime, name, null); - } - - /** - * @see org.jruby.runtime.GlobalVariable#get() - */ - @Override - public IRubyObject get() { - return runtime.getLoadService().getLoadPath(); - } - } - - private static class LoadedFeatures extends ReadonlyGlobalVariable { - public LoadedFeatures(Ruby runtime, String name) { - super(runtime, name, null); - } - - /** - * @see org.jruby.runtime.GlobalVariable#get() - */ - @Override - public IRubyObject get() { - return runtime.getLoadService().getLoadedFeatures(); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2006 Ola Bini <Ola.Bini@ki.se> - * Copyright (C) 2006 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 MenTaLguY <mental@rydia.net> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.util.AbstractCollection; -import java.util.AbstractSet; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.javasupport.JavaUtil; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; -import org.jruby.util.TypeConverter; - -// Design overview: -// -// RubyHash is implemented as hash table with a singly-linked list of -// RubyHash.RubyHashEntry objects for each bucket. RubyHashEntry objects -// are also kept in a doubly-linked list which reflects their insertion -// order and is used for iteration. For simplicity, this latter list is -// circular; a dummy RubyHashEntry, RubyHash.head, is used to mark the -// ends of the list. -// -// When an entry is removed from the table, it is also removed from the -// doubly-linked list. However, while the reference to the previous -// RubyHashEntry is cleared (to mark the entry as dead), the reference -// to the next RubyHashEntry is preserved so that iterators are not -// invalidated: any iterator with a reference to a dead entry can climb -// back up into the list of live entries by chasing next references until -// it finds a live entry (or head). -// -// Ordinarily, this scheme would require O(N) time to clear a hash (since -// each RubyHashEntry would need to be visited and unlinked from the -// iteration list), but RubyHash also maintains a generation count. Every -// time the hash is cleared, the doubly-linked list is simply discarded and -// the generation count incremented. Iterators check to see whether the -// generation count has changed; if it has, they reset themselves back to -// the new start of the list. -// -// This design means that iterators are never invalidated by changes to the -// hashtable, and they do not need to modify the structure during their -// lifecycle. -// - -/** Implementation of the Hash class. - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */ -@JRubyClass(name = "Hash", include="Enumerable") -public class RubyHash extends RubyObject implements Map { - - public static RubyClass createHashClass(Ruby runtime) { - RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR); - runtime.setHash(hashc); - hashc.index = ClassIndex.HASH; - hashc.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyHash; - } - }; - - hashc.includeModule(runtime.getEnumerable()); - - hashc.defineAnnotatedMethods(RubyHash.class); - - return hashc; - } - - private final static ObjectAllocator HASH_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyHash(runtime, klass); - } - }; - - public int getNativeTypeIndex() { - return ClassIndex.HASH; - } - - /** rb_hash_s_create - * - */ - @JRubyMethod(name = "[]", rest = true, frame = true, meta = true) - public static IRubyObject create(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyClass klass = (RubyClass) recv; - Ruby runtime = context.getRuntime(); - RubyHash hash; - - if (args.length == 1) { - IRubyObject tmp = TypeConverter.convertToTypeWithCheck( - args[0], runtime.getHash(), MethodIndex.TO_HASH, "to_hash"); - - if (!tmp.isNil()) { - RubyHash otherHash = (RubyHash) tmp; - return new RubyHash(runtime, klass, otherHash); - } - } - - if ((args.length & 1) != 0) { - throw runtime.newArgumentError("odd number of args for Hash"); - } - - hash = (RubyHash)klass.allocate(); - for (int i=0; i < args.length; i+=2) hash.op_aset(context, args[i], args[i+1]); - - return hash; - } - - /** rb_hash_new - * - */ - public static final RubyHash newHash(Ruby runtime) { - return new RubyHash(runtime); - } - - /** rb_hash_new - * - */ - public static final RubyHash newHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) { - assert defaultValue != null; - - return new RubyHash(runtime, valueMap, defaultValue); - } - - private RubyHashEntry[] table; - private int size = 0; - private int threshold; - - private static final int PROCDEFAULT_HASH_F = 1 << 10; - - private IRubyObject ifNone; - - private RubyHash(Ruby runtime, RubyClass klass, RubyHash other) { - super(runtime, klass); - this.ifNone = runtime.getNil(); - threshold = INITIAL_THRESHOLD; - table = other.internalCopyTable(head); - size = other.size; - } - - public RubyHash(Ruby runtime, RubyClass klass) { - super(runtime, klass); - this.ifNone = runtime.getNil(); - alloc(); - } - - public RubyHash(Ruby runtime) { - this(runtime, runtime.getNil()); - } - - public RubyHash(Ruby runtime, IRubyObject defaultValue) { - super(runtime, runtime.getHash()); - this.ifNone = defaultValue; - alloc(); - } - - /* - * Constructor for internal usage (mainly for Array#|, Array#&, Array#- and Array#uniq) - * it doesn't initialize ifNone field - */ - RubyHash(Ruby runtime, boolean objectSpace) { - super(runtime, runtime.getHash(), objectSpace); - alloc(); - } - - // TODO should this be deprecated ? (to be efficient, internals should deal with RubyHash directly) - public RubyHash(Ruby runtime, Map valueMap, IRubyObject defaultValue) { - super(runtime, runtime.getHash()); - this.ifNone = defaultValue; - alloc(); - - for (Iterator iter = valueMap.entrySet().iterator();iter.hasNext();) { - Map.Entry e = (Map.Entry)iter.next(); - internalPut((IRubyObject)e.getKey(), (IRubyObject)e.getValue()); - } - } - - private final void alloc() { - threshold = INITIAL_THRESHOLD; - generation++; - head.nextAdded = head.prevAdded = head; - table = new RubyHashEntry[MRI_HASH_RESIZE ? MRI_INITIAL_CAPACITY : JAVASOFT_INITIAL_CAPACITY]; - } - - /* ============================ - * Here are hash internals - * (This could be extracted to a separate class but it's not too large though) - * ============================ - */ - - private static final int MRI_PRIMES[] = { - 8 + 3, 16 + 3, 32 + 5, 64 + 3, 128 + 3, 256 + 27, 512 + 9, 1024 + 9, 2048 + 5, 4096 + 3, - 8192 + 27, 16384 + 43, 32768 + 3, 65536 + 45, 131072 + 29, 262144 + 3, 524288 + 21, 1048576 + 7, - 2097152 + 17, 4194304 + 15, 8388608 + 9, 16777216 + 43, 33554432 + 35, 67108864 + 15, - 134217728 + 29, 268435456 + 3, 536870912 + 11, 1073741824 + 85, 0 - }; - - private static final int JAVASOFT_INITIAL_CAPACITY = 8; // 16 ? - private static final int MRI_INITIAL_CAPACITY = MRI_PRIMES[0]; - - private static final int INITIAL_THRESHOLD = JAVASOFT_INITIAL_CAPACITY - (JAVASOFT_INITIAL_CAPACITY >> 2); - private static final int MAXIMUM_CAPACITY = 1 << 30; - - private static final RubyHashEntry NO_ENTRY = new RubyHashEntry(); - private int generation = 0; // generation count for O(1) clears - private final RubyHashEntry head = new RubyHashEntry(); - { head.prevAdded = head.nextAdded = head; } - - static final class RubyHashEntry implements Map.Entry { - private IRubyObject key; - private IRubyObject value; - private RubyHashEntry next; - private RubyHashEntry prevAdded; - private RubyHashEntry nextAdded; - private int hash; - - RubyHashEntry() { - key = NEVER; - } - - RubyHashEntry(int h, IRubyObject k, IRubyObject v, RubyHashEntry e, RubyHashEntry head) { - key = k; value = v; next = e; hash = h; - prevAdded = head.prevAdded; - nextAdded = head; - nextAdded.prevAdded = this; - prevAdded.nextAdded = this; - } - - public void detach() { - if (prevAdded != null) { - prevAdded.nextAdded = nextAdded; - nextAdded.prevAdded = prevAdded; - prevAdded = null; - } - } - - public boolean isLive() { - return prevAdded != null; - } - - public Object getKey() { - return key; - } - public Object getJavaifiedKey(){ - return JavaUtil.convertRubyToJava(key); - } - - public Object getValue() { - return value; - } - public Object getJavaifiedValue() { - return JavaUtil.convertRubyToJava(value); - } - - public Object setValue(Object value) { - IRubyObject oldValue = this.value; - if (value instanceof IRubyObject) { - this.value = (IRubyObject)value; - } else { - throw new UnsupportedOperationException("directEntrySet() doesn't support setValue for non IRubyObject instance entries, convert them manually or use entrySet() instead"); - } - return oldValue; - } - - public boolean equals(Object other){ - if(!(other instanceof RubyHashEntry)) return false; - RubyHashEntry otherEntry = (RubyHashEntry)other; - if(key == otherEntry.key || key.eql(otherEntry.key)){ - if(value == otherEntry.value || value.equals(otherEntry.value)) return true; - } - return false; - } - - public int hashCode(){ - return key.hashCode() ^ value.hashCode(); - } - } - - private static int JavaSoftHashValue(int h) { - h ^= (h >>> 20) ^ (h >>> 12); - return h ^ (h >>> 7) ^ (h >>> 4); - } - - private static int JavaSoftBucketIndex(final int h, final int length) { - return h & (length - 1); - } - - private static int MRIHashValue(int h) { - return h & HASH_SIGN_BIT_MASK; - } - - private static final int HASH_SIGN_BIT_MASK = ~(1 << 31); - private static int MRIBucketIndex(final int h, final int length) { - return (h % length); - } - - private final void resize(int newCapacity) { - final RubyHashEntry[] oldTable = table; - final RubyHashEntry[] newTable = new RubyHashEntry[newCapacity]; - for (int j = 0; j < oldTable.length; j++) { - RubyHashEntry entry = oldTable[j]; - oldTable[j] = null; - while (entry != null) { - RubyHashEntry next = entry.next; - int i = bucketIndex(entry.hash, newCapacity); - entry.next = newTable[i]; - newTable[i] = entry; - entry = next; - } - } - table = newTable; - } - - private final void JavaSoftCheckResize() { - if (size > threshold) { - int oldCapacity = table.length; - if (oldCapacity == MAXIMUM_CAPACITY) { - threshold = Integer.MAX_VALUE; - return; - } - int newCapacity = table.length << 1; - resize(newCapacity); - threshold = newCapacity - (newCapacity >> 2); - } - } - - private static final int MIN_CAPA = 8; - private static final int ST_DEFAULT_MAX_DENSITY = 5; - private final void MRICheckResize() { - if (size / table.length > ST_DEFAULT_MAX_DENSITY) { - int forSize = table.length + 1; // size + 1; - for (int i=0, newCapacity = MIN_CAPA; i < MRI_PRIMES.length; i++, newCapacity <<= 1) { - if (newCapacity > forSize) { - resize(MRI_PRIMES[i]); - return; - } - } - return; // suboptimal for large hashes (> 1073741824 + 85 entries) not very likely to happen - } - } - // ------------------------------ - private static boolean MRI_HASH = true; - private static boolean MRI_HASH_RESIZE = true; - - private static int hashValue(final int h) { - return MRI_HASH ? MRIHashValue(h) : JavaSoftHashValue(h); - } - - private static int bucketIndex(final int h, final int length) { - return MRI_HASH ? MRIBucketIndex(h, length) : JavaSoftBucketIndex(h, length); - } - - private void checkResize() { - if (MRI_HASH_RESIZE) MRICheckResize(); else JavaSoftCheckResize(); - } - // ------------------------------ - public static long collisions = 0; - - // put implementation - - private final void internalPut(final IRubyObject key, final IRubyObject value) { - internalPut(key, value, true); - } - - private final void internalPut(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) { - checkResize(); - final int hash = hashValue(key.hashCode()); - final int i = bucketIndex(hash, table.length); - - // if (table[i] != null) collisions++; - - if (checkForExisting) { - for (RubyHashEntry entry = table[i]; entry != null; entry = entry.next) { - IRubyObject k; - if (entry.hash == hash && ((k = entry.key) == key || key.eql(k))) { - entry.value = value; - return; - } - } - } - - table[i] = new RubyHashEntry(hash, key, value, table[i], head); - size++; - } - - // get implementation - - private final IRubyObject internalGet(IRubyObject key) { // specialized for value - return internalGetEntry(key).value; - } - - private final RubyHashEntry internalGetEntry(IRubyObject key) { - final int hash = hashValue(key.hashCode()); - for (RubyHashEntry entry = table[bucketIndex(hash, table.length)]; entry != null; entry = entry.next) { - IRubyObject k; - if (entry.hash == hash && ((k = entry.key) == key || key.eql(k))) return entry; - } - return NO_ENTRY; - } - - // delete implementation - - - private final RubyHashEntry internalDelete(final IRubyObject key) { - return internalDelete(hashValue(key.hashCode()), MATCH_KEY, key); - } - - private final RubyHashEntry internalDeleteEntry(final RubyHashEntry entry) { - // n.b. we need to recompute the hash in case the key object was modified - return internalDelete(hashValue(entry.key.hashCode()), MATCH_ENTRY, entry); - } - - private final RubyHashEntry internalDelete(final int hash, final EntryMatchType matchType, final Object obj) { - final int i = bucketIndex(hash, table.length); - - RubyHashEntry entry = table[i]; - if (entry != null) { - RubyHashEntry prior = null; - for (; entry != null; prior = entry, entry = entry.next) { - if (entry.hash == hash && matchType.matches(entry, obj)) { - if (prior != null) { - prior.next = entry.next; - } else { - table[i] = entry.next; - } - entry.detach(); - size--; - return entry; - } - } - } - - return NO_ENTRY; - } - - private static abstract class EntryMatchType { - public abstract boolean matches(final RubyHashEntry entry, final Object obj); - } - - private static final EntryMatchType MATCH_KEY = new EntryMatchType() { - public boolean matches(final RubyHashEntry entry, final Object obj) { - final IRubyObject key = entry.key; - return obj == key || (((IRubyObject)obj).eql(key)); - } - }; - - private static final EntryMatchType MATCH_ENTRY = new EntryMatchType() { - public boolean matches(final RubyHashEntry entry, final Object obj) { - return entry.equals(obj); - } - }; - - private final RubyHashEntry[] internalCopyTable(RubyHashEntry destHead) { - RubyHashEntry[]newTable = new RubyHashEntry[table.length]; - - for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) { - int i = bucketIndex(entry.hash, table.length); - newTable[i] = new RubyHashEntry(entry.hash, entry.key, entry.value, newTable[i], destHead); - } - return newTable; - } - - public static abstract class Visitor { - public abstract void visit(IRubyObject key, IRubyObject value); - } - - public void visitAll(Visitor visitor) { - int startGeneration = generation; - for (RubyHashEntry entry = head.nextAdded; entry != head; entry = entry.nextAdded) { - if (startGeneration != generation) { - startGeneration = generation; - entry = head.nextAdded; - if (entry == head) break; - } - if (entry.isLive()) visitor.visit(entry.key, entry.value); - } - } - - /* ============================ - * End of hash internals - * ============================ - */ - - /* ================ - * Instance Methods - * ================ - */ - - /** rb_hash_initialize - * - */ - @JRubyMethod(name = "initialize", optional = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, final Block block) { - modify(); - - if (block.isGiven()) { - if (args.length > 0) throw getRuntime().newArgumentError("wrong number of arguments"); - ifNone = getRuntime().newProc(Block.Type.PROC, block); - flags |= PROCDEFAULT_HASH_F; - } else { - Arity.checkArgumentCount(getRuntime(), args, 0, 1); - if (args.length == 1) ifNone = args[0]; - } - return this; - } - - /** rb_hash_default - * - */ - @Deprecated - public IRubyObject default_value_get(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 0: return default_value_get(context); - case 1: return default_value_get(context, args[0]); - default: throw context.getRuntime().newArgumentError(args.length, 1); - } - } - @JRubyMethod(name = "default", frame = true) - public IRubyObject default_value_get(ThreadContext context) { - if ((flags & PROCDEFAULT_HASH_F) != 0) { - return getRuntime().getNil(); - } - return ifNone; - } - @JRubyMethod(name = "default", frame = true) - public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) { - if ((flags & PROCDEFAULT_HASH_F) != 0) { - return RuntimeHelpers.invoke(context, ifNone, "call", this, arg); - } - return ifNone; - } - - /** rb_hash_set_default - * - */ - @JRubyMethod(name = "default=", required = 1) - public IRubyObject default_value_set(final IRubyObject defaultValue) { - modify(); - - ifNone = defaultValue; - flags &= ~PROCDEFAULT_HASH_F; - - return ifNone; - } - - /** rb_hash_default_proc - * - */ - @JRubyMethod(name = "default_proc", frame = true) - public IRubyObject default_proc() { - return (flags & PROCDEFAULT_HASH_F) != 0 ? ifNone : getRuntime().getNil(); - } - - /** rb_hash_modify - * - */ - public void modify() { - testFrozen("hash"); - if (isTaint() && getRuntime().getSafeLevel() >= 4) { - throw getRuntime().newSecurityError("Insecure: can't modify hash"); - } - } - - /** inspect_hash - * - */ - private IRubyObject inspectHash(final ThreadContext context) { - final ByteList buffer = new ByteList(); - buffer.append('{'); - final boolean[] firstEntry = new boolean[1]; - - firstEntry[0] = true; - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (!firstEntry[0]) buffer.append(',').append(' '); - - buffer.append(inspect(context, key).getByteList()); - buffer.append('=').append('>'); - buffer.append(inspect(context, value).getByteList()); - firstEntry[0] = false; - } - }); - buffer.append('}'); - return getRuntime().newString(buffer); - } - - /** rb_hash_inspect - * - */ - @JRubyMethod(name = "inspect") - public IRubyObject inspect(ThreadContext context) { - if (size == 0) return getRuntime().newString("{}"); - if (getRuntime().isInspecting(this)) return getRuntime().newString("{...}"); - - try { - getRuntime().registerInspecting(this); - return inspectHash(context); - } finally { - getRuntime().unregisterInspecting(this); - } - } - - /** rb_hash_size - * - */ - @JRubyMethod(name = {"size", "length"}) - public RubyFixnum rb_size() { - return getRuntime().newFixnum(size); - } - - /** rb_hash_empty_p - * - */ - @JRubyMethod(name = "empty?") - public RubyBoolean empty_p() { - return size == 0 ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - /** rb_hash_to_a - * - */ - @JRubyMethod(name = "to_a") - public RubyArray to_a() { - final Ruby runtime = getRuntime(); - final RubyArray result = RubyArray.newArray(runtime, size); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - result.append(RubyArray.newArray(runtime, key, value)); - } - }); - - result.setTaint(isTaint()); - return result; - } - - /** rb_hash_to_s & to_s_hash - * - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - if (getRuntime().isInspecting(this)) return getRuntime().newString("{...}"); - try { - getRuntime().registerInspecting(this); - return to_a().to_s(); - } finally { - getRuntime().unregisterInspecting(this); - } - } - - /** rb_hash_rehash - * - */ - @JRubyMethod(name = "rehash") - public RubyHash rehash() { - modify(); - final RubyHashEntry[] oldTable = table; - final RubyHashEntry[] newTable = new RubyHashEntry[oldTable.length]; - for (int j = 0; j < oldTable.length; j++) { - RubyHashEntry entry = oldTable[j]; - oldTable[j] = null; - while (entry != null) { - RubyHashEntry next = entry.next; - entry.hash = entry.key.hashCode(); // update the hash value - int i = bucketIndex(entry.hash, newTable.length); - entry.next = newTable[i]; - newTable[i] = entry; - entry = next; - } - } - table = newTable; - return this; - } - - /** rb_hash_to_hash - * - */ - @JRubyMethod(name = "to_hash") - public RubyHash to_hash() { - return this; - } - - public RubyHash convertToHash() { - return this; - } - - public final void fastASet(IRubyObject key, IRubyObject value) { - internalPut(key, value); - } - - @Deprecated - public IRubyObject op_aset(IRubyObject key, IRubyObject value) { - return op_aset(getRuntime().getCurrentContext(), key, value); - } - - /** rb_hash_aset - * - */ - @JRubyMethod(name = {"[]=", "store"}, required = 2) - public IRubyObject op_aset(ThreadContext context, IRubyObject key, IRubyObject value) { - modify(); - - if (!(key instanceof RubyString)) { - internalPut(key, value); - } else { - final RubyHashEntry entry = internalGetEntry(key); - if (entry != NO_ENTRY) { - entry.value = value; - } else { - RubyString realKey = (RubyString)key; - - if (!realKey.isFrozen()) { - realKey = realKey.strDup(context.getRuntime(), realKey.getMetaClass().getRealClass());; - realKey.setFrozen(true); - } - - internalPut(realKey, value, false); - } - } - - return value; - } - - /** - * Note: this is included as a compatibility measure for AR-JDBC - * @deprecated use RubyHash.op_aset instead - */ - public IRubyObject aset(IRubyObject key, IRubyObject value) { - return op_aset(getRuntime().getCurrentContext(), key, value); - } - - /** - * Note: this is included as a compatibility measure for Mongrel+JRuby - * @deprecated use RubyHash.op_aref instead - */ - public IRubyObject aref(IRubyObject key) { - return op_aref(getRuntime().getCurrentContext(), key); - } - - public final IRubyObject fastARef(IRubyObject key) { // retuns null when not found to avoid unnecessary getRuntime().getNil() call - return internalGet(key); - } - - /** rb_hash_aref - * - */ - @JRubyMethod(name = "[]", required = 1) - public IRubyObject op_aref(ThreadContext context, IRubyObject key) { - IRubyObject value; - return ((value = internalGet(key)) == null) ? callMethod(context, MethodIndex.DEFAULT, "default", key) : value; - } - - /** rb_hash_fetch - * - */ - @JRubyMethod(name = "fetch", required = 1, optional = 1, frame = true) - public IRubyObject fetch(ThreadContext context, IRubyObject[] args, Block block) { - if (args.length == 2 && block.isGiven()) { - getRuntime().getWarnings().warn(ID.BLOCK_BEATS_DEFAULT_VALUE, "block supersedes default value argument"); - } - - IRubyObject value; - if ((value = internalGet(args[0])) == null) { - if (block.isGiven()) return block.yield(context, args[0]); - if (args.length == 1) throw getRuntime().newIndexError("key not found"); - return args[1]; - } - return value; - } - - /** rb_hash_has_key - * - */ - @JRubyMethod(name = {"has_key?", "key?", "include?", "member?"}, required = 1) - public RubyBoolean has_key_p(IRubyObject key) { - return internalGetEntry(key) == NO_ENTRY ? getRuntime().getFalse() : getRuntime().getTrue(); - } - - private class Found extends RuntimeException {} - - private boolean hasValue(final ThreadContext context, final IRubyObject expected) { - try { - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (equalInternal(context, value, expected)) { - throw new Found(); - } - } - }); - return false; - } catch (Found found) { - return true; - } - } - - /** rb_hash_has_value - * - */ - @JRubyMethod(name = {"has_value?", "value?"}, required = 1) - public RubyBoolean has_value_p(ThreadContext context, IRubyObject expected) { - return getRuntime().newBoolean(hasValue(context, expected)); - } - - /** rb_hash_each - * - */ - @JRubyMethod(name = "each", frame = true) - public RubyHash each(final ThreadContext context, final Block block) { - final Ruby runtime = getRuntime(); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - // rb_assoc_new equivalent - block.yield(context, RubyArray.newArray(runtime, key, value), null, null, false); - } - }); - - return this; - } - - /** rb_hash_each_pair - * - */ - @JRubyMethod(name = "each_pair", frame = true) - public RubyHash each_pair(final ThreadContext context, final Block block) { - final Ruby runtime = getRuntime(); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - // rb_yield_values(2,...) equivalent - block.yield(context, RubyArray.newArray(runtime, key, value), null, null, true); - } - }); - - return this; - } - - /** rb_hash_each_value - * - */ - @JRubyMethod(name = "each_value", frame = true) - public RubyHash each_value(final ThreadContext context, final Block block) { - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - block.yield(context, value); - } - }); - - return this; - } - - /** rb_hash_each_key - * - */ - @JRubyMethod(name = "each_key", frame = true) - public RubyHash each_key(final ThreadContext context, final Block block) { - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - block.yield(context, key); - } - }); - - return this; - } - - /** rb_hash_sort - * - */ - @JRubyMethod(name = "sort", frame = true) - public RubyArray sort(Block block) { - return to_a().sort_bang(block); - } - - private static class FoundKey extends RuntimeException { - public IRubyObject key; - FoundKey(IRubyObject key) { - super(); - this.key = key; - } - } - - /** rb_hash_index - * - */ - @JRubyMethod(name = "index", required = 1) - public IRubyObject index(ThreadContext context, IRubyObject expected) { - IRubyObject key = internalIndex(context, expected); - if (key != null) { - return key; - } else { - return getRuntime().getNil(); - } - } - - private IRubyObject internalIndex(final ThreadContext context, final IRubyObject expected) { - try { - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (equalInternal(context, value, expected)) { - throw new FoundKey(key); - } - } - }); - return null; - } catch (FoundKey found) { - return found.key; - } - } - - /** rb_hash_indexes - * - */ - @JRubyMethod(name = {"indexes", "indices"}, rest = true) - public RubyArray indices(ThreadContext context, IRubyObject[] indices) { - return values_at(context, indices); - } - - /** rb_hash_keys - * - */ - @JRubyMethod(name = "keys") - public RubyArray keys() { - final Ruby runtime = getRuntime(); - final RubyArray keys = RubyArray.newArray(runtime, size); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - keys.append(key); - } - }); - - return keys; - } - - /** rb_hash_values - * - */ - @JRubyMethod(name = "values") - public RubyArray rb_values() { - final RubyArray values = RubyArray.newArray(getRuntime(), size); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - values.append(value); - } - }); - - return values; - } - - /** rb_hash_equal - * - */ - - private static final boolean EQUAL_CHECK_DEFAULT_VALUE = false; - - private static class Mismatch extends RuntimeException {} - - @Override - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(final ThreadContext context, final IRubyObject other) { - if (this == other) return getRuntime().getTrue(); - if (!(other instanceof RubyHash)) { - if (other.respondsTo("to_hash") && equalInternal(context, other, this)) return getRuntime().getTrue(); - return getRuntime().getFalse(); - } - - final RubyHash otherHash = (RubyHash)other; - if (size != otherHash.size) return getRuntime().getFalse(); - - final Ruby runtime = getRuntime(); - - if (EQUAL_CHECK_DEFAULT_VALUE) { - if (!equalInternal(context, ifNone, otherHash.ifNone) && - (flags & PROCDEFAULT_HASH_F) != (otherHash.flags & PROCDEFAULT_HASH_F)) return runtime.getFalse(); - } - - try { - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - IRubyObject otherValue = otherHash.internalGet(key); - if (otherValue == null || !equalInternal(context, value, otherValue)) throw new Mismatch(); - } - }); - return runtime.getTrue(); - } catch (Mismatch e) { - return runtime.getFalse(); - } - } - - /** rb_hash_shift - * - */ - @JRubyMethod(name = "shift") - public IRubyObject shift(ThreadContext context) { - modify(); - - RubyHashEntry entry = head.nextAdded; - if (entry != head) { - RubyArray result = RubyArray.newArray(getRuntime(), entry.key, entry.value); - internalDeleteEntry(entry); - return result; - } - - if ((flags & PROCDEFAULT_HASH_F) != 0) { - return RuntimeHelpers.invoke(context, ifNone, "call", this, getRuntime().getNil()); - } else { - return ifNone; - } - } - - public final boolean fastDelete(IRubyObject key) { - return internalDelete(key) != NO_ENTRY; - } - - /** rb_hash_delete - * - */ - @JRubyMethod(name = "delete", required = 1, frame = true) - public IRubyObject delete(ThreadContext context, IRubyObject key, Block block) { - modify(); - - final RubyHashEntry entry = internalDelete(key); - if (entry != NO_ENTRY) return entry.value; - - if (block.isGiven()) return block.yield(context, key); - return getRuntime().getNil(); - } - - /** rb_hash_select - * - */ - @JRubyMethod(name = "select", frame = true) - public IRubyObject select(final ThreadContext context, final Block block) { - final RubyArray result = getRuntime().newArray(); - final Ruby runtime = getRuntime(); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (block.yield(context, runtime.newArray(key, value), null, null, true).isTrue()) { - result.append(runtime.newArray(key, value)); - } - } - }); - - return result; - } - - /** rb_hash_delete_if - * - */ - @JRubyMethod(name = "delete_if", frame = true) - public RubyHash delete_if(final ThreadContext context, final Block block) { - modify(); - - final Ruby runtime = getRuntime(); - final RubyHash self = this; - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (block.yield(context, RubyArray.newArray(runtime, key, value), null, null, true).isTrue()) { - self.delete(context, key, block); - } - } - }); - - return this; - } - - /** rb_hash_reject - * - */ - @JRubyMethod(name = "reject", frame = true) - public RubyHash reject(ThreadContext context, Block block) { - return ((RubyHash)dup()).delete_if(context, block); - } - - /** rb_hash_reject_bang - * - */ - @JRubyMethod(name = "reject!", frame = true) - public IRubyObject reject_bang(ThreadContext context, Block block) { - int n = size; - delete_if(context, block); - if (n == size) return getRuntime().getNil(); - return this; - } - - /** rb_hash_clear - * - */ - @JRubyMethod(name = "clear") - public RubyHash rb_clear() { - modify(); - - if (size > 0) { - alloc(); - size = 0; - } - - return this; - } - - /** rb_hash_invert - * - */ - @JRubyMethod(name = "invert") - public RubyHash invert(final ThreadContext context) { - final RubyHash result = newHash(getRuntime()); - - visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - result.op_aset(context, value, key); - } - }); - - return result; - } - - /** rb_hash_update - * - */ - @JRubyMethod(name = {"merge!", "update"}, required = 1, frame = true) - public RubyHash merge_bang(final ThreadContext context, final IRubyObject other, final Block block) { - modify(); - - final Ruby runtime = getRuntime(); - final RubyHash otherHash = other.convertToHash(); - final RubyHash self = this; - otherHash.visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - if (block.isGiven()) { - IRubyObject existing = self.internalGet(key); - if (existing != null) - value = block.yield(context, RubyArray.newArrayNoCopy(runtime, new IRubyObject[]{key, existing, value})); - } - self.op_aset(context, key, value); - } - }); - - return this; - } - - /** rb_hash_merge - * - */ - @JRubyMethod(name = "merge", required = 1, frame = true) - public RubyHash merge(ThreadContext context, IRubyObject other, Block block) { - return ((RubyHash)dup()).merge_bang(context, other, block); - } - - /** rb_hash_replace - * - */ - @JRubyMethod(name = "initialize_copy", required = 1, visibility = Visibility.PRIVATE) - public RubyHash initialize_copy(ThreadContext context, IRubyObject other) { - return replace(context, other); - } - - /** rb_hash_replace - * - */ - @JRubyMethod(name = "replace", required = 1) - public RubyHash replace(final ThreadContext context, IRubyObject other) { - final RubyHash otherHash = other.convertToHash(); - - if (this == otherHash) return this; - - rb_clear(); - - final RubyHash self = this; - otherHash.visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - self.op_aset(context, key, value); - } - }); - - ifNone = otherHash.ifNone; - - if ((otherHash.flags & PROCDEFAULT_HASH_F) != 0) { - flags |= PROCDEFAULT_HASH_F; - } else { - flags &= ~PROCDEFAULT_HASH_F; - } - - return this; - } - - /** rb_hash_values_at - * - */ - @JRubyMethod(name = "values_at", rest = true) - public RubyArray values_at(ThreadContext context, IRubyObject[] args) { - RubyArray result = RubyArray.newArray(getRuntime(), args.length); - for (int i = 0; i < args.length; i++) { - result.append(op_aref(context, args[i])); - } - return result; - } - - public boolean hasDefaultProc() { - return (flags & PROCDEFAULT_HASH_F) != 0; - } - - public IRubyObject getIfNone(){ - return ifNone; - } - - private static class VisitorIOException extends RuntimeException { - VisitorIOException(Throwable cause) { - super(cause); - } - } - - // FIXME: Total hack to get flash in Rails marshalling/unmarshalling in session ok...We need - // to totally change marshalling to work with overridden core classes. - public static void marshalTo(final RubyHash hash, final MarshalStream output) throws IOException { - output.registerLinkTarget(hash); - output.writeInt(hash.size); - try { - hash.visitAll(new Visitor() { - public void visit(IRubyObject key, IRubyObject value) { - try { - output.dumpObject(key); - output.dumpObject(value); - } catch (IOException e) { - throw new VisitorIOException(e); - } - } - }); - } catch (VisitorIOException e) { - throw (IOException)e.getCause(); - } - - if (!hash.ifNone.isNil()) output.dumpObject(hash.ifNone); - } - - public static RubyHash unmarshalFrom(UnmarshalStream input, boolean defaultValue) throws IOException { - RubyHash result = newHash(input.getRuntime()); - input.registerLinkTarget(result); - int size = input.unmarshalInt(); - ThreadContext context = input.getRuntime().getCurrentContext(); - for (int i = 0; i < size; i++) { - result.op_aset(context, input.unmarshalObject(), input.unmarshalObject()); - } - if (defaultValue) result.default_value_set(input.unmarshalObject()); - return result; - } - - public Class getJavaClass() { - return Map.class; - } - - // Satisfy java.util.Set interface (for Java integration) - - public int size() { - return size; - } - - public boolean isEmpty() { - return size == 0; - } - - public boolean containsKey(Object key) { - return internalGet(JavaUtil.convertJavaToRuby(getRuntime(), key)) != null; - } - - public boolean containsValue(Object value) { - return hasValue(getRuntime().getCurrentContext(), JavaUtil.convertJavaToRuby(getRuntime(), value)); - } - - public Object get(Object key) { - return JavaUtil.convertRubyToJava(internalGet(JavaUtil.convertJavaToRuby(getRuntime(), key))); - } - - public Object put(Object key, Object value) { - internalPut(JavaUtil.convertJavaToRuby(getRuntime(), key), JavaUtil.convertJavaToRuby(getRuntime(), value)); - return value; - } - - public Object remove(Object key) { - IRubyObject rubyKey = JavaUtil.convertJavaToRuby(getRuntime(), key); - return internalDelete(rubyKey).value; - } - - public void putAll(Map map) { - Ruby runtime = getRuntime(); - for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { - Object key = iter.next(); - internalPut(JavaUtil.convertJavaToRuby(runtime, key), JavaUtil.convertJavaToRuby(runtime, map.get(key))); - } - } - - public void clear() { - rb_clear(); - } - - public boolean equals(Object other) { - if (!(other instanceof RubyHash)) return false; - if (this == other) return true; - return op_equal(getRuntime().getCurrentContext(), (RubyHash)other).isTrue() ? true : false; - } - - public Set keySet() { - return new BaseSet(KEY_VIEW); - } - - public Set directKeySet() { - return new BaseSet(DIRECT_KEY_VIEW); - } - - public Collection values() { - return new BaseCollection(VALUE_VIEW); - } - - public Collection directValues() { - return new BaseCollection(DIRECT_VALUE_VIEW); - } - - public Set entrySet() { - return new BaseSet(ENTRY_VIEW); - } - - public Set directEntrySet() { - return new BaseSet(DIRECT_ENTRY_VIEW); - } - - private class BaseSet extends AbstractSet { - final EntryView view; - - public BaseSet(EntryView view) { - this.view = view; - } - - public Iterator iterator() { - return new BaseIterator(view); - } - - public boolean contains(Object o) { - return view.contains(RubyHash.this, o); - } - - public void clear() { - RubyHash.this.clear(); - } - - public int size() { - return RubyHash.this.size; - } - - public boolean remove(Object o) { - return view.remove(RubyHash.this, o); - } - } - - private class BaseCollection extends AbstractCollection { - final EntryView view; - - public BaseCollection(EntryView view) { - this.view = view; - } - - public Iterator iterator() { - return new BaseIterator(view); - } - - public boolean contains(Object o) { - return view.contains(RubyHash.this, o); - } - - public void clear() { - RubyHash.this.clear(); - } - - public int size() { - return RubyHash.this.size; - } - - public boolean remove(Object o) { - return view.remove(RubyHash.this, o); - } - } - - private class BaseIterator implements Iterator { - final private EntryView view; - private RubyHashEntry entry; - private boolean peeking; - private int startGeneration; - - public BaseIterator(EntryView view) { - this.view = view; - this.entry = head; - this.startGeneration = generation; - } - - private void advance(boolean consume) { - if (!peeking) { - do { - if (startGeneration != generation) { - startGeneration = generation; - entry = head; - } - entry = entry.nextAdded; - } while (entry != head && !entry.isLive()); - } - peeking = !consume; - } - - public Object next() { - advance(true); - if (entry == head) { - peeking = true; // remain where we are - throw new NoSuchElementException(); - } - return view.convertEntry(getRuntime(), entry); - } - - // once hasNext has been called, we commit to next() returning - // the entry it found, even if it were subsequently deleted - public boolean hasNext() { - advance(false); - return entry != head; - } - - public void remove() { - if (entry == head) { - throw new IllegalStateException("Iterator out of range"); - } - internalDeleteEntry(entry); - } - } - - private static abstract class EntryView { - public abstract Object convertEntry(Ruby runtime, RubyHashEntry value); - public abstract boolean contains(RubyHash hash, Object o); - public abstract boolean remove(RubyHash hash, Object o); - } - - private static final EntryView DIRECT_KEY_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return entry.key; - } - public boolean contains(RubyHash hash, Object o) { - if (!(o instanceof IRubyObject)) return false; - return hash.internalGet((IRubyObject)o) != null; - } - public boolean remove(RubyHash hash, Object o) { - if (!(o instanceof IRubyObject)) return false; - return hash.internalDelete((IRubyObject)o) != NO_ENTRY; - } - }; - - private static final EntryView KEY_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return JavaUtil.convertRubyToJava(entry.key, Object.class); - } - public boolean contains(RubyHash hash, Object o) { - return hash.containsKey(o); - } - public boolean remove(RubyHash hash, Object o) { - return hash.remove(o) != null; - } - }; - - private static final EntryView DIRECT_VALUE_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return entry.value; - } - public boolean contains(RubyHash hash, Object o) { - if (!(o instanceof IRubyObject)) return false; - IRubyObject obj = (IRubyObject)o; - return hash.hasValue(obj.getRuntime().getCurrentContext(), obj); - } - public boolean remove(RubyHash hash, Object o) { - if (!(o instanceof IRubyObject)) return false; - IRubyObject obj = (IRubyObject) o; - IRubyObject key = hash.internalIndex(obj.getRuntime().getCurrentContext(), obj); - if (key == null) return false; - return hash.internalDelete(key) != NO_ENTRY; - } - }; - - private final EntryView VALUE_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return JavaUtil.convertRubyToJava(entry.value, Object.class); - } - public boolean contains(RubyHash hash, Object o) { - return hash.containsValue(o); - } - public boolean remove(RubyHash hash, Object o) { - IRubyObject value = JavaUtil.convertJavaToRuby(hash.getRuntime(), o); - IRubyObject key = hash.internalIndex(hash.getRuntime().getCurrentContext(), value); - if (key == null) return false; - return hash.internalDelete(key) != NO_ENTRY; - } - }; - - private final EntryView DIRECT_ENTRY_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return entry; - } - public boolean contains(RubyHash hash, Object o) { - if (!(o instanceof RubyHashEntry)) return false; - RubyHashEntry entry = (RubyHashEntry)o; - RubyHashEntry candidate = internalGetEntry(entry.key); - return candidate != NO_ENTRY && entry.equals(candidate); - } - public boolean remove(RubyHash hash, Object o) { - if (!(o instanceof RubyHashEntry)) return false; - return hash.internalDeleteEntry((RubyHashEntry)o) != NO_ENTRY; - } - }; - - private final EntryView ENTRY_VIEW = new EntryView() { - public Object convertEntry(Ruby runtime, RubyHashEntry entry) { - return new ConvertingEntry(runtime, entry); - } - public boolean contains(RubyHash hash, Object o) { - if (!(o instanceof ConvertingEntry)) return false; - ConvertingEntry entry = (ConvertingEntry)o; - RubyHashEntry candidate = hash.internalGetEntry(entry.entry.key); - return candidate != NO_ENTRY && entry.entry.equals(candidate); - } - public boolean remove(RubyHash hash, Object o) { - if (!(o instanceof ConvertingEntry)) return false; - ConvertingEntry entry = (ConvertingEntry)o; - return hash.internalDeleteEntry(entry.entry) != NO_ENTRY; - } - }; - - private static class ConvertingEntry implements Map.Entry { - private final RubyHashEntry entry; - private final Ruby runtime; - - public ConvertingEntry(Ruby runtime, RubyHashEntry entry) { - this.entry = entry; - this.runtime = runtime; - } - - public Object getKey() { - return JavaUtil.convertRubyToJava(entry.key, Object.class); - } - public Object getValue() { - return JavaUtil.convertRubyToJava(entry.value, Object.class); - } - public Object setValue(Object o) { - return entry.setValue(JavaUtil.convertJavaToRuby(runtime, o)); - } - - public boolean equals(Object o) { - if (!(o instanceof ConvertingEntry)) { - return false; - } - ConvertingEntry other = (ConvertingEntry)o; - return entry.equals(other.entry); - } - public int hashCode() { - return entry.hashCode(); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2007 Koichiro Ohba <koichiro@meadowy.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CodingErrorAction; -import java.nio.charset.IllegalCharsetNameException; -import java.nio.charset.MalformedInputException; -import java.nio.charset.UnmappableCharacterException; -import java.nio.charset.UnsupportedCharsetException; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Arity; - -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -import org.jruby.util.ByteList; - -@JRubyClass(name="Iconv") -public class RubyIconv extends RubyObject { - //static private final String TRANSLIT = "//translit"; - static private final String IGNORE = "//ignore"; - - private CharsetDecoder fromEncoding; - private CharsetEncoder toEncoding; - - public RubyIconv(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private static final ObjectAllocator ICONV_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyIconv(runtime, klass); - } - }; - - @JRubyModule(name="Iconv::Failure") - public static class Failure {} - @JRubyClass(name="Iconv::IllegalSequence", parent="ArgumentError", include="Iconv::Failure") - public static class IllegalSequence {} - @JRubyClass(name="Iconv::InvalidCharacter", parent="ArgumentError", include="Iconv::Failure") - public static class InvalidCharacter {} - @JRubyClass(name="Iconv::InvalidEncoding", parent="ArgumentError", include="Iconv::Failure") - public static class InvalidEncoding {} - @JRubyClass(name="Iconv::OutOfRange", parent="ArgumentError", include="Iconv::Failure") - public static class OutOfRange {} - @JRubyClass(name="Iconv::BrokenLibrary", parent="ArgumentError", include="Iconv::Failure") - public static class BrokenLibrary {} - - public static void createIconv(Ruby runtime) { - RubyClass iconvClass = runtime.defineClass("Iconv", runtime.getObject(), ICONV_ALLOCATOR); - - iconvClass.defineAnnotatedMethods(RubyIconv.class); - - RubyModule failure = iconvClass.defineModuleUnder("Failure"); - RubyClass argumentError = runtime.getArgumentError(); - - String[] iconvErrors = {"IllegalSequence", "InvalidCharacter", "InvalidEncoding", - "OutOfRange", "BrokenLibrary"}; - - for (int i = 0; i < iconvErrors.length; i++) { - RubyClass subClass = iconvClass.defineClassUnder(iconvErrors[i], argumentError, RubyFailure.ICONV_FAILURE_ALLOCATOR); - subClass.defineAnnotatedMethods(RubyFailure.class); - subClass.includeModule(failure); - } - } - - public static class RubyFailure extends RubyException { - private IRubyObject success; - private IRubyObject failed; - - public static RubyFailure newInstance(Ruby runtime, RubyClass excptnClass, String msg) { - return new RubyFailure(runtime, excptnClass, msg); - } - - protected static final ObjectAllocator ICONV_FAILURE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyFailure(runtime, klass); - } - }; - - protected RubyFailure(Ruby runtime, RubyClass rubyClass) { - this(runtime, rubyClass, null); - } - - public RubyFailure(Ruby runtime, RubyClass rubyClass, String message) { - super(runtime, rubyClass, message); - } - - @JRubyMethod(name = "initialize", required = 1, optional = 2, frame = true) - public IRubyObject initialize(IRubyObject[] args, Block block) { - super.initialize(args, block); - success = args.length >= 2 ? args[1] : getRuntime().getNil(); - failed = args.length == 3 ? args[2] : getRuntime().getNil(); - - return this; - } - - @JRubyMethod(name = "success") - public IRubyObject success() { - return success; - } - - @JRubyMethod(name = "failed") - public IRubyObject failed() { - return failed; - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - RubyModule rubyClass = getMetaClass(); - StringBuilder buffer = new StringBuilder("#<"); - buffer.append(rubyClass.getName()).append(": ").append(success.inspect().toString()); - buffer.append(", ").append(failed.inspect().toString()).append(">"); - - return getRuntime().newString(buffer.toString()); - } - } - - private static String getCharset(String encoding) { - int index = encoding.indexOf("//"); - if (index == -1) return encoding; - return encoding.substring(0, index); - } - - /* Currently dead code, but useful when we figure out how to actually perform translit. - private static boolean isTranslit(String encoding) { - return encoding.toLowerCase().indexOf(TRANSLIT) != -1 ? true : false; - }*/ - - private static boolean isIgnore(String encoding) { - return encoding.toLowerCase().indexOf(IGNORE) != -1 ? true : false; - } - - @JRubyMethod(name = "open", required = 2, frame = true, meta = true) - public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject to, IRubyObject from, Block block) { - Ruby runtime = context.getRuntime(); - - RubyIconv iconv = newIconv(context, recv, to, from); - - if (!block.isGiven()) return iconv; - - IRubyObject result = runtime.getNil(); - try { - result = block.yield(context, iconv); - } finally { - iconv.close(); - } - - return result; - } - - private static RubyIconv newIconv(ThreadContext context, IRubyObject recv, - IRubyObject to, IRubyObject from) { - RubyClass klazz = (RubyClass)recv; - - return (RubyIconv) klazz.newInstance( - context, new IRubyObject[] {to, from}, Block.NULL_BLOCK); - } - - @JRubyMethod(name = "initialize", required = 2, frame = true) - public IRubyObject initialize(IRubyObject arg1, IRubyObject arg2, Block unusedBlock) { - Ruby runtime = getRuntime(); - if (!arg1.respondsTo("to_str")) { - throw runtime.newTypeError("can't convert " + arg1.getMetaClass() + " into String"); - } - if (!arg2.respondsTo("to_str")) { - throw runtime.newTypeError("can't convert " + arg2.getMetaClass() + " into String"); - } - - String to = arg1.convertToString().toString(); - String from = arg2.convertToString().toString(); - - try { - - fromEncoding = Charset.forName(getCharset(from)).newDecoder(); - toEncoding = Charset.forName(getCharset(to)).newEncoder(); - - if (!isIgnore(from)) fromEncoding.onUnmappableCharacter(CodingErrorAction.REPORT); - if (!isIgnore(to)) toEncoding.onUnmappableCharacter(CodingErrorAction.REPORT); - } catch (IllegalCharsetNameException e) { - throw runtime.newInvalidEncoding("invalid encoding"); - } catch (UnsupportedCharsetException e) { - throw runtime.newInvalidEncoding("invalid encoding"); - } catch (Exception e) { - throw runtime.newSystemCallError(e.toString()); - } - - return this; - } - - @JRubyMethod(name = "close") - public IRubyObject close() { - toEncoding = null; - fromEncoding = null; - return RubyString.newEmptyString(getRuntime()); - } - - @JRubyMethod - public IRubyObject iconv(IRubyObject str) { - return iconv(str, 0, -1); - } - - @JRubyMethod - public IRubyObject iconv(IRubyObject str, IRubyObject startArg) { - int start = 0; - if (!startArg.isNil()) start = RubyNumeric.fix2int(startArg); - return iconv(str, start, -1); - } - - @JRubyMethod - public IRubyObject iconv(IRubyObject str, IRubyObject startArg, IRubyObject endArg) { - int start = 0; - int end = -1; - - if (!startArg.isNil()) start = RubyNumeric.fix2int(startArg); - if (!endArg.isNil()) end = RubyNumeric.fix2int(endArg); - - return iconv(str, start, end); - } - - private IRubyObject iconv(IRubyObject str, int start, int end) { - if (str.isNil()) { - fromEncoding.reset(); - toEncoding.reset(); - return RubyString.newEmptyString(getRuntime()); - } - - return _iconv(str.convertToString(), start, end); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one, two or three arguments. - */ - public IRubyObject iconv(IRubyObject[] args) { - switch (args.length) { - case 1: - return iconv(args[0]); - case 2: - return iconv(args[0], args[1]); - case 3: - return iconv(args[0], args[1], args[2]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - // FIXME: We are assuming that original string will be raw bytes. If -Ku is provided - // this will not be true, but that is ok for now. Deal with that when someone needs it. - private IRubyObject _iconv(RubyString str, int start, int end) { - if (fromEncoding == null) { - throw getRuntime().newArgumentError("closed iconv"); - } - - ByteList bytes = str.getByteList(); - - // treat start and end as start...end for end >= 0, start..end for end < 0 - if (start < 0) { - start += bytes.length(); - } - - if (end < 0) { - end += 1 + bytes.length(); - } else if (end > bytes.length()) { - end = bytes.length(); - } - - if (start < 0 || end < start) { // invalid ranges result in an empty string - return RubyString.newEmptyString(getRuntime()); - } - - ByteBuffer buf = ByteBuffer.wrap(bytes.unsafeBytes(), bytes.begin() + start, end - start); - - try { - CharBuffer cbuf = fromEncoding.decode(buf); - buf = toEncoding.encode(cbuf); - } catch (MalformedInputException e) { - } catch (UnmappableCharacterException e) { - } catch (CharacterCodingException e) { - throw getRuntime().newInvalidEncoding("invalid sequence"); - } catch (IllegalStateException e) { - } - byte[] arr = buf.array(); - - return getRuntime().newString(new ByteList(arr, 0, buf.limit())); - } - - @JRubyMethod(name = "iconv", required = 2, rest = true, meta = true) - public static IRubyObject iconv(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - return convertWithArgs(context, recv, args, "iconv"); - } - - @JRubyMethod(name = "conv", required = 3, rest = true, meta = true) - public static IRubyObject conv(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - return convertWithArgs(context, recv, args, "conv").join(context, RubyString.newEmptyString(recv.getRuntime())); - } - - @JRubyMethod(name = "charset_map", meta= true) - public static IRubyObject charset_map_get(IRubyObject recv) { - return recv.getRuntime().getCharsetMap(); - } - - private static String mapCharset(ThreadContext context, IRubyObject val) { - RubyHash charset = val.getRuntime().getCharsetMap(); - if (charset.size() > 0) { - RubyString key = val.callMethod(context, "downcase").convertToString(); - IRubyObject tryVal = charset.fastARef(key); - if (tryVal != null) val = tryVal; - } - - return val.convertToString().toString(); - } - - public static RubyArray convertWithArgs(ThreadContext context, IRubyObject recv, IRubyObject[] args, String function) { - assert args.length >= 2; - - RubyArray array = context.getRuntime().newArray(args.length - 2); - RubyIconv iconv = newIconv(context, recv, args[0], args[1]); - - try { - for (int i = 2; i < args.length; i++) { - array.append(iconv.iconv(args[i])); - } - } finally { - iconv.close(); - } - - return array; - } - - /* - private static IRubyObject convert(String fromEncoding, String toEncoding, RubyString original) - throws UnsupportedEncodingException { - // Get all bytes from PLAIN string pretend they are not encoded in any way. - byte[] string = original.getBytes(); - // Now create a string pretending it is from fromEncoding - string = new String(string, fromEncoding).getBytes(toEncoding); - // Finally recode back to PLAIN - return RubyString.newString(original.getRuntime(), string); - } - */ -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import java.util.Set; -import java.util.StringTokenizer; -import org.jruby.ast.executable.Script; -import org.jruby.exceptions.MainExitException; -import org.jruby.runtime.Constants; -import org.jruby.runtime.load.LoadService; -import org.jruby.util.ClassCache; -import org.jruby.util.JRubyFile; -import org.jruby.util.KCode; -import org.jruby.util.NormalizedFile; -import org.jruby.util.SafePropertyAccessor; -import org.objectweb.asm.Opcodes; - -public class RubyInstanceConfig { - - /** - * The max count of active methods eligible for JIT-compilation. - */ - private static final int JIT_MAX_METHODS_LIMIT = 4096; - - /** - * The max size of JIT-compiled methods (full class size) allowed. - */ - private static final int JIT_MAX_SIZE_LIMIT = Integer.MAX_VALUE; - - /** - * The JIT threshold to the specified method invocation count. - */ - private static final int JIT_THRESHOLD = 50; - - /** The version to use for generated classes. Set to current JVM version by default */ - public static final int JAVA_VERSION; - - /** - * Default size for chained compilation. - */ - private static final int CHAINED_COMPILE_LINE_COUNT_DEFAULT = 500; - - /** - * The number of lines at which a method, class, or block body is split into - * chained methods (to dodge 64k method-size limit in JVM). - */ - public static final int CHAINED_COMPILE_LINE_COUNT - = SafePropertyAccessor.getInt("jruby.compile.chainsize", CHAINED_COMPILE_LINE_COUNT_DEFAULT); - - public enum CompileMode { - JIT, FORCE, OFF; - - public boolean shouldPrecompileCLI() { - switch (this) { - case JIT: case FORCE: - return true; - } - return false; - } - - public boolean shouldJIT() { - switch (this) { - case JIT: case FORCE: - return true; - } - return false; - } - - public boolean shouldPrecompileAll() { - return this == FORCE; - } - } - private InputStream input = System.in; - private PrintStream output = System.out; - private PrintStream error = System.err; - private Profile profile = Profile.DEFAULT; - private boolean objectSpaceEnabled - = SafePropertyAccessor.getBoolean("jruby.objectspace.enabled", false); - - private CompileMode compileMode = CompileMode.JIT; - private boolean runRubyInProcess = true; - private String currentDirectory; - private Map environment; - private String[] argv = {}; - - private final boolean jitLogging; - private final boolean jitLoggingVerbose; - private final int jitLogEvery; - private final int jitThreshold; - private final int jitMax; - private final int jitMaxSize; - private final boolean samplingEnabled; - private CompatVersion compatVersion; - - private ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); - private ClassLoader loader = contextLoader == null ? RubyInstanceConfig.class.getClassLoader() : contextLoader; - - private ClassCache<Script> classCache; - - // from CommandlineParser - private List<String> loadPaths = new ArrayList<String>(); - private Set<String> excludedMethods = new HashSet<String>(); - private StringBuffer inlineScript = new StringBuffer(); - private boolean hasInlineScript = false; - private String scriptFileName = null; - private List<String> requiredLibraries = new ArrayList<String>(); - private boolean benchmarking = false; - private boolean argvGlobalsOn = false; - private boolean assumeLoop = false; - private boolean assumePrinting = false; - private Map optionGlobals = new HashMap(); - private boolean processLineEnds = false; - private boolean split = false; - // This property is a Boolean, to allow three values, so it can match MRI's nil, false and true - private Boolean verbose = Boolean.FALSE; - private boolean debug = false; - private boolean showVersion = false; - private boolean showBytecode = false; - private boolean showCopyright = false; - private boolean endOfArguments = false; - private boolean shouldRunInterpreter = true; - private boolean shouldPrintUsage = false; - private boolean shouldPrintProperties=false; - private boolean yarv = false; - private boolean rubinius = false; - private boolean yarvCompile = false; - private KCode kcode = KCode.NONE; - private String recordSeparator = "\n"; - private boolean shouldCheckSyntax = false; - private String inputFieldSeparator = null; - private boolean managementEnabled = true; - - private int safeLevel = 0; - - private String jrubyHome; - - public static final boolean FASTEST_COMPILE_ENABLED - = SafePropertyAccessor.getBoolean("jruby.compile.fastest"); - public static final boolean BOXED_COMPILE_ENABLED - = FASTEST_COMPILE_ENABLED - || SafePropertyAccessor.getBoolean("jruby.compile.boxed"); - public static final boolean FASTOPS_COMPILE_ENABLED - = FASTEST_COMPILE_ENABLED - || SafePropertyAccessor.getBoolean("jruby.compile.fastops"); - public static final boolean FRAMELESS_COMPILE_ENABLED - = FASTEST_COMPILE_ENABLED - || SafePropertyAccessor.getBoolean("jruby.compile.frameless"); - public static final boolean POSITIONLESS_COMPILE_ENABLED - = FASTEST_COMPILE_ENABLED - || SafePropertyAccessor.getBoolean("jruby.compile.positionless"); - public static final boolean THREADLESS_COMPILE_ENABLED - = FASTEST_COMPILE_ENABLED - || SafePropertyAccessor.getBoolean("jruby.compile.threadless"); - public static final boolean LAZYHANDLES_COMPILE = SafePropertyAccessor.getBoolean("jruby.compile.lazyHandles", false); - public static final boolean FORK_ENABLED - = SafePropertyAccessor.getBoolean("jruby.fork.enabled"); - public static final boolean POOLING_ENABLED - = SafePropertyAccessor.getBoolean("jruby.thread.pool.enabled"); - public static final int POOL_MAX - = SafePropertyAccessor.getInt("jruby.thread.pool.max", Integer.MAX_VALUE); - public static final int POOL_MIN - = SafePropertyAccessor.getInt("jruby.thread.pool.min", 0); - public static final int POOL_TTL - = SafePropertyAccessor.getInt("jruby.thread.pool.ttl", 60); - - public static final boolean NATIVE_NET_PROTOCOL - = SafePropertyAccessor.getBoolean("jruby.native.net.protocol", false); - - public static boolean FULL_TRACE_ENABLED - = SafePropertyAccessor.getBoolean("jruby.debug.fullTrace", false); - - public static final String COMPILE_EXCLUDE - = SafePropertyAccessor.getProperty("jruby.jit.exclude"); - public static boolean nativeEnabled = true; - - - public static interface LoadServiceCreator { - LoadService create(Ruby runtime); - - LoadServiceCreator DEFAULT = new LoadServiceCreator() { - public LoadService create(Ruby runtime) { - return new LoadService(runtime); - } - }; - } - - private LoadServiceCreator creator = LoadServiceCreator.DEFAULT; - - - static { - String specVersion = null; - try { - specVersion = System.getProperty("jruby.bytecode.version"); - if (specVersion == null) { - specVersion = System.getProperty("java.specification.version"); - } - if (System.getProperty("jruby.native.enabled") != null) { - nativeEnabled = Boolean.getBoolean("jruby.native.enabled"); - } - } catch (SecurityException se) { - nativeEnabled = false; - specVersion = "1.5"; - } - - if (specVersion.equals("1.5")) { - JAVA_VERSION = Opcodes.V1_5; - } else { - JAVA_VERSION = Opcodes.V1_6; - } - } - - public int characterIndex = 0; - - public RubyInstanceConfig() { - if (Ruby.isSecurityRestricted()) - currentDirectory = "/"; - else { - currentDirectory = JRubyFile.getFileProperty("user.dir"); - } - - samplingEnabled = SafePropertyAccessor.getBoolean("jruby.sampling.enabled", false); - String compatString = SafePropertyAccessor.getProperty("jruby.compat.version", "RUBY1_8"); - if (compatString.equalsIgnoreCase("RUBY1_8")) { - compatVersion = CompatVersion.RUBY1_8; - } else if (compatString.equalsIgnoreCase("RUBY1_9")) { - compatVersion = CompatVersion.RUBY1_9; - } else { - System.err.println("Compatibility version `" + compatString + "' invalid; use RUBY1_8 or RUBY1_9. Using RUBY1_8."); - compatVersion = CompatVersion.RUBY1_8; - } - - if (Ruby.isSecurityRestricted()) { - compileMode = CompileMode.OFF; - jitLogging = false; - jitLoggingVerbose = false; - jitLogEvery = 0; - jitThreshold = -1; - jitMax = 0; - jitMaxSize = -1; - managementEnabled = false; - } else { - String threshold = SafePropertyAccessor.getProperty("jruby.jit.threshold"); - String max = SafePropertyAccessor.getProperty("jruby.jit.max"); - String maxSize = SafePropertyAccessor.getProperty("jruby.jit.maxsize"); - - if (COMPILE_EXCLUDE != null) { - String[] elements = COMPILE_EXCLUDE.split(","); - for (String element : elements) excludedMethods.add(element); - } - - managementEnabled = SafePropertyAccessor.getBoolean("jruby.management.enabled", true); - runRubyInProcess = SafePropertyAccessor.getBoolean("jruby.launch.inproc", true); - boolean jitProperty = SafePropertyAccessor.getProperty("jruby.jit.enabled") != null; - if (jitProperty) { - error.print("jruby.jit.enabled property is deprecated; use jruby.compile.mode=(OFF|JIT|FORCE) for -C, default, and +C flags"); - compileMode = SafePropertyAccessor.getBoolean("jruby.jit.enabled") ? CompileMode.JIT : CompileMode.OFF; - } else { - String jitModeProperty = SafePropertyAccessor.getProperty("jruby.compile.mode", "JIT"); - - if (jitModeProperty.equals("OFF")) { - compileMode = CompileMode.OFF; - } else if (jitModeProperty.equals("JIT")) { - compileMode = CompileMode.JIT; - } else if (jitModeProperty.equals("FORCE")) { - compileMode = CompileMode.FORCE; - } else { - error.print("jruby.compile.mode property must be OFF, JIT, FORCE, or unset; defaulting to JIT"); - compileMode = CompileMode.JIT; - } - } - jitLogging = SafePropertyAccessor.getBoolean("jruby.jit.logging"); - jitLoggingVerbose = SafePropertyAccessor.getBoolean("jruby.jit.logging.verbose"); - String logEvery = SafePropertyAccessor.getProperty("jruby.jit.logEvery"); - jitLogEvery = logEvery == null ? 0 : Integer.parseInt(logEvery); - jitThreshold = threshold == null ? - JIT_THRESHOLD : Integer.parseInt(threshold); - jitMax = max == null ? - JIT_MAX_METHODS_LIMIT : Integer.parseInt(max); - jitMaxSize = maxSize == null ? - JIT_MAX_SIZE_LIMIT : Integer.parseInt(maxSize); - } - - // default ClassCache using jitMax as a soft upper bound - classCache = new ClassCache<Script>(loader, jitMax); - - if (FORK_ENABLED) { - error.print("WARNING: fork is highly unlikely to be safe or stable on the JVM. Have fun!\n"); - } - } - - public LoadServiceCreator getLoadServiceCreator() { - return creator; - } - - public void setLoadServiceCreator(LoadServiceCreator creator) { - this.creator = creator; - } - - public LoadService createLoadService(Ruby runtime) { - return this.creator.create(runtime); - } - - public String getBasicUsageHelp() { - StringBuilder sb = new StringBuilder(); - sb - .append("Usage: jruby [switches] [--] [programfile] [arguments]\n") - .append(" -0[octal] specify record separator (\0, if no argument)\n") - .append(" -a autosplit mode with -n or -p (splits $_ into $F)\n") - .append(" -b benchmark mode, times the script execution\n") - .append(" -c check syntax only\n") - .append(" -Cdirectory cd to directory, before executing your script\n") - .append(" -d set debugging flags (set $DEBUG to true)\n") - .append(" -e 'command' one line of script. Several -e's allowed. Omit [programfile]\n") - .append(" -Fpattern split() pattern for autosplit (-a)\n") - //.append(" -i[extension] edit ARGV files in place (make backup if extension supplied)\n") - .append(" -Idirectory specify $LOAD_PATH directory (may be used more than once)\n") - .append(" -J[java option] pass an option on to the JVM (e.g. -J-Xmx512m)\n") - .append(" use --properties to list JRuby properties\n") - .append(" run 'java -help' for a list of other Java options\n") - .append(" -Kkcode specifies code-set (e.g. -Ku for Unicode\n") - .append(" -l enable line ending processing\n") - .append(" -n assume 'while gets(); ... end' loop around your script\n") - .append(" -p assume loop like -n but print line also like sed\n") - .append(" -rlibrary require the library, before executing your script\n") - .append(" -s enable some switch parsing for switches after script name\n") - .append(" -S look for the script in bin or using PATH environment variable\n") - .append(" -T[level] turn on tainting checks\n") - .append(" -v print version number, then turn on verbose mode\n") - .append(" -w turn warnings on for your script\n") - .append(" -W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)\n") - //.append(" -x[directory] strip off text before #!ruby line and perhaps cd to directory\n") - .append(" -X[option] enable extended option (omit option to list)\n") - .append(" --copyright print the copyright\n") - .append(" --debug sets the execution mode most suitable for debugger functionality\n") - .append(" --jdb runs JRuby process under JDB\n") - .append(" --properties List all configuration Java properties (pass -J-Dproperty=value)\n") - .append(" --sample run with profiling using the JVM's sampling profiler\n") - .append(" --client use the non-optimizing \"client\" JVM (improves startup; default)\n") - .append(" --server use the optimizing \"server\" JVM (improves perf)\n") - .append(" --manage enable remote JMX management and monitoring of the VM and JRuby\n") - .append(" --1.8 specify Ruby 1.8.x compatibility (default)\n") - .append(" --1.9 specify Ruby 1.9.x compatibility\n") - .append(" --bytecode show the JVM bytecode produced by compiling specified code\n") - .append(" --version print the version\n"); - - return sb.toString(); - } - - public String getExtendedHelp() { - StringBuilder sb = new StringBuilder(); - sb - .append("These flags are for extended JRuby options.\n") - .append("Specify them by passing -X<option>\n") - .append(" -O run with ObjectSpace disabled (default; improves performance)\n") - .append(" +O run with ObjectSpace enabled (reduces performance)\n") - .append(" -C disable all compilation\n") - .append(" +C force compilation of all scripts before they are run (except eval)\n") - .append(" -y read a YARV-compiled Ruby script and run that (EXPERIMENTAL)\n") - .append(" -Y compile a Ruby script into YARV bytecodes and run this (EXPERIMENTAL)\n") - .append(" -R read a Rubinius-compiled Ruby script and run that (EXPERIMENTAL)\n"); - - return sb.toString(); - } - - public String getPropertyHelp() { - StringBuilder sb = new StringBuilder(); - sb - .append("These properties can be used to alter runtime behavior for perf or compatibility.\n") - .append("Specify them by passing -J-D<property>=<value>\n") - .append("\nCOMPILER SETTINGS:\n") - .append(" jruby.compile.mode=JIT|FORCE|OFF\n") - .append(" Set compilation mode. JIT is default; FORCE compiles all, OFF disables\n") - .append(" jruby.compile.fastest=true|false\n") - .append(" (EXPERIMENTAL) Turn on all experimental compiler optimizations\n") - .append(" jruby.compile.boxed=true|false\n") - .append(" (EXPERIMENTAL) Use boxed variables; this can speed up some methods. Default is false\n") - .append(" jruby.compile.frameless=true|false\n") - .append(" (EXPERIMENTAL) Turn on frameless compilation where possible\n") - .append(" jruby.compile.positionless=true|false\n") - .append(" (EXPERIMENTAL) Turn on compilation that avoids updating Ruby position info. Default is false\n") - .append(" jruby.compile.threadless=true|false\n") - .append(" (EXPERIMENTAL) Turn on compilation without polling for \"unsafe\" thread events. Default is false\n") - .append(" jruby.compile.fastops=true|false\n") - .append(" (EXPERIMENTAL) Turn on fast operators for Fixnum. Default is false\n") - .append(" jruby.compile.chainsize=<line count>\n") - .append(" Set the number of lines at which compiled bodies are \"chained\". Default is " + CHAINED_COMPILE_LINE_COUNT_DEFAULT + "\n") - .append(" jruby.compile.lazyHandles=true|false\n") - .append(" Generate method bindings (handles) for compiled methods lazily. Default is false.") - .append("\nJIT SETTINGS:\n") - .append(" jruby.jit.threshold=<invocation count>\n") - .append(" Set the JIT threshold to the specified method invocation count. Default is " + JIT_THRESHOLD + ".\n") - .append(" jruby.jit.max=<method count>\n") - .append(" Set the max count of active methods eligible for JIT-compilation.\n") - .append(" Default is " + JIT_MAX_METHODS_LIMIT + " per runtime. A value of 0 disables JIT, -1 disables max.\n") - .append(" jruby.jit.maxsize=<jitted method size (full .class)>\n") - .append(" Set the maximum full-class byte size allowed for jitted methods. Default is Integer.MAX_VALUE\n") - .append(" jruby.jit.logging=true|false\n") - .append(" Enable JIT logging (reports successful compilation). Default is false\n") - .append(" jruby.jit.logging.verbose=true|false\n") - .append(" Enable verbose JIT logging (reports failed compilation). Default is false\n") - .append(" jruby.jit.logEvery=<method count>\n") - .append(" Log a message every n methods JIT compiled. Default is 0 (off).\n") - .append(" jruby.jit.exclude=<ClsOrMod,ClsOrMod::method_name,-::method_name>\n") - .append(" Exclude methods from JIT by class/module short name, c/m::method_name,\n") - .append(" or -::method_name for anon/singleton classes/modules. Comma-delimited.\n") - .append("\nNATIVE SUPPORT:\n") - .append(" jruby.native.enabled=true|false\n") - .append(" Enable/disable native extensions (like JNA for non-Java APIs; Default is true\n") - .append(" (This affects all JRuby instances in a given JVM)\n") - .append(" jruby.native.verbose=true|false\n") - .append(" Enable verbose logging of native extension loading. Default is false.\n") - .append(" jruby.fork.enabled=true|false\n") - .append(" (EXPERIMENTAL, maybe dangerous) Enable fork(2) on platforms that support it.\n") - .append("\nTHREAD POOLING:\n") - .append(" jruby.thread.pool.enabled=true|false\n") - .append(" Enable reuse of native backing threads via a thread pool. Default is false.\n") - .append(" jruby.thread.pool.min=<min thread count>\n") - .append(" The minimum number of threads to keep alive in the pool. Default is 0.\n") - .append(" jruby.thread.pool.max=<max thread count>\n") - .append(" The maximum number of threads to allow in the pool. Default is unlimited.\n") - .append(" jruby.thread.pool.ttl=<time to live, in seconds>\n") - .append(" The maximum number of seconds to keep alive an idle thread. Default is 60.\n") - .append("\nMISCELLANY:\n") - .append(" jruby.compat.version=RUBY1_8|RUBY1_9\n") - .append(" Specify the major Ruby version to be compatible with; Default is RUBY1_8\n") - .append(" jruby.objectspace.enabled=true|false\n") - .append(" Enable or disable ObjectSpace.each_object (default is disabled)\n") - .append(" jruby.launch.inproc=true|false\n") - .append(" Set in-process launching of e.g. system('ruby ...'). Default is true\n") - .append(" jruby.bytecode.version=1.5|1.6\n") - .append(" Set bytecode version for JRuby to generate. Default is current JVM version.\n") - .append(" jruby.management.enabled=true|false\n") - .append(" Set whether JMX management is enabled. Default is true.\n") - .append(" jruby.debug.fullTrace=true|false\n") - .append(" Set whether full traces are enabled (c-call/c-return). Default is false.\n"); - - return sb.toString(); - } - - public String getVersionString() { - String ver = Constants.RUBY_VERSION; - switch (compatVersion) { - case RUBY1_8: - ver = Constants.RUBY_VERSION; - break; - case RUBY1_9: - ver = Constants.RUBY1_9_VERSION; - break; - } - - String fullVersion = String.format( - "jruby %s (ruby %s patchlevel %s) (%s rev %s) [%s-java]\n", - Constants.VERSION, ver, Constants.RUBY_PATCHLEVEL, - Constants.COMPILE_DATE, Constants.REVISION, - SafePropertyAccessor.getProperty("os.arch", "unknown") - ); - - return fullVersion; - } - - public String getCopyrightString() { - return "JRuby - Copyright (C) 2001-2008 The JRuby Community (and contribs)\n"; - } - - public void processArguments(String[] arguments) { - new ArgumentProcessor(arguments).processArguments(); - } - - public CompileMode getCompileMode() { - return compileMode; - } - - public void setCompileMode(CompileMode compileMode) { - this.compileMode = compileMode; - } - - public boolean isJitLogging() { - return jitLogging; - } - - public boolean isJitLoggingVerbose() { - return jitLoggingVerbose; - } - - public int getJitLogEvery() { - return jitLogEvery; - } - - public boolean isSamplingEnabled() { - return samplingEnabled; - } - - public int getJitThreshold() { - return jitThreshold; - } - - public int getJitMax() { - return jitMax; - } - - public int getJitMaxSize() { - return jitMaxSize; - } - - public boolean isRunRubyInProcess() { - return runRubyInProcess; - } - - public void setRunRubyInProcess(boolean flag) { - this.runRubyInProcess = flag; - } - - public void setInput(InputStream newInput) { - input = newInput; - } - - public InputStream getInput() { - return input; - } - - public CompatVersion getCompatVersion() { - return compatVersion; - } - - public void setOutput(PrintStream newOutput) { - output = newOutput; - } - - public PrintStream getOutput() { - return output; - } - - public void setError(PrintStream newError) { - error = newError; - } - - public PrintStream getError() { - return error; - } - - public void setCurrentDirectory(String newCurrentDirectory) { - currentDirectory = newCurrentDirectory; - } - - public String getCurrentDirectory() { - return currentDirectory; - } - - public void setProfile(Profile newProfile) { - profile = newProfile; - } - - public Profile getProfile() { - return profile; - } - - public void setObjectSpaceEnabled(boolean newObjectSpaceEnabled) { - objectSpaceEnabled = newObjectSpaceEnabled; - } - - public boolean isObjectSpaceEnabled() { - return objectSpaceEnabled; - } - - public void setEnvironment(Map newEnvironment) { - environment = newEnvironment; - } - - public Map getEnvironment() { - return environment; - } - - public ClassLoader getLoader() { - return loader; - } - - public void setLoader(ClassLoader loader) { - // Setting the loader needs to reset the class cache - if(this.loader != loader) { - this.classCache = new ClassCache<Script>(loader, this.classCache.getMax()); - } - this.loader = loader; - } - - public String[] getArgv() { - return argv; - } - - public void setArgv(String[] argv) { - this.argv = argv; - } - - public String getJRubyHome() { - if (jrubyHome == null) { - if (Ruby.isSecurityRestricted()) { - return "SECURITY RESTRICTED"; - } - jrubyHome = verifyHome(SafePropertyAccessor.getProperty("jruby.home", - SafePropertyAccessor.getProperty("user.home") + "/.jruby")); - - try { - // This comment also in rbConfigLibrary - // Our shell scripts pass in non-canonicalized paths, but even if we didn't - // anyone who did would become unhappy because Ruby apps expect no relative - // operators in the pathname (rubygems, for example). - jrubyHome = new NormalizedFile(jrubyHome).getCanonicalPath(); - } catch (IOException e) { } - - jrubyHome = new NormalizedFile(jrubyHome).getAbsolutePath(); - } - return jrubyHome; - } - - public void setJRubyHome(String home) { - jrubyHome = verifyHome(home); - } - - // We require the home directory to be absolute - private String verifyHome(String home) { - if (home.equals(".")) { - home = System.getProperty("user.dir"); - } - if (!home.startsWith("file:")) { - NormalizedFile f = new NormalizedFile(home); - if (!f.isAbsolute()) { - home = f.getAbsolutePath(); - } - f.mkdirs(); - } - return home; - } - - private class ArgumentProcessor { - private String[] arguments; - private int argumentIndex = 0; - - public ArgumentProcessor(String[] arguments) { - this.arguments = arguments; - } - - public void processArguments() { - while (argumentIndex < arguments.length && isInterpreterArgument(arguments[argumentIndex])) { - processArgument(); - argumentIndex++; - } - - if (!hasInlineScript && scriptFileName == null) { - if (argumentIndex < arguments.length) { - setScriptFileName(arguments[argumentIndex]); //consume the file name - argumentIndex++; - } - } - - processArgv(); - } - - private void processArgv() { - List<String> arglist = new ArrayList<String>(); - for (; argumentIndex < arguments.length; argumentIndex++) { - String arg = arguments[argumentIndex]; - if (argvGlobalsOn && arg.startsWith("-")) { - arg = arg.substring(1); - if (arg.indexOf('=') > 0) { - String[] keyvalue = arg.split("=", 2); - optionGlobals.put(keyvalue[0], keyvalue[1]); - } else { - optionGlobals.put(arg, null); - } - } else { - argvGlobalsOn = false; - arglist.add(arg); - } - } - - // Remaining arguments are for the script itself - argv = arglist.toArray(new String[arglist.size()]); - } - - private boolean isInterpreterArgument(String argument) { - return (argument.charAt(0) == '-' || argument.charAt(0) == '+') && !endOfArguments; - } - - private String getArgumentError(String additionalError) { - return "jruby: invalid argument\n" + additionalError + "\n"; - } - - private void processArgument() { - String argument = arguments[argumentIndex]; - FOR : for (characterIndex = 1; characterIndex < argument.length(); characterIndex++) { - switch (argument.charAt(characterIndex)) { - case '0': { - String temp = grabOptionalValue(); - if (null == temp) { - recordSeparator = "\u0000"; - } else if (temp.equals("0")) { - recordSeparator = "\n\n"; - } else if (temp.equals("777")) { - recordSeparator = "\uFFFF"; // Specify something that can't separate - } else { - try { - int val = Integer.parseInt(temp, 8); - recordSeparator = "" + (char) val; - } catch (Exception e) { - MainExitException mee = new MainExitException(1, getArgumentError(" -0 must be followed by either 0, 777, or a valid octal value")); - mee.setUsageError(true); - throw mee; - } - } - break FOR; - } - case 'a': - split = true; - break; - case 'b': - benchmarking = true; - break; - case 'c': - shouldCheckSyntax = true; - break; - case 'C': - try { - String saved = grabValue(getArgumentError(" -C must be followed by a directory expression")); - File base = new File(currentDirectory); - File newDir = new File(saved); - if (newDir.isAbsolute()) { - currentDirectory = newDir.getCanonicalPath(); - } else { - currentDirectory = new File(base, newDir.getPath()).getCanonicalPath(); - } - if (!(new File(currentDirectory).isDirectory())) { - MainExitException mee = new MainExitException(1, "jruby: Can't chdir to " + saved + " (fatal)"); - mee.setUsageError(true); - throw mee; - } - } catch (IOException e) { - MainExitException mee = new MainExitException(1, getArgumentError(" -C must be followed by a valid directory")); - mee.setUsageError(true); - throw mee; - } - break; - case 'd': - debug = true; - verbose = Boolean.TRUE; - break; - case 'e': - inlineScript.append(grabValue(getArgumentError(" -e must be followed by an expression to evaluate"))); - inlineScript.append('\n'); - hasInlineScript = true; - break FOR; - case 'F': - inputFieldSeparator = grabValue(getArgumentError(" -F must be followed by a pattern for input field separation")); - break; - case 'h': - shouldPrintUsage = true; - shouldRunInterpreter = false; - break; - // FIXME: -i flag not supported -// case 'i' : -// break; - case 'I': - String s = grabValue(getArgumentError("-I must be followed by a directory name to add to lib path")); - String[] ls = s.split(java.io.File.pathSeparator); - for (int i = 0; i < ls.length; i++) { - loadPaths.add(ls[i]); - } - break FOR; - case 'K': - // FIXME: No argument seems to work for -K in MRI plus this should not - // siphon off additional args 'jruby -K ~/scripts/foo'. Also better error - // processing. - String eArg = grabValue(getArgumentError("provide a value for -K")); - kcode = KCode.create(null, eArg); - break; - case 'l': - processLineEnds = true; - break; - case 'n': - assumeLoop = true; - break; - case 'p': - assumePrinting = true; - assumeLoop = true; - break; - case 'r': - requiredLibraries.add(grabValue(getArgumentError("-r must be followed by a package to require"))); - break FOR; - case 's' : - argvGlobalsOn = true; - break; - case 'S': - runBinScript(); - break FOR; - case 'T' :{ - String temp = grabOptionalValue(); - int value = 1; - - if(temp!=null) { - try { - value = Integer.parseInt(temp, 8); - } catch(Exception e) { - value = 1; - } - } - - safeLevel = value; - - break FOR; - } - case 'v': - verbose = Boolean.TRUE; - setShowVersion(true); - break; - case 'w': - verbose = Boolean.TRUE; - break; - case 'W': { - String temp = grabOptionalValue(); - int value = 2; - if (null != temp) { - if (temp.equals("2")) { - value = 2; - } else if (temp.equals("1")) { - value = 1; - } else if (temp.equals("0")) { - value = 0; - } else { - MainExitException mee = new MainExitException(1, getArgumentError(" -W must be followed by either 0, 1, 2 or nothing")); - mee.setUsageError(true); - throw mee; - } - } - switch (value) { - case 0: - verbose = null; - break; - case 1: - verbose = Boolean.FALSE; - break; - case 2: - verbose = Boolean.TRUE; - break; - } - - - break FOR; - } - // FIXME: -x flag not supported -// case 'x' : -// break; - case 'X': - String extendedOption = grabOptionalValue(); - - if (extendedOption == null) { - throw new MainExitException(0, "jruby: missing extended option, listing available options\n" + getExtendedHelp()); - } else if (extendedOption.equals("-O")) { - objectSpaceEnabled = false; - } else if (extendedOption.equals("+O")) { - objectSpaceEnabled = true; - } else if (extendedOption.equals("-C")) { - compileMode = CompileMode.OFF; - } else if (extendedOption.equals("+C")) { - compileMode = CompileMode.FORCE; - } else if (extendedOption.equals("-y")) { - yarv = true; - } else if (extendedOption.equals("-Y")) { - yarvCompile = true; - } else if (extendedOption.equals("-R")) { - rubinius = true; - } else { - MainExitException mee = - new MainExitException(1, "jruby: invalid extended option " + extendedOption + " (-X will list valid options)\n"); - mee.setUsageError(true); - - throw mee; - } - break FOR; - case '-': - if (argument.equals("--command") || argument.equals("--bin")) { - characterIndex = argument.length(); - runBinScript(); - break; - } else if (argument.equals("--compat")) { - characterIndex = argument.length(); - compatVersion = CompatVersion.getVersionFromString(grabValue(getArgumentError("--compat must be RUBY1_8 or RUBY1_9"))); - if (compatVersion == null) { - compatVersion = CompatVersion.RUBY1_8; - } - break FOR; - } else if (argument.equals("--copyright")) { - setShowCopyright(true); - shouldRunInterpreter = false; - break FOR; - } else if (argument.equals("--debug")) { - compileMode = CompileMode.OFF; - FULL_TRACE_ENABLED = true; - System.setProperty("jruby.reflection", "true"); - break FOR; - } else if (argument.equals("--jdb")) { - debug = true; - verbose = Boolean.TRUE; - break; - } else if (argument.equals("--help")) { - shouldPrintUsage = true; - shouldRunInterpreter = false; - break; - } else if (argument.equals("--properties")) { - shouldPrintProperties = true; - shouldRunInterpreter = false; - break; - } else if (argument.equals("--version")) { - setShowVersion(true); - break FOR; - } else if (argument.equals("--bytecode")) { - setShowBytecode(true); - break FOR; - } else { - if (argument.equals("--")) { - // ruby interpreter compatibilty - // Usage: ruby [switches] [--] [programfile] [arguments]) - endOfArguments = true; - break; - } - } - default: - throw new MainExitException(1, "jruby: unknown option " + argument); - } - } - } - - private void runBinScript() { - String scriptName = grabValue("jruby: provide a bin script to execute"); - if (scriptName.equals("irb")) { - scriptName = "jirb"; - } - - scriptFileName = scriptName; - - if (!new File(scriptFileName).exists()) { - try { - String jrubyHome = JRubyFile.create(System.getProperty("user.dir"), JRubyFile.getFileProperty("jruby.home")).getCanonicalPath(); - scriptFileName = JRubyFile.create(jrubyHome + JRubyFile.separator + "bin", scriptName).getCanonicalPath(); - } catch (IOException io) { - MainExitException mee = new MainExitException(1, "jruby: Can't determine script filename"); - mee.setUsageError(true); - throw mee; - } - } - - // route 'gem' through ruby code in case we're running out of the complete jar - if (scriptName.equals("gem") || !new File(scriptFileName).exists()) { - requiredLibraries.add("jruby/commands"); - inlineScript.append("JRuby::Commands." + scriptName); - inlineScript.append("\n"); - hasInlineScript = true; - } - endOfArguments = true; - } - - private String grabValue(String errorMessage) { - characterIndex++; - if (characterIndex < arguments[argumentIndex].length()) { - return arguments[argumentIndex].substring(characterIndex); - } - argumentIndex++; - if (argumentIndex < arguments.length) { - return arguments[argumentIndex]; - } - - MainExitException mee = new MainExitException(1, errorMessage); - mee.setUsageError(true); - - throw mee; - } - - private String grabOptionalValue() { - characterIndex++; - if (characterIndex < arguments[argumentIndex].length()) { - return arguments[argumentIndex].substring(characterIndex); - } - return null; - } - } - - public byte[] inlineScript() { - return inlineScript.toString().getBytes(); - } - - public List<String> requiredLibraries() { - return requiredLibraries; - } - - public List<String> loadPaths() { - return loadPaths; - } - - public boolean shouldRunInterpreter() { - if(isShowVersion() && (hasInlineScript || scriptFileName != null)) { - return true; - } - return isShouldRunInterpreter(); - } - - public boolean shouldPrintUsage() { - return shouldPrintUsage; - } - - public boolean shouldPrintProperties() { - return shouldPrintProperties; - } - - private boolean isSourceFromStdin() { - return getScriptFileName() == null; - } - - public boolean isInlineScript() { - return hasInlineScript; - } - - public InputStream getScriptSource() { - try { - // KCode.NONE is used because KCODE does not affect parse in Ruby 1.8 - // if Ruby 2.0 encoding pragmas are implemented, this will need to change - if (hasInlineScript) { - return new ByteArrayInputStream(inlineScript()); - } else if (isSourceFromStdin()) { - // can't use -v and stdin - if (isShowVersion()) { - return null; - } - return getInput(); - } else { - File file = JRubyFile.create(getCurrentDirectory(), getScriptFileName()); - return new BufferedInputStream(new FileInputStream(file)); - } - } catch (IOException e) { - throw new MainExitException(1, "Error opening script file: " + e.getMessage()); - } - } - - public String displayedFileName() { - if (hasInlineScript) { - if (scriptFileName != null) { - return scriptFileName; - } else { - return "-e"; - } - } else if (isSourceFromStdin()) { - return "-"; - } else { - return getScriptFileName(); - } - } - - private void setScriptFileName(String scriptFileName) { - this.scriptFileName = scriptFileName; - } - - public String getScriptFileName() { - return scriptFileName; - } - - public boolean isBenchmarking() { - return benchmarking; - } - - public boolean isAssumeLoop() { - return assumeLoop; - } - - public boolean isAssumePrinting() { - return assumePrinting; - } - - public boolean isProcessLineEnds() { - return processLineEnds; - } - - public boolean isSplit() { - return split; - } - - public boolean isVerbose() { - return verbose == Boolean.TRUE; - } - - public Boolean getVerbose() { - return verbose; - } - - public boolean isDebug() { - return debug; - } - - public boolean isShowVersion() { - return showVersion; - } - - public boolean isShowBytecode() { - return showBytecode; - } - - public boolean isShowCopyright() { - return showCopyright; - } - - protected void setShowVersion(boolean showVersion) { - this.showVersion = showVersion; - } - - protected void setShowBytecode(boolean showBytecode) { - this.showBytecode = showBytecode; - } - - protected void setShowCopyright(boolean showCopyright) { - this.showCopyright = showCopyright; - } - - public boolean isShouldRunInterpreter() { - return shouldRunInterpreter; - } - - public boolean isShouldCheckSyntax() { - return shouldCheckSyntax; - } - - public boolean isYARVEnabled() { - return yarv; - } - - public String getInputFieldSeparator() { - return inputFieldSeparator; - } - - public boolean isRubiniusEnabled() { - return rubinius; - } - - public boolean isYARVCompileEnabled() { - return yarvCompile; - } - - public KCode getKCode() { - return kcode; - } - - public String getRecordSeparator() { - return recordSeparator; - } - - public int getSafeLevel() { - return safeLevel; - } - - public void setRecordSeparator(String recordSeparator) { - this.recordSeparator = recordSeparator; - } - - public ClassCache getClassCache() { - return classCache; - } - - public void setClassCache(ClassCache classCache) { - this.classCache = classCache; - } - - public Map getOptionGlobals() { - return optionGlobals; - } - - public boolean isManagementEnabled() { - return managementEnabled; - } - - public Set getExcludedMethods() { - return excludedMethods; - } - -} -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Block; -import org.jruby.runtime.BlockBody; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; - -/** Implementation of the Integer class. - * - * @author jpetersen - */ -@JRubyClass(name="Integer", parent="Numeric", include="Precision") -public abstract class RubyInteger extends RubyNumeric { - - public static RubyClass createIntegerClass(Ruby runtime) { - RubyClass integer = runtime.defineClass("Integer", runtime.getNumeric(), - ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setInteger(integer); - integer.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyInteger; - } - }; - - integer.getSingletonClass().undefineMethod("new"); - - integer.includeModule(runtime.getPrecision()); - - integer.defineAnnotatedMethods(RubyInteger.class); - - return integer; - } - - public RubyInteger(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass); - } - - public RubyInteger(Ruby runtime, RubyClass rubyClass, boolean useObjectSpace) { - super(runtime, rubyClass, useObjectSpace); - } - - public RubyInteger convertToInteger() { - return this; - } - - // conversion - protected RubyFloat toFloat() { - return RubyFloat.newFloat(getRuntime(), getDoubleValue()); - } - - /* ================ - * Instance Methods - * ================ - */ - - /** int_int_p - * - */ - @JRubyMethod(name = "integer?") - public IRubyObject integer_p() { - return getRuntime().getTrue(); - } - - /** int_upto - * - */ - @JRubyMethod(name = "upto", frame = true) - public IRubyObject upto(ThreadContext context, IRubyObject to, Block block) { - final Ruby runtime = getRuntime(); - - if (this instanceof RubyFixnum && to instanceof RubyFixnum) { - RubyFixnum toFixnum = (RubyFixnum) to; - final long toValue = toFixnum.getLongValue(); - final long fromValue = getLongValue(); - - if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { - final IRubyObject nil = runtime.getNil(); - for (long i = fromValue; i <= toValue; i++) { - block.yield(context, nil); - } - } else { - for (long i = fromValue; i <= toValue; i++) { - block.yield(context, RubyFixnum.newFixnum(runtime, i)); - } - } - } else { - RubyNumeric i = this; - - while (true) { - if (i.callMethod(context, MethodIndex.OP_GT, ">", to).isTrue()) { - break; - } - block.yield(context, i); - i = (RubyNumeric) i.callMethod(context, MethodIndex.OP_PLUS, "+", RubyFixnum.one(runtime)); - } - } - return this; - } - - /** int_downto - * - */ - // TODO: Make callCoerced work in block context...then fix downto, step, and upto. - @JRubyMethod(name = "downto", frame = true) - public IRubyObject downto(ThreadContext context, IRubyObject to, Block block) { - final Ruby runtime = getRuntime(); - - if (this instanceof RubyFixnum && to instanceof RubyFixnum) { - RubyFixnum toFixnum = (RubyFixnum) to; - final long toValue = toFixnum.getLongValue(); - if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { - final IRubyObject nil = runtime.getNil(); - for (long i = getLongValue(); i >= toValue; i--) { - block.yield(context, nil); - } - } else { - for (long i = getLongValue(); i >= toValue; i--) { - block.yield(context, RubyFixnum.newFixnum(getRuntime(), i)); - } - } - } else { - RubyNumeric i = this; - - while (true) { - if (i.callMethod(context, MethodIndex.OP_LT, "<", to).isTrue()) { - break; - } - block.yield(context, i); - i = (RubyNumeric) i.callMethod(context, MethodIndex.OP_MINUS, "-", RubyFixnum.one(getRuntime())); - } - } - return this; - } - - @JRubyMethod(name = "times", frame = true) - public IRubyObject times(ThreadContext context, Block block) { - final Ruby runtime = context.getRuntime(); - - if (this instanceof RubyFixnum) { - final long value = getLongValue(); - if (block.getBody().getArgumentType() == BlockBody.ZERO_ARGS) { - final IRubyObject nil = runtime.getNil(); - for (long i = 0; i < value; i++) { - block.yield(context, nil); - } - } else { - for (long i = 0; i < value; i++) { - block.yield(context, RubyFixnum.newFixnum(runtime, i)); - } - } - } else { - RubyNumeric i = RubyFixnum.zero(runtime); - while (true) { - if (!i.callMethod(context, MethodIndex.OP_LT, "<", this).isTrue()) { - break; - } - block.yield(context, i); - i = (RubyNumeric) i.callMethod(context, MethodIndex.OP_PLUS, "+", RubyFixnum.one(runtime)); - } - } - - return this; - } - - /** int_succ - * - */ - @JRubyMethod(name = {"succ", "next"}) - public IRubyObject succ(ThreadContext context) { - if (this instanceof RubyFixnum) { - return RubyFixnum.newFixnum(getRuntime(), getLongValue() + 1L); - } else { - return callMethod(context, MethodIndex.OP_PLUS, "+", RubyFixnum.one(getRuntime())); - } - } - - /** int_chr - * - */ - @JRubyMethod(name = "chr") - public RubyString chr() { - if (getLongValue() < 0 || getLongValue() > 0xff) { - throw getRuntime().newRangeError(this.toString() + " out of char range"); - } - return RubyString.newString(getRuntime(), new ByteList(new byte[]{(byte)getLongValue()}, false)); - } - - /** int_to_i - * - */ - @JRubyMethod(name = {"to_i", "to_int", "floor", "ceil", "round", "truncate"}) - public RubyInteger to_i() { - return this; - } - - /** integer_to_r - * - */ - @JRubyMethod(name = "to_r", compat = CompatVersion.RUBY1_9) - public IRubyObject to_r(ThreadContext context) { - return RubyRational.newRationalCanonicalize(context, this); - } - - - @JRubyMethod(name = {"odd?"}) - public static RubyBoolean odd_p(ThreadContext context, IRubyObject recv) { - if(recv.callMethod(context, "%", recv.getRuntime().newFixnum(2)) != RubyFixnum.zero(recv.getRuntime())) { - return recv.getRuntime().getTrue(); - } - return recv.getRuntime().getFalse(); - } - - @JRubyMethod(name = {"even?"}) - public static RubyBoolean even_p(ThreadContext context, IRubyObject recv) { - if(recv.callMethod(context, "%", recv.getRuntime().newFixnum(2)) == RubyFixnum.zero(recv.getRuntime())) { - return recv.getRuntime().getTrue(); - } - return recv.getRuntime().getFalse(); - } - - @JRubyMethod - public static IRubyObject pred(ThreadContext context, IRubyObject recv) { - return recv.callMethod(context, "-", recv.getRuntime().newFixnum(1)); - } - - - /* ================ - * Singleton Methods - * ================ - */ - - /** rb_int_induced_from - * - */ - @JRubyMethod(name = "induced_from", meta = true) - public static IRubyObject induced_from(ThreadContext context, IRubyObject recv, IRubyObject other) { - if (other instanceof RubyFixnum || other instanceof RubyBignum) { - return other; - } else if (other instanceof RubyFloat || other instanceof RubyRational) { - return other.callMethod(context, MethodIndex.TO_I, "to_i"); - } else { - throw recv.getRuntime().newTypeError( - "failed to convert " + other.getMetaClass().getName() + " into Integer"); - } - } -} -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2006 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Evan Buswell <ebuswell@gmail.com> - * Copyright (C) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.EOFException; -import java.io.FileDescriptor; -import java.io.FilterInputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.ref.Reference; -import java.lang.ref.WeakReference; -import java.nio.channels.Channel; -import java.nio.channels.Channels; -import java.nio.channels.FileChannel; -import java.nio.channels.Pipe; -import java.nio.channels.SelectableChannel; -import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import java.util.concurrent.atomic.AtomicInteger; -import org.jruby.anno.FrameField; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.exceptions.RaiseException; -import org.jruby.ext.posix.util.FieldAccess; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallType; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.io.Stream; -import org.jruby.util.io.ModeFlags; -import org.jruby.util.ShellLauncher; -import org.jruby.util.TypeConverter; -import org.jruby.util.io.BadDescriptorException; -import org.jruby.util.io.ChannelStream; -import org.jruby.util.io.InvalidValueException; -import org.jruby.util.io.PipeException; -import org.jruby.util.io.FileExistsException; -import org.jruby.util.io.STDIO; -import org.jruby.util.io.OpenFile; -import org.jruby.util.io.ChannelDescriptor; - -import static org.jruby.CompatVersion.*; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="IO", include="Enumerable") -public class RubyIO extends RubyObject { - protected OpenFile openFile; - protected List<RubyThread> blockingThreads; - - public void registerDescriptor(ChannelDescriptor descriptor) { - getRuntime().getDescriptors().put(new Integer(descriptor.getFileno()), new WeakReference<ChannelDescriptor>(descriptor)); - } - - public void unregisterDescriptor(int aFileno) { - getRuntime().getDescriptors().remove(new Integer(aFileno)); - } - - public ChannelDescriptor getDescriptorByFileno(int aFileno) { - Reference<ChannelDescriptor> reference = getRuntime().getDescriptors().get(new Integer(aFileno)); - if (reference == null) { - return null; - } - return reference.get(); - } - - // FIXME can't use static; would interfere with other runtimes in the same JVM - protected static AtomicInteger filenoIndex = new AtomicInteger(2); - - public static int getNewFileno() { - return filenoIndex.incrementAndGet(); - } - - // This should only be called by this and RubyFile. - // It allows this object to be created without a IOHandler. - public RubyIO(Ruby runtime, RubyClass type) { - super(runtime, type); - - openFile = new OpenFile(); - } - - public RubyIO(Ruby runtime, OutputStream outputStream) { - super(runtime, runtime.getIO()); - - // We only want IO objects with valid streams (better to error now). - if (outputStream == null) { - throw runtime.newIOError("Opening invalid stream"); - } - - openFile = new OpenFile(); - - try { - openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(outputStream), getNewFileno(), new FileDescriptor()))); - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } - - openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND); - - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - public RubyIO(Ruby runtime, InputStream inputStream) { - super(runtime, runtime.getIO()); - - if (inputStream == null) { - throw runtime.newIOError("Opening invalid stream"); - } - - openFile = new OpenFile(); - - try { - openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(Channels.newChannel(inputStream), getNewFileno(), new FileDescriptor()))); - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } - - openFile.setMode(OpenFile.READABLE); - - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - public RubyIO(Ruby runtime, Channel channel) { - super(runtime, runtime.getIO()); - - // We only want IO objects with valid streams (better to error now). - if (channel == null) { - throw runtime.newIOError("Opening invalid stream"); - } - - openFile = new OpenFile(); - - try { - openFile.setMainStream(new ChannelStream(runtime, new ChannelDescriptor(channel, getNewFileno(), new FileDescriptor()))); - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } - - openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags()); - - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - public RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, ModeFlags modes) { - super(runtime, runtime.getIO()); - - openFile = new OpenFile(); - - openFile.setMode(modes.getOpenFileFlags() | OpenFile.SYNC); - openFile.setProcess(process); - - try { - if (openFile.isReadable()) { - Channel inChannel; - if (process.getInput() != null) { - // NIO-based - inChannel = process.getInput(); - } else { - // Stream-based - inChannel = Channels.newChannel(process.getInputStream()); - } - - ChannelDescriptor main = new ChannelDescriptor( - inChannel, - getNewFileno(), - new FileDescriptor()); - main.setCanBeSeekable(false); - - openFile.setMainStream(new ChannelStream(getRuntime(), main)); - registerDescriptor(main); - } - - if (openFile.isWritable()) { - Channel outChannel; - if (process.getOutput() != null) { - // NIO-based - outChannel = process.getOutput(); - } else { - outChannel = Channels.newChannel(process.getOutputStream()); - } - - ChannelDescriptor pipe = new ChannelDescriptor( - outChannel, - getNewFileno(), - new FileDescriptor()); - pipe.setCanBeSeekable(false); - - if (openFile.getMainStream() != null) { - openFile.setPipeStream(new ChannelStream(getRuntime(), pipe)); - } else { - openFile.setMainStream(new ChannelStream(getRuntime(), pipe)); - } - - registerDescriptor(pipe); - } - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } - } - - public RubyIO(Ruby runtime, STDIO stdio) { - super(runtime, runtime.getIO()); - - openFile = new OpenFile(); - - try { - switch (stdio) { - case IN: - openFile.setMainStream( - new ChannelStream( - runtime, - // special constructor that accepts stream, not channel - new ChannelDescriptor(runtime.getIn(), 0, new ModeFlags(ModeFlags.RDONLY), FileDescriptor.in), - FileDescriptor.in)); - break; - case OUT: - openFile.setMainStream( - new ChannelStream( - runtime, - new ChannelDescriptor(Channels.newChannel(runtime.getOut()), 1, new ModeFlags(ModeFlags.WRONLY | ModeFlags.APPEND), FileDescriptor.out), - FileDescriptor.out)); - openFile.getMainStream().setSync(true); - break; - case ERR: - openFile.setMainStream( - new ChannelStream( - runtime, - new ChannelDescriptor(Channels.newChannel(runtime.getErr()), 2, new ModeFlags(ModeFlags.WRONLY | ModeFlags.APPEND), FileDescriptor.err), - FileDescriptor.err)); - openFile.getMainStream().setSync(true); - break; - } - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } - - openFile.setMode(openFile.getMainStream().getModes().getOpenFileFlags()); - - registerDescriptor(openFile.getMainStream().getDescriptor()); - } - - public static RubyIO newIO(Ruby runtime, Channel channel) { - return new RubyIO(runtime, channel); - } - - public OpenFile getOpenFile() { - return openFile; - } - - protected OpenFile getOpenFileChecked() { - openFile.checkClosed(getRuntime()); - return openFile; - } - - private static ObjectAllocator IO_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyIO(runtime, klass); - } - }; - - public static RubyClass createIOClass(Ruby runtime) { - RubyClass ioClass = runtime.defineClass("IO", runtime.getObject(), IO_ALLOCATOR); - ioClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyIO; - } - }; - - ioClass.includeModule(runtime.getEnumerable()); - - // TODO: Implement tty? and isatty. We have no real capability to - // determine this from java, but if we could set tty status, then - // we could invoke jruby differently to allow stdin to return true - // on this. This would allow things like cgi.rb to work properly. - - ioClass.defineAnnotatedMethods(RubyIO.class); - - // Constants for seek - ioClass.fastSetConstant("SEEK_SET", runtime.newFixnum(Stream.SEEK_SET)); - ioClass.fastSetConstant("SEEK_CUR", runtime.newFixnum(Stream.SEEK_CUR)); - ioClass.fastSetConstant("SEEK_END", runtime.newFixnum(Stream.SEEK_END)); - - return ioClass; - } - - public OutputStream getOutStream() { - return getOpenFileChecked().getMainStream().newOutputStream(); - } - - public InputStream getInStream() { - return getOpenFileChecked().getMainStream().newInputStream(); - } - - public Channel getChannel() { - if (getOpenFileChecked().getMainStream() instanceof ChannelStream) { - return ((ChannelStream) openFile.getMainStream()).getDescriptor().getChannel(); - } else { - return null; - } - } - - public Stream getHandler() { - return getOpenFileChecked().getMainStream(); - } - - @JRubyMethod(name = "reopen", required = 1, optional = 1) - public IRubyObject reopen(ThreadContext context, IRubyObject[] args) throws InvalidValueException { - Ruby runtime = context.getRuntime(); - - if (args.length < 1) { - throw runtime.newArgumentError("wrong number of arguments"); - } - - IRubyObject tmp = TypeConverter.convertToTypeWithCheck(args[0], runtime.getIO(), - MethodIndex.getIndex("to_io"), "to_io"); - - if (!tmp.isNil()) { - try { - RubyIO ios = (RubyIO) tmp; - - if (ios.openFile == this.openFile) { - return this; - } - - OpenFile originalFile = ios.getOpenFileChecked(); - OpenFile selfFile = getOpenFileChecked(); - - long pos = 0; - if (originalFile.isReadable()) { - pos = originalFile.getMainStream().fgetpos(); - } - - if (originalFile.getPipeStream() != null) { - originalFile.getPipeStream().fflush(); - } else if (originalFile.isWritable()) { - originalFile.getMainStream().fflush(); - } - - if (selfFile.isWritable()) { - selfFile.getWriteStream().fflush(); - } - - selfFile.setMode(originalFile.getMode()); - selfFile.setProcess(originalFile.getProcess()); - selfFile.setLineNumber(originalFile.getLineNumber()); - selfFile.setPath(originalFile.getPath()); - selfFile.setFinalizer(originalFile.getFinalizer()); - - ChannelDescriptor selfDescriptor = selfFile.getMainStream().getDescriptor(); - ChannelDescriptor originalDescriptor = originalFile.getMainStream().getDescriptor(); - - // confirm we're not reopening self's channel - if (selfDescriptor.getChannel() != originalDescriptor.getChannel()) { - // check if we're a stdio IO, and ensure we're not badly mutilated - if (selfDescriptor.getFileno() >=0 && selfDescriptor.getFileno() <= 2) { - selfFile.getMainStream().clearerr(); - - // dup2 new fd into self to preserve fileno and references to it - originalDescriptor.dup2Into(selfDescriptor); - - // re-register, since fileno points at something new now - registerDescriptor(selfDescriptor); - } else { - Stream pipeFile = selfFile.getPipeStream(); - int mode = selfFile.getMode(); - selfFile.getMainStream().fclose(); - selfFile.setPipeStream(null); - - // TODO: turn off readable? am I reading this right? - // This only seems to be used while duping below, since modes gets - // reset to actual modes afterward - //fptr->mode &= (m & FMODE_READABLE) ? ~FMODE_READABLE : ~FMODE_WRITABLE; - - if (pipeFile != null) { - selfFile.setMainStream(ChannelStream.fdopen(runtime, originalDescriptor, new ModeFlags())); - selfFile.setPipeStream(pipeFile); - } else { - selfFile.setMainStream( - new ChannelStream( - runtime, - originalDescriptor.dup2(selfDescriptor.getFileno()))); - - // re-register the descriptor - registerDescriptor(selfFile.getMainStream().getDescriptor()); - - // since we're not actually duping the incoming channel into our handler, we need to - // copy the original sync behavior from the other handler - selfFile.getMainStream().setSync(selfFile.getMainStream().isSync()); - } - selfFile.setMode(mode); - } - - // TODO: anything threads attached to original fd are notified of the close... - // see rb_thread_fd_close - - if (originalFile.isReadable() && pos >= 0) { - selfFile.seek(pos, Stream.SEEK_SET); - originalFile.seek(pos, Stream.SEEK_SET); - } - } - - if (selfFile.getPipeStream() != null && selfDescriptor.getFileno() != selfFile.getPipeStream().getDescriptor().getFileno()) { - int fd = selfFile.getPipeStream().getDescriptor().getFileno(); - - if (originalFile.getPipeStream() == null) { - selfFile.getPipeStream().fclose(); - selfFile.setPipeStream(null); - } else if (fd != originalFile.getPipeStream().getDescriptor().getFileno()) { - selfFile.getPipeStream().fclose(); - ChannelDescriptor newFD2 = originalFile.getPipeStream().getDescriptor().dup2(fd); - selfFile.setPipeStream(ChannelStream.fdopen(runtime, newFD2, getIOModes(runtime, "w"))); - - // re-register, since fileno points at something new now - registerDescriptor(newFD2); - } - } - - // TODO: restore binary mode - // if (fptr->mode & FMODE_BINMODE) { - // rb_io_binmode(io); - // } - - // TODO: set our metaclass to target's class (i.e. scary!) - - } catch (IOException ex) { // TODO: better error handling - throw runtime.newIOError("could not reopen: " + ex.getMessage()); - } catch (BadDescriptorException ex) { - throw runtime.newIOError("could not reopen: " + ex.getMessage()); - } catch (PipeException ex) { - throw runtime.newIOError("could not reopen: " + ex.getMessage()); - } - } else { - IRubyObject pathString = args[0].convertToString(); - - // TODO: check safe, taint on incoming string - - if (openFile == null) { - openFile = new OpenFile(); - } - - try { - ModeFlags modes; - if (args.length > 1) { - IRubyObject modeString = args[1].convertToString(); - modes = getIOModes(runtime, modeString.toString()); - - openFile.setMode(modes.getOpenFileFlags()); - } else { - modes = getIOModes(runtime, "r"); - } - - String path = pathString.toString(); - - // Ruby code frequently uses a platform check to choose "NUL:" on windows - // but since that check doesn't work well on JRuby, we help it out - - openFile.setPath(path); - - if (openFile.getMainStream() == null) { - try { - openFile.setMainStream(ChannelStream.fopen(runtime, path, modes)); - } catch (FileExistsException fee) { - throw runtime.newErrnoEEXISTError(path); - } - - registerDescriptor(openFile.getMainStream().getDescriptor()); - if (openFile.getPipeStream() != null) { - openFile.getPipeStream().fclose(); - unregisterDescriptor(openFile.getPipeStream().getDescriptor().getFileno()); - openFile.setPipeStream(null); - } - return this; - } else { - // TODO: This is an freopen in MRI, this is close, but not quite the same - openFile.getMainStream().freopen(path, getIOModes(runtime, openFile.getModeAsString(runtime))); - - // re-register - registerDescriptor(openFile.getMainStream().getDescriptor()); - - if (openFile.getPipeStream() != null) { - // TODO: pipe handler to be reopened with path and "w" mode - } - } - } catch (PipeException pe) { - throw runtime.newErrnoEPIPEError(); - } catch (IOException ex) { - throw runtime.newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw runtime.newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw runtime.newErrnoEINVALError(); - } - } - - // A potentially previously close IO is being 'reopened'. - return this; - } - - public static ModeFlags getIOModes(Ruby runtime, String modesString) throws InvalidValueException { - return new ModeFlags(getIOModesIntFromString(runtime, modesString)); - } - - public static int getIOModesIntFromString(Ruby runtime, String modesString) { - int modes = 0; - int length = modesString.length(); - - if (length == 0) { - throw runtime.newArgumentError("illegal access mode"); - } - - switch (modesString.charAt(0)) { - case 'r' : - modes |= ModeFlags.RDONLY; - break; - case 'a' : - modes |= ModeFlags.APPEND | ModeFlags.WRONLY | ModeFlags.CREAT; - break; - case 'w' : - modes |= ModeFlags.WRONLY | ModeFlags.TRUNC | ModeFlags.CREAT; - break; - default : - throw runtime.newArgumentError("illegal access mode " + modes); - } - - for (int n = 1; n < length; n++) { - switch (modesString.charAt(n)) { - case 'b': - modes |= ModeFlags.BINARY; - break; - case '+': - modes = (modes & ~ModeFlags.ACCMODE) | ModeFlags.RDWR; - break; - default: - throw runtime.newArgumentError("illegal access mode " + modes); - } - } - - return modes; - } - - private static ByteList getSeparatorFromArgs(Ruby runtime, IRubyObject[] args, int idx) { - IRubyObject sepVal; - - if (args.length > idx) { - sepVal = args[idx]; - } else { - sepVal = runtime.getRecordSeparatorVar().get(); - } - - ByteList separator = sepVal.isNil() ? null : sepVal.convertToString().getByteList(); - - if (separator != null && separator.realSize == 0) { - separator = Stream.PARAGRAPH_DELIMETER; - } - - return separator; - } - - private ByteList getSeparatorForGets(Ruby runtime, IRubyObject[] args) { - return getSeparatorFromArgs(runtime, args, 0); - } - - public IRubyObject getline(Ruby runtime, ByteList separator) { - try { - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkReadable(runtime); - myOpenFile.setReadBuffered(); - - boolean isParagraph = separator == Stream.PARAGRAPH_DELIMETER; - separator = (separator == Stream.PARAGRAPH_DELIMETER) ? - Stream.PARAGRAPH_SEPARATOR : separator; - - if (isParagraph) { - swallow('\n'); - } - - if (separator == null) { - IRubyObject str = readAll(null); - if (((RubyString)str).getByteList().length() == 0) { - return runtime.getNil(); - } - incrementLineno(runtime, myOpenFile); - return str; - } else if (separator.length() == 1) { - return getlineFast(runtime, separator.get(0)); - } else { - Stream readStream = myOpenFile.getMainStream(); - int c = -1; - int n = -1; - int newline = separator.get(separator.length() - 1) & 0xFF; - - ByteList buf = new ByteList(0); - boolean update = false; - - while (true) { - do { - readCheck(readStream); - readStream.clearerr(); - - try { - n = readStream.getline(buf, (byte) newline); - c = buf.length() > 0 ? buf.get(buf.length() - 1) & 0xff : -1; - } catch (EOFException e) { - n = -1; - } - - if (n == -1) { - if (!readStream.isBlocking() && (readStream instanceof ChannelStream)) { - if(!(waitReadable(((ChannelStream)readStream).getDescriptor()))) { - throw runtime.newIOError("bad file descriptor: " + openFile.getPath()); - } - - continue; - } else { - break; - } - } - - update = true; - } while (c != newline); // loop until we see the nth separator char - - // if we hit EOF, we're done - if (n == -1) { - break; - } - - // if we've found the last char of the separator, - // and we've found at least as many characters as separator length, - // and the last n characters of our buffer match the separator, we're done - if (c == newline && buf.length() >= separator.length() && - 0 == ByteList.memcmp(buf.unsafeBytes(), buf.begin + buf.realSize - separator.length(), separator.unsafeBytes(), separator.begin, separator.realSize)) { - break; - } - } - - if (isParagraph) { - if (c != -1) { - swallow('\n'); - } - } - - if (!update) { - return runtime.getNil(); - } else { - incrementLineno(runtime, myOpenFile); - RubyString str = RubyString.newString(runtime, buf); - str.setTaint(true); - - return str; - } - } - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (EOFException e) { - return runtime.getNil(); - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - private void incrementLineno(Ruby runtime, OpenFile myOpenFile) { - int lineno = myOpenFile.getLineNumber() + 1; - myOpenFile.setLineNumber(lineno); - runtime.getGlobalVariables().set("$.", runtime.newFixnum(lineno)); - // this is for a range check, near as I can tell - RubyNumeric.int2fix(runtime, myOpenFile.getLineNumber()); - } - - protected boolean swallow(int term) throws IOException, BadDescriptorException { - Stream readStream = openFile.getMainStream(); - int c; - - do { - readCheck(readStream); - - try { - c = readStream.fgetc(); - } catch (EOFException e) { - c = -1; - } - - if (c != term) { - readStream.ungetc(c); - return true; - } - } while (c != -1); - - return false; - } - - public IRubyObject getlineFast(Ruby runtime, int delim) throws IOException, BadDescriptorException { - Stream readStream = openFile.getMainStream(); - int c = -1; - - ByteList buf = new ByteList(0); - boolean update = false; - do { - readCheck(readStream); - readStream.clearerr(); - int n; - try { - n = readStream.getline(buf, (byte) delim); - c = buf.length() > 0 ? buf.get(buf.length() - 1) & 0xff : -1; - } catch (EOFException e) { - n = -1; - } - - if (n == -1) { - if (!readStream.isBlocking() && (readStream instanceof ChannelStream)) { - if(!(waitReadable(((ChannelStream)readStream).getDescriptor()))) { - throw runtime.newIOError("bad file descriptor: " + openFile.getPath()); - } - continue; - } else { - break; - } - } - - update = true; - } while (c != delim); - - if (!update) { - return runtime.getNil(); - } else { - incrementLineno(runtime, openFile); - RubyString str = RubyString.newString(runtime, buf); - str.setTaint(true); - return str; - } - } - // IO class methods. - - @JRubyMethod(name = {"new", "for_fd"}, rest = true, frame = true, meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyClass klass = (RubyClass)recv; - - if (block.isGiven()) { - String className = klass.getName(); - context.getRuntime().getWarnings().warn( - ID.BLOCK_NOT_ACCEPTED, - className + "::new() does not take block; use " + className + "::open() instead", - className + "::open()"); - } - - return klass.newInstance(context, args, block); - } - - @JRubyMethod(name = "initialize", required = 1, optional = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - int argCount = args.length; - ModeFlags modes; - - int fileno = RubyNumeric.fix2int(args[0]); - - try { - ChannelDescriptor descriptor = getDescriptorByFileno(fileno); - - if (descriptor == null) { - throw getRuntime().newErrnoEBADFError(); - } - - descriptor.checkOpen(); - - if (argCount == 2) { - if (args[1] instanceof RubyFixnum) { - modes = new ModeFlags(RubyFixnum.fix2long(args[1])); - } else { - modes = getIOModes(getRuntime(), args[1].convertToString().toString()); - } - } else { - // use original modes - modes = descriptor.getOriginalModes(); - } - - openFile.setMode(modes.getOpenFileFlags()); - - openFile.setMainStream(fdopen(descriptor, modes)); - } catch (BadDescriptorException ex) { - throw getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException ive) { - throw getRuntime().newErrnoEINVALError(); - } - - return this; - } - - protected Stream fdopen(ChannelDescriptor existingDescriptor, ModeFlags modes) throws InvalidValueException { - // See if we already have this descriptor open. - // If so then we can mostly share the handler (keep open - // file, but possibly change the mode). - - if (existingDescriptor == null) { - // redundant, done above as well - - // this seems unlikely to happen unless it's a totally bogus fileno - // ...so do we even need to bother trying to create one? - - // IN FACT, we should probably raise an error, yes? - throw getRuntime().newErrnoEBADFError(); - -// if (mode == null) { -// mode = "r"; -// } -// -// try { -// openFile.setMainStream(streamForFileno(getRuntime(), fileno)); -// } catch (BadDescriptorException e) { -// throw getRuntime().newErrnoEBADFError(); -// } catch (IOException e) { -// throw getRuntime().newErrnoEBADFError(); -// } -// //modes = new IOModes(getRuntime(), mode); -// -// registerStream(openFile.getMainStream()); - } else { - // We are creating a new IO object that shares the same - // IOHandler (and fileno). - return ChannelStream.fdopen(getRuntime(), existingDescriptor, modes); - } - } - - @JRubyMethod(name = "open", required = 1, optional = 2, frame = true, meta = true) - public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - RubyClass klass = (RubyClass)recv; - - RubyIO io = (RubyIO)klass.newInstance(context, args, block); - - if (block.isGiven()) { - try { - return block.yield(context, io); - } finally { - try { - io.getMetaClass().invoke(context, io, "close", IRubyObject.NULL_ARRAY, CallType.FUNCTIONAL, Block.NULL_BLOCK); - } catch (RaiseException re) { - RubyException rubyEx = re.getException(); - if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) { - // MRI behavior: swallow StandardErorrs - } else { - throw re; - } - } - } - } - - return io; - } - - // This appears to be some windows-only mode. On a java platform this is a no-op - @JRubyMethod(name = "binmode") - public IRubyObject binmode() { - return this; - } - - /** @deprecated will be removed in 1.2 */ - protected void checkInitialized() { - if (openFile == null) { - throw getRuntime().newIOError("uninitialized stream"); - } - } - - /** @deprecated will be removed in 1.2 */ - protected void checkClosed() { - if (openFile.getMainStream() == null && openFile.getPipeStream() == null) { - throw getRuntime().newIOError("closed stream"); - } - } - - @JRubyMethod(name = "syswrite", required = 1) - public IRubyObject syswrite(ThreadContext context, IRubyObject obj) { - Ruby runtime = context.getRuntime(); - - try { - RubyString string = obj.asString(); - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkWritable(runtime); - - Stream writeStream = myOpenFile.getWriteStream(); - - if (myOpenFile.isWriteBuffered()) { - runtime.getWarnings().warn(ID.SYSWRITE_BUFFERED_IO, "syswrite for buffered IO"); - } - - if (!writeStream.getDescriptor().isWritable()) { - myOpenFile.checkClosed(runtime); - } - - int read = writeStream.getDescriptor().write(string.getByteList()); - - if (read == -1) { - // TODO? I think this ends up propagating from normal Java exceptions - // sys_fail(openFile.getPath()) - } - - return runtime.newFixnum(read); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (IOException e) { - throw runtime.newSystemCallError(e.getMessage()); - } - } - - @JRubyMethod(name = "write_nonblock", required = 1) - public IRubyObject write_nonblock(ThreadContext context, IRubyObject obj) { - // MRI behavior: always check whether the file is writable - // or not, even if we are to write 0 bytes. - OpenFile myOpenFile = getOpenFileChecked(); - try { - myOpenFile.checkWritable(context.getRuntime()); - } catch (IOException ex) { - throw context.getRuntime().newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException ex) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (PipeException ex) { - throw context.getRuntime().newErrnoEPIPEError(); - } - - // TODO: Obviously, we're not doing a non-blocking write here - return write(context, obj); - } - - /** io_write - * - */ - @JRubyMethod(name = "write", required = 1) - public IRubyObject write(ThreadContext context, IRubyObject obj) { - Ruby runtime = context.getRuntime(); - - runtime.secure(4); - - RubyString str = obj.asString(); - - // TODO: Ruby reuses this logic for other "write" behavior by checking if it's an IO and calling write again - - if (str.getByteList().length() == 0) { - return runtime.newFixnum(0); - } - - try { - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkWritable(runtime); - - int written = fwrite(str.getByteList()); - - if (written == -1) { - // TODO: sys fail - } - - // if not sync, we switch to write buffered mode - if (!myOpenFile.isSync()) { - myOpenFile.setWriteBuffered(); - } - - return runtime.newFixnum(written); - } catch (IOException ex) { - throw runtime.newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw runtime.newErrnoEBADFError(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } - } - - protected boolean waitWritable(ChannelDescriptor descriptor) throws IOException { - Channel channel = descriptor.getChannel(); - if (channel == null || !(channel instanceof SelectableChannel)) { - return false; - } - - Selector selector = Selector.open(); - - ((SelectableChannel) channel).configureBlocking(false); - int real_ops = ((SelectableChannel) channel).validOps() & SelectionKey.OP_WRITE; - SelectionKey key = ((SelectableChannel) channel).keyFor(selector); - - if (key == null) { - ((SelectableChannel) channel).register(selector, real_ops, descriptor); - } else { - key.interestOps(key.interestOps()|real_ops); - } - - while(selector.select() == 0); - - for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) { - SelectionKey skey = (SelectionKey) i.next(); - if ((skey.interestOps() & skey.readyOps() & (SelectionKey.OP_WRITE)) != 0) { - if(skey.attachment() == descriptor) { - return true; - } - } - } - return false; - } - - protected boolean waitReadable(ChannelDescriptor descriptor) throws IOException { - Channel channel = descriptor.getChannel(); - if (channel == null || !(channel instanceof SelectableChannel)) { - return false; - } - - Selector selector = Selector.open(); - - ((SelectableChannel) channel).configureBlocking(false); - int real_ops = ((SelectableChannel) channel).validOps() & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT); - SelectionKey key = ((SelectableChannel) channel).keyFor(selector); - - if (key == null) { - ((SelectableChannel) channel).register(selector, real_ops, descriptor); - } else { - key.interestOps(key.interestOps()|real_ops); - } - - while(selector.select() == 0); - - for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) { - SelectionKey skey = (SelectionKey) i.next(); - if ((skey.interestOps() & skey.readyOps() & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) != 0) { - if(skey.attachment() == descriptor) { - return true; - } - } - } - return false; - } - - protected int fwrite(ByteList buffer) { - int n, r, l, offset = 0; - boolean eagain = false; - Stream writeStream = openFile.getWriteStream(); - - int len = buffer.length(); - - if ((n = len) <= 0) return n; - - try { - if (openFile.isSync()) { - openFile.fflush(writeStream); - - // TODO: why is this guarded? - // if (!rb_thread_fd_writable(fileno(f))) { - // rb_io_check_closed(fptr); - // } - - while(offset<len) { - l = n; - - // TODO: Something about pipe buffer length here - - r = writeStream.getDescriptor().write(buffer,offset,l); - - if(r == len) { - return len; //Everything written - } - - if (0 <= r) { - offset += r; - n -= r; - eagain = true; - } - - if(eagain && waitWritable(writeStream.getDescriptor())) { - openFile.checkClosed(getRuntime()); - if(offset >= buffer.length()) { - return -1; - } - eagain = false; - } else { - return -1; - } - } - - - // TODO: all this stuff...some pipe logic, some async thread stuff - // retry: - // l = n; - // if (PIPE_BUF < l && - // !rb_thread_critical && - // !rb_thread_alone() && - // wsplit_p(fptr)) { - // l = PIPE_BUF; - // } - // TRAP_BEG; - // r = write(fileno(f), RSTRING(str)->ptr+offset, l); - // TRAP_END; - // if (r == n) return len; - // if (0 <= r) { - // offset += r; - // n -= r; - // errno = EAGAIN; - // } - // if (rb_io_wait_writable(fileno(f))) { - // rb_io_check_closed(fptr); - // if (offset < RSTRING(str)->len) - // goto retry; - // } - // return -1L; - } - - // TODO: handle errors in buffered write by retrying until finished or file is closed - return writeStream.fwrite(buffer); - // while (errno = 0, offset += (r = fwrite(RSTRING(str)->ptr+offset, 1, n, f)), (n -= r) > 0) { - // if (ferror(f) - // ) { - // if (rb_io_wait_writable(fileno(f))) { - // rb_io_check_closed(fptr); - // clearerr(f); - // if (offset < RSTRING(str)->len) - // continue; - // } - // return -1L; - // } - // } - -// return len - n; - } catch (IOException ex) { - throw getRuntime().newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw getRuntime().newErrnoEBADFError(); - } - } - - /** rb_io_addstr - * - */ - @JRubyMethod(name = "<<", required = 1) - public IRubyObject op_append(ThreadContext context, IRubyObject anObject) { - // Claims conversion is done via 'to_s' in docs. - callMethod(context, "write", anObject); - - return this; - } - - @JRubyMethod(name = "fileno", alias = "to_i") - public RubyFixnum fileno(ThreadContext context) { - return context.getRuntime().newFixnum(getOpenFileChecked().getMainStream().getDescriptor().getFileno()); - } - - /** Returns the current line number. - * - * @return the current line number. - */ - @JRubyMethod(name = "lineno") - public RubyFixnum lineno(ThreadContext context) { - return context.getRuntime().newFixnum(getOpenFileChecked().getLineNumber()); - } - - /** Sets the current line number. - * - * @param newLineNumber The new line number. - */ - @JRubyMethod(name = "lineno=", required = 1) - public RubyFixnum lineno_set(ThreadContext context, IRubyObject newLineNumber) { - getOpenFileChecked().setLineNumber(RubyNumeric.fix2int(newLineNumber)); - - return context.getRuntime().newFixnum(getOpenFileChecked().getLineNumber()); - } - - /** Returns the current sync mode. - * - * @return the current sync mode. - */ - @JRubyMethod(name = "sync") - public RubyBoolean sync(ThreadContext context) { - return context.getRuntime().newBoolean(getOpenFileChecked().getMainStream().isSync()); - } - - /** - * <p>Return the process id (pid) of the process this IO object - * spawned. If no process exists (popen was not called), then - * nil is returned. This is not how it appears to be defined - * but ruby 1.8 works this way.</p> - * - * @return the pid or nil - */ - @JRubyMethod(name = "pid") - public IRubyObject pid(ThreadContext context) { - OpenFile myOpenFile = getOpenFileChecked(); - - if (myOpenFile.getProcess() == null) { - return context.getRuntime().getNil(); - } - - // Of course this isn't particularly useful. - int pid = myOpenFile.getProcess().hashCode(); - - return context.getRuntime().newFixnum(pid); - } - - /** - * @deprecated - * @return - */ - public boolean writeDataBuffered() { - return openFile.getMainStream().writeDataBuffered(); - } - - @JRubyMethod(name = {"pos", "tell"}) - public RubyFixnum pos(ThreadContext context) { - try { - return context.getRuntime().newFixnum(getOpenFileChecked().getMainStream().fgetpos()); - } catch (InvalidValueException ex) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (BadDescriptorException bde) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (IOException e) { - throw context.getRuntime().newIOError(e.getMessage()); - } - } - - @JRubyMethod(name = "pos=", required = 1) - public RubyFixnum pos_set(ThreadContext context, IRubyObject newPosition) { - long offset = RubyNumeric.num2long(newPosition); - - if (offset < 0) { - throw context.getRuntime().newSystemCallError("Negative seek offset"); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - try { - myOpenFile.getMainStream().lseek(offset, Stream.SEEK_SET); - } catch (BadDescriptorException e) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (IOException e) { - throw context.getRuntime().newIOError(e.getMessage()); - } - - myOpenFile.getMainStream().clearerr(); - - return context.getRuntime().newFixnum(offset); - } - - /** Print some objects to the stream. - * - */ - @JRubyMethod(name = "print", rest = true, reads = FrameField.LASTLINE) - public IRubyObject print(ThreadContext context, IRubyObject[] args) { - if (args.length == 0) { - args = new IRubyObject[] { context.getCurrentFrame().getLastLine() }; - } - - Ruby runtime = context.getRuntime(); - IRubyObject fs = runtime.getGlobalVariables().get("$,"); - IRubyObject rs = runtime.getGlobalVariables().get("$\\"); - - for (int i = 0; i < args.length; i++) { - if (i > 0 && !fs.isNil()) { - callMethod(context, "write", fs); - } - if (args[i].isNil()) { - callMethod(context, "write", runtime.newString("nil")); - } else { - callMethod(context, "write", args[i]); - } - } - if (!rs.isNil()) { - callMethod(context, "write", rs); - } - - return runtime.getNil(); - } - - @JRubyMethod(name = "printf", required = 1, rest = true) - public IRubyObject printf(ThreadContext context, IRubyObject[] args) { - callMethod(context, "write", RubyKernel.sprintf(context, this, args)); - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "putc", required = 1, backtrace = true) - public IRubyObject putc(ThreadContext context, IRubyObject object) { - int c = RubyNumeric.num2chr(object); - - try { - getOpenFileChecked().getMainStream().fputc(c); - } catch (BadDescriptorException e) { - return RubyFixnum.zero(context.getRuntime()); - } catch (IOException e) { - return RubyFixnum.zero(context.getRuntime()); - } - - return object; - } - - public RubyFixnum seek(ThreadContext context, IRubyObject[] args) { - long offset = RubyNumeric.num2long(args[0]); - int whence = Stream.SEEK_SET; - - if (args.length > 1) { - whence = RubyNumeric.fix2int(args[1].convertToInteger()); - } - - return doSeek(context, offset, whence); - } - - @JRubyMethod(name = "seek") - public RubyFixnum seek(ThreadContext context, IRubyObject arg0) { - long offset = RubyNumeric.num2long(arg0); - int whence = Stream.SEEK_SET; - - return doSeek(context, offset, whence); - } - - @JRubyMethod(name = "seek") - public RubyFixnum seek(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - long offset = RubyNumeric.num2long(arg0); - int whence = RubyNumeric.fix2int(arg1.convertToInteger()); - - return doSeek(context, offset, whence); - } - - private RubyFixnum doSeek(ThreadContext context, long offset, int whence) { - OpenFile myOpenFile = getOpenFileChecked(); - - try { - myOpenFile.seek(offset, whence); - } catch (BadDescriptorException ex) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (IOException e) { - throw context.getRuntime().newIOError(e.getMessage()); - } - - myOpenFile.getMainStream().clearerr(); - - return RubyFixnum.zero(context.getRuntime()); - } - - // This was a getOpt with one mandatory arg, but it did not work - // so I am parsing it for now. - @JRubyMethod(name = "sysseek", required = 1, optional = 1) - public RubyFixnum sysseek(ThreadContext context, IRubyObject[] args) { - long offset = RubyNumeric.num2long(args[0]); - long pos; - int whence = Stream.SEEK_SET; - - if (args.length > 1) { - whence = RubyNumeric.fix2int(args[1].convertToInteger()); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - try { - - if (myOpenFile.isReadable() && myOpenFile.isReadBuffered()) { - throw context.getRuntime().newIOError("sysseek for buffered IO"); - } - if (myOpenFile.isWritable() && myOpenFile.isWriteBuffered()) { - context.getRuntime().getWarnings().warn(ID.SYSSEEK_BUFFERED_IO, "sysseek for buffered IO"); - } - - pos = myOpenFile.getMainStream().getDescriptor().lseek(offset, whence); - } catch (BadDescriptorException ex) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (IOException e) { - throw context.getRuntime().newIOError(e.getMessage()); - } - - myOpenFile.getMainStream().clearerr(); - - return context.getRuntime().newFixnum(pos); - } - - @JRubyMethod(name = "rewind") - public RubyFixnum rewind(ThreadContext context) { - OpenFile myOpenfile = getOpenFileChecked(); - - try { - myOpenfile.getMainStream().lseek(0L, Stream.SEEK_SET); - myOpenfile.getMainStream().clearerr(); - - // TODO: This is some goofy global file value from MRI..what to do? -// if (io == current_file) { -// gets_lineno -= fptr->lineno; -// } - } catch (BadDescriptorException e) { - throw context.getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw context.getRuntime().newErrnoEINVALError(); - } catch (PipeException e) { - throw context.getRuntime().newErrnoESPIPEError(); - } catch (IOException e) { - throw context.getRuntime().newIOError(e.getMessage()); - } - - // Must be back on first line on rewind. - myOpenfile.setLineNumber(0); - - return RubyFixnum.zero(context.getRuntime()); - } - - @JRubyMethod(name = "fsync") - public RubyFixnum fsync(ThreadContext context) { - Ruby runtime = context.getRuntime(); - - try { - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkWritable(runtime); - - myOpenFile.getWriteStream().sync(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } - - return RubyFixnum.zero(runtime); - } - - /** Sets the current sync mode. - * - * @param newSync The new sync mode. - */ - @JRubyMethod(name = "sync=", required = 1) - public IRubyObject sync_set(IRubyObject newSync) { - getOpenFileChecked().setSync(newSync.isTrue()); - getOpenFileChecked().getMainStream().setSync(newSync.isTrue()); - - return this; - } - - @JRubyMethod(name = {"eof?", "eof"}) - public RubyBoolean eof_p(ThreadContext context) { - Ruby runtime = context.getRuntime(); - - try { - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkReadable(runtime); - myOpenFile.setReadBuffered(); - - if (myOpenFile.getMainStream().feof()) { - return runtime.getTrue(); - } - - if (myOpenFile.getMainStream().readDataBuffered()) { - return runtime.getFalse(); - } - - readCheck(myOpenFile.getMainStream()); - - myOpenFile.getMainStream().clearerr(); - - int c = myOpenFile.getMainStream().fgetc(); - - if (c != -1) { - myOpenFile.getMainStream().ungetc(c); - return runtime.getFalse(); - } - - myOpenFile.checkClosed(runtime); - - myOpenFile.getMainStream().clearerr(); - - return runtime.getTrue(); - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - @JRubyMethod(name = {"tty?", "isatty"}) - public RubyBoolean tty_p(ThreadContext context) { - return context.getRuntime().newBoolean(context.getRuntime().getPosix().isatty(getOpenFileChecked().getMainStream().getDescriptor().getFileDescriptor())); - } - - @JRubyMethod(name = "initialize_copy", required = 1) - @Override - public IRubyObject initialize_copy(IRubyObject original){ - Ruby runtime = getRuntime(); - - if (this == original) return this; - - RubyIO originalIO = (RubyIO) TypeConverter.convertToTypeWithCheck(original, runtime.getIO(), MethodIndex.TO_IO, "to_io"); - - OpenFile originalFile = originalIO.getOpenFileChecked(); - OpenFile newFile = openFile; - - try { - // TODO: I didn't see where MRI has this check, but it seems to be the right place - originalFile.checkClosed(runtime); - - if (originalFile.getPipeStream() != null) { - originalFile.getPipeStream().fflush(); - originalFile.getMainStream().lseek(0, Stream.SEEK_CUR); - } else if (originalFile.isWritable()) { - originalFile.getMainStream().fflush(); - } else { - originalFile.getMainStream().lseek(0, Stream.SEEK_CUR); - } - - newFile.setMode(originalFile.getMode()); - newFile.setProcess(originalFile.getProcess()); - newFile.setLineNumber(originalFile.getLineNumber()); - newFile.setPath(originalFile.getPath()); - newFile.setFinalizer(originalFile.getFinalizer()); - - ModeFlags modes; - if (newFile.isReadable()) { - if (newFile.isWritable()) { - if (newFile.getPipeStream() != null) { - modes = new ModeFlags(ModeFlags.RDONLY); - } else { - modes = new ModeFlags(ModeFlags.RDWR); - } - } else { - modes = new ModeFlags(ModeFlags.RDONLY); - } - } else { - if (newFile.isWritable()) { - modes = new ModeFlags(ModeFlags.WRONLY); - } else { - modes = originalFile.getMainStream().getModes(); - } - } - - ChannelDescriptor descriptor = originalFile.getMainStream().getDescriptor().dup(); - - newFile.setMainStream(ChannelStream.fdopen(runtime, descriptor, modes)); - - // TODO: the rest of this...seeking to same position is unnecessary since we share a channel - // but some of this may be needed? - -// fseeko(fptr->f, ftello(orig->f), SEEK_SET); -// if (orig->f2) { -// if (fileno(orig->f) != fileno(orig->f2)) { -// fd = ruby_dup(fileno(orig->f2)); -// } -// fptr->f2 = rb_fdopen(fd, "w"); -// fseeko(fptr->f2, ftello(orig->f2), SEEK_SET); -// } -// if (fptr->mode & FMODE_BINMODE) { -// rb_io_binmode(dest); -// } - - // Register the new descriptor - registerDescriptor(newFile.getMainStream().getDescriptor()); - } catch (IOException ex) { - throw runtime.newIOError("could not init copy: " + ex); - } catch (BadDescriptorException ex) { - throw runtime.newIOError("could not init copy: " + ex); - } catch (PipeException ex) { - throw runtime.newIOError("could not init copy: " + ex); - } catch (InvalidValueException ex) { - throw runtime.newIOError("could not init copy: " + ex); - } - - return this; - } - - /** Closes the IO. - * - * @return The IO. - */ - @JRubyMethod(name = "closed?") - public RubyBoolean closed_p(ThreadContext context) { - return context.getRuntime().newBoolean(openFile.getMainStream() == null && openFile.getPipeStream() == null); - } - - /** - * <p>Closes all open resources for the IO. It also removes - * it from our magical all open file descriptor pool.</p> - * - * @return The IO. - */ - @JRubyMethod(name = "close") - public IRubyObject close() { - Ruby runtime = getRuntime(); - - if (runtime.getSafeLevel() >= 4 && isTaint()) { - throw runtime.newSecurityError("Insecure: can't close"); - } - - openFile.checkClosed(runtime); - return close2(runtime); - } - - protected IRubyObject close2(Ruby runtime) { - if (openFile == null) return runtime.getNil(); - - // These would be used when we notify threads...if we notify threads - interruptBlockingThreads(); - - ChannelDescriptor main, pipe; - if (openFile.getPipeStream() != null) { - pipe = openFile.getPipeStream().getDescriptor(); - } else { - if (openFile.getMainStream() == null) { - return runtime.getNil(); - } - pipe = null; - } - - main = openFile.getMainStream().getDescriptor(); - - // cleanup, raising errors if any - openFile.cleanup(runtime, true); - - // TODO: notify threads waiting on descriptors/IO? probably not... - - if (openFile.getProcess() != null) { - try { - IRubyObject processResult = RubyProcess.RubyStatus.newProcessStatus(runtime, openFile.getProcess().waitFor()); - runtime.getGlobalVariables().set("$?", processResult); - } catch (InterruptedException ie) { - // TODO: do something here? - } - } - - return runtime.getNil(); - } - - @JRubyMethod(name = "close_write") - public IRubyObject close_write(ThreadContext context) throws BadDescriptorException { - try { - if (context.getRuntime().getSafeLevel() >= 4 && isTaint()) { - throw context.getRuntime().newSecurityError("Insecure: can't close"); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - if (myOpenFile.getPipeStream() == null && myOpenFile.isReadable()) { - throw context.getRuntime().newIOError("closing non-duplex IO for writing"); - } - - if (myOpenFile.getPipeStream() == null) { - close(); - } else{ - myOpenFile.getPipeStream().fclose(); - myOpenFile.setPipeStream(null); - myOpenFile.setMode(myOpenFile.getMode() & ~OpenFile.WRITABLE); - // TODO - // n is result of fclose; but perhaps having a SysError below is enough? - // if (n != 0) rb_sys_fail(fptr->path); - } - } catch (IOException ioe) { - // hmmmm - } - return this; - } - - @JRubyMethod(name = "close_read") - public IRubyObject close_read(ThreadContext context) throws BadDescriptorException { - Ruby runtime = context.getRuntime(); - - try { - if (runtime.getSafeLevel() >= 4 && isTaint()) { - throw runtime.newSecurityError("Insecure: can't close"); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - if (myOpenFile.getPipeStream() == null && myOpenFile.isWritable()) { - throw runtime.newIOError("closing non-duplex IO for reading"); - } - - if (myOpenFile.getPipeStream() == null) { - close(); - } else{ - myOpenFile.getMainStream().fclose(); - myOpenFile.setMode(myOpenFile.getMode() & ~OpenFile.READABLE); - myOpenFile.setMainStream(myOpenFile.getPipeStream()); - myOpenFile.setPipeStream(null); - // TODO - // n is result of fclose; but perhaps having a SysError below is enough? - // if (n != 0) rb_sys_fail(fptr->path); - } - } catch (IOException ioe) { - // I believe Ruby bails out with a "bug" if closing fails - throw runtime.newIOErrorFromException(ioe); - } - return this; - } - - /** Flushes the IO output stream. - * - * @return The IO. - */ - @JRubyMethod(name = "flush") - public RubyIO flush() { - try { - getOpenFileChecked().getWriteStream().fflush(); - } catch (BadDescriptorException e) { - throw getRuntime().newErrnoEBADFError(); - } catch (IOException e) { - throw getRuntime().newIOError(e.getMessage()); - } - - return this; - } - - /** Read a line. - * - */ - @JRubyMethod(name = "gets", optional = 1, writes = FrameField.LASTLINE) - public IRubyObject gets(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - ByteList separator = getSeparatorForGets(runtime, args); - - IRubyObject result = getline(runtime, separator); - - if (!result.isNil()) context.getCurrentFrame().setLastLine(result); - - return result; - } - - public boolean getBlocking() { - return ((ChannelStream) openFile.getMainStream()).isBlocking(); - } - - @JRubyMethod(name = "fcntl", required = 2) - public IRubyObject fcntl(ThreadContext context, IRubyObject cmd, IRubyObject arg) { - // TODO: This version differs from ioctl by checking whether fcntl exists - // and raising notimplemented if it doesn't; perhaps no difference for us? - return ctl(context.getRuntime(), cmd, arg); - } - - @JRubyMethod(name = "ioctl", required = 1, optional = 1) - public IRubyObject ioctl(ThreadContext context, IRubyObject[] args) { - IRubyObject cmd = args[0]; - IRubyObject arg; - - if (args.length == 2) { - arg = args[1]; - } else { - arg = context.getRuntime().getNil(); - } - - return ctl(context.getRuntime(), cmd, arg); - } - - public IRubyObject ctl(Ruby runtime, IRubyObject cmd, IRubyObject arg) { - long realCmd = cmd.convertToInteger().getLongValue(); - long nArg = 0; - - // FIXME: Arg may also be true, false, and nil and still be valid. Strangely enough, - // protocol conversion is not happening in Ruby on this arg? - if (arg.isNil() || arg == runtime.getFalse()) { - nArg = 0; - } else if (arg instanceof RubyFixnum) { - nArg = RubyFixnum.fix2long(arg); - } else if (arg == runtime.getTrue()) { - nArg = 1; - } else { - throw runtime.newNotImplementedError("JRuby does not support string for second fcntl/ioctl argument yet"); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - // Fixme: Only F_SETFL is current supported - if (realCmd == 1L) { // cmd is F_SETFL - boolean block = true; - - if ((nArg & ModeFlags.NONBLOCK) == ModeFlags.NONBLOCK) { - block = false; - } - - try { - myOpenFile.getMainStream().setBlocking(block); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } else { - throw runtime.newNotImplementedError("JRuby only supports F_SETFL for fcntl/ioctl currently"); - } - - return runtime.newFixnum(0); - } - - private static final ByteList NIL_BYTELIST = ByteList.create("nil"); - private static final ByteList RECURSIVE_BYTELIST = ByteList.create("[...]"); - - @JRubyMethod(name = "puts", rest = true) - public IRubyObject puts(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - assert runtime.getGlobalVariables().getDefaultSeparator() instanceof RubyString; - RubyString separator = (RubyString) runtime.getGlobalVariables().getDefaultSeparator(); - - if (args.length == 0) { - write(context, separator.getByteList()); - return runtime.getNil(); - } - - for (int i = 0; i < args.length; i++) { - ByteList line; - - if (args[i].isNil()) { - line = NIL_BYTELIST; - } else if (runtime.isInspecting(args[i])) { - line = RECURSIVE_BYTELIST; - } else if (args[i] instanceof RubyArray) { - inspectPuts(context, (RubyArray) args[i]); - continue; - } else { - line = args[i].asString().getByteList(); - } - - write(context, line); - - if (line.length() == 0 || !line.endsWith(separator.getByteList())) { - write(context, separator.getByteList()); - } - } - return runtime.getNil(); - } - - protected void write(ThreadContext context, ByteList byteList) { - callMethod(context, "write", RubyString.newStringShared(context.getRuntime(), byteList)); - } - - private IRubyObject inspectPuts(ThreadContext context, RubyArray array) { - try { - context.getRuntime().registerInspecting(array); - return puts(context, array.toJavaArray()); - } finally { - context.getRuntime().unregisterInspecting(array); - } - } - - /** Read a line. - * - */ - @JRubyMethod(name = "readline", optional = 1, writes = FrameField.LASTLINE) - public IRubyObject readline(ThreadContext context, IRubyObject[] args) { - IRubyObject line = gets(context, args); - - if (line.isNil()) throw context.getRuntime().newEOFError(); - - return line; - } - - /** Read a byte. On EOF returns nil. - * - */ - @JRubyMethod(name = "getc") - public IRubyObject getc() { - try { - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkReadable(getRuntime()); - myOpenFile.setReadBuffered(); - - Stream stream = myOpenFile.getMainStream(); - - readCheck(stream); - stream.clearerr(); - - int c = myOpenFile.getMainStream().fgetc(); - - if (c == -1) { - // TODO: check for ferror, clear it, and try once more up above readCheck -// if (ferror(f)) { -// clearerr(f); -// if (!rb_io_wait_readable(fileno(f))) -// rb_sys_fail(fptr->path); -// goto retry; -// } - return getRuntime().getNil(); - } - - return getRuntime().newFixnum(c); - } catch (PipeException ex) { - throw getRuntime().newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } catch (BadDescriptorException e) { - throw getRuntime().newErrnoEBADFError(); - } catch (EOFException e) { - throw getRuntime().newEOFError(); - } catch (IOException e) { - throw getRuntime().newIOError(e.getMessage()); - } - } - - private void readCheck(Stream stream) { - if (!stream.readDataBuffered()) { - openFile.checkClosed(getRuntime()); - } - } - - /** - * <p>Pushes char represented by int back onto IOS.</p> - * - * @param number to push back - */ - @JRubyMethod(name = "ungetc", required = 1) - public IRubyObject ungetc(IRubyObject number) { - int ch = RubyNumeric.fix2int(number); - - OpenFile myOpenFile = getOpenFileChecked(); - - if (!myOpenFile.isReadBuffered()) { - throw getRuntime().newIOError("unread stream"); - } - - try { - myOpenFile.checkReadable(getRuntime()); - myOpenFile.setReadBuffered(); - - if (myOpenFile.getMainStream().ungetc(ch) == -1 && ch != -1) { - throw getRuntime().newIOError("ungetc failed"); - } - } catch (PipeException ex) { - throw getRuntime().newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } catch (BadDescriptorException e) { - throw getRuntime().newErrnoEBADFError(); - } catch (EOFException e) { - throw getRuntime().newEOFError(); - } catch (IOException e) { - throw getRuntime().newIOError(e.getMessage()); - } - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "read_nonblock", required = 1, optional = 1) - public IRubyObject read_nonblock(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - openFile.checkClosed(runtime); - - if(!(openFile.getMainStream() instanceof ChannelStream)) { - // cryptic for the uninitiated... - throw runtime.newNotImplementedError("read_nonblock only works with Nio based handlers"); - } - try { - int maxLength = RubyNumeric.fix2int(args[0]); - if (maxLength < 0) { - throw runtime.newArgumentError("negative length " + maxLength + " given"); - } - ByteList buf = ((ChannelStream)openFile.getMainStream()).readnonblock(RubyNumeric.fix2int(args[0])); - IRubyObject strbuf = RubyString.newString(runtime, buf == null ? new ByteList(ByteList.NULL_ARRAY) : buf); - if(args.length > 1) { - args[1].callMethod(context, MethodIndex.OP_LSHIFT, "<<", strbuf); - return args[1]; - } - - return strbuf; - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (EOFException e) { - return runtime.getNil(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - @JRubyMethod(name = "readpartial", required = 1, optional = 1) - public IRubyObject readpartial(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - openFile.checkClosed(runtime); - - if(!(openFile.getMainStream() instanceof ChannelStream)) { - // cryptic for the uninitiated... - throw runtime.newNotImplementedError("readpartial only works with Nio based handlers"); - } - try { - int maxLength = RubyNumeric.fix2int(args[0]); - if (maxLength < 0) { - throw runtime.newArgumentError("negative length " + maxLength + " given"); - } - ByteList buf = ((ChannelStream)openFile.getMainStream()).readpartial(RubyNumeric.fix2int(args[0])); - IRubyObject strbuf = RubyString.newString(runtime, buf == null ? new ByteList(ByteList.NULL_ARRAY) : buf); - if(args.length > 1) { - args[1].callMethod(context, MethodIndex.OP_LSHIFT, "<<", strbuf); - return args[1]; - } - - return strbuf; - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (EOFException e) { - return runtime.getNil(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - @JRubyMethod(name = "sysread", required = 1, optional = 1) - public IRubyObject sysread(ThreadContext context, IRubyObject[] args) { - int len = (int)RubyNumeric.num2long(args[0]); - if (len < 0) throw getRuntime().newArgumentError("Negative size"); - - try { - RubyString str; - ByteList buffer; - if (args.length == 1 || args[1].isNil()) { - if (len == 0) { - return RubyString.newStringShared(getRuntime(), ByteList.EMPTY_BYTELIST); - } - - buffer = new ByteList(len); - str = RubyString.newString(getRuntime(), buffer); - } else { - str = args[1].convertToString(); - str.modify(len); - - if (len == 0) { - return str; - } - - buffer = str.getByteList(); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - myOpenFile.checkReadable(getRuntime()); - - if (myOpenFile.getMainStream().readDataBuffered()) { - throw getRuntime().newIOError("sysread for buffered IO"); - } - - // TODO: Ruby locks the string here - - context.getThread().beforeBlockingCall(); - myOpenFile.checkClosed(getRuntime()); - - // TODO: Ruby re-checks that the buffer string hasn't been modified - - int bytesRead = myOpenFile.getMainStream().getDescriptor().read(len, str.getByteList()); - - // TODO: Ruby unlocks the string here - - // TODO: Ruby truncates string to specific size here, but our bytelist should handle this already? - - if (bytesRead == -1 || (bytesRead == 0 && len > 0)) { - throw getRuntime().newEOFError(); - } - - str.setTaint(true); - - return str; - } catch (BadDescriptorException e) { - throw getRuntime().newErrnoEBADFError(); - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } catch (PipeException e) { - throw getRuntime().newErrnoEPIPEError(); - } catch (EOFException e) { - throw getRuntime().newEOFError(); - } catch (IOException e) { - // All errors to sysread should be SystemCallErrors, but on a closed stream - // Ruby returns an IOError. Java throws same exception for all errors so - // we resort to this hack... - if ("File not open".equals(e.getMessage())) { - throw getRuntime().newIOError(e.getMessage()); - } - throw getRuntime().newSystemCallError(e.getMessage()); - } finally { - context.getThread().afterBlockingCall(); - } - } - - public IRubyObject read(IRubyObject[] args) { - ThreadContext context = getRuntime().getCurrentContext(); - - switch (args.length) { - case 0: return read(context); - case 1: return read(context, args[0]); - case 2: return read(context, args[0], args[1]); - default: throw getRuntime().newArgumentError(args.length, 2); - } - } - - @JRubyMethod(name = "read") - public IRubyObject read(ThreadContext context) { - Ruby runtime = context.getRuntime(); - OpenFile myOpenFile = getOpenFileChecked(); - - try { - myOpenFile.checkReadable(runtime); - myOpenFile.setReadBuffered(); - - return readAll(getRuntime().getNil()); - } catch (PipeException ex) { - throw getRuntime().newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } catch (EOFException ex) { - throw getRuntime().newEOFError(); - } catch (IOException ex) { - throw getRuntime().newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw getRuntime().newErrnoEBADFError(); - } - } - - @JRubyMethod(name = "read") - public IRubyObject read(ThreadContext context, IRubyObject arg0) { - if (arg0.isNil()) { - return read(context); - } - - OpenFile myOpenFile = getOpenFileChecked(); - - int length = RubyNumeric.num2int(arg0); - - if (length < 0) { - throw getRuntime().newArgumentError("negative length " + length + " given"); - } - - RubyString str = null; - - return readNotAll(context, myOpenFile, length, str); - } - - @JRubyMethod(name = "read") - public IRubyObject read(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - OpenFile myOpenFile = getOpenFileChecked(); - - if (arg0.isNil()) { - try { - myOpenFile.checkReadable(getRuntime()); - myOpenFile.setReadBuffered(); - - return readAll(arg1); - } catch (PipeException ex) { - throw getRuntime().newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw getRuntime().newErrnoEINVALError(); - } catch (EOFException ex) { - throw getRuntime().newEOFError(); - } catch (IOException ex) { - throw getRuntime().newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw getRuntime().newErrnoEBADFError(); - } - } - - int length = RubyNumeric.num2int(arg0); - - if (length < 0) { - throw getRuntime().newArgumentError("negative length " + length + " given"); - } - - RubyString str = null; -// ByteList buffer = null; - if (arg1.isNil()) { -// buffer = new ByteList(length); -// str = RubyString.newString(getRuntime(), buffer); - } else { - str = arg1.convertToString(); - str.modify(length); - - if (length == 0) { - return str; - } - -// buffer = str.getByteList(); - } - - return readNotAll(context, myOpenFile, length, str); - } - - private IRubyObject readNotAll(ThreadContext context, OpenFile myOpenFile, int length, RubyString str) { - Ruby runtime = context.getRuntime(); - - try { - myOpenFile.checkReadable(runtime); - myOpenFile.setReadBuffered(); - - if (myOpenFile.getMainStream().feof()) { - return runtime.getNil(); - } - - // TODO: Ruby locks the string here - - // READ_CHECK from MRI io.c - readCheck(myOpenFile.getMainStream()); - - // TODO: check buffer length again? - // if (RSTRING(str)->len != len) { - // rb_raise(rb_eRuntimeError, "buffer string modified"); - // } - - // TODO: read into buffer using all the fread logic - // int read = openFile.getMainStream().fread(buffer); - ByteList newBuffer = myOpenFile.getMainStream().fread(length); - - // TODO: Ruby unlocks the string here - - // TODO: change this to check number read into buffer once that's working - // if (read == 0) { - - if (newBuffer == null || newBuffer.length() == 0) { - if (myOpenFile.getMainStream() == null) { - return runtime.getNil(); - } - - if (myOpenFile.getMainStream().feof()) { - // truncate buffer string to zero, if provided - if (str != null) { - str.setValue(ByteList.EMPTY_BYTELIST.dup()); - } - - return runtime.getNil(); - } - - // Removed while working on JRUBY-2386, since fixes for that - // modified EOF logic such that this check is not really valid. - // We expect that an EOFException will be thrown now in EOF - // cases. -// if (length > 0) { -// // I think this is only partly correct; sys fail based on errno in Ruby -// throw getRuntime().newEOFError(); -// } - } - - - // TODO: Ruby truncates string to specific size here, but our bytelist should handle this already? - - // FIXME: I don't like the null checks here - if (str == null) { - if (newBuffer == null) { - str = RubyString.newEmptyString(runtime); - } else { - str = RubyString.newString(runtime, newBuffer); - } - } else { - if (newBuffer == null) { - str.empty(); - } else { - str.setValue(newBuffer); - } - } - str.setTaint(true); - - return str; - } catch (EOFException ex) { - throw runtime.newEOFError(); - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (IOException ex) { - throw runtime.newIOErrorFromException(ex); - } catch (BadDescriptorException ex) { - throw runtime.newErrnoEBADFError(); - } - } - - protected IRubyObject readAll(IRubyObject buffer) throws BadDescriptorException, EOFException, IOException { - Ruby runtime = getRuntime(); - // TODO: handle writing into original buffer better - - RubyString str = null; - if (buffer instanceof RubyString) { - str = (RubyString)buffer; - } - - // TODO: ruby locks the string here - - // READ_CHECK from MRI io.c - if (openFile.getMainStream().readDataBuffered()) { - openFile.checkClosed(runtime); - } - - ByteList newBuffer = openFile.getMainStream().readall(); - - // TODO same zero-length checks as file above - - if (str == null) { - if (newBuffer == null) { - str = RubyString.newEmptyString(runtime); - } else { - str = RubyString.newString(runtime, newBuffer); - } - } else { - if (newBuffer == null) { - str.empty(); - } else { - str.setValue(newBuffer); - } - } - - str.taint(runtime.getCurrentContext()); - - return str; -// long bytes = 0; -// long n; -// -// if (siz == 0) siz = BUFSIZ; -// if (NIL_P(str)) { -// str = rb_str_new(0, siz); -// } -// else { -// rb_str_resize(str, siz); -// } -// for (;;) { -// rb_str_locktmp(str); -// READ_CHECK(fptr->f); -// n = io_fread(RSTRING(str)->ptr+bytes, siz-bytes, fptr); -// rb_str_unlocktmp(str); -// if (n == 0 && bytes == 0) { -// if (!fptr->f) break; -// if (feof(fptr->f)) break; -// if (!ferror(fptr->f)) break; -// rb_sys_fail(fptr->path); -// } -// bytes += n; -// if (bytes < siz) break; -// siz += BUFSIZ; -// rb_str_resize(str, siz); -// } -// if (bytes != siz) rb_str_resize(str, bytes); -// OBJ_TAINT(str); -// -// return str; - } - - // TODO: There's a lot of complexity here due to error handling and - // nonblocking IO; much of this goes away, but for now I'm just - // having read call ChannelStream.fread directly. -// protected int fread(int len, ByteList buffer) { -// long n = len; -// int c; -// int saved_errno; -// -// while (n > 0) { -// c = read_buffered_data(ptr, n, fptr->f); -// if (c < 0) goto eof; -// if (c > 0) { -// ptr += c; -// if ((n -= c) <= 0) break; -// } -// rb_thread_wait_fd(fileno(fptr->f)); -// rb_io_check_closed(fptr); -// clearerr(fptr->f); -// TRAP_BEG; -// c = getc(fptr->f); -// TRAP_END; -// if (c == EOF) { -// eof: -// if (ferror(fptr->f)) { -// switch (errno) { -// case EINTR: -// #if defined(ERESTART) -// case ERESTART: -// #endif -// clearerr(fptr->f); -// continue; -// case EAGAIN: -// #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN -// case EWOULDBLOCK: -// #endif -// if (len > n) { -// clearerr(fptr->f); -// } -// saved_errno = errno; -// rb_warning("nonblocking IO#read is obsolete; use IO#readpartial or IO#sysread"); -// errno = saved_errno; -// } -// if (len == n) return 0; -// } -// break; -// } -// *ptr++ = c; -// n--; -// } -// return len - n; -// -// } - - /** Read a byte. On EOF throw EOFError. - * - */ - @JRubyMethod(name = "readchar") - public IRubyObject readchar() { - IRubyObject c = getc(); - - if (c.isNil()) throw getRuntime().newEOFError(); - - return c; - } - - @JRubyMethod - public IRubyObject stat(ThreadContext context) { - openFile.checkClosed(context.getRuntime()); - return context.getRuntime().newFileStat(getOpenFileChecked().getMainStream().getDescriptor().getFileDescriptor()); - } - - /** - * <p>Invoke a block for each byte.</p> - */ - @JRubyMethod(name = "each_byte", frame = true) - public IRubyObject each_byte(ThreadContext context, Block block) { - Ruby runtime = context.getRuntime(); - - try { - OpenFile myOpenFile = getOpenFileChecked(); - - while (true) { - myOpenFile.checkReadable(runtime); - myOpenFile.setReadBuffered(); - - // TODO: READ_CHECK from MRI - - int c = myOpenFile.getMainStream().fgetc(); - - if (c == -1) { - // TODO: check for error, clear it, and wait until readable before trying once more -// if (ferror(f)) { -// clearerr(f); -// if (!rb_io_wait_readable(fileno(f))) -// rb_sys_fail(fptr->path); -// continue; -// } - break; - } - - assert c < 256; - block.yield(context, getRuntime().newFixnum(c)); - } - - // TODO: one more check for error -// if (ferror(f)) rb_sys_fail(fptr->path); - return this; - } catch (PipeException ex) { - throw runtime.newErrnoEPIPEError(); - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (BadDescriptorException e) { - throw runtime.newErrnoEBADFError(); - } catch (EOFException e) { - return runtime.getNil(); - } catch (IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - /** - * <p>Invoke a block for each line.</p> - */ - @JRubyMethod(name = {"each_line", "each"}, optional = 1, frame = true) - public RubyIO each_line(ThreadContext context, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - ByteList separator = getSeparatorForGets(runtime, args); - - for (IRubyObject line = getline(runtime, separator); !line.isNil(); - line = getline(runtime, separator)) { - block.yield(context, line); - } - - return this; - } - - - @JRubyMethod(name = "readlines", optional = 1) - public RubyArray readlines(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - IRubyObject[] separatorArgs = args.length > 0 ? new IRubyObject[] { args[0] } : IRubyObject.NULL_ARRAY; - ByteList separator = getSeparatorForGets(runtime, separatorArgs); - RubyArray result = runtime.newArray(); - IRubyObject line; - - while (! (line = getline(runtime, separator)).isNil()) { - result.append(line); - } - return result; - } - - @JRubyMethod(name = "to_io") - public RubyIO to_io() { - return this; - } - - @Override - public String toString() { - return "RubyIO(" + openFile.getMode() + ", " + openFile.getMainStream().getDescriptor().getFileno() + ")"; - } - - /* class methods for IO */ - - /** rb_io_s_foreach - * - */ - @JRubyMethod(name = "foreach", required = 1, optional = 1, frame = true, meta = true) - public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - int count = args.length; - IRubyObject filename = args[0].convertToString(); - runtime.checkSafeString(filename); - - ByteList separator = getSeparatorFromArgs(runtime, args, 1); - - RubyIO io = (RubyIO)RubyFile.open(context, runtime.getFile(), new IRubyObject[] { filename }, Block.NULL_BLOCK); - - if (!io.isNil()) { - try { - IRubyObject str = io.getline(runtime, separator); - while (!str.isNil()) { - block.yield(context, str); - str = io.getline(runtime, separator); - } - } finally { - io.close(); - } - } - - return runtime.getNil(); - } - - private static RubyIO convertToIO(ThreadContext context, IRubyObject obj) { - return (RubyIO)TypeConverter.convertToType(obj, context.getRuntime().getIO(), MethodIndex.TO_IO, "to_io"); - } - - private static boolean registerSelect(ThreadContext context, Selector selector, IRubyObject obj, RubyIO ioObj, int ops) throws IOException { - Channel channel = ioObj.getChannel(); - if (channel == null || !(channel instanceof SelectableChannel)) { - return false; - } - - ((SelectableChannel) channel).configureBlocking(false); - int real_ops = ((SelectableChannel) channel).validOps() & ops; - SelectionKey key = ((SelectableChannel) channel).keyFor(selector); - - if (key == null) { - ((SelectableChannel) channel).register(selector, real_ops, obj); - } else { - key.interestOps(key.interestOps()|real_ops); - } - - return true; - } - - @JRubyMethod(name = "select", required = 1, optional = 3, meta = true) - public static IRubyObject select(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return select_static(context, context.getRuntime(), args); - } - - private static void checkArrayType(Ruby runtime, IRubyObject obj) { - if (!(obj instanceof RubyArray)) { - throw runtime.newTypeError("wrong argument type " - + obj.getMetaClass().getName() + " (expected Array)"); - } - } - - public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args) { - try { - Set pending = new HashSet(); - Set unselectable_reads = new HashSet(); - Set unselectable_writes = new HashSet(); - Selector selector = Selector.open(); - if (!args[0].isNil()) { - // read - checkArrayType(runtime, args[0]); - for (Iterator i = ((RubyArray) args[0]).getList().iterator(); i.hasNext(); ) { - IRubyObject obj = (IRubyObject) i.next(); - RubyIO ioObj = convertToIO(context, obj); - if (registerSelect(context, selector, obj, ioObj, SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) { - if (ioObj.writeDataBuffered()) { - pending.add(obj); - } - } else { - if (( ioObj.openFile.getMode() & OpenFile.READABLE ) != 0) { - unselectable_reads.add(obj); - } - } - } - } - - if (args.length > 1 && !args[1].isNil()) { - // write - checkArrayType(runtime, args[1]); - for (Iterator i = ((RubyArray) args[1]).getList().iterator(); i.hasNext(); ) { - IRubyObject obj = (IRubyObject) i.next(); - RubyIO ioObj = convertToIO(context, obj); - if (!registerSelect(context, selector, obj, ioObj, SelectionKey.OP_WRITE)) { - if (( ioObj.openFile.getMode() & OpenFile.WRITABLE ) != 0) { - unselectable_writes.add(obj); - } - } - } - } - - if (args.length > 2 && !args[2].isNil()) { - checkArrayType(runtime, args[2]); - // Java's select doesn't do anything about this, so we leave it be. - } - - final boolean has_timeout = ( args.length > 3 && !args[3].isNil() ); - long timeout = 0; - if(has_timeout) { - IRubyObject timeArg = args[3]; - if (timeArg instanceof RubyFloat) { - timeout = Math.round(((RubyFloat) timeArg).getDoubleValue() * 1000); - } else if (timeArg instanceof RubyFixnum) { - timeout = Math.round(((RubyFixnum) timeArg).getDoubleValue() * 1000); - } else { // TODO: MRI also can hadle Bignum here - throw runtime.newTypeError("can't convert " - + timeArg.getMetaClass().getName() + " into time interval"); - } - - if (timeout < 0) { - throw runtime.newArgumentError("negative timeout given"); - } - } - - if (pending.isEmpty() && unselectable_reads.isEmpty() && unselectable_writes.isEmpty()) { - if (has_timeout) { - if (timeout==0) { - selector.selectNow(); - } else { - selector.select(timeout); - } - } else { - selector.select(); - } - } else { - selector.selectNow(); - } - - List r = new ArrayList(); - List w = new ArrayList(); - List e = new ArrayList(); - for (Iterator i = selector.selectedKeys().iterator(); i.hasNext(); ) { - SelectionKey key = (SelectionKey) i.next(); - if ((key.interestOps() & key.readyOps() - & (SelectionKey.OP_READ|SelectionKey.OP_ACCEPT|SelectionKey.OP_CONNECT)) != 0) { - r.add(key.attachment()); - pending.remove(key.attachment()); - } - if ((key.interestOps() & key.readyOps() & (SelectionKey.OP_WRITE)) != 0) { - w.add(key.attachment()); - } - } - r.addAll(pending); - r.addAll(unselectable_reads); - w.addAll(unselectable_writes); - - // make all sockets blocking as configured again - for (Iterator i = selector.keys().iterator(); i.hasNext(); ) { - SelectionKey key = (SelectionKey) i.next(); - SelectableChannel channel = key.channel(); - synchronized(channel.blockingLock()) { - RubyIO originalIO = (RubyIO) TypeConverter.convertToType( - (IRubyObject) key.attachment(), runtime.getIO(), - MethodIndex.TO_IO, "to_io"); - boolean blocking = originalIO.getBlocking(); - key.cancel(); - channel.configureBlocking(blocking); - } - } - selector.close(); - - if (r.size() == 0 && w.size() == 0 && e.size() == 0) { - return runtime.getNil(); - } - - List ret = new ArrayList(); - - ret.add(RubyArray.newArray(runtime, r)); - ret.add(RubyArray.newArray(runtime, w)); - ret.add(RubyArray.newArray(runtime, e)); - - return RubyArray.newArray(runtime, ret); - } catch(IOException e) { - throw runtime.newIOError(e.getMessage()); - } - } - - public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - switch (args.length) { - case 0: throw context.getRuntime().newArgumentError(0, 1); - case 1: return read(context, recv, args[0], block); - case 2: return read(context, recv, args[0], args[1], block); - case 3: return read(context, recv, args[0], args[1], args[2], block); - default: throw context.getRuntime().newArgumentError(args.length, 3); - } - } - - @JRubyMethod(name = "read", meta = true) - public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) { - IRubyObject[] fileArguments = new IRubyObject[] {arg0}; - RubyIO file = (RubyIO) RubyKernel.open(context, recv, fileArguments, block); - - try { - return file.read(context); - } finally { - file.close(); - } - } - - @JRubyMethod(name = "read", meta = true) - public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) { - IRubyObject[] fileArguments = new IRubyObject[] {arg0}; - RubyIO file = (RubyIO) RubyKernel.open(context, recv, fileArguments, block); - - try { - if (!arg1.isNil()) { - return file.read(context, arg1); - } else { - return file.read(context); - } - } finally { - file.close(); - } - } - - @JRubyMethod(name = "read", meta = true) - public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - IRubyObject[] fileArguments = new IRubyObject[]{arg0}; - RubyIO file = (RubyIO) RubyKernel.open(context, recv, fileArguments, block); - - if (!arg2.isNil()) { - file.seek(context, arg2); - } - - try { - if (!arg1.isNil()) { - return file.read(context, arg1); - } else { - return file.read(context); - } - } finally { - file.close(); - } - } - - @JRubyMethod(name = "readlines", required = 1, optional = 1, meta = true) - public static RubyArray readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - int count = args.length; - - IRubyObject[] fileArguments = new IRubyObject[]{ args[0].convertToString() }; - IRubyObject[] separatorArguments = count >= 2 ? new IRubyObject[]{args[1]} : IRubyObject.NULL_ARRAY; - RubyIO file = (RubyIO) RubyKernel.open(context, recv, fileArguments, block); - try { - return file.readlines(context, separatorArguments); - } finally { - file.close(); - } - } - - @JRubyMethod(name = "popen", required = 1, optional = 1, meta = true) - public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - int mode; - - IRubyObject cmdObj = args[0].convertToString(); - runtime.checkSafeString(cmdObj); - - if ("-".equals(cmdObj.toString())) { - throw runtime.newNotImplementedError("popen(\"-\") is unimplemented"); - } - - try { - if (args.length == 1) { - mode = ModeFlags.RDONLY; - } else if (args[1] instanceof RubyFixnum) { - mode = RubyFixnum.num2int(args[1]); - } else { - mode = getIOModesIntFromString(runtime, args[1].convertToString().toString()); - } - - ModeFlags modes = new ModeFlags(mode); - - ShellLauncher.POpenProcess process = ShellLauncher.popen(runtime, cmdObj, modes); - RubyIO io = new RubyIO(runtime, process, modes); - - if (block.isGiven()) { - try { - return block.yield(context, io); - } finally { - if (io.openFile.isOpen()) { - io.close(); - } - runtime.getGlobalVariables().set("$?", RubyProcess.RubyStatus.newProcessStatus(runtime, (process.waitFor() * 256))); - } - } - return io; - } catch (InvalidValueException ex) { - throw runtime.newErrnoEINVALError(); - } catch (IOException e) { - throw runtime.newIOErrorFromException(e); - } catch (InterruptedException e) { - throw runtime.newThreadError("unexpected interrupt"); - } - } - - // NIO based pipe - @JRubyMethod(name = "pipe", meta = true) - public static IRubyObject pipe(ThreadContext context, IRubyObject recv) throws Exception { - // TODO: This isn't an exact port of MRI's pipe behavior, so revisit - Ruby runtime = context.getRuntime(); - Pipe pipe = Pipe.open(); - - RubyIO source = new RubyIO(runtime, pipe.source()); - RubyIO sink = new RubyIO(runtime, pipe.sink()); - - sink.openFile.getMainStream().setSync(true); - return runtime.newArrayNoCopy(new IRubyObject[] { source, sink }); - } - - @JRubyMethod(name = "copy_stream", meta = true, compat = RUBY1_9) - public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, - IRubyObject stream1, IRubyObject stream2) throws IOException { - RubyIO io1 = (RubyIO)stream1; - RubyIO io2 = (RubyIO)stream2; - - ChannelDescriptor d1 = io1.openFile.getMainStream().getDescriptor(); - if (!d1.isSeekable()) { - throw context.getRuntime().newTypeError("only supports file-to-file copy"); - } - ChannelDescriptor d2 = io2.openFile.getMainStream().getDescriptor(); - if (!d2.isSeekable()) { - throw context.getRuntime().newTypeError("only supports file-to-file copy"); - } - - FileChannel f1 = (FileChannel)d1.getChannel(); - FileChannel f2 = (FileChannel)d2.getChannel(); - - long size = f1.size(); - - f1.transferTo(f2.position(), size, f2); - - return context.getRuntime().newFixnum(size); - } - - /** - * Add a thread to the list of blocking threads for this IO. - * - * @param thread A thread blocking on this IO - */ - public synchronized void addBlockingThread(RubyThread thread) { - if (blockingThreads == null) { - blockingThreads = new ArrayList<RubyThread>(1); - } - blockingThreads.add(thread); - } - - /** - * Remove a thread from the list of blocking threads for this IO. - * - * @param thread A thread blocking on this IO - */ - public synchronized void removeBlockingThread(RubyThread thread) { - if (blockingThreads == null) { - return; - } - for (int i = 0; i < blockingThreads.size(); i++) { - if (blockingThreads.get(i) == thread) { - // not using remove(Object) here to avoid the equals() call - blockingThreads.remove(i); - } - } - } - - /** - * Fire an IOError in all threads blocking on this IO object - */ - protected synchronized void interruptBlockingThreads() { - if (blockingThreads == null) { - return; - } - for (int i = 0; i < blockingThreads.size(); i++) { - RubyThread thread = blockingThreads.get(i); - - // raise will also wake the thread from selection - thread.raise(new IRubyObject[] {getRuntime().newIOError("stream closed").getException()}, Block.NULL_BLOCK); - } - } -} -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2005 Thomas E Enebo <enebo@acm.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.anno.JRubyClass; - -import org.jruby.ast.ArgsNode; -import org.jruby.ast.ArgumentNode; -import org.jruby.ast.ListNode; -import org.jruby.ast.LocalAsgnNode; -import org.jruby.javasupport.Java; -import org.jruby.javasupport.JavaObject; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.load.Library; -import org.jruby.internal.runtime.methods.DynamicMethod; - -import org.jruby.ast.Node; -import org.jruby.compiler.ASTInspector; -import org.jruby.compiler.ASTCompiler; -import org.jruby.compiler.impl.StandardASMCompiler; -import org.jruby.internal.runtime.methods.MethodArgs; -import org.jruby.javasupport.JavaUtil; -import org.jruby.runtime.InterpretedBlock; -import org.jruby.runtime.ThreadContext; -import org.jruby.util.TypeConverter; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.util.TraceClassVisitor; - -/** - * Module which defines JRuby-specific methods for use. - */ -@JRubyModule(name="JRuby") -public class RubyJRuby { - public static RubyModule createJRuby(Ruby runtime) { - ThreadContext context = runtime.getCurrentContext(); - runtime.getKernel().callMethod(context, "require", runtime.newString("java")); - RubyModule jrubyModule = runtime.defineModule("JRuby"); - - jrubyModule.defineAnnotatedMethods(RubyJRuby.class); - - RubyClass compiledScriptClass = jrubyModule.defineClassUnder("CompiledScript",runtime.getObject(), runtime.getObject().getAllocator()); - - compiledScriptClass.attr_accessor(context, new IRubyObject[]{runtime.newSymbol("name"), runtime.newSymbol("class_name"), runtime.newSymbol("original_script"), runtime.newSymbol("code")}); - compiledScriptClass.defineAnnotatedMethods(JRubyCompiledScript.class); - - return jrubyModule; - } - - public static RubyModule createJRubyExt(Ruby runtime) { - runtime.getKernel().callMethod(runtime.getCurrentContext(),"require", runtime.newString("java")); - RubyModule mJRubyExt = runtime.getOrCreateModule("JRuby").defineModuleUnder("Extensions"); - - mJRubyExt.defineAnnotatedMethods(JRubyExtensions.class); - - runtime.getObject().includeModule(mJRubyExt); - - return mJRubyExt; - } - - public static class ExtLibrary implements Library { - public void load(Ruby runtime, boolean wrap) throws IOException { - RubyJRuby.createJRubyExt(runtime); - - runtime.getMethod().defineAnnotatedMethods(MethodExtensions.class); - } - } - - public static class TypeLibrary implements Library { - public void load(Ruby runtime, boolean wrap) throws IOException { - RubyModule jrubyType = runtime.defineModule("Type"); - jrubyType.defineAnnotatedMethods(TypeLibrary.class); - } - - @JRubyMethod(module = true) - public static IRubyObject coerce_to(ThreadContext context, IRubyObject self, IRubyObject object, IRubyObject clazz, IRubyObject method) { - Ruby ruby = object.getRuntime(); - - if (!(clazz instanceof RubyClass)) { - throw ruby.newTypeError(clazz, ruby.getClassClass()); - } - if (!(method instanceof RubySymbol)) { - throw ruby.newTypeError(method, ruby.getSymbol()); - } - - RubyClass rubyClass = (RubyClass)clazz; - RubySymbol methodSym = (RubySymbol)method; - - return TypeConverter.convertToTypeOrRaise(object, rubyClass, methodSym.asJavaString()); - } - } - - @JRubyMethod(name = "runtime", frame = true, module = true) - public static IRubyObject runtime(IRubyObject recv, Block unusedBlock) { - return Java.java_to_ruby(recv, JavaObject.wrap(recv.getRuntime(), recv.getRuntime()), Block.NULL_BLOCK); - } - - @JRubyMethod(name = "objectspace", frame = true, module = true) - public static IRubyObject getObjectSpaceEnabled(IRubyObject recv, Block b) { - Ruby runtime = recv.getRuntime(); - return RubyBoolean.newBoolean( - runtime, runtime.isObjectSpaceEnabled()); - } - - @JRubyMethod(name = "objectspace=", required = 1, frame = true, module = true) - public static IRubyObject setObjectSpaceEnabled( - IRubyObject recv, IRubyObject arg, Block b) { - Ruby runtime = recv.getRuntime(); - runtime.setObjectSpaceEnabled(arg.isTrue()); - return runtime.getNil(); - } - - @JRubyMethod(name = {"parse", "ast_for"}, optional = 3, frame = true, module = true) - public static IRubyObject parse(IRubyObject recv, IRubyObject[] args, Block block) { - if(block.isGiven()) { - if(block.getBody() instanceof org.jruby.runtime.CompiledBlock) { - throw new RuntimeException("Cannot compile an already compiled block. Use -J-Djruby.jit.enabled=false to avoid this problem."); - } - Arity.checkArgumentCount(recv.getRuntime(),args,0,0); - return Java.java_to_ruby(recv, JavaObject.wrap(recv.getRuntime(), ((InterpretedBlock)block.getBody()).getIterNode().getBodyNode()), Block.NULL_BLOCK); - } else { - Arity.checkArgumentCount(recv.getRuntime(),args,1,3); - String filename = "-"; - boolean extraPositionInformation = false; - RubyString content = args[0].convertToString(); - if(args.length>1) { - filename = args[1].convertToString().toString(); - if(args.length>2) { - extraPositionInformation = args[2].isTrue(); - } - } - return Java.java_to_ruby(recv, JavaObject.wrap(recv.getRuntime(), - recv.getRuntime().parse(content.getByteList(), filename, null, 0, extraPositionInformation)), Block.NULL_BLOCK); - } - } - - @JRubyMethod(name = "compile", optional = 3, frame = true, module = true) - public static IRubyObject compile(IRubyObject recv, IRubyObject[] args, Block block) { - Node node; - String filename; - RubyString content; - if(block.isGiven()) { - Arity.checkArgumentCount(recv.getRuntime(),args,0,0); - if(block.getBody() instanceof org.jruby.runtime.CompiledBlock) { - throw new RuntimeException("Cannot compile an already compiled block. Use -J-Djruby.jit.enabled=false to avoid this problem."); - } - content = RubyString.newEmptyString(recv.getRuntime()); - Node bnode = ((InterpretedBlock)block.getBody()).getIterNode().getBodyNode(); - node = new org.jruby.ast.RootNode(bnode.getPosition(), block.getBinding().getDynamicScope(), bnode); - filename = "__block_" + node.getPosition().getFile(); - } else { - Arity.checkArgumentCount(recv.getRuntime(),args,1,3); - filename = "-"; - boolean extraPositionInformation = false; - content = args[0].convertToString(); - if(args.length>1) { - filename = args[1].convertToString().toString(); - if(args.length>2) { - extraPositionInformation = args[2].isTrue(); - } - } - - node = recv.getRuntime().parse(content.getByteList(), filename, null, 0, extraPositionInformation); - } - - String classname; - if (filename.equals("-e")) { - classname = "__dash_e__"; - } else { - classname = filename.replace('\\', '/').replaceAll(".rb", "").replaceAll("-","_dash_"); - } - - ASTInspector inspector = new ASTInspector(); - inspector.inspect(node); - - StandardASMCompiler asmCompiler = new StandardASMCompiler(classname, filename); - ASTCompiler compiler = new ASTCompiler(); - compiler.compileRoot(node, asmCompiler, inspector); - byte[] bts = asmCompiler.getClassByteArray(); - - IRubyObject compiledScript = ((RubyModule)recv).fastGetConstant("CompiledScript").callMethod(recv.getRuntime().getCurrentContext(),"new"); - compiledScript.callMethod(recv.getRuntime().getCurrentContext(), "name=", recv.getRuntime().newString(filename)); - compiledScript.callMethod(recv.getRuntime().getCurrentContext(), "class_name=", recv.getRuntime().newString(classname)); - compiledScript.callMethod(recv.getRuntime().getCurrentContext(), "original_script=", content); - compiledScript.callMethod(recv.getRuntime().getCurrentContext(), "code=", Java.java_to_ruby(recv, JavaObject.wrap(recv.getRuntime(), bts), Block.NULL_BLOCK)); - - return compiledScript; - } - - @JRubyMethod(name = "reference", required = 1, module = true) - public static IRubyObject reference(IRubyObject recv, IRubyObject obj) { - return Java.wrap(recv.getRuntime().getJavaSupport().getJavaUtilitiesModule(), - JavaObject.wrap(recv.getRuntime(), obj)); - } - - @JRubyMethod(name = "dereference", required = 1, module = true) - public static IRubyObject dereference(ThreadContext context, IRubyObject recv, IRubyObject obj) { - if (!(obj.dataGetStruct() instanceof JavaObject)) { - throw context.getRuntime().newTypeError("got " + obj + ", expected wrapped Java object"); - } - - Object unwrapped = JavaUtil.unwrapJavaObject(obj); - - if (!(unwrapped instanceof IRubyObject)) { - throw context.getRuntime().newTypeError("got " + obj + ", expected Java-wrapped Ruby object"); - } - - return (IRubyObject)unwrapped; - } - - @JRubyClass(name="JRuby::CompiledScript") - public static class JRubyCompiledScript { - @JRubyMethod(name = "to_s") - public static IRubyObject compiled_script_to_s(IRubyObject recv) { - return recv.getInstanceVariables().fastGetInstanceVariable("@original_script"); - } - - @JRubyMethod(name = "inspect") - public static IRubyObject compiled_script_inspect(IRubyObject recv) { - return recv.getRuntime().newString("#<JRuby::CompiledScript " + recv.getInstanceVariables().fastGetInstanceVariable("@name") + ">"); - } - - @JRubyMethod(name = "inspect_bytecode") - public static IRubyObject compiled_script_inspect_bytecode(IRubyObject recv) { - StringWriter sw = new StringWriter(); - ClassReader cr = new ClassReader((byte[])org.jruby.javasupport.JavaUtil.convertRubyToJava(recv.getInstanceVariables().fastGetInstanceVariable("@code"),byte[].class)); - TraceClassVisitor cv = new TraceClassVisitor(new PrintWriter(sw)); - cr.accept(cv, ClassReader.SKIP_DEBUG); - return recv.getRuntime().newString(sw.toString()); - } - } - - @JRubyModule(name="JRubyExtensions") - public static class JRubyExtensions { - @JRubyMethod(name = "steal_method", required = 2, module = true) - public static IRubyObject steal_method(IRubyObject recv, IRubyObject type, IRubyObject methodName) { - RubyModule to_add = null; - if(recv instanceof RubyModule) { - to_add = (RubyModule)recv; - } else { - to_add = recv.getSingletonClass(); - } - String name = methodName.toString(); - if(!(type instanceof RubyModule)) { - throw recv.getRuntime().newArgumentError("First argument must be a module/class"); - } - - DynamicMethod method = ((RubyModule)type).searchMethod(name); - if(method == null || method.isUndefined()) { - throw recv.getRuntime().newArgumentError("No such method " + name + " on " + type); - } - - to_add.addMethod(name, method); - return recv.getRuntime().getNil(); - } - - @JRubyMethod(name = "steal_methods", required = 1, rest = true, module = true) - public static IRubyObject steal_methods(IRubyObject recv, IRubyObject[] args) { - IRubyObject type = args[0]; - for(int i=1;i<args.length;i++) { - steal_method(recv, type, args[i]); - } - return recv.getRuntime().getNil(); - } - } - - public static class MethodExtensions { - @JRubyMethod(name = "args") - public static IRubyObject methodArgs(IRubyObject recv) { - Ruby ruby = recv.getRuntime(); - RubyMethod rubyMethod = (RubyMethod)recv; - - DynamicMethod method = rubyMethod.method; - - if (method instanceof MethodArgs) { - MethodArgs interpMethod = (MethodArgs)method; - ArgsNode args = interpMethod.getArgsNode(); - RubyArray argsArray = RubyArray.newArray(ruby); - - RubyArray reqArray = RubyArray.newArray(ruby); - ListNode requiredArgs = args.getArgs(); - for (int i = 0; requiredArgs != null && i < requiredArgs.size(); i++) { - ArgumentNode arg = (ArgumentNode)requiredArgs.get(i); - reqArray.append(RubySymbol.newSymbol(ruby, arg.getName())); - } - argsArray.append(reqArray); - - RubyArray optArray = RubyArray.newArray(ruby); - ListNode optArgs = args.getOptArgs(); - for (int i = 0; optArgs != null && i < optArgs.size(); i++) { - LocalAsgnNode arg = (LocalAsgnNode)optArgs.get(i); - optArray.append(RubySymbol.newSymbol(ruby, arg.getName())); - } - argsArray.append(optArray); - - if (args.getRestArgNode() != null) { - argsArray.append(RubySymbol.newSymbol(ruby, args.getRestArgNode().getName())); - } else { - argsArray.append(ruby.getNil()); - } - - if (args.getBlockArgNode() != null) { - argsArray.append(RubySymbol.newSymbol(ruby, args.getBlockArgNode().getName())); - } else { - argsArray.append(ruby.getNil()); - } - - return argsArray; - } - - throw ruby.newTypeError("Method args are only available for standard interpreted or jitted methods"); - } - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Kiel Hodges <jruby-devel@selfsosoft.com> - * Copyright (C) 2006 Evan Buswell <evan@heron.sytes.net> - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * Copyright (C) 2006 Michael Studman <codehaus@michaelstudman.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.ByteArrayOutputStream; -import java.math.BigInteger; -import java.util.ArrayList; -import static org.jruby.anno.FrameField.*; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; - -import org.jruby.ast.util.ArgsUtil; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.evaluator.ASTInterpreter; -import org.jruby.exceptions.JumpException; -import org.jruby.exceptions.MainExitException; -import org.jruby.exceptions.RaiseException; -import org.jruby.internal.runtime.JumpTarget; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallType; -import org.jruby.runtime.Frame; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import static org.jruby.runtime.Visibility.*; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.load.IAutoloadMethod; -import org.jruby.runtime.load.LoadService; -import org.jruby.util.IdUtil; -import org.jruby.util.ShellLauncher; -import org.jruby.util.TypeConverter; - -/** - * Note: For CVS history, see KernelModule.java. - */ -@JRubyModule(name="Kernel") -public class RubyKernel { - public final static Class<?> IRUBY_OBJECT = IRubyObject.class; - - public static RubyModule createKernelModule(Ruby runtime) { - RubyModule module = runtime.defineModule("Kernel"); - runtime.setKernel(module); - - module.defineAnnotatedMethods(RubyKernel.class); - module.defineAnnotatedMethods(RubyObject.class); - - runtime.setRespondToMethod(module.searchMethod("respond_to?")); - - module.setFlag(RubyObject.USER7_F, false); //Kernel is the only Module that doesn't need an implementor - - return module; - } - - @JRubyMethod(name = "at_exit", frame = true, module = true, visibility = PRIVATE) - public static IRubyObject at_exit(ThreadContext context, IRubyObject recv, Block block) { - return context.getRuntime().pushExitBlock(context.getRuntime().newProc(Block.Type.PROC, block)); - } - - @JRubyMethod(name = "autoload?", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject autoload_p(ThreadContext context, final IRubyObject recv, IRubyObject symbol) { - Ruby runtime = context.getRuntime(); - RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : runtime.getObject(); - String name = module.getName() + "::" + symbol.asJavaString(); - - IAutoloadMethod autoloadMethod = runtime.getLoadService().autoloadFor(name); - if (autoloadMethod == null) return runtime.getNil(); - - return runtime.newString(autoloadMethod.file()); - } - - @JRubyMethod(name = "autoload", required = 2, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject autoload(final IRubyObject recv, IRubyObject symbol, final IRubyObject file) { - Ruby runtime = recv.getRuntime(); - final LoadService loadService = runtime.getLoadService(); - String nonInternedName = symbol.asJavaString(); - - if (!IdUtil.isValidConstantName(nonInternedName)) { - throw runtime.newNameError("autoload must be constant name", nonInternedName); - } - - RubyString fileString = file.convertToString(); - - if (fileString.isEmpty()) { - throw runtime.newArgumentError("empty file name"); - } - - final String baseName = symbol.asJavaString().intern(); // interned, OK for "fast" methods - final RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : runtime.getObject(); - String nm = module.getName() + "::" + baseName; - - IRubyObject existingValue = module.fastFetchConstant(baseName); - if (existingValue != null && existingValue != RubyObject.UNDEF) return runtime.getNil(); - - module.fastStoreConstant(baseName, RubyObject.UNDEF); - - loadService.addAutoload(nm, new IAutoloadMethod() { - public String file() { - return file.toString(); - } - /** - * @see org.jruby.runtime.load.IAutoloadMethod#load(Ruby, String) - */ - public IRubyObject load(Ruby runtime, String name) { - boolean required = loadService.require(file()); - - // File to be loaded by autoload has already been or is being loaded. - if (!required) return null; - - return module.fastGetConstant(baseName); - } - }); - return runtime.getNil(); - } - - @JRubyMethod(name = "method_missing", rest = true, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject method_missing(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - - if (args.length == 0 || !(args[0] instanceof RubySymbol)) throw runtime.newArgumentError("no id given"); - - Visibility lastVis = context.getLastVisibility(); - CallType lastCallType = context.getLastCallType(); - - // create a lightweight thunk - IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime, - recv, - args[0], - lastVis, - lastCallType); - final IRubyObject[]exArgs; - final RubyClass exc; - if (lastCallType != CallType.VARIABLE) { - exc = runtime.getNoMethodError(); - exArgs = new IRubyObject[]{msg, args[0], RubyArray.newArrayNoCopy(runtime, args, 1)}; - } else { - exc = runtime.getNameError(); - exArgs = new IRubyObject[]{msg, args[0]}; - } - - throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK)); - } - - @JRubyMethod(name = "open", required = 1, optional = 2, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - String arg = args[0].convertToString().toString(); - Ruby runtime = context.getRuntime(); - - if (arg.startsWith("|")) { - String command = arg.substring(1); - // exec process, create IO with process - return RubyIO.popen(context, runtime.getIO(), new IRubyObject[] {runtime.newString(command)}, block); - } - - return RubyFile.open(context, runtime.getFile(), args, block); - } - - @JRubyMethod(name = "getc", module = true, visibility = PRIVATE) - public static IRubyObject getc(ThreadContext context, IRubyObject recv) { - context.getRuntime().getWarnings().warn(ID.DEPRECATED_METHOD, "getc is obsolete; use STDIN.getc instead", "getc", "STDIN.getc"); - IRubyObject defin = context.getRuntime().getGlobalVariables().get("$stdin"); - return defin.callMethod(context, "getc"); - } - - @JRubyMethod(name = "gets", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject gets(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return RubyArgsFile.gets(context, context.getRuntime().getGlobalVariables().get("$<"), args); - } - - @JRubyMethod(name = "abort", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject abort(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - if(args.length == 1) { - context.getRuntime().getGlobalVariables().get("$stderr").callMethod(context,"puts",args[0]); - } - throw new MainExitException(1,true); - } - - @JRubyMethod(name = "Array", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject new_array(ThreadContext context, IRubyObject recv, IRubyObject object) { - IRubyObject value = object.checkArrayType(); - - if (value.isNil()) { - if (object.getMetaClass().searchMethod("to_a").getImplementationClass() != context.getRuntime().getKernel()) { - value = object.callMethod(context, MethodIndex.TO_A, "to_a"); - if (!(value instanceof RubyArray)) throw context.getRuntime().newTypeError("`to_a' did not return Array"); - return value; - } else { - return context.getRuntime().newArray(object); - } - } - return value; - } - - @JRubyMethod(name = "Complex", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_complex(ThreadContext context, IRubyObject recv) { - return RuntimeHelpers.invoke(context, context.getRuntime().getComplex(), "convert"); - } - @JRubyMethod(name = "Complex", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_complex(ThreadContext context, IRubyObject recv, IRubyObject arg) { - return RuntimeHelpers.invoke(context, context.getRuntime().getComplex(), "convert", arg); - } - @JRubyMethod(name = "Complex", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_complex(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) { - return RuntimeHelpers.invoke(context, context.getRuntime().getComplex(), "convert", arg0, arg1); - } - - @JRubyMethod(name = "Rational", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_rational(ThreadContext context, IRubyObject recv) { - return RuntimeHelpers.invoke(context, context.getRuntime().getRational(), "convert"); - } - @JRubyMethod(name = "Rational", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_rational(ThreadContext context, IRubyObject recv, IRubyObject arg) { - return RuntimeHelpers.invoke(context, context.getRuntime().getRational(), "convert", arg); - } - @JRubyMethod(name = "Rational", module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static IRubyObject new_rational(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) { - return RuntimeHelpers.invoke(context, context.getRuntime().getRational(), "convert", arg0, arg1); - } - - @JRubyMethod(name = "Float", module = true, visibility = PRIVATE) - public static IRubyObject new_float(IRubyObject recv, IRubyObject object) { - if(object instanceof RubyFixnum){ - return RubyFloat.newFloat(object.getRuntime(), ((RubyFixnum)object).getDoubleValue()); - }else if(object instanceof RubyFloat){ - return object; - }else if(object instanceof RubyBignum){ - return RubyFloat.newFloat(object.getRuntime(), RubyBignum.big2dbl((RubyBignum)object)); - }else if(object instanceof RubyString){ - if(((RubyString)object).getByteList().realSize == 0){ // rb_cstr_to_dbl case - throw recv.getRuntime().newArgumentError("invalid value for Float(): " + object.inspect()); - } - return RubyNumeric.str2fnum(recv.getRuntime(),(RubyString)object,true); - }else if(object.isNil()){ - throw recv.getRuntime().newTypeError("can't convert nil into Float"); - } else { - RubyFloat rFloat = (RubyFloat)TypeConverter.convertToType(object, recv.getRuntime().getFloat(), MethodIndex.TO_F, "to_f"); - if (Double.isNaN(rFloat.getDoubleValue())) throw recv.getRuntime().newArgumentError("invalid value for Float()"); - return rFloat; - } - } - - @JRubyMethod(name = "Integer", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject new_integer(ThreadContext context, IRubyObject recv, IRubyObject object) { - if (object instanceof RubyFloat) { - double val = ((RubyFloat)object).getDoubleValue(); - if (val > (double) RubyFixnum.MAX && val < (double) RubyFixnum.MIN) { - return RubyNumeric.dbl2num(context.getRuntime(),((RubyFloat)object).getDoubleValue()); - } - } else if (object instanceof RubyFixnum || object instanceof RubyBignum) { - return object; - } else if (object instanceof RubyString) { - return RubyNumeric.str2inum(context.getRuntime(),(RubyString)object,0,true); - } - - IRubyObject tmp = TypeConverter.convertToType(object, context.getRuntime().getInteger(), MethodIndex.TO_INT, "to_int", false); - if (tmp.isNil()) return object.convertToInteger(MethodIndex.TO_I, "to_i"); - return tmp; - } - - @JRubyMethod(name = "String", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject new_string(ThreadContext context, IRubyObject recv, IRubyObject object) { - return TypeConverter.convertToType(object, context.getRuntime().getString(), MethodIndex.TO_S, "to_s"); - } - - @JRubyMethod(name = "p", rest = true, module = true, visibility = PRIVATE) - public static IRubyObject p(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - IRubyObject defout = runtime.getGlobalVariables().get("$>"); - - for (int i = 0; i < args.length; i++) { - if (args[i] != null) { - defout.callMethod(context, "write", RubyObject.inspect(context, args[i])); - defout.callMethod(context, "write", runtime.newString("\n")); - } - } - - if (defout instanceof RubyFile) { - ((RubyFile)defout).flush(); - } - - return context.getRuntime().getNil(); - } - - /** rb_f_putc - */ - @JRubyMethod(name = "putc", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject putc(ThreadContext context, IRubyObject recv, IRubyObject ch) { - IRubyObject defout = context.getRuntime().getGlobalVariables().get("$>"); - return defout.callMethod(context, "putc", ch); - } - - @JRubyMethod(name = "puts", rest = true, module = true, visibility = PRIVATE) - public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject defout = context.getRuntime().getGlobalVariables().get("$>"); - - defout.callMethod(context, "puts", args); - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "print", rest = true, module = true, visibility = PRIVATE) - public static IRubyObject print(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject defout = context.getRuntime().getGlobalVariables().get("$>"); - - defout.callMethod(context, "print", args); - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "printf", rest = true, module = true, visibility = PRIVATE) - public static IRubyObject printf(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - if (args.length != 0) { - IRubyObject defout = context.getRuntime().getGlobalVariables().get("$>"); - - if (!(args[0] instanceof RubyString)) { - defout = args[0]; - args = ArgsUtil.popArray(args); - } - - defout.callMethod(context, "write", RubyKernel.sprintf(recv, args)); - } - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "readline", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject readline(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - IRubyObject line = gets(context, recv, args); - - if (line.isNil()) throw context.getRuntime().newEOFError(); - - return line; - } - - @JRubyMethod(name = "readlines", optional = 1, module = true, visibility = PRIVATE) - public static RubyArray readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return RubyArgsFile.readlines(context, context.getRuntime().getGlobalVariables().get("$<"), args); - } - - /** Returns value of $_. - * - * @throws TypeError if $_ is not a String or nil. - * @return value of $_ as String. - */ - private static RubyString getLastlineString(ThreadContext context, Ruby runtime) { - IRubyObject line = context.getPreviousFrame().getLastLine(); - - if (line.isNil()) { - throw runtime.newTypeError("$_ value need to be String (nil given)."); - } else if (!(line instanceof RubyString)) { - throw runtime.newTypeError("$_ value need to be String (" + line.getMetaClass().getName() + " given)."); - } else { - return (RubyString) line; - } - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */ - public static IRubyObject sub_bang(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - return getLastlineString(context, context.getRuntime()).sub_bang(context, args, block); - } - - @JRubyMethod(name = "sub!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE) - public static IRubyObject sub_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) { - return getLastlineString(context, context.getRuntime()).sub_bang(context, arg0, block); - } - - @JRubyMethod(name = "sub!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE) - public static IRubyObject sub_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) { - return getLastlineString(context, context.getRuntime()).sub_bang(context, arg0, arg1, block); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */ - public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.sub_bang(context, args, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - @JRubyMethod(name = "sub", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.sub_bang(context, arg0, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - @JRubyMethod(name = "sub", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject sub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.sub_bang(context, arg0, arg1, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */ - public static IRubyObject gsub_bang(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - return getLastlineString(context, context.getRuntime()).gsub_bang(context, args, block); - } - - @JRubyMethod(name = "gsub!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject gsub_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) { - return getLastlineString(context, context.getRuntime()).gsub_bang(context, arg0, block); - } - - @JRubyMethod(name = "gsub!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject gsub_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) { - return getLastlineString(context, context.getRuntime()).gsub_bang(context, arg0, arg1, block); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the one or two-arg versions. - */ - public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.gsub_bang(context, args, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - @JRubyMethod(name = "gsub", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.gsub_bang(context, arg0, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - @JRubyMethod(name = "gsub", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject gsub(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, Block block) { - RubyString str = (RubyString) getLastlineString(context, context.getRuntime()).dup(); - - if (!str.gsub_bang(context, arg0, arg1, block).isNil()) { - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - @JRubyMethod(name = "chop!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chop_bang(ThreadContext context, IRubyObject recv, Block block) { - return getLastlineString(context, context.getRuntime()).chop_bang(); - } - - @JRubyMethod(name = "chop", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chop(ThreadContext context, IRubyObject recv, Block block) { - RubyString str = getLastlineString(context, context.getRuntime()); - - if (str.getByteList().realSize > 0) { - str = (RubyString) str.dup(); - str.chop_bang(); - context.getPreviousFrame().setLastLine(str); - } - - return str; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one-arg versions. - */ - public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - return getLastlineString(context, context.getRuntime()).chomp_bang(args); - } - - @JRubyMethod(name = "chomp!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv) { - return getLastlineString(context, context.getRuntime()).chomp_bang(); - } - - @JRubyMethod(name = "chomp!", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chomp_bang(ThreadContext context, IRubyObject recv, IRubyObject arg0) { - return getLastlineString(context, context.getRuntime()).chomp_bang(arg0); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one-arg versions. - */ - public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyString str = getLastlineString(context, context.getRuntime()); - RubyString dup = (RubyString) str.dup(); - - if (dup.chomp_bang(args).isNil()) { - return str; - } - - context.getPreviousFrame().setLastLine(dup); - return dup; - } - - @JRubyMethod(name = "chomp", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chomp(ThreadContext context, IRubyObject recv) { - RubyString str = getLastlineString(context, context.getRuntime()); - RubyString dup = (RubyString) str.dup(); - - if (dup.chomp_bang().isNil()) { - return str; - } - - context.getPreviousFrame().setLastLine(dup); - return dup; - } - - @JRubyMethod(name = "chomp", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = LASTLINE) - public static IRubyObject chomp(ThreadContext context, IRubyObject recv, IRubyObject arg0) { - RubyString str = getLastlineString(context, context.getRuntime()); - RubyString dup = (RubyString) str.dup(); - - if (dup.chomp_bang(arg0).isNil()) { - return str; - } - - context.getPreviousFrame().setLastLine(dup); - return dup; - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * - * @param context The thread context for the current thread - * @param recv The receiver of the method (usually a class that has included Kernel) - * @return - * @deprecated Use the versions with zero, one, or two args. - */ - public static IRubyObject split(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return getLastlineString(context, context.getRuntime()).split(context, args); - } - - @JRubyMethod(name = "split", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = {LASTLINE, BACKREF}) - public static IRubyObject split(ThreadContext context, IRubyObject recv) { - return getLastlineString(context, context.getRuntime()).split(context); - } - - @JRubyMethod(name = "split", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = {LASTLINE, BACKREF}) - public static IRubyObject split(ThreadContext context, IRubyObject recv, IRubyObject arg0) { - return getLastlineString(context, context.getRuntime()).split(context, arg0); - } - - @JRubyMethod(name = "split", frame = true, module = true, visibility = PRIVATE, reads = LASTLINE, writes = {LASTLINE, BACKREF}) - public static IRubyObject split(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) { - return getLastlineString(context, context.getRuntime()).split(context, arg0, arg1); - } - - @JRubyMethod(name = "scan", required = 1, frame = true, module = true, visibility = PRIVATE, reads = {LASTLINE, BACKREF}, writes = {LASTLINE, BACKREF}) - public static IRubyObject scan(ThreadContext context, IRubyObject recv, IRubyObject pattern, Block block) { - return getLastlineString(context, context.getRuntime()).scan(context, pattern, block); - } - - @JRubyMethod(name = "select", required = 1, optional = 3, module = true, visibility = PRIVATE) - public static IRubyObject select(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return RubyIO.select_static(context, context.getRuntime(), args); - } - - @JRubyMethod(name = "sleep", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject sleep(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - long milliseconds; - - if (args.length == 0) { - // Zero sleeps forever - milliseconds = 0; - } else { - if (!(args[0] instanceof RubyNumeric)) { - throw context.getRuntime().newTypeError("can't convert " + args[0].getMetaClass().getName() + "into time interval"); - } - milliseconds = (long) (args[0].convertToFloat().getDoubleValue() * 1000); - if (milliseconds < 0) { - throw context.getRuntime().newArgumentError("time interval must be positive"); - } else if (milliseconds == 0) { - // Explicit zero in MRI returns immediately - return context.getRuntime().newFixnum(0); - } - } - long startTime = System.currentTimeMillis(); - - RubyThread rubyThread = context.getThread(); - - do { - long loopStartTime = System.currentTimeMillis(); - try { - rubyThread.sleep(milliseconds); - } catch (InterruptedException iExcptn) { - } - milliseconds -= (System.currentTimeMillis() - loopStartTime); - } while (milliseconds > 0); - - return context.getRuntime().newFixnum(Math.round((System.currentTimeMillis() - startTime) / 1000.0)); - } - - // FIXME: Add at_exit and finalizers to exit, then make exit_bang not call those. - @JRubyMethod(name = "exit", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject exit(IRubyObject recv, IRubyObject[] args) { - exit(recv.getRuntime(), args, false); - return recv.getRuntime().getNil(); // not reached - } - - @JRubyMethod(name = "exit!", optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject exit_bang(IRubyObject recv, IRubyObject[] args) { - exit(recv.getRuntime(), args, true); - return recv.getRuntime().getNil(); // not reached - } - - private static void exit(Ruby runtime, IRubyObject[] args, boolean hard) { - runtime.secure(4); - - int status = 1; - if (args.length > 0) { - RubyObject argument = (RubyObject)args[0]; - if (argument instanceof RubyFixnum) { - status = RubyNumeric.fix2int(argument); - } else { - status = argument.isFalse() ? 1 : 0; - } - } - - if (hard) { - throw new MainExitException(status, true); - } else { - throw runtime.newSystemExit(status); - } - } - - - /** Returns an Array with the names of all global variables. - * - */ - @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) - public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { - Ruby runtime = context.getRuntime(); - RubyArray globalVariables = runtime.newArray(); - - for (String globalVariableName : runtime.getGlobalVariables().getNames()) { - globalVariables.append(runtime.newString(globalVariableName)); - } - - return globalVariables; - } - - /** Returns an Array with the names of all local variables. - * - */ - @JRubyMethod(name = "local_variables", module = true, visibility = PRIVATE) - public static RubyArray local_variables(ThreadContext context, IRubyObject recv) { - final Ruby runtime = context.getRuntime(); - RubyArray localVariables = runtime.newArray(); - - for (String name: context.getCurrentScope().getAllNamesInScope()) { - if (IdUtil.isLocal(name)) localVariables.append(runtime.newString(name)); - } - - return localVariables; - } - - @JRubyMethod(name = "binding", frame = true, module = true, visibility = PRIVATE) - public static RubyBinding binding(ThreadContext context, IRubyObject recv, Block block) { - return RubyBinding.newBinding(context.getRuntime()); - } - - @JRubyMethod(name = {"block_given?", "iterator?"}, frame = true, module = true, visibility = PRIVATE) - public static RubyBoolean block_given_p(ThreadContext context, IRubyObject recv, Block block) { - return context.getRuntime().newBoolean(context.getPreviousFrame().getBlock().isGiven()); - } - - - @Deprecated - public static IRubyObject sprintf(IRubyObject recv, IRubyObject[] args) { - return sprintf(recv.getRuntime().getCurrentContext(), recv, args); - } - - @JRubyMethod(name = {"sprintf", "format"}, required = 1, rest = true, module = true, visibility = PRIVATE) - public static IRubyObject sprintf(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - if (args.length == 0) { - throw context.getRuntime().newArgumentError("sprintf must have at least one argument"); - } - - RubyString str = RubyString.stringValue(args[0]); - - RubyArray newArgs = context.getRuntime().newArrayNoCopy(args); - newArgs.shift(); - - return str.op_format(context, newArgs); - } - - @JRubyMethod(name = {"raise", "fail"}, optional = 3, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - // FIXME: Pass block down? - Ruby runtime = context.getRuntime(); - - if (args.length == 0) { - IRubyObject lastException = runtime.getGlobalVariables().get("$!"); - if (lastException.isNil()) { - throw new RaiseException(runtime, runtime.getRuntimeError(), "", false); - } - throw new RaiseException((RubyException) lastException); - } - - IRubyObject exception; - - if (args.length == 1) { - if (args[0] instanceof RubyString) { - throw new RaiseException((RubyException)runtime.getRuntimeError().newInstance(context, args, block)); - } - - if (!args[0].respondsTo("exception")) { - throw runtime.newTypeError("exception class/object expected"); - } - exception = args[0].callMethod(context, "exception"); - } else { - if (!args[0].respondsTo("exception")) { - throw runtime.newTypeError("exception class/object expected"); - } - - exception = args[0].callMethod(context, "exception", args[1]); - } - - if (!runtime.fastGetClass("Exception").isInstance(exception)) { - throw runtime.newTypeError("exception object expected"); - } - - if (args.length == 3) { - ((RubyException) exception).set_backtrace(args[2]); - } - - if (runtime.getDebug().isTrue()) { - printExceptionSummary(context, runtime, (RubyException) exception); - } - - throw new RaiseException((RubyException) exception); - } - - private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) { - Frame currentFrame = context.getCurrentFrame(); - - String msg = String.format("Exception `%s' at %s:%s - %s\n", - rEx.getMetaClass(), - currentFrame.getFile(), currentFrame.getLine() + 1, - rEx.to_s()); - - IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr"); - errorStream.callMethod(context, "write", runtime.newString(msg)); - } - - /** - * Require. - * MRI allows to require ever .rb files or ruby extension dll (.so or .dll depending on system). - * we allow requiring either .rb files or jars. - * @param recv ruby object used to call require (any object will do and it won't be used anyway). - * @param name the name of the file to require - **/ - @JRubyMethod(name = "require", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject require(IRubyObject recv, IRubyObject name, Block block) { - Ruby runtime = recv.getRuntime(); - - if (runtime.getLoadService().require(name.convertToString().toString())) { - return runtime.getTrue(); - } - return runtime.getFalse(); - } - - @JRubyMethod(name = "load", required = 1, optional = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject load(IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = recv.getRuntime(); - RubyString file = args[0].convertToString(); - boolean wrap = args.length == 2 ? args[1].isTrue() : false; - - runtime.getLoadService().load(file.getByteList().toString(), wrap); - - return runtime.getTrue(); - } - - @JRubyMethod(name = "eval", required = 1, optional = 3, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject eval(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - - // string to eval - RubyString src = args[0].convertToString(); - runtime.checkSafeString(src); - - IRubyObject scope = args.length > 1 && !args[1].isNil() ? args[1] : null; - String file; - if (args.length > 2) { - file = args[2].convertToString().toString(); - } else if (scope == null) { - file = "(eval)"; - } else { - file = null; - } - int line; - if (args.length > 3) { - line = (int) args[3].convertToInteger().getLongValue(); - } else if (scope == null) { - line = 0; - } else { - line = -1; - } - if (scope == null) scope = RubyBinding.newBindingForEval(context); - - return ASTInterpreter.evalWithBinding(context, src, scope, file, line); - } - - @JRubyMethod(name = "callcc", frame = true, module = true, visibility = PRIVATE) - public static IRubyObject callcc(ThreadContext context, IRubyObject recv, Block block) { - Ruby runtime = context.getRuntime(); - runtime.getWarnings().warn(ID.EMPTY_IMPLEMENTATION, "Kernel#callcc: Continuations are not implemented in JRuby and will not work", "Kernel#callcc"); - IRubyObject cc = runtime.getContinuation().callMethod(context, "new"); - cc.dataWrapStruct(block); - return block.yield(context, cc); - } - - @JRubyMethod(name = "caller", optional = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject caller(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - int level = args.length > 0 ? RubyNumeric.fix2int(args[0]) : 1; - - if (level < 0) { - throw context.getRuntime().newArgumentError("negative level(" + level + ')'); - } - - return context.createCallerBacktrace(context.getRuntime(), level); - } - - @JRubyMethod(name = "catch", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject rbCatch(ThreadContext context, IRubyObject recv, IRubyObject tag, Block block) { - CatchTarget target = new CatchTarget(tag.asJavaString()); - try { - context.pushCatch(target); - return block.yield(context, tag); - } catch (JumpException.ThrowJump tj) { - if (tj.getTarget() == target) return (IRubyObject) tj.getValue(); - - throw tj; - } finally { - context.popCatch(); - } - } - - public static class CatchTarget implements JumpTarget { - private final String tag; - public CatchTarget(String tag) { this.tag = tag; } - public String getTag() { return tag; } - } - - @JRubyMethod(name = "throw", required = 1, frame = true, optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject rbThrow(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = context.getRuntime(); - - String tag = args[0].asJavaString(); - CatchTarget[] catches = context.getActiveCatches(); - - String message = "uncaught throw `" + tag + "'"; - - // Ordering of array traversal not important, just intuitive - for (int i = catches.length - 1 ; i >= 0 ; i--) { - if (tag.equals(catches[i].getTag())) { - //Catch active, throw for catch to handle - throw new JumpException.ThrowJump(catches[i], args.length > 1 ? args[1] : runtime.getNil()); - } - } - - // No catch active for this throw - RubyThread currentThread = context.getThread(); - if (currentThread == runtime.getThreadService().getMainThread()) { - throw runtime.newNameError(message, tag); - } else { - throw runtime.newThreadError(message + " in thread 0x" + Integer.toHexString(RubyInteger.fix2int(currentThread.id()))); - } - } - - @JRubyMethod(name = "trap", required = 1, frame = true, optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject trap(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - context.getRuntime().getLoadService().require("jsignal"); - return RuntimeHelpers.invoke(context, recv, "__jtrap", args, block); - } - - @JRubyMethod(name = "warn", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) { - Ruby runtime = context.getRuntime(); - - if (!runtime.getVerbose().isNil()) { - IRubyObject out = runtime.getGlobalVariables().get("$stderr"); - RuntimeHelpers.invoke(context, out, "puts", message); - } - return runtime.getNil(); - } - - @JRubyMethod(name = "set_trace_func", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject set_trace_func(ThreadContext context, IRubyObject recv, IRubyObject trace_func, Block block) { - if (trace_func.isNil()) { - context.getRuntime().setTraceFunction(null); - } else if (!(trace_func instanceof RubyProc)) { - throw context.getRuntime().newTypeError("trace_func needs to be Proc."); - } else { - context.getRuntime().setTraceFunction((RubyProc) trace_func); - } - return trace_func; - } - - @JRubyMethod(name = "trace_var", required = 1, optional = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject trace_var(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - if (args.length == 0) throw context.getRuntime().newArgumentError(0, 1); - RubyProc proc = null; - String var = args.length > 1 ? args[0].toString() : null; - // ignore if it's not a global var - if (var.charAt(0) != '$') return context.getRuntime().getNil(); - if (args.length == 1) proc = RubyProc.newProc(context.getRuntime(), block, Block.Type.PROC); - if (args.length == 2) { - proc = (RubyProc)TypeConverter.convertToType(args[1], context.getRuntime().getProc(), 0, "to_proc", true); - } - - context.getRuntime().getGlobalVariables().setTraceVar(var, proc); - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "untrace_var", required = 1, optional = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject untrace_var(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - if (args.length == 0) throw context.getRuntime().newArgumentError(0, 1); - String var = args.length >= 1 ? args[0].toString() : null; - - // ignore if it's not a global var - if (var.charAt(0) != '$') return context.getRuntime().getNil(); - - if (args.length > 1) { - ArrayList<IRubyObject> success = new ArrayList<IRubyObject>(); - for (int i = 1; i < args.length; i++) { - if (context.getRuntime().getGlobalVariables().untraceVar(var, args[i])) { - success.add(args[i]); - } - } - return RubyArray.newArray(context.getRuntime(), success); - } else { - context.getRuntime().getGlobalVariables().untraceVar(var); - } - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "singleton_method_added", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject singleton_method_added(ThreadContext context, IRubyObject recv, IRubyObject symbolId, Block block) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "singleton_method_removed", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject singleton_method_removed(ThreadContext context, IRubyObject recv, IRubyObject symbolId, Block block) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "singleton_method_undefined", required = 1, frame = true, module = true, visibility = PRIVATE) - public static IRubyObject singleton_method_undefined(ThreadContext context, IRubyObject recv, IRubyObject symbolId, Block block) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = {"proc", "lambda"}, frame = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_8) - public static RubyProc proc(ThreadContext context, IRubyObject recv, Block block) { - return context.getRuntime().newProc(Block.Type.LAMBDA, block); - } - - @Deprecated - public static RubyProc proc(IRubyObject recv, Block block) { - return recv.getRuntime().newProc(Block.Type.LAMBDA, block); - } - - @JRubyMethod(name = {"lambda"}, frame = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static RubyProc lambda(ThreadContext context, IRubyObject recv, Block block) { - return context.getRuntime().newProc(Block.Type.LAMBDA, block); - } - - @JRubyMethod(name = {"proc"}, frame = true, module = true, visibility = PRIVATE, compat = CompatVersion.RUBY1_9) - public static RubyProc proc_1_9(ThreadContext context, IRubyObject recv, Block block) { - return context.getRuntime().newProc(Block.Type.PROC, block); - } - - @JRubyMethod(name = "loop", frame = true, module = true, visibility = PRIVATE) - public static IRubyObject loop(ThreadContext context, IRubyObject recv, Block block) { - while (true) { - block.yield(context, context.getRuntime().getNil()); - - context.pollThreadEvents(); - } - } - - @JRubyMethod(name = "test", required = 2, optional = 1, module = true, visibility = PRIVATE) - public static IRubyObject test(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - if (args.length == 0) throw context.getRuntime().newArgumentError("wrong number of arguments"); - - int cmd; - if (args[0] instanceof RubyFixnum) { - cmd = (int)((RubyFixnum) args[0]).getLongValue(); - } else if (args[0] instanceof RubyString && - ((RubyString) args[0]).getByteList().length() > 0) { - // MRI behavior: use first byte of string value if len > 0 - cmd = ((RubyString) args[0]).getByteList().charAt(0); - } else { - cmd = (int) args[0].convertToInteger().getLongValue(); - } - - // MRI behavior: raise ArgumentError for 'unknown command' before - // checking number of args. - switch(cmd) { - case 'A': case 'b': case 'c': case 'C': case 'd': case 'e': case 'f': case 'g': case 'G': - case 'k': case 'M': case 'l': case 'o': case 'O': case 'p': case 'r': case 'R': case 's': - case 'S': case 'u': case 'w': case 'W': case 'x': case 'X': case 'z': case '=': case '<': - case '>': case '-': - break; - default: - throw context.getRuntime().newArgumentError("unknown command ?" + (char) cmd); - } - - // MRI behavior: now check arg count - - switch(cmd) { - case '-': case '=': case '<': case '>': - if (args.length != 3) throw context.getRuntime().newArgumentError(args.length, 3); - break; - default: - if (args.length != 2) throw context.getRuntime().newArgumentError(args.length, 2); - break; - } - - switch (cmd) { - case 'A': // ?A | Time | Last access time for file1 - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).atime(); - case 'b': // ?b | boolean | True if file1 is a block device - return RubyFileTest.blockdev_p(recv, args[1]); - case 'c': // ?c | boolean | True if file1 is a character device - return RubyFileTest.chardev_p(recv, args[1]); - case 'C': // ?C | Time | Last change time for file1 - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).ctime(); - case 'd': // ?d | boolean | True if file1 exists and is a directory - return RubyFileTest.directory_p(recv, args[1]); - case 'e': // ?e | boolean | True if file1 exists - return RubyFileTest.exist_p(recv, args[1]); - case 'f': // ?f | boolean | True if file1 exists and is a regular file - return RubyFileTest.file_p(recv, args[1]); - case 'g': // ?g | boolean | True if file1 has the \CF{setgid} bit - return RubyFileTest.setgid_p(recv, args[1]); - case 'G': // ?G | boolean | True if file1 exists and has a group ownership equal to the caller's group - return RubyFileTest.grpowned_p(recv, args[1]); - case 'k': // ?k | boolean | True if file1 exists and has the sticky bit set - return RubyFileTest.sticky_p(recv, args[1]); - case 'M': // ?M | Time | Last modification time for file1 - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).mtime(); - case 'l': // ?l | boolean | True if file1 exists and is a symbolic link - return RubyFileTest.symlink_p(recv, args[1]); - case 'o': // ?o | boolean | True if file1 exists and is owned by the caller's effective uid - return RubyFileTest.owned_p(recv, args[1]); - case 'O': // ?O | boolean | True if file1 exists and is owned by the caller's real uid - return RubyFileTest.rowned_p(recv, args[1]); - case 'p': // ?p | boolean | True if file1 exists and is a fifo - return RubyFileTest.pipe_p(recv, args[1]); - case 'r': // ?r | boolean | True if file1 is readable by the effective uid/gid of the caller - return RubyFileTest.readable_p(recv, args[1]); - case 'R': // ?R | boolean | True if file is readable by the real uid/gid of the caller - // FIXME: Need to implement an readable_real_p in FileTest - return RubyFileTest.readable_p(recv, args[1]); - case 's': // ?s | int/nil | If file1 has nonzero size, return the size, otherwise nil - return RubyFileTest.size_p(recv, args[1]); - case 'S': // ?S | boolean | True if file1 exists and is a socket - return RubyFileTest.socket_p(recv, args[1]); - case 'u': // ?u | boolean | True if file1 has the setuid bit set - return RubyFileTest.setuid_p(recv, args[1]); - case 'w': // ?w | boolean | True if file1 exists and is writable by effective uid/gid - return RubyFileTest.writable_p(recv, args[1]); - case 'W': // ?W | boolean | True if file1 exists and is writable by the real uid/gid - // FIXME: Need to implement an writable_real_p in FileTest - return RubyFileTest.writable_p(recv, args[1]); - case 'x': // ?x | boolean | True if file1 exists and is executable by the effective uid/gid - return RubyFileTest.executable_p(recv, args[1]); - case 'X': // ?X | boolean | True if file1 exists and is executable by the real uid/gid - return RubyFileTest.executable_real_p(recv, args[1]); - case 'z': // ?z | boolean | True if file1 exists and has a zero length - return RubyFileTest.zero_p(recv, args[1]); - case '=': // ?= | boolean | True if the modification times of file1 and file2 are equal - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).mtimeEquals(args[2]); - case '<': // ?< | boolean | True if the modification time of file1 is prior to that of file2 - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).mtimeLessThan(args[2]); - case '>': // ?> | boolean | True if the modification time of file1 is after that of file2 - return context.getRuntime().newFileStat(args[1].convertToString().toString(), false).mtimeGreaterThan(args[2]); - case '-': // ?- | boolean | True if file1 and file2 are identical - return RubyFileTest.identical_p(recv, args[1], args[2]); - default: - throw new InternalError("unreachable code reached!"); - } - } - - @JRubyMethod(name = "`", required = 1, module = true, visibility = PRIVATE) - public static IRubyObject backquote(ThreadContext context, IRubyObject recv, IRubyObject aString) { - Ruby runtime = context.getRuntime(); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - - RubyString string = aString.convertToString(); - int resultCode = ShellLauncher.runAndWait(runtime, new IRubyObject[] {string}, output); - - runtime.getGlobalVariables().set("$?", RubyProcess.RubyStatus.newProcessStatus(runtime, resultCode)); - - return RubyString.newString(runtime, output.toByteArray()); - } - - @JRubyMethod(name = "srand", optional = 1, module = true, visibility = PRIVATE) - public static RubyInteger srand(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - long oldRandomSeed = runtime.getRandomSeed(); - - if (args.length > 0) { - RubyInteger integerSeed = args[0].convertToInteger(MethodIndex.TO_INT, "to_int"); - runtime.setRandomSeed(integerSeed.getLongValue()); - } else { - // Not sure how well this works, but it works much better than - // just currentTimeMillis by itself. - runtime.setRandomSeed(System.currentTimeMillis() ^ - recv.hashCode() ^ runtime.incrementRandomSeedSequence() ^ - runtime.getRandom().nextInt(Math.max(1, Math.abs((int)runtime.getRandomSeed())))); - } - runtime.getRandom().setSeed(runtime.getRandomSeed()); - return runtime.newFixnum(oldRandomSeed); - } - - @JRubyMethod(name = "rand", optional = 1, module = true, visibility = PRIVATE) - public static RubyNumeric rand(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - long ceil; - if (args.length == 0) { - ceil = 0; - } else if (args.length == 1) { - if (args[0] instanceof RubyBignum) { - byte[] bigCeilBytes = ((RubyBignum) args[0]).getValue().toByteArray(); - BigInteger bigCeil = new BigInteger(bigCeilBytes).abs(); - - byte[] randBytes = new byte[bigCeilBytes.length]; - runtime.getRandom().nextBytes(randBytes); - - BigInteger result = new BigInteger(randBytes).abs().mod(bigCeil); - - return new RubyBignum(runtime, result); - } - - RubyInteger integerCeil = (RubyInteger)RubyKernel.new_integer(context, recv, args[0]); - ceil = Math.abs(integerCeil.getLongValue()); - } else { - throw runtime.newArgumentError("wrong # of arguments(" + args.length + " for 1)"); - } - - if (ceil == 0) { - return RubyFloat.newFloat(runtime, runtime.getRandom().nextDouble()); - } - if (ceil > Integer.MAX_VALUE) { - return runtime.newFixnum(Math.abs(runtime.getRandom().nextLong()) % ceil); - } - - return runtime.newFixnum(runtime.getRandom().nextInt((int) ceil)); - } - - @JRubyMethod(name = "syscall", required = 1, optional = 9, module = true, visibility = PRIVATE) - public static IRubyObject syscall(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - throw context.getRuntime().newNotImplementedError("Kernel#syscall is not implemented in JRuby"); - } - - @JRubyMethod(name = {"system"}, required = 1, rest = true, module = true, visibility = PRIVATE) - public static RubyBoolean system(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - int resultCode; - try { - resultCode = ShellLauncher.runAndWait(runtime, args); - } catch (Exception e) { - resultCode = 127; - } - runtime.getGlobalVariables().set("$?", RubyProcess.RubyStatus.newProcessStatus(runtime, resultCode)); - return runtime.newBoolean(resultCode == 0); - } - - @JRubyMethod(name = {"exec"}, required = 1, rest = true, module = true, visibility = PRIVATE) - public static IRubyObject exec(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - int resultCode; - try { - // TODO: exec should replace the current process. - // This could be possible with JNA. - resultCode = ShellLauncher.execAndWait(runtime, args); - } catch (Exception e) { - throw runtime.newErrnoENOENTError("cannot execute"); - } - - return exit(recv, new IRubyObject[] {runtime.newFixnum(resultCode)}); - } - - @JRubyMethod(name = "fork", module = true, visibility = PRIVATE) - public static IRubyObject fork(ThreadContext context, IRubyObject recv, Block block) { - Ruby runtime = context.getRuntime(); - - if (!RubyInstanceConfig.FORK_ENABLED) { - throw runtime.newNotImplementedError("fork is unsafe and disabled by default on JRuby"); - } - - if (block.isGiven()) { - int pid = runtime.getPosix().fork(); - - if (pid == 0) { - try { - block.yield(context, runtime.getNil()); - } catch (RaiseException re) { - if (re.getException() instanceof RubySystemExit) { - throw re; - } - return exit_bang(recv, new IRubyObject[] {RubyFixnum.minus_one(runtime)}); - } catch (Throwable t) { - return exit_bang(recv, new IRubyObject[] {RubyFixnum.minus_one(runtime)}); - } - return exit_bang(recv, new IRubyObject[] {RubyFixnum.zero(runtime)}); - } else { - return runtime.newFixnum(pid); - } - } else { - int result = runtime.getPosix().fork(); - - if (result == -1) { - return runtime.getNil(); - } - - return runtime.newFixnum(result); - } - } - - @JRubyMethod(frame = true, module = true) - public static IRubyObject tap(ThreadContext context, IRubyObject recv, Block block) { - block.yield(context, recv); - return recv; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ - -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyClass(name="LocalJumpError",parent="StandardError") -public class RubyLocalJumpError extends RubyException { - private static ObjectAllocator LOCALJUMPERROR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyLocalJumpError(runtime, klass); - } - }; - - public static RubyClass createLocalJumpErrorClass(Ruby runtime, RubyClass standardErrorClass) { - RubyClass nameErrorClass = runtime.defineClass("LocalJumpError", standardErrorClass, LOCALJUMPERROR_ALLOCATOR); - - nameErrorClass.defineAnnotatedMethods(RubyLocalJumpError.class); - - return nameErrorClass; - } - - private RubyLocalJumpError(Ruby runtime, RubyClass exceptionClass) { - super(runtime, exceptionClass); - } - - public RubyLocalJumpError(Ruby runtime, RubyClass exceptionClass, String message, String reason, IRubyObject exitValue) { - super(runtime, exceptionClass, message); - fastSetInternalVariable("reason", runtime.newSymbol(reason)); - fastSetInternalVariable("exit_value", exitValue); - } - - @JRubyMethod(name = "reason") - public IRubyObject reason() { - return fastGetInternalVariable("reason"); - } - - @JRubyMethod(name = "exit_value") - public IRubyObject exit_value() { - return fastGetInternalVariable("exit_value"); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2007 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2003 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; - -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.Constants; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; - -import org.jruby.util.ByteList; -import org.jruby.util.IOInputStream; -import org.jruby.util.IOOutputStream; - -/** - * Marshal module - * - * @author Anders - */ -@JRubyModule(name="Marshal") -public class RubyMarshal { - - public static RubyModule createMarshalModule(Ruby runtime) { - RubyModule module = runtime.defineModule("Marshal"); - runtime.setMarshal(module); - - module.defineAnnotatedMethods(RubyMarshal.class); - module.defineConstant("MAJOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MAJOR)); - module.defineConstant("MINOR_VERSION", runtime.newFixnum(Constants.MARSHAL_MINOR)); - - return module; - } - - @JRubyMethod(name = "dump", required = 1, optional = 2, frame = true, module = true) - public static IRubyObject dump(IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - if (args.length < 1) { - throw recv.getRuntime().newArgumentError("wrong # of arguments(at least 1)"); - } - IRubyObject objectToDump = args[0]; - - IRubyObject io = null; - int depthLimit = -1; - - if (args.length >= 2) { - if (args[1].respondsTo("write")) { - io = args[1]; - } else if (args[1] instanceof RubyFixnum) { - depthLimit = (int) ((RubyFixnum) args[1]).getLongValue(); - } else { - throw recv.getRuntime().newTypeError("Instance of IO needed"); - } - if (args.length == 3) { - depthLimit = (int) ((RubyFixnum) args[2]).getLongValue(); - } - } - - try { - if (io != null) { - dumpToStream(objectToDump, outputStream(io), depthLimit); - return io; - } - ByteArrayOutputStream stringOutput = new ByteArrayOutputStream(); - dumpToStream(objectToDump, stringOutput, depthLimit); - - return RubyString.newString(recv.getRuntime(), new ByteList(stringOutput.toByteArray(),false)); - - } catch (IOException ioe) { - throw recv.getRuntime().newIOErrorFromException(ioe); - } - - } - - private static OutputStream outputStream(IRubyObject out) { - setBinmodeIfPossible(out); - if (out instanceof RubyIO) { - return ((RubyIO) out).getOutStream(); - } - return new IOOutputStream(out); - } - - private static void setBinmodeIfPossible(IRubyObject io) { - if (io.respondsTo("binmode")) { - io.callMethod(io.getRuntime().getCurrentContext(), "binmode"); - } - } - - @JRubyMethod(name = {"load", "restore"}, required = 1, optional = 1, frame = true, module = true) - public static IRubyObject load(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - try { - if (args.length < 1) { - throw recv.getRuntime().newArgumentError("wrong number of arguments (0 for 1)"); - } - - if (args.length > 2) { - throw recv.getRuntime().newArgumentError("wrong number of arguments (" + args.length + " for 2)"); - } - - IRubyObject in = null; - IRubyObject proc = null; - - switch (args.length) { - case 2: - proc = args[1]; - case 1: - in = args[0]; - } - - InputStream rawInput; - if (in != null && in.respondsTo("read")) { - rawInput = inputStream(in); - } else if (in != null && in.respondsTo("to_str")) { - RubyString inString = (RubyString) RuntimeHelpers.invoke(context, in, "to_str"); - ByteList bytes = inString.getByteList(); - rawInput = new ByteArrayInputStream(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - } else { - throw recv.getRuntime().newTypeError("instance of IO needed"); - } - - UnmarshalStream input = new UnmarshalStream(recv.getRuntime(), rawInput, proc); - - return input.unmarshalObject(); - - } catch (EOFException ee) { - throw recv.getRuntime().newEOFError(); - } catch (IOException ioe) { - throw recv.getRuntime().newIOErrorFromException(ioe); - } - } - - private static InputStream inputStream(IRubyObject in) { - setBinmodeIfPossible(in); - if (in instanceof RubyIO) { - return ((RubyIO) in).getInStream(); - } - return new IOInputStream(in); - } - - private static void dumpToStream(IRubyObject object, OutputStream rawOutput, int depthLimit) - throws IOException - { - MarshalStream output = new MarshalStream(object.getRuntime(), rawOutput, depthLimit); - output.dumpObject(object); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.Iterator; - -import org.joni.NameEntry; -import org.joni.Regex; -import org.joni.Region; -import org.joni.exception.JOniException; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; - -/** - * @author olabini - */ -@JRubyClass(name="MatchData") -public class RubyMatchData extends RubyObject { - Region regs; // captures - int begin; // begin and end are used when not groups defined - int end; - RubyString str; - Regex pattern; - - public static RubyClass createMatchDataClass(Ruby runtime) { - // TODO: Is NOT_ALLOCATABLE_ALLOCATOR ok here, since you can't actually instantiate MatchData directly? - RubyClass matchDataClass = runtime.defineClass("MatchData", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setMatchData(matchDataClass); - runtime.defineGlobalConstant("MatchingData", matchDataClass); - matchDataClass.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyMatchData; - } - }; - - matchDataClass.getMetaClass().undefineMethod("new"); - - matchDataClass.defineAnnotatedMethods(RubyMatchData.class); - - return matchDataClass; - } - - public RubyMatchData(Ruby runtime) { - super(runtime, runtime.getMatchData()); - } - - public final static int MATCH_BUSY = USER2_F; - - // rb_match_busy - public final void use() { - flags |= MATCH_BUSY; - } - - public final boolean used() { - return (flags & MATCH_BUSY) != 0; - } - - private RubyArray match_array(Ruby runtime, int start) { - if (regs == null) { - if (start != 0) return runtime.newEmptyArray(); - if (begin == -1) { - return getRuntime().newArray(runtime.getNil()); - } else { - RubyString ss = str.makeShared(runtime, begin, end - begin); - if (isTaint()) ss.setTaint(true); - return getRuntime().newArray(ss); - } - } else { - RubyArray arr = getRuntime().newArray(regs.numRegs - start); - for (int i=start; i<regs.numRegs; i++) { - if (regs.beg[i] == -1) { - arr.append(getRuntime().getNil()); - } else { - RubyString ss = str.makeShared(runtime, regs.beg[i], regs.end[i] - regs.beg[i]); - if (isTaint()) ss.setTaint(true); - arr.append(ss); - } - } - return arr; - } - - } - - public IRubyObject group(long n) { - return RubyRegexp.nth_match((int)n, this); - } - - public IRubyObject group(int n) { - return RubyRegexp.nth_match(n, this); - } - - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - if (pattern == null) return anyToString(); - - RubyString result = getRuntime().newString(); - result.cat((byte)'#').cat((byte)'<'); - result.append(getMetaClass().getRealClass().to_s()); - - NameEntry[]names = new NameEntry[regs == null ? 1 : regs.numRegs]; - - if (pattern.numberOfNames() > 0) { - for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) { - NameEntry e = i.next(); - for (int num : e.getBackRefs()) names[num] = e; - } - } - - for (int i=0; i<names.length; i++) { - result.cat((byte)' '); - if (i > 0) { - NameEntry e = names[i]; - if (e != null) { - result.cat(e.name, e.nameP, e.nameEnd - e.nameP); - } else { - result.cat((byte)('0' + i)); - } - result.cat((byte)':'); - } - IRubyObject v = RubyRegexp.nth_match(i, this); - if (v.isNil()) { - result.cat("nil".getBytes()); - } else { - result.append(v.inspect()); - } - } - - return result.cat((byte)'>'); - } - - /** match_to_a - * - */ - @JRubyMethod(name = "to_a") - @Override - public RubyArray to_a() { - return match_array(getRuntime(), 0); - } - - @JRubyMethod(name = "values_at", required = 1, rest = true) - public IRubyObject values_at(IRubyObject[] args) { - return to_a().values_at(args); - } - - @JRubyMethod(name = "select", frame = true) - public IRubyObject select(ThreadContext context, Block block) { - return block.yield(context, to_a()); - } - - /** match_captures - * - */ - @JRubyMethod(name = "captures") - public IRubyObject captures(ThreadContext context) { - return match_array(context.getRuntime(), 1); - } - - private int nameToBackrefNumber(RubyString str) { - ByteList value = str.getByteList(); - try { - return pattern.nameToBackrefNumber(value.bytes, value.begin, value.begin + value.realSize, regs); - } catch (JOniException je) { - throw getRuntime().newIndexError(je.getMessage()); - } - } - - final int backrefNumber(IRubyObject obj) { - if (obj instanceof RubySymbol) { - return nameToBackrefNumber((RubyString)((RubySymbol)obj).id2name()); - } else if (obj instanceof RubyString) { - return nameToBackrefNumber((RubyString)obj); - } else { - return RubyNumeric.num2int(obj); - } - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public IRubyObject op_aref(IRubyObject[] args) { - switch (args.length) { - case 1: - return op_aref(args[0]); - case 2: - return op_aref(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** match_aref - * - */ - @JRubyMethod(name = "[]") - public IRubyObject op_aref(IRubyObject idx) { - IRubyObject result = op_arefCommon(idx); - return result == null ? ((RubyArray)to_a()).aref(idx) : result; - } - - /** match_aref - * - */ - @JRubyMethod(name = "[]") - public IRubyObject op_aref(IRubyObject idx, IRubyObject rest) { - IRubyObject result; - return !rest.isNil() || (result = op_arefCommon(idx)) == null ? ((RubyArray)to_a()).aref(idx, rest) : result; - } - - private IRubyObject op_arefCommon(IRubyObject idx) { - if (idx instanceof RubyFixnum) { - int num = RubyNumeric.fix2int(idx); - if (num >= 0) return RubyRegexp.nth_match(num, this); - } else { - if (idx instanceof RubySymbol) { - return RubyRegexp.nth_match(nameToBackrefNumber((RubyString)((RubySymbol)idx).id2name()), this); - } else if (idx instanceof RubyString) { - return RubyRegexp.nth_match(nameToBackrefNumber((RubyString)idx), this); - } - } - return null; - } - - /** match_size - * - */ - @JRubyMethod(name = {"size", "length"}) - public IRubyObject size() { - return regs == null ? RubyFixnum.one(getRuntime()) : RubyFixnum.newFixnum(getRuntime(), regs.numRegs); - } - - /** match_begin - * - */ - @JRubyMethod(name = "begin", required = 1) - public IRubyObject begin(IRubyObject index) { - int i = backrefNumber(index); - - if (regs == null) { - if (i != 0) throw getRuntime().newIndexError("index " + i + " out of matches"); - if (begin < 0) return getRuntime().getNil(); - return RubyFixnum.newFixnum(getRuntime(), begin); - } else { - if (i < 0 || regs.numRegs <= i) throw getRuntime().newIndexError("index " + i + " out of matches"); - if (regs.beg[i] < 0) return getRuntime().getNil(); - return RubyFixnum.newFixnum(getRuntime(), regs.beg[i]); - } - } - - /** match_end - * - */ - @JRubyMethod(name = "end", required = 1) - public IRubyObject end(IRubyObject index) { - int i = backrefNumber(index); - - if (regs == null) { - if (i != 0) throw getRuntime().newIndexError("index " + i + " out of matches"); - if (end < 0) return getRuntime().getNil(); - return RubyFixnum.newFixnum(getRuntime(), end); - } else { - if (i < 0 || regs.numRegs <= i) throw getRuntime().newIndexError("index " + i + " out of matches"); - if (regs.end[i] < 0) return getRuntime().getNil(); - return RubyFixnum.newFixnum(getRuntime(), regs.end[i]); - } - } - - /** match_offset - * - */ - @JRubyMethod(name = "offset", required = 1) - public IRubyObject offset(IRubyObject index) { - int i = backrefNumber(index); - Ruby runtime = getRuntime(); - - if (regs == null) { - if (i != 0) throw getRuntime().newIndexError("index " + i + " out of matches"); - if (begin < 0) return runtime.newArray(runtime.getNil(), runtime.getNil()); - return runtime.newArray(RubyFixnum.newFixnum(runtime, begin),RubyFixnum.newFixnum(runtime, end)); - } else { - if (i < 0 || regs.numRegs <= i) throw runtime.newIndexError("index " + i + " out of matches"); - if (regs.beg[i] < 0) return runtime.newArray(runtime.getNil(), runtime.getNil()); - return runtime.newArray(RubyFixnum.newFixnum(runtime, regs.beg[i]),RubyFixnum.newFixnum(runtime, regs.end[i])); - } - } - - /** match_pre_match - * - */ - @JRubyMethod(name = "pre_match") - public IRubyObject pre_match(ThreadContext context) { - RubyString ss; - - if (regs == null) { - if(begin == -1) return context.getRuntime().getNil(); - ss = str.makeShared(context.getRuntime(), 0, begin); - } else { - if(regs.beg[0] == -1) return context.getRuntime().getNil(); - ss = str.makeShared(context.getRuntime(), 0, regs.beg[0]); - } - - if (isTaint()) ss.setTaint(true); - return ss; - } - - /** match_post_match - * - */ - @JRubyMethod(name = "post_match") - public IRubyObject post_match(ThreadContext context) { - RubyString ss; - - if (regs == null) { - if (begin == -1) return context.getRuntime().getNil(); - ss = str.makeShared(context.getRuntime(), end, str.getByteList().length() - end); - } else { - if (regs.beg[0] == -1) return context.getRuntime().getNil(); - ss = str.makeShared(context.getRuntime(), regs.end[0], str.getByteList().length() - regs.end[0]); - } - - if(isTaint()) ss.setTaint(true); - return ss; - } - - /** match_to_s - * - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - IRubyObject ss = RubyRegexp.last_match(this); - if (ss.isNil()) ss = RubyString.newEmptyString(getRuntime()); - if (isTaint()) ss.setTaint(true); - return ss; - } - - /** match_string - * - */ - @JRubyMethod(name = "string") - public IRubyObject string() { - return str; //str is frozen - } - - @JRubyMethod(name = "initialize_copy", required = 1) - public IRubyObject initialize_copy(IRubyObject original) { - if (this == original) return this; - - if (!(getMetaClass() == original.getMetaClass())){ // MRI also does a pointer comparison here - throw getRuntime().newTypeError("wrong argument class"); - } - - RubyMatchData origMatchData = (RubyMatchData)original; - str = origMatchData.str; - regs = origMatchData.regs; - - return this; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyModule(name="Math") -public class RubyMath { - /** Create the Math module and add it to the Ruby runtime. - * - */ - public static RubyModule createMathModule(Ruby runtime) { - RubyModule result = runtime.defineModule("Math"); - runtime.setMath(result); - - result.defineConstant("E", RubyFloat.newFloat(runtime, Math.E)); - result.defineConstant("PI", RubyFloat.newFloat(runtime, Math.PI)); - - result.defineAnnotatedMethods(RubyMath.class); - - return result; - } - - - private static void domainCheck(IRubyObject recv, double value, String msg) { - if (Double.isNaN(value)) { - throw recv.getRuntime().newErrnoEDOMError(msg); - } - } - - private static double chebylevSerie(double x, double coef[]) { - double b0, b1, b2, twox; - int i; - b1 = 0.0; - b0 = 0.0; - b2 = 0.0; - twox = 2.0 * x; - for (i = coef.length-1; i >= 0; i--) { - b2 = b1; - b1 = b0; - b0 = twox * b1 - b2 + coef[i]; - } - return 0.5*(b0 - b2); - } - - private static double sign(double x, double y) { - double abs = ((x < 0) ? -x : x); - return (y < 0.0) ? -abs : abs; - } - - @JRubyMethod(name = "atan2", required = 2, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat atan2(IRubyObject recv, IRubyObject x, IRubyObject y) { - double valuea = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double valueb = ((RubyFloat)RubyKernel.new_float(recv,y)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(), Math.atan2(valuea, valueb)); - } - - @JRubyMethod(name = "cos", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat cos(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),Math.cos(value)); - } - - @JRubyMethod(name = "sin", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat sin(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),Math.sin(value)); - } - - @JRubyMethod(name = "tan", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat tan(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),Math.tan(value)); - } - - @JRubyMethod(name = "asin", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat asin(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result = Math.asin(value); - domainCheck(recv, result, "asin"); - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - @JRubyMethod(name = "acos", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat acos(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result = Math.acos(value); - domainCheck(recv, result, "acos"); - return RubyFloat.newFloat(recv.getRuntime(), result); - } - - @JRubyMethod(name = "atan", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat atan(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),Math.atan(value)); - } - - @JRubyMethod(name = "cosh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat cosh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),(Math.exp(value) + Math.exp(-value)) / 2.0); - } - - @JRubyMethod(name = "sinh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat sinh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),(Math.exp(value) - Math.exp(-value)) / 2.0); - } - - @JRubyMethod(name = "tanh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat tanh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(), Math.tanh(value)); - } - - @JRubyMethod(name = "acosh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat acosh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result; - if (Double.isNaN(value) || value < 1) { - result = Double.NaN; - } else if (value < 94906265.62) { - result = Math.log(value + Math.sqrt(value * value - 1.0)); - } else{ - result = 0.69314718055994530941723212145818 + Math.log(value); - } - - domainCheck(recv, result, "acosh"); - - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - private static final double ASINH_COEF[] = { - -.12820039911738186343372127359268e+0, - -.58811761189951767565211757138362e-1, - .47274654322124815640725249756029e-2, - -.49383631626536172101360174790273e-3, - .58506207058557412287494835259321e-4, - -.74669983289313681354755069217188e-5, - .10011693583558199265966192015812e-5, - -.13903543858708333608616472258886e-6, - .19823169483172793547317360237148e-7, - -.28847468417848843612747272800317e-8, - .42672965467159937953457514995907e-9, - -.63976084654366357868752632309681e-10, - .96991686089064704147878293131179e-11, - -.14844276972043770830246658365696e-11, - .22903737939027447988040184378983e-12, - -.35588395132732645159978942651310e-13, - .55639694080056789953374539088554e-14, - -.87462509599624678045666593520162e-15, - .13815248844526692155868802298129e-15, - -.21916688282900363984955142264149e-16, - .34904658524827565638313923706880e-17 - }; - - @JRubyMethod(name = "asinh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat asinh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double y = Math.abs(value); - double result; - - if (Double.isNaN(value)) { - result = Double.NaN; - } else if (y <= 1.05367e-08) { - result = value; - } else if (y <= 1.0) { - result = value * (1.0 + chebylevSerie(2.0 * value * value - 1.0, ASINH_COEF)); - } else if (y < 94906265.62) { - result = Math.log(value + Math.sqrt(value * value + 1.0)); - } else { - result = 0.69314718055994530941723212145818 + Math.log(y); - if (value < 0) result *= -1; - } - - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - private static final double ATANH_COEF[] = { - .9439510239319549230842892218633e-1, - .4919843705578615947200034576668e-1, - .2102593522455432763479327331752e-2, - .1073554449776116584640731045276e-3, - .5978267249293031478642787517872e-5, - .3505062030889134845966834886200e-6, - .2126374343765340350896219314431e-7, - .1321694535715527192129801723055e-8, - .8365875501178070364623604052959e-10, - .5370503749311002163881434587772e-11, - .3486659470157107922971245784290e-12, - .2284549509603433015524024119722e-13, - .1508407105944793044874229067558e-14, - .1002418816804109126136995722837e-15, - .6698674738165069539715526882986e-17, - .4497954546494931083083327624533e-18 - }; - - @JRubyMethod(name = "atanh", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat atanh(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double y = Math.abs(value); - double result; - - if (Double.isNaN(value)) { - result = Double.NaN; - } else if (y < 1.82501e-08) { - result = value; - } else if (y <= 0.5) { - result = value * (1.0 + chebylevSerie(8.0 * value * value - 1.0, ATANH_COEF)); - } else if (y < 1.0) { - result = 0.5 * Math.log((1.0 + value) / (1.0 - value)); - } else if (y == 1.0) { - result = value * Double.POSITIVE_INFINITY; - } else { - result = Double.NaN; - } - - domainCheck(recv, result, "atanh"); - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - @JRubyMethod(name = "exp", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat exp(IRubyObject recv, IRubyObject exponent) { - double value = ((RubyFloat)RubyKernel.new_float(recv,exponent)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),Math.exp(value)); - } - - /** Returns the natural logarithm of x. - * - */ - @JRubyMethod(name = "log", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat log(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result = Math.log(value); - domainCheck(recv, result, "log"); - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - /** Returns the base 10 logarithm of x. - * - */ - @JRubyMethod(name = "log10", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat log10(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result = Math.log(value) / Math.log(10); - domainCheck(recv, result, "log10"); - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - @JRubyMethod(name = "sqrt", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat sqrt(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result; - - if (value < 0) { - result = Double.NaN; - } else{ - result = Math.sqrt(value); - } - - domainCheck(recv, result, "sqrt"); - return RubyFloat.newFloat(recv.getRuntime(), result); - } - - @JRubyMethod(name = "hypot", required = 2, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat hypot(IRubyObject recv, IRubyObject x, IRubyObject y) { - double valuea = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double valueb = ((RubyFloat)RubyKernel.new_float(recv,y)).getDoubleValue(); - double result; - - if (Math.abs(valuea) > Math.abs(valueb)) { - result = valueb / valuea; - result = Math.abs(valuea) * Math.sqrt(1 + result * result); - } else if (valueb != 0) { - result = valuea / valueb; - result = Math.abs(valueb) * Math.sqrt(1 + result * result); - } else { - result = 0; - } - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - - /* - * x = mantissa * 2 ** exponent - * - * Where mantissa is in the range of [.5, 1) - * - */ - @JRubyMethod(name = "frexp", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyArray frexp(IRubyObject recv, IRubyObject other) { - double mantissa = ((RubyFloat)RubyKernel.new_float(recv,other)).getDoubleValue(); - short sign = 1; - long exponent = 0; - - if (mantissa != 0.0) { - // Make mantissa same sign so we only have one code path. - if (mantissa < 0) { - mantissa = -mantissa; - sign = -1; - } - - // Increase value to hit lower range. - for (; mantissa < 0.5; mantissa *= 2.0, exponent -=1) { } - - // Decrease value to hit upper range. - for (; mantissa >= 1.0; mantissa *= 0.5, exponent +=1) { } - } - - return RubyArray.newArray(recv.getRuntime(), - RubyFloat.newFloat(recv.getRuntime(), sign * mantissa), - RubyNumeric.int2fix(recv.getRuntime(), exponent)); - } - - /* - * r = x * 2 ** y - */ - @JRubyMethod(name = "ldexp", required = 2, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat ldexp(IRubyObject recv, IRubyObject mantissa, IRubyObject exponent) { - double mantissaValue = ((RubyFloat)RubyKernel.new_float(recv, mantissa)).getDoubleValue(); - return RubyFloat.newFloat(recv.getRuntime(),mantissaValue * Math.pow(2.0, RubyNumeric.num2int(exponent))); - } - - private static final double ERFC_COEF[] = { - -.490461212346918080399845440334e-1, - -.142261205103713642378247418996e0, - .100355821875997955757546767129e-1, - -.576876469976748476508270255092e-3, - .274199312521960610344221607915e-4, - -.110431755073445076041353812959e-5, - .384887554203450369499613114982e-7, - -.118085825338754669696317518016e-8, - .323342158260509096464029309534e-10, - -.799101594700454875816073747086e-12, - .179907251139614556119672454866e-13, - -.371863548781869263823168282095e-15, - .710359900371425297116899083947e-17, - -.126124551191552258324954248533e-18 - }; - - @JRubyMethod(name = "erf", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat erf(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - - double result; - double y = Math.abs(value); - - if (y <= 1.49012e-08) { - result = 2 * value / 1.77245385090551602729816748334; - } else if (y <= 1) { - result = value * (1 + chebylevSerie(2 * value * value - 1, ERFC_COEF)); - } else if (y < 6.013687357) { - result = sign(1 - erfc(recv, RubyFloat.newFloat(recv.getRuntime(),y)).getDoubleValue(), value); - } else { - result = sign(1, value); - } - return RubyFloat.newFloat(recv.getRuntime(),result); - } - - private static final double ERFC2_COEF[] = { - -.69601346602309501127391508262e-1, - -.411013393626208934898221208467e-1, - .391449586668962688156114370524e-2, - -.490639565054897916128093545077e-3, - .715747900137703638076089414183e-4, - -.115307163413123283380823284791e-4, - .199467059020199763505231486771e-5, - -.364266647159922287393611843071e-6, - .694437261000501258993127721463e-7, - -.137122090210436601953460514121e-7, - .278838966100713713196386034809e-8, - -.581416472433116155186479105032e-9, - .123892049175275318118016881795e-9, - -.269063914530674343239042493789e-10, - .594261435084791098244470968384e-11, - -.133238673575811957928775442057e-11, - .30280468061771320171736972433e-12, - -.696664881494103258879586758895e-13, - .162085454105392296981289322763e-13, - -.380993446525049199987691305773e-14, - .904048781597883114936897101298e-15, - -.2164006195089607347809812047e-15, - .522210223399585498460798024417e-16, - -.126972960236455533637241552778e-16, - .310914550427619758383622741295e-17, - -.766376292032038552400956671481e-18, - .190081925136274520253692973329e-18 - }; - - private static final double ERFCC_COEF[] = { - .715179310202924774503697709496e-1, - -.265324343376067157558893386681e-1, - .171115397792085588332699194606e-2, - -.163751663458517884163746404749e-3, - .198712935005520364995974806758e-4, - -.284371241276655508750175183152e-5, - .460616130896313036969379968464e-6, - -.822775302587920842057766536366e-7, - .159214187277090112989358340826e-7, - -.329507136225284321486631665072e-8, - .72234397604005554658126115389e-9, - -.166485581339872959344695966886e-9, - .401039258823766482077671768814e-10, - -.100481621442573113272170176283e-10, - .260827591330033380859341009439e-11, - -.699111056040402486557697812476e-12, - .192949233326170708624205749803e-12, - -.547013118875433106490125085271e-13, - .158966330976269744839084032762e-13, - -.47268939801975548392036958429e-14, - .14358733767849847867287399784e-14, - -.444951056181735839417250062829e-15, - .140481088476823343737305537466e-15, - -.451381838776421089625963281623e-16, - .147452154104513307787018713262e-16, - -.489262140694577615436841552532e-17, - .164761214141064673895301522827e-17, - -.562681717632940809299928521323e-18, - .194744338223207851429197867821e-18 - }; - - @JRubyMethod(name = "erfc", required = 1, module = true, visibility = Visibility.PRIVATE) - public static RubyFloat erfc(IRubyObject recv, IRubyObject x) { - double value = ((RubyFloat)RubyKernel.new_float(recv,x)).getDoubleValue(); - double result; - double y = Math.abs(value); - - if (value <= -6.013687357) { - result = 2; - } else if (y < 1.49012e-08) { - result = 1 - 2 * value / 1.77245385090551602729816748334; - } else { - double ysq = y*y; - if (y < 1) { - result = 1 - value * (1 + chebylevSerie(2 * ysq - 1, ERFC_COEF)); - } else if (y <= 4.0) { - result = Math.exp(-ysq)/y*(0.5+chebylevSerie((8.0 / ysq - 5.0) / 3.0, ERFC2_COEF)); - if (value < 0) result = 2.0 - result; - if (value < 0) result = 2.0 - result; - if (value < 0) result = 2.0 - result; - } else { - result = Math.exp(-ysq) / y * (0.5 + chebylevSerie(8.0 / ysq - 1, ERFCC_COEF)); - if (value < 0) result = 2.0 - result; - } - } - return RubyFloat.newFloat(recv.getRuntime(),result); - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.exceptions.JumpException; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallbackFactory; -import org.jruby.runtime.MethodBlock; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * The RubyMethod class represents a RubyMethod object. - * - * You can get such a method by calling the "method" method of an object. - * - * Note: This was renamed from Method.java - * - * @author jpetersen - * @since 0.2.3 - */ -@JRubyClass(name="Method") -public class RubyMethod extends RubyObject { - protected RubyModule implementationModule; - protected String methodName; - protected RubyModule originModule; - protected String originName; - protected DynamicMethod method; - protected IRubyObject receiver; - - protected RubyMethod(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass); - } - - /** Create the RubyMethod class and add it to the Ruby runtime. - * - */ - public static RubyClass createMethodClass(Ruby runtime) { - // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415 - RubyClass methodClass = runtime.defineClass("Method", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setMethod(methodClass); - - methodClass.defineAnnotatedMethods(RubyMethod.class); - - return methodClass; - } - - public static RubyMethod newMethod( - RubyModule implementationModule, - String methodName, - RubyModule originModule, - String originName, - DynamicMethod method, - IRubyObject receiver) { - Ruby runtime = implementationModule.getRuntime(); - RubyMethod newMethod = new RubyMethod(runtime, runtime.getMethod()); - - newMethod.implementationModule = implementationModule; - newMethod.methodName = methodName; - newMethod.originModule = originModule; - newMethod.originName = originName; - newMethod.method = method.getRealMethod(); - newMethod.receiver = receiver; - - return newMethod; - } - - /** Call the method. - * - */ - @JRubyMethod(name = {"call", "[]"}) - public IRubyObject call(ThreadContext context, Block block) { - return method.call(context, receiver, implementationModule, methodName, block); - } - @JRubyMethod(name = {"call", "[]"}) - public IRubyObject call(ThreadContext context, IRubyObject arg, Block block) { - return method.call(context, receiver, implementationModule, methodName, arg, block); - } - @JRubyMethod(name = {"call", "[]"}) - public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - return method.call(context, receiver, implementationModule, methodName, arg0, arg1, block); - } - @JRubyMethod(name = {"call", "[]"}) - public IRubyObject call(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - return method.call(context, receiver, implementationModule, methodName, arg0, arg1, arg2, block); - } - @JRubyMethod(name = {"call", "[]"}, rest = true) - public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) { - return method.call(context, receiver, implementationModule, methodName, args, block); - } - - /** Returns the number of arguments a method accepted. - * - * @return the number of arguments of a method. - */ - @JRubyMethod(name = "arity") - public RubyFixnum arity() { - return getRuntime().newFixnum(method.getArity().getValue()); - } - - @JRubyMethod(name = "==", required = 1) - @Override - public RubyBoolean op_equal(ThreadContext context, IRubyObject other) { - if (!(other instanceof RubyMethod)) return context.getRuntime().getFalse(); - RubyMethod otherMethod = (RubyMethod)other; - return context.getRuntime().newBoolean(implementationModule == otherMethod.implementationModule && - originModule == otherMethod.originModule && - receiver == otherMethod.receiver && - method.getRealMethod() == otherMethod.method.getRealMethod()); - } - - @JRubyMethod(name = "clone") - @Override - public RubyMethod rbClone() { - return newMethod(implementationModule, methodName, originModule, originName, method, receiver); - } - - /** Create a Proc object. - * - */ - @JRubyMethod(name = "to_proc", frame = true) - public IRubyObject to_proc(ThreadContext context, Block unusedBlock) { - Ruby runtime = context.getRuntime(); - CallbackFactory f = runtime.callbackFactory(RubyMethod.class); - Block block = MethodBlock.createMethodBlock(context, context.getCurrentScope(), - f.getBlockMethod("bmcall"), this, runtime.getTopSelf()); - - while (true) { - try { - // FIXME: We should not be regenerating this over and over - return mproc(context, block); - } catch (JumpException.BreakJump bj) { - return (IRubyObject) bj.getValue(); - } catch (JumpException.ReturnJump rj) { - return (IRubyObject) rj.getValue(); - } catch (JumpException.RetryJump rj) { - // Execute iterateMethod again. - } - } - } - - /** Create a Proc object which is called like a ruby method. - * - * Used by the RubyMethod#to_proc method. - * - */ - private IRubyObject mproc(ThreadContext context, Block block) { - try { - context.preMproc(); - - return RubyKernel.proc(context, context.getRuntime().getNil(), block); - } finally { - context.postMproc(); - } - } - - /** Delegate a block call to a bound method call. - * - * Used by the RubyMethod#to_proc method. - * - */ - public static IRubyObject bmcall(IRubyObject blockArg, IRubyObject arg1, - IRubyObject self, Block unusedBlock) { - ThreadContext context = blockArg.getRuntime().getCurrentContext(); - - if (blockArg instanceof RubyArray) { - // ENEBO: Very wrong - return ((RubyMethod) arg1).call(context, ((RubyArray) blockArg).toJavaArray(), Block.NULL_BLOCK); - } - // ENEBO: Very wrong - return ((RubyMethod) arg1).call(context, new IRubyObject[] { blockArg }, Block.NULL_BLOCK); - } - - @JRubyMethod(name = "unbind", frame = true) - public RubyUnboundMethod unbind(Block unusedBlock) { - RubyUnboundMethod unboundMethod = - RubyUnboundMethod.newUnboundMethod(implementationModule, methodName, originModule, originName, method); - unboundMethod.infectBy(this); - - return unboundMethod; - } - - @JRubyMethod(name = {"inspect", "to_s"}) - @Override - public IRubyObject inspect() { - StringBuilder buf = new StringBuilder("#<"); - char delimeter = '#'; - - buf.append(getMetaClass().getRealClass().getName()).append(": "); - - if (implementationModule.isSingleton()) { - IRubyObject attached = ((MetaClass) implementationModule).getAttached(); - if (receiver == null) { - buf.append(implementationModule.inspect().toString()); - } else if (receiver == attached) { - buf.append(attached.inspect().toString()); - delimeter = '.'; - } else { - buf.append(receiver.inspect().toString()); - buf.append('(').append(attached.inspect().toString()).append(')'); - delimeter = '.'; - } - } else { - buf.append(originModule.getName()); - - if (implementationModule != originModule) { - buf.append('(').append(implementationModule.getName()).append(')'); - } - } - - buf.append(delimeter).append(methodName).append('>'); - - RubyString str = getRuntime().newString(buf.toString()); - str.setTaint(isTaint()); - return str; - } -} - -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006-2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.locks.ReentrantLock; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyConstant; -import org.jruby.anno.JavaMethodDescriptor; -import org.jruby.anno.TypePopulator; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.compiler.ASTInspector; -import org.jruby.internal.runtime.methods.AliasMethod; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.internal.runtime.methods.FullFunctionCallbackMethod; -import org.jruby.internal.runtime.methods.SimpleCallbackMethod; -import org.jruby.internal.runtime.methods.MethodMethod; -import org.jruby.internal.runtime.methods.ProcMethod; -import org.jruby.internal.runtime.methods.UndefinedMethod; -import org.jruby.internal.runtime.methods.WrapperMethod; -import org.jruby.parser.StaticScope; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.CacheMap; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import static org.jruby.runtime.Visibility.*; -import static org.jruby.anno.FrameField.*; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; -import org.jruby.runtime.callback.Callback; -import org.jruby.runtime.component.VariableEntry; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ClassProvider; -import org.jruby.util.IdUtil; -import org.jruby.exceptions.RaiseException; -import org.jruby.internal.runtime.methods.JavaMethod; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodFactory; -import org.jruby.runtime.MethodIndex; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="Module") -public class RubyModule extends RubyObject { - private static final boolean DEBUG = false; - - public static RubyClass createModuleClass(Ruby runtime, RubyClass moduleClass) { - moduleClass.index = ClassIndex.MODULE; - moduleClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyModule; - } - }; - - moduleClass.defineAnnotatedMethods(RubyModule.class); - moduleClass.defineAnnotatedMethods(ModuleKernelMethods.class); - - return moduleClass; - } - - public static class ModuleKernelMethods { - @JRubyMethod - public static IRubyObject autoload(IRubyObject recv, IRubyObject arg0, IRubyObject arg1) { - return RubyKernel.autoload(recv, arg0, arg1); - } - - @JRubyMethod(name = "autoload?") - public static IRubyObject autoload_p(ThreadContext context, IRubyObject recv, IRubyObject arg0) { - return RubyKernel.autoload_p(context, recv, arg0); - } - } - - static ObjectAllocator MODULE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyModule(runtime, klass); - } - }; - - @Override - public int getNativeTypeIndex() { - return ClassIndex.MODULE; - } - - @Override - public boolean isModule() { - return true; - } - - @Override - public boolean isClass() { - return false; - } - - public boolean isSingleton() { - return false; - } - - // superClass may be null. - protected RubyClass superClass; - - public int index; - - public static class KindOf { - public static final KindOf DEFAULT_KIND_OF = new KindOf(); - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj.getMetaClass().hasModuleInHierarchy(type); - } - } - - public boolean isInstance(IRubyObject object) { - return kindOf.isKindOf(object, this); - } - - public KindOf kindOf = KindOf.DEFAULT_KIND_OF; - - public final int id; - - // Containing class...The parent of Object is null. Object should always be last in chain. - public RubyModule parent; - - // ClassId is the name of the class/module sans where it is located. - // If it is null, then it an anonymous class. - protected String classId; - - - // CONSTANT TABLE - - // Lock used for variableTable/constantTable writes. The RubyObject variableTable - // write methods are overridden here to use this lock rather than Java - // synchronization for faster concurrent writes for modules/classes. - protected final ReentrantLock variableWriteLock = new ReentrantLock(); - - protected transient volatile ConstantTableEntry[] constantTable = - new ConstantTableEntry[CONSTANT_TABLE_DEFAULT_CAPACITY]; - - protected transient int constantTableSize; - - protected transient int constantTableThreshold = - (int)(CONSTANT_TABLE_DEFAULT_CAPACITY * CONSTANT_TABLE_LOAD_FACTOR); - - private final Map<String, DynamicMethod> methods = new ConcurrentHashMap<String, DynamicMethod>(12, 0.75f, 1); - - // ClassProviders return Java class/module (in #defineOrGetClassUnder and - // #defineOrGetModuleUnder) when class/module is opened using colon syntax. - private transient List<ClassProvider> classProviders; - - /** separate path for MetaClass construction - * - */ - protected RubyModule(Ruby runtime, RubyClass metaClass, boolean objectSpace) { - super(runtime, metaClass, objectSpace); - id = runtime.allocModuleId(); - // if (parent == null) parent = runtime.getObject(); - setFlag(USER7_F, !isClass()); - } - - /** used by MODULE_ALLOCATOR and RubyClass constructors - * - */ - protected RubyModule(Ruby runtime, RubyClass metaClass) { - this(runtime, metaClass, runtime.isObjectSpaceEnabled()); - } - - /** standard path for Module construction - * - */ - protected RubyModule(Ruby runtime) { - this(runtime, runtime.getModule()); - } - - public boolean needsImplementer() { - return getFlag(USER7_F); - } - - /** rb_module_new - * - */ - public static RubyModule newModule(Ruby runtime) { - return new RubyModule(runtime); - } - - /** rb_module_new/rb_define_module_id/rb_name_class/rb_set_class_path - * - */ - public static RubyModule newModule(Ruby runtime, String name, RubyModule parent, boolean setParent) { - RubyModule module = newModule(runtime); - module.setBaseName(name); - if (setParent) module.setParent(parent); - parent.setConstant(name, module); - return module; - } - - // synchronized method per JRUBY-1173 (unsafe Double-Checked Locking) - // FIXME: synchronization is still wrong in CP code - public synchronized void addClassProvider(ClassProvider provider) { - if (classProviders == null) { - List<ClassProvider> cp = Collections.synchronizedList(new ArrayList<ClassProvider>()); - cp.add(provider); - classProviders = cp; - } else { - synchronized(classProviders) { - if (!classProviders.contains(provider)) { - classProviders.add(provider); - } - } - } - } - - public void removeClassProvider(ClassProvider provider) { - if (classProviders != null) { - classProviders.remove(provider); - } - } - - private RubyClass searchProvidersForClass(String name, RubyClass superClazz) { - if (classProviders != null) { - synchronized(classProviders) { - RubyClass clazz; - for (ClassProvider classProvider: classProviders) { - if ((clazz = classProvider.defineClassUnder(this, name, superClazz)) != null) { - return clazz; - } - } - } - } - return null; - } - - private RubyModule searchProvidersForModule(String name) { - if (classProviders != null) { - synchronized(classProviders) { - RubyModule module; - for (ClassProvider classProvider: classProviders) { - if ((module = classProvider.defineModuleUnder(this, name)) != null) { - return module; - } - } - } - } - return null; - } - - /** Getter for property superClass. - * @return Value of property superClass. - */ - public RubyClass getSuperClass() { - return superClass; - } - - protected void setSuperClass(RubyClass superClass) { - this.superClass = superClass; - } - - public RubyModule getParent() { - return parent; - } - - public void setParent(RubyModule parent) { - this.parent = parent; - } - - public Map<String, DynamicMethod> getMethods() { - return methods; - } - - - // note that addMethod now does its own put, so any change made to - // functionality here should be made there as well - private void putMethod(String name, DynamicMethod method) { - getMethods().put(name, method); - } - - /** - * Is this module one that in an included one (e.g. an IncludedModuleWrapper). - */ - public boolean isIncluded() { - return false; - } - - public RubyModule getNonIncludedClass() { - return this; - } - - public String getBaseName() { - return classId; - } - - public void setBaseName(String name) { - classId = name; - } - - private volatile String bareName; - private volatile String fullName; - - /** - * Generate a fully-qualified class name or a #-style name for anonymous and singleton classes. - * - * Ruby C equivalent = "classname" - * - * @return The generated class name - */ - public String getName() { - if (fullName == null) { - fullName = calculateFullName(); - } - return fullName; - } - - private String calculateFullName() { - if (getBaseName() == null) { - if (bareName == null) { - if (isClass()) { - bareName = "#<" + "Class" + ":01x" + Integer.toHexString(System.identityHashCode(this)) + ">"; - } else { - bareName = "#<" + "Module" + ":01x" + Integer.toHexString(System.identityHashCode(this)) + ">"; - } - } - - return bareName; - } - - String result = getBaseName(); - RubyClass objectClass = getRuntime().getObject(); - - for (RubyModule p = this.getParent(); p != null && p != objectClass; p = p.getParent()) { - String pName = p.getBaseName(); - // This is needed when the enclosing class or module is a singleton. - // In that case, we generated a name such as null::Foo, which broke - // Marshalling, among others. The correct thing to do in this situation - // is to insert the generate the name of form #<Class:01xasdfasd> if - // it's a singleton module/class, which this code accomplishes. - if(pName == null) { - pName = p.getName(); - } - result = pName + "::" + result; - } - - return result; - } - - /** - * Create a wrapper to use for including the specified module into this one. - * - * Ruby C equivalent = "include_class_new" - * - * @return The module wrapper - */ - public IncludedModuleWrapper newIncludeClass(RubyClass superClazz) { - IncludedModuleWrapper includedModule = new IncludedModuleWrapper(getRuntime(), superClazz, this); - - // include its parent (and in turn that module's parents) - if (getSuperClass() != null) { - includedModule.includeModule(getSuperClass()); - } - - return includedModule; - } - /** - * Finds a class that is within the current module (or class). - * - * @param name to be found in this module (or class) - * @return the class or null if no such class - */ - public RubyClass getClass(String name) { - IRubyObject module; - if ((module = getConstantAt(name)) instanceof RubyClass) { - return (RubyClass)module; - } - return null; - } - - public RubyClass fastGetClass(String internedName) { - IRubyObject module; - if ((module = fastGetConstantAt(internedName)) instanceof RubyClass) { - return (RubyClass)module; - } - return null; - } - - /** - * Include a new module in this module or class. - * - * @param arg The module to include - */ - public synchronized void includeModule(IRubyObject arg) { - assert arg != null; - - testFrozen("module"); - if (!isTaint()) { - getRuntime().secure(4); - } - - if (!(arg instanceof RubyModule)) { - throw getRuntime().newTypeError("Wrong argument type " + arg.getMetaClass().getName() + - " (expected Module)."); - } - - RubyModule module = (RubyModule) arg; - - // Make sure the module we include does not already exist - if (isSame(module)) { - return; - } - - infectBy(module); - - doIncludeModule(module); - } - - public void defineMethod(String name, Callback method) { - Visibility visibility = name.equals("initialize") ? - PRIVATE : PUBLIC; - addMethod(name, new FullFunctionCallbackMethod(this, method, visibility)); - } - - public void defineAnnotatedMethod(Class clazz, String name) { - // FIXME: This is probably not very efficient, since it loads all methods for each call - boolean foundMethod = false; - for (Method method : clazz.getDeclaredMethods()) { - if (method.getName().equals(name) && defineAnnotatedMethod(method, MethodFactory.createFactory(getRuntime().getJRubyClassLoader()))) { - foundMethod = true; - } - } - - if (!foundMethod) { - throw new RuntimeException("No JRubyMethod present for method " + name + "on class " + clazz.getName()); - } - } - - public void defineAnnotatedConstants(Class clazz) { - Field[] declaredFields = clazz.getDeclaredFields(); - for (Field field : declaredFields) { - if(Modifier.isStatic(field.getModifiers())) { - defineAnnotatedConstant(field); - } - } - } - - public boolean defineAnnotatedConstant(Field field) { - JRubyConstant jrubyConstant = field.getAnnotation(JRubyConstant.class); - - if (jrubyConstant == null) return false; - - String[] names = jrubyConstant.value(); - if(names.length == 0) { - names = new String[]{field.getName()}; - } - - Class tp = field.getType(); - IRubyObject realVal; - - try { - if(tp == Integer.class || tp == Integer.TYPE || tp == Short.class || tp == Short.TYPE || tp == Byte.class || tp == Byte.TYPE) { - realVal = RubyNumeric.int2fix(getRuntime(), field.getInt(null)); - } else if(tp == Boolean.class || tp == Boolean.TYPE) { - realVal = field.getBoolean(null) ? getRuntime().getTrue() : getRuntime().getFalse(); - } else { - realVal = getRuntime().getNil(); - } - } catch(Exception e) { - realVal = getRuntime().getNil(); - } - - - for(String name : names) { - this.fastSetConstant(name, realVal); - } - - return true; - } - - public void defineAnnotatedMethods(Class clazz) { - defineAnnotatedMethodsIndividually(clazz); - } - - public static class MethodClumper { - Map<String, List<JavaMethodDescriptor>> annotatedMethods = new HashMap<String, List<JavaMethodDescriptor>>(); - Map<String, List<JavaMethodDescriptor>> staticAnnotatedMethods = new HashMap<String, List<JavaMethodDescriptor>>(); - Map<String, List<JavaMethodDescriptor>> annotatedMethods1_8 = new HashMap<String, List<JavaMethodDescriptor>>(); - Map<String, List<JavaMethodDescriptor>> staticAnnotatedMethods1_8 = new HashMap<String, List<JavaMethodDescriptor>>(); - Map<String, List<JavaMethodDescriptor>> annotatedMethods1_9 = new HashMap<String, List<JavaMethodDescriptor>>(); - Map<String, List<JavaMethodDescriptor>> staticAnnotatedMethods1_9 = new HashMap<String, List<JavaMethodDescriptor>>(); - - public void clump(Class cls) { - Method[] declaredMethods = cls.getDeclaredMethods(); - for (Method method: declaredMethods) { - JRubyMethod anno = method.getAnnotation(JRubyMethod.class); - if (anno == null) continue; - - JavaMethodDescriptor desc = new JavaMethodDescriptor(method); - - String name = anno.name().length == 0 ? method.getName() : anno.name()[0]; - - List<JavaMethodDescriptor> methodDescs; - Map<String, List<JavaMethodDescriptor>> methodsHash = null; - if (desc.isStatic) { - if (anno.compat() == CompatVersion.RUBY1_8) { - methodsHash = staticAnnotatedMethods1_8; - } else if (anno.compat() == CompatVersion.RUBY1_9) { - methodsHash = staticAnnotatedMethods1_9; - } else { - methodsHash = staticAnnotatedMethods; - } - } else { - if (anno.compat() == CompatVersion.RUBY1_8) { - methodsHash = annotatedMethods1_8; - } else if (anno.compat() == CompatVersion.RUBY1_9) { - methodsHash = annotatedMethods1_9; - } else { - methodsHash = annotatedMethods; - } - } - - methodDescs = methodsHash.get(name); - if (methodDescs == null) { - methodDescs = new ArrayList<JavaMethodDescriptor>(); - methodsHash.put(name, methodDescs); - } - - methodDescs.add(desc); - } - } - - public Map<String, List<JavaMethodDescriptor>> getAnnotatedMethods() { - return annotatedMethods; - } - - public Map<String, List<JavaMethodDescriptor>> getAnnotatedMethods1_8() { - return annotatedMethods1_8; - } - - public Map<String, List<JavaMethodDescriptor>> getAnnotatedMethods1_9() { - return annotatedMethods1_9; - } - - public Map<String, List<JavaMethodDescriptor>> getStaticAnnotatedMethods() { - return staticAnnotatedMethods; - } - - public Map<String, List<JavaMethodDescriptor>> getStaticAnnotatedMethods1_8() { - return staticAnnotatedMethods1_8; - } - - public Map<String, List<JavaMethodDescriptor>> getStaticAnnotatedMethods1_9() { - return staticAnnotatedMethods1_9; - } - } - - public void defineAnnotatedMethodsIndividually(Class clazz) { - String x = clazz.getSimpleName(); - TypePopulator populator = null; - - if (RubyInstanceConfig.FULL_TRACE_ENABLED) { - // we need full traces, use default (slow) populator - if (DEBUG) System.out.println("trace mode, using default populator"); - populator = TypePopulator.DEFAULT; - } else { - try { - String qualifiedName = "org.jruby.gen." + clazz.getCanonicalName().replace('.', '$'); - - if (DEBUG) System.out.println("looking for " + qualifiedName + "$Populator"); - - Class populatorClass = Class.forName(qualifiedName + "$Populator"); - populator = (TypePopulator)populatorClass.newInstance(); - } catch (Throwable t) { - if (DEBUG) System.out.println("Could not find it, using default populator"); - populator = TypePopulator.DEFAULT; - } - } - - populator.populate(this, clazz); - } - - @Deprecated - private void defineAnnotatedMethodsIndexed(Class clazz) { - MethodFactory methodFactory = MethodFactory.createFactory(getRuntime().getJRubyClassLoader()); - methodFactory.defineIndexedAnnotatedMethods(this, clazz, methodDefiningCallback); - } - - private static MethodFactory.MethodDefiningCallback methodDefiningCallback = new MethodFactory.MethodDefiningCallback() { - public void define(RubyModule module, JavaMethodDescriptor desc, DynamicMethod dynamicMethod) { - JRubyMethod jrubyMethod = desc.anno; - if (jrubyMethod.frame()) { - for (String name : jrubyMethod.name()) { - ASTInspector.FRAME_AWARE_METHODS.add(name); - } - } - if(jrubyMethod.compat() == CompatVersion.BOTH || - module.getRuntime().getInstanceConfig().getCompatVersion() == jrubyMethod.compat()) { - RubyModule singletonClass; - - if (jrubyMethod.meta()) { - singletonClass = module.getSingletonClass(); - dynamicMethod.setImplementationClass(singletonClass); - - String baseName; - if (jrubyMethod.name().length == 0) { - baseName = desc.name; - singletonClass.addMethod(baseName, dynamicMethod); - } else { - baseName = jrubyMethod.name()[0]; - for (String name : jrubyMethod.name()) { - singletonClass.addMethod(name, dynamicMethod); - } - } - - if (jrubyMethod.alias().length > 0) { - for (String alias : jrubyMethod.alias()) { - singletonClass.defineAlias(alias, baseName); - } - } - } else { - String baseName; - if (jrubyMethod.name().length == 0) { - baseName = desc.name; - module.addMethod(baseName, dynamicMethod); - } else { - baseName = jrubyMethod.name()[0]; - for (String name : jrubyMethod.name()) { - module.addMethod(name, dynamicMethod); - } - } - - if (jrubyMethod.alias().length > 0) { - for (String alias : jrubyMethod.alias()) { - module.defineAlias(alias, baseName); - } - } - - if (jrubyMethod.module()) { - singletonClass = module.getSingletonClass(); - // module/singleton methods are all defined public - DynamicMethod moduleMethod = dynamicMethod.dup(); - moduleMethod.setVisibility(PUBLIC); - - if (jrubyMethod.name().length == 0) { - baseName = desc.name; - singletonClass.addMethod(desc.name, moduleMethod); - } else { - baseName = jrubyMethod.name()[0]; - for (String name : jrubyMethod.name()) { - singletonClass.addMethod(name, moduleMethod); - } - } - - if (jrubyMethod.alias().length > 0) { - for (String alias : jrubyMethod.alias()) { - singletonClass.defineAlias(alias, baseName); - } - } - } - } - } - } - }; - - public boolean defineAnnotatedMethod(String name, List<JavaMethodDescriptor> methods, MethodFactory methodFactory) { - JavaMethodDescriptor desc = methods.get(0); - if (methods.size() == 1) { - return defineAnnotatedMethod(desc, methodFactory); - } else { - DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, methods); - methodDefiningCallback.define(this, desc, dynamicMethod); - - return true; - } - } - - public boolean defineAnnotatedMethod(Method method, MethodFactory methodFactory) { - JRubyMethod jrubyMethod = method.getAnnotation(JRubyMethod.class); - - if (jrubyMethod == null) return false; - - if(jrubyMethod.compat() == CompatVersion.BOTH || - getRuntime().getInstanceConfig().getCompatVersion() == jrubyMethod.compat()) { - JavaMethodDescriptor desc = new JavaMethodDescriptor(method); - DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, desc); - methodDefiningCallback.define(this, desc, dynamicMethod); - - return true; - } - return false; - } - - public boolean defineAnnotatedMethod(JavaMethodDescriptor desc, MethodFactory methodFactory) { - JRubyMethod jrubyMethod = desc.anno; - - if (jrubyMethod == null) return false; - - if(jrubyMethod.compat() == CompatVersion.BOTH || - getRuntime().getInstanceConfig().getCompatVersion() == jrubyMethod.compat()) { - DynamicMethod dynamicMethod = methodFactory.getAnnotatedMethod(this, desc); - methodDefiningCallback.define(this, desc, dynamicMethod); - - return true; - } - return false; - } - - public void defineFastMethod(String name, Callback method) { - Visibility visibility = name.equals("initialize") ? - PRIVATE : PUBLIC; - addMethod(name, new SimpleCallbackMethod(this, method, visibility)); - } - - public void defineFastMethod(String name, Callback method, Visibility visibility) { - addMethod(name, new SimpleCallbackMethod(this, method, visibility)); - } - - public void definePrivateMethod(String name, Callback method) { - addMethod(name, new FullFunctionCallbackMethod(this, method, PRIVATE)); - } - - public void defineFastPrivateMethod(String name, Callback method) { - addMethod(name, new SimpleCallbackMethod(this, method, PRIVATE)); - } - - public void defineFastProtectedMethod(String name, Callback method) { - addMethod(name, new SimpleCallbackMethod(this, method, PROTECTED)); - } - - public void undefineMethod(String name) { - addMethod(name, UndefinedMethod.getInstance()); - } - - /** rb_undef - * - */ - public void undef(ThreadContext context, String name) { - Ruby runtime = context.getRuntime(); - - if (this == runtime.getObject()) runtime.secure(4); - - if (runtime.getSafeLevel() >= 4 && !isTaint()) { - throw new SecurityException("Insecure: can't undef"); - } - testFrozen("module"); - if (name.equals("__id__") || name.equals("__send__")) { - runtime.getWarnings().warn(ID.UNDEFINING_BAD, "undefining `"+ name +"' may cause serious problem"); - } - DynamicMethod method = searchMethod(name); - if (method.isUndefined()) { - String s0 = " class"; - RubyModule c = this; - - if (c.isSingleton()) { - IRubyObject obj = ((MetaClass)c).getAttached(); - - if (obj != null && obj instanceof RubyModule) { - c = (RubyModule) obj; - s0 = ""; - } - } else if (c.isModule()) { - s0 = " module"; - } - - throw runtime.newNameError("Undefined method " + name + " for" + s0 + " '" + c.getName() + "'", name); - } - addMethod(name, UndefinedMethod.getInstance()); - - if (isSingleton()) { - IRubyObject singleton = ((MetaClass)this).getAttached(); - singleton.callMethod(context, "singleton_method_undefined", runtime.newSymbol(name)); - } else { - callMethod(context, "method_undefined", runtime.newSymbol(name)); - } - } - - @JRubyMethod(name = "include?", required = 1) - public IRubyObject include_p(ThreadContext context, IRubyObject arg) { - if (!arg.isModule()) { - throw context.getRuntime().newTypeError(arg, context.getRuntime().getModule()); - } - - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if ((p instanceof IncludedModuleWrapper) && ((IncludedModuleWrapper) p).getNonIncludedClass() == arg) { - return context.getRuntime().getTrue(); - } - } - - return context.getRuntime().getFalse(); - } - - // TODO: Consider a better way of synchronizing - public void addMethod(String name, DynamicMethod method) { - Ruby runtime = getRuntime(); - - if (this == runtime.getObject()) runtime.secure(4); - - if (runtime.getSafeLevel() >= 4 && !isTaint()) { - throw runtime.newSecurityError("Insecure: can't define method"); - } - testFrozen("class/module"); - - // We can safely reference methods here instead of doing getMethods() since if we - // are adding we are not using a IncludedModuleWrapper. - synchronized(getMethods()) { - // If we add a method which already is cached in this class, then we should update the - // cachemap so it stays up to date. - DynamicMethod existingMethod = getMethods().put(name, method); - if (existingMethod != null) { - runtime.getCacheMap().remove(existingMethod); - } - } - } - - public void removeMethod(ThreadContext context, String name) { - Ruby runtime = context.getRuntime(); - - if (this == runtime.getObject()) runtime.secure(4); - - if (runtime.getSafeLevel() >= 4 && !isTaint()) { - throw runtime.newSecurityError("Insecure: can't remove method"); - } - testFrozen("class/module"); - - // We can safely reference methods here instead of doing getMethods() since if we - // are adding we are not using a IncludedModuleWrapper. - synchronized(getMethods()) { - DynamicMethod method = (DynamicMethod) getMethods().remove(name); - if (method == null) { - throw runtime.newNameError("method '" + name + "' not defined in " + getName(), name); - } - - runtime.getCacheMap().remove(method); - } - - if (isSingleton()) { - IRubyObject singleton = ((MetaClass)this).getAttached(); - singleton.callMethod(context, "singleton_method_removed", runtime.newSymbol(name)); - } else { - callMethod(context, "method_removed", runtime.newSymbol(name)); - } - } - - /** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */ - public DynamicMethod searchMethod(String name) { - DynamicMethod method = getMethods().get(name); - - if (method != null) return method; - - return superClass == null ? UndefinedMethod.getInstance() : superClass.searchMethod(name); - } - - /** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */ - public DynamicMethod retrieveMethod(String name) { - return getMethods().get(name); - } - - /** - * Search through this module and supermodules for method definitions. Cache superclass definitions in this class. - * - * @param name The name of the method to search for - * @return The method, or UndefinedMethod if not found - */ - public RubyModule findImplementer(RubyModule clazz) { - for (RubyModule searchModule = this; searchModule != null; searchModule = searchModule.getSuperClass()) { - if (searchModule.isSame(clazz)) { - return searchModule; - } - } - - return null; - } - - public void addModuleFunction(String name, DynamicMethod method) { - addMethod(name, method); - getSingletonClass().addMethod(name, method); - } - - /** rb_define_module_function - * - */ - public void defineModuleFunction(String name, Callback method) { - definePrivateMethod(name, method); - getSingletonClass().defineMethod(name, method); - } - - /** rb_define_module_function - * - */ - public void definePublicModuleFunction(String name, Callback method) { - defineMethod(name, method); - getSingletonClass().defineMethod(name, method); - } - - /** rb_define_module_function - * - */ - public void defineFastModuleFunction(String name, Callback method) { - defineFastPrivateMethod(name, method); - getSingletonClass().defineFastMethod(name, method); - } - - /** rb_define_module_function - * - */ - public void defineFastPublicModuleFunction(String name, Callback method) { - defineFastMethod(name, method); - getSingletonClass().defineFastMethod(name, method); - } - - /** rb_alias - * - */ - public synchronized void defineAlias(String name, String oldName) { - testFrozen("module"); - if (oldName.equals(name)) { - return; - } - Ruby runtime = getRuntime(); - if (this == runtime.getObject()) { - runtime.secure(4); - } - DynamicMethod method = searchMethod(oldName); - DynamicMethod oldMethod = searchMethod(name); - if (method.isUndefined()) { - if (isModule()) { - method = runtime.getObject().searchMethod(oldName); - } - - if (method.isUndefined()) { - throw runtime.newNameError("undefined method `" + oldName + "' for " + - (isModule() ? "module" : "class") + " `" + getName() + "'", oldName); - } - } - CacheMap cacheMap = runtime.getCacheMap(); - cacheMap.remove(method); - cacheMap.remove(oldMethod); - if (oldMethod != oldMethod.getRealMethod()) { - cacheMap.remove(oldMethod.getRealMethod()); - } - putMethod(name, new AliasMethod(this, method, oldName)); - } - - public synchronized void defineAliases(List<String> aliases, String oldName) { - testFrozen("module"); - Ruby runtime = getRuntime(); - if (this == runtime.getObject()) { - runtime.secure(4); - } - DynamicMethod method = searchMethod(oldName); - if (method.isUndefined()) { - if (isModule()) { - method = runtime.getObject().searchMethod(oldName); - } - - if (method.isUndefined()) { - throw runtime.newNameError("undefined method `" + oldName + "' for " + - (isModule() ? "module" : "class") + " `" + getName() + "'", oldName); - } - } - CacheMap cacheMap = runtime.getCacheMap(); - cacheMap.remove(method); - for (String name: aliases) { - if (oldName.equals(name)) continue; - DynamicMethod oldMethod = searchMethod(name); - cacheMap.remove(oldMethod); - if (oldMethod != oldMethod.getRealMethod()) { - cacheMap.remove(oldMethod.getRealMethod()); - } - putMethod(name, new AliasMethod(this, method, oldName)); - } - } - - /** this method should be used only by interpreter or compiler - * - */ - public RubyClass defineOrGetClassUnder(String name, RubyClass superClazz) { - // This method is intended only for defining new classes in Ruby code, - // so it uses the allocator of the specified superclass or default to - // the Object allocator. It should NOT be used to define classes that require a native allocator. - - Ruby runtime = getRuntime(); - IRubyObject classObj = getConstantAt(name); - RubyClass clazz; - - if (classObj != null) { - if (!(classObj instanceof RubyClass)) throw runtime.newTypeError(name + " is not a class"); - clazz = (RubyClass)classObj; - - if (superClazz != null) { - RubyClass tmp = clazz.getSuperClass(); - while (tmp != null && tmp.isIncluded()) tmp = tmp.getSuperClass(); // need to skip IncludedModuleWrappers - if (tmp != null) tmp = tmp.getRealClass(); - if (tmp != superClazz) throw runtime.newTypeError("superclass mismatch for class " + name); - // superClazz = null; - } - - if (runtime.getSafeLevel() >= 4) throw runtime.newTypeError("extending class prohibited"); - } else if (classProviders != null && (clazz = searchProvidersForClass(name, superClazz)) != null) { - // reopen a java class - } else { - if (superClazz == null) superClazz = runtime.getObject(); - clazz = RubyClass.newClass(runtime, superClazz, name, superClazz.getAllocator(), this, true); - } - - return clazz; - } - - /** this method should be used only by interpreter or compiler - * - */ - public RubyModule defineOrGetModuleUnder(String name) { - // This method is intended only for defining new modules in Ruby code - Ruby runtime = getRuntime(); - IRubyObject moduleObj = getConstantAt(name); - RubyModule module; - if (moduleObj != null) { - if (!moduleObj.isModule()) throw runtime.newTypeError(name + " is not a module"); - if (runtime.getSafeLevel() >= 4) throw runtime.newSecurityError("extending module prohibited"); - module = (RubyModule)moduleObj; - } else if (classProviders != null && (module = searchProvidersForModule(name)) != null) { - // reopen a java module - } else { - module = RubyModule.newModule(runtime, name, this, true); - } - return module; - } - - /** rb_define_class_under - * this method should be used only as an API to define/open nested classes - */ - public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator) { - return getRuntime().defineClassUnder(name, superClass, allocator, this); - } - - /** rb_define_module_under - * this method should be used only as an API to define/open nested module - */ - public RubyModule defineModuleUnder(String name) { - return getRuntime().defineModuleUnder(name, this); - } - - // FIXME: create AttrReaderMethod, AttrWriterMethod, for faster attr access - private void addAccessor(ThreadContext context, String internedName, boolean readable, boolean writeable) { - assert internedName == internedName.intern() : internedName + " is not interned"; - - final Ruby runtime = context.getRuntime(); - - // Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed - Visibility attributeScope = context.getCurrentVisibility(); - if (attributeScope == PRIVATE) { - //FIXME warning - } else if (attributeScope == MODULE_FUNCTION) { - attributeScope = PRIVATE; - // FIXME warning - } - final String variableName = ("@" + internedName).intern(); - if (readable) { - // FIXME: should visibility be set to current visibility? - addMethod(internedName, new JavaMethod(this, PUBLIC) { - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { - if (args.length != 0) Arity.raiseArgumentError(runtime, args.length, 0, 0); - - IRubyObject variable = self.getInstanceVariables().fastGetInstanceVariable(variableName); - - return variable == null ? runtime.getNil() : variable; - } - - @Override - public Arity getArity() { - return Arity.noArguments(); - } - }); - callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); - } - if (writeable) { - internedName = (internedName + "=").intern(); - // FIXME: should visibility be set to current visibility? - addMethod(internedName, new JavaMethod(this, PUBLIC) { - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { - // ENEBO: Can anyone get args to be anything but length 1? - if (args.length != 1) Arity.raiseArgumentError(runtime, args.length, 1, 1); - - return self.getInstanceVariables().fastSetInstanceVariable(variableName, args[0]); - } - - @Override - public Arity getArity() { - return Arity.singleArgument(); - } - }); - callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); - } - } - - /** set_method_visibility - * - */ - public void setMethodVisibility(IRubyObject[] methods, Visibility visibility) { - if (getRuntime().getSafeLevel() >= 4 && !isTaint()) { - throw getRuntime().newSecurityError("Insecure: can't change method visibility"); - } - - for (int i = 0; i < methods.length; i++) { - exportMethod(methods[i].asJavaString(), visibility); - } - } - - /** rb_export_method - * - */ - public void exportMethod(String name, Visibility visibility) { - if (this == getRuntime().getObject()) { - getRuntime().secure(4); - } - - DynamicMethod method = searchMethod(name); - - if (method.isUndefined()) { - throw getRuntime().newNameError("undefined method '" + name + "' for " + - (isModule() ? "module" : "class") + " '" + getName() + "'", name); - } - - if (method.getVisibility() != visibility) { - if (this == method.getImplementationClass()) { - method.setVisibility(visibility); - } else { - // FIXME: Why was this using a FullFunctionCallbackMethod before that did callSuper? - addMethod(name, new WrapperMethod(this, method, visibility)); - } - } - } - - /** - * MRI: rb_method_boundp - * - */ - public boolean isMethodBound(String name, boolean checkVisibility) { - DynamicMethod method = searchMethod(name); - if (!method.isUndefined()) { - return !(checkVisibility && method.getVisibility() == PRIVATE); - } - return false; - } - - public IRubyObject newMethod(IRubyObject receiver, String name, boolean bound) { - DynamicMethod method = searchMethod(name); - if (method.isUndefined()) { - throw getRuntime().newNameError("undefined method `" + name + - "' for class `" + this.getName() + "'", name); - } - - RubyModule implementationModule = method.getImplementationClass(); - RubyModule originModule = this; - while (originModule != implementationModule && originModule.isSingleton()) { - originModule = ((MetaClass)originModule).getRealClass(); - } - - RubyMethod newMethod = null; - if (bound) { - newMethod = RubyMethod.newMethod(implementationModule, name, originModule, name, method, receiver); - } else { - newMethod = RubyUnboundMethod.newUnboundMethod(implementationModule, name, originModule, name, method); - } - newMethod.infectBy(this); - - return newMethod; - } - - @JRubyMethod(name = "define_method", frame = true, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject define_method(ThreadContext context, IRubyObject arg0, Block block) { - Ruby runtime = context.getRuntime(); - String name = arg0.asJavaString().intern(); - DynamicMethod newMethod = null; - Visibility visibility = context.getCurrentVisibility(); - - if (visibility == MODULE_FUNCTION) visibility = PRIVATE; - RubyProc proc = runtime.newProc(Block.Type.LAMBDA, block); - - // a normal block passed to define_method changes to do arity checking; make it a lambda - proc.getBlock().type = Block.Type.LAMBDA; - - newMethod = createProcMethod(name, visibility, proc); - - RuntimeHelpers.addInstanceMethod(this, name, newMethod, context.getPreviousVisibility(), context, runtime); - - return proc; - } - - @JRubyMethod(name = "define_method", frame = true, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject define_method(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - Ruby runtime = context.getRuntime(); - IRubyObject body; - String name = arg0.asJavaString().intern(); - DynamicMethod newMethod = null; - Visibility visibility = context.getCurrentVisibility(); - - if (visibility == MODULE_FUNCTION) visibility = PRIVATE; - if (runtime.getProc().isInstance(arg1)) { - // double-testing args.length here, but it avoids duplicating the proc-setup code in two places - RubyProc proc = (RubyProc)arg1; - body = proc; - - newMethod = createProcMethod(name, visibility, proc); - } else if (runtime.getMethod().isInstance(arg1)) { - RubyMethod method = (RubyMethod)arg1; - body = method; - - newMethod = new MethodMethod(this, method.unbind(null), visibility); - } else { - throw runtime.newTypeError("wrong argument type " + arg1.getType().getName() + " (expected Proc/Method)"); - } - - RuntimeHelpers.addInstanceMethod(this, name, newMethod, context.getPreviousVisibility(), context, runtime); - - return body; - } - @Deprecated - public IRubyObject define_method(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 1: - return define_method(context, args[0], block); - case 2: - return define_method(context, args[0], args[1], block); - default: - throw context.getRuntime().newArgumentError("wrong # of arguments(" + args.length + " for 2)"); - } - } - - private DynamicMethod createProcMethod(String name, Visibility visibility, RubyProc proc) { - Block block = proc.getBlock(); - block.getBinding().getFrame().setKlazz(this); - block.getBinding().getFrame().setName(name); - - StaticScope scope = block.getBody().getStaticScope(); - - // for zsupers in define_method (blech!) we tell the proc scope to act as the "argument" scope - scope.setArgumentScope(true); - - Arity arity = block.arity(); - // just using required is broken...but no more broken than before zsuper refactoring - scope.setRequiredArgs(arity.required()); - - if(!arity.isFixed()) { - scope.setRestArg(arity.required()); - } - - return new ProcMethod(this, proc, visibility); - } - - @Deprecated - public IRubyObject executeUnder(ThreadContext context, Callback method, IRubyObject[] args, Block block) { - context.preExecuteUnder(this, block); - try { - return method.execute(this, args, block); - } finally { - context.postExecuteUnder(); - } - } - - @JRubyMethod(name = "name") - public RubyString name() { - return getRuntime().newString(getBaseName() == null ? "" : getName()); - } - - protected IRubyObject cloneMethods(RubyModule clone) { - RubyModule realType = this.getNonIncludedClass(); - for (Map.Entry<String, DynamicMethod> entry : getMethods().entrySet()) { - DynamicMethod method = entry.getValue(); - // Do not clone cached methods - // FIXME: MRI copies all methods here - if (method.getImplementationClass() == realType || method instanceof UndefinedMethod) { - - // A cloned method now belongs to a new class. Set it. - // TODO: Make DynamicMethod immutable - DynamicMethod clonedMethod = method.dup(); - clonedMethod.setImplementationClass(clone); - clone.putMethod(entry.getKey(), clonedMethod); - } - } - - return clone; - } - - /** rb_mod_init_copy - * - */ - @JRubyMethod(name = "initialize_copy", required = 1) - @Override - public IRubyObject initialize_copy(IRubyObject original) { - super.initialize_copy(original); - - RubyModule originalModule = (RubyModule)original; - - if (!getMetaClass().isSingleton()) setMetaClass(originalModule.getSingletonClassClone()); - setSuperClass(originalModule.getSuperClass()); - - if (originalModule.hasVariables()){ - syncVariables(originalModule.getVariableList()); - } - - originalModule.cloneMethods(this); - - return this; - } - - /** rb_mod_included_modules - * - */ - @JRubyMethod(name = "included_modules") - public RubyArray included_modules(ThreadContext context) { - RubyArray ary = context.getRuntime().newArray(); - - for (RubyModule p = getSuperClass(); p != null; p = p.getSuperClass()) { - if (p.isIncluded()) { - ary.append(p.getNonIncludedClass()); - } - } - - return ary; - } - - /** rb_mod_ancestors - * - */ - @JRubyMethod(name = "ancestors") - public RubyArray ancestors(ThreadContext context) { - return context.getRuntime().newArray(getAncestorList()); - } - - @Deprecated - public RubyArray ancestors() { - return getRuntime().newArray(getAncestorList()); - } - - public List<IRubyObject> getAncestorList() { - ArrayList<IRubyObject> list = new ArrayList<IRubyObject>(); - - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if(!p.isSingleton()) { - list.add(p.getNonIncludedClass()); - } - } - - return list; - } - - public boolean hasModuleInHierarchy(RubyModule type) { - // XXX: This check previously used callMethod("==") to check for equality between classes - // when scanning the hierarchy. However the == check may be safe; we should only ever have - // one instance bound to a given type/constant. If it's found to be unsafe, examine ways - // to avoid the == call. - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if (p.getNonIncludedClass() == type) return true; - } - - return false; - } - - @Override - public int hashCode() { - return id; - } - - @JRubyMethod(name = "hash") - @Override - public RubyFixnum hash() { - return getRuntime().newFixnum(id); - } - - /** rb_mod_to_s - * - */ - @JRubyMethod(name = "to_s") - @Override - public IRubyObject to_s() { - if(isSingleton()){ - IRubyObject attached = ((MetaClass)this).getAttached(); - StringBuilder buffer = new StringBuilder("#<Class:"); - if (attached != null) { // FIXME: figure out why we get null sometimes - if(attached instanceof RubyClass || attached instanceof RubyModule){ - buffer.append(attached.inspect()); - }else{ - buffer.append(attached.anyToString()); - } - } - buffer.append(">"); - return getRuntime().newString(buffer.toString()); - } - return getRuntime().newString(getName()); - } - - /** rb_mod_eqq - * - */ - @JRubyMethod(name = "===", required = 1) - @Override - public RubyBoolean op_eqq(ThreadContext context, IRubyObject obj) { - return context.getRuntime().newBoolean(isInstance(obj)); - } - - @JRubyMethod(name = "==", required = 1) - @Override - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - return super.op_equal(context, other); - } - - /** rb_mod_freeze - * - */ - @JRubyMethod(name = "freeze") - @Override - public IRubyObject freeze(ThreadContext context) { - to_s(); - return super.freeze(context); - } - - /** rb_mod_le - * - */ - @JRubyMethod(name = "<=", required = 1) - public IRubyObject op_le(IRubyObject obj) { - if (!(obj instanceof RubyModule)) { - throw getRuntime().newTypeError("compared with non class/module"); - } - - if (isKindOfModule((RubyModule) obj)) { - return getRuntime().getTrue(); - } else if (((RubyModule) obj).isKindOfModule(this)) { - return getRuntime().getFalse(); - } - - return getRuntime().getNil(); - } - - /** rb_mod_lt - * - */ - @JRubyMethod(name = "<", required = 1) - public IRubyObject op_lt(IRubyObject obj) { - return obj == this ? getRuntime().getFalse() : op_le(obj); - } - - /** rb_mod_ge - * - */ - @JRubyMethod(name = ">=", required = 1) - public IRubyObject op_ge(IRubyObject obj) { - if (!(obj instanceof RubyModule)) { - throw getRuntime().newTypeError("compared with non class/module"); - } - - return ((RubyModule) obj).op_le(this); - } - - /** rb_mod_gt - * - */ - @JRubyMethod(name = ">", required = 1) - public IRubyObject op_gt(IRubyObject obj) { - return this == obj ? getRuntime().getFalse() : op_ge(obj); - } - - /** rb_mod_cmp - * - */ - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(IRubyObject obj) { - if (this == obj) return getRuntime().newFixnum(0); - if (!(obj instanceof RubyModule)) return getRuntime().getNil(); - - RubyModule module = (RubyModule) obj; - - if (module.isKindOfModule(this)) { - return getRuntime().newFixnum(1); - } else if (this.isKindOfModule(module)) { - return getRuntime().newFixnum(-1); - } - - return getRuntime().getNil(); - } - - public boolean isKindOfModule(RubyModule type) { - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if (p.isSame(type)) { - return true; - } - } - - return false; - } - - protected boolean isSame(RubyModule module) { - return this == module; - } - - /** rb_mod_initialize - * - */ - @JRubyMethod(name = "initialize", frame = true, visibility = PRIVATE) - public IRubyObject initialize(Block block) { - if (block.isGiven()) { - // class and module bodies default to public, so make the block's visibility public. JRUBY-1185. - block.getBinding().setVisibility(PUBLIC); - block.yield(getRuntime().getCurrentContext(), this, this, this, false); - } - - return getRuntime().getNil(); - } - - public void addReadWriteAttribute(ThreadContext context, String name) { - addAccessor(context, name.intern(), true, true); - } - - public void addReadAttribute(ThreadContext context, String name) { - addAccessor(context, name.intern(), true, false); - } - - public void addWriteAttribute(ThreadContext context, String name) { - addAccessor(context, name.intern(), false, true); - } - - /** rb_mod_attr - * - */ - @JRubyMethod(name = "attr", required = 1, optional = 1, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject attr(ThreadContext context, IRubyObject[] args) { - boolean writeable = args.length > 1 ? args[1].isTrue() : false; - - addAccessor(context, args[0].asJavaString().intern(), true, writeable); - - return getRuntime().getNil(); - } - - /** - * @deprecated - */ - public IRubyObject attr_reader(IRubyObject[] args) { - return attr_reader(getRuntime().getCurrentContext(), args); - } - - /** rb_mod_attr_reader - * - */ - @JRubyMethod(name = "attr_reader", rest = true, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args) { - for (int i = 0; i < args.length; i++) { - addAccessor(context, args[i].asJavaString().intern(), true, false); - } - - return context.getRuntime().getNil(); - } - - /** rb_mod_attr_writer - * - */ - @JRubyMethod(name = "attr_writer", rest = true, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject attr_writer(ThreadContext context, IRubyObject[] args) { - for (int i = 0; i < args.length; i++) { - addAccessor(context, args[i].asJavaString().intern(), false, true); - } - - return context.getRuntime().getNil(); - } - - /** - * @deprecated - */ - public IRubyObject attr_accessor(IRubyObject[] args) { - return attr_accessor(getRuntime().getCurrentContext(), args); - } - - /** rb_mod_attr_accessor - * - */ - @JRubyMethod(name = "attr_accessor", rest = true, visibility = PRIVATE, reads = VISIBILITY) - public IRubyObject attr_accessor(ThreadContext context, IRubyObject[] args) { - for (int i = 0; i < args.length; i++) { - // This is almost always already interned, since it will be called with a symbol in most cases - // but when created from Java code, we might get an argument that needs to be interned. - // addAccessor has as a precondition that the string MUST be interned - addAccessor(context, args[i].asJavaString().intern(), true, true); - } - - return context.getRuntime().getNil(); - } - - /** - * Get a list of all instance methods names of the provided visibility unless not is true, then - * get all methods which are not the provided - * - * @param args passed into one of the Ruby instance_method methods - * @param visibility to find matching instance methods against - * @param not if true only find methods not matching supplied visibility - * @return a RubyArray of instance method names - */ - private RubyArray instance_methods(IRubyObject[] args, final Visibility visibility, boolean not) { - boolean includeSuper = args.length > 0 ? args[0].isTrue() : true; - RubyArray ary = getRuntime().newArray(); - Set<String> seen = new HashSet<String>(); - - for (RubyModule type = this; type != null; type = type.getSuperClass()) { - RubyModule realType = type.getNonIncludedClass(); - for (Iterator iter = type.getMethods().entrySet().iterator(); iter.hasNext();) { - Map.Entry entry = (Map.Entry) iter.next(); - DynamicMethod method = (DynamicMethod) entry.getValue(); - String methodName = (String) entry.getKey(); - - if (! seen.contains(methodName)) { - seen.add(methodName); - - if (method.getImplementationClass() == realType && - (!not && method.getVisibility() == visibility || (not && method.getVisibility() != visibility)) && - ! method.isUndefined()) { - - ary.append(getRuntime().newString(methodName)); - } - } - } - - if (!includeSuper) { - break; - } - } - - return ary; - } - - @JRubyMethod(name = "instance_methods", optional = 1) - public RubyArray instance_methods(IRubyObject[] args) { - return instance_methods(args, PRIVATE, true); - } - - @JRubyMethod(name = "public_instance_methods", optional = 1) - public RubyArray public_instance_methods(IRubyObject[] args) { - return instance_methods(args, PUBLIC, false); - } - - @JRubyMethod(name = "instance_method", required = 1) - public IRubyObject instance_method(IRubyObject symbol) { - return newMethod(null, symbol.asJavaString(), false); - } - - /** rb_class_protected_instance_methods - * - */ - @JRubyMethod(name = "protected_instance_methods", optional = 1) - public RubyArray protected_instance_methods(IRubyObject[] args) { - return instance_methods(args, PROTECTED, false); - } - - /** rb_class_private_instance_methods - * - */ - @JRubyMethod(name = "private_instance_methods", optional = 1) - public RubyArray private_instance_methods(IRubyObject[] args) { - return instance_methods(args, PRIVATE, false); - } - - /** rb_mod_append_features - * - */ - @JRubyMethod(name = "append_features", required = 1, visibility = PRIVATE) - public RubyModule append_features(IRubyObject module) { - if (!(module instanceof RubyModule)) { - // MRI error message says Class, even though Module is ok - throw getRuntime().newTypeError(module,getRuntime().getClassClass()); - } - ((RubyModule) module).includeModule(this); - return this; - } - - /** rb_mod_extend_object - * - */ - @JRubyMethod(name = "extend_object", required = 1, visibility = PRIVATE) - public IRubyObject extend_object(IRubyObject obj) { - obj.getSingletonClass().includeModule(this); - return obj; - } - - /** rb_mod_include - * - */ - @JRubyMethod(name = "include", required = 1, rest = true, visibility = PRIVATE) - public RubyModule include(IRubyObject[] modules) { - ThreadContext context = getRuntime().getCurrentContext(); - // MRI checks all types first: - for (int i = modules.length; --i >= 0; ) { - IRubyObject obj = modules[i]; - if (!obj.isModule()) throw context.getRuntime().newTypeError(obj, context.getRuntime().getModule()); - } - for (int i = modules.length - 1; i >= 0; i--) { - modules[i].callMethod(context, "append_features", this); - modules[i].callMethod(context, "included", this); - } - - return this; - } - - @JRubyMethod(name = "included", required = 1) - public IRubyObject included(ThreadContext context, IRubyObject other) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "extended", required = 1, frame = true) - public IRubyObject extended(ThreadContext context, IRubyObject other, Block block) { - return context.getRuntime().getNil(); - } - - private void setVisibility(ThreadContext context, IRubyObject[] args, Visibility visibility) { - if (context.getRuntime().getSafeLevel() >= 4 && !isTaint()) { - throw context.getRuntime().newSecurityError("Insecure: can't change method visibility"); - } - - if (args.length == 0) { - // Note: we change current frames visibility here because the methods which call - // this method are all "fast" (e.g. they do not created their own frame). - context.setCurrentVisibility(visibility); - } else { - setMethodVisibility(args, visibility); - } - } - - /** rb_mod_public - * - */ - @JRubyMethod(name = "public", rest = true, visibility = PRIVATE, writes = VISIBILITY) - public RubyModule rbPublic(ThreadContext context, IRubyObject[] args) { - setVisibility(context, args, PUBLIC); - return this; - } - - /** rb_mod_protected - * - */ - @JRubyMethod(name = "protected", rest = true, visibility = PRIVATE, writes = VISIBILITY) - public RubyModule rbProtected(ThreadContext context, IRubyObject[] args) { - setVisibility(context, args, PROTECTED); - return this; - } - - /** rb_mod_private - * - */ - @JRubyMethod(name = "private", rest = true, visibility = PRIVATE, writes = VISIBILITY) - public RubyModule rbPrivate(ThreadContext context, IRubyObject[] args) { - setVisibility(context, args, PRIVATE); - return this; - } - - /** rb_mod_modfunc - * - */ - @JRubyMethod(name = "module_function", rest = true, visibility = PRIVATE, writes = VISIBILITY) - public RubyModule module_function(ThreadContext context, IRubyObject[] args) { - if (context.getRuntime().getSafeLevel() >= 4 && !isTaint()) { - throw context.getRuntime().newSecurityError("Insecure: can't change method visibility"); - } - - if (args.length == 0) { - context.setCurrentVisibility(MODULE_FUNCTION); - } else { - setMethodVisibility(args, PRIVATE); - - for (int i = 0; i < args.length; i++) { - String name = args[i].asJavaString().intern(); - DynamicMethod method = searchMethod(name); - assert !method.isUndefined() : "undefined method '" + name + "'"; - getSingletonClass().addMethod(name, new WrapperMethod(getSingletonClass(), method, PUBLIC)); - callMethod(context, "singleton_method_added", context.getRuntime().fastNewSymbol(name)); - } - } - return this; - } - - @JRubyMethod(name = "method_added", required = 1, visibility = PRIVATE) - public IRubyObject method_added(ThreadContext context, IRubyObject nothing) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "method_removed", required = 1, visibility = PRIVATE) - public IRubyObject method_removed(ThreadContext context, IRubyObject nothing) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "method_undefined", required = 1, visibility = PRIVATE) - public IRubyObject method_undefined(ThreadContext context, IRubyObject nothing) { - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "method_defined?", required = 1) - public RubyBoolean method_defined_p(ThreadContext context, IRubyObject symbol) { - return isMethodBound(symbol.asJavaString(), true) ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - @JRubyMethod(name = "public_method_defined?", required = 1) - public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) { - DynamicMethod method = searchMethod(symbol.asJavaString()); - - return context.getRuntime().newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC); - } - - @JRubyMethod(name = "protected_method_defined?", required = 1) - public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) { - DynamicMethod method = searchMethod(symbol.asJavaString()); - - return context.getRuntime().newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED); - } - - @JRubyMethod(name = "private_method_defined?", required = 1) - public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) { - DynamicMethod method = searchMethod(symbol.asJavaString()); - - return context.getRuntime().newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE); - } - - @JRubyMethod(name = "public_class_method", rest = true) - public RubyModule public_class_method(IRubyObject[] args) { - getMetaClass().setMethodVisibility(args, PUBLIC); - return this; - } - - @JRubyMethod(name = "private_class_method", rest = true) - public RubyModule private_class_method(IRubyObject[] args) { - getMetaClass().setMethodVisibility(args, PRIVATE); - return this; - } - - @JRubyMethod(name = "alias_method", required = 2, visibility = PRIVATE) - public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyObject oldId) { - String newName = newId.asJavaString(); - defineAlias(newName, oldId.asJavaString()); - RubySymbol newSym = newId instanceof RubySymbol ? (RubySymbol)newId : - context.getRuntime().newSymbol(newName); - if (isSingleton()) { - ((MetaClass)this).getAttached().callMethod(context, "singleton_method_added", newSym); - } else { - callMethod(context, "method_added", newSym); - } - return this; - } - - @JRubyMethod(name = "undef_method", required = 1, rest = true, visibility = PRIVATE) - public RubyModule undef_method(ThreadContext context, IRubyObject[] args) { - for (int i=0; i<args.length; i++) { - undef(context, args[i].asJavaString()); - } - return this; - } - - @JRubyMethod(name = {"module_eval", "class_eval"}, frame = true) - public IRubyObject module_eval(ThreadContext context, Block block) { - return specificEval(context, this, block); - } - @JRubyMethod(name = {"module_eval", "class_eval"}, frame = true) - public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, Block block) { - return specificEval(context, this, arg0, block); - } - @JRubyMethod(name = {"module_eval", "class_eval"}, frame = true) - public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - return specificEval(context, this, arg0, arg1, block); - } - @JRubyMethod(name = {"module_eval", "class_eval"}, frame = true) - public IRubyObject module_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - return specificEval(context, this, arg0, arg1, arg2, block); - } - @Deprecated - public IRubyObject module_eval(ThreadContext context, IRubyObject[] args, Block block) { - return specificEval(context, this, args, block); - } - - @JRubyMethod(name = "remove_method", required = 1, rest = true, visibility = PRIVATE) - public RubyModule remove_method(ThreadContext context, IRubyObject[] args) { - for(int i=0;i<args.length;i++) { - removeMethod(context, args[i].asJavaString()); - } - return this; - } - - public static void marshalTo(RubyModule module, MarshalStream output) throws java.io.IOException { - output.registerLinkTarget(module); - output.writeString(MarshalStream.getPathFromClass(module)); - } - - public static RubyModule unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - String name = RubyString.byteListToString(input.unmarshalString()); - RubyModule result = UnmarshalStream.getModuleFromPath(input.getRuntime(), name); - input.registerLinkTarget(result); - return result; - } - - /* Module class methods */ - - /** - * Return an array of nested modules or classes. - */ - @JRubyMethod(name = "nesting", frame = true, meta = true) - public static RubyArray nesting(ThreadContext context, IRubyObject recv, Block block) { - Ruby runtime = context.getRuntime(); - RubyModule object = runtime.getObject(); - StaticScope scope = context.getCurrentScope().getStaticScope(); - RubyArray result = runtime.newArray(); - - for (StaticScope current = scope; current.getModule() != object; current = current.getPreviousCRefScope()) { - result.append(current.getModule()); - } - - return result; - } - - private void doIncludeModule(RubyModule includedModule) { - boolean skip = false; - - RubyModule currentModule = this; - while (includedModule != null) { - - if (getNonIncludedClass() == includedModule.getNonIncludedClass()) { - throw getRuntime().newArgumentError("cyclic include detected"); - } - - boolean superclassSeen = false; - - // scan class hierarchy for module - for (RubyModule superClass = this.getSuperClass(); superClass != null; superClass = superClass.getSuperClass()) { - if (superClass instanceof IncludedModuleWrapper) { - if (superClass.getNonIncludedClass() == includedModule.getNonIncludedClass()) { - if (!superclassSeen) { - currentModule = superClass; - } - skip = true; - break; - } - } else { - superclassSeen = true; - } - } - - if (!skip) { - - // blow away caches for any methods that are redefined by module - getRuntime().getCacheMap().moduleIncluded(currentModule, includedModule); - - // In the current logic, if we get here we know that module is not an - // IncludedModuleWrapper, so there's no need to fish out the delegate. But just - // in case the logic should change later, let's do it anyway: - currentModule.setSuperClass(new IncludedModuleWrapper(getRuntime(), currentModule.getSuperClass(), - includedModule.getNonIncludedClass())); - currentModule = currentModule.getSuperClass(); - } - - includedModule = includedModule.getSuperClass(); - skip = false; - } - } - - - // - ////////////////// CLASS VARIABLE RUBY METHODS //////////////// - // - - @JRubyMethod(name = "class_variable_defined?", required = 1) - public IRubyObject class_variable_defined_p(ThreadContext context, IRubyObject var) { - String internedName = validateClassVariable(var.asJavaString().intern()); - RubyModule module = this; - do { - if (module.fastHasClassVariable(internedName)) { - return context.getRuntime().getTrue(); - } - } while ((module = module.getSuperClass()) != null); - - return context.getRuntime().getFalse(); - } - - /** rb_mod_cvar_get - * - */ - @JRubyMethod(name = "class_variable_get", required = 1, visibility = PRIVATE) - public IRubyObject class_variable_get(IRubyObject var) { - return fastGetClassVar(validateClassVariable(var.asJavaString()).intern()); - } - - /** rb_mod_cvar_set - * - */ - @JRubyMethod(name = "class_variable_set", required = 2, visibility = PRIVATE) - public IRubyObject class_variable_set(IRubyObject var, IRubyObject value) { - return fastSetClassVar(validateClassVariable(var.asJavaString()).intern(), value); - } - - /** rb_mod_remove_cvar - * - */ - @JRubyMethod(name = "remove_class_variable", required = 1, visibility = PRIVATE) - public IRubyObject remove_class_variable(ThreadContext context, IRubyObject name) { - String javaName = validateClassVariable(name.asJavaString()); - IRubyObject value; - - if ((value = deleteClassVariable(javaName)) != null) { - return value; - } - - if (fastIsClassVarDefined(javaName)) { - throw cannotRemoveError(javaName); - } - - throw context.getRuntime().newNameError("class variable " + javaName + " not defined for " + getName(), javaName); - } - - /** rb_mod_class_variables - * - */ - @JRubyMethod(name = "class_variables") - public RubyArray class_variables(ThreadContext context) { - Set<String> names = new HashSet<String>(); - - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - for (String name : p.getClassVariableNameList()) { - names.add(name); - } - } - - Ruby runtime = context.getRuntime(); - RubyArray ary = runtime.newArray(); - - for (String name : names) { - ary.append(runtime.newString(name)); - } - - return ary; - } - - - // - ////////////////// CONSTANT RUBY METHODS //////////////// - // - - /** rb_mod_const_defined - * - */ - @JRubyMethod(name = "const_defined?", required = 1) - public RubyBoolean const_defined_p(ThreadContext context, IRubyObject symbol) { - // Note: includes part of fix for JRUBY-1339 - return context.getRuntime().newBoolean(fastIsConstantDefined(validateConstant(symbol.asJavaString()).intern())); - } - - /** rb_mod_const_get - * - */ - @JRubyMethod(name = "const_get", required = 1) - public IRubyObject const_get(IRubyObject symbol) { - return fastGetConstant(validateConstant(symbol.asJavaString()).intern()); - } - - /** rb_mod_const_set - * - */ - @JRubyMethod(name = "const_set", required = 2) - public IRubyObject const_set(IRubyObject symbol, IRubyObject value) { - return fastSetConstant(validateConstant(symbol.asJavaString()).intern(), value); - } - - @JRubyMethod(name = "remove_const", required = 1, visibility = PRIVATE) - public IRubyObject remove_const(ThreadContext context, IRubyObject name) { - String id = validateConstant(name.asJavaString()); - IRubyObject value; - if ((value = deleteConstant(id)) != null) { - if (value != UNDEF) { - return value; - } - context.getRuntime().getLoadService().removeAutoLoadFor(getName() + "::" + id); - // FIXME: I'm not sure this is right, but the old code returned - // the undef, which definitely isn't right... - return context.getRuntime().getNil(); - } - - if (hasConstantInHierarchy(id)) { - throw cannotRemoveError(id); - } - - throw context.getRuntime().newNameError("constant " + id + " not defined for " + getName(), id); - } - - private boolean hasConstantInHierarchy(final String name) { - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if (p.hasConstant(name)) { - return true; - } - } - return false; - } - - /** - * Base implementation of Module#const_missing, throws NameError for specific missing constant. - * - * @param name The constant name which was found to be missing - * @return Nothing! Absolutely nothing! (though subclasses might choose to return something) - */ - @JRubyMethod(name = "const_missing", required = 1, frame = true) - public IRubyObject const_missing(ThreadContext context, IRubyObject name, Block block) { - /* Uninitialized constant */ - if (this != context.getRuntime().getObject()) { - throw context.getRuntime().newNameError("uninitialized constant " + getName() + "::" + name.asJavaString(), "" + getName() + "::" + name.asJavaString()); - } - - throw context.getRuntime().newNameError("uninitialized constant " + name.asJavaString(), name.asJavaString()); - } - - /** rb_mod_constants - * - */ - @JRubyMethod(name = "constants") - public RubyArray constants(ThreadContext context) { - Ruby runtime = context.getRuntime(); - RubyArray array = runtime.newArray(); - RubyModule objectClass = runtime.getObject(); - - if (getRuntime().getModule() == this) { - - for (String name : objectClass.getStoredConstantNameList()) { - array.append(runtime.newString(name)); - } - - } else if (objectClass == this) { - - for (String name : getStoredConstantNameList()) { - array.append(runtime.newString(name)); - } - - } else { - Set<String> names = new HashSet<String>(); - for (RubyModule p = this; p != null; p = p.getSuperClass()) { - if (objectClass != p) { - for (String name : p.getStoredConstantNameList()) { - names.add(name); - } - } - } - for (String name : names) { - array.append(runtime.newString(name)); - } - } - - return array; - } - - - // - ////////////////// CLASS VARIABLE API METHODS //////////////// - // - - /** - * Set the named class variable to the given value, provided taint and freeze allow setting it. - * - * Ruby C equivalent = "rb_cvar_set" - * - * @param name The variable name to set - * @param value The value to set it to - */ - public IRubyObject setClassVar(String name, IRubyObject value) { - RubyModule module = this; - do { - if (module.hasClassVariable(name)) { - return module.storeClassVariable(name, value); - } - } while ((module = module.getSuperClass()) != null); - - return storeClassVariable(name, value); - } - - public IRubyObject fastSetClassVar(final String internedName, final IRubyObject value) { - assert internedName == internedName.intern() : internedName + " is not interned"; - RubyModule module = this; - do { - if (module.fastHasClassVariable(internedName)) { - return module.fastStoreClassVariable(internedName, value); - } - } while ((module = module.getSuperClass()) != null); - - return fastStoreClassVariable(internedName, value); - } - - /** - * Retrieve the specified class variable, searching through this module, included modules, and supermodules. - * - * Ruby C equivalent = "rb_cvar_get" - * - * @param name The name of the variable to retrieve - * @return The variable's value, or throws NameError if not found - */ - public IRubyObject getClassVar(String name) { - assert IdUtil.isClassVariable(name); - IRubyObject value; - RubyModule module = this; - - do { - if ((value = module.variableTableFetch(name)) != null) return value; - } while ((module = module.getSuperClass()) != null); - - throw getRuntime().newNameError("uninitialized class variable " + name + " in " + getName(), name); - } - - public IRubyObject fastGetClassVar(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - assert IdUtil.isClassVariable(internedName); - IRubyObject value; - RubyModule module = this; - - do { - if ((value = module.variableTableFastFetch(internedName)) != null) return value; - } while ((module = module.getSuperClass()) != null); - - throw getRuntime().newNameError("uninitialized class variable " + internedName + " in " + getName(), internedName); - } - - /** - * Is class var defined? - * - * Ruby C equivalent = "rb_cvar_defined" - * - * @param name The class var to determine "is defined?" - * @return true if true, false if false - */ - public boolean isClassVarDefined(String name) { - RubyModule module = this; - do { - if (module.hasClassVariable(name)) return true; - } while ((module = module.getSuperClass()) != null); - - return false; - } - - public boolean fastIsClassVarDefined(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - RubyModule module = this; - do { - if (module.fastHasClassVariable(internedName)) return true; - } while ((module = module.getSuperClass()) != null); - - return false; - } - - - /** rb_mod_remove_cvar - * - * FIXME: any good reason to have two identical methods? (same as remove_class_variable) - */ - public IRubyObject removeCvar(IRubyObject name) { // Wrong Parameter ? - String internedName = validateClassVariable(name.asJavaString()); - IRubyObject value; - - if ((value = deleteClassVariable(internedName)) != null) { - return value; - } - - if (fastIsClassVarDefined(internedName)) { - throw cannotRemoveError(internedName); - } - - throw getRuntime().newNameError("class variable " + internedName + " not defined for " + getName(), internedName); - } - - - // - ////////////////// CONSTANT API METHODS //////////////// - // - - public IRubyObject getConstantAt(String name) { - IRubyObject value; - if ((value = fetchConstant(name)) != UNDEF) { - return value; - } - deleteConstant(name); - return getRuntime().getLoadService().autoload(getName() + "::" + name); - } - - public IRubyObject fastGetConstantAt(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - IRubyObject value; - if ((value = fastFetchConstant(internedName)) != UNDEF) { - return value; - } - deleteConstant(internedName); - return getRuntime().getLoadService().autoload(getName() + "::" + internedName); - } - - /** - * Retrieve the named constant, invoking 'const_missing' should that be appropriate. - * - * @param name The constant to retrieve - * @return The value for the constant, or null if not found - */ - public IRubyObject getConstant(String name) { - assert IdUtil.isConstant(name); - boolean retryForModule = false; - IRubyObject value; - RubyModule p = this; - - retry: while (true) { - while (p != null) { - if ((value = p.constantTableFetch(name)) != null) { - if (value != UNDEF) { - return value; - } - p.deleteConstant(name); - if (getRuntime().getLoadService().autoload( - p.getName() + "::" + name) == null) { - break; - } - continue; - } - p = p.getSuperClass(); - } - - if (!retryForModule && !isClass()) { - retryForModule = true; - p = getRuntime().getObject(); - continue retry; - } - - break; - } - - return callMethod(getRuntime().getCurrentContext(), - "const_missing", getRuntime().newSymbol(name)); - } - - public IRubyObject fastGetConstant(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - assert IdUtil.isConstant(internedName); - boolean retryForModule = false; - IRubyObject value; - RubyModule p = this; - - retry: while (true) { - while (p != null) { - if ((value = p.constantTableFastFetch(internedName)) != null) { - if (value != UNDEF) { - return value; - } - p.deleteConstant(internedName); - if (getRuntime().getLoadService().autoload( - p.getName() + "::" + internedName) == null) { - break; - } - continue; - } - p = p.getSuperClass(); - } - - if (!retryForModule && !isClass()) { - retryForModule = true; - p = getRuntime().getObject(); - continue retry; - } - - break; - } - - return callMethod(getRuntime().getCurrentContext(), - "const_missing", getRuntime().fastNewSymbol(internedName)); - } - - // not actually called anywhere (all known uses call the fast version) - public IRubyObject getConstantFrom(String name) { - return fastGetConstantFrom(name.intern()); - } - - public IRubyObject fastGetConstantFrom(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - assert IdUtil.isConstant(internedName); - RubyClass objectClass = getRuntime().getObject(); - IRubyObject value; - - RubyModule p = this; - - while (p != null) { - if ((value = p.constantTableFastFetch(internedName)) != null) { - if (value != UNDEF) { - if (p == objectClass && this != objectClass) { - String badCName = getName() + "::" + internedName; - getRuntime().getWarnings().warn(ID.CONSTANT_BAD_REFERENCE, "toplevel constant " + - internedName + " referenced by " + badCName, badCName); - } - return value; - } - p.deleteConstant(internedName); - if (getRuntime().getLoadService().autoload( - p.getName() + "::" + internedName) == null) { - break; - } - continue; - } - p = p.getSuperClass(); - } - - return callMethod(getRuntime().getCurrentContext(), - "const_missing", getRuntime().fastNewSymbol(internedName)); - } - /** - * Set the named constant on this module. Also, if the value provided is another Module and - * that module has not yet been named, assign it the specified name. - * - * @param name The name to assign - * @param value The value to assign to it; if an unnamed Module, also set its basename to name - * @return The result of setting the variable. - */ - public IRubyObject setConstant(String name, IRubyObject value) { - IRubyObject oldValue; - if ((oldValue = fetchConstant(name)) != null) { - if (oldValue == UNDEF) { - getRuntime().getLoadService().removeAutoLoadFor(getName() + "::" + name); - } else { - getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + name, name); - } - } - - storeConstant(name, value); - - // if adding a module under a constant name, set that module's basename to the constant name - if (value instanceof RubyModule) { - RubyModule module = (RubyModule)value; - if (module.getBaseName() == null) { - module.setBaseName(name); - module.setParent(this); - } - /* - module.setParent(this); - */ - } - return value; - } - - public IRubyObject fastSetConstant(String internedName, IRubyObject value) { - assert internedName == internedName.intern() : internedName + " is not interned"; - IRubyObject oldValue; - if ((oldValue = fastFetchConstant(internedName)) != null) { - if (oldValue == UNDEF) { - getRuntime().getLoadService().removeAutoLoadFor(getName() + "::" + internedName); - } else { - getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + internedName, internedName); - } - } - - fastStoreConstant(internedName, value); - - // if adding a module under a constant name, set that module's basename to the constant name - if (value instanceof RubyModule) { - RubyModule module = (RubyModule)value; - if (module.getBaseName() == null) { - module.setBaseName(internedName); - module.setParent(this); - } - /* - module.setParent(this); - */ - } - return value; - } - - /** rb_define_const - * - */ - public void defineConstant(String name, IRubyObject value) { - assert value != null; - - if (this == getRuntime().getClassClass()) { - getRuntime().secure(4); - } - - if (!IdUtil.isValidConstantName(name)) { - throw getRuntime().newNameError("bad constant name " + name, name); - } - - setConstant(name, value); - } - - // Fix for JRUBY-1339 - search hierarchy for constant - /** rb_const_defined_at - * - */ - public boolean isConstantDefined(String name) { - assert IdUtil.isConstant(name); - boolean isObject = this == getRuntime().getObject(); - - RubyModule module = this; - - do { - Object value; - if ((value = module.constantTableFetch(name)) != null) { - if (value != UNDEF) return true; - return getRuntime().getLoadService().autoloadFor( - module.getName() + "::" + name) != null; - } - - } while (isObject && (module = module.getSuperClass()) != null ); - - return false; - } - - public boolean fastIsConstantDefined(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - assert IdUtil.isConstant(internedName); - boolean isObject = this == getRuntime().getObject(); - - RubyModule module = this; - - do { - Object value; - if ((value = module.constantTableFastFetch(internedName)) != null) { - if (value != UNDEF) return true; - return getRuntime().getLoadService().autoloadFor( - module.getName() + "::" + internedName) != null; - } - - } while (isObject && (module = module.getSuperClass()) != null ); - - return false; - } - - // - ////////////////// COMMON CONSTANT / CVAR METHODS //////////////// - // - - private RaiseException cannotRemoveError(String id) { - return getRuntime().newNameError("cannot remove " + id + " for " + getName(), id); - } - - - // - ////////////////// INTERNAL MODULE VARIABLE API METHODS //////////////// - // - - /** - * Behaves similarly to {@link #getClassVar(String)}. Searches this - * class/module <em>and its ancestors</em> for the specified internal - * variable. - * - * @param name the internal variable name - * @return the value of the specified internal variable if found, else null - * @see #setInternalModuleVariable(String, IRubyObject) - */ - public boolean hasInternalModuleVariable(final String name) { - RubyModule module = this; - do { - if (module.hasInternalVariable(name)) { - return true; - } - } while ((module = module.getSuperClass()) != null); - - return false; - } - /** - * Behaves similarly to {@link #getClassVar(String)}. Searches this - * class/module <em>and its ancestors</em> for the specified internal - * variable. - * - * @param name the internal variable name - * @return the value of the specified internal variable if found, else null - * @see #setInternalModuleVariable(String, IRubyObject) - */ - public IRubyObject searchInternalModuleVariable(final String name) { - RubyModule module = this; - IRubyObject value; - do { - if ((value = module.getInternalVariable(name)) != null) { - return value; - } - } while ((module = module.getSuperClass()) != null); - - return null; - } - - /** - * Behaves similarly to {@link #setClassVar(String, IRubyObject)}. If the - * specified internal variable is found in this class/module <em>or an ancestor</em>, - * it is set where found. Otherwise it is set in this module. - * - * @param name the internal variable name - * @param value the internal variable value - * @see #searchInternalModuleVariable(String) - */ - public void setInternalModuleVariable(final String name, final IRubyObject value) { - RubyModule module = this; - do { - if (module.hasInternalVariable(name)) { - module.setInternalVariable(name, value); - return; - } - } while ((module = module.getSuperClass()) != null); - - setInternalVariable(name, value); - } - - // - ////////////////// LOW-LEVEL CLASS VARIABLE INTERFACE //////////////// - // - // fetch/store/list class variables for this module - // - - public boolean hasClassVariable(String name) { - assert IdUtil.isClassVariable(name); - return variableTableContains(name); - } - - public boolean fastHasClassVariable(String internedName) { - assert IdUtil.isClassVariable(internedName); - return variableTableFastContains(internedName); - } - - public IRubyObject fetchClassVariable(String name) { - assert IdUtil.isClassVariable(name); - return variableTableFetch(name); - } - - public IRubyObject fastFetchClassVariable(String internedName) { - assert IdUtil.isClassVariable(internedName); - return variableTableFastFetch(internedName); - } - - public IRubyObject storeClassVariable(String name, IRubyObject value) { - assert IdUtil.isClassVariable(name) && value != null; - ensureClassVariablesSettable(); - return variableTableStore(name, value); - } - - public IRubyObject fastStoreClassVariable(String internedName, IRubyObject value) { - assert IdUtil.isClassVariable(internedName) && value != null; - ensureClassVariablesSettable(); - return variableTableFastStore(internedName, value); - } - - public IRubyObject deleteClassVariable(String name) { - assert IdUtil.isClassVariable(name); - ensureClassVariablesSettable(); - return variableTableRemove(name); - } - - public List<Variable<IRubyObject>> getClassVariableList() { - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - VariableTableEntry[] table = variableTableGetTable(); - IRubyObject readValue; - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if (IdUtil.isClassVariable(e.name)) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - list.add(new VariableEntry<IRubyObject>(e.name, readValue)); - } - } - } - return list; - } - - public List<String> getClassVariableNameList() { - ArrayList<String> list = new ArrayList<String>(); - VariableTableEntry[] table = variableTableGetTable(); - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if (IdUtil.isClassVariable(e.name)) { - list.add(e.name); - } - } - } - return list; - } - - protected static final String ERR_INSECURE_SET_CLASS_VAR = "Insecure: can't modify class variable"; - protected static final String ERR_FROZEN_CVAR_TYPE = "class/module "; - - protected final String validateClassVariable(String name) { - if (IdUtil.isValidClassVariableName(name)) { - return name; - } - throw getRuntime().newNameError("`" + name + "' is not allowed as a class variable name", name); - } - - protected final void ensureClassVariablesSettable() { - Ruby runtime = getRuntime(); - - if (!isFrozen() && (runtime.getSafeLevel() < 4 || isTaint())) { - return; - } - - if (runtime.getSafeLevel() >= 4 && !isTaint()) { - throw runtime.newSecurityError(ERR_INSECURE_SET_CONSTANT); - } - if (isFrozen()) { - if (this instanceof RubyModule) { - throw runtime.newFrozenError(ERR_FROZEN_CONST_TYPE); - } else { - throw runtime.newFrozenError(""); - } - } - } - - // - ////////////////// LOW-LEVEL CONSTANT INTERFACE //////////////// - // - // fetch/store/list constants for this module - // - - public boolean hasConstant(String name) { - assert IdUtil.isConstant(name); - return constantTableContains(name); - } - - public boolean fastHasConstant(String internedName) { - assert IdUtil.isConstant(internedName); - return constantTableFastContains(internedName); - } - - // returns the stored value without processing undefs (autoloads) - public IRubyObject fetchConstant(String name) { - assert IdUtil.isConstant(name); - return constantTableFetch(name); - } - - // returns the stored value without processing undefs (autoloads) - public IRubyObject fastFetchConstant(String internedName) { - assert IdUtil.isConstant(internedName); - return constantTableFastFetch(internedName); - } - - public IRubyObject storeConstant(String name, IRubyObject value) { - assert IdUtil.isConstant(name) && value != null; - ensureConstantsSettable(); - return constantTableStore(name, value); - } - - public IRubyObject fastStoreConstant(String internedName, IRubyObject value) { - assert IdUtil.isConstant(internedName) && value != null; - ensureConstantsSettable(); - return constantTableFastStore(internedName, value); - } - - // removes and returns the stored value without processing undefs (autoloads) - public IRubyObject deleteConstant(String name) { - assert IdUtil.isConstant(name); - ensureConstantsSettable(); - return constantTableRemove(name); - } - - public List<Variable<IRubyObject>> getStoredConstantList() { - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - ConstantTableEntry[] table = constantTableGetTable(); - for (int i = table.length; --i >= 0; ) { - for (ConstantTableEntry e = table[i]; e != null; e = e.next) { - list.add(e); - } - } - return list; - } - - public List<String> getStoredConstantNameList() { - ArrayList<String> list = new ArrayList<String>(); - ConstantTableEntry[] table = constantTableGetTable(); - for (int i = table.length; --i >= 0; ) { - for (ConstantTableEntry e = table[i]; e != null; e = e.next) { - list.add(e.name); - } - } - return list; - } - - protected static final String ERR_INSECURE_SET_CONSTANT = "Insecure: can't modify constant"; - protected static final String ERR_FROZEN_CONST_TYPE = "class/module "; - - protected final String validateConstant(String name) { - if (IdUtil.isValidConstantName(name)) { - return name; - } - throw getRuntime().newNameError("wrong constant name " + name, name); - } - - protected final void ensureConstantsSettable() { - Ruby runtime = getRuntime(); - - if (!isFrozen() && (runtime.getSafeLevel() < 4 || isTaint())) { - return; - } - - if (runtime.getSafeLevel() >= 4 && !isTaint()) { - throw runtime.newSecurityError(ERR_INSECURE_SET_CONSTANT); - } - if (isFrozen()) { - if (this instanceof RubyModule) { - throw runtime.newFrozenError(ERR_FROZEN_CONST_TYPE); - } else { - throw runtime.newFrozenError(""); - } - } - } - - - // - ////////////////// VARIABLE TABLE METHODS //////////////// - // - // Overridden to use variableWriteLock in place of synchronization - // - - @Override - protected IRubyObject variableTableStore(String name, IRubyObject value) { - int hash = name.hashCode(); - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - VariableTableEntry[] table; - VariableTableEntry e; - if ((table = variableTable) == null) { - table = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - e = new VariableTableEntry(hash, name.intern(), value, null); - table[hash & (VARIABLE_TABLE_DEFAULT_CAPACITY - 1)] = e; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTableSize = 1; - variableTable = table; - return value; - } - int potentialNewSize; - if ((potentialNewSize = variableTableSize + 1) > variableTableThreshold) { - table = variableTableRehash(); - } - int index; - for (e = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - e.value = value; - return value; - } - } - // external volatile value initialization intended to obviate the need for - // readValueUnderLock technique used in ConcurrentHashMap. may be a little - // slower, but better to pay a price on first write rather than all reads. - e = new VariableTableEntry(hash, name.intern(), value, table[index]); - table[index] = e; - variableTableSize = potentialNewSize; - variableTable = table; // write-volatile - } finally { - lock.unlock(); - } - return value; - } - - @Override - protected IRubyObject variableTableFastStore(String internedName, IRubyObject value) { - assert internedName == internedName.intern() : internedName + " not interned"; - int hash = internedName.hashCode(); - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - VariableTableEntry[] table; - VariableTableEntry e; - if ((table = variableTable) == null) { - table = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - e = new VariableTableEntry(hash, internedName, value, null); - table[hash & (VARIABLE_TABLE_DEFAULT_CAPACITY - 1)] = e; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTableSize = 1; - variableTable = table; - return value; - } - int potentialNewSize; - if ((potentialNewSize = variableTableSize + 1) > variableTableThreshold) { - table = variableTableRehash(); - } - int index; - for (e = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - e.value = value; - return value; - } - } - // external volatile value initialization intended to obviate the need for - // readValueUnderLock technique used in ConcurrentHashMap. may be a little - // slower, but better to pay a price on first write rather than all reads. - e = new VariableTableEntry(hash, internedName, value, table[index]); - table[index] = e; - variableTableSize = potentialNewSize; - variableTable = table; // write-volatile - } finally { - lock.unlock(); - } - return value; - } - - @Override - protected IRubyObject variableTableRemove(String name) { - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - VariableTableEntry[] table; - if ((table = variableTable) != null) { - int hash = name.hashCode(); - int index = hash & (table.length - 1); - VariableTableEntry first = table[index]; - VariableTableEntry e; - for (e = first; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - IRubyObject oldValue = e.value; - // All entries following removed node can stay - // in list, but all preceding ones need to be - // cloned. - VariableTableEntry newFirst = e.next; - for (VariableTableEntry p = first; p != e; p = p.next) { - newFirst = new VariableTableEntry(p.hash, p.name, p.value, newFirst); - } - table[index] = newFirst; - variableTableSize--; - variableTable = table; // write-volatile - return oldValue; - } - } - } - } finally { - lock.unlock(); - } - return null; - } - - @Override - protected IRubyObject variableTableReadLocked(VariableTableEntry entry) { - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - return entry.value; - } finally { - lock.unlock(); - } - } - - @Override - protected void variableTableSync(List<Variable<IRubyObject>> vars) { - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - variableTableSize = 0; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTable = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - for (Variable<IRubyObject> var : vars) { - assert !var.isConstant() && var.getValue() != null; - variableTableStore(var.getName(), var.getValue()); - } - } finally { - lock.unlock(); - } - } - - @Override - public void syncVariables(List<Variable<IRubyObject>> variables) { - ArrayList<Variable<IRubyObject>> constants = new ArrayList<Variable<IRubyObject>>(variables.size()); - Variable<IRubyObject> var; - for (Iterator<Variable<IRubyObject>> iter = variables.iterator(); iter.hasNext(); ) { - if ((var = iter.next()).isConstant()) { - constants.add(var); - iter.remove(); - } - } - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - variableTableSync(variables); - constantTableSync(constants); - } finally { - lock.unlock(); - } - } - - @Override - @SuppressWarnings("unchecked") - @Deprecated // born deprecated - public Map getVariableMap() { - Map map = variableTableGetMap(); - constantTableGetMap(map); - return map; - } - - @Override - public boolean hasVariables() { - return variableTableGetSize() > 0 || constantTableGetSize() > 0; - } - - @Override - public int getVariableCount() { - return variableTableGetSize() + constantTableGetSize(); - } - - @Override - public List<Variable<IRubyObject>> getVariableList() { - VariableTableEntry[] vtable = variableTableGetTable(); - ConstantTableEntry[] ctable = constantTableGetTable(); - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - IRubyObject readValue; - for (int i = vtable.length; --i >= 0; ) { - for (VariableTableEntry e = vtable[i]; e != null; e = e.next) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - list.add(new VariableEntry<IRubyObject>(e.name, readValue)); - } - } - for (int i = ctable.length; --i >= 0; ) { - for (ConstantTableEntry e = ctable[i]; e != null; e = e.next) { - list.add(e); - } - } - return list; - } - - @Override - public List<String> getVariableNameList() { - VariableTableEntry[] vtable = variableTableGetTable(); - ConstantTableEntry[] ctable = constantTableGetTable(); - ArrayList<String> list = new ArrayList<String>(); - for (int i = vtable.length; --i >= 0; ) { - for (VariableTableEntry e = vtable[i]; e != null; e = e.next) { - list.add(e.name); - } - } - for (int i = ctable.length; --i >= 0; ) { - for (ConstantTableEntry e = ctable[i]; e != null; e = e.next) { - list.add(e.name); - } - } - return list; - } - - - // - ////////////////// CONSTANT TABLE METHODS, ETC. //////////////// - // - - protected static final int CONSTANT_TABLE_DEFAULT_CAPACITY = 8; // MUST be power of 2! - protected static final int CONSTANT_TABLE_MAXIMUM_CAPACITY = 1 << 30; - protected static final float CONSTANT_TABLE_LOAD_FACTOR = 0.75f; - - protected static final class ConstantTableEntry implements Variable<IRubyObject> { - final int hash; - final String name; - final IRubyObject value; - final ConstantTableEntry next; - - // constant table entry values are final; if a constant is redefined, the - // entry will be removed and replaced with a new entry. - ConstantTableEntry( - int hash, - String name, - IRubyObject value, - ConstantTableEntry next) { - this.hash = hash; - this.name = name; - this.value = value; - this.next = next; - } - - public String getName() { - return name; - } - - public IRubyObject getValue() { - return value; - } - public final boolean isClassVariable() { - return false; - } - - public final boolean isConstant() { - return true; - } - - public final boolean isInstanceVariable() { - return false; - } - - public final boolean isRubyVariable() { - return true; - } - } - - protected boolean constantTableContains(String name) { - int hash = name.hashCode(); - ConstantTableEntry[] table; - for (ConstantTableEntry e = (table = constantTable)[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return true; - } - } - return false; - } - - protected boolean constantTableFastContains(String internedName) { - ConstantTableEntry[] table; - for (ConstantTableEntry e = (table = constantTable)[internedName.hashCode() & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - return true; - } - } - return false; - } - - protected IRubyObject constantTableFetch(String name) { - int hash = name.hashCode(); - ConstantTableEntry[] table; - for (ConstantTableEntry e = (table = constantTable)[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return e.value; - } - } - return null; - } - - protected IRubyObject constantTableFastFetch(String internedName) { - ConstantTableEntry[] table; - for (ConstantTableEntry e = (table = constantTable)[internedName.hashCode() & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - return e.value; - } - } - return null; - } - - protected IRubyObject constantTableStore(String name, IRubyObject value) { - int hash = name.hashCode(); - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - ConstantTableEntry[] table; - ConstantTableEntry e; - ConstantTableEntry first; - int potentialNewSize; - if ((potentialNewSize = constantTableSize + 1) > constantTableThreshold) { - table = constantTableRehash(); - } else { - table = constantTable; - } - int index; - for (e = first = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - // if value is unchanged, do nothing - if (value == e.value) { - return value; - } - // create new entry, prepend to any trailing entries - ConstantTableEntry newFirst = new ConstantTableEntry(e.hash, e.name, value, e.next); - // all entries before this one must be cloned - for (ConstantTableEntry n = first; n != e; n = n.next) { - newFirst = new ConstantTableEntry(n.hash, n.name, n.value, newFirst); - } - table[index] = newFirst; - constantTable = table; // write-volatile - return value; - } - } - table[index] = new ConstantTableEntry(hash, name.intern(), value, table[index]); - constantTableSize = potentialNewSize; - constantTable = table; // write-volatile - } finally { - lock.unlock(); - } - return value; - } - - protected IRubyObject constantTableFastStore(String internedName, IRubyObject value) { - assert internedName == internedName.intern() : internedName + " not interned"; - int hash = internedName.hashCode(); - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - ConstantTableEntry[] table; - ConstantTableEntry e; - ConstantTableEntry first; - int potentialNewSize; - if ((potentialNewSize = constantTableSize + 1) > constantTableThreshold) { - table = constantTableRehash(); - } else { - table = constantTable; - } - int index; - for (e = first = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - // if value is unchanged, do nothing - if (value == e.value) { - return value; - } - // create new entry, prepend to any trailing entries - ConstantTableEntry newFirst = new ConstantTableEntry(e.hash, e.name, value, e.next); - // all entries before this one must be cloned - for (ConstantTableEntry n = first; n != e; n = n.next) { - newFirst = new ConstantTableEntry(n.hash, n.name, n.value, newFirst); - } - table[index] = newFirst; - constantTable = table; // write-volatile - return value; - } - } - table[index] = new ConstantTableEntry(hash, internedName, value, table[index]); - constantTableSize = potentialNewSize; - constantTable = table; // write-volatile - } finally { - lock.unlock(); - } - return value; - } - - protected IRubyObject constantTableRemove(String name) { - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - ConstantTableEntry[] table; - if ((table = constantTable) != null) { - int hash = name.hashCode(); - int index = hash & (table.length - 1); - ConstantTableEntry first = table[index]; - ConstantTableEntry e; - for (e = first; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - IRubyObject oldValue = e.value; - // All entries following removed node can stay - // in list, but all preceding ones need to be - // cloned. - ConstantTableEntry newFirst = e.next; - for (ConstantTableEntry p = first; p != e; p = p.next) { - newFirst = new ConstantTableEntry(p.hash, p.name, p.value, newFirst); - } - table[index] = newFirst; - constantTableSize--; - constantTable = table; // write-volatile - return oldValue; - } - } - } - } finally { - lock.unlock(); - } - return null; - } - - - protected ConstantTableEntry[] constantTableGetTable() { - return constantTable; - } - - protected int constantTableGetSize() { - if (constantTable != null) { - return constantTableSize; - } - return 0; - } - - protected void constantTableSync(List<Variable<IRubyObject>> vars) { - ReentrantLock lock; - (lock = variableWriteLock).lock(); - try { - constantTableSize = 0; - constantTableThreshold = (int)(CONSTANT_TABLE_DEFAULT_CAPACITY * CONSTANT_TABLE_LOAD_FACTOR); - constantTable = new ConstantTableEntry[CONSTANT_TABLE_DEFAULT_CAPACITY]; - for (Variable<IRubyObject> var : vars) { - assert var.isConstant() && var.getValue() != null; - constantTableStore(var.getName(), var.getValue()); - } - } finally { - lock.unlock(); - } - } - - // MUST be called from synchronized/locked block! - // should only be called by constantTableStore/constantTableFastStore - private final ConstantTableEntry[] constantTableRehash() { - ConstantTableEntry[] oldTable = constantTable; - int oldCapacity; - if ((oldCapacity = oldTable.length) >= CONSTANT_TABLE_MAXIMUM_CAPACITY) { - return oldTable; - } - - int newCapacity = oldCapacity << 1; - ConstantTableEntry[] newTable = new ConstantTableEntry[newCapacity]; - constantTableThreshold = (int)(newCapacity * CONSTANT_TABLE_LOAD_FACTOR); - int sizeMask = newCapacity - 1; - ConstantTableEntry e; - for (int i = oldCapacity; --i >= 0; ) { - // We need to guarantee that any existing reads of old Map can - // proceed. So we cannot yet null out each bin. - e = oldTable[i]; - - if (e != null) { - ConstantTableEntry next = e.next; - int idx = e.hash & sizeMask; - - // Single node on list - if (next == null) - newTable[idx] = e; - - else { - // Reuse trailing consecutive sequence at same slot - ConstantTableEntry lastRun = e; - int lastIdx = idx; - for (ConstantTableEntry last = next; - last != null; - last = last.next) { - int k = last.hash & sizeMask; - if (k != lastIdx) { - lastIdx = k; - lastRun = last; - } - } - newTable[lastIdx] = lastRun; - - // Clone all remaining nodes - for (ConstantTableEntry p = e; p != lastRun; p = p.next) { - int k = p.hash & sizeMask; - ConstantTableEntry m = new ConstantTableEntry(p.hash, p.name, p.value, newTable[k]); - newTable[k] = m; - } - } - } - } - constantTable = newTable; - return newTable; - } - - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - protected Map constantTableGetMap() { - HashMap map = new HashMap(); - ConstantTableEntry[] table; - if ((table = constantTable) != null) { - for (int i = table.length; --i >= 0; ) { - for (ConstantTableEntry e = table[i]; e != null; e = e.next) { - map.put(e.name, e.value); - } - } - } - return map; - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - protected Map constantTableGetMap(Map map) { - ConstantTableEntry[] table; - if ((table = constantTable) != null) { - for (int i = table.length; --i >= 0; ) { - for (ConstantTableEntry e = table[i]; e != null; e = e.next) { - map.put(e.name, e.value); - } - } - } - return map; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ - -package org.jruby; - -import static org.jruby.runtime.Visibility.PRIVATE; -import static org.jruby.runtime.Visibility.PROTECTED; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.exceptions.JumpException; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallType; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.Sprintf; - -/** - * @author Anders Bengtsson - */ -@JRubyClass(name="NameError", parent="StandardError") -public class RubyNameError extends RubyException { - private IRubyObject name; - - /** - * Nested class whose instances act as thunks reacting to to_str method - * called from (Exception#to_str, Exception#message) - * MRI equivalent: rb_cNameErrorMesg, class name: "message", construction method: "!", - * to_str implementation: "name_err_mesg_to_str" - * - * TODO: this class should not be lookupable - */ - @JRubyClass(name = "NameError::Message", parent = "Object") - public static final class RubyNameErrorMessage extends RubyObject { - - static ObjectAllocator NAMEERRORMESSAGE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - IRubyObject dummy = new RubyObject(runtime, runtime.getObject()); - return new RubyNameErrorMessage(runtime, dummy, dummy, Visibility.PRIVATE, CallType.VARIABLE); - } - }; - - private final IRubyObject object; - private final IRubyObject method; - private final Visibility visibility; - private final CallType callType; - - RubyNameErrorMessage(Ruby runtime, IRubyObject object, IRubyObject method, Visibility visibility, CallType callType) { - super(runtime, runtime.getNameErrorMessage(), false); - this.object = object; - this.method = method; - this.visibility = visibility; - this.callType = callType; - } - - @JRubyMethod(name = "_load", meta = true) - public static IRubyObject load(IRubyObject recv, IRubyObject arg) { - return arg; - } - - @JRubyMethod(name = "_dump") - public IRubyObject dump(ThreadContext context, IRubyObject arg) { - return to_str(context); - } - - @JRubyMethod(name = "to_str") - public IRubyObject to_str(ThreadContext context) { - String format = null; - - if (visibility == PRIVATE) { - format = "private method `%s' called for %s"; - } else if (visibility == PROTECTED) { - format = "protected method `%s' called for %s"; - } else if (callType == CallType.VARIABLE) { - format = "undefined local variable or method `%s' for %s"; - } else if (callType == CallType.SUPER) { - format = "super: no superclass method `%s'"; - } - - if (format == null) format = "undefined method `%s' for %s"; - - String description = null; - - if (object.isNil()) { - description = "nil"; - } else if (object instanceof RubyBoolean && object.isTrue()) { - description = "true"; - } else if (object instanceof RubyBoolean && !object.isTrue()) { - description = "false"; - } else { - try { - description = RubyObject.inspect(context, object).toString(); - } catch(JumpException e) {} - - if (description == null || description.length() > 65) description = object.anyToString().toString(); - } - - if (description.length() == 0 || (description.length() > 0 && description.charAt(0) != '#')) { - description = description + ":" + object.getMetaClass().getRealClass().getName(); - } - - Ruby runtime = getRuntime(); - RubyArray arr = runtime.newArray(method, runtime.newString(description)); - RubyString msg = runtime.newString(Sprintf.sprintf(runtime.newString(format), arr).toString()); - if (object.isTaint()) msg.setTaint(true); - return msg; - } - } - - private static ObjectAllocator NAMEERROR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyNameError(runtime, klass); - } - }; - - public static RubyClass createNameErrorClass(Ruby runtime, RubyClass standardErrorClass) { - RubyClass nameErrorClass = runtime.defineClass("NameError", standardErrorClass, NAMEERROR_ALLOCATOR); - nameErrorClass.defineAnnotatedMethods(RubyNameError.class); - return nameErrorClass; - } - - public static RubyClass createNameErrorMessageClass(Ruby runtime, RubyClass nameErrorClass) { - RubyClass messageClass = nameErrorClass.defineClassUnder("Message", runtime.getObject(), RubyNameErrorMessage.NAMEERRORMESSAGE_ALLOCATOR); - messageClass.defineAnnotatedMethods(RubyNameErrorMessage.class); - return messageClass; - } - - protected RubyNameError(Ruby runtime, RubyClass exceptionClass) { - this(runtime, exceptionClass, exceptionClass.getName()); - } - - public RubyNameError(Ruby runtime, RubyClass exceptionClass, String message) { - this(runtime, exceptionClass, message, null); - } - - public RubyNameError(Ruby runtime, RubyClass exceptionClass, String message, String name) { - super(runtime, exceptionClass, message); - this.name = name == null ? runtime.getNil() : runtime.newString(name); - } - - @JRubyMethod(name = "exception", rest = true, meta = true) - public static RubyException newRubyNameError(IRubyObject recv, IRubyObject[] args) { - RubyClass klass = (RubyClass)recv; - - RubyException newError = (RubyException) klass.allocate(); - - newError.callInit(args, Block.NULL_BLOCK); - - return newError; - } - - @JRubyMethod(name = "initialize", optional = 2, frame = true) - @Override - public IRubyObject initialize(IRubyObject[] args, Block block) { - if (args.length > 1) { - name = args[args.length - 1]; - int newLength = args.length > 2 ? args.length - 2 : args.length - 1; - - IRubyObject []tmpArgs = new IRubyObject[newLength]; - System.arraycopy(args, 0, tmpArgs, 0, newLength); - args = tmpArgs; - } else { - name = getRuntime().getNil(); - } - - super.initialize(args, block); - return this; - } - - @JRubyMethod(name = "to_s") - @Override - public IRubyObject to_s() { - if (message.isNil()) return getRuntime().newString(message.getMetaClass().getName()); - RubyString str = message.convertToString(); - if (str != message) message = str; - if (isTaint()) message.setTaint(true); - return message; - } - - @JRubyMethod(name = "name") - public IRubyObject name() { - return name; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * - * @author jpetersen - */ -@JRubyClass(name="NilClass") -public class RubyNil extends RubyObject { - public RubyNil(Ruby runtime) { - super(runtime, runtime.getNilClass(), false); - flags |= NIL_F | FALSE_F; - } - - public static final ObjectAllocator NIL_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return runtime.getNil(); - } - }; - - public static RubyClass createNilClass(Ruby runtime) { - RubyClass nilClass = runtime.defineClass("NilClass", runtime.getObject(), NIL_ALLOCATOR); - runtime.setNilClass(nilClass); - nilClass.index = ClassIndex.NIL; - - nilClass.defineAnnotatedMethods(RubyNil.class); - - nilClass.getMetaClass().undefineMethod("new"); - - // FIXME: This is causing a verification error for some reason - //nilClass.dispatcher = callbackFactory.createDispatcher(nilClass); - - return nilClass; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.NIL; - } - - @Override - public boolean isImmediate() { - return true; - } - - @Override - public RubyClass getSingletonClass() { - return metaClass; - } - - @Override - public Class<?> getJavaClass() { - return void.class; - } - - // Methods of the Nil Class (nil_*): - - /** nil_to_i - * - */ - @JRubyMethod(name = "to_i") - public static RubyFixnum to_i(IRubyObject recv) { - return RubyFixnum.zero(recv.getRuntime()); - } - - /** - * nil_to_f - * - */ - @JRubyMethod(name = "to_f") - public static RubyFloat to_f(IRubyObject recv) { - return RubyFloat.newFloat(recv.getRuntime(), 0.0D); - } - - /** nil_to_s - * - */ - @JRubyMethod(name = "to_s") - public static RubyString to_s(IRubyObject recv) { - return RubyString.newEmptyString(recv.getRuntime()); - } - - /** nil_to_a - * - */ - @JRubyMethod(name = "to_a") - public static RubyArray to_a(IRubyObject recv) { - return recv.getRuntime().newEmptyArray(); - } - - /** nil_inspect - * - */ - @JRubyMethod(name = "inspect") - public static RubyString inspect(IRubyObject recv) { - return recv.getRuntime().newString("nil"); - } - - /** nil_type - * - */ - @JRubyMethod(name = "type") - public static RubyClass type(IRubyObject recv) { - return recv.getRuntime().getNilClass(); - } - - /** nil_and - * - */ - @JRubyMethod(name = "&", required = 1) - public static RubyBoolean op_and(IRubyObject recv, IRubyObject obj) { - return recv.getRuntime().getFalse(); - } - - /** nil_or - * - */ - @JRubyMethod(name = "|", required = 1) - public static RubyBoolean op_or(IRubyObject recv, IRubyObject obj) { - return recv.getRuntime().newBoolean(obj.isTrue()); - } - - /** nil_xor - * - */ - @JRubyMethod(name = "^", required = 1) - public static RubyBoolean op_xor(IRubyObject recv, IRubyObject obj) { - return recv.getRuntime().newBoolean(obj.isTrue()); - } - - @JRubyMethod(name = "nil?") - public IRubyObject nil_p() { - return getRuntime().getTrue(); - } - - @Override - public RubyFixnum id() { - return getRuntime().newFixnum(4); - } - - @Override - public IRubyObject taint(ThreadContext context) { - return this; - } - - @Override - public IRubyObject freeze(ThreadContext context) { - return this; - } - - /** nilclass_to_c - * - */ - @JRubyMethod(name = "to_c", compat = CompatVersion.RUBY1_9) - public static IRubyObject to_c(ThreadContext context, IRubyObject recv) { - return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(context.getRuntime())); - } - - /** nilclass_to_r - * - */ - @JRubyMethod(name = "to_r", compat = CompatVersion.RUBY1_9) - public static IRubyObject to_r(ThreadContext context, IRubyObject recv) { - return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(context.getRuntime())); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Koichiro Ohba <koichiro@meadowy.org> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.UnsupportedCharsetException; -import java.util.HashMap; -import java.util.Map; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; - -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.KCode; - -@JRubyModule(name="NKF") -public class RubyNKF { - public static final NKFCharset AUTO = new NKFCharset(0, "x-JISAutoDetect"); - public static final NKFCharset JIS = new NKFCharset(1, "iso-2022-jp"); - public static final NKFCharset EUC = new NKFCharset(2, "EUC-JP"); - public static final NKFCharset SJIS = new NKFCharset(3, "Windows-31J"); - public static final NKFCharset BINARY = new NKFCharset(4, null); - public static final NKFCharset NOCONV = new NKFCharset(4, null); - public static final NKFCharset UNKNOWN = new NKFCharset(0, null); - public static final NKFCharset ASCII = new NKFCharset(5, "iso-8859-1"); - public static final NKFCharset UTF8 = new NKFCharset(6, "UTF-8"); - public static final NKFCharset UTF16 = new NKFCharset(8, "UTF-16"); - public static final NKFCharset UTF32 = new NKFCharset(12, "UTF-32"); - public static final NKFCharset OTHER = new NKFCharset(16, null); - - public static class NKFCharset { - private final int value; - private final String charset; - - public NKFCharset(int v, String c) { - value = v; - charset = c; - } - - public int getValue() { - return value; - } - - public String getCharset() { - return charset; - } - } - - public static void createNKF(Ruby runtime) { - RubyModule nkfModule = runtime.defineModule("NKF"); - - nkfModule.defineConstant("AUTO", RubyFixnum.newFixnum(runtime, AUTO.getValue())); - nkfModule.defineConstant("JIS", RubyFixnum.newFixnum(runtime, JIS.getValue())); - nkfModule.defineConstant("EUC", RubyFixnum.newFixnum(runtime, EUC.getValue())); - nkfModule.defineConstant("SJIS", RubyFixnum.newFixnum(runtime, SJIS.getValue())); - nkfModule.defineConstant("BINARY", RubyFixnum.newFixnum(runtime, BINARY.getValue())); - nkfModule.defineConstant("NOCONV", RubyFixnum.newFixnum(runtime, NOCONV.getValue())); - nkfModule.defineConstant("UNKNOWN", RubyFixnum.newFixnum(runtime, UNKNOWN.getValue())); - nkfModule.defineConstant("ASCII", RubyFixnum.newFixnum(runtime, ASCII.getValue())); - nkfModule.defineConstant("UTF8", RubyFixnum.newFixnum(runtime, UTF8.getValue())); - nkfModule.defineConstant("UTF16", RubyFixnum.newFixnum(runtime, UTF16.getValue())); - nkfModule.defineConstant("UTF32", RubyFixnum.newFixnum(runtime, UTF32.getValue())); - nkfModule.defineConstant("OTHER", RubyFixnum.newFixnum(runtime, OTHER.getValue())); - - RubyString version = runtime.newString("2.0.7 (JRuby 2007-05-11)"); - RubyString nkfVersion = runtime.newString("2.0.7"); - RubyString nkfDate = runtime.newString("2007-05-11"); - - ThreadContext context = runtime.getCurrentContext(); - - version.freeze(context); - nkfVersion.freeze(context); - nkfDate.freeze(context); - - nkfModule.defineAnnotatedMethods(RubyNKF.class); - } - - @JRubyMethod(name = "guess", required = 1, module = true) - public static IRubyObject guess(ThreadContext context, IRubyObject recv, IRubyObject s) { - Ruby runtime = context.getRuntime(); - if (!s.respondsTo("to_str")) { - throw runtime.newTypeError("can't convert " + s.getMetaClass() + " into String"); - } - ByteList bytes = s.convertToString().getByteList(); - ByteBuffer buf = ByteBuffer.wrap(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - CharsetDecoder decoder = Charset.forName("x-JISAutoDetect").newDecoder(); - try { - decoder.decode(buf); - } catch (CharacterCodingException e) { - return runtime.newFixnum(UNKNOWN.getValue()); - } - if (!decoder.isCharsetDetected()) { - return runtime.newFixnum(UNKNOWN.getValue()); - } - Charset charset = decoder.detectedCharset(); - String name = charset.name(); -// System.out.println("detect: " + name + "\n"); - if ("Shift_JIS".equals(name)) - return runtime.newFixnum(SJIS.getValue()); - if ("windows-31j".equals(name)) - return runtime.newFixnum(SJIS.getValue()); - else if ("EUC-JP".equals(name)) - return runtime.newFixnum(EUC.getValue()); - else if ("ISO-2022-JP".equals(name)) - return runtime.newFixnum(JIS.getValue()); - else - return runtime.newFixnum(UNKNOWN.getValue()); - } - - @JRubyMethod(name = "guess1", required = 1, module = true) - public static IRubyObject guess1(ThreadContext context, IRubyObject recv, IRubyObject str) { - return guess(context, recv, str); - } - - @JRubyMethod(name = "guess2", required = 1, module = true) - public static IRubyObject guess2(ThreadContext context, IRubyObject recv, IRubyObject str) { - return guess(context, recv, str); - } - - @JRubyMethod(name = "nkf", required = 2, module = true) - public static IRubyObject nkf(ThreadContext context, IRubyObject recv, IRubyObject opt, IRubyObject str) { - Ruby runtime = context.getRuntime(); - - if (!opt.respondsTo("to_str")) { - throw runtime.newTypeError("can't convert " + opt.getMetaClass() + " into String"); - } - - if (!str.respondsTo("to_str")) { - throw runtime.newTypeError("can't convert " + str.getMetaClass() + " into String"); - } - - Map<String, NKFCharset> options = parseOpt(opt.convertToString().toString()); - - NKFCharset nc = options.get("input"); - if (nc.getValue() == AUTO.getValue()) { - KCode kcode = runtime.getKCode(); - if (kcode == KCode.SJIS) { - nc = SJIS; - } else if (kcode == KCode.EUC) { - nc = EUC; - } else if (kcode == KCode.UTF8) { - nc = UTF8; - } - } - String decodeCharset = nc.getCharset(); - String encodeCharset = options.get("output").getCharset(); - - return convert(context, decodeCharset, encodeCharset, str); - } - - private static IRubyObject convert(ThreadContext context, String decodeCharset, - String encodeCharset, IRubyObject str) { - Ruby runtime = context.getRuntime(); - CharsetDecoder decoder; - CharsetEncoder encoder; - try { - decoder = Charset.forName(decodeCharset).newDecoder(); - encoder = Charset.forName(encodeCharset).newEncoder(); - } catch (UnsupportedCharsetException e) { - throw runtime.newArgumentError("invalid encoding"); - } - - ByteList bytes = str.convertToString().getByteList(); - ByteBuffer buf = ByteBuffer.wrap(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - try { - CharBuffer cbuf = decoder.decode(buf); - buf = encoder.encode(cbuf); - } catch (CharacterCodingException e) { - throw runtime.newArgumentError("invalid encoding"); - } - byte[] arr = buf.array(); - - return runtime.newString(new ByteList(arr, 0, buf.limit())); - - } - - private static int optionUTF(String s, int i) { - int n = 8; - if (i+1 < s.length() && Character.isDigit(s.charAt(i+1))) { - n = Character.digit(s.charAt(i+1), 10); - if (i+2 < s.length() && Character.isDigit(s.charAt(i+2))) { - n *= 10; - n += Character.digit(s.charAt(i+2), 10); - } - } - return n; - } - - private static Map<String, NKFCharset> parseOpt(String s) { - Map<String, NKFCharset> options = new HashMap<String, NKFCharset>(); - - // default options - options.put("input", AUTO); - options.put("output", JIS); - - for (int i = 0; i < s.length(); i++) { - switch (s.charAt(i)) { - case 'b': - break; - case 'u': - break; - case 'j': // iso-2022-jp - options.put("output", JIS); - break; - case 's': // Shift_JIS - options.put("output", SJIS); - break; - case 'e': // EUC-JP - options.put("output", EUC); - break; - case 'w': // UTF-8 - { - int n = optionUTF(s, i); - if (n == 32) - options.put("output", UTF32); - else if (n == 16) - options.put("output", UTF16); - else - options.put("output", UTF8); - } - break; - case 'J': // iso-2022-jp - options.put("input", JIS); - break; - case 'S': // Shift_JIS - options.put("input", SJIS); - break; - case 'E': // EUC-JP - options.put("input", EUC); - break; - case 'W': // UTF-8 - { - int n = optionUTF(s, i); - if (n == 32) - options.put("input", UTF32); - else if (n == 16) - options.put("input", UTF16); - else - options.put("input", UTF8); - } - break; - case 't': - break; - case 'r': - break; - case 'h': - break; - case 'm': - break; - case 'M': - break; - case 'l': - break; - case 'f': - break; - case 'F': - break; - case 'Z': - break; - case 'X': - break; - case 'x': - break; - case 'B': - break; - case 'T': - break; - case 'd': - break; - case 'c': - break; - case 'I': - break; - case 'L': - break; - case '-': - if (s.charAt(i+1) == '-') { - // long name option - } - default: - } - } - return options; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ - -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyClass(name="NoMethodError", parent="NameError") -public class RubyNoMethodError extends RubyNameError { - private IRubyObject args; - - private static final ObjectAllocator NOMETHODERROR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyNoMethodError(runtime, klass); - } - }; - - public static RubyClass createNoMethodErrorClass(Ruby runtime, RubyClass nameErrorClass) { - RubyClass noMethodErrorClass = runtime.defineClass("NoMethodError", nameErrorClass, NOMETHODERROR_ALLOCATOR); - - noMethodErrorClass.defineAnnotatedMethods(RubyNoMethodError.class); - - return noMethodErrorClass; - } - - protected RubyNoMethodError(Ruby runtime, RubyClass exceptionClass) { - super(runtime, exceptionClass, exceptionClass.getName()); - this.args = runtime.getNil(); - } - - public RubyNoMethodError(Ruby runtime, RubyClass exceptionClass, String message, String name, IRubyObject args) { - super(runtime, exceptionClass, message, name); - this.args = args; - } - - @JRubyMethod(name = "initialize", optional = 3, frame = true) - public IRubyObject initialize(IRubyObject[] args, Block block) { - if (args.length > 2) { - this.args = args[args.length - 1]; - IRubyObject []tmpArgs = new IRubyObject[args.length - 1]; - System.arraycopy(args, 0, tmpArgs, 0, tmpArgs.length); - args = tmpArgs; - } else { - this.args = getRuntime().getNil(); - } - - super.initialize(args, block); - return this; - } - - @JRubyMethod(name = "args") - public IRubyObject args() { - return args; - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2006 Antti Karanta <Antti.Karanta@napa.fi> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import static org.jruby.util.Numeric.f_abs; -import static org.jruby.util.Numeric.f_arg; -import static org.jruby.util.Numeric.f_negative_p; - -import java.math.BigInteger; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.exceptions.RaiseException; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.Convert; - -/** - * Base class for all numerical types in ruby. - */ -// TODO: Numeric.new works in Ruby and it does here too. However trying to use -// that instance in a numeric operation should generate an ArgumentError. Doing -// this seems so pathological I do not see the need to fix this now. -@JRubyClass(name="Numeric", include="Comparable") -public class RubyNumeric extends RubyObject { - - public static RubyClass createNumericClass(Ruby runtime) { - RubyClass numeric = runtime.defineClass("Numeric", runtime.getObject(), NUMERIC_ALLOCATOR); - runtime.setNumeric(numeric); - - numeric.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyNumeric; - } - }; - - numeric.includeModule(runtime.getComparable()); - numeric.defineAnnotatedMethods(RubyNumeric.class); - - return numeric; - } - - protected static final ObjectAllocator NUMERIC_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyNumeric(runtime, klass); - } - }; - - public static double DBL_EPSILON=2.2204460492503131e-16; - - private static IRubyObject convertToNum(double val, Ruby runtime) { - - if (val >= (double) RubyFixnum.MAX || val < (double) RubyFixnum.MIN) { - return RubyBignum.newBignum(runtime, val); - } - return RubyFixnum.newFixnum(runtime, (long) val); - } - - public RubyNumeric(Ruby runtime, RubyClass metaClass) { - super(runtime, metaClass); - } - - public RubyNumeric(Ruby runtime, RubyClass metaClass, boolean useObjectSpace) { - super(runtime, metaClass, useObjectSpace); - } - - // The implementations of these are all bonus (see TODO above) I was going - // to throw an error from these, but it appears to be the wrong place to - // do it. - public double getDoubleValue() { - return 0; - } - - public long getLongValue() { - return 0; - } - - public static RubyNumeric newNumeric(Ruby runtime) { - return new RubyNumeric(runtime, runtime.getNumeric()); - } - - /* ================ - * Utility Methods - * ================ - */ - - /** rb_num2int, NUM2INT - * - */ - public static int num2int(IRubyObject arg) { - long num = num2long(arg); - - checkInt(arg, num); - return (int)num; - } - - /** check_int - * - */ - public static void checkInt(IRubyObject arg, long num){ - String s; - if (num < Integer.MIN_VALUE) { - s = "small"; - } else if (num > Integer.MAX_VALUE) { - s = "big"; - } else { - return; - } - throw arg.getRuntime().newRangeError("integer " + num + " too " + s + " to convert to `int'"); - } - - /** - * NUM2CHR - */ - public static byte num2chr(IRubyObject arg) { - if (arg instanceof RubyString) { - String value = ((RubyString) arg).toString(); - - if (value != null && value.length() > 0) return (byte) value.charAt(0); - } - - return (byte) num2int(arg); - } - - /** rb_num2long and FIX2LONG (numeric.c) - * - */ - public static long num2long(IRubyObject arg) { - if (arg instanceof RubyFixnum) { - return ((RubyFixnum) arg).getLongValue(); - } - if (arg.isNil()) { - throw arg.getRuntime().newTypeError("no implicit conversion from nil to integer"); - } - - if (arg instanceof RubyFloat) { - double aFloat = ((RubyFloat) arg).getDoubleValue(); - if (aFloat <= (double) Long.MAX_VALUE && aFloat >= (double) Long.MIN_VALUE) { - return (long) aFloat; - } else { - // TODO: number formatting here, MRI uses "%-.10g", 1.4 API is a must? - throw arg.getRuntime().newRangeError("float " + aFloat + " out of range of integer"); - } - } else if (arg instanceof RubyBignum) { - return RubyBignum.big2long((RubyBignum) arg); - } - return arg.convertToInteger().getLongValue(); - } - - /** rb_dbl2big + LONG2FIX at once (numeric.c) - * - */ - public static IRubyObject dbl2num(Ruby runtime, double val) { - if (Double.isInfinite(val)) { - throw runtime.newFloatDomainError(val < 0 ? "-Infinity" : "Infinity"); - } - if (Double.isNaN(val)) { - throw runtime.newFloatDomainError("NaN"); - } - return convertToNum(val,runtime); - } - - /** rb_num2dbl and NUM2DBL - * - */ - public static double num2dbl(IRubyObject arg) { - if (arg instanceof RubyFloat) { - return ((RubyFloat) arg).getDoubleValue(); - } else if (arg instanceof RubyString) { - throw arg.getRuntime().newTypeError("no implicit conversion to float from string"); - } else if (arg == arg.getRuntime().getNil()) { - throw arg.getRuntime().newTypeError("no implicit conversion to float from nil"); - } - return arg.convertToFloat().getDoubleValue(); - } - - /** rb_dbl_cmp (numeric.c) - * - */ - public static IRubyObject dbl_cmp(Ruby runtime, double a, double b) { - if (Double.isNaN(a) || Double.isNaN(b)) { - return runtime.getNil(); - } - if (a > b) { - return RubyFixnum.one(runtime); - } - if (a < b) { - return RubyFixnum.minus_one(runtime); - } - return RubyFixnum.zero(runtime); - } - - public static long fix2long(IRubyObject arg) { - return ((RubyFixnum) arg).getLongValue(); - } - - public static int fix2int(IRubyObject arg) { - long num = arg instanceof RubyFixnum ? fix2long(arg) : num2long(arg); - - checkInt(arg, num); - return (int) num; - } - - public static RubyInteger str2inum(Ruby runtime, RubyString str, int base) { - return str2inum(runtime,str,base,false); - } - - public static RubyNumeric int2fix(Ruby runtime, long val) { - return RubyFixnum.newFixnum(runtime,val); - } - - /** rb_num2fix - * - */ - public static IRubyObject num2fix(IRubyObject val) { - if (val instanceof RubyFixnum) { - return val; - } - if (val instanceof RubyBignum) { - // any BigInteger is bigger than Fixnum and we don't have FIXABLE - throw val.getRuntime().newRangeError("integer " + val + " out of range of fixnum"); - } - return RubyFixnum.newFixnum(val.getRuntime(), num2long(val)); - } - - /** - * Converts a string representation of an integer to the integer value. - * Parsing starts at the beginning of the string (after leading and - * trailing whitespace have been removed), and stops at the end or at the - * first character that can't be part of an integer. Leading signs are - * allowed. If <code>base</code> is zero, strings that begin with '0[xX]', - * '0[bB]', or '0' (optionally preceded by a sign) will be treated as hex, - * binary, or octal numbers, respectively. If a non-zero base is given, - * only the prefix (if any) that is appropriate to that base will be - * parsed correctly. For example, if the base is zero or 16, the string - * "0xff" will be converted to 256, but if the base is 10, it will come out - * as zero, since 'x' is not a valid decimal digit. If the string fails - * to parse as a number, zero is returned. - * - * @param runtime the ruby runtime - * @param str the string to be converted - * @param base the expected base of the number (for example, 2, 8, 10, 16), - * or 0 if the method should determine the base automatically - * (defaults to 10). Values 0 and 2-36 are permitted. Any other - * value will result in an ArgumentError. - * @param strict if true, enforce the strict criteria for String encoding of - * numeric values, as required by Integer('n'), and raise an - * exception when those criteria are not met. Otherwise, allow - * lax expression of values, as permitted by String#to_i, and - * return a value in almost all cases (excepting illegal radix). - * TODO: describe the rules/criteria - * @return a RubyFixnum or (if necessary) a RubyBignum representing - * the result of the conversion, which will be zero if the - * conversion failed. - */ - public static RubyInteger str2inum(Ruby runtime, RubyString str, int base, boolean strict) { - if (base != 0 && (base < 2 || base > 36)) { - throw runtime.newArgumentError("illegal radix " + base); - } - ByteList bytes = str.getByteList(); - try { - return runtime.newFixnum(Convert.byteListToLong(bytes, base, strict)); - } catch (InvalidIntegerException e) { - return str2inumIIE(strict, runtime, str); - } catch (NumberTooLargeException e) { - return str2inumNTLE(strict, runtime, str, bytes, base); - } - } - - private static RubyInteger str2inumIIE(boolean strict, Ruby runtime, RubyString str) throws RaiseException { - if (strict) { - throw runtime.newArgumentError("invalid value for Integer: " + str.callMethod(runtime.getCurrentContext(), "inspect").toString()); - } - return RubyFixnum.zero(runtime); - } - - private static RubyInteger str2inumNTLE(boolean strict, Ruby runtime, RubyString str, ByteList bytes, int base) { - try { - BigInteger bi = Convert.byteListToBigInteger(bytes, base, strict); - return new RubyBignum(runtime, bi); - } catch (InvalidIntegerException e2) { - return str2inumIIE(strict, runtime, str); - } - } - - public static RubyFloat str2fnum(Ruby runtime, RubyString arg) { - return str2fnum(runtime,arg,false); - } - - /** - * Converts a string representation of a floating-point number to the - * numeric value. Parsing starts at the beginning of the string (after - * leading and trailing whitespace have been removed), and stops at the - * end or at the first character that can't be part of a number. If - * the string fails to parse as a number, 0.0 is returned. - * - * @param runtime the ruby runtime - * @param arg the string to be converted - * @param strict if true, enforce the strict criteria for String encoding of - * numeric values, as required by Float('n'), and raise an - * exception when those criteria are not met. Otherwise, allow - * lax expression of values, as permitted by String#to_f, and - * return a value in all cases. - * TODO: describe the rules/criteria - * @return a RubyFloat representing the result of the conversion, which - * will be 0.0 if the conversion failed. - */ - public static RubyFloat str2fnum(Ruby runtime, RubyString arg, boolean strict) { - final double ZERO = 0.0; - - try { - return new RubyFloat(runtime,Convert.byteListToDouble(arg.getByteList(),strict)); - } catch (NumberFormatException e) { - if (strict) { - throw runtime.newArgumentError("invalid value for Float(): " - + arg.callMethod(runtime.getCurrentContext(), "inspect").toString()); - } - return new RubyFloat(runtime,ZERO); - } - } - - /** Numeric methods. (num_*) - * - */ - - protected IRubyObject[] getCoerced(ThreadContext context, IRubyObject other, boolean error) { - IRubyObject result; - - try { - result = other.callMethod(context, "coerce", this); - } catch (RaiseException e) { - if (error) { - throw getRuntime().newTypeError( - other.getMetaClass().getName() + " can't be coerced into " + getMetaClass().getName()); - } - - return null; - } - - if (!(result instanceof RubyArray) || ((RubyArray)result).getLength() != 2) { - throw getRuntime().newTypeError("coerce must return [x, y]"); - } - - return ((RubyArray)result).toJavaArray(); - } - - protected IRubyObject callCoerced(ThreadContext context, String method, IRubyObject other, boolean err) { - IRubyObject[] args = getCoerced(context, other, err); - if(args == null) { - return getRuntime().getNil(); - } - return args[0].callMethod(context, method, args[1]); - } - - protected IRubyObject callCoerced(ThreadContext context, String method, IRubyObject other) { - IRubyObject[] args = getCoerced(context, other, false); - if(args == null) { - return getRuntime().getNil(); - } - return args[0].callMethod(context, method, args[1]); - } - - // beneath are rewritten coercions that reflect MRI logic, the aboves are used only by RubyBigDecimal - - /** coerce_body - * - */ - protected final IRubyObject coerceBody(ThreadContext context, IRubyObject other) { - return other.callMethod(context, "coerce", this); - } - - /** do_coerce - * - */ - protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) { - IRubyObject result; - try { - result = coerceBody(context, other); - } catch (RaiseException e) { - if (err) { - throw getRuntime().newTypeError( - other.getMetaClass().getName() + " can't be coerced into " + getMetaClass().getName()); - } - return null; - } - - if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) { - throw getRuntime().newTypeError("coerce must return [x, y]"); - } - return (RubyArray) result; - } - - /** rb_num_coerce_bin - * coercion taking two arguments - */ - protected final IRubyObject coerceBin(ThreadContext context, String method, IRubyObject other) { - RubyArray ary = doCoerce(context, other, true); - return (ary.eltInternal(0)).callMethod(context, method, ary.eltInternal(1)); - } - - /** rb_num_coerce_cmp - * coercion used for comparisons - */ - protected final IRubyObject coerceCmp(ThreadContext context, String method, IRubyObject other) { - RubyArray ary = doCoerce(context, other, false); - if (ary == null) { - return getRuntime().getNil(); // MRI does it! - } - return (ary.eltInternal(0)).callMethod(context, method, ary.eltInternal(1)); - } - - /** rb_num_coerce_relop - * coercion used for relative operators - */ - protected final IRubyObject coerceRelOp(ThreadContext context, String method, IRubyObject other) { - RubyArray ary = doCoerce(context, other, false); - if (ary == null) { - return RubyComparable.cmperr(this, other); - } - - return unwrapCoerced(context, method, other, ary); - } - - private final IRubyObject unwrapCoerced(ThreadContext context, String method, IRubyObject other, RubyArray ary) { - IRubyObject result = (ary.eltInternal(0)).callMethod(context, method, ary.eltInternal(1)); - if (result.isNil()) { - return RubyComparable.cmperr(this, other); - } - return result; - } - - public RubyNumeric asNumeric() { - return this; - } - - /* ================ - * Instance Methods - * ================ - */ - - /** num_sadded - * - */ - @JRubyMethod(name = "singleton_method_added") - public IRubyObject sadded(IRubyObject name) { - throw getRuntime().newTypeError("can't define singleton method " + name + " for " + getType().getName()); - } - - /** num_init_copy - * - */ - @Override - @JRubyMethod(name = "initialize_copy", visibility = Visibility.PRIVATE) - public IRubyObject initialize_copy(IRubyObject arg) { - throw getRuntime().newTypeError("can't copy " + getType().getName()); - } - - /** num_coerce - * - */ - @JRubyMethod(name = "coerce") - public IRubyObject coerce(IRubyObject other) { - if (getClass() == other.getClass()) return getRuntime().newArray(other, this); - - IRubyObject cdr = RubyKernel.new_float(this, this); - IRubyObject car = RubyKernel.new_float(this, other); - - return getRuntime().newArray(car, cdr); - } - - /** num_uplus - * - */ - @JRubyMethod(name = "+@") - public IRubyObject op_uplus() { - return this; - } - - /** num_uminus - * - */ - @JRubyMethod(name = "-@") - public IRubyObject op_uminus(ThreadContext context) { - RubyFixnum zero = RubyFixnum.zero(getRuntime()); - RubyArray ary = zero.doCoerce(context, this, true); - return ary.eltInternal(0).callMethod(context, MethodIndex.OP_MINUS, "-", ary.eltInternal(1)); - } - - /** num_cmp - * - */ - @JRubyMethod(name = "<=>") - public IRubyObject op_cmp(IRubyObject other) { - if (this == other) { // won't hurt fixnums - return RubyFixnum.zero(getRuntime()); - } - return getRuntime().getNil(); - } - - /** num_eql - * - */ - @JRubyMethod(name = "eql?") - public IRubyObject eql_p(ThreadContext context, IRubyObject other) { - if (getClass() != other.getClass()) return getRuntime().getFalse(); - return equalInternal(context, this, other) ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - /** num_quo - * - */ - @JRubyMethod(name = "quo") - public IRubyObject quo(ThreadContext context, IRubyObject other) { - return callMethod(context, "/", other); - } - - /** num_quo - * - */ - @JRubyMethod(name = "quo", compat = CompatVersion.RUBY1_9) - public IRubyObject quo_19(ThreadContext context, IRubyObject other) { - return RubyRational.newRationalRaw(context.getRuntime(), this).callMethod(context, "/", other); - } - - /** num_div - * - */ - @JRubyMethod(name = "div") - public IRubyObject div(ThreadContext context, IRubyObject other) { - return callMethod(context, "/", other).convertToFloat().floor(); - } - - /** num_divmod - * - */ - @JRubyMethod(name = "divmod") - public IRubyObject divmod(ThreadContext context, IRubyObject other) { - return RubyArray.newArray(getRuntime(), div(context, other), modulo(context, other)); - } - - /** num_fdiv (1.9) */ - @JRubyMethod(name = "fdiv", compat = CompatVersion.RUBY1_9) - public IRubyObject fdiv(ThreadContext context, IRubyObject other) { - return RuntimeHelpers.invoke(context, this.convertToFloat(), "/", other); - } - - /** num_modulo - * - */ - @JRubyMethod(name = "modulo") - public IRubyObject modulo(ThreadContext context, IRubyObject other) { - return callMethod(context, "%", other); - } - - /** num_remainder - * - */ - @JRubyMethod(name = "remainder") - public IRubyObject remainder(ThreadContext context, IRubyObject dividend) { - IRubyObject z = callMethod(context, "%", dividend); - IRubyObject x = this; - RubyFixnum zero = RubyFixnum.zero(getRuntime()); - - if (!equalInternal(context, z, zero) && - ((x.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue() && - dividend.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue()) || - (x.callMethod(context, MethodIndex.OP_GT, ">", zero).isTrue() && - dividend.callMethod(context, MethodIndex.OP_LT, "<", zero).isTrue()))) { - return z.callMethod(context, MethodIndex.OP_MINUS, "-", dividend); - } else { - return z; - } - } - - /** num_abs - * - */ - @JRubyMethod(name = "abs") - public IRubyObject abs(ThreadContext context) { - if (callMethod(context, MethodIndex.OP_LT, "<", RubyFixnum.zero(getRuntime())).isTrue()) { - return callMethod(context, "-@"); - } - return this; - } - - /** num_to_int - * - */ - @JRubyMethod(name = "to_int") - public IRubyObject to_int(ThreadContext context) { - return RuntimeHelpers.invoke(context, this, "to_i"); - } - - /** num_scalar_p - * - */ - @JRubyMethod(name = "scalar?", compat = CompatVersion.RUBY1_9) - public IRubyObject scalar_p() { - return getRuntime().getTrue(); - } - - /** num_int_p - * - */ - @JRubyMethod(name = "integer?") - public IRubyObject integer_p() { - return getRuntime().getFalse(); - } - - /** num_zero_p - * - */ - @JRubyMethod(name = "zero?") - public IRubyObject zero_p(ThreadContext context) { - return equalInternal(context, this, RubyFixnum.zero(getRuntime())) ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - /** num_nonzero_p - * - */ - @JRubyMethod(name = "nonzero?") - public IRubyObject nonzero_p(ThreadContext context) { - if (callMethod(context, "zero?").isTrue()) { - return getRuntime().getNil(); - } - return this; - } - - /** num_floor - * - */ - @JRubyMethod(name = "floor") - public IRubyObject floor() { - return convertToFloat().floor(); - } - - /** num_ceil - * - */ - @JRubyMethod(name = "ceil") - public IRubyObject ceil() { - return convertToFloat().ceil(); - } - - /** num_round - * - */ - @JRubyMethod(name = "round") - public IRubyObject round() { - return convertToFloat().round(); - } - - /** num_truncate - * - */ - @JRubyMethod(name = "truncate") - public IRubyObject truncate() { - return convertToFloat().truncate(); - } - - @JRubyMethod(name = "step", required = 1, optional = 1, frame = true) - public IRubyObject step(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 0: throw context.getRuntime().newArgumentError(0, 1); - case 1: return step(context, args[0], block); - case 2: return step(context, args[0], args[1], block); - default: throw context.getRuntime().newArgumentError(args.length, 2); - } - } - - @JRubyMethod(name = "step", frame = true) - public IRubyObject step(ThreadContext context, IRubyObject arg0, Block block) { - return step(context, arg0, RubyFixnum.one(context.getRuntime()), block); - } - - @JRubyMethod(name = "step", frame = true) - public IRubyObject step(ThreadContext context, IRubyObject to, IRubyObject step, Block block) { - if (this instanceof RubyFixnum && to instanceof RubyFixnum && step instanceof RubyFixnum) { - long value = getLongValue(); - long end = ((RubyFixnum) to).getLongValue(); - long diff = ((RubyFixnum) step).getLongValue(); - - if (diff == 0) { - throw getRuntime().newArgumentError("step cannot be 0"); - } - if (diff > 0) { - for (long i = value; i <= end; i += diff) { - block.yield(context, RubyFixnum.newFixnum(getRuntime(), i)); - } - } else { - for (long i = value; i >= end; i += diff) { - block.yield(context, RubyFixnum.newFixnum(getRuntime(), i)); - } - } - } else if (this instanceof RubyFloat || to instanceof RubyFloat || step instanceof RubyFloat) { - double beg = num2dbl(this); - double end = num2dbl(to); - double unit = num2dbl(step); - - if (unit == 0) { - throw getRuntime().newArgumentError("step cannot be 0"); - } - - double n = (end - beg)/unit; - double err = (Math.abs(beg) + Math.abs(end) + Math.abs(end - beg)) / Math.abs(unit) * DBL_EPSILON; - - if (err>0.5) { - err=0.5; - } - n = Math.floor(n + err) + 1; - - for(double i = 0; i < n; i++){ - block.yield(context, RubyFloat.newFloat(getRuntime(), i * unit + beg)); - } - - } else { - RubyNumeric i = this; - - int cmp; - String cmpString; - if (((RubyBoolean) step.callMethod(context, MethodIndex.OP_GT, ">", RubyFixnum.zero(getRuntime()))).isTrue()) { - cmp = MethodIndex.OP_GT; - } else { - cmp = MethodIndex.OP_LT; - } - cmpString = MethodIndex.NAMES.get(cmp); - - while (true) { - if (i.callMethod(context, cmp, cmpString, to).isTrue()) { - break; - } - block.yield(context, i); - i = (RubyNumeric) i.callMethod(context, MethodIndex.OP_PLUS, "+", step); - } - } - return this; - } - - /** num_equal, doesn't override RubyObject.op_equal - * - */ - protected final IRubyObject op_num_equal(ThreadContext context, IRubyObject other) { - // it won't hurt fixnums - if (this == other) return getRuntime().getTrue(); - - return other.callMethod(context, MethodIndex.EQUALEQUAL, "==", this); - } - - /** num_numerator - * - */ - @JRubyMethod(name = "numerator", compat = CompatVersion.RUBY1_9) - public IRubyObject numerator(ThreadContext context) { - return RubyRational.newRationalConvert(context, this).callMethod(context, "numerator"); - } - - /** num_denominator - * - */ - @JRubyMethod(name = "denominator", compat = CompatVersion.RUBY1_9) - public IRubyObject denominator(ThreadContext context) { - return RubyRational.newRationalConvert(context, this).callMethod(context, "denominator"); - } - - /** numeric_to_c - * - */ - @JRubyMethod(name = "to_c", compat = CompatVersion.RUBY1_9) - public IRubyObject to_c(ThreadContext context) { - return RubyComplex.newComplexCanonicalize(context, this); - } - - /** numeric_re - * - */ - @JRubyMethod(name = "re", compat = CompatVersion.RUBY1_9) - public IRubyObject re(ThreadContext context) { - return RubyComplex.newComplexConvert(context, this); - } - - /** numeric_im - * - */ - @JRubyMethod(name = "im", compat = CompatVersion.RUBY1_9) - public IRubyObject im(ThreadContext context) { - return RubyComplex.newComplexConvert(context, RubyFixnum.zero(context.getRuntime()), this); - } - - /** numeric_real - * - */ - @JRubyMethod(name = "real", compat = CompatVersion.RUBY1_9) - public IRubyObject real(ThreadContext context) { - return this; - } - - /** numeric_image - * - */ - @JRubyMethod(name = {"image", "imag"}, compat = CompatVersion.RUBY1_9) - public IRubyObject image(ThreadContext context) { - return RubyFixnum.zero(context.getRuntime()); - } - - /** numeric_arg - * - */ - @JRubyMethod(name = "arg", compat = CompatVersion.RUBY1_9) - public IRubyObject arg(ThreadContext context) { - if (!f_negative_p(context, this)) return RubyFixnum.zero(context.getRuntime()); - return context.getRuntime().getMath().fastFetchConstant("PI"); - } - - /** numeric_polar - * - */ - @JRubyMethod(name = "polar", compat = CompatVersion.RUBY1_9) - public IRubyObject polar(ThreadContext context) { - return context.getRuntime().newArray(f_abs(context, this), f_arg(context, this)); - } - - /** numeric_real - * - */ - @JRubyMethod(name = "conjugate", compat = CompatVersion.RUBY1_9) - public IRubyObject conjugate(ThreadContext context) { - return this; - } - - public static class InvalidIntegerException extends NumberFormatException { - private static final long serialVersionUID = 55019452543252148L; - - public InvalidIntegerException() { - super(); - } - public InvalidIntegerException(String message) { - super(message); - } - public Throwable fillInStackTrace() { - return this; - } - } - - public static class NumberTooLargeException extends NumberFormatException { - private static final long serialVersionUID = -1835120694982699449L; - public NumberTooLargeException() { - super(); - } - public NumberTooLargeException(String message) { - super(message); - } - public Throwable fillInStackTrace() { - return this; - } - } -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Ola Bini <ola.bini@ki.se> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 MenTaLguY <mental@rydia.net> - * Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.evaluator.ASTInterpreter; -import org.jruby.exceptions.JumpException; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallType; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; -import org.jruby.runtime.component.VariableEntry; -import org.jruby.util.IdUtil; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.javasupport.JavaObject; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.builtin.InstanceVariables; -import org.jruby.runtime.builtin.InternalVariables; -import org.jruby.runtime.marshal.CoreObjectType; -import org.jruby.util.TypeConverter; - -/** - * RubyObject is the only implementation of the - * {@link org.jruby.runtime.builtin.IRubyObject}. Every Ruby object in JRuby - * is represented by something that is an instance of RubyObject. In - * some of the core class implementations, this means doing a subclass - * that extends RubyObject, in other cases it means using a simple - * RubyObject instance and the data field to store specific - * information about the Ruby object. - * - * Some care has been taken to make the implementation be as - * monomorphic as possible, so that the Java Hotspot engine can - * improve performance of it. That is the reason for several patterns - * that might seem odd in this class. - * - * The IRubyObject interface used to have lots of methods for - * different things, but these have now mostly been refactored into - * several interfaces that gives access to that specific part of the - * object. This gives us the possibility to switch out that subsystem - * without changing interfaces again. For example, instance variable - * and internal variables are handled this way, but the implementation - * in RubyObject only returns "this" in {@link #getInstanceVariables()} and - * {@link #getInternalVariables()}. - * - * @author jpetersen - */ -@JRubyClass(name="Object", include="Kernel") -public class RubyObject implements Cloneable, IRubyObject, Serializable, CoreObjectType, InstanceVariables, InternalVariables { - - /** - * It's not valid to create a totally empty RubyObject. Since the - * RubyObject is always defined in relation to a runtime, that - * means that creating RubyObjects from outside the class might - * cause problems. - */ - private RubyObject(){}; - - /** - * A value that is used as a null sentinel in among other places - * the RubyArray implementation. It will cause large problems to - * call any methods on this object. - */ - public static final IRubyObject NEVER = new RubyObject(); - - /** - * A value that specifies an undefined value. This value is used - * as a sentinel for undefined constant values, and other places - * where neither null nor NEVER makes sense. - */ - public static final IRubyObject UNDEF = new RubyObject(); - - // The class of this object - protected transient RubyClass metaClass; - - /** - * The variableTable contains variables for an object, defined as: - * <ul> - * <li> instance variables - * <li> class variables (for classes/modules) - * <li> internal variables (such as those used when marshaling RubyRange and RubyException) - * </ul> - * - * Constants are stored separately, see {@link RubyModule}. - * - */ - protected transient volatile VariableTableEntry[] variableTable; - protected transient int variableTableSize; - protected transient int variableTableThreshold; - - // The dataStruct is a place where custom information can be - // contained for core implementations that doesn't necessarily - // want to go to the trouble of creating a subclass of - // RubyObject. The OpenSSL implementation uses this heavily to - // save holder objects containing Java cryptography objects. - // Java integration uses this to store the Java object ref. - protected transient Object dataStruct; - - protected int flags; // zeroed by jvm - public static final int ALL_F = -1; - public static final int FALSE_F = 1 << 0; - - /** - * This flag is a bit funny. It's used to denote that this value - * is nil. It's a bit counterintuitive for a Java programmer to - * not use subclassing to handle this case, since we have a - * RubyNil subclass anyway. Well, the reason for it being a flag - * is that the {@link #isNil()} method is called extremely often. So often - * that it gives a good speed boost to make it monomorphic and - * final. It turns out using a flag for this actually gives us - * better performance than having a polymorphic {@link #isNil()} method. - */ - public static final int NIL_F = 1 << 1; - - public static final int FROZEN_F = 1 << 2; - public static final int TAINTED_F = 1 << 3; - - public static final int FL_USHIFT = 4; - - public static final int USER0_F = (1<<(FL_USHIFT+0)); - public static final int USER1_F = (1<<(FL_USHIFT+1)); - public static final int USER2_F = (1<<(FL_USHIFT+2)); - public static final int USER3_F = (1<<(FL_USHIFT+3)); - public static final int USER4_F = (1<<(FL_USHIFT+4)); - public static final int USER5_F = (1<<(FL_USHIFT+5)); - public static final int USER6_F = (1<<(FL_USHIFT+6)); - public static final int USER7_F = (1<<(FL_USHIFT+7)); - - /** - * Sets or unsets a flag on this object. The only flags that are - * guaranteed to be valid to use as the first argument is: - * - * <ul> - * <li>{@link #FALSE_F}</li> - * <li>{@link NIL_F}</li> - * <li>{@link FROZEN_F}</li> - * <li>{@link TAINTED_F}</li> - * <li>{@link USER0_F}</li> - * <li>{@link USER1_F}</li> - * <li>{@link USER2_F}</li> - * <li>{@link USER3_F}</li> - * <li>{@link USER4_F}</li> - * <li>{@link USER5_F}</li> - * <li>{@link USER6_F}</li> - * <li>{@link USER7_F}</li> - * </ul> - * - * @param flag the actual flag to set or unset. - * @param set if true, the flag will be set, if false, the flag will be unset. - */ - public final void setFlag(int flag, boolean set) { - if (set) { - flags |= flag; - } else { - flags &= ~flag; - } - } - - /** - * Get the value of a custom flag on this object. The only - * guaranteed flags that can be sent in to this method is: - * - * <ul> - * <li>{@link #FALSE_F}</li> - * <li>{@link NIL_F}</li> - * <li>{@link FROZEN_F}</li> - * <li>{@link TAINTED_F}</li> - * <li>{@link USER0_F}</li> - * <li>{@link USER1_F}</li> - * <li>{@link USER2_F}</li> - * <li>{@link USER3_F}</li> - * <li>{@link USER4_F}</li> - * <li>{@link USER5_F}</li> - * <li>{@link USER6_F}</li> - * <li>{@link USER7_F}</li> - * </ul> - * - * @param flag the flag to get - * @return true if the flag is set, false otherwise - */ - public final boolean getFlag(int flag) { - return (flags & flag) != 0; - } - - private transient Finalizer finalizer; - - /** - * Class that keeps track of the finalizers for the object under - * operation. - */ - public class Finalizer implements Finalizable { - private long id; - private List<IRubyObject> finalizers; - private AtomicBoolean finalized; - - public Finalizer(long id) { - this.id = id; - this.finalized = new AtomicBoolean(false); - } - - public void addFinalizer(IRubyObject finalizer) { - if (finalizers == null) { - finalizers = new ArrayList<IRubyObject>(); - } - finalizers.add(finalizer); - } - - public void removeFinalizers() { - finalizers = null; - } - - @Override - public void finalize() { - if (finalized.compareAndSet(false, true)) { - if (finalizers != null) { - for (int i = 0; i < finalizers.size(); i++) { - IRubyObject finalizer = finalizers.get(i); - RuntimeHelpers.invoke( - finalizer.getRuntime().getCurrentContext(), - finalizer, "call", RubyObject.this.id()); - } - } - } - } - } - - /** - * Standard path for object creation. Objects are entered into ObjectSpace - * only if ObjectSpace is enabled. - */ - public RubyObject(Ruby runtime, RubyClass metaClass) { - this.metaClass = metaClass; - - if (runtime.isObjectSpaceEnabled()) addToObjectSpace(runtime); - if (runtime.getSafeLevel() >= 3) taint(runtime); - } - - /** - * Path for objects who want to decide whether they don't want to be in - * ObjectSpace even when it is on. (notably used by objects being - * considered immediate, they'll always pass false here) - */ - protected RubyObject(Ruby runtime, RubyClass metaClass, boolean useObjectSpace) { - this.metaClass = metaClass; - - if (useObjectSpace) addToObjectSpace(runtime); - if (runtime.getSafeLevel() >= 3) taint(runtime); - } - - private void addToObjectSpace(Ruby runtime) { - assert runtime.isObjectSpaceEnabled(); - runtime.getObjectSpace().add(this); - } - - /** - * Will create the Ruby class Object in the runtime - * specified. This method needs to take the actual class as an - * argument because of the Object class' central part in runtime - * initialization. - */ - public static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass) { - objectClass.index = ClassIndex.OBJECT; - - objectClass.defineAnnotatedMethods(ObjectMethods.class); - - return objectClass; - } - - /** - * Interestingly, the Object class doesn't really have that many - * methods for itself. Instead almost all of the Object methods - * are really defined on the Kernel module. This class is a holder - * for all Object methods. - * - * @see RubyKernel - */ - public static class ObjectMethods { - @JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE) - public static IRubyObject intialize(IRubyObject self) { - return self.getRuntime().getNil(); - } - } - - /** - * Default allocator instance for all Ruby objects. The only - * reason to not use this allocator is if you actually need to - * have all instances of something be a subclass of RubyObject. - * - * @see org.jruby.runtime.ObjectAllocator - */ - public static final ObjectAllocator OBJECT_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyObject(runtime, klass); - } - }; - - /** - * Will make sure that this object is added to the current object - * space. - * - * @see org.jruby.runtime.ObjectSpace - */ - public void attachToObjectSpace() { - getRuntime().getObjectSpace().add(this); - } - - /** - * This is overridden in the other concrete Java builtins to provide a fast way - * to determine what type they are. - * - * Will generally return a value from org.jruby.runtime.ClassIndex - * - * @see org.jruby.runtime.ClassInde - */ - public int getNativeTypeIndex() { - return ClassIndex.OBJECT; - } - - /** - * Specifically polymorphic method that are meant to be overridden - * by modules to specify that they are modules in an easy way. - */ - public boolean isModule() { - return false; - } - - /** - * Specifically polymorphic method that are meant to be overridden - * by classes to specify that they are classes in an easy way. - */ - public boolean isClass() { - return false; - } - - /** - * Is object immediate (def: Fixnum, Symbol, true, false, nil?). - */ - public boolean isImmediate() { - return false; - } - - /** rb_make_metaclass - * - * Will create a new meta class, insert this in the chain of - * classes for this specific object, and return the generated meta - * class. - */ - public RubyClass makeMetaClass(RubyClass superClass) { - MetaClass klass = new MetaClass(getRuntime(), superClass); // rb_class_boot - setMetaClass(klass); - - klass.setAttached(this); - klass.setMetaClass(superClass.getRealClass().getMetaClass()); - - return klass; - } - - /** - * Will return the Java interface that most closely can represent - * this object, when working through JAva integration - * translations. - */ - public Class getJavaClass() { - if (dataGetStruct() instanceof JavaObject) { - return ((JavaObject)dataGetStruct()).getValue().getClass(); - } - return getClass(); - } - - /** - * Simple helper to print any objects. - */ - public static void puts(Object obj) { - System.out.println(obj.toString()); - } - - /** - * This method is just a wrapper around the Ruby "==" method, - * provided so that RubyObjects can be used as keys in the Java - * HashMap object underlying RubyHash. - */ - @Override - public boolean equals(Object other) { - return other == this || - other instanceof IRubyObject && - callMethod(getRuntime().getCurrentContext(), MethodIndex.EQUALEQUAL, "==", (IRubyObject) other).isTrue(); - } - - /** - * The default toString method is just a wrapper that calls the - * Ruby "to_s" method. - */ - @Override - public String toString() { - return RuntimeHelpers.invoke(getRuntime().getCurrentContext(), this, "to_s").toString(); - } - - /** - * Will return the runtime that this object is associated with. - * - * @return current runtime - */ - public final Ruby getRuntime() { - return getMetaClass().getClassRuntime(); - } - - /** - * if exist return the meta-class else return the type of the object. - * - */ - public final RubyClass getMetaClass() { - return metaClass; - } - - /** - * Makes it possible to change the metaclass of an object. In - * practice, this is a simple version of Smalltalks Become, except - * that it doesn't work when we're dealing with subclasses. In - * practice it's used to change the singleton/meta class used, - * without changing the "real" inheritance chain. - */ - public void setMetaClass(RubyClass metaClass) { - this.metaClass = metaClass; - } - - /** - * Is this value frozen or not? Shortcut for doing - * getFlag(FROZEN_F). - * - * @return true if this object is frozen, false otherwise - */ - public boolean isFrozen() { - return (flags & FROZEN_F) != 0; - } - - /** - * Sets whether this object is frozen or not. Shortcut for doing - * setFlag(FROZEN_F, frozen). - * - * @param frozen should this object be frozen? - */ - public void setFrozen(boolean frozen) { - if (frozen) { - flags |= FROZEN_F; - } else { - flags &= ~FROZEN_F; - } - } - - /** rb_frozen_class_p - * - * Helper to test whether this object is frozen, and if it is will - * throw an exception based on the message. - */ - protected final void testFrozen(String message) { - if (isFrozen()) { - throw getRuntime().newFrozenError(message + " " + getMetaClass().getName()); - } - } - - /** - * The actual method that checks frozen with the default frozen message from MRI. - * If possible, call this instead of {@link #testFrozen}. - */ - protected void checkFrozen() { - testFrozen("can't modify frozen "); - } - - /** - * Gets the taint. Shortcut for getFlag(TAINTED_F). - * - * @return true if this object is tainted - */ - public boolean isTaint() { - return (flags & TAINTED_F) != 0; - } - - /** - * Sets the taint flag. Shortcut for setFlag(TAINTED_F, taint) - * - * @param taint should this object be tainted or not? - */ - public void setTaint(boolean taint) { - if (taint) { - flags |= TAINTED_F; - } else { - flags &= ~TAINTED_F; - } - } - - /** - * Does this object represent nil? See the docs for the {@link - * #NIL_F} flag for more information. - */ - public final boolean isNil() { - return (flags & NIL_F) != 0; - } - - /** - * Is this value a true value or not? Based on the {@link #FALSE_F} flag. - */ - public final boolean isTrue() { - return (flags & FALSE_F) == 0; - } - - /** - * Is this value a false value or not? Based on the {@link #FALSE_F} flag. - */ - public final boolean isFalse() { - return (flags & FALSE_F) != 0; - } - - /** - * Does this object respond to the specified message? Uses a - * shortcut if it can be proved that respond_to? haven't been - * overridden. - */ - public final boolean respondsTo(String name) { - if(getMetaClass().searchMethod("respond_to?") == getRuntime().getRespondToMethod()) { - return getMetaClass().isMethodBound(name, false); - } else { - return callMethod(getRuntime().getCurrentContext(),"respond_to?",getRuntime().newSymbol(name)).isTrue(); - } - } - - /** rb_singleton_class - * - * Note: this method is specialized for RubyFixnum, RubySymbol, - * RubyNil and RubyBoolean - * - * Will either return the existing singleton class for this - * object, or create a new one and return that. - */ - public RubyClass getSingletonClass() { - RubyClass klass; - - if (getMetaClass().isSingleton() && ((MetaClass)getMetaClass()).getAttached() == this) { - klass = getMetaClass(); - } else { - klass = makeMetaClass(getMetaClass()); - } - - klass.setTaint(isTaint()); - if (isFrozen()) klass.setFrozen(true); - - return klass; - } - - /** rb_singleton_class_clone - * - * Will make sure that if the current objects class is a - * singleton, it will get cloned. - * - * @return either a real class, or a clone of the current singleton class - */ - protected RubyClass getSingletonClassClone() { - RubyClass klass = getMetaClass(); - - if (!klass.isSingleton()) return klass; - - MetaClass clone = new MetaClass(getRuntime()); - clone.flags = flags; - - if (this instanceof RubyClass) { - clone.setMetaClass(clone); - } else { - clone.setMetaClass(klass.getSingletonClassClone()); - } - - clone.setSuperClass(klass.getSuperClass()); - - if (klass.hasVariables()) { - clone.syncVariables(klass.getVariableList()); - } - - klass.cloneMethods(clone); - - ((MetaClass)clone.getMetaClass()).setAttached(clone); - - ((MetaClass)clone).setAttached(((MetaClass)klass).getAttached()); - - return clone; - } - - /** init_copy - * - * Initializes a copy with variable and special instance variable - * information, and then call the initialize_copy Ruby method. - */ - private static void initCopy(IRubyObject clone, RubyObject original) { - assert !clone.isFrozen() : "frozen object (" + clone.getMetaClass().getName() + ") allocated"; - - original.copySpecialInstanceVariables(clone); - - if (original.hasVariables()) { - clone.syncVariables(original.getVariableList()); - } - - /* FIXME: finalizer should be dupped here */ - clone.callMethod(clone.getRuntime().getCurrentContext(), "initialize_copy", original); - } - - /** OBJ_INFECT - * - * Infects this object with traits from the argument obj. In real - * terms this currently means that if obj is tainted, this object - * will get tainted too. It's possible to hijack this method to do - * other infections if that would be interesting. - */ - public IRubyObject infectBy(IRubyObject obj) { - if (obj.isTaint()) setTaint(true); - return this; - } - - /** - * The protocol for super method invocation is a bit complicated - * in Ruby. In real terms it involves first finding the real - * implementation class (the super class), getting the name of the - * method to call from the frame, and then invoke that on the - * super class with the current self as the actual object - * invoking. - */ - public IRubyObject callSuper(ThreadContext context, IRubyObject[] args, Block block) { - RubyModule klazz = context.getFrameKlazz(); - - RubyClass superClass = RuntimeHelpers.findImplementerIfNecessary(getMetaClass(), klazz).getSuperClass(); - - if (superClass == null) { - String name = context.getFrameName(); - return RuntimeHelpers.callMethodMissing(context, this, klazz.searchMethod(name), name, args, this, CallType.SUPER, block); - } - return RuntimeHelpers.invokeAs(context, superClass, this, context.getFrameName(), args, CallType.SUPER, block); - } - - /** - * Will invoke a named method with no arguments and no block. - */ - public final IRubyObject callMethod(ThreadContext context, String name) { - return RuntimeHelpers.invoke(context, this, name); - } - - /** - * Will invoke a named method with one argument and no block with - * functional invocation. - */ - public final IRubyObject callMethod(ThreadContext context, String name, IRubyObject arg) { - return RuntimeHelpers.invoke(context, this, name, arg); - } - - /** - * Will invoke a named method with the supplied arguments and no - * block with functional invocation. - */ - public final IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args) { - return RuntimeHelpers.invoke(context, this, name, args); - } - - /** - * Will invoke a named method with the supplied arguments and - * supplied block with functional invocation. - */ - public final IRubyObject callMethod(ThreadContext context, String name, IRubyObject[] args, Block block) { - return RuntimeHelpers.invoke(context, this, name, args, block); - } - - /** - * Will invoke an indexed method with the no arguments and no - * block. - */ - public final IRubyObject callMethod(ThreadContext context, int methodIndex, String name) { - return RuntimeHelpers.invoke(context, this, name); - } - - /** - * Will invoke an indexed method with the one argument and no - * block with a functional invocation. - */ - public final IRubyObject callMethod(ThreadContext context, int methodIndex, String name, IRubyObject arg) { - return RuntimeHelpers.invoke(context, this, name, arg, Block.NULL_BLOCK); - } - - /** - * Call the Ruby initialize method with the supplied arguments and block. - */ - public final void callInit(IRubyObject[] args, Block block) { - callMethod(getRuntime().getCurrentContext(), "initialize", args, block); - } - - /** rb_to_id - * - * Will try to convert this object to a String using the Ruby - * "to_str" if the object isn't already a String. If this still - * doesn't work, will throw a Ruby TypeError. - * - */ - public String asJavaString() { - IRubyObject asString = checkStringType(); - if(!asString.isNil()) return ((RubyString)asString).asJavaString(); - throw getRuntime().newTypeError(inspect().toString() + " is not a symbol"); - } - - /** - * Tries to convert this object to a Ruby Array using the "to_ary" - * method. - */ - public RubyArray convertToArray() { - return (RubyArray) TypeConverter.convertToType(this, getRuntime().getArray(), MethodIndex.TO_ARY, "to_ary"); - } - - /** - * Tries to convert this object to a Ruby Hash using the "to_hash" - * method. - */ - public RubyHash convertToHash() { - return (RubyHash)TypeConverter.convertToType(this, getRuntime().getHash(), MethodIndex.TO_HASH, "to_hash"); - } - - /** - * Tries to convert this object to a Ruby Float using the "to_f" - * method. - */ - public RubyFloat convertToFloat() { - return (RubyFloat) TypeConverter.convertToType(this, getRuntime().getFloat(), MethodIndex.TO_F, "to_f"); - } - - /** - * Tries to convert this object to a Ruby Integer using the "to_int" - * method. - */ - public RubyInteger convertToInteger() { - return convertToInteger(MethodIndex.TO_INT, "to_int"); - } - - /** - * Tries to convert this object to a Ruby Integer using the - * supplied conversion method. - */ - public RubyInteger convertToInteger(int convertMethodIndex, String convertMethod) { - IRubyObject val = TypeConverter.convertToType(this, getRuntime().getInteger(), convertMethodIndex, convertMethod, true); - if (!(val instanceof RubyInteger)) throw getRuntime().newTypeError(getMetaClass().getName() + "#" + convertMethod + " should return Integer"); - return (RubyInteger)val; - } - - /** - * Tries to convert this object to a Ruby String using the - * "to_str" method. - */ - public RubyString convertToString() { - return (RubyString) TypeConverter.convertToType(this, getRuntime().getString(), MethodIndex.TO_STR, "to_str"); - } - - /** - * Tries to convert this object to the specified Ruby type, using - * a specific conversion method. - */ - public final IRubyObject convertToType(RubyClass target, int convertMethodIndex) { - return TypeConverter.convertToType(this, target, convertMethodIndex, (String)MethodIndex.NAMES.get(convertMethodIndex)); - } - - /** rb_obj_as_string - * - * First converts this object into a String using the "to_s" - * method, infects it with the current taint and returns it. If - * to_s doesn't return a Ruby String, {@link #anyToString} is used - * instead. - */ - public RubyString asString() { - IRubyObject str = RuntimeHelpers.invoke(getRuntime().getCurrentContext(), this, "to_s"); - - if (!(str instanceof RubyString)) return (RubyString)anyToString(); - if (isTaint()) str.setTaint(true); - return (RubyString) str; - } - - /** rb_check_string_type - * - * Tries to return a coerced string representation of this object, - * using "to_str". If that returns something other than a String - * or nil, an empty String will be returned. - * - */ - public IRubyObject checkStringType() { - IRubyObject str = TypeConverter.convertToTypeWithCheck(this, getRuntime().getString(), MethodIndex.TO_STR, "to_str"); - if(!str.isNil() && !(str instanceof RubyString)) { - str = RubyString.newEmptyString(getRuntime()); - } - return str; - } - - /** rb_check_array_type - * - * Returns the result of trying to convert this object to an Array - * with "to_ary". - */ - public IRubyObject checkArrayType() { - return TypeConverter.convertToTypeWithCheck(this, getRuntime().getArray(), MethodIndex.TO_ARY, "to_ary"); - } - - /** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */ - @Deprecated - public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject[] args, Block block) { - if (block.isGiven()) { - if (args.length > 0) throw getRuntime().newArgumentError(args.length, 0); - - return yieldUnder(context, mod, block); - } - - if (args.length == 0) { - throw getRuntime().newArgumentError("block not supplied"); - } else if (args.length > 3) { - String lastFuncName = context.getFrameName(); - throw getRuntime().newArgumentError( - "wrong # of arguments: " + lastFuncName + "(src) or " + lastFuncName + "{..}"); - } - - // We just want the TypeError if the argument doesn't convert to a String (JRUBY-386) - RubyString evalStr; - if (args[0] instanceof RubyString) { - evalStr = (RubyString)args[0]; - } else { - evalStr = args[0].convertToString(); - } - - String file; - int line; - if (args.length > 1) { - file = args[1].convertToString().asJavaString(); - if (args.length > 2) { - line = (int)(args[2].convertToInteger().getLongValue() - 1); - } else { - line = 0; - } - } else { - file = "(eval)"; - line = 0; - } - - return evalUnder(context, mod, evalStr, file, line); - } - - /** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */ - public IRubyObject specificEval(ThreadContext context, RubyModule mod, Block block) { - if (block.isGiven()) { - return yieldUnder(context, mod, block); - } else { - throw context.getRuntime().newArgumentError("block not supplied"); - } - } - - /** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */ - public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject arg, Block block) { - if (block.isGiven()) throw context.getRuntime().newArgumentError(1, 0); - - // We just want the TypeError if the argument doesn't convert to a String (JRUBY-386) - RubyString evalStr; - if (arg instanceof RubyString) { - evalStr = (RubyString)arg; - } else { - evalStr = arg.convertToString(); - } - - String file = "(eval)"; - int line = 0; - - return evalUnder(context, mod, evalStr, file, line); - } - - /** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */ - public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject arg0, IRubyObject arg1, Block block) { - if (block.isGiven()) throw context.getRuntime().newArgumentError(2, 0); - - // We just want the TypeError if the argument doesn't convert to a String (JRUBY-386) - RubyString evalStr; - if (arg0 instanceof RubyString) { - evalStr = (RubyString)arg0; - } else { - evalStr = arg0.convertToString(); - } - - String file = arg1.convertToString().asJavaString(); - int line = 0; - - return evalUnder(context, mod, evalStr, file, line); - } - - /** specific_eval - * - * Evaluates the block or string inside of the context of this - * object, using the supplied arguments. If a block is given, this - * will be yielded in the specific context of this object. If no - * block is given then a String-like object needs to be the first - * argument, and this string will be evaluated. Second and third - * arguments in the args-array is optional, but can contain the - * filename and line of the string under evaluation. - */ - public IRubyObject specificEval(ThreadContext context, RubyModule mod, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - if (block.isGiven()) throw context.getRuntime().newArgumentError(2, 0); - - // We just want the TypeError if the argument doesn't convert to a String (JRUBY-386) - RubyString evalStr; - if (arg0 instanceof RubyString) { - evalStr = (RubyString)arg0; - } else { - evalStr = arg0.convertToString(); - } - - String file = arg1.convertToString().asJavaString(); - int line = (int)(arg2.convertToInteger().getLongValue() - 1); - - return evalUnder(context, mod, evalStr, file, line); - } - - /** - * Evaluates the string src with self set to the current object, - * using the module under as the context. - * @deprecated Call with an int line number and String file - */ - public IRubyObject evalUnder(final ThreadContext context, RubyModule under, IRubyObject src, IRubyObject file, IRubyObject line) { - return evalUnder(context, under, src.convertToString(), file.convertToString().toString(), (int) (line.convertToInteger().getLongValue() - 1)); - } - - /** - * Evaluates the string src with self set to the current object, - * using the module under as the context. - */ - public IRubyObject evalUnder(final ThreadContext context, RubyModule under, RubyString src, String file, int line) { - Visibility savedVisibility = context.getCurrentVisibility(); - context.setCurrentVisibility(Visibility.PUBLIC); - context.preExecuteUnder(under, Block.NULL_BLOCK); - try { - return ASTInterpreter.evalSimple(context, this, src, - file, line); - } finally { - context.postExecuteUnder(); - context.setCurrentVisibility(savedVisibility); - } - } - - /** - * Will yield to the specific block changing the self to be the - * current object instead of the self that is part of the frame - * saved in the block frame. This method is the basis for the Ruby - * instance_eval and module_eval methods. The arguments sent in to - * it in the args array will be yielded to the block. This makes - * it possible to emulate both instance_eval and instance_exec - * with this implementation. - */ - private IRubyObject yieldUnder(final ThreadContext context, RubyModule under, IRubyObject[] args, Block block) { - context.preExecuteUnder(under, block); - - Visibility savedVisibility = block.getBinding().getVisibility(); - block.getBinding().setVisibility(Visibility.PUBLIC); - - try { - IRubyObject valueInYield; - boolean aValue; - if (args.length == 1) { - valueInYield = args[0]; - aValue = false; - } else { - valueInYield = RubyArray.newArrayNoCopy(context.getRuntime(), args); - aValue = true; - } - - // FIXME: This is an ugly hack to resolve JRUBY-1381; I'm not proud of it - block = block.cloneBlock(); - block.getBinding().setSelf(RubyObject.this); - block.getBinding().getFrame().setSelf(RubyObject.this); - // end hack - - return block.yield(context, valueInYield, RubyObject.this, context.getRubyClass(), aValue); - //TODO: Should next and return also catch here? - } catch (JumpException.BreakJump bj) { - return (IRubyObject) bj.getValue(); - } finally { - block.getBinding().setVisibility(savedVisibility); - - context.postExecuteUnder(); - } - } - - /** - * Will yield to the specific block changing the self to be the - * current object instead of the self that is part of the frame - * saved in the block frame. This method is the basis for the Ruby - * instance_eval and module_eval methods. The arguments sent in to - * it in the args array will be yielded to the block. This makes - * it possible to emulate both instance_eval and instance_exec - * with this implementation. - */ - private IRubyObject yieldUnder(final ThreadContext context, RubyModule under, Block block) { - context.preExecuteUnder(under, block); - - Visibility savedVisibility = block.getBinding().getVisibility(); - block.getBinding().setVisibility(Visibility.PUBLIC); - - try { - // FIXME: This is an ugly hack to resolve JRUBY-1381; I'm not proud of it - block = block.cloneBlock(); - block.getBinding().setSelf(RubyObject.this); - block.getBinding().getFrame().setSelf(RubyObject.this); - // end hack - - return block.yield(context, this, this, context.getRubyClass(), false); - //TODO: Should next and return also catch here? - } catch (JumpException.BreakJump bj) { - return (IRubyObject) bj.getValue(); - } finally { - block.getBinding().setVisibility(savedVisibility); - - context.postExecuteUnder(); - } - } - - // Methods of the Object class (rb_obj_*): - - /** rb_obj_equal - * - * Will by default use identity equality to compare objects. This - * follows the Ruby semantics. - */ - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(ThreadContext context, IRubyObject obj) { - return this == obj ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - /** rb_obj_equal - * - * Will use Java identity equality. - */ - @JRubyMethod(name = "equal?", required = 1) - public IRubyObject equal_p(ThreadContext context, IRubyObject obj) { - return this == obj ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - /** method used for Hash key comparison (specialized for String, Symbol and Fixnum) - * - * Will by default just call the Ruby method "eql?" - */ - public boolean eql(IRubyObject other) { - return callMethod(getRuntime().getCurrentContext(), MethodIndex.EQL_P, "eql?", other).isTrue(); - } - - /** rb_obj_equal - * - * Just like "==" and "equal?", "eql?" will use identity equality for Object. - */ - @JRubyMethod(name = "eql?", required = 1) - public IRubyObject eql_p(IRubyObject obj) { - return this == obj ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - /** rb_equal - * - * The Ruby "===" method is used by default in case/when - * statements. The Object implementation first checks Java identity - * equality and then calls the "==" method too. - */ - @JRubyMethod(name = "===", required = 1) - public IRubyObject op_eqq(ThreadContext context, IRubyObject other) { - return context.getRuntime().newBoolean(equalInternal(context, this, other)); - } - - /** - * Helper method for checking equality, first using Java identity - * equality, and then calling the "==" method. - */ - protected static boolean equalInternal(final ThreadContext context, final IRubyObject that, final IRubyObject other){ - return that == other || that.callMethod(context, MethodIndex.EQUALEQUAL, "==", other).isTrue(); - } - - /** - * Helper method for checking equality, first using Java identity - * equality, and then calling the "eql?" method. - */ - protected static boolean eqlInternal(final ThreadContext context, final IRubyObject that, final IRubyObject other){ - return that == other || that.callMethod(context, MethodIndex.EQL_P, "eql?", other).isTrue(); - } - - /** rb_obj_init_copy - * - * Initializes this object as a copy of the original, that is the - * parameter to this object. Will make sure that the argument - * actually has the same real class as this object. It shouldn't - * be possible to initialize an object with something totally - * different. - */ - @JRubyMethod(name = "initialize_copy", required = 1, visibility = Visibility.PRIVATE) - public IRubyObject initialize_copy(IRubyObject original) { - if (this == original) return this; - checkFrozen(); - - if (getMetaClass().getRealClass() != original.getMetaClass().getRealClass()) { - throw getRuntime().newTypeError("initialize_copy should take same class object"); - } - - return this; - } - - /** obj_respond_to - * - * respond_to?( aSymbol, includePriv=false ) -> true or false - * - * Returns true if this object responds to the given method. Private - * methods are included in the search only if the optional second - * parameter evaluates to true. - * - * @return true if this responds to the given method - * - * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 - * - * Going back to splitting according to method arity. MRI is wrong - * about most of these anyway, and since we have arity splitting - * in both the compiler and the interpreter, the performance - * benefit is important for this method. - */ - @JRubyMethod(name = "respond_to?") - public RubyBoolean respond_to_p(IRubyObject mname) { - String name = mname.asJavaString(); - return getRuntime().newBoolean(getMetaClass().isMethodBound(name, true)); - } - - /** obj_respond_to - * - * respond_to?( aSymbol, includePriv=false ) -> true or false - * - * Returns true if this object responds to the given method. Private - * methods are included in the search only if the optional second - * parameter evaluates to true. - * - * @return true if this responds to the given method - * - * !!! For some reason MRI shows the arity of respond_to? as -1, when it should be -2; that's why this is rest instead of required, optional = 1 - * - * Going back to splitting according to method arity. MRI is wrong - * about most of these anyway, and since we have arity splitting - * in both the compiler and the interpreter, the performance - * benefit is important for this method. - */ - @JRubyMethod(name = "respond_to?") - public RubyBoolean respond_to_p(IRubyObject mname, IRubyObject includePrivate) { - String name = mname.asJavaString(); - return getRuntime().newBoolean(getMetaClass().isMethodBound(name, !includePrivate.isTrue())); - } - - /** rb_obj_id - * - * Return the internal id of an object. - * - * FIXME: Should this be renamed to match its ruby name? - */ - @JRubyMethod(name = {"object_id", "__id__"}) - public synchronized IRubyObject id() { - return getRuntime().newFixnum(getRuntime().getObjectSpace().idOf(this)); - } - - /** rb_obj_id_obsolete - * - * Old id version. This one is bound to the "id" name and will emit a deprecation warning. - */ - @JRubyMethod(name = "id") - public synchronized IRubyObject id_deprecated() { - getRuntime().getWarnings().warn(ID.DEPRECATED_METHOD, "Object#id will be deprecated; use Object#object_id", "Object#id", "Object#object_id"); - return id(); - } - - /** rb_obj_id - * - * Will return the hash code of this object. In comparison to MRI, - * this method will use the Java identity hash code instead of - * using rb_obj_id, since the usage of id in JRuby will incur the - * cost of some. ObjectSpace maintenance. - */ - @JRubyMethod(name = "hash") - public RubyFixnum hash() { - return getRuntime().newFixnum(super.hashCode()); - } - - /** - * Override the Object#hashCode method to make sure that the Ruby - * hash is actually used as the hashcode for Ruby objects. If the - * Ruby "hash" method doesn't return a number, the Object#hashCode - * implementation will be used instead. - */ - @Override - public int hashCode() { - IRubyObject hashValue = callMethod(getRuntime().getCurrentContext(), MethodIndex.HASH, "hash"); - - if (hashValue instanceof RubyFixnum) return (int) RubyNumeric.fix2long(hashValue); - - return super.hashCode(); - } - - /** rb_obj_class - * - * Returns the real class of this object, excluding any - * singleton/meta class in the inheritance chain. - */ - @JRubyMethod(name = "class") - public RubyClass type() { - return getMetaClass().getRealClass(); - } - - /** rb_obj_type - * - * The deprecated version of type, that emits a deprecation - * warning. - */ - @JRubyMethod(name = "type") - public RubyClass type_deprecated() { - getRuntime().getWarnings().warn(ID.DEPRECATED_METHOD, "Object#type is deprecated; use Object#class", "Object#type", "Object#class"); - return type(); - } - - /** rb_obj_clone - * - * This method should be overridden only by: Proc, Method, - * UnboundedMethod, Binding. It will use the defined allocated of - * the object, then clone the singleton class, taint the object, - * call initCopy and then copy frozen state. - */ - @JRubyMethod(name = "clone", frame = true) - public IRubyObject rbClone() { - if (isImmediate()) throw getRuntime().newTypeError("can't clone " + getMetaClass().getName()); - - // We're cloning ourselves, so we know the result should be a RubyObject - RubyObject clone = (RubyObject)getMetaClass().getRealClass().allocate(); - clone.setMetaClass(getSingletonClassClone()); - if (isTaint()) clone.setTaint(true); - - initCopy(clone, this); - - if (isFrozen()) clone.setFrozen(true); - return clone; - } - - /** rb_obj_dup - * - * This method should be overridden only by: Proc - * - * Will allocate a new instance of the real class of this object, - * and then initialize that copy. It's different from {@link - * #rbClone} in that it doesn't copy the singleton class. - */ - @JRubyMethod(name = "dup") - public IRubyObject dup() { - if (isImmediate()) throw getRuntime().newTypeError("can't dup " + getMetaClass().getName()); - - IRubyObject dup = getMetaClass().getRealClass().allocate(); - if (isTaint()) dup.setTaint(true); - - initCopy(dup, this); - - return dup; - } - - /** - * Lots of MRI objects keep their state in non-lookupable ivars - * (e:g. Range, Struct, etc). This method is responsible for - * dupping our java field equivalents - */ - protected void copySpecialInstanceVariables(IRubyObject clone) { - } - - /** rb_obj_display - * - * call-seq: - * obj.display(port=$>) => nil - * - * Prints <i>obj</i> on the given port (default <code>$></code>). - * Equivalent to: - * - * def display(port=$>) - * port.write self - * end - * - * For example: - * - * 1.display - * "cat".display - * [ 4, 5, 6 ].display - * puts - * - * <em>produces:</em> - * - * 1cat456 - * - */ - @JRubyMethod(name = "display", optional = 1) - public IRubyObject display(ThreadContext context, IRubyObject[] args) { - IRubyObject port = args.length == 0 ? context.getRuntime().getGlobalVariables().get("$>") : args[0]; - - port.callMethod(context, "write", this); - - return context.getRuntime().getNil(); - } - - /** rb_obj_tainted - * - * call-seq: - * obj.tainted? => true or false - * - * Returns <code>true</code> if the object is tainted. - * - */ - @JRubyMethod(name = "tainted?") - public RubyBoolean tainted_p(ThreadContext context) { - return context.getRuntime().newBoolean(isTaint()); - } - - /** rb_obj_taint - * - * call-seq: - * obj.taint -> obj - * - * Marks <i>obj</i> as tainted---if the <code>$SAFE</code> level is - * set appropriately, many method calls which might alter the running - * programs environment will refuse to accept tainted strings. - */ - @JRubyMethod(name = "taint") - public IRubyObject taint(ThreadContext context) { - taint(context.getRuntime()); - return this; - } - - private void taint(Ruby runtime) { - runtime.secure(4); - if (!isTaint()) { - testFrozen("object"); - setTaint(true); - } - } - - /** rb_obj_untaint - * - * call-seq: - * obj.untaint => obj - * - * Removes the taint from <i>obj</i>. - * - * Only callable in if more secure than 3. - */ - @JRubyMethod(name = "untaint") - public IRubyObject untaint(ThreadContext context) { - context.getRuntime().secure(3); - - if (isTaint()) { - testFrozen("object"); - setTaint(false); - } - - return this; - } - - /** rb_obj_freeze - * - * call-seq: - * obj.freeze => obj - * - * Prevents further modifications to <i>obj</i>. A - * <code>TypeError</code> will be raised if modification is attempted. - * There is no way to unfreeze a frozen object. See also - * <code>Object#frozen?</code>. - * - * a = [ "a", "b", "c" ] - * a.freeze - * a << "z" - * - * <em>produces:</em> - * - * prog.rb:3:in `<<': can't modify frozen array (TypeError) - * from prog.rb:3 - */ - @JRubyMethod(name = "freeze") - public IRubyObject freeze(ThreadContext context) { - if ((flags & FROZEN_F) == 0) { - if (context.getRuntime().getSafeLevel() >= 4 && isTaint()) { - throw context.getRuntime().newSecurityError("Insecure: can't freeze object"); - } - flags |= FROZEN_F; - } - return this; - } - - /** rb_obj_frozen_p - * - * call-seq: - * obj.frozen? => true or false - * - * Returns the freeze status of <i>obj</i>. - * - * a = [ "a", "b", "c" ] - * a.freeze #=> ["a", "b", "c"] - * a.frozen? #=> true - */ - @JRubyMethod(name = "frozen?") - public RubyBoolean frozen_p(ThreadContext context) { - return context.getRuntime().newBoolean(isFrozen()); - } - - /** inspect_obj - * - * The internal helper method that takes care of the part of the - * inspection that inspects instance variables. - */ - private StringBuilder inspectObj(StringBuilder part) { - ThreadContext context = getRuntime().getCurrentContext(); - String sep = ""; - - for (Variable<IRubyObject> ivar : getInstanceVariableList()) { - part.append(sep).append(" ").append(ivar.getName()).append("="); - part.append(ivar.getValue().callMethod(context, "inspect")); - sep = ","; - } - part.append(">"); - return part; - } - - /** rb_inspect - * - * The internal helper that ensures a RubyString instance is returned - * so dangerous casting can be omitted - * Prefered over callMethod(context, "inspect") - */ - static RubyString inspect(ThreadContext context, IRubyObject object) { - return RubyString.objAsString(context, object.callMethod(context, "inspect")); - } - - /** rb_obj_inspect - * - * call-seq: - * obj.inspect => string - * - * Returns a string containing a human-readable representation of - * <i>obj</i>. If not overridden, uses the <code>to_s</code> method to - * generate the string. - * - * [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" - * Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003" - */ - @JRubyMethod(name = "inspect") - public IRubyObject inspect() { - Ruby runtime = getRuntime(); - if ((!isImmediate()) && - // TYPE(obj) == T_OBJECT - !(this instanceof RubyClass) && - this != runtime.getObject() && - this != runtime.getModule() && - !(this instanceof RubyModule) && - // TODO: should have #hasInstanceVariables method, though - // this will work here: - hasVariables()) { - - StringBuilder part = new StringBuilder(); - String cname = getMetaClass().getRealClass().getName(); - part.append("#<").append(cname).append(":0x"); - part.append(Integer.toHexString(System.identityHashCode(this))); - - if (runtime.isInspecting(this)) { - /* 6:tags 16:addr 1:eos */ - part.append(" ...>"); - return runtime.newString(part.toString()); - } - try { - runtime.registerInspecting(this); - return runtime.newString(inspectObj(part).toString()); - } finally { - runtime.unregisterInspecting(this); - } - } - - if (isNil()) return RubyNil.inspect(this); - return RuntimeHelpers.invoke(runtime.getCurrentContext(), this, "to_s"); - } - - /** rb_obj_is_instance_of - * - * call-seq: - * obj.instance_of?(class) => true or false - * - * Returns <code>true</code> if <i>obj</i> is an instance of the given - * class. See also <code>Object#kind_of?</code>. - */ - @JRubyMethod(name = "instance_of?", required = 1) - public RubyBoolean instance_of_p(ThreadContext context, IRubyObject type) { - if (type() == type) { - return context.getRuntime().getTrue(); - } else if (!(type instanceof RubyModule)) { - throw context.getRuntime().newTypeError("class or module required"); - } else { - return context.getRuntime().getFalse(); - } - } - - - /** rb_obj_is_kind_of - * - * call-seq: - * obj.is_a?(class) => true or false - * obj.kind_of?(class) => true or false - * - * Returns <code>true</code> if <i>class</i> is the class of - * <i>obj</i>, or if <i>class</i> is one of the superclasses of - * <i>obj</i> or modules included in <i>obj</i>. - * - * module M; end - * class A - * include M - * end - * class B < A; end - * class C < B; end - * b = B.new - * b.instance_of? A #=> false - * b.instance_of? B #=> true - * b.instance_of? C #=> false - * b.instance_of? M #=> false - * b.kind_of? A #=> true - * b.kind_of? B #=> true - * b.kind_of? C #=> false - * b.kind_of? M #=> true - */ - @JRubyMethod(name = {"kind_of?", "is_a?"}, required = 1) - public RubyBoolean kind_of_p(ThreadContext context, IRubyObject type) { - // TODO: Generalize this type-checking code into IRubyObject helper. - if (!(type instanceof RubyModule)) { - // TODO: newTypeError does not offer enough for ruby error string... - throw context.getRuntime().newTypeError("class or module required"); - } - - return context.getRuntime().newBoolean(((RubyModule)type).isInstance(this)); - } - - /** rb_obj_methods - * - * call-seq: - * obj.methods => array - * - * Returns a list of the names of methods publicly accessible in - * <i>obj</i>. This will include all the methods accessible in - * <i>obj</i>'s ancestors. - * - * class Klass - * def kMethod() - * end - * end - * k = Klass.new - * k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?", - * "class", "instance_variable_set", - * "methods", "extend", "__send__", "instance_eval"] - * k.methods.length #=> 42 - */ - @JRubyMethod(name = "methods", optional = 1) - public IRubyObject methods(ThreadContext context, IRubyObject[] args) { - boolean all = true; - if (args.length == 1) { - all = args[0].isTrue(); - } - - RubyArray singletonMethods = null; - if (getMetaClass().isSingleton()) { - singletonMethods = - getMetaClass().instance_methods(new IRubyObject[] {context.getRuntime().getFalse()}); - if (all) { - singletonMethods.concat(getMetaClass().getSuperClass().instance_methods(new IRubyObject[] {context.getRuntime().getTrue()})); - } - } else { - if (all) { - singletonMethods = getMetaClass().instance_methods(new IRubyObject[] {context.getRuntime().getTrue()}); - } else { - singletonMethods = context.getRuntime().newEmptyArray(); - } - } - - return singletonMethods; - } - - /** rb_obj_public_methods - * - * call-seq: - * obj.public_methods(all=true) => array - * - * Returns the list of public methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - */ - @JRubyMethod(name = "public_methods", optional = 1) - public IRubyObject public_methods(ThreadContext context, IRubyObject[] args) { - if (args.length == 0) { - args = new IRubyObject[] { context.getRuntime().getTrue() }; - } - - return getMetaClass().public_instance_methods(args); - } - - /** rb_obj_protected_methods - * - * call-seq: - * obj.protected_methods(all=true) => array - * - * Returns the list of protected methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - * - * Internally this implementation uses the - * {@link RubyModule#protected_instance_methods} method. - */ - @JRubyMethod(name = "protected_methods", optional = 1) - public IRubyObject protected_methods(ThreadContext context, IRubyObject[] args) { - if (args.length == 0) { - args = new IRubyObject[] { context.getRuntime().getTrue() }; - } - - return getMetaClass().protected_instance_methods(args); - } - - /** rb_obj_private_methods - * - * call-seq: - * obj.private_methods(all=true) => array - * - * Returns the list of private methods accessible to <i>obj</i>. If - * the <i>all</i> parameter is set to <code>false</code>, only those methods - * in the receiver will be listed. - * - * Internally this implementation uses the - * {@link RubyModule#private_instance_methods} method. - */ - @JRubyMethod(name = "private_methods", optional = 1) - public IRubyObject private_methods(ThreadContext context, IRubyObject[] args) { - if (args.length == 0) { - args = new IRubyObject[] { context.getRuntime().getTrue() }; - } - - return getMetaClass().private_instance_methods(args); - } - - /** rb_obj_singleton_methods - * - * call-seq: - * obj.singleton_methods(all=true) => array - * - * Returns an array of the names of singleton methods for <i>obj</i>. - * If the optional <i>all</i> parameter is true, the list will include - * methods in modules included in <i>obj</i>. - * - * module Other - * def three() end - * end - * - * class Single - * def Single.four() end - * end - * - * a = Single.new - * - * def a.one() - * end - * - * class << a - * include Other - * def two() - * end - * end - * - * Single.singleton_methods #=> ["four"] - * a.singleton_methods(false) #=> ["two", "one"] - * a.singleton_methods #=> ["two", "one", "three"] - */ - // TODO: This is almost RubyModule#instance_methods on the metaClass. Perhaps refactor. - @JRubyMethod(name = "singleton_methods", optional = 1) - public RubyArray singleton_methods(ThreadContext context, IRubyObject[] args) { - boolean all = true; - if(args.length == 1) { - all = args[0].isTrue(); - } - - RubyArray singletonMethods; - if (getMetaClass().isSingleton()) { - singletonMethods = getMetaClass().instance_methods(new IRubyObject[] {context.getRuntime().getFalse()}); - if (all) { - RubyClass superClass = getMetaClass().getSuperClass(); - while (superClass.isIncluded()) { - singletonMethods.concat(superClass.instance_methods(new IRubyObject[] {context.getRuntime().getFalse()})); - superClass = superClass.getSuperClass(); - } - } - } else { - singletonMethods = context.getRuntime().newEmptyArray(); - } - - return singletonMethods; - } - - /** rb_obj_method - * - * call-seq: - * obj.method(sym) => method - * - * Looks up the named method as a receiver in <i>obj</i>, returning a - * <code>Method</code> object (or raising <code>NameError</code>). The - * <code>Method</code> object acts as a closure in <i>obj</i>'s object - * instance, so instance variables and the value of <code>self</code> - * remain available. - * - * class Demo - * def initialize(n) - * @iv = n - * end - * def hello() - * "Hello, @iv = #{@iv}" - * end - * end - * - * k = Demo.new(99) - * m = k.method(:hello) - * m.call #=> "Hello, @iv = 99" - * - * l = Demo.new('Fred') - * m = l.method("hello") - * m.call #=> "Hello, @iv = Fred" - */ - @JRubyMethod(name = "method", required = 1) - public IRubyObject method(IRubyObject symbol) { - return getMetaClass().newMethod(this, symbol.asJavaString(), true); - } - - /** - * Internal method that helps to convert any object into the - * format of a class name and a hex string inside of #<>. - */ - public IRubyObject anyToString() { - String cname = getMetaClass().getRealClass().getName(); - /* 6:tags 16:addr 1:eos */ - RubyString str = getRuntime().newString("#<" + cname + ":0x" + Integer.toHexString(System.identityHashCode(this)) + ">"); - str.setTaint(isTaint()); - return str; - } - - /** rb_any_to_s - * - * call-seq: - * obj.to_s => string - * - * Returns a string representing <i>obj</i>. The default - * <code>to_s</code> prints the object's class and an encoding of the - * object id. As a special case, the top-level object that is the - * initial execution context of Ruby programs returns ``main.'' - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - return anyToString(); - } - - /** rb_any_to_a - * - * call-seq: - * obj.to_a -> anArray - * - * Returns an array representation of <i>obj</i>. For objects of class - * <code>Object</code> and others that don't explicitly override the - * method, the return value is an array containing <code>self</code>. - * However, this latter behavior will soon be obsolete. - * - * self.to_a #=> -:1: warning: default `to_a' will be obsolete - * "hello".to_a #=> ["hello"] - * Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"] - * - * The default to_a method is deprecated. - */ - @JRubyMethod(name = "to_a", visibility = Visibility.PUBLIC) - public RubyArray to_a() { - getRuntime().getWarnings().warn(ID.DEPRECATED_METHOD, "default 'to_a' will be obsolete", "to_a"); - return getRuntime().newArray(this); - } - - /** rb_obj_instance_eval - * - * call-seq: - * obj.instance_eval(string [, filename [, lineno]] ) => obj - * obj.instance_eval {| | block } => obj - * - * Evaluates a string containing Ruby source code, or the given block, - * within the context of the receiver (_obj_). In order to set the - * context, the variable +self+ is set to _obj_ while - * the code is executing, giving the code access to _obj_'s - * instance variables. In the version of <code>instance_eval</code> - * that takes a +String+, the optional second and third - * parameters supply a filename and starting line number that are used - * when reporting compilation errors. - * - * class Klass - * def initialize - * @secret = 99 - * end - * end - * k = Klass.new - * k.instance_eval { @secret } #=> 99 - */ - @JRubyMethod(name = "instance_eval", frame = true) - public IRubyObject instance_eval(ThreadContext context, Block block) { - return specificEval(context, getInstanceEvalClass(), block); - } - @JRubyMethod(name = "instance_eval", frame = true) - public IRubyObject instance_eval(ThreadContext context, IRubyObject arg0, Block block) { - return specificEval(context, getInstanceEvalClass(), arg0, block); - } - @JRubyMethod(name = "instance_eval", frame = true) - public IRubyObject instance_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - return specificEval(context, getInstanceEvalClass(), arg0, arg1, block); - } - @JRubyMethod(name = "instance_eval", frame = true) - public IRubyObject instance_eval(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - return specificEval(context, getInstanceEvalClass(), arg0, arg1, arg2, block); - } - @Deprecated - public IRubyObject instance_eval(ThreadContext context, IRubyObject[] args, Block block) { - RubyModule klazz; - - if (isImmediate()) { - // Ruby uses Qnil here, we use "dummy" because we need a class - klazz = context.getRuntime().getDummy(); - } else { - klazz = getSingletonClass(); - } - - return specificEval(context, klazz, args, block); - } - - private RubyModule getInstanceEvalClass() { - if (isImmediate()) { - // Ruby uses Qnil here, we use "dummy" because we need a class - return getRuntime().getDummy(); - } else { - return getSingletonClass(); - } - } - - /** rb_obj_instance_exec - * - * call-seq: - * obj.instance_exec(arg...) {|var...| block } => obj - * - * Executes the given block within the context of the receiver - * (_obj_). In order to set the context, the variable +self+ is set - * to _obj_ while the code is executing, giving the code access to - * _obj_'s instance variables. Arguments are passed as block parameters. - * - * class Klass - * def initialize - * @secret = 99 - * end - * end - * k = Klass.new - * k.instance_exec(5) {|x| @secret+x } #=> 104 - */ - @JRubyMethod(name = "instance_exec", optional = 3, frame = true) - public IRubyObject instance_exec(ThreadContext context, IRubyObject[] args, Block block) { - if (!block.isGiven()) throw context.getRuntime().newArgumentError("block not supplied"); - - RubyModule klazz; - if (isImmediate()) { - // Ruby uses Qnil here, we use "dummy" because we need a class - klazz = context.getRuntime().getDummy(); - } else { - klazz = getSingletonClass(); - } - - return yieldUnder(context, klazz, args, block); - } - - /** rb_obj_extend - * - * call-seq: - * obj.extend(module, ...) => obj - * - * Adds to _obj_ the instance methods from each module given as a - * parameter. - * - * module Mod - * def hello - * "Hello from Mod.\n" - * end - * end - * - * class Klass - * def hello - * "Hello from Klass.\n" - * end - * end - * - * k = Klass.new - * k.hello #=> "Hello from Klass.\n" - * k.extend(Mod) #=> #<Klass:0x401b3bc8> - * k.hello #=> "Hello from Mod.\n" - */ - @JRubyMethod(name = "extend", required = 1, rest = true) - public IRubyObject extend(IRubyObject[] args) { - Ruby runtime = getRuntime(); - - // Make sure all arguments are modules before calling the callbacks - for (int i = 0; i < args.length; i++) { - if (!args[i].isModule()) throw runtime.newTypeError(args[i], runtime.getModule()); - } - - ThreadContext context = runtime.getCurrentContext(); - - // MRI extends in order from last to first - for (int i = args.length - 1; i >= 0; i--) { - args[i].callMethod(context, "extend_object", this); - args[i].callMethod(context, "extended", this); - } - return this; - } - - /** rb_obj_dummy - * - * Default initialize method. This one gets defined in some other - * place as a Ruby method. - */ - public IRubyObject initialize() { - return getRuntime().getNil(); - } - - /** rb_f_send - * - * send( aSymbol [, args ]* ) -> anObject - * - * Invokes the method identified by aSymbol, passing it any arguments - * specified. You can use __send__ if the name send clashes with an - * existing method in this object. - * - * <pre> - * class Klass - * def hello(*args) - * "Hello " + args.join(' ') - * end - * end - * - * k = Klass.new - * k.send :hello, "gentle", "readers" - * </pre> - * - * @return the result of invoking the method identified by aSymbol. - */ - @JRubyMethod(name = {"send", "__send__"}) - public IRubyObject send(ThreadContext context, Block block) { - throw context.getRuntime().newArgumentError(0, 1); - } - @JRubyMethod(name = {"send", "__send__"}) - public IRubyObject send(ThreadContext context, IRubyObject arg0, Block block) { - String name = arg0.asJavaString(); - - return getMetaClass().finvoke(context, this, name, block); - } - @JRubyMethod(name = {"send", "__send__"}) - public IRubyObject send(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - String name = arg0.asJavaString(); - - return getMetaClass().finvoke(context, this, name, arg1, block); - } - @JRubyMethod(name = {"send", "__send__"}) - public IRubyObject send(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { - String name = arg0.asJavaString(); - - return getMetaClass().finvoke(context, this, name, arg1, arg2, block); - } - @JRubyMethod(name = {"send", "__send__"}, rest = true) - public IRubyObject send(ThreadContext context, IRubyObject[] args, Block block) { - String name = args[0].asJavaString(); - int newArgsLength = args.length - 1; - - IRubyObject[] newArgs; - if (newArgsLength == 0) { - newArgs = IRubyObject.NULL_ARRAY; - } else { - newArgs = new IRubyObject[newArgsLength]; - System.arraycopy(args, 1, newArgs, 0, newArgs.length); - } - - return getMetaClass().finvoke(context, this, name, newArgs, block); - } - - /** rb_false - * - * call_seq: - * nil.nil? => true - * <anything_else>.nil? => false - * - * Only the object <i>nil</i> responds <code>true</code> to <code>nil?</code>. - */ - @JRubyMethod(name = "nil?") - public IRubyObject nil_p(ThreadContext context) { - return context.getRuntime().getFalse(); - } - - /** rb_obj_pattern_match - * - * call-seq: - * obj =~ other => false - * - * Pattern Match---Overridden by descendents (notably - * <code>Regexp</code> and <code>String</code>) to provide meaningful - * pattern-match semantics. - */ - @JRubyMethod(name = "=~", required = 1) - public IRubyObject op_match(ThreadContext context, IRubyObject arg) { - return context.getRuntime().getFalse(); - } - - public IRubyObject to_java() { - throw getRuntime().newTypeError(getMetaClass().getBaseName() + " cannot coerce to a Java type."); - } - - public IRubyObject as(Class javaClass) { - throw getRuntime().newTypeError(getMetaClass().getBaseName() + " cannot coerce to a Java type."); - } - - /** - * @see org.jruby.runtime.builtin.IRubyObject#getType() - */ - public RubyClass getType() { - return type(); - } - - /** - * @see org.jruby.runtime.builtin.IRubyObject#dataWrapStruct() - */ - public synchronized void dataWrapStruct(Object obj) { - this.dataStruct = obj; - } - - /** - * @see org.jruby.runtime.builtin.IRubyObject#dataGetStruct() - */ - public synchronized Object dataGetStruct() { - return dataStruct; - } - - /** - * Adds the specified object as a finalizer for this object. - */ - public void addFinalizer(IRubyObject finalizer) { - if (this.finalizer == null) { - this.finalizer = new Finalizer(getRuntime().getObjectSpace().idOf(this)); - getRuntime().addFinalizer(this.finalizer); - } - this.finalizer.addFinalizer(finalizer); - } - - /** - * Remove all the finalizers for this object. - */ - public void removeFinalizers() { - if (finalizer != null) { - finalizer.removeFinalizers(); - finalizer = null; - getRuntime().removeFinalizer(this.finalizer); - } - } - - - // - // INSTANCE VARIABLE RUBY METHODS - // - - /** rb_obj_ivar_defined - * - * call-seq: - * obj.instance_variable_defined?(symbol) => true or false - * - * Returns <code>true</code> if the given instance variable is - * defined in <i>obj</i>. - * - * class Fred - * def initialize(p1, p2) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99) - * fred.instance_variable_defined?(:@a) #=> true - * fred.instance_variable_defined?("@b") #=> true - * fred.instance_variable_defined?("@c") #=> false - */ - @JRubyMethod(name = "instance_variable_defined?", required = 1) - public IRubyObject instance_variable_defined_p(ThreadContext context, IRubyObject name) { - if (variableTableContains(validateInstanceVariable(name.asJavaString()))) { - return context.getRuntime().getTrue(); - } - return context.getRuntime().getFalse(); - } - - /** rb_obj_ivar_get - * - * call-seq: - * obj.instance_variable_get(symbol) => obj - * - * Returns the value of the given instance variable, or nil if the - * instance variable is not set. The <code>@</code> part of the - * variable name should be included for regular instance - * variables. Throws a <code>NameError</code> exception if the - * supplied symbol is not valid as an instance variable name. - * - * class Fred - * def initialize(p1, p2) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99) - * fred.instance_variable_get(:@a) #=> "cat" - * fred.instance_variable_get("@b") #=> 99 - */ - @JRubyMethod(name = "instance_variable_get", required = 1) - public IRubyObject instance_variable_get(ThreadContext context, IRubyObject name) { - IRubyObject value; - if ((value = variableTableFetch(validateInstanceVariable(name.asJavaString()))) != null) { - return value; - } - return context.getRuntime().getNil(); - } - - /** rb_obj_ivar_set - * - * call-seq: - * obj.instance_variable_set(symbol, obj) => obj - * - * Sets the instance variable names by <i>symbol</i> to - * <i>object</i>, thereby frustrating the efforts of the class's - * author to attempt to provide proper encapsulation. The variable - * did not have to exist prior to this call. - * - * class Fred - * def initialize(p1, p2) - * @a, @b = p1, p2 - * end - * end - * fred = Fred.new('cat', 99) - * fred.instance_variable_set(:@a, 'dog') #=> "dog" - * fred.instance_variable_set(:@c, 'cat') #=> "cat" - * fred.inspect #=> "#<Fred:0x401b3da8 @a=\"dog\", @b=99, @c=\"cat\">" - */ - @JRubyMethod(name = "instance_variable_set", required = 2) - public IRubyObject instance_variable_set(IRubyObject name, IRubyObject value) { - ensureInstanceVariablesSettable(); - return variableTableStore(validateInstanceVariable(name.asJavaString()), value); - } - - /** rb_obj_remove_instance_variable - * - * call-seq: - * obj.remove_instance_variable(symbol) => obj - * - * Removes the named instance variable from <i>obj</i>, returning that - * variable's value. - * - * class Dummy - * attr_reader :var - * def initialize - * @var = 99 - * end - * def remove - * remove_instance_variable(:@var) - * end - * end - * d = Dummy.new - * d.var #=> 99 - * d.remove #=> 99 - * d.var #=> nil - */ - @JRubyMethod(name = "remove_instance_variable", required = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject remove_instance_variable(ThreadContext context, IRubyObject name, Block block) { - ensureInstanceVariablesSettable(); - IRubyObject value; - if ((value = variableTableRemove(validateInstanceVariable(name.asJavaString()))) != null) { - return value; - } - throw context.getRuntime().newNameError("instance variable " + name.asJavaString() + " not defined", name.asJavaString()); - } - - /** rb_obj_instance_variables - * - * call-seq: - * obj.instance_variables => array - * - * Returns an array of instance variable names for the receiver. Note - * that simply defining an accessor does not create the corresponding - * instance variable. - * - * class Fred - * attr_accessor :a1 - * def initialize - * @iv = 3 - * end - * end - * Fred.new.instance_variables #=> ["@iv"] - */ - @JRubyMethod(name = "instance_variables") - public RubyArray instance_variables(ThreadContext context) { - Ruby runtime = context.getRuntime(); - List<String> nameList = getInstanceVariableNameList(); - - RubyArray array = runtime.newArray(nameList.size()); - - for (String name : nameList) { - array.append(runtime.newString(name)); - } - - return array; - } - - // - // INSTANCE VARIABLE API METHODS - // - - /** - * Dummy method to avoid a cast, and to avoid polluting the - * IRubyObject interface with all the instance variable management - * methods. - */ - public InstanceVariables getInstanceVariables() { - return this; - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#hasInstanceVariable - */ - public boolean hasInstanceVariable(String name) { - assert IdUtil.isInstanceVariable(name); - return variableTableContains(name); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#fastHasInstanceVariable - */ - public boolean fastHasInstanceVariable(String internedName) { - assert IdUtil.isInstanceVariable(internedName); - return variableTableFastContains(internedName); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariable - */ - public IRubyObject getInstanceVariable(String name) { - assert IdUtil.isInstanceVariable(name); - return variableTableFetch(name); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#fastGetInstanceVariable - */ - public IRubyObject fastGetInstanceVariable(String internedName) { - assert IdUtil.isInstanceVariable(internedName); - return variableTableFastFetch(internedName); - } - - /** rb_iv_set / rb_ivar_set - * - * @see org.jruby.runtime.builtin.InstanceVariables#setInstanceVariable - */ - public IRubyObject setInstanceVariable(String name, IRubyObject value) { - assert IdUtil.isInstanceVariable(name) && value != null; - ensureInstanceVariablesSettable(); - return variableTableStore(name, value); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#fastSetInstanceVariable - */ - public IRubyObject fastSetInstanceVariable(String internedName, IRubyObject value) { - assert IdUtil.isInstanceVariable(internedName) && value != null; - ensureInstanceVariablesSettable(); - return variableTableFastStore(internedName, value); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#removeInstanceVariable - */ - public IRubyObject removeInstanceVariable(String name) { - assert IdUtil.isInstanceVariable(name); - ensureInstanceVariablesSettable(); - return variableTableRemove(name); - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariableList - */ - public List<Variable<IRubyObject>> getInstanceVariableList() { - VariableTableEntry[] table = variableTableGetTable(); - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - IRubyObject readValue; - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if (IdUtil.isInstanceVariable(e.name)) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - list.add(new VariableEntry<IRubyObject>(e.name, readValue)); - } - } - } - return list; - } - - /** - * @see org.jruby.runtime.builtin.InstanceVariables#getInstanceVariableNameList - */ - public List<String> getInstanceVariableNameList() { - VariableTableEntry[] table = variableTableGetTable(); - ArrayList<String> list = new ArrayList<String>(); - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if (IdUtil.isInstanceVariable(e.name)) { - list.add(e.name); - } - } - } - return list; - } - - /** - * The error message used when some one tries to modify an - * instance variable in a high security setting. - */ - protected static final String ERR_INSECURE_SET_INST_VAR = "Insecure: can't modify instance variable"; - - /** - * Checks if the name parameter represents a legal instance variable name, and otherwise throws a Ruby NameError - */ - protected String validateInstanceVariable(String name) { - if (IdUtil.isValidInstanceVariableName(name)) return name; - - throw getRuntime().newNameError("`" + name + "' is not allowable as an instance variable name", name); - } - - /** - * Makes sure that instance variables can be set on this object, - * including information about whether this object is frozen, or - * tainted. Will throw a suitable exception in that case. - */ - protected void ensureInstanceVariablesSettable() { - if (!isFrozen() && (getRuntime().getSafeLevel() < 4 || isTaint())) { - return; - } - - if (getRuntime().getSafeLevel() >= 4 && !isTaint()) { - throw getRuntime().newSecurityError(ERR_INSECURE_SET_INST_VAR); - } - if (isFrozen()) { - if (this instanceof RubyModule) { - throw getRuntime().newFrozenError("class/module "); - } else { - throw getRuntime().newFrozenError(""); - } - } - } - - // - // INTERNAL VARIABLE METHODS - // - - /** - * Dummy method to avoid a cast, and to avoid polluting the - * IRubyObject interface with all the instance variable management - * methods. - */ - public InternalVariables getInternalVariables() { - return this; - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#hasInternalVariable - */ - public boolean hasInternalVariable(String name) { - assert !isRubyVariable(name); - return variableTableContains(name); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#fastHasInternalVariable - */ - public boolean fastHasInternalVariable(String internedName) { - assert !isRubyVariable(internedName); - return variableTableFastContains(internedName); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#getInternalVariable - */ - public IRubyObject getInternalVariable(String name) { - assert !isRubyVariable(name); - return variableTableFetch(name); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#fastGetInternalVariable - */ - public IRubyObject fastGetInternalVariable(String internedName) { - assert !isRubyVariable(internedName); - return variableTableFastFetch(internedName); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#setInternalVariable - */ - public void setInternalVariable(String name, IRubyObject value) { - assert !isRubyVariable(name); - variableTableStore(name, value); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#fastSetInternalVariable - */ - public void fastSetInternalVariable(String internedName, IRubyObject value) { - assert !isRubyVariable(internedName); - variableTableFastStore(internedName, value); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#removeInternalVariable - */ - public IRubyObject removeInternalVariable(String name) { - assert !isRubyVariable(name); - return variableTableRemove(name); - } - - /** - * Sync one variable table with another - this is used to make - * rbClone work correctly. - */ - public void syncVariables(List<Variable<IRubyObject>> variables) { - variableTableSync(variables); - } - - /** - * @see org.jruby.runtime.builtin.InternalVariables#getInternalVariableList - */ - public List<Variable<IRubyObject>> getInternalVariableList() { - VariableTableEntry[] table = variableTableGetTable(); - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - IRubyObject readValue; - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if (!isRubyVariable(e.name)) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - list.add(new VariableEntry<IRubyObject>(e.name, readValue)); - } - } - } - return list; - } - - - // - // COMMON VARIABLE METHODS - // - - /** - * Returns true if object has any variables, defined as: - * <ul> - * <li> instance variables - * <li> class variables - * <li> constants - * <li> internal variables, such as those used when marshaling Ranges and Exceptions - * </ul> - * @return true if object has any variables, else false - */ - public boolean hasVariables() { - return variableTableGetSize() > 0; - } - - /** - * Returns the amount of instance variables, class variables, - * constants and internal variables this object has. - */ - public int getVariableCount() { - return variableTableGetSize(); - } - - /** - * Gets a list of all variables in this object. - */ - // TODO: must override in RubyModule to pick up constants - public List<Variable<IRubyObject>> getVariableList() { - VariableTableEntry[] table = variableTableGetTable(); - ArrayList<Variable<IRubyObject>> list = new ArrayList<Variable<IRubyObject>>(); - IRubyObject readValue; - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - list.add(new VariableEntry<IRubyObject>(e.name, readValue)); - } - } - return list; - } - - /** - * Gets a name list of all variables in this object. - */ - // TODO: must override in RubyModule to pick up constants - public List<String> getVariableNameList() { - VariableTableEntry[] table = variableTableGetTable(); - ArrayList<String> list = new ArrayList<String>(); - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - list.add(e.name); - } - } - return list; - } - - /** - * Gets internal access to the getmap for variables. - */ - @SuppressWarnings("unchecked") - @Deprecated // born deprecated - public Map getVariableMap() { - return variableTableGetMap(); - } - - /** - * Check the syntax of a Ruby variable, including that it's longer - * than zero characters, and starts with either an @ or a capital - * letter. - */ - // FIXME: this should go somewhere more generic -- maybe IdUtil - protected static final boolean isRubyVariable(String name) { - char c; - return name.length() > 0 && ((c = name.charAt(0)) == '@' || (c <= 'Z' && c >= 'A')); - } - - // - // VARIABLE TABLE METHODS, ETC. - // - - protected static final int VARIABLE_TABLE_DEFAULT_CAPACITY = 8; // MUST be power of 2! - protected static final int VARIABLE_TABLE_MAXIMUM_CAPACITY = 1 << 30; - protected static final float VARIABLE_TABLE_LOAD_FACTOR = 0.75f; - protected static final VariableTableEntry[] VARIABLE_TABLE_EMPTY_TABLE = new VariableTableEntry[0]; - - /** - * Every entry in the variable map is represented by an instance - * of this class. - */ - protected static final class VariableTableEntry { - final int hash; - final String name; - volatile IRubyObject value; - final VariableTableEntry next; - - VariableTableEntry(int hash, String name, IRubyObject value, VariableTableEntry next) { - assert name == name.intern() : name + " is not interned"; - this.hash = hash; - this.name = name; - this.value = value; - this.next = next; - } - } - - /** - * Reads the value of the specified entry, locked on the current - * object. - */ - protected synchronized IRubyObject variableTableReadLocked(VariableTableEntry entry) { - return entry.value; - } - - /** - * Checks if the variable table contains a variable of the - * specified name. - */ - protected boolean variableTableContains(String name) { - VariableTableEntry[] table; - if ((table = variableTable) != null) { - int hash = name.hashCode(); - for (VariableTableEntry e = table[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return true; - } - } - } - return false; - } - - /** - * Checks if the variable table contains the the variable of the - * specified name, where the precondition is that the name must be - * an interned Java String. - */ - protected boolean variableTableFastContains(String internedName) { - assert internedName == internedName.intern() : internedName + " not interned"; - VariableTableEntry[] table; - if ((table = variableTable) != null) { - for (VariableTableEntry e = table[internedName.hashCode() & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - return true; - } - } - } - return false; - } - - /** - * Fetch an object from the variable table based on the name. - * - * @return the object or null if not found - */ - protected IRubyObject variableTableFetch(String name) { - VariableTableEntry[] table; - IRubyObject readValue; - if ((table = variableTable) != null) { - int hash = name.hashCode(); - for (VariableTableEntry e = table[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - if ((readValue = e.value) != null) return readValue; - return variableTableReadLocked(e); - } - } - } - return null; - } - - /** - * Fetch an object from the variable table based on the name, - * where the name must be an interned Java String. - * - * @return the object or null if not found - */ - protected IRubyObject variableTableFastFetch(String internedName) { - assert internedName == internedName.intern() : internedName + " not interned"; - VariableTableEntry[] table; - IRubyObject readValue; - if ((table = variableTable) != null) { - for (VariableTableEntry e = table[internedName.hashCode() & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - if ((readValue = e.value) != null) return readValue; - return variableTableReadLocked(e); - } - } - } - return null; - } - - /** - * Store a value in the variable store under the specific name. - */ - protected IRubyObject variableTableStore(String name, IRubyObject value) { - int hash = name.hashCode(); - synchronized(this) { - VariableTableEntry[] table; - VariableTableEntry e; - if ((table = variableTable) == null) { - table = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - e = new VariableTableEntry(hash, name.intern(), value, null); - table[hash & (VARIABLE_TABLE_DEFAULT_CAPACITY - 1)] = e; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTableSize = 1; - variableTable = table; - return value; - } - int potentialNewSize; - if ((potentialNewSize = variableTableSize + 1) > variableTableThreshold) { - table = variableTableRehash(); - } - int index; - for (e = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - e.value = value; - return value; - } - } - e = new VariableTableEntry(hash, name.intern(), value, table[index]); - table[index] = e; - variableTableSize = potentialNewSize; - variableTable = table; // write-volatile - } - return value; - } - - /** - * Will store the value under the specified name, where the name - * needs to be an interned Java String. - */ - protected IRubyObject variableTableFastStore(String internedName, IRubyObject value) { - assert internedName == internedName.intern() : internedName + " not interned"; - int hash = internedName.hashCode(); - synchronized(this) { - VariableTableEntry[] table; - VariableTableEntry e; - if ((table = variableTable) == null) { - table = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - e = new VariableTableEntry(hash, internedName, value, null); - table[hash & (VARIABLE_TABLE_DEFAULT_CAPACITY - 1)] = e; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTableSize = 1; - variableTable = table; - return value; - } - int potentialNewSize; - if ((potentialNewSize = variableTableSize + 1) > variableTableThreshold) { - table = variableTableRehash(); - } - int index; - for (e = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - e.value = value; - return value; - } - } - e = new VariableTableEntry(hash, internedName, value, table[index]); - table[index] = e; - variableTableSize = potentialNewSize; - variableTable = table; // write-volatile - } - return value; - } - - /** - * Removes the entry with the specified name from the variable - * table, and returning the removed value. - */ - protected IRubyObject variableTableRemove(String name) { - synchronized(this) { - VariableTableEntry[] table; - if ((table = variableTable) != null) { - int hash = name.hashCode(); - int index = hash & (table.length - 1); - VariableTableEntry first = table[index]; - VariableTableEntry e; - for (e = first; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - IRubyObject oldValue = e.value; - // All entries following removed node can stay - // in list, but all preceding ones need to be - // cloned. - VariableTableEntry newFirst = e.next; - for (VariableTableEntry p = first; p != e; p = p.next) { - newFirst = new VariableTableEntry(p.hash, p.name, p.value, newFirst); - } - table[index] = newFirst; - variableTableSize--; - variableTable = table; // write-volatile - return oldValue; - } - } - } - } - return null; - } - - /** - * Get the actual table used to save variable entries. - */ - protected VariableTableEntry[] variableTableGetTable() { - VariableTableEntry[] table; - if ((table = variableTable) != null) { - return table; - } - return VARIABLE_TABLE_EMPTY_TABLE; - } - - /** - * Get the size of the variable table. - */ - protected int variableTableGetSize() { - if (variableTable != null) { - return variableTableSize; - } - return 0; - } - - /** - * Synchronize the variable table with the argument. In real terms - * this means copy all entries into a newly allocated table. - */ - protected void variableTableSync(List<Variable<IRubyObject>> vars) { - synchronized(this) { - variableTableSize = 0; - variableTableThreshold = (int)(VARIABLE_TABLE_DEFAULT_CAPACITY * VARIABLE_TABLE_LOAD_FACTOR); - variableTable = new VariableTableEntry[VARIABLE_TABLE_DEFAULT_CAPACITY]; - for (Variable<IRubyObject> var : vars) { - variableTableStore(var.getName(), var.getValue()); - } - } - } - - /** - * Rehashes the variable table. Must be called from a synchronized - * block. - */ - // MUST be called from synchronized/locked block! - // should only be called by variableTableStore/variableTableFastStore - protected final VariableTableEntry[] variableTableRehash() { - VariableTableEntry[] oldTable = variableTable; - int oldCapacity; - if ((oldCapacity = oldTable.length) >= VARIABLE_TABLE_MAXIMUM_CAPACITY) { - return oldTable; - } - - int newCapacity = oldCapacity << 1; - VariableTableEntry[] newTable = new VariableTableEntry[newCapacity]; - variableTableThreshold = (int)(newCapacity * VARIABLE_TABLE_LOAD_FACTOR); - int sizeMask = newCapacity - 1; - VariableTableEntry e; - for (int i = oldCapacity; --i >= 0; ) { - // We need to guarantee that any existing reads of old Map can - // proceed. So we cannot yet null out each bin. - e = oldTable[i]; - - if (e != null) { - VariableTableEntry next = e.next; - int idx = e.hash & sizeMask; - - // Single node on list - if (next == null) - newTable[idx] = e; - - else { - // Reuse trailing consecutive sequence at same slot - VariableTableEntry lastRun = e; - int lastIdx = idx; - for (VariableTableEntry last = next; - last != null; - last = last.next) { - int k = last.hash & sizeMask; - if (k != lastIdx) { - lastIdx = k; - lastRun = last; - } - } - newTable[lastIdx] = lastRun; - - // Clone all remaining nodes - for (VariableTableEntry p = e; p != lastRun; p = p.next) { - int k = p.hash & sizeMask; - VariableTableEntry m = new VariableTableEntry(p.hash, p.name, p.value, newTable[k]); - newTable[k] = m; - } - } - } - } - variableTable = newTable; - return newTable; - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - protected Map variableTableGetMap() { - HashMap map = new HashMap(); - VariableTableEntry[] table; - IRubyObject readValue; - if ((table = variableTable) != null) { - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - map.put(e.name, readValue); - } - } - } - return map; - } - - /** - * Method to help ease transition to new variables implementation. - * Will likely be deprecated in the near future. - */ - @SuppressWarnings("unchecked") - protected Map variableTableGetMap(Map map) { - VariableTableEntry[] table; - IRubyObject readValue; - if ((table = variableTable) != null) { - for (int i = table.length; --i >= 0; ) { - for (VariableTableEntry e = table[i]; e != null; e = e.next) { - if ((readValue = e.value) == null) readValue = variableTableReadLocked(e); - map.put(e.name, readValue); - } - } - } - return map; - } - - /** - * Tries to support Java serialization of Ruby objects. This is - * still experimental and might not work. - */ - // NOTE: Serialization is primarily supported for testing purposes, and there is no general - // guarantee that serialization will work correctly. Specifically, instance variables pointing - // at symbols, threads, modules, classes, and other unserializable types are not detected. - private void writeObject(ObjectOutputStream out) throws IOException { - out.defaultWriteObject(); - // write out ivar count followed by name/value pairs - List<String> names = getInstanceVariableNameList(); - out.writeInt(names.size()); - for (String name : names) { - out.writeObject(name); - out.writeObject(getInstanceVariables().getInstanceVariable(name)); - } - } - - /** - * Tries to support Java unserialization of Ruby objects. This is - * still experimental and might not work. - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - // rest in ivar count followed by name/value pairs - int ivarCount = in.readInt(); - for (int i = 0; i < ivarCount; i++) { - setInstanceVariable((String)in.readObject(), (IRubyObject)in.readObject()); - } - } - -} - -package org.jruby; - -import org.jruby.runtime.Block; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * - * @author nicksieger - */ -public interface RubyObjectAdapter { - - boolean isKindOf(IRubyObject value, RubyModule rubyModule); - - IRubyObject setInstanceVariable(IRubyObject obj, String variableName, IRubyObject value); - - IRubyObject[] convertToJavaArray(IRubyObject array); - - RubyInteger convertToRubyInteger(IRubyObject obj); - - IRubyObject getInstanceVariable(IRubyObject obj, String variableName); - - RubyString convertToRubyString(IRubyObject obj); - - // These call* assume ThreadContext = receiver.getRuntime().getCurrentContext() - IRubyObject callMethod(IRubyObject receiver, String methodName); - - IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject singleArg); - - IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject[] args); - - IRubyObject callMethod(IRubyObject receiver, String methodName, IRubyObject[] args, Block block); - - IRubyObject callSuper(IRubyObject receiver, IRubyObject[] args); - - IRubyObject callSuper(IRubyObject receiver, IRubyObject[] args, Block block); -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.Iterator; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyModule(name="ObjectSpace") -public class RubyObjectSpace { - - /** Create the ObjectSpace module and add it to the Ruby runtime. - * - */ - public static RubyModule createObjectSpaceModule(Ruby runtime) { - RubyModule objectSpaceModule = runtime.defineModule("ObjectSpace"); - runtime.setObjectSpaceModule(objectSpaceModule); - - objectSpaceModule.defineAnnotatedMethods(RubyObjectSpace.class); - - return objectSpaceModule; - } - - @JRubyMethod(name = "define_finalizer", required = 1, optional = 1, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject define_finalizer(IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = recv.getRuntime(); - IRubyObject finalizer = null; - if (args.length == 2) { - finalizer = args[1]; - if (!finalizer.respondsTo("call")) { - throw runtime.newArgumentError("wrong type argument " - + finalizer.getType() + " (should be callable)"); - } - } else { - finalizer = runtime.newProc(Block.Type.PROC, block); - } - IRubyObject obj = args[0]; - runtime.getObjectSpace().addFinalizer(obj, finalizer); - return runtime.newArray(runtime.newFixnum(runtime.getSafeLevel()), finalizer); - } - - @JRubyMethod(name = "undefine_finalizer", required = 1, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject undefine_finalizer(IRubyObject recv, IRubyObject arg1, Block block) { - recv.getRuntime().getObjectSpace().removeFinalizers(RubyNumeric.fix2long(arg1.id())); - return recv; - } - - @JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) { - Ruby runtime = id.getRuntime(); - if (!(id instanceof RubyFixnum)) { - throw recv.getRuntime().newTypeError(id, recv.getRuntime().getFixnum()); - } - RubyFixnum idFixnum = (RubyFixnum) id; - long longId = idFixnum.getLongValue(); - if (longId == 0) { - return runtime.getFalse(); - } else if (longId == 2) { - return runtime.getTrue(); - } else if (longId == 4) { - return runtime.getNil(); - } else if (longId % 2 != 0) { - // odd - return runtime.newFixnum((longId - 1) / 2); - } else { - IRubyObject object = runtime.getObjectSpace().id2ref(longId); - if (object == null) { - return runtime.getNil(); - } - return object; - } - } - - @JRubyMethod(name = "each_object", optional = 1, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject each_object(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyModule rubyClass; - if (args.length == 0) { - rubyClass = recv.getRuntime().getObject(); - } else { - if (!(args[0] instanceof RubyModule)) throw recv.getRuntime().newTypeError("class or module required"); - rubyClass = (RubyModule) args[0]; - } - Ruby runtime = recv.getRuntime(); - int count = 0; - if (rubyClass != runtime.getClassClass()) { - if (!runtime.isObjectSpaceEnabled()) { - throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass +O to enable"); - } - Iterator iter = recv.getRuntime().getObjectSpace().iterator(rubyClass); - - IRubyObject obj = null; - while ((obj = (IRubyObject)iter.next()) != null) { - count++; - block.yield(context, obj); - } - } else { - Iterator iter = runtime.getObject().subclasses(true).iterator(); - - while (iter.hasNext()) { - count++; - block.yield(context, (IRubyObject)iter.next()); - } - } - return recv.getRuntime().newFixnum(count); - } - - @JRubyMethod(name = "garbage_collect", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject garbage_collect(IRubyObject recv) { - return RubyGC.start(recv); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.callback.Callback; - -/** - * - * @author jpetersen - */ -@JRubyModule(name="Precision") -public class RubyPrecision { - - public static RubyModule createPrecisionModule(Ruby runtime) { - RubyModule precisionModule = runtime.defineModule("Precision"); - runtime.setPrecision(precisionModule); - - precisionModule.defineAnnotatedMethods(RubyPrecision.class); - - return precisionModule; - } - - public static IRubyObject induced_from(IRubyObject receiver, IRubyObject source, Block block) { - throw receiver.getRuntime().newTypeError("Undefined conversion from " + source.getMetaClass().getName() + " into " + ((RubyClass)receiver).getName()); - } - - @JRubyMethod(name = "append_features", required = 1, frame = true, module = true) - public static IRubyObject append_features(IRubyObject receiver, IRubyObject include, Block block) { - if (include instanceof RubyModule) { - ((RubyModule) include).includeModule(receiver); - include.getSingletonClass().defineMethod("induced_from", new Callback() { - - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) { - Arity.checkArgumentCount(recv.getRuntime(), args, 1, 1); - - return RubyPrecision.induced_from(recv, args[0], block); - } - - public Arity getArity() { - return Arity.ONE_ARGUMENT; - } - }); - } - return receiver; - } - - - @JRubyMethod(name = "prec", required = 1, frame = true) - public static IRubyObject prec(ThreadContext context, IRubyObject receiver, IRubyObject type, Block block) { - return type.callMethod(context, "induced_from", receiver); - } - - @JRubyMethod(name = "prec_i", frame = true) - public static IRubyObject prec_i(ThreadContext context, IRubyObject receiver, Block block) { - return receiver.getRuntime().getInteger().callMethod(context, "induced_from", receiver); - } - - @JRubyMethod(name = "prec_f", frame = true) - public static IRubyObject prec_f(ThreadContext context, IRubyObject receiver, Block block) { - return receiver.getRuntime().getFloat().callMethod(context, "induced_from", receiver); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2007 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.exceptions.JumpException; -import org.jruby.internal.runtime.JumpTarget; -import org.jruby.java.MiniJava; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * @author jpetersen - */ -@JRubyClass(name="Proc") -public class RubyProc extends RubyObject implements JumpTarget { - private Block block = Block.NULL_BLOCK; - private Block.Type type; - private String file; - private int line; - - public RubyProc(Ruby runtime, RubyClass rubyClass, Block.Type type) { - super(runtime, rubyClass); - - this.type = type; - } - - private static ObjectAllocator PROC_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyProc instance = RubyProc.newProc(runtime, Block.Type.PROC); - - instance.setMetaClass(klass); - - return instance; - } - }; - - public static RubyClass createProcClass(Ruby runtime) { - RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), PROC_ALLOCATOR); - runtime.setProc(procClass); - - procClass.defineAnnotatedMethods(RubyProc.class); - - return procClass; - } - - public Block getBlock() { - return block; - } - - // Proc class - - public static RubyProc newProc(Ruby runtime, Block.Type type) { - return new RubyProc(runtime, runtime.getProc(), type); - } - public static RubyProc newProc(Ruby runtime, Block block, Block.Type type) { - RubyProc proc = new RubyProc(runtime, runtime.getProc(), type); - proc.callInit(NULL_ARRAY, block); - - return proc; - } - - /** - * Create a new instance of a Proc object. We override this method (from RubyClass) - * since we need to deal with special case of Proc.new with no arguments or block arg. In - * this case, we need to check previous frame for a block to consume. - */ - @JRubyMethod(name = "new", rest = true, frame = true, meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - // No passed in block, lets check next outer frame for one ('Proc.new') - if (!block.isGiven()) { - block = context.getPreviousFrame().getBlock(); - } - - if (block.isGiven() && block.getProcObject() != null) { - return block.getProcObject(); - } - - IRubyObject obj = ((RubyClass) recv).allocate(); - - obj.callMethod(context, "initialize", args, block); - return obj; - } - - @JRubyMethod(name = "initialize", frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(ThreadContext context, Block procBlock) { - if (!procBlock.isGiven()) { - throw getRuntime().newArgumentError("tried to create Proc object without a block"); - } - - if (type == Block.Type.LAMBDA && procBlock == null) { - // TODO: warn "tried to create Proc object without a block" - } - - block = procBlock.cloneBlock(); - block.type = type; - block.setProcObject(this); - - file = context.getFile(); - line = context.getLine(); - return this; - } - - @JRubyMethod(name = "clone") - public IRubyObject rbClone() { - RubyProc newProc = new RubyProc(getRuntime(), getRuntime().getProc(), type); - newProc.block = getBlock(); - newProc.file = file; - newProc.line = line; - // TODO: CLONE_SETUP here - return newProc; - } - - @JRubyMethod(name = "dup") - public IRubyObject dup() { - RubyProc newProc = new RubyProc(getRuntime(), getRuntime().getProc(), type); - newProc.block = getBlock(); - newProc.file = file; - newProc.line = line; - return newProc; - } - - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(IRubyObject other) { - if (!(other instanceof RubyProc)) return getRuntime().getFalse(); - - if (this == other || this.block == ((RubyProc)other).block) { - return getRuntime().getTrue(); - } - - return getRuntime().getFalse(); - } - - @JRubyMethod(name = "to_s") - public IRubyObject to_s() { - return RubyString.newString(getRuntime(), - "#<Proc:0x" + Integer.toString(block.hashCode(), 16) + "@" + - file + ":" + (line + 1) + ">"); - } - - @JRubyMethod(name = "binding") - public IRubyObject binding() { - return getRuntime().newBinding(block.getBinding()); - } - - @JRubyMethod(name = {"call", "[]"}, rest = true, frame = true) - public IRubyObject call(ThreadContext context, IRubyObject[] args) { - return call(context, args, null); - } - - public IRubyObject call(ThreadContext context, IRubyObject[] args, IRubyObject self) { - assert args != null; - - Ruby runtime = getRuntime(); - Block newBlock = block.cloneBlock(); - JumpTarget jumpTarget = newBlock.getBinding().getFrame().getJumpTarget(); - - try { - if (self != null) newBlock.getBinding().setSelf(self); - - return newBlock.call(context, args); - } catch (JumpException.BreakJump bj) { - switch(block.type) { - case LAMBDA: if (bj.getTarget() == jumpTarget) { - return (IRubyObject) bj.getValue(); - } else { - throw runtime.newLocalJumpError("break", (IRubyObject)bj.getValue(), "unexpected break"); - } - case PROC: - if (newBlock.isEscaped()) { - throw runtime.newLocalJumpError("break", (IRubyObject)bj.getValue(), "break from proc-closure"); - } else { - throw bj; - } - default: throw bj; - } - } catch (JumpException.ReturnJump rj) { - Object target = rj.getTarget(); - - if (target == jumpTarget && block.type == Block.Type.LAMBDA) return (IRubyObject) rj.getValue(); - - if (type == Block.Type.THREAD) { - throw runtime.newThreadError("return can't jump across threads"); - } - throw rj; - } catch (JumpException.RetryJump rj) { - throw runtime.newLocalJumpError("retry", (IRubyObject)rj.getValue(), "retry not supported outside rescue"); - } - } - - @JRubyMethod(name = "arity") - public RubyFixnum arity() { - return getRuntime().newFixnum(block.arity().getValue()); - } - - @JRubyMethod(name = "to_proc") - public RubyProc to_proc() { - return this; - } - - public IRubyObject as(Class asClass) { - final Ruby ruby = getRuntime(); - if (!asClass.isInterface()) { - throw ruby.newTypeError(asClass.getCanonicalName() + " is not an interface"); - } - - return MiniJava.javaToRuby(ruby, Proxy.newProxyInstance(Ruby.getClassLoader(), new Class[] {asClass}, new InvocationHandler() { - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - IRubyObject[] rubyArgs = new IRubyObject[args.length + 1]; - rubyArgs[0] = RubySymbol.newSymbol(ruby, method.getName()); - for (int i = 1; i < rubyArgs.length; i++) { - rubyArgs[i] = MiniJava.javaToRuby(ruby, args[i - 1]); - } - return MiniJava.rubyToJava(call(ruby.getCurrentContext(), rubyArgs)); - } - })); - } -} -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.ext.posix.POSIX; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.BlockCallback; -import org.jruby.runtime.CallBlock; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - - -/** - */ - -@JRubyModule(name="Process") -public class RubyProcess { - - public static RubyModule createProcessModule(Ruby runtime) { - RubyModule process = runtime.defineModule("Process"); - runtime.setProcess(process); - - // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415 - RubyClass process_status = process.defineClassUnder("Status", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setProcStatus(process_status); - - RubyModule process_uid = process.defineModuleUnder("UID"); - runtime.setProcUID(process_uid); - - RubyModule process_gid = process.defineModuleUnder("GID"); - runtime.setProcGID(process_gid); - - RubyModule process_sys = process.defineModuleUnder("Sys"); - runtime.setProcSys(process_sys); - - process.defineAnnotatedMethods(RubyProcess.class); - process_status.defineAnnotatedMethods(RubyStatus.class); - process_uid.defineAnnotatedMethods(UserID.class); - process_gid.defineAnnotatedMethods(GroupID.class); - process_sys.defineAnnotatedMethods(Sys.class); - - process.defineConstant("PRIO_PROCESS", runtime.newFixnum(0)); - process.defineConstant("PRIO_PGRP", runtime.newFixnum(1)); - process.defineConstant("PRIO_USER", runtime.newFixnum(2)); - - process.defineConstant("WNOHANG", runtime.newFixnum(1)); - - return process; - } - - @JRubyClass(name="Process::Status") - public static class RubyStatus extends RubyObject { - private long status = 0L; - - private static final long EXIT_SUCCESS = 0L; - public RubyStatus(Ruby runtime, RubyClass metaClass, long status) { - super(runtime, metaClass); - this.status = status; - } - - public static RubyStatus newProcessStatus(Ruby runtime, long status) { - return new RubyStatus(runtime, runtime.getProcStatus(), status); - } - - // Bunch of methods still not implemented - @JRubyMethod(name = {"to_int", "pid", "stopped?", "stopsig", "signaled?", "termsig?", "exited?", "coredump?"}) - public IRubyObject not_implemented() { - String error = "Process::Status#" + getRuntime().getCurrentContext().getFrameName() + " not implemented"; - throw getRuntime().newNotImplementedError(error); - } - - @JRubyMethod(name = {"&"}) - public IRubyObject not_implemented1(IRubyObject arg) { - String error = "Process::Status#" + getRuntime().getCurrentContext().getFrameName() + " not implemented"; - throw getRuntime().newNotImplementedError(error); - } - - @JRubyMethod - public IRubyObject exitstatus() { - return getRuntime().newFixnum(status); - } - - @JRubyMethod(name = ">>") - public IRubyObject op_rshift(IRubyObject other) { - long shiftValue = other.convertToInteger().getLongValue(); - return getRuntime().newFixnum(status >> shiftValue); - } - - @JRubyMethod(name = "==") - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - return other.callMethod(context, MethodIndex.EQUALEQUAL, "==", this.to_i()); - } - - @JRubyMethod - public IRubyObject to_i() { - return getRuntime().newFixnum(shiftedValue()); - } - - @JRubyMethod - public IRubyObject to_s() { - return getRuntime().newString(String.valueOf(shiftedValue())); - } - - @JRubyMethod - public IRubyObject inspect() { - return getRuntime().newString("#<Process::Status: pid=????,exited(" + String.valueOf(status) + ")>"); - } - - @JRubyMethod(name = "success?") - public IRubyObject success_p() { - return getRuntime().newBoolean(status == EXIT_SUCCESS); - } - - private long shiftedValue() { - return status << 8; - } - } - - @JRubyModule(name="Process::UID") - public static class UserID { - @JRubyMethod(name = "change_privilege", module = true) - public static IRubyObject change_privilege(IRubyObject self, IRubyObject arg) { - throw self.getRuntime().newNotImplementedError("Process::UID::change_privilege not implemented yet"); - } - - @JRubyMethod(name = "eid", module = true) - public static IRubyObject eid(IRubyObject self) { - return euid(self); - } - - @JRubyMethod(name = "eid=", module = true) - public static IRubyObject eid(IRubyObject self, IRubyObject arg) { - return euid_set(self, arg); - } - - @JRubyMethod(name = "grant_privilege", module = true) - public static IRubyObject grant_privilege(IRubyObject self, IRubyObject arg) { - throw self.getRuntime().newNotImplementedError("Process::UID::grant_privilege not implemented yet"); - } - - @JRubyMethod(name = "re_exchange", module = true) - public static IRubyObject re_exchange(ThreadContext context, IRubyObject self) { - return switch_rb(context, self, Block.NULL_BLOCK); - } - - @JRubyMethod(name = "re_exchangeable?", module = true) - public static IRubyObject re_exchangeable_p(IRubyObject self) { - throw self.getRuntime().newNotImplementedError("Process::UID::re_exchangeable? not implemented yet"); - } - - @JRubyMethod(name = "rid", module = true) - public static IRubyObject rid(IRubyObject self) { - return uid(self); - } - - @JRubyMethod(name = "sid_available?", module = true) - public static IRubyObject sid_available_p(IRubyObject self) { - throw self.getRuntime().newNotImplementedError("Process::UID::sid_available not implemented yet"); - } - - @JRubyMethod(name = "switch", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject switch_rb(ThreadContext context, IRubyObject self, Block block) { - Ruby runtime = self.getRuntime(); - int uid = runtime.getPosix().getuid(); - int euid = runtime.getPosix().geteuid(); - - if (block.isGiven()) { - try { - runtime.getPosix().seteuid(uid); - runtime.getPosix().setuid(euid); - - return block.yield(context, runtime.getNil()); - } finally { - runtime.getPosix().seteuid(euid); - runtime.getPosix().setuid(uid); - } - } else { - runtime.getPosix().seteuid(uid); - runtime.getPosix().setuid(euid); - - return RubyFixnum.zero(runtime); - } - } - } - - @JRubyModule(name="Process::GID") - public static class GroupID { - @JRubyMethod(name = "change_privilege", module = true) - public static IRubyObject change_privilege(IRubyObject self, IRubyObject arg) { - throw self.getRuntime().newNotImplementedError("Process::GID::change_privilege not implemented yet"); - } - - @JRubyMethod(name = "eid", module = true) - public static IRubyObject eid(IRubyObject self) { - return egid(self); - } - - @JRubyMethod(name = "eid=", module = true) - public static IRubyObject eid(IRubyObject self, IRubyObject arg) { - return RubyProcess.egid_set(self, arg); - } - - @JRubyMethod(name = "grant_privilege", module = true) - public static IRubyObject grant_privilege(IRubyObject self, IRubyObject arg) { - throw self.getRuntime().newNotImplementedError("Process::GID::grant_privilege not implemented yet"); - } - - @JRubyMethod(name = "re_exchange", module = true) - public static IRubyObject re_exchange(ThreadContext context, IRubyObject self) { - return switch_rb(context, self, Block.NULL_BLOCK); - } - - @JRubyMethod(name = "re_exchangeable?", module = true) - public static IRubyObject re_exchangeable_p(IRubyObject self) { - throw self.getRuntime().newNotImplementedError("Process::GID::re_exchangeable? not implemented yet"); - } - - @JRubyMethod(name = "rid", module = true) - public static IRubyObject rid(IRubyObject self) { - return gid(self); - } - - @JRubyMethod(name = "sid_available?", module = true) - public static IRubyObject sid_available_p(IRubyObject self) { - throw self.getRuntime().newNotImplementedError("Process::GID::sid_available not implemented yet"); - } - - @JRubyMethod(name = "switch", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject switch_rb(ThreadContext context, IRubyObject self, Block block) { - Ruby runtime = self.getRuntime(); - int gid = runtime.getPosix().getgid(); - int egid = runtime.getPosix().getegid(); - - if (block.isGiven()) { - try { - runtime.getPosix().setegid(gid); - runtime.getPosix().setgid(egid); - - return block.yield(context, runtime.getNil()); - } finally { - runtime.getPosix().setegid(egid); - runtime.getPosix().setgid(gid); - } - } else { - runtime.getPosix().setegid(gid); - runtime.getPosix().setgid(egid); - - return RubyFixnum.zero(runtime); - } - } - } - - @JRubyModule(name="Process::Sys") - public static class Sys { - @JRubyMethod(name = "getegid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getegid(IRubyObject self) { - return egid(self); - } - - @JRubyMethod(name = "geteuid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject geteuid(IRubyObject self) { - return euid(self); - } - - @JRubyMethod(name = "getgid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getgid(IRubyObject self) { - return gid(self); - } - - @JRubyMethod(name = "getuid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getuid(IRubyObject self) { - return uid(self); - } - - @JRubyMethod(name = "setegid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setegid(IRubyObject recv, IRubyObject arg) { - return egid_set(recv, arg); - } - - @JRubyMethod(name = "seteuid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject seteuid(IRubyObject recv, IRubyObject arg) { - return euid_set(recv, arg); - } - - @JRubyMethod(name = "setgid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setgid(IRubyObject recv, IRubyObject arg) { - return gid_set(recv, arg); - } - - @JRubyMethod(name = "setuid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setuid(IRubyObject recv, IRubyObject arg) { - return uid_set(recv, arg); - } - } - - @JRubyMethod(name = "abort", optional = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject abort(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - return RubyKernel.abort(context, recv, args); - } - - @JRubyMethod(name = "exit!", optional = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject exit_bang(IRubyObject recv, IRubyObject[] args) { - return RubyKernel.exit_bang(recv, args); - } - - @JRubyMethod(name = "groups", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject groups(IRubyObject recv) { - throw recv.getRuntime().newNotImplementedError("Process#groups not yet implemented"); - } - - @JRubyMethod(name = "setrlimit", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setrlimit(IRubyObject recv, IRubyObject[] args) { - throw recv.getRuntime().newNotImplementedError("Process#setrlimit not yet implemented"); - } - - @JRubyMethod(name = "getpgrp", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getpgrp(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getpgrp()); - } - - @JRubyMethod(name = "groups=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject groups_set(IRubyObject recv, IRubyObject arg) { - throw recv.getRuntime().newNotImplementedError("Process#groups not yet implemented"); - } - - @JRubyMethod(name = "waitpid", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject waitpid(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - int pid = -1; - int flags = 0; - if (args.length > 0) { - pid = (int)args[0].convertToInteger().getLongValue(); - } - if (args.length > 1) { - flags = (int)args[1].convertToInteger().getLongValue(); - } - - int[] status = new int[1]; - pid = runtime.getPosix().waitpid(pid, status, flags); - - if (pid == -1) { - throw runtime.newErrnoECHILDError(); - } - - runtime.getGlobalVariables().set( - "$?", - RubyProcess.RubyStatus.newProcessStatus(runtime, status[0])); - return runtime.newFixnum(pid); - } - - @JRubyMethod(name = "wait", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject wait(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - - if (args.length > 0) { - return waitpid(recv, args); - } - - int[] status = new int[1]; - int pid = runtime.getPosix().wait(status); - - if (pid == -1) { - throw runtime.newErrnoECHILDError(); - } - - runtime.getGlobalVariables().set( - "$?", - RubyProcess.RubyStatus.newProcessStatus(runtime, status[0])); - return runtime.newFixnum(pid); - } - - @JRubyMethod(name = "waitall", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject waitall(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - POSIX posix = runtime.getPosix(); - RubyArray results = recv.getRuntime().newArray(); - - int[] status = new int[1]; - int result = posix.wait(status); - while (result != -1) { - results.append(runtime.newArray(runtime.newFixnum(result), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0]))); - result = posix.wait(status); - } - - return results; - } - - @JRubyMethod(name = "setsid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setsid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().setsid()); - } - - @JRubyMethod(name = "setpgrp", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setpgrp(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().setpgid(0, 0)); - } - - @JRubyMethod(name = "egid=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject egid_set(IRubyObject recv, IRubyObject arg) { - recv.getRuntime().getPosix().setegid((int)arg.convertToInteger().getLongValue()); - return RubyFixnum.zero(recv.getRuntime()); - } - - @JRubyMethod(name = "euid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject euid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().geteuid()); - } - - @JRubyMethod(name = "uid=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject uid_set(IRubyObject recv, IRubyObject arg) { - recv.getRuntime().getPosix().setuid((int)arg.convertToInteger().getLongValue()); - return RubyFixnum.zero(recv.getRuntime()); - } - - @JRubyMethod(name = "gid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject gid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getgid()); - } - - @JRubyMethod(name = "maxgroups", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject maxgroups(IRubyObject recv) { - throw recv.getRuntime().newNotImplementedError("Process#maxgroups not yet implemented"); - } - - @JRubyMethod(name = "getpriority", required = 2, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getpriority(IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { - int which = (int)arg1.convertToInteger().getLongValue(); - int who = (int)arg2.convertToInteger().getLongValue(); - int result = recv.getRuntime().getPosix().getpriority(which, who); - - return recv.getRuntime().newFixnum(result); - } - - @JRubyMethod(name = "uid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject uid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getuid()); - } - - @JRubyMethod(name = "waitpid2", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject waitpid2(IRubyObject recv, IRubyObject[] args) { - Ruby runtime = recv.getRuntime(); - int pid = -1; - int flags = 0; - if (args.length > 0) { - pid = (int)args[0].convertToInteger().getLongValue(); - } - if (args.length > 1) { - flags = (int)args[1].convertToInteger().getLongValue(); - } - - int[] status = new int[1]; - pid = runtime.getPosix().waitpid(pid, status, flags); - - if (pid == -1) { - throw runtime.newErrnoECHILDError(); - } - - return runtime.newArray(runtime.newFixnum(pid), RubyProcess.RubyStatus.newProcessStatus(runtime, status[0])); - } - - @JRubyMethod(name = "initgroups", required = 2, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject initgroups(IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { - throw recv.getRuntime().newNotImplementedError("Process#initgroups not yet implemented"); - } - - @JRubyMethod(name = "maxgroups=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject maxgroups_set(IRubyObject recv, IRubyObject arg) { - throw recv.getRuntime().newNotImplementedError("Process#maxgroups_set not yet implemented"); - } - - @JRubyMethod(name = "ppid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject ppid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getppid()); - } - - @JRubyMethod(name = "gid=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject gid_set(IRubyObject recv, IRubyObject arg) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().setgid((int)arg.convertToInteger().getLongValue())); - } - - @JRubyMethod(name = "wait2", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject wait2(IRubyObject recv, IRubyObject[] args) { - return waitpid2(recv, args); - } - - @JRubyMethod(name = "euid=", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject euid_set(IRubyObject recv, IRubyObject arg) { - recv.getRuntime().getPosix().seteuid((int)arg.convertToInteger().getLongValue()); - return RubyFixnum.zero(recv.getRuntime()); - } - - @JRubyMethod(name = "setpriority", required = 3, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setpriority(IRubyObject recv, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { - int which = (int)arg1.convertToInteger().getLongValue(); - int who = (int)arg2.convertToInteger().getLongValue(); - int prio = (int)arg3.convertToInteger().getLongValue(); - int result = recv.getRuntime().getPosix().setpriority(which, who, prio); - - return recv.getRuntime().newFixnum(result); - } - - @JRubyMethod(name = "setpgid", required = 2, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject setpgid(IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { - int pid = (int)arg1.convertToInteger().getLongValue(); - int gid = (int)arg2.convertToInteger().getLongValue(); - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().setpgid(pid, gid)); - } - - @JRubyMethod(name = "getpgid", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getpgid(IRubyObject recv, IRubyObject arg) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getpgid((int)arg.convertToInteger().getLongValue())); - } - - @JRubyMethod(name = "getrlimit", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject getrlimit(IRubyObject recv, IRubyObject arg) { - throw recv.getRuntime().newNotImplementedError("Process#getrlimit not yet implemented"); - } - - @JRubyMethod(name = "egid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject egid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getegid()); - } - - private static String[] signals = new String[] {"EXIT", "HUP", "INT", "QUIT", "ILL", "TRAP", - "ABRT", "POLL", "FPE", "KILL", "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "URG", "STOP", - "TSTP", "CONT", "CHLD", "TTIN", "TTOU", "XCPU", "XFSZ", "VTALRM", "PROF", "USR1", "USR2"}; - - private static int parseSignalString(Ruby runtime, String value) { - int startIndex = 0; - boolean negative = value.startsWith("-"); - - if (negative) startIndex++; - - boolean signalString = value.startsWith("SIG", startIndex); - - if (signalString) startIndex += 3; - - String signalName = value.substring(startIndex); - - // FIXME: This table will get moved into POSIX library so we can get all actual supported - // signals. This is a quick fix to support basic signals until that happens. - for (int i = 0; i < signals.length; i++) { - if (signals[i].equals(signalName)) return negative ? -i : i; - } - - throw runtime.newArgumentError("unsupported name `SIG" + signalName + "'"); - } - - @JRubyMethod(name = "kill", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject kill(IRubyObject recv, IRubyObject[] args) { - if (args.length < 2) { - throw recv.getRuntime().newArgumentError("wrong number of arguments -- kill(sig, pid...)"); - } - - Ruby runtime = recv.getRuntime(); - int signal; - if (args[0] instanceof RubyFixnum) { - signal = (int) ((RubyFixnum) args[0]).getLongValue(); - } else if (args[0] instanceof RubySymbol) { - signal = parseSignalString(runtime, args[0].toString()); - } else if (args[0] instanceof RubyString) { - signal = parseSignalString(runtime, args[0].toString()); - } else { - signal = parseSignalString(runtime, args[0].checkStringType().toString()); - } - - boolean processGroupKill = signal < 0; - - if (processGroupKill) signal = -signal; - - POSIX posix = runtime.getPosix(); - for (int i = 1; i < args.length; i++) { - int pid = RubyNumeric.num2int(args[i]); - - // FIXME: It may be possible to killpg on systems which support it. POSIX library - // needs to tell whether a particular method works or not - if (pid == 0) pid = runtime.getPosix().getpid(); - posix.kill(processGroupKill ? -pid : pid, signal); - } - - return runtime.newFixnum(args.length - 1); - - } - - @JRubyMethod(name = "detach", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject detach(ThreadContext context, IRubyObject recv, IRubyObject arg) { - final int pid = (int)arg.convertToInteger().getLongValue(); - Ruby runtime = recv.getRuntime(); - - BlockCallback callback = new BlockCallback() { - public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) { - int[] status = new int[1]; - int result = context.getRuntime().getPosix().waitpid(pid, status, 0); - - return context.getRuntime().newFixnum(result); - } - }; - - return RubyThread.newInstance( - runtime.getThread(), - IRubyObject.NULL_ARRAY, - CallBlock.newCallClosure(recv, (RubyModule)recv, Arity.NO_ARGUMENTS, callback, context)); - } - - @JRubyMethod(name = "times", frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject times(IRubyObject recv, Block unusedBlock) { - Ruby runtime = recv.getRuntime(); - double currentTime = System.currentTimeMillis() / 1000.0; - double startTime = runtime.getStartTime() / 1000.0; - RubyFloat zero = runtime.newFloat(0.0); - return RubyStruct.newStruct(runtime.getTmsStruct(), - new IRubyObject[] { runtime.newFloat(currentTime - startTime), zero, zero, zero }, - Block.NULL_BLOCK); - } - - @JRubyMethod(name = "pid", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject pid(IRubyObject recv) { - return recv.getRuntime().newFixnum(recv.getRuntime().getPosix().getpid()); - } - - @JRubyMethod(name = "fork", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject fork(ThreadContext context, IRubyObject recv, Block block) { - return RubyKernel.fork(context, recv, block); - } - - @JRubyMethod(name = "exit", optional = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject exit(IRubyObject recv, IRubyObject[] args) { - return RubyKernel.exit(recv, args); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001 Ed Sinjiashvili <slorcim@users.sourceforge.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.util.List; - -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.exceptions.RaiseException; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.BlockCallback; -import org.jruby.runtime.CallBlock; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ObjectMarshal; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; -import org.jruby.runtime.component.VariableEntry; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; - -/** - * @author jpetersen - */ -@JRubyClass(name="Range", include="Enumerable") -public class RubyRange extends RubyObject { - private IRubyObject begin; - private IRubyObject end; - private boolean isExclusive; - - public static RubyClass createRangeClass(Ruby runtime) { - RubyClass result = runtime.defineClass("Range", runtime.getObject(), RANGE_ALLOCATOR); - runtime.setRange(result); - result.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyRange; - } - }; - - result.setMarshal(RANGE_MARSHAL); - result.includeModule(runtime.getEnumerable()); - - // We override Enumerable#member? since ranges in 1.8.1 are continuous. - // result.defineMethod("member?", callbackFactory.getMethod("include_p", RubyKernel.IRUBY_OBJECT)); - // result.defineMethod("===", callbackFactory.getMethod("include_p", RubyKernel.IRUBY_OBJECT)); - - result.defineAnnotatedMethods(RubyRange.class); - return result; - } - - private static final ObjectAllocator RANGE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyRange(runtime, klass); - } - }; - - private RubyRange(Ruby runtime, RubyClass klass) { - super(runtime, klass); - begin = end = runtime.getNil(); - } - - public static RubyRange newRange(Ruby runtime, ThreadContext context, IRubyObject begin, IRubyObject end, boolean isExclusive) { - RubyRange range = new RubyRange(runtime, runtime.getRange()); - range.init(context, begin, end, isExclusive); - return range; - } - - public static RubyRange newExclusiveRange(Ruby runtime, ThreadContext context, IRubyObject begin, IRubyObject end) { - RubyRange range = new RubyRange(runtime, runtime.getRange()); - range.init(context, begin, end, true); - return range; - } - - public static RubyRange newInclusiveRange(Ruby runtime, ThreadContext context, IRubyObject begin, IRubyObject end) { - RubyRange range = new RubyRange(runtime, runtime.getRange()); - range.init(context, begin, end, false); - return range; - } - - protected void copySpecialInstanceVariables(IRubyObject clone) { - RubyRange range = (RubyRange)clone; - range.begin = begin; - range.end = end; - range.isExclusive = isExclusive; - } - - final long[] begLen(long len, int err){ - long beg = RubyNumeric.num2long(this.begin); - long end = RubyNumeric.num2long(this.end); - - if (beg < 0) { - beg += len; - if (beg < 0) { - if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); - return null; - } - } - - if (err == 0 || err == 2) { - if (beg > len) { - if (err != 0) throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range"); - return null; - } - if (end > len) end = len; - } - - if (end < 0) end += len; - if (!isExclusive) end++; - len = end - beg; - if (len < 0) len = 0; - - return new long[]{beg, len}; - } - - private void init(ThreadContext context, IRubyObject begin, IRubyObject end, boolean isExclusive) { - if (!(begin instanceof RubyFixnum && end instanceof RubyFixnum)) { - try { - IRubyObject result = begin.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", end); - if (result.isNil()) throw getRuntime().newArgumentError("bad value for range"); - } catch (RaiseException re) { - throw getRuntime().newArgumentError("bad value for range"); - } - } - - this.begin = begin; - this.end = end; - this.isExclusive = isExclusive; - } - - @JRubyMethod(name = "initialize", required = 2, optional = 1, frame = true) - public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block unusedBlock) { - init(context, args[0], args[1], args.length > 2 && args[2].isTrue()); - return getRuntime().getNil(); - } - - @JRubyMethod(name = {"first", "begin"}) - public IRubyObject first() { - return begin; - } - - @JRubyMethod(name = {"last", "end"}) - public IRubyObject last() { - return end; - } - - @JRubyMethod(name = "hash") - public RubyFixnum hash(ThreadContext context) { - long hash = isExclusive ? 1 : 0; - long h = hash; - - long v = begin.callMethod(context, MethodIndex.HASH, "hash").convertToInteger().getLongValue(); - hash ^= v << 1; - v = end.callMethod(context, MethodIndex.HASH, "hash").convertToInteger().getLongValue(); - hash ^= v << 9; - hash ^= h << 24; - return getRuntime().newFixnum(hash); - } - - private static byte[] DOTDOTDOT = "...".getBytes(); - private static byte[] DOTDOT = "..".getBytes(); - - @JRubyMethod(name = "inspect") - public IRubyObject inspect(ThreadContext context) { - RubyString str = inspect(context, begin).strDup(context.getRuntime()); - RubyString str2 = inspect(context, end); - - str.cat(isExclusive ? DOTDOTDOT : DOTDOT); - str.concat(str2); - str.infectBy(str2); - return str; - } - - @JRubyMethod(name = "to_s") - public IRubyObject to_s(ThreadContext context) { - RubyString str = RubyString.objAsString(context, begin).strDup(context.getRuntime()); - RubyString str2 = RubyString.objAsString(context, end); - - str.cat(isExclusive ? DOTDOTDOT : DOTDOT); - str.concat(str2); - str.infectBy(str2); - return str; - - } - - @JRubyMethod(name = "exclude_end?") - public RubyBoolean exclude_end_p() { - return getRuntime().newBoolean(isExclusive); - } - - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if (this == other) return getRuntime().getTrue(); - if (!(other instanceof RubyRange)) return getRuntime().getFalse(); - RubyRange otherRange = (RubyRange) other; - - if (equalInternal(context, begin, otherRange.begin) && - equalInternal(context, end, otherRange.end) && - isExclusive == otherRange.isExclusive) return getRuntime().getTrue(); - - return getRuntime().getFalse(); - } - - @JRubyMethod(name = "eql?", required = 1) - public IRubyObject eql_p(ThreadContext context, IRubyObject other) { - if (this == other) return getRuntime().getTrue(); - if (!(other instanceof RubyRange)) return getRuntime().getFalse(); - RubyRange otherRange = (RubyRange)other; - - if (eqlInternal(context, begin, otherRange.begin) && - eqlInternal(context, end, otherRange.end) && - isExclusive == otherRange.isExclusive) return getRuntime().getTrue(); - - return getRuntime().getFalse(); - } - - private static abstract class RangeCallBack { - abstract void call(ThreadContext context, IRubyObject arg); - } - - private static final class StepBlockCallBack extends RangeCallBack implements BlockCallback { - final Block block; - IRubyObject iter; - final IRubyObject step; - - StepBlockCallBack(Block block, IRubyObject iter, IRubyObject step) { - this.block = block; - this.iter = iter; - this.step = step; - } - - public IRubyObject call(ThreadContext context, IRubyObject[] args, Block originalBlock) { - call(context, args[0]); - return context.getRuntime().getNil(); - } - - void call(ThreadContext context, IRubyObject arg) { - if (iter instanceof RubyFixnum) { - iter = RubyFixnum.newFixnum(context.getRuntime(), ((RubyFixnum)iter).getLongValue() - 1); - } else { - iter = iter.callMethod(context, MethodIndex.OP_MINUS, "-", RubyFixnum.one(context.getRuntime())); - } - if (iter == RubyFixnum.zero(context.getRuntime())) { - block.yield(context, arg); - iter = step; - } - } - } - - private IRubyObject rangeLt(ThreadContext context, IRubyObject a, IRubyObject b) { - IRubyObject result = a.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", b); - if (result.isNil()) return null; - return RubyComparable.cmpint(context, result, a, b) < 0 ? getRuntime().getTrue() : null; - } - - private IRubyObject rangeLe(ThreadContext context, IRubyObject a, IRubyObject b) { - IRubyObject result = a.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", b); - if (result.isNil()) return null; - int c = RubyComparable.cmpint(context, result, a, b); - if (c == 0) return RubyFixnum.zero(getRuntime()); - return c < 0 ? getRuntime().getTrue() : null; - } - - private void rangeEach(ThreadContext context, RangeCallBack callback) { - IRubyObject v = begin; - if (isExclusive) { - while (rangeLt(context, v, end) != null) { - callback.call(context, v); - v = v.callMethod(context, "succ"); - } - } else { - IRubyObject c; - while ((c = rangeLe(context, v, end)) != null && c.isTrue()) { - callback.call(context, v); - if (c == RubyFixnum.zero(getRuntime())) break; - v = v.callMethod(context, "succ"); - } - } - } - - @JRubyMethod(name = "each", frame = true) - public IRubyObject each(ThreadContext context, final Block block) { - final Ruby runtime = context.getRuntime(); - - if (begin instanceof RubyFixnum && end instanceof RubyFixnum) { - long lim = ((RubyFixnum) end).getLongValue(); - if (!isExclusive) lim++; - - for (long i = ((RubyFixnum) begin).getLongValue(); i < lim; i++) { - block.yield(context, RubyFixnum.newFixnum(runtime, i)); - } - } else if (begin instanceof RubyString) { - ((RubyString) begin).upto(context, end, isExclusive, block); - } else { - if (!begin.respondsTo("succ")) throw getRuntime().newTypeError( - "can't iterate from " + begin.getMetaClass().getName()); - rangeEach(context, new RangeCallBack() { - @Override - void call(ThreadContext context, IRubyObject arg) { - block.yield(context, arg); - } - }); - } - return this; - } - - @JRubyMethod(name = "step", optional = 1, frame = true) - public IRubyObject step(ThreadContext context, IRubyObject[] args, Block block) { - final Ruby runtime = context.getRuntime(); - final IRubyObject step; - if (args.length == 0) { - step = RubyFixnum.one(runtime); - } else { - step = args[0]; - } - - long unit = RubyNumeric.num2long(step); - if (unit < 0) throw runtime.newArgumentError("step can't be negative"); - - if (begin instanceof RubyFixnum && end instanceof RubyFixnum) { - if (unit == 0) throw runtime.newArgumentError("step can't be 0"); - - long e = ((RubyFixnum)end).getLongValue(); - if (!isExclusive) e++; - - for (long i = ((RubyFixnum)begin).getLongValue(); i < e; i += unit) { - block.yield(context, RubyFixnum.newFixnum(runtime, i)); - } - } else { - IRubyObject tmp = begin.checkStringType(); - if (!tmp.isNil()) { - if (unit == 0) throw runtime.newArgumentError("step can't be 0"); - // rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter); - StepBlockCallBack callback = new StepBlockCallBack(block, RubyFixnum.one(runtime), step); - Block blockCallback = CallBlock.newCallClosure(this, runtime.getRange(), Arity.singleArgument(), callback, context); - ((RubyString)tmp).upto(context, end, isExclusive, blockCallback); - } else if (begin instanceof RubyNumeric) { - if (equalInternal(context, step, RubyFixnum.zero(runtime))) { - throw runtime.newArgumentError("step can't be 0"); - } - final String method; - final int methodIndex; - if (isExclusive) { - method = "<"; - methodIndex = MethodIndex.OP_LT; - } else { - method = "<="; - methodIndex = MethodIndex.OP_LE; - } - IRubyObject beg = begin; - while (beg.callMethod(context, methodIndex, method, end).isTrue()) { - block.yield(context, beg); - beg = beg.callMethod(context, MethodIndex.OP_PLUS, "+", step); - } - } else { - if (unit == 0) throw runtime.newArgumentError("step can't be 0"); - if (!begin.respondsTo("succ")) throw runtime.newTypeError( - "can't iterate from " + begin.getMetaClass().getName()); - // range_each_func(range, step_i, b, e, args); - rangeEach(context, new StepBlockCallBack(block, RubyFixnum.one(runtime), step)); - } - } - return this; - } - - @JRubyMethod(name = {"include?", "member?", "==="}, required = 1) - public RubyBoolean include_p(ThreadContext context, IRubyObject obj) { - if (rangeLe(context, begin, obj) != null) { - if (isExclusive) { - if (rangeLt(context, obj, end) != null) return context.getRuntime().getTrue(); - } else { - if (rangeLe(context, obj, end) != null) return context.getRuntime().getTrue(); - } - } - return context.getRuntime().getFalse(); - } - - private static final ObjectMarshal RANGE_MARSHAL = new ObjectMarshal() { - public void marshalTo(Ruby runtime, Object obj, RubyClass type, - MarshalStream marshalStream) throws IOException { - RubyRange range = (RubyRange)obj; - - marshalStream.registerLinkTarget(range); - List<Variable<IRubyObject>> attrs = range.getVariableList(); - - attrs.add(new VariableEntry<IRubyObject>("begin", range.begin)); - attrs.add(new VariableEntry<IRubyObject>("end", range.end)); - attrs.add(new VariableEntry<IRubyObject>("excl", range.isExclusive ? runtime.getTrue() : runtime.getFalse())); - - marshalStream.dumpVariables(attrs); - } - - public Object unmarshalFrom(Ruby runtime, RubyClass type, - UnmarshalStream unmarshalStream) throws IOException { - RubyRange range = (RubyRange)type.allocate(); - - unmarshalStream.registerLinkTarget(range); - - unmarshalStream.defaultVariablesUnmarshal(range); - - range.begin = range.removeInternalVariable("begin"); - range.end = range.removeInternalVariable("end"); - range.isExclusive = range.removeInternalVariable("excl").isTrue(); - - return range; - } - }; -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import static org.jruby.util.Numeric.f_add; -import static org.jruby.util.Numeric.f_cmp; -import static org.jruby.util.Numeric.f_div; -import static org.jruby.util.Numeric.f_equal_p; -import static org.jruby.util.Numeric.f_expt; -import static org.jruby.util.Numeric.f_floor; -import static org.jruby.util.Numeric.f_gcd; -import static org.jruby.util.Numeric.f_idiv; -import static org.jruby.util.Numeric.f_mul; -import static org.jruby.util.Numeric.f_negate; -import static org.jruby.util.Numeric.f_negative_p; -import static org.jruby.util.Numeric.f_one_p; -import static org.jruby.util.Numeric.f_rshift; -import static org.jruby.util.Numeric.f_sub; -import static org.jruby.util.Numeric.f_to_f; -import static org.jruby.util.Numeric.f_to_i; -import static org.jruby.util.Numeric.f_to_r; -import static org.jruby.util.Numeric.f_to_s; -import static org.jruby.util.Numeric.f_truncate; -import static org.jruby.util.Numeric.f_xor; -import static org.jruby.util.Numeric.f_zero_p; -import static org.jruby.util.Numeric.i_gcd; -import static org.jruby.util.Numeric.i_ilog2; -import static org.jruby.util.Numeric.ldexp; - -import org.joni.encoding.specific.ASCIIEncoding; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Arity; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.Frame; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.Numeric; - -/** - * 1.9 rational.c as of revision: 18876 - */ - -@JRubyClass(name = "Rational", parent = "Numeric", include = "Precision") -public class RubyRational extends RubyNumeric { - - public static RubyClass createRationalClass(Ruby runtime) { - RubyClass rationalc = runtime.defineClass("Rational", runtime.getNumeric(), RATIONAL_ALLOCATOR); // because one can Complex.send(:allocate) - runtime.setRational(rationalc); - - rationalc.index = ClassIndex.RATIONAL; - rationalc.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyRational; - } - }; - - ThreadContext context = runtime.getCurrentContext(); - rationalc.callMethod(context, "private_class_method", runtime.newSymbol("allocate")); - - rationalc.defineAnnotatedMethods(RubyRational.class); - - return rationalc; - } - - private static ObjectAllocator RATIONAL_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyRational(runtime, klass, RubyFixnum.zero(runtime), RubyFixnum.one(runtime)); - } - }; - - /** internal - * - */ - private RubyRational(Ruby runtime, IRubyObject clazz, IRubyObject num, IRubyObject den) { - super(runtime, (RubyClass)clazz); - this.num = num; - this.den = den; - } - - /** rb_rational_raw - * - */ - static RubyRational newRationalRaw(Ruby runtime, IRubyObject x, RubyObject y) { - return new RubyRational(runtime, runtime.getRational(), x, y); - } - - /** rb_rational_raw1 - * - */ - static RubyRational newRationalRaw(Ruby runtime, IRubyObject x) { - return new RubyRational(runtime, runtime.getRational(), x, RubyFixnum.one(runtime)); - } - - /** rb_rational_new1 - * - */ - static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x) { - return newRationalCanonicalize(context, x, RubyFixnum.one(context.getRuntime())); - } - - /** rb_rational_new - * - */ - private static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) { - return canonicalizeInternal(context, context.getRuntime().getRational(), x, y); - } - - /** f_rational_new2 - * - */ - private static IRubyObject newRational(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert x instanceof RubyRational && y instanceof RubyRational; - return canonicalizeInternal(context, clazz, x, y); - } - - /** f_rational_new1 - * - */ - private static IRubyObject newRational(ThreadContext context, IRubyObject clazz, IRubyObject x) { - assert x instanceof RubyRational; - return canonicalizeInternal(context, clazz, x, RubyFixnum.one(context.getRuntime())); - } - - /** f_rational_new_no_reduce2 - * - */ - private static IRubyObject newRationalNoReduce(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert x instanceof RubyRational && y instanceof RubyRational; - return canonicalizeInternalNoReduce(context, clazz, x, y); - } - - /** f_rational_new_no_reduce1 - * - */ - private static IRubyObject newRationalNoReduce(ThreadContext context, IRubyObject clazz, IRubyObject x) { - assert x instanceof RubyRational; - return canonicalizeInternalNoReduce(context, clazz, x, RubyFixnum.one(context.getRuntime())); - } - - /** f_rational_new_bang2 - * - */ - private static RubyRational newRationalBang(ThreadContext context, IRubyObject clazz, IRubyObject x, IRubyObject y) { - assert !f_negative_p(context, y) && !(f_zero_p(context, y)); - return new RubyRational(context.getRuntime(), clazz, x, y); - } - - /** f_rational_new_bang1 - * - */ - private static RubyRational newRationalBang(ThreadContext context, IRubyObject clazz, IRubyObject x) { - return newRationalBang(context, clazz, x, RubyFixnum.one(context.getRuntime())); - } - - private IRubyObject num; - private IRubyObject den; - - /** nurat_s_new_bang - * - */ - @Deprecated - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject[]args) { - switch (args.length) { - case 1: return newInstanceBang(context, recv, args[0]); - case 2: return newInstanceBang(context, recv, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 1); - return null; - } - - @JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject num) { - return newInstanceBang(context, recv, num, RubyFixnum.one(context.getRuntime())); - } - - @JRubyMethod(name = "new!", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject newInstanceBang(ThreadContext context, IRubyObject recv, IRubyObject num, IRubyObject den) { - if (!(num instanceof RubyInteger)) num = f_to_i(context, num); - if (!(den instanceof RubyInteger)) den = f_to_i(context, den); - - Ruby runtime = context.getRuntime(); - IRubyObject res = f_cmp(context, den, RubyFixnum.zero(runtime)); - if (res == RubyFixnum.minus_one(runtime)) { - num = f_negate(context, num); - den = f_negate(context, den); - } else if (res == RubyFixnum.zero(runtime)) { - throw runtime.newZeroDivisionError(); - } - - return new RubyRational(runtime, recv, num, den); - } - - /** nurat_int_check - * - */ - private static void intCheck(IRubyObject num) { - if (!(num instanceof RubyFixnum ) && !(num instanceof RubyBignum)) throw num.getRuntime().newArgumentError("not an integer"); - } - - /** nurat_s_canonicalize_internal - * - */ - private static IRubyObject canonicalizeInternal(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) { - Ruby runtime = context.getRuntime(); - IRubyObject res = f_cmp(context, den, RubyFixnum.zero(runtime)); - if (res == RubyFixnum.minus_one(runtime)) { - num = f_negate(context, num); - den = f_negate(context, den); - } else if (res == RubyFixnum.zero(runtime)) { - throw runtime.newZeroDivisionError(); - } - - IRubyObject gcd = f_gcd(context, num, den); - num = f_idiv(context, num, gcd); - den = f_idiv(context, den, gcd); - - if (f_one_p(context, den) && ((RubyModule)clazz).fastHasConstant("Unify")) return num; - return new RubyRational(context.getRuntime(), clazz, num, den); - } - - /** nurat_s_canonicalize_internal_no_reduce - * - */ - private static IRubyObject canonicalizeInternalNoReduce(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) { - Ruby runtime = context.getRuntime(); - IRubyObject res = f_cmp(context, den, RubyFixnum.zero(runtime)); - if (res == RubyFixnum.minus_one(runtime)) { - num = f_negate(context, num); - den = f_negate(context, den); - } else if (res == RubyFixnum.zero(runtime)) { - throw runtime.newZeroDivisionError(); - } - - if (f_equal_p(context, den, RubyFixnum.one(runtime)) && ((RubyModule)clazz).fastHasConstant("Unify")) return num; - return new RubyRational(context.getRuntime(), clazz, num, den); - } - - /** nurat_s_new - * - */ - @Deprecated - public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject[]args) { - switch (args.length) { - case 1: return newInstance(context, clazz, args[0]); - case 2: return newInstance(context, clazz, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 1); - return null; - } - - @JRubyMethod(name = "new", meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num) { - intCheck(num); - return canonicalizeInternal(context, clazz, num, RubyFixnum.one(context.getRuntime())); - } - - @JRubyMethod(name = "new", meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) { - intCheck(num); - intCheck(den); - return canonicalizeInternal(context, clazz, num, den); - } - - /** rb_Rational1 - * - */ - public static IRubyObject newRationalConvert(ThreadContext context, IRubyObject x) { - return newRationalConvert(context, x, RubyFixnum.one(context.getRuntime())); - } - - /** rb_Rational/rb_Rational2 - * - */ - public static IRubyObject newRationalConvert(ThreadContext context, IRubyObject x, IRubyObject y) { - return convert(context, context.getRuntime().getRational(), x, y); - } - - @Deprecated - public static IRubyObject convert(ThreadContext context, IRubyObject clazz, IRubyObject[]args) { - switch (args.length) { - case 0: return convert(context, clazz); - case 1: return convert(context, clazz, args[0]); - case 2: return convert(context, clazz, args[0], args[1]); - } - Arity.raiseArgumentError(context.getRuntime(), args.length, 0, 2); - return null; - } - - /** nurat_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv) { - IRubyObject nil = context.getRuntime().getNil(); - return convertCommon(context, recv, nil, nil); - } - - /** nurat_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1) { - return convertCommon(context, recv, a1, context.getRuntime().getNil()); - } - - /** nurat_s_convert - * - */ - @JRubyMethod(name = "convert", meta = true, visibility = Visibility.PRIVATE) - public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) { - return convertCommon(context, recv, a1, a2); - } - - private static IRubyObject convertCommon(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) { - if (a1 instanceof RubyComplex) { - RubyComplex a1Complex = (RubyComplex)a1; - if (a1Complex.getImage() instanceof RubyFloat || !f_zero_p(context, a1Complex.getImage())) { - IRubyObject s = f_to_s(context, a1); - throw context.getRuntime().newArgumentError("can't accept " + s.convertToString()); - } - a1 = a1Complex.getReal(); - } - if (a2 instanceof RubyComplex) { - RubyComplex a2Complex = (RubyComplex)a2; - if (a2Complex.getImage() instanceof RubyFloat || !f_zero_p(context, a2Complex.getImage())) { - IRubyObject s = f_to_s(context, a2); - throw context.getRuntime().newArgumentError("can't accept " + s.convertToString()); - } - a2 = a2Complex.getReal(); - } - - Frame frame = context.getCurrentFrame(); - IRubyObject backref = frame.getBackRef(); - if (backref != null && backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); - - if (a1 instanceof RubyFloat) { - a1 = f_to_r(context, a1); - } else if (a1 instanceof RubyString) { - a1 = str_to_r_strict(context, a1); - } - - if (a2 instanceof RubyFloat) { - a2 = f_to_r(context, a2); - } else if (a2 instanceof RubyString) { - a2 = str_to_r_strict(context, a2); - } - - frame.setBackRef(backref); - - if (a1 instanceof RubyRational) { - if (a2.isNil() || f_zero_p(context, a2)) return a1; - return f_div(context, a1, a2); - } - - if (a2 instanceof RubyRational) { - return f_div(context, a1, a2); - } - - return a2.isNil() ? newInstance(context, recv, a1) : newInstance(context, recv, a1, a2); - } - - /** nurat_s_induced_from - * - */ - @JRubyMethod(name = "induced_from", meta = true) - public static IRubyObject induced_from(ThreadContext context, IRubyObject recv, IRubyObject arg) { - return f_to_r(context, arg); - } - - /** nurat_numerator - * - */ - @JRubyMethod(name = "numerator") - public IRubyObject numerator(ThreadContext context) { - return num; - } - - /** nurat_denominator - * - */ - @JRubyMethod(name = "denominator") - public IRubyObject denominator(ThreadContext context) { - return den; - } - - /** f_imul - * - */ - private static IRubyObject f_imul(ThreadContext context, long a, long b) { - Ruby runtime = context.getRuntime(); - if (a == 0 || b == 0) { - return RubyFixnum.zero(runtime); - } else if (a == 1) { - return RubyFixnum.newFixnum(runtime, b); - } else if (b == 1) { - return RubyFixnum.newFixnum(runtime, a); - } - - long c = a * b; - if(c / a != b) { - return RubyBignum.newBignum(runtime, a).op_mul(context, RubyBignum.newBignum(runtime, b)); - } - return RubyFixnum.newFixnum(runtime, c); - } - - /** f_addsub - * - */ - private IRubyObject f_addsub(ThreadContext context, IRubyObject anum, IRubyObject aden, IRubyObject bnum, IRubyObject bden, boolean plus) { - Ruby runtime = context.getRuntime(); - IRubyObject num, den, g, a, b; - if (anum instanceof RubyFixnum && aden instanceof RubyFixnum && - bnum instanceof RubyFixnum && bden instanceof RubyFixnum) { - long an = ((RubyFixnum)anum).getLongValue(); - long ad = ((RubyFixnum)aden).getLongValue(); - long bn = ((RubyFixnum)bnum).getLongValue(); - long bd = ((RubyFixnum)bden).getLongValue(); - long ig = i_gcd(ad, bd); - - g = RubyFixnum.newFixnum(runtime, ig); - a = f_imul(context, an, bd / ig); - b = f_imul(context, bn, ad / ig); - } else { - g = f_gcd(context, aden, bden); - a = f_mul(context, anum, f_idiv(context, bden, g)); - b = f_mul(context, bnum, f_idiv(context, aden, g)); - } - - IRubyObject c = plus ? f_add(context, a, b) : f_sub(context, a, b); - - b = f_idiv(context, aden, g); - g = f_gcd(context, c, g); - num = f_idiv(context, c, g); - a = f_idiv(context, bden, g); - den = f_mul(context, a, b); - - return RubyRational.newRationalNoReduce(context, getMetaClass(), num, den); - } - - /** nurat_add - * - */ - @JRubyMethod(name = "+") - public IRubyObject op_add(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), true); - case ClassIndex.FLOAT: - return f_add(context, f_to_f(context, this), other); - case ClassIndex.RATIONAL: - RubyRational otherRational = (RubyRational)other; - return f_addsub(context, num, den, otherRational.num, otherRational.den, true); - } - return coerceBin(context, "+", other); - } - - /** nurat_sub - * - */ - @JRubyMethod(name = "-") - public IRubyObject op_sub(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - return f_addsub(context, num, den, other, RubyFixnum.one(context.getRuntime()), false); - case ClassIndex.FLOAT: - return f_sub(context, f_to_f(context, this), other); - case ClassIndex.RATIONAL: - RubyRational otherRational = (RubyRational)other; - return f_addsub(context, num, den, otherRational.num, otherRational.den, false); - } - return coerceBin(context, "-", other); - } - - /** f_muldiv - * - */ - private IRubyObject f_muldiv(ThreadContext context, IRubyObject anum, IRubyObject aden, IRubyObject bnum, IRubyObject bden, boolean mult) { - if (!mult) { - if (f_negative_p(context, bnum)) { - anum = f_negate(context, anum); - bnum = f_negate(context, bnum); - } - IRubyObject tmp = bnum; - bnum = bden; - bden = tmp; - } - - final IRubyObject num, den; - if (anum instanceof RubyFixnum && aden instanceof RubyFixnum && - bnum instanceof RubyFixnum && bden instanceof RubyFixnum) { - long an = ((RubyFixnum)anum).getLongValue(); - long ad = ((RubyFixnum)aden).getLongValue(); - long bn = ((RubyFixnum)bnum).getLongValue(); - long bd = ((RubyFixnum)bden).getLongValue(); - long g1 = i_gcd(an, bd); - long g2 = i_gcd(ad, bn); - - num = f_imul(context, an / g1, bn / g2); - den = f_imul(context, ad / g2, bd / g1); - } else { - IRubyObject g1 = f_gcd(context, anum, bden); - IRubyObject g2 = f_gcd(context, aden, bnum); - - num = f_mul(context, f_idiv(context, anum, g1), f_idiv(context, bnum, g2)); - den = f_mul(context, f_idiv(context, aden, g2), f_idiv(context, bden, g1)); - } - return RubyRational.newRationalNoReduce(context, getMetaClass(), num, den); - - } - - /** nurat_mul - * - */ - @JRubyMethod(name = "*") - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), true); - case ClassIndex.FLOAT: - return f_mul(context, f_to_f(context, this), other); - case ClassIndex.RATIONAL: - RubyRational otherRational = (RubyRational)other; - return f_muldiv(context, num, den, otherRational.num, otherRational.den, true); - } - return coerceBin(context, "*", other); - } - - /** nurat_div - * - */ - @JRubyMethod(name = "/") - public IRubyObject op_div(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - if (f_zero_p(context, other)) throw context.getRuntime().newZeroDivisionError(); - return f_muldiv(context, num, den, other, RubyFixnum.one(context.getRuntime()), false); - case ClassIndex.FLOAT: - return f_to_f(context, this).callMethod(context, "/", other); - case ClassIndex.RATIONAL: - if (f_zero_p(context, other)) throw context.getRuntime().newZeroDivisionError(); - RubyRational otherRational = (RubyRational)other; - return f_muldiv(context, num, den, otherRational.num, otherRational.den, false); - } - return coerceBin(context, "/", other); - } - - /** nurat_fdiv - * - */ - @JRubyMethod(name = "fdiv") - public IRubyObject op_fdiv(ThreadContext context, IRubyObject other) { - return f_div(context, f_to_f(context, this), other); - } - - /** nurat_expt - * - */ - @JRubyMethod(name = "**") - public IRubyObject op_expt(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - - if (f_zero_p(context, other)) { - return RubyRational.newRationalBang(context, getMetaClass(), RubyFixnum.one(runtime)); - } - - if (other instanceof RubyRational) { - RubyRational otherRational = (RubyRational)other; - if (f_one_p(context, otherRational.den)) other = otherRational.num; - } - - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - final IRubyObject tnum, tden; - IRubyObject res = f_cmp(context, other, RubyFixnum.zero(runtime)); - if (res == RubyFixnum.one(runtime)) { - tnum = f_expt(context, num, other); - tden = f_expt(context, den, other); - } else if (res == RubyFixnum.minus_one(runtime)){ - tnum = f_expt(context, den, f_negate(context, other)); - tden = f_expt(context, num, f_negate(context, other)); - } else { - tnum = tden = RubyFixnum.one(runtime); - } - return RubyRational.newRational(context, getMetaClass(), tnum, tden); - case ClassIndex.FLOAT: - case ClassIndex.RATIONAL: - return f_expt(context, f_to_f(context, this), other); - } - return coerceBin(context, "**", other); - } - - - /** nurat_cmp - * - */ - @JRubyMethod(name = "<=>") - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - if (den instanceof RubyFixnum && ((RubyFixnum)den).getLongValue() == 1) return f_cmp(context, num, other); - return f_cmp(context, this, RubyRational.newRationalBang(context, getMetaClass(), other)); - - case ClassIndex.FLOAT: - return f_cmp(context, f_to_f(context, this), other); - - case ClassIndex.RATIONAL: - RubyRational otherRational = (RubyRational)other; - final IRubyObject num1, num2; - if (num instanceof RubyFixnum && den instanceof RubyFixnum && - otherRational.num instanceof RubyFixnum && otherRational.den instanceof RubyFixnum) { - num1 = f_imul(context, ((RubyFixnum)num).getLongValue(), ((RubyFixnum)otherRational.den).getLongValue()); - num2 = f_imul(context, ((RubyFixnum)otherRational.num).getLongValue(), ((RubyFixnum)den).getLongValue()); - } else { - num1 = f_mul(context, num, otherRational.den); - num2 = f_mul(context, otherRational.num, den); - } - return f_cmp(context, f_sub(context, num1, num2), RubyFixnum.zero(context.getRuntime())); - } - return coerceBin(context, "<=>", other); - } - - /** nurat_equal_p - * - */ - @JRubyMethod(name = "==") - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - if (f_zero_p(context, num) && f_zero_p(context, den)) return runtime.getTrue(); - if (!(den instanceof RubyFixnum) || ((RubyFixnum)den).getLongValue() != 1) return runtime.getFalse(); - if (f_equal_p(context, num, other)) return runtime.getTrue(); - return runtime.getFalse(); - - case ClassIndex.FLOAT: - return f_equal_p(context, f_to_f(context, this), other) ? runtime.getTrue() : runtime.getFalse(); - - case ClassIndex.RATIONAL: - RubyRational otherRational = (RubyRational)other; - if (f_zero_p(context, num) && f_zero_p(context, otherRational.num)) return runtime.getTrue(); - if (f_equal_p(context, num, otherRational.num) && f_equal_p(context, den, otherRational.den)) return runtime.getTrue(); - return runtime.getFalse(); - } - return f_equal_p(context, other, this) ? runtime.getTrue() : runtime.getFalse(); - } - - /** nurat_coerce - * - */ - @JRubyMethod(name = "coerce") - public IRubyObject op_coerce(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - switch (other.getMetaClass().index) { - case ClassIndex.FIXNUM: - case ClassIndex.BIGNUM: - return runtime.newArray(RubyRational.newRationalBang(context, getMetaClass(), other), this); - case ClassIndex.FLOAT: - return runtime.newArray(other, f_to_f(context, this)); - } - throw runtime.newTypeError(other.getMetaClass() + " can't be coerced into " + getMetaClass()); - } - - /** nurat_idiv - * - */ - @JRubyMethod(name = "div") - public IRubyObject op_idiv(ThreadContext context, IRubyObject other) { - return f_floor(context, f_div(context, this, other)); - } - - /** nurat_mod - * - */ - @JRubyMethod(name = {"modulo", "%"}) - public IRubyObject op_mod(ThreadContext context, IRubyObject other) { - IRubyObject val = f_floor(context, f_div(context, this, other)); - return f_sub(context, this, f_mul(context, other, val)); - } - - /** nurat_divmod - * - */ - @JRubyMethod(name = "divmod") - public IRubyObject op_divmod(ThreadContext context, IRubyObject other) { - IRubyObject val = f_floor(context, f_div(context, this, other)); - return context.getRuntime().newArray(val, f_sub(context, this, f_mul(context, other, val))); - } - - /** nurat_rem - * - */ - @JRubyMethod(name = "remainder") - public IRubyObject op_rem(ThreadContext context, IRubyObject other) { - IRubyObject val = f_truncate(context, f_div(context, this, other)); - return f_sub(context, this, f_mul(context, other, val)); - } - - /** nurat_abs - * - */ - @JRubyMethod(name = "abs") - public IRubyObject op_abs(ThreadContext context) { - if (!f_negative_p(context, this)) return this; - return f_negate(context, this); - } - - /** nurat_floor - * - */ - @JRubyMethod(name = "floor") - public IRubyObject op_floor(ThreadContext context) { - return f_idiv(context, num, den); - } - - /** nurat_ceil - * - */ - @JRubyMethod(name = "ceil") - public IRubyObject op_ceil(ThreadContext context) { - return f_negate(context, f_idiv(context, f_negate(context, num), den)); - } - - /** nurat_truncate - * - */ - @JRubyMethod(name = {"truncate", "to_i"}) - public IRubyObject op_truncate(ThreadContext context) { - if (f_negative_p(context, num)) { - return f_negate(context, f_idiv(context, f_negate(context, num), den)); - } - return f_idiv(context, num, den); - } - - /** nurat_round - * - */ - @JRubyMethod(name = "round") - public IRubyObject op_round(ThreadContext context) { - IRubyObject two = RubyFixnum.two(context.getRuntime()); - if (f_negative_p(context, num)) { - IRubyObject tnum = f_negate(context, num); - tnum = f_add(context, f_mul(context, tnum, two), den); - IRubyObject tden = f_mul(context, den, two); - return f_negate(context, f_idiv(context, tnum, tden)); - } else { - IRubyObject tnum = f_add(context, f_mul(context, num, two), den); - IRubyObject tden = f_mul(context, den, two); - return f_idiv(context, tnum, tden); - } - } - - /** nurat_to_f - * - */ - private static long ML = (long)(Math.log(Double.MAX_VALUE) / Math.log(2.0) - 1); - @JRubyMethod(name = "to_f") - public IRubyObject to_f(ThreadContext context) { - Ruby runtime = context.getRuntime(); - if (f_zero_p(context, num)) return runtime.newFloat(0); - - IRubyObject num = this.num; - IRubyObject den = this.den; - - boolean minus = false; - if (f_negative_p(context, num)) { - num = f_negate(context, num); - minus = true; - } - - long nl = i_ilog2(context, num); - long dl = i_ilog2(context, den); - - long ne = 0; - if (nl > ML) { - ne = nl - ML; - num = f_rshift(context, num, RubyFixnum.newFixnum(runtime, ne)); - } - - long de = 0; - if (dl > ML) { - de = dl - ML; - den = f_rshift(context, den, RubyFixnum.newFixnum(runtime, de)); - } - - long e = ne - de; - - if (e > 1023 || e < -1022) { - runtime.getWarnings().warn(IRubyWarnings.ID.FLOAT_OUT_OF_RANGE, "out of Float range", getMetaClass()); - return runtime.newFloat(e > 0 ? Double.MAX_VALUE : 0); - } - - double f = RubyNumeric.num2dbl(num) / RubyNumeric.num2dbl(den); - - if (minus) { - f = -f; - f = ldexp(f, e); - } - - if (Double.isInfinite(f) || Double.isNaN(f)) { - runtime.getWarnings().warn(IRubyWarnings.ID.FLOAT_OUT_OF_RANGE, "out of Float range", getMetaClass()); - } - - return runtime.newFloat(f); - } - - /** nurat_to_r - * - */ - @JRubyMethod(name = "to_r") - public IRubyObject to_r(ThreadContext context) { - return this; - } - - /** nurat_to_r - * - */ - @JRubyMethod(name = "hash") - public IRubyObject hash(ThreadContext context) { - return f_xor(context, num, den); - } - - /** nurat_to_s - * - */ - @JRubyMethod(name = "to_s") - public IRubyObject to_s(ThreadContext context) { - return RuntimeHelpers.invoke(context, context.getRuntime().getKernel(), "format", context.getRuntime().newString("%d/%d"), num, den); - } - - /** nurat_inspect - * - */ - @JRubyMethod(name = "inspect") - public IRubyObject inspect(ThreadContext context) { - return RuntimeHelpers.invoke(context, context.getRuntime().getKernel(), "format", context.getRuntime().newString("(%d/%d)"), num, den); - } - - /** nurat_marshal_dump - * - */ - @JRubyMethod(name = "marshal_dump") - public IRubyObject marshal_dump(ThreadContext context) { - return context.getRuntime().newArray(num, den); - } - - /** nurat_marshal_load - * - */ - @JRubyMethod(name = "marshal_load") - public IRubyObject marshal_load(ThreadContext context, IRubyObject arg) { - RubyArray a = arg.convertToArray(); - num = a.size() > 0 ? a.eltInternal(0) : context.getRuntime().getNil(); - den = a.size() > 1 ? a.eltInternal(1) : context.getRuntime().getNil(); - - if (f_zero_p(context, den)) throw context.getRuntime().newZeroDivisionError(); - return this; - } - - /** rb_gcd - * - */ - @JRubyMethod(name = "gcd") - public IRubyObject gcd(ThreadContext context, IRubyObject other) { - intCheck(other); - return f_gcd(context, this, other); - } - - /** rb_lcm - * - */ - @JRubyMethod(name = "lcm") - public IRubyObject lcm(ThreadContext context, IRubyObject other) { - intCheck(other); - return Numeric.f_lcm(context, this, other); - } - - /** rb_gcdlcm - * - */ - @JRubyMethod(name = "gcdlcm") - public IRubyObject gcdlcm(ThreadContext context, IRubyObject other) { - intCheck(other); - return context.getRuntime().newArray(f_gcd(context, this, other), Numeric.f_lcm(context, this, other)); - } - - - static RubyArray str_to_r_internal(ThreadContext context, IRubyObject recv) { - RubyString s = recv.callMethod(context, "strip").convertToString(); - ByteList bytes = s.getByteList(); - - Ruby runtime = context.getRuntime(); - if (bytes.realSize == 0) return runtime.newArray(runtime.getNil(), recv); - - IRubyObject m = RubyRegexp.newRegexp(runtime, Numeric.RationalPatterns.rat_pat).callMethod(context, "match", s); - - if (!m.isNil()) { - IRubyObject si = m.callMethod(context, "[]", RubyFixnum.one(runtime)); - IRubyObject nu = m.callMethod(context, "[]", RubyFixnum.two(runtime)); - IRubyObject de = m.callMethod(context, "[]", RubyFixnum.three(runtime)); - IRubyObject re = m.callMethod(context, "post_match"); - - RubyArray a = nu.callMethod(context, "split", RubyRegexp.newRegexp(runtime, Numeric.RationalPatterns.an_e_pat)).convertToArray(); - IRubyObject ifp = a.eltInternal(0); - IRubyObject exp = a.size() != 2 ? runtime.getNil() : a.eltInternal(1); - - a = ifp.callMethod(context, "split", RubyRegexp.newRegexp(runtime, Numeric.RationalPatterns.a_dot_pat)).convertToArray(); - IRubyObject ip = a.eltInternal(0); - IRubyObject fp = a.size() != 2 ? runtime.getNil() : a.eltInternal(1); - - IRubyObject v = RubyRational.newRationalCanonicalize(context, f_to_i(context, ip)); - - if (!fp.isNil()) { - bytes = fp.convertToString().getByteList(); - int count = 0; - byte[]buf = bytes.bytes; - int i = bytes.begin; - int end = i + bytes.realSize; - while (i < end) if (ASCIIEncoding.INSTANCE.isDigit(buf[i++])) count++; - IRubyObject l = f_expt(context, RubyFixnum.newFixnum(runtime, 10), RubyFixnum.newFixnum(runtime, count)); - v = f_mul(context, v, l); - v = f_add(context, v, f_to_i(context, fp)); - v = f_div(context, v, l); - } - if (!exp.isNil()) { - v = f_mul(context, v, f_expt(context, RubyFixnum.newFixnum(runtime, 10), f_to_i(context, exp))); - } - if (!si.isNil()) { - bytes = si.convertToString().getByteList(); - if (bytes.length() > 0 && bytes.get(0) == '-') v = f_negate(context, v); - } - if (!de.isNil()) { - v = f_div(context, v, f_to_i(context, de)); - } - return runtime.newArray(v, re); - } - return runtime.newArray(runtime.getNil(), recv); - } - - private static IRubyObject str_to_r_strict(ThreadContext context, IRubyObject recv) { - RubyArray a = str_to_r_internal(context, recv); - if (a.eltInternal(0).isNil() || a.eltInternal(1).convertToString().getByteList().length() > 0) { - IRubyObject s = recv.callMethod(context, "inspect"); - throw context.getRuntime().newArgumentError("invalid value for Rational: " + s.convertToString()); - } - return a.eltInternal(0); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004-2005 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C) 2006 Nick Sieger <nicksieger@gmail.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.ref.SoftReference; -import java.util.concurrent.ConcurrentHashMap; -import java.util.Iterator; -import java.util.Map; - -import org.joni.Matcher; -import org.joni.NameEntry; -import org.joni.Option; -import org.joni.Regex; -import org.joni.Region; -import org.joni.Syntax; -import org.joni.WarnCallback; -import org.joni.encoding.Encoding; -import org.joni.exception.JOniException; - -import static org.jruby.anno.FrameField.*; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.parser.ReOptions; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.Frame; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; -import org.jruby.util.KCode; -import org.jruby.util.TypeConverter; - -/** - * - */ -@JRubyClass(name="Regexp") -public class RubyRegexp extends RubyObject implements ReOptions, WarnCallback { - private KCode kcode; - private Regex pattern; - private ByteList str; - - private static final int REGEXP_LITERAL_F = 1 << 11; - private static final int REGEXP_KCODE_DEFAULT = 1 << 12; - - public void setLiteral() { - flags |= REGEXP_LITERAL_F; - } - - public void clearLiteral() { - flags &= ~REGEXP_LITERAL_F; - } - - public boolean isLiteral() { - return (flags & REGEXP_LITERAL_F) != 0; - } - - public void setKCodeDefault() { - flags |= REGEXP_KCODE_DEFAULT; - } - - public void clearKCodeDefault() { - flags &= ~REGEXP_KCODE_DEFAULT; - } - - public boolean isKCodeDefault() { - return (flags & REGEXP_KCODE_DEFAULT) != 0; - } - - public KCode getKCode() { - return kcode; - } - - private static Map<ByteList, Regex> getPatternCache() { - Map<ByteList, Regex> cache = patternCache.get(); - if (cache == null) { - cache = new ConcurrentHashMap<ByteList, Regex>(5); - patternCache = new SoftReference<Map<ByteList, Regex>>(cache); - } - return cache; - } - - static volatile SoftReference<Map<ByteList, Regex>> patternCache = new SoftReference<Map<ByteList, Regex>>(null); - - public static RubyClass createRegexpClass(Ruby runtime) { - RubyClass regexpClass = runtime.defineClass("Regexp", runtime.getObject(), REGEXP_ALLOCATOR); - runtime.setRegexp(regexpClass); - regexpClass.index = ClassIndex.REGEXP; - regexpClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyRegexp; - } - }; - - regexpClass.defineConstant("IGNORECASE", runtime.newFixnum(RE_OPTION_IGNORECASE)); - regexpClass.defineConstant("EXTENDED", runtime.newFixnum(RE_OPTION_EXTENDED)); - regexpClass.defineConstant("MULTILINE", runtime.newFixnum(RE_OPTION_MULTILINE)); - - regexpClass.defineAnnotatedMethods(RubyRegexp.class); - - return regexpClass; - } - - private static ObjectAllocator REGEXP_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyRegexp instance = new RubyRegexp(runtime, klass); - return instance; - } - }; - - /** used by allocator - * - */ - private RubyRegexp(Ruby runtime, RubyClass klass) { - super(runtime, klass); - } - - /** default constructor - * - */ - private RubyRegexp(Ruby runtime) { - super(runtime, runtime.getRegexp()); - } - - // used only by the compiler/interpreter (will set the literal flag) - public static RubyRegexp newRegexp(Ruby runtime, String pattern, int options) { - return newRegexp(runtime, ByteList.create(pattern), options); - } - - // used only by the compiler/interpreter (will set the literal flag) - public static RubyRegexp newRegexp(Ruby runtime, ByteList pattern, int options) { - RubyRegexp regexp = newRegexp(runtime, pattern, options, false); - regexp.setLiteral(); - return regexp; - } - - public static RubyRegexp newRegexp(Ruby runtime, ByteList pattern, int options, boolean quote) { - RubyRegexp regexp = new RubyRegexp(runtime); - regexp.initialize(pattern, options, quote); - return regexp; - } - - // internal usage - static RubyRegexp newRegexp(Ruby runtime, Regex regex) { - RubyRegexp regexp = new RubyRegexp(runtime); - regexp.pattern = regex; - regexp.str = ByteList.EMPTY_BYTELIST; - return regexp; - } - - public void warn(String message) { - getRuntime().getWarnings().warn(ID.MISCELLANEOUS, message); - } - - @JRubyMethod(name = "kcode") - public IRubyObject kcode(ThreadContext context) { - return (!isKCodeDefault() && kcode != null) ? - context.getRuntime().newString(kcode.name()) : context.getRuntime().getNil(); - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.REGEXP; - } - - public Regex getPattern() { - return pattern; - } - - private void check() { - if (pattern == null || str == null) throw getRuntime().newTypeError("uninitialized Regexp"); - } - - @JRubyMethod(name = "hash") - @Override - public RubyFixnum hash() { - check(); - int hashval = (int)pattern.getOptions(); - int len = this.str.realSize; - int p = this.str.begin; - while (len-->0) { - hashval = hashval * 33 + str.bytes[p++]; - } - hashval = hashval + (hashval>>5); - return getRuntime().newFixnum(hashval); - } - - @JRubyMethod(name = {"==", "eql?"}, required = 1) - @Override - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if(this == other) return context.getRuntime().getTrue(); - if(!(other instanceof RubyRegexp)) return context.getRuntime().getFalse(); - RubyRegexp otherRegex = (RubyRegexp)other; - - check(); - otherRegex.check(); - - return context.getRuntime().newBoolean(str.equal(otherRegex.str) && - kcode == otherRegex.kcode && pattern.getOptions() == otherRegex.pattern.getOptions()); - } - - @JRubyMethod(name = "~", reads = {LASTLINE, BACKREF}, writes = BACKREF) - public IRubyObject op_match2(ThreadContext context) { - Ruby runtime = context.getRuntime(); - IRubyObject line = context.getCurrentFrame().getLastLine(); - if(!(line instanceof RubyString)) { - context.getCurrentFrame().setBackRef(runtime.getNil()); - return runtime.getNil(); - } - int start = search(context, (RubyString)line, 0, false); - if(start < 0) { - return runtime.getNil(); - } else { - return runtime.newFixnum(start); - } - } - - /** rb_reg_eqq - * - */ - @JRubyMethod(name = "===", required = 1, writes = BACKREF) - public IRubyObject eqq(ThreadContext context, IRubyObject str) { - Ruby runtime = context.getRuntime(); - if(!(str instanceof RubyString)) str = str.checkStringType(); - - if (str.isNil()) { - context.getCurrentFrame().setBackRef(runtime.getNil()); - return runtime.getFalse(); - } - int start = search(context, (RubyString)str, 0, false); - return (start < 0) ? runtime.getFalse() : runtime.getTrue(); - } - - private static final int REGEX_QUOTED = 1; - private void initialize(ByteList bytes, int options, boolean quote) { - if (!isTaint() && getRuntime().getSafeLevel() >= 4) throw getRuntime().newSecurityError("Insecure: can't modify regexp"); - checkFrozen(); - if (isLiteral()) throw getRuntime().newSecurityError("can't modify literal regexp"); - - setKCode(options); - - Map<ByteList, Regex> cache = getPatternCache(); - Regex pat = cache.get(bytes); - - if (pat != null && - pat.getEncoding() == kcode.getEncoding() && - pat.getOptions() == (options & 0xf) && - ((pat.getUserOptions() & REGEX_QUOTED) != 0) == quote) { // cache hit - pattern = pat; - } else { - if (quote) bytes = quote(bytes, getRuntime().getKCode()); - makeRegexp(bytes, bytes.begin, bytes.realSize, options & 0xf, kcode.getEncoding()); - if (quote) pattern.setUserOptions(REGEX_QUOTED); - cache.put(bytes, pattern); - } - - str = bytes; - } - - private void makeRegexp(ByteList bytes, int start, int len, int flags, Encoding enc) { - try { - pattern = new Regex(bytes.bytes, start, start + len, flags, enc, Syntax.DEFAULT, this); - } catch(Exception e) { - rb_reg_raise(bytes.bytes, start, len, e.getMessage(), flags); - } - } - - private final void rb_reg_raise(byte[] s, int start, int len, String err,int flags) { - throw getRuntime().newRegexpError(err + ": " + rb_reg_desc(s,start, len,flags)); - } - - private final StringBuilder rb_reg_desc(byte[] s, int start, int len, int flags) { - StringBuilder sb = new StringBuilder("/"); - rb_reg_expr_str(sb, s, start, len); - sb.append("/"); - - if((flags & ReOptions.RE_OPTION_MULTILINE) != 0) sb.append("m"); - if((flags & ReOptions.RE_OPTION_IGNORECASE) != 0) sb.append("i"); - if((flags & ReOptions.RE_OPTION_EXTENDED) != 0) sb.append("x"); - - if (kcode != null && !isKCodeDefault()) { - sb.append(kcode.name().charAt(0)); - } - return sb; - } - - private final void rb_reg_expr_str(StringBuilder sb, byte[] s, int start, int len) { - int p,pend; - boolean need_escape = false; - p = start; - pend = start+len; - Encoding enc = kcode.getEncoding(); - while(p<pend) { - if(s[p] == '/' || (!(' ' == s[p] || (!Character.isWhitespace(s[p]) && - !Character.isISOControl(s[p]))) && - enc.length(s[p])==1)) { - need_escape = true; - break; - } - p += enc.length(s[p]); - } - if(!need_escape) { - sb.append(new ByteList(s,start,len,false).toString()); - } else { - p = 0; - while(p < pend) { - if(s[p] == '\\') { - int n = enc.length(s[p+1]) + 1; - sb.append(new ByteList(s,p,n,false).toString()); - p += n; - continue; - } else if(s[p] == '/') { - sb.append("\\/"); - } else if(enc.length(s[p])!=1) { - sb.append(new ByteList(s,p,enc.length(s[p]),false).toString()); - p += enc.length(s[p]); - continue; - } else if((' ' == s[p] || (!Character.isWhitespace(s[p]) && - !Character.isISOControl(s[p])))) { - sb.append((char)(s[p]&0xFF)); - } else if(!Character.isWhitespace((char)(s[p]&0xFF))) { - sb.append('\\'); - sb.append(Integer.toString((int)(s[p]&0377),8)); - } else { - sb.append((char)(s[p]&0xFF)); - } - p++; - } - } - } - - /** rb_reg_init_copy - */ - @JRubyMethod(name = "initialize_copy", required = 1) - @Override - public IRubyObject initialize_copy(IRubyObject re) { - if(this == re) return this; - - checkFrozen(); - - if (getMetaClass().getRealClass() != re.getMetaClass().getRealClass()) { - throw getRuntime().newTypeError("wrong argument type"); - } - - RubyRegexp regexp = (RubyRegexp)re; - regexp.check(); - - initialize(regexp.str, regexp.getOptions(), false); - - return this; - } - - /** rb_set_kcode - */ - private int getKcode() { - if(kcode == KCode.NONE) { - return 16; - } else if(kcode == KCode.EUC) { - return 32; - } else if(kcode == KCode.SJIS) { - return 48; - } else if(kcode == KCode.UTF8) { - return 64; - } - return 0; - } - - /** - */ - private void setKCode(int options) { - clearKCodeDefault(); - switch(options & ~0xf) { - case 0: - default: - setKCodeDefault(); - kcode = getRuntime().getKCode(); - break; - case 16: - kcode = KCode.NONE; - break; - case 32: - kcode = KCode.EUC; - break; - case 48: - kcode = KCode.SJIS; - break; - case 64: - kcode = KCode.UTF8; - break; - } - } - - /** rb_reg_options - */ - private int getOptions() { - check(); - int options = (int)(pattern.getOptions() & (RE_OPTION_IGNORECASE|RE_OPTION_MULTILINE|RE_OPTION_EXTENDED)); - if(!isKCodeDefault()) { - options |= getKcode(); - } - return options; - } - - /** rb_reg_initialize_m - */ - @JRubyMethod(name = "initialize", optional = 3, visibility = Visibility.PRIVATE) - public IRubyObject initialize_m(IRubyObject[] args) { - ByteList bytes; - int regexFlags = 0; - - if(args[0] instanceof RubyRegexp) { - if(args.length > 1) { - getRuntime().getWarnings().warn(ID.REGEXP_IGNORED_FLAGS, "flags" + (args.length == 3 ? " and encoding" : "") + " ignored"); - } - RubyRegexp regexp = (RubyRegexp)args[0]; - regexp.check(); - - regexFlags = (int)regexp.pattern.getOptions() & 0xF; - if (!regexp.isKCodeDefault() && regexp.kcode != null && regexp.kcode != KCode.NIL) { - if (regexp.kcode == KCode.NONE) { - regexFlags |= 16; - } else if (regexp.kcode == KCode.EUC) { - regexFlags |= 32; - } else if (regexp.kcode == KCode.SJIS) { - regexFlags |= 48; - } else if (regexp.kcode == KCode.UTF8) { - regexFlags |= 64; - } - } - bytes = regexp.str; - } else { - if (args.length >= 2) { - if (args[1] instanceof RubyFixnum) { - regexFlags = RubyNumeric.fix2int(args[1]); - } else if (args[1].isTrue()) { - regexFlags = RE_OPTION_IGNORECASE; - } - } - if (args.length == 3 && !args[2].isNil()) { - ByteList kcodeBytes = args[2].convertToString().getByteList(); - char first = kcodeBytes.length() > 0 ? kcodeBytes.charAt(0) : 0; - regexFlags &= ~0x70; - switch (first) { - case 'n': case 'N': - regexFlags |= 16; - break; - case 'e': case 'E': - regexFlags |= 32; - break; - case 's': case 'S': - regexFlags |= 48; - break; - case 'u': case 'U': - regexFlags |= 64; - break; - default: - break; - } - } - bytes = args[0].convertToString().getByteList(); - } - initialize(bytes, regexFlags, false); - - return this; - } - - @JRubyMethod(name = {"new", "compile"}, required = 1, optional = 2, meta = true) - public static RubyRegexp newInstance(IRubyObject recv, IRubyObject[] args) { - RubyClass klass = (RubyClass)recv; - - RubyRegexp re = (RubyRegexp) klass.allocate(); - re.callInit(args, Block.NULL_BLOCK); - - return re; - } - - @JRubyMethod(name = "options") - public IRubyObject options() { - return getRuntime().newFixnum(getOptions()); - } - - /** rb_reg_search - */ - public int search(ThreadContext context, RubyString str, int pos, boolean reverse) { - Ruby runtime = context.getRuntime(); - Frame frame = context.getCurrentRubyFrame(); - - ByteList value = str.getByteList(); - if (pos > value.realSize || pos < 0) { - frame.setBackRef(runtime.getNil()); - return -1; - } - - return performSearch(reverse, pos, value, frame, runtime, context, str); - } - - private int performSearch(boolean reverse, int pos, ByteList value, Frame frame, Ruby runtime, ThreadContext context, RubyString str) { - check(); - - int realSize = value.realSize; - int begin = value.begin; - int range = reverse ? -pos : realSize - pos; - - Matcher matcher = pattern.matcher(value.bytes, begin, begin + realSize); - - int result = matcher.search(begin + pos, begin + pos + range, Option.NONE); - - if (result < 0) { - frame.setBackRef(runtime.getNil()); - return result; - } - - updateBackRef(context, str, frame, matcher); - - return result; - } - - final RubyMatchData updateBackRef(ThreadContext context, RubyString str, Frame frame, Matcher matcher) { - Ruby runtime = context.getRuntime(); - IRubyObject backref = frame.getBackRef(); - final RubyMatchData match; - if (backref == null || backref.isNil() || ((RubyMatchData)backref).used()) { - match = new RubyMatchData(runtime); - } else { - match = (RubyMatchData)backref; - match.setTaint(runtime.getSafeLevel() >= 3); - } - - match.regs = matcher.getRegion(); // lazy, null when no groups defined - match.begin = matcher.getBegin(); - match.end = matcher.getEnd(); - - match.str = (RubyString)str.strDup(runtime).freeze(context); - match.pattern = pattern; - - frame.setBackRef(match); - - match.infectBy(this); - match.infectBy(str); - return match; - } - - /** rb_reg_match - * - */ - @JRubyMethod(name = "=~", required = 1, reads = BACKREF, writes = BACKREF) - @Override - public IRubyObject op_match(ThreadContext context, IRubyObject str) { - int start; - if(str.isNil()) { - context.getCurrentFrame().setBackRef(context.getRuntime().getNil()); - return str; - } - - start = search(context, str.convertToString(), 0, false); - - if (start < 0) return context.getRuntime().getNil(); - - return RubyFixnum.newFixnum(context.getRuntime(), start); - } - - /** rb_reg_match_m - * - */ - @JRubyMethod(name = "match", required = 1, reads = BACKREF) - public IRubyObject match_m(ThreadContext context, IRubyObject str) { - if (op_match(context, str).isNil()) return context.getRuntime().getNil(); - - IRubyObject result = context.getCurrentFrame().getBackRef(); - if (result instanceof RubyMatchData) { - ((RubyMatchData)result).use(); - } - return result; - } - - - public RubyString regsub(RubyString str, RubyString src, Matcher matcher) { - Region regs = matcher.getRegion(); - int mbeg = matcher.getBegin(); - int mend = matcher.getEnd(); - - int p,s,e; - p = s = 0; - int no = -1; - ByteList bs = str.getByteList(); - ByteList srcbs = src.getByteList(); - e = bs.length(); - RubyString val = null; - Encoding enc = kcode.getEncoding(); - - int beg, end; - while(s < e) { - int ss = s; - char c = bs.charAt(s++); - if(enc.length((byte)c) != 1) { - s += enc.length((byte)c) - 1; - continue; - } - if (c != '\\' || s == e) continue; - if (val == null) val = RubyString.newString(getRuntime(), new ByteList(ss - p)); - - val.cat(bs.bytes, bs.begin + p, ss - p); - c = bs.charAt(s++); - p = s; - - switch(c) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - no = c - '0'; - break; - case '&': - no = 0; - break; - case '`': - beg = regs == null ? mbeg : regs.beg[0]; - val.cat(srcbs.bytes, srcbs.begin, beg); - continue; - - case '\'': - end = regs == null ? mend : regs.end[0]; - val.cat(srcbs.bytes, srcbs.begin + end, src.getByteList().realSize - end); - continue; - - case '+': - if (regs == null) { - if (mbeg == -1) { - no = 0; - continue; - } - } else { - no = regs.numRegs-1; - while(regs.beg[no] == -1 && no > 0) no--; - if (no == 0) continue; - } - break; - case '\\': - val.cat(bs.bytes, s - 1, 1); - continue; - default: - val.cat(bs.bytes, s - 2, 2); - continue; - } - - if (regs != null) { - if (no >= 0) { - if (no >= regs.numRegs || regs.beg[no] == -1) continue; - val.cat(srcbs.bytes, srcbs.begin + regs.beg[no], regs.end[no] - regs.beg[no]); - } - } else { - if (no != 0 || mbeg == -1) continue; - val.cat(srcbs.bytes, srcbs.begin + mbeg, mend - mbeg); - } - } - - if(p < e) { - if(val == null) { - val = RubyString.newString(getRuntime(), bs.makeShared(p, e-p)); - } else { - val.cat(bs.bytes, bs.begin + p, e - p); - } - } - if (val == null) return str; - - return val; - } - - final int adjustStartPos(RubyString str, int pos, boolean reverse) { - check(); - ByteList value = str.getByteList(); - return pattern.adjustStartPosition(value.bytes, value.begin, value.realSize, pos, reverse); - } - - @JRubyMethod(name = "casefold?") - public IRubyObject casefold_p(ThreadContext context) { - check(); - - return context.getRuntime().newBoolean((pattern.getOptions() & RE_OPTION_IGNORECASE) != 0); - } - - /** rb_reg_source - * - */ - @JRubyMethod(name = "source") - public IRubyObject source() { - Ruby runtime = getRuntime(); - check(); - RubyString str = RubyString.newStringShared(runtime, this.str); - if(isTaint()) { - str.taint(runtime.getCurrentContext()); - } - return str; - } - - final int length() { - return str.realSize; - } - - /** rb_reg_inspect - * - */ - @JRubyMethod(name = "inspect") - @Override - public IRubyObject inspect() { - check(); - return getRuntime().newString(ByteList.create(rb_reg_desc(str.bytes, str.begin, str.realSize, pattern.getOptions()).toString())); - } - - private final static int EMBEDDABLE = RE_OPTION_MULTILINE|RE_OPTION_IGNORECASE|RE_OPTION_EXTENDED; - - @JRubyMethod(name = "to_s") - @Override - public IRubyObject to_s() { - RubyString ss = getRuntime().newString("(?"); - check(); - - int options = pattern.getOptions(); - int ptr = str.begin; - int len = str.realSize; - byte[] bytes = str.bytes; - again: do { - if (len >= 4 && bytes[ptr] == '(' && bytes[ptr + 1] == '?') { - boolean err = true; - ptr += 2; - if ((len -= 2) > 0) { - do { - if (bytes[ptr] == 'm') { - options |= RE_OPTION_MULTILINE; - } else if (bytes[ptr] == 'i') { - options |= RE_OPTION_IGNORECASE; - } else if (bytes[ptr] == 'x') { - options |= RE_OPTION_EXTENDED; - } else { - break; - } - ptr++; - } while(--len > 0); - } - if (len > 1 && bytes[ptr] == '-') { - ++ptr; - --len; - do { - if (bytes[ptr] == 'm') { - options &= ~RE_OPTION_MULTILINE; - } else if (bytes[ptr] == 'i') { - options &= ~RE_OPTION_IGNORECASE; - } else if (bytes[ptr] == 'x') { - options &= ~RE_OPTION_EXTENDED; - } else { - break; - } - ptr++; - } while(--len > 0); - } - - if (bytes[ptr] == ')') { - --len; - ++ptr; - continue again; - } - - if (bytes[ptr] == ':' && bytes[ptr + len - 1] == ')') { - try { - new Regex(bytes, ++ptr, ptr + (len-=2) ,Option.DEFAULT, kcode.getEncoding(), Syntax.DEFAULT); - err = false; - } catch (JOniException e) { - err = true; - } - } - - if (err) { - options = (int)pattern.getOptions(); - ptr = str.begin; - len = str.realSize; - } - } - if ((options & RE_OPTION_MULTILINE) !=0 ) ss.cat((byte)'m'); - if ((options & RE_OPTION_IGNORECASE) !=0 ) ss.cat((byte)'i'); - if ((options & RE_OPTION_EXTENDED) !=0 ) ss.cat((byte)'x'); - - if ((options & EMBEDDABLE) != EMBEDDABLE) { - ss.cat((byte)'-'); - if ((options & RE_OPTION_MULTILINE) == 0) ss.cat((byte)'m'); - if ((options & RE_OPTION_IGNORECASE) == 0) ss.cat((byte)'i'); - if ((options & RE_OPTION_EXTENDED) == 0) ss.cat((byte)'x'); - } - ss.cat((byte)':'); - rb_reg_expr_str(ss, ptr, len); - ss.cat((byte)')'); - ss.infectBy(this); - return ss; - } while(true); - } - - private final void rb_reg_expr_str(RubyString ss, int s, int len) { - int p = s; - int pend = p + len; - boolean need_escape = false; - Encoding enc = kcode.getEncoding(); - while (p < pend) { - if (str.bytes[p] == '/' || (!enc.isPrint(str.bytes[p] & 0xff) && enc.length(str.bytes[p]) == 1)) { - need_escape = true; - break; - } - p += enc.length(str.bytes[p]); - } - if (!need_escape) { - ss.cat(str.bytes, s, len); - } else { - p = s; - while (p<pend) { - if (str.bytes[p] == '\\') { - int n = enc.length(str.bytes[p+1]) + 1; - ss.cat(str.bytes, p, n); - p += n; - continue; - } else if (str.bytes[p] == '/') { - ss.cat((byte)'\\'); - ss.cat(str.bytes, p, 1); - } else if (enc.length(str.bytes[p]) != 1) { - ss.cat(str.bytes, p, enc.length(str.bytes[p])); - p += enc.length(str.bytes[p]); - continue; - } else if (enc.isPrint(str.bytes[p] & 0xff)) { - ss.cat(str.bytes,p,1); - } else if (!enc.isSpace(str.bytes[p] & 0xff)) { - ss.cat(ByteList.create(Integer.toString(str.bytes[p] & 0377, 8))); - } else { - ss.cat(str.bytes, p, 1); - } - p++; - } - } - } - - /** rb_reg_s_quote - * - */ - @JRubyMethod(name = {"quote", "escape"}, required = 1, optional = 1, meta = true) - public static RubyString quote(IRubyObject recv, IRubyObject[] args) { - IRubyObject kcode = args.length == 2 ? args[1] : null; - IRubyObject str = args[0]; - KCode code = recv.getRuntime().getKCode(); - - if (kcode != null && !kcode.isNil()) { - code = KCode.create(recv.getRuntime(), kcode.toString()); - } - - RubyString src = str.convertToString(); - RubyString dst = RubyString.newString(recv.getRuntime(), quote(src.getByteList(), code)); - dst.infectBy(src); - return dst; - } - - /** rb_reg_quote - * - */ - public static ByteList quote(ByteList str, KCode kcode) { - ByteList bs = str; - int tix = 0; - int s = bs.begin; - char c; - int send = s+bs.length(); - Encoding enc = kcode.getEncoding(); - meta_found: do { - for(; s<send; s++) { - c = (char)(bs.bytes[s]&0xFF); - if(enc.length((byte)c) != 1) { - int n = enc.length((byte)c); - while(n-- > 0 && s < send) { - s++; - } - s--; - continue; - } - switch (c) { - case '[': case ']': case '{': case '}': - case '(': case ')': case '|': case '-': - case '*': case '.': case '\\': - case '?': case '+': case '^': case '$': - case ' ': case '#': - case '\t': case '\f': case '\n': case '\r': - break meta_found; - } - } - return bs; - } while(false); - ByteList b1 = new ByteList(send*2); - System.arraycopy(bs.bytes,bs.begin,b1.bytes,b1.begin,s-bs.begin); - tix += (s-bs.begin); - - for(; s<send; s++) { - c = (char)(bs.bytes[s]&0xFF); - if(enc.length((byte)c) != 1) { - int n = enc.length((byte)c); - while(n-- > 0 && s < send) { - b1.bytes[tix++] = bs.bytes[s++]; - } - s--; - continue; - } - - switch(c) { - case '[': case ']': case '{': case '}': - case '(': case ')': case '|': case '-': - case '*': case '.': case '\\': - case '?': case '+': case '^': case '$': - case '#': - b1.bytes[tix++] = '\\'; - break; - case ' ': - b1.bytes[tix++] = '\\'; - b1.bytes[tix++] = ' '; - continue; - case '\t': - b1.bytes[tix++] = '\\'; - b1.bytes[tix++] = 't'; - continue; - case '\n': - b1.bytes[tix++] = '\\'; - b1.bytes[tix++] = 'n'; - continue; - case '\r': - b1.bytes[tix++] = '\\'; - b1.bytes[tix++] = 'r'; - continue; - case '\f': - b1.bytes[tix++] = '\\'; - b1.bytes[tix++] = 'f'; - continue; - } - b1.bytes[tix++] = (byte)c; - } - b1.realSize = tix; - return b1; - } - - - /** rb_reg_nth_match - * - */ - public static IRubyObject nth_match(int nth, IRubyObject match) { - if (match.isNil()) return match; - RubyMatchData m = (RubyMatchData)match; - - int start, end; - - if (m.regs == null) { - if (nth >= 1) return match.getRuntime().getNil(); - if (nth < 0 && ++nth <= 0) return match.getRuntime().getNil(); - start = m.begin; - end = m.end; - } else { - if (nth >= m.regs.numRegs) return match.getRuntime().getNil(); - if (nth < 0 && (nth+=m.regs.numRegs) <= 0) return match.getRuntime().getNil(); - start = m.regs.beg[nth]; - end = m.regs.end[nth]; - } - - if (start == -1) return match.getRuntime().getNil(); - - RubyString str = m.str.makeShared(match.getRuntime(), start, end - start); - str.infectBy(match); - return str; - } - - /** rb_reg_last_match - * - */ - public static IRubyObject last_match(IRubyObject match) { - return nth_match(0, match); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public static IRubyObject last_match_s(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - switch (args.length) { - case 0: - return last_match_s(context, recv); - case 1: - return last_match_s(context, recv, args[0]); - default: - Arity.raiseArgumentError(recv.getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** rb_reg_s_last_match / match_getter - * - */ - @JRubyMethod(name = "last_match", meta = true, reads = BACKREF) - public static IRubyObject last_match_s(ThreadContext context, IRubyObject recv) { - IRubyObject match = context.getCurrentFrame().getBackRef(); - if (match instanceof RubyMatchData) ((RubyMatchData)match).use(); - return match; - } - - /** rb_reg_s_last_match - * - */ - @JRubyMethod(name = "last_match", meta = true, reads = BACKREF) - public static IRubyObject last_match_s(ThreadContext context, IRubyObject recv, IRubyObject nth) { - IRubyObject match = context.getCurrentFrame().getBackRef(); - if (match.isNil()) return match; - return nth_match(((RubyMatchData)match).backrefNumber(nth), match); - } - - /** rb_reg_match_pre - * - */ - public static IRubyObject match_pre(IRubyObject match) { - if (match.isNil()) return match; - RubyMatchData m = (RubyMatchData)match; - - int beg = m.regs == null ? m.begin : m.regs.beg[0]; - - if(beg == -1) match.getRuntime().getNil(); - - RubyString str = m.str.makeShared(match.getRuntime(), 0, beg); - str.infectBy(match); - return str; - } - - /** rb_reg_match_post - * - */ - public static IRubyObject match_post(IRubyObject match) { - if (match.isNil()) return match; - RubyMatchData m = (RubyMatchData)match; - - int end; - if (m.regs == null) { - if (m.begin == -1) return match.getRuntime().getNil(); - end = m.end; - } else { - if (m.regs.beg[0] == -1) return match.getRuntime().getNil(); - end = m.regs.end[0]; - } - - RubyString str = m.str.makeShared(match.getRuntime(), end, m.str.getByteList().realSize - end); - str.infectBy(match); - return str; - } - - /** rb_reg_match_last - * - */ - public static IRubyObject match_last(IRubyObject match) { - if (match.isNil()) return match; - RubyMatchData m = (RubyMatchData)match; - - if (m.regs == null || m.regs.beg[0] == -1) return match.getRuntime().getNil(); - - int i; - for (i=m.regs.numRegs-1; m.regs.beg[i]==-1 && i>0; i--); - if (i == 0) return match.getRuntime().getNil(); - - return nth_match(i,match); - } - - /** rb_reg_s_union - * - */ - @JRubyMethod(name = "union", rest = true, meta = true) - public static IRubyObject union(ThreadContext context, IRubyObject recv, IRubyObject[] args) { - if (args.length == 0) { - return newRegexp(recv.getRuntime(), ByteList.create("(?!)"), 0, false); - } else if (args.length == 1) { - IRubyObject v = TypeConverter.convertToTypeWithCheck(args[0], recv.getRuntime().getRegexp(), 0, "to_regexp"); - if(!v.isNil()) { - return v; - } else { - // newInstance here - return newRegexp(recv.getRuntime(), quote(recv,args).getByteList(), 0, false); - } - } else { - KCode kcode = null; - IRubyObject kcode_re = recv.getRuntime().getNil(); - RubyString source = recv.getRuntime().newString(); - IRubyObject[] _args = new IRubyObject[3]; - - for (int i = 0; i < args.length; i++) { - if (0 < i) { - source.cat((byte)'|'); - } - IRubyObject v = TypeConverter.convertToTypeWithCheck(args[i], recv.getRuntime().getRegexp(), 0, "to_regexp"); - if (!v.isNil()) { - if (!((RubyRegexp)v).isKCodeDefault()) { - if (kcode == null) { - kcode_re = v; - kcode = ((RubyRegexp)v).kcode; - } else if (((RubyRegexp)v).kcode != kcode) { - IRubyObject str1 = kcode_re.inspect(); - IRubyObject str2 = v.inspect(); - throw recv.getRuntime().newArgumentError("mixed kcode " + str1 + " and " + str2); - } - } - v = ((RubyRegexp)v).to_s(); - } else { - v = quote(recv, new IRubyObject[]{args[i]}); - } - source.append(v); - } - - _args[0] = source; - _args[1] = recv.getRuntime().getNil(); - if (kcode == null) { - _args[2] = recv.getRuntime().getNil(); - } else if (kcode == KCode.NONE) { - _args[2] = recv.getRuntime().newString("n"); - } else if (kcode == KCode.EUC) { - _args[2] = recv.getRuntime().newString("e"); - } else if (kcode == KCode.SJIS) { - _args[2] = recv.getRuntime().newString("s"); - } else if (kcode == KCode.UTF8) { - _args[2] = recv.getRuntime().newString("u"); - } - return recv.callMethod(context, "new", _args); - } - } - - /** rb_reg_names - * - */ - @JRubyMethod(name = "names", compat = CompatVersion.RUBY1_9) - public IRubyObject names() { - if (pattern.numberOfNames() == 0) return getRuntime().newEmptyArray(); - - RubyArray ary = getRuntime().newArray(pattern.numberOfNames()); - for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) { - NameEntry e = i.next(); - ary.append(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP)); - } - return ary; - } - - /** rb_reg_named_captures - * - */ - @JRubyMethod(name = "named_captures", compat = CompatVersion.RUBY1_9) - public IRubyObject named_captures(ThreadContext context) { - RubyHash hash = RubyHash.newHash(getRuntime()); - if (pattern.numberOfNames() == 0) return hash; - - for (Iterator<NameEntry> i = pattern.namedBackrefIterator(); i.hasNext();) { - NameEntry e = i.next(); - int[]backrefs = e.getBackRefs(); - RubyArray ary = getRuntime().newArray(backrefs.length); - - for (int backref : backrefs) ary.append(RubyFixnum.newFixnum(getRuntime(), backref)); - hash.fastASet(RubyString.newStringShared(getRuntime(), e.name, e.nameP, e.nameEnd - e.nameP).freeze(context), ary); - } - return hash; - } - - public static RubyRegexp unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - RubyRegexp result = newRegexp(input.getRuntime(), input.unmarshalString(), input.unmarshalInt(), false); - input.registerLinkTarget(result); - return result; - } - - public static void marshalTo(RubyRegexp regexp, MarshalStream output) throws java.io.IOException { - output.registerLinkTarget(regexp); - output.writeString(new String(regexp.str.bytes,regexp.str.begin,regexp.str.realSize)); - output.writeInt(regexp.pattern.getOptions() & EMBEDDABLE); - } -} - -package org.jruby; - -import org.jruby.runtime.builtin.IRubyObject; - -/** - * - * @author nicksieger - */ -public interface RubyRuntimeAdapter { - IRubyObject eval(Ruby runtime, String script); -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyModule; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Block; -import org.jruby.runtime.CallType; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -import org.jruby.util.SignalFacade; -import org.jruby.util.NoFunctionalitySignalFacade; - -@JRubyModule(name="Signal") -public class RubySignal { - private final static SignalFacade SIGNALS = getSignalFacade(); - - private final static SignalFacade getSignalFacade() { - try { - Class realFacadeClass = Class.forName("org.jruby.util.SunSignalFacade"); - return (SignalFacade)realFacadeClass.newInstance(); - } catch(Throwable e) { - return new NoFunctionalitySignalFacade(); - } - } - - // NOTE: The indicies here match exactly the signal values; do not reorder - public static final String[] NAMES = { - "EXIT", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "EMT", - "FPE", "KILL", "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "URG", - "STOP", "TSTP", "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", - "XFSZ", "VTALRM", "PROF", "WINCH", "INFO", "USR1", "USR2"}; - - public static void createSignal(Ruby runtime) { - RubyModule mSignal = runtime.defineModule("Signal"); - - mSignal.defineAnnotatedMethods(RubySignal.class); - } - - @JRubyMethod(name = "trap", required = 1, optional = 1, frame = true, meta = true) - public static IRubyObject trap(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = recv.getRuntime(); - runtime.getLoadService().require("jsignal"); - return RuntimeHelpers.invoke(context, runtime.getKernel(), "__jtrap", args, block); - } - - @JRubyMethod(name = "list", meta = true) - public static IRubyObject list(ThreadContext context, IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - RubyHash names = RubyHash.newHash(runtime); - for (int i = 0; i < NAMES.length; i++) { - names.op_aset(context, runtime.newString(NAMES[i]), runtime.newFixnum(i)); - } - // IOT is also 6 - names.op_aset(context, runtime.newString("IOT"), runtime.newFixnum(6)); - // CLD is also 20 - names.op_aset(context, runtime.newString("CLD"), runtime.newFixnum(20)); - return names; - } - - @JRubyMethod(name = "__jtrap_kernel", required = 3,meta = true) - public static IRubyObject __jtrap_kernel(final IRubyObject recv, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3) { - return SIGNALS.trap(recv, arg1, arg2, arg3); - } -}// RubySignal -/* - **** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2004 David Corbin <dcorbin@users.sourceforge.net> - * Copyright (C) 2005 Tim Azzopardi <tim@tigerfive.com> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * Copyright (C) 2007 Nick Sieger <nicksieger@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import static org.jruby.anno.FrameField.BACKREF; -import static org.jruby.anno.FrameField.LASTLINE; - -import java.io.UnsupportedEncodingException; -import java.util.Locale; - -import org.joni.Matcher; -import org.joni.Option; -import org.joni.Regex; -import org.joni.Region; -import org.joni.encoding.Encoding; -import org.joni.encoding.specific.ASCIIEncoding; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.exceptions.RaiseException; -import org.jruby.java.MiniJava; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.Frame; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; -import org.jruby.util.Numeric; -import org.jruby.util.Pack; -import org.jruby.util.Sprintf; -import org.jruby.util.string.JavaCrypt; - -/** - * Implementation of Ruby String class - * - * Concurrency: no synchronization is required among readers, but - * all users must synchronize externally with writers. - * - */ -@JRubyClass(name="String", include={"Enumerable", "Comparable"}) -public class RubyString extends RubyObject { - private static final ASCIIEncoding ASCII = ASCIIEncoding.INSTANCE; - - // string doesn't share any resources - private static final int SHARE_LEVEL_NONE = 0; - // string has it's own ByteList, but it's pointing to a shared buffer (byte[]) - private static final int SHARE_LEVEL_BUFFER = 1; - // string doesn't have it's own ByteList (values) - private static final int SHARE_LEVEL_BYTELIST = 2; - - private volatile int shareLevel = SHARE_LEVEL_NONE; - - private ByteList value; - - private static ObjectAllocator STRING_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return RubyString.newEmptyString(runtime, klass); - } - }; - - public static RubyClass createStringClass(Ruby runtime) { - RubyClass stringClass = runtime.defineClass("String", runtime.getObject(), STRING_ALLOCATOR); - runtime.setString(stringClass); - stringClass.index = ClassIndex.STRING; - stringClass.kindOf = new RubyModule.KindOf() { - @Override - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubyString; - } - }; - - stringClass.includeModule(runtime.getComparable()); - stringClass.includeModule(runtime.getEnumerable()); - stringClass.defineAnnotatedMethods(RubyString.class); - - return stringClass; - } - - /** short circuit for String key comparison - * - */ - @Override - public final boolean eql(IRubyObject other) { - if (other.getMetaClass() == getRuntime().getString()) return value.equal(((RubyString)other).value); - return super.eql(other); - } - - private RubyString(Ruby runtime, RubyClass rubyClass, CharSequence value) { - super(runtime, rubyClass); - assert value != null; - this.value = new ByteList(ByteList.plain(value), false); - } - - private RubyString(Ruby runtime, RubyClass rubyClass, byte[] value) { - super(runtime, rubyClass); - assert value != null; - this.value = new ByteList(value); - } - - private RubyString(Ruby runtime, RubyClass rubyClass, ByteList value) { - super(runtime, rubyClass); - assert value != null; - this.value = value; - } - - private RubyString(Ruby runtime, RubyClass rubyClass, ByteList value, boolean objectSpace) { - super(runtime, rubyClass, objectSpace); - assert value != null; - this.value = value; - } - - - /** Create a new String which uses the same Ruby runtime and the same - * class like this String. - * - * This method should be used to satisfy RCR #38. - * @deprecated - */ - public RubyString newString(CharSequence s) { - return new RubyString(getRuntime(), getType(), s); - } - - /** Create a new String which uses the same Ruby runtime and the same - * class like this String. - * - * This method should be used to satisfy RCR #38. - * @deprecated - */ - public RubyString newString(ByteList s) { - return new RubyString(getRuntime(), getMetaClass(), s); - } - - // Methods of the String class (rb_str_*): - - /** rb_str_new2 - * - */ - public static RubyString newString(Ruby runtime, CharSequence str) { - return new RubyString(runtime, runtime.getString(), str); - } - - public static RubyString newEmptyString(Ruby runtime) { - return newEmptyString(runtime, runtime.getString()); - } - - public static RubyString newEmptyString(Ruby runtime, RubyClass metaClass) { - RubyString empty = new RubyString(runtime, metaClass, ByteList.EMPTY_BYTELIST); - empty.shareLevel = SHARE_LEVEL_BYTELIST; - return empty; - } - - public static RubyString newUnicodeString(Ruby runtime, String str) { - try { - return new RubyString(runtime, runtime.getString(), new ByteList(str.getBytes("UTF8"), false)); - } catch (UnsupportedEncodingException uee) { - return new RubyString(runtime, runtime.getString(), str); - } - } - - @Deprecated - public static RubyString newString(Ruby runtime, RubyClass clazz, CharSequence str) { - return new RubyString(runtime, clazz, str); - } - - public static RubyString newString(Ruby runtime, byte[] bytes) { - return new RubyString(runtime, runtime.getString(), bytes); - } - - public static RubyString newString(Ruby runtime, byte[] bytes, int start, int length) { - byte[] copy = new byte[length]; - System.arraycopy(bytes, start, copy, 0, length); - return new RubyString(runtime, runtime.getString(), new ByteList(copy, false)); - } - - public static RubyString newString(Ruby runtime, ByteList bytes) { - return new RubyString(runtime, runtime.getString(), bytes); - } - - public static RubyString newStringLight(Ruby runtime, ByteList bytes) { - return new RubyString(runtime, runtime.getString(), bytes, false); - } - - public static RubyString newStringShared(Ruby runtime, RubyString orig) { - orig.shareLevel = SHARE_LEVEL_BYTELIST; - RubyString str = new RubyString(runtime, runtime.getString(), orig.value); - str.shareLevel = SHARE_LEVEL_BYTELIST; - return str; - } - - public static RubyString newStringShared(Ruby runtime, ByteList bytes) { - return newStringShared(runtime, runtime.getString(), bytes); - } - - public static RubyString newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes) { - RubyString str = new RubyString(runtime, clazz, bytes); - str.shareLevel = SHARE_LEVEL_BYTELIST; - return str; - } - - public static RubyString newStringShared(Ruby runtime, byte[] bytes, int start, int length) { - RubyString str = new RubyString(runtime, runtime.getString(), new ByteList(bytes, start, length, false)); - str.shareLevel = SHARE_LEVEL_BUFFER; - return str; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.STRING; - } - - @Override - public Class getJavaClass() { - return String.class; - } - - @Override - public RubyString convertToString() { - return this; - } - - @Override - public String toString() { - return value.toString(); - } - - /** rb_str_dup - * - */ - @Deprecated - public final RubyString strDup() { - return strDup(getRuntime(), getMetaClass()); - } - - public final RubyString strDup(Ruby runtime) { - return strDup(runtime, getMetaClass()); - } - - @Deprecated - final RubyString strDup(RubyClass clazz) { - return strDup(getRuntime(), getMetaClass()); - } - - final RubyString strDup(Ruby runtime, RubyClass clazz) { - shareLevel = SHARE_LEVEL_BYTELIST; - RubyString dup = new RubyString(runtime, clazz, value); - dup.shareLevel = SHARE_LEVEL_BYTELIST; - - dup.infectBy(this); - return dup; - } - - public final RubyString makeShared(Ruby runtime, int index, int len) { - if (len == 0) { - RubyString s = newEmptyString(runtime, getMetaClass()); - s.infectBy(this); - return s; - } - - if (shareLevel == SHARE_LEVEL_NONE) shareLevel = SHARE_LEVEL_BUFFER; - RubyString shared = new RubyString(runtime, getMetaClass(), value.makeShared(index, len)); - shared.shareLevel = SHARE_LEVEL_BUFFER; - - shared.infectBy(this); - return shared; - } - - final void modifyCheck() { - if ((flags & FROZEN_F) != 0) throw getRuntime().newFrozenError("string"); - - if (!isTaint() && getRuntime().getSafeLevel() >= 4) { - throw getRuntime().newSecurityError("Insecure: can't modify string"); - } - } - - private final void modifyCheck(byte[] b, int len) { - if (value.bytes != b || value.realSize != len) throw getRuntime().newRuntimeError("string modified"); - } - - private final void frozenCheck() { - if (isFrozen()) throw getRuntime().newRuntimeError("string frozen"); - } - - /** rb_str_modify - * - */ - public final void modify() { - modifyCheck(); - - if (shareLevel != SHARE_LEVEL_NONE) { - if (shareLevel == SHARE_LEVEL_BYTELIST) { - value = value.dup(); - } else { - value.unshare(); - } - shareLevel = SHARE_LEVEL_NONE; - } - - value.invalidate(); - } - - /** rb_str_modify (with length bytes ensured) - * - */ - public final void modify(int length) { - modifyCheck(); - - if (shareLevel != SHARE_LEVEL_NONE) { - if (shareLevel == SHARE_LEVEL_BYTELIST) { - value = value.dup(length); - } else { - value.unshare(length); - } - shareLevel = SHARE_LEVEL_NONE; - } else { - value.ensure(length); - } - - value.invalidate(); - } - - private final void view(ByteList bytes) { - modifyCheck(); - - value = bytes; - shareLevel = SHARE_LEVEL_NONE; - } - - private final void view(byte[]bytes) { - modifyCheck(); - - value.replace(bytes); - shareLevel = SHARE_LEVEL_NONE; - - value.invalidate(); - } - - private final void view(int index, int len) { - modifyCheck(); - - if (shareLevel != SHARE_LEVEL_NONE) { - if (shareLevel == SHARE_LEVEL_BYTELIST) { - // if len == 0 then shared empty - value = value.makeShared(index, len); - shareLevel = SHARE_LEVEL_BUFFER; - } else { - value.view(index, len); - } - } else { - value.view(index, len); - // FIXME this below is temporary, but its much safer for COW (it prevents not shared Strings with begin != 0) - // this allows now e.g.: ByteList#set not to be begin aware - shareLevel = SHARE_LEVEL_BUFFER; - } - - value.invalidate(); - } - - public static String bytesToString(byte[] bytes, int beg, int len) { - return new String(ByteList.plain(bytes, beg, len)); - } - - public static String byteListToString(ByteList bytes) { - return bytesToString(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - } - - public static String bytesToString(byte[] bytes) { - return bytesToString(bytes, 0, bytes.length); - } - - public static byte[] stringToBytes(String string) { - return ByteList.plain(string); - } - - public static boolean isDigit(int c) { - return c >= '0' && c <= '9'; - } - - public static boolean isUpper(int c) { - return c >= 'A' && c <= 'Z'; - } - - public static boolean isLower(int c) { - return c >= 'a' && c <= 'z'; - } - - public static boolean isLetter(int c) { - return isUpper(c) || isLower(c); - } - - public static boolean isAlnum(int c) { - return isUpper(c) || isLower(c) || isDigit(c); - } - - public static boolean isPrint(int c) { - return c >= 0x20 && c <= 0x7E; - } - - @Override - public RubyString asString() { - return this; - } - - @Override - public IRubyObject checkStringType() { - return this; - } - - @JRubyMethod(name = {"to_s", "to_str"}) - @Override - public IRubyObject to_s() { - Ruby runtime = getRuntime(); - if (getMetaClass().getRealClass() != runtime.getString()) { - return strDup(runtime, runtime.getString()); - } - return this; - } - - /* rb_str_cmp_m */ - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - if (other instanceof RubyString) { - return context.getRuntime().newFixnum(op_cmp((RubyString)other)); - } - - // deal with case when "other" is not a string - if (other.respondsTo("to_str") && other.respondsTo("<=>")) { - IRubyObject result = other.callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", this); - - if (result instanceof RubyNumeric) { - return ((RubyNumeric) result).op_uminus(context); - } - } - - return context.getRuntime().getNil(); - } - - /** - * - */ - @JRubyMethod(name = "==", required = 1) - @Override - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - Ruby runtime = context.getRuntime(); - - if (this == other) return runtime.getTrue(); - - if (!(other instanceof RubyString)) { - if (!other.respondsTo("to_str")) return runtime.getFalse(); - - return other.callMethod(context, MethodIndex.EQUALEQUAL, "==", this).isTrue() ? runtime.getTrue() : runtime.getFalse(); - } - return value.equal(((RubyString)other).value) ? runtime.getTrue() : runtime.getFalse(); - } - - @JRubyMethod(name = "+", required = 1) - public IRubyObject op_plus(ThreadContext context, IRubyObject other) { - RubyString str = other.convertToString(); - - ByteList result = new ByteList(value.realSize + str.value.realSize); - result.realSize = value.realSize + str.value.realSize; - System.arraycopy(value.bytes, value.begin, result.bytes, 0, value.realSize); - System.arraycopy(str.value.bytes, str.value.begin, result.bytes, value.realSize, str.value.realSize); - - RubyString resultStr = newString(context.getRuntime(), result); - if (isTaint() || str.isTaint()) resultStr.setTaint(true); - return resultStr; - } - - @JRubyMethod(name = "*", required = 1) - public IRubyObject op_mul(ThreadContext context, IRubyObject other) { - RubyInteger otherInteger = (RubyInteger) other.convertToInteger(); - long len = otherInteger.getLongValue(); - - if (len < 0) throw context.getRuntime().newArgumentError("negative argument"); - - // we limit to int because ByteBuffer can only allocate int sizes - if (len > 0 && Integer.MAX_VALUE / len < value.length()) { - throw context.getRuntime().newArgumentError("argument too big"); - } - ByteList newBytes = new ByteList(value.length() * (int)len); - - for (int i = 0; i < len; i++) { - newBytes.append(value); - } - - RubyString newString = new RubyString(context.getRuntime(), getMetaClass(), newBytes); - newString.setTaint(isTaint()); - return newString; - } - - @JRubyMethod(name = "%", required = 1) - public IRubyObject op_format(ThreadContext context, IRubyObject arg) { - final RubyString s; - - IRubyObject tmp = arg.checkArrayType(); - if (tmp.isNil()) { - tmp = arg; - } - - // FIXME: Should we make this work with platform's locale, - // or continue hardcoding US? - s = Sprintf.sprintf(context.getRuntime(), Locale.US, value, tmp); - - s.infectBy(this); - return s; - } - - @JRubyMethod(name = "hash") - @Override - public RubyFixnum hash() { - return getRuntime().newFixnum(value.hashCode()); - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object other) { - if (this == other) return true; - - if (other instanceof RubyString) { - RubyString string = (RubyString) other; - - if (string.value.equal(value)) return true; - } - - return false; - } - - /** rb_obj_as_string - * - */ - public static RubyString objAsString(ThreadContext context, IRubyObject obj) { - if (obj instanceof RubyString) return (RubyString) obj; - - IRubyObject str = obj.callMethod(context, MethodIndex.TO_S, "to_s"); - - if (!(str instanceof RubyString)) return (RubyString) obj.anyToString(); - - if (obj.isTaint()) str.setTaint(true); - - return (RubyString) str; - } - - /** rb_str_cmp - * - */ - public int op_cmp(RubyString other) { - return value.cmp(other.value); - } - - /** rb_to_id - * - */ - @Override - public String asJavaString() { - // TODO: This used to intern; but it didn't appear to change anything - // turning that off, and it's unclear if it was needed. Plus, we intern - // - return toString(); - } - - public IRubyObject doClone(){ - return newString(getRuntime(), value.dup()); - } - - public RubyString cat(byte[] str) { - modify(value.realSize + str.length); - System.arraycopy(str, 0, value.bytes, value.begin + value.realSize, str.length); - value.realSize += str.length; - return this; - } - - public RubyString cat(byte[] str, int beg, int len) { - modify(value.realSize + len); - System.arraycopy(str, beg, value.bytes, value.begin + value.realSize, len); - value.realSize += len; - return this; - } - - public RubyString cat(ByteList str) { - modify(value.realSize + str.realSize); - System.arraycopy(str.bytes, str.begin, value.bytes, value.begin + value.realSize, str.realSize); - value.realSize += str.realSize; - return this; - } - - public RubyString cat(byte ch) { - modify(value.realSize + 1); - value.bytes[value.begin + value.realSize] = ch; - value.realSize++; - return this; - } - - /** rb_str_replace_m - * - */ - @JRubyMethod(name = {"replace", "initialize_copy"}, required = 1) - public RubyString replace(IRubyObject other) { - if (this == other) return this; - - modifyCheck(); - - RubyString otherStr = stringValue(other); - - otherStr.shareLevel = shareLevel = SHARE_LEVEL_BYTELIST; - - value = otherStr.value; - - infectBy(other); - return this; - } - - @JRubyMethod(name = "reverse") - public RubyString reverse(ThreadContext context) { - if (value.length() <= 1) return strDup(context.getRuntime()); - - ByteList buf = new ByteList(value.length()+2); - buf.realSize = value.length(); - int src = value.length() - 1; - int dst = 0; - - while (src >= 0) buf.set(dst++, value.get(src--)); - - RubyString rev = new RubyString(context.getRuntime(), getMetaClass(), buf); - rev.infectBy(this); - return rev; - } - - @JRubyMethod(name = "reverse!") - public RubyString reverse_bang() { - if (value.length() > 1) { - modify(); - for (int i = 0; i < (value.length() / 2); i++) { - byte b = (byte) value.get(i); - - value.set(i, value.get(value.length() - i - 1)); - value.set(value.length() - i - 1, b); - } - } - - return this; - } - - /** rb_str_s_new - * - */ - public static RubyString newInstance(IRubyObject recv, IRubyObject[] args, Block block) { - RubyString newString = newStringShared(recv.getRuntime(), ByteList.EMPTY_BYTELIST); - newString.setMetaClass((RubyClass) recv); - newString.callInit(args, block); - return newString; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with zero or one arguments - */ - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - switch (args.length) { - case 0: - return this; - case 1: - return initialize(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - @JRubyMethod(frame = true, visibility = Visibility.PRIVATE) - @Override - public IRubyObject initialize() { - return this; - } - - @JRubyMethod(frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject arg0) { - replace(arg0); - - return this; - } - - @JRubyMethod - public IRubyObject casecmp(IRubyObject other) { - int compare = value.caseInsensitiveCmp(stringValue(other).value); - return RubyFixnum.newFixnum(getRuntime(), compare); - } - - /** rb_str_match - * - */ - @JRubyMethod(name = "=~") - @Override - public IRubyObject op_match(ThreadContext context, IRubyObject other) { - if (other instanceof RubyRegexp) return ((RubyRegexp) other).op_match(context, this); - if (other instanceof RubyString) { - throw context.getRuntime().newTypeError("type mismatch: String given"); - } - return other.callMethod(context, "=~", this); - } - - /** rb_str_match2 - * - */ - @JRubyMethod(name = "~", reads = {LASTLINE, BACKREF}, writes = BACKREF) - public IRubyObject op_match2(ThreadContext context) { - return RubyRegexp.newRegexp(context.getRuntime(), value, 0, false).op_match2(context); - } - - /** - * String#match(pattern) - * - * rb_str_match_m - * - * @param pattern Regexp or String - */ - @JRubyMethod - public IRubyObject match(ThreadContext context, IRubyObject pattern) { - return getPattern(pattern, false).callMethod(context, "match", this); - } - - /** rb_str_capitalize - * - */ - @JRubyMethod - public IRubyObject capitalize(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.capitalize_bang(context); - return str; - } - - /** rb_str_capitalize_bang - * - */ - @JRubyMethod(name = "capitalize!") - public IRubyObject capitalize_bang(ThreadContext context) { - if (value.realSize == 0) { - modifyCheck(); - return context.getRuntime().getNil(); - } - - modify(); - - int s = value.begin; - int send = s + value.realSize; - byte[]buf = value.bytes; - - - - boolean modify = false; - - int c = buf[s] & 0xff; - if (ASCII.isLower(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToUpper(c); - modify = true; - } - - while (++s < send) { - c = (char)(buf[s] & 0xff); - if (ASCII.isUpper(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToLower(c); - modify = true; - } - } - - if (modify) return this; - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = ">=") - public IRubyObject op_ge(ThreadContext context, IRubyObject other) { - if (other instanceof RubyString) { - return context.getRuntime().newBoolean(op_cmp((RubyString) other) >= 0); - } - - return RubyComparable.op_ge(context, this, other); - } - - @JRubyMethod(name = ">") - public IRubyObject op_gt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyString) { - return context.getRuntime().newBoolean(op_cmp((RubyString) other) > 0); - } - - return RubyComparable.op_gt(context, this, other); - } - - @JRubyMethod(name = "<=") - public IRubyObject op_le(ThreadContext context, IRubyObject other) { - if (other instanceof RubyString) { - return context.getRuntime().newBoolean(op_cmp((RubyString) other) <= 0); - } - - return RubyComparable.op_le(context, this, other); - } - - @JRubyMethod(name = "<") - public IRubyObject op_lt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyString) { - return context.getRuntime().newBoolean(op_cmp((RubyString) other) < 0); - } - - return RubyComparable.op_lt(context, this, other); - } - - @JRubyMethod(name = "eql?") - public IRubyObject str_eql_p(ThreadContext context, IRubyObject other) { - if (!(other instanceof RubyString)) return context.getRuntime().getFalse(); - RubyString otherString = (RubyString)other; - return value.equal(otherString.value) ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - /** rb_str_upcase - * - */ - @JRubyMethod - public RubyString upcase(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.upcase_bang(context); - return str; - } - - /** rb_str_upcase_bang - * - */ - @JRubyMethod(name = "upcase!") - public IRubyObject upcase_bang(ThreadContext context) { - if (value.realSize == 0) { - modifyCheck(); - return context.getRuntime().getNil(); - } - - modify(); - - int s = value.begin; - int send = s + value.realSize; - byte []buf = value.bytes; - - boolean modify = false; - while (s < send) { - int c = buf[s] & 0xff; - if (ASCII.isLower(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToUpper(c); - modify = true; - } - s++; - } - - if (modify) return this; - return context.getRuntime().getNil(); - } - - /** rb_str_downcase - * - */ - @JRubyMethod - public RubyString downcase(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.downcase_bang(context); - return str; - } - - /** rb_str_downcase_bang - * - */ - @JRubyMethod(name = "downcase!") - public IRubyObject downcase_bang(ThreadContext context) { - if (value.realSize == 0) { - modifyCheck(); - return context.getRuntime().getNil(); - } - - modify(); - - int s = value.begin; - int send = s + value.realSize; - byte []buf = value.bytes; - - boolean modify = false; - while (s < send) { - int c = buf[s] & 0xff; - if (ASCII.isUpper(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToLower(c); - modify = true; - } - s++; - } - - if (modify) return this; - return context.getRuntime().getNil(); - } - - /** rb_str_swapcase - * - */ - @JRubyMethod - public RubyString swapcase(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.swapcase_bang(context); - return str; - } - - /** rb_str_swapcase_bang - * - */ - @JRubyMethod(name = "swapcase!") - public IRubyObject swapcase_bang(ThreadContext context) { - if (value.realSize == 0) { - modifyCheck(); - return context.getRuntime().getNil(); - } - - modify(); - - int s = value.begin; - int send = s + value.realSize; - byte[]buf = value.bytes; - - boolean modify = false; - while (s < send) { - int c = buf[s] & 0xff; - if (ASCII.isUpper(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToLower(c); - modify = true; - } else if (ASCII.isLower(c)) { - buf[s] = (byte)ASCIIEncoding.asciiToUpper(c); - modify = true; - } - s++; - } - - if (modify) return this; - return context.getRuntime().getNil(); - } - - /** rb_str_dump - * - */ - @JRubyMethod - public IRubyObject dump() { - RubyString s = new RubyString(getRuntime(), getMetaClass(), inspectIntoByteList(true)); - s.infectBy(this); - return s; - } - - @JRubyMethod - public IRubyObject insert(ThreadContext context, IRubyObject indexArg, IRubyObject stringArg) { - // MRI behavior: first check for ability to convert to String... - RubyString s = (RubyString)stringArg.convertToString(); - ByteList insert = s.value; - - // ... and then the index - int index = (int) indexArg.convertToInteger().getLongValue(); - if (index < 0) index += value.length() + 1; - - if (index < 0 || index > value.length()) { - throw context.getRuntime().newIndexError("index " + index + " out of range"); - } - - modify(); - - value.unsafeReplace(index, 0, insert); - this.infectBy(s); - return this; - } - - /** rb_str_inspect - * - */ - @JRubyMethod - @Override - public IRubyObject inspect() { - RubyString s = getRuntime().newString(inspectIntoByteList(false)); - s.infectBy(this); - return s; - } - - private ByteList inspectIntoByteList(boolean ignoreKCode) { - Ruby runtime = getRuntime(); - Encoding enc = runtime.getKCode().getEncoding(); - final int length = value.length(); - ByteList sb = new ByteList(length + 2 + length / 100); - - sb.append('\"'); - - for (int i = 0; i < length; i++) { - int c = value.get(i) & 0xFF; - - if (!ignoreKCode) { - int seqLength = enc.length((byte)c); - - if (seqLength > 1 && (i + seqLength -1 < length)) { - // don't escape multi-byte characters, leave them as bytes - sb.append(value, i, seqLength); - i += seqLength - 1; - continue; - } - } - - if (isAlnum(c)) { - sb.append((char)c); - } else if (c == '\"' || c == '\\') { - sb.append('\\').append((char)c); - } else if (c == '#' && isEVStr(i, length)) { - sb.append('\\').append((char)c); - } else if (isPrint(c)) { - sb.append((char)c); - } else if (c == '\n') { - sb.append('\\').append('n'); - } else if (c == '\r') { - sb.append('\\').append('r'); - } else if (c == '\t') { - sb.append('\\').append('t'); - } else if (c == '\f') { - sb.append('\\').append('f'); - } else if (c == '\u000B') { - sb.append('\\').append('v'); - } else if (c == '\u0007') { - sb.append('\\').append('a'); - } else if (c == '\u0008') { - sb.append('\\').append('b'); - } else if (c == '\u001B') { - sb.append('\\').append('e'); - } else { - sb.append(ByteList.plain(Sprintf.sprintf(runtime,"\\%03o",c))); - } - } - - sb.append('\"'); - return sb; - } - - private boolean isEVStr(int i, int length) { - if (i+1 >= length) return false; - int c = value.get(i+1) & 0xFF; - - return c == '$' || c == '@' || c == '{'; - } - - /** rb_str_length - * - */ - @JRubyMethod(name = {"length", "size"}) - public RubyFixnum length() { - return getRuntime().newFixnum(value.length()); - } - - /** rb_str_empty - * - */ - @JRubyMethod(name = "empty?") - public RubyBoolean empty_p(ThreadContext context) { - return isEmpty() ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - public boolean isEmpty() { - return value.length() == 0; - } - - /** rb_str_append - * - */ - public RubyString append(IRubyObject other) { - infectBy(other); - return cat(stringValue(other).value); - } - - /** rb_str_concat - * - */ - @JRubyMethod(name = {"concat", "<<"}) - public RubyString concat(IRubyObject other) { - if (other instanceof RubyFixnum) { - long value = ((RubyFixnum) other).getLongValue(); - if (value >= 0 && value < 256) return cat((byte) value); - } - return append(other); - } - - /** rb_str_crypt - * - */ - @JRubyMethod(name = "crypt") - public RubyString crypt(ThreadContext context, IRubyObject other) { - ByteList salt = stringValue(other).getByteList(); - if (salt.realSize < 2) { - throw context.getRuntime().newArgumentError("salt too short(need >=2 bytes)"); - } - - salt = salt.makeShared(0, 2); - RubyString s = RubyString.newStringShared(context.getRuntime(), JavaCrypt.crypt(salt, this.getByteList())); - s.infectBy(this); - s.infectBy(other); - return s; - } - - /* RubyString aka rb_string_value */ - public static RubyString stringValue(IRubyObject object) { - return (RubyString) (object instanceof RubyString ? object : - object.convertToString()); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args. - */ - public IRubyObject sub(ThreadContext context, IRubyObject[] args, Block block) { - RubyString str = strDup(context.getRuntime()); - str.sub_bang(context, args, block); - return str; - } - - /** rb_str_sub - * - */ - @JRubyMethod(name = "sub", frame = true) - public IRubyObject sub(ThreadContext context, IRubyObject arg0, Block block) { - RubyString str = strDup(context.getRuntime()); - str.sub_bang(context, arg0, block); - return str; - } - - /** rb_str_sub - * - */ - @JRubyMethod(name = "sub", frame = true) - public IRubyObject sub(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - RubyString str = strDup(context.getRuntime()); - str.sub_bang(context, arg0, arg1, block); - return str; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */ - public IRubyObject sub_bang(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 1: - return sub_bang(context, args[0], block); - case 2: - return sub_bang(context, args[0], args[1], block); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_sub_bang - * - */ - @JRubyMethod(name = "sub!", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, Block block) { - if (block.isGiven()) { - RubyRegexp rubyRegex = getPattern(arg0, true); - Regex regex = rubyRegex.getPattern(); - return subBangCommon(regex, context, true, rubyRegex, block, null, false); - } else { - throw context.getRuntime().newArgumentError("wrong number of arguments (1 for 2)"); - } - } - - /** rb_str_sub_bang - * - */ - @JRubyMethod(name = "sub!", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject sub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - RubyString repl = arg1.convertToString(); - RubyRegexp rubyRegex = getPattern(arg0, true); - Regex regex = rubyRegex.getPattern(); - return subBangCommon(regex, context, false, rubyRegex, block, repl, repl.isTaint()); - } - - private IRubyObject subBangCommon(Regex regex, ThreadContext context, final boolean iter, RubyRegexp rubyRegex, Block block, RubyString repl, boolean tainted) { - - int range = value.begin + value.realSize; - Matcher matcher = regex.matcher(value.bytes, value.begin, range); - - Frame frame = context.getPreviousFrame(); - if (matcher.search(value.begin, range, Option.NONE) >= 0) { - if (iter) { - byte[] bytes = value.bytes; - int size = value.realSize; - RubyMatchData match = rubyRegex.updateBackRef(context, this, frame, matcher); - match.use(); - if (regex.numberOfCaptures() == 0) { - repl = objAsString(context, block.yield(context, substr(matcher.getBegin(), matcher.getEnd() - matcher.getBegin()))); - } else { - Region region = matcher.getRegion(); - repl = objAsString(context, block.yield(context, substr(region.beg[0], region.end[0] - region.beg[0]))); - } - modifyCheck(bytes, size); - frozenCheck(); - frame.setBackRef(match); - } else { - repl = rubyRegex.regsub(repl, this, matcher); - rubyRegex.updateBackRef(context, this, frame, matcher); - } - - final int beg; - final int plen; - if (regex.numberOfCaptures() == 0) { - beg = matcher.getBegin(); - plen = matcher.getEnd() - beg; - } else { - Region region = matcher.getRegion(); - beg = region.beg[0]; - plen = region.end[0] - beg; - } - - ByteList replValue = repl.value; - if (replValue.realSize > plen) { - modify(value.realSize + replValue.realSize - plen); - } else { - modify(); - } - if (repl.isTaint()) { - tainted = true; - } - if (replValue.realSize != plen) { - int src = value.begin + beg + plen; - int dst = value.begin + beg + replValue.realSize; - int length = value.realSize - beg - plen; - System.arraycopy(value.bytes, src, value.bytes, dst, length); - } - System.arraycopy(replValue.bytes, replValue.begin, value.bytes, value.begin + beg, replValue.realSize); - value.realSize += replValue.realSize - plen; - if (tainted) { - setTaint(true); - } - return this; - } else { - frame.setBackRef(context.getRuntime().getNil()); - return context.getRuntime().getNil(); - } - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */ - public IRubyObject gsub(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 1: - return gsub(context, args[0], block); - case 2: - return gsub(context, args[0], args[1], block); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_gsub - * - */ - @JRubyMethod(name = "gsub", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject gsub(ThreadContext context, IRubyObject arg0, Block block) { - return gsub(context, arg0, block, false); - } - - /** rb_str_gsub - * - */ - @JRubyMethod(name = "gsub", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject gsub(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - return gsub(context, arg0, arg1, block, false); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */ - public IRubyObject gsub_bang(ThreadContext context, IRubyObject[] args, Block block) { - switch (args.length) { - case 1: - return gsub_bang(context, args[0], block); - case 2: - return gsub_bang(context, args[0], args[1], block); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_gsub_bang - * - */ - @JRubyMethod(name = "gsub!", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject gsub_bang(ThreadContext context, IRubyObject arg0, Block block) { - return gsub(context, arg0, block, true); - } - - /** rb_str_gsub_bang - * - */ - @JRubyMethod(name = "gsub!", frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject gsub_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) { - return gsub(context, arg0, arg1, block, true); - } - - private final IRubyObject gsub(ThreadContext context, IRubyObject arg0, Block block, final boolean bang) { - if (block.isGiven()) { - RubyRegexp rubyRegex = getPattern(arg0, true); - Regex regex = rubyRegex.getPattern(); - return gsubCommon(regex, context, bang, true, rubyRegex, block, null, false); - } else { - throw context.getRuntime().newArgumentError("wrong number of arguments (1 for 2)"); - } - } - - private final IRubyObject gsub(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block, final boolean bang) { - IRubyObject repl = arg1.convertToString(); - RubyRegexp rubyRegex = getPattern(arg0, true); - Regex regex = rubyRegex.getPattern(); - return gsubCommon(regex, context, bang, false, rubyRegex, block, repl, repl.isTaint()); - } - - private IRubyObject gsubCommon(Regex regex, ThreadContext context, final boolean bang, final boolean iter, RubyRegexp rubyRegex, Block block, IRubyObject repl, boolean tainted) { - - int begin = value.begin; - int range = begin + value.realSize; - Matcher matcher = regex.matcher(value.bytes, begin, range); - - int beg = matcher.search(begin, range, Option.NONE); - - Frame frame = context.getPreviousFrame(); - - if (beg < 0) { - frame.setBackRef(context.getRuntime().getNil()); - return bang ? context.getRuntime().getNil() : strDup(context.getRuntime()); /* bang: true, no match, no substitution */ - } - - int blen = value.realSize + 30; /* len + margin */ - ByteList dest = new ByteList(blen); - dest.realSize = blen; - int buf = 0; - int bp = 0; - int cp = value.begin; - - int offset = 0; - RubyString val; - - RubyMatchData match = null; - while (beg >= 0) { - final int begz; - final int endz; - if (iter) { - byte[] bytes = value.bytes; - int size = value.realSize; - match = rubyRegex.updateBackRef(context, this, frame, matcher); - match.use(); - if (regex.numberOfCaptures() == 0) { - begz = matcher.getBegin(); - endz = matcher.getEnd(); - val = objAsString(context, block.yield(context, substr(context.getRuntime(), begz, endz - begz))); - } else { - Region region = matcher.getRegion(); - begz = region.beg[0]; - endz = region.end[0]; - val = objAsString(context, block.yield(context, substr(context.getRuntime(), begz, endz - begz))); - } - modifyCheck(bytes, size); - if (bang) { - frozenCheck(); - } - } else { - val = rubyRegex.regsub((RubyString) repl, this, matcher); - if (regex.numberOfCaptures() == 0) { - begz = matcher.getBegin(); - endz = matcher.getEnd(); - } else { - Region region = matcher.getRegion(); - begz = region.beg[0]; - endz = region.end[0]; - } - } - - if (val.isTaint()) { - tainted = true; - } - ByteList vbuf = val.value; - int len = (bp - buf) + (beg - offset) + vbuf.realSize + 3; - if (blen < len) { - while (blen < len) { - blen <<= 1; - } - len = bp - buf; - dest.realloc(blen); - dest.realSize = blen; - bp = buf + len; - } - len = beg - offset; /* copy pre-match substr */ - System.arraycopy(value.bytes, cp, dest.bytes, bp, len); - bp += len; - System.arraycopy(vbuf.bytes, vbuf.begin, dest.bytes, bp, vbuf.realSize); - bp += vbuf.realSize; - offset = endz; - - if (begz == endz) { - if (value.realSize <= endz) { - break; - } - len = regex.getEncoding().length(value.bytes[begin + endz]); - System.arraycopy(value.bytes, begin + endz, dest.bytes, bp, len); - bp += len; - offset = endz + len; - } - cp = begin + offset; - if (offset > value.realSize) { - break; - } - beg = matcher.search(cp, range, Option.NONE); - } - - if (value.realSize > offset) { - int len = bp - buf; - if (blen - len < value.realSize - offset) { - blen = len + value.realSize - offset; - dest.realloc(blen); - bp = buf + len; - } - System.arraycopy(value.bytes, cp, dest.bytes, bp, value.realSize - offset); - bp += value.realSize - offset; - } - - if (match != null) { - frame.setBackRef(match); - } else { - rubyRegex.updateBackRef(context, this, frame, matcher); - } - - dest.realSize = bp - buf; - if (bang) { - view(dest); - if (tainted) { - setTaint(true); - } - return this; - } else { - RubyString destStr = new RubyString(context.getRuntime(), getMetaClass(), dest); - destStr.infectBy(this); - if (tainted) { - destStr.setTaint(true); - } - return destStr; - } - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args. - */ - public IRubyObject index(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 1: - return index(context, args[0]); - case 2: - return index(context, args[0], args[1]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_index_m - * - */ - @JRubyMethod(reads = BACKREF, writes = BACKREF) - public IRubyObject index(ThreadContext context, IRubyObject arg0) { - return indexCommon(0, arg0, context); - } - - /** rb_str_index_m - * - */ - @JRubyMethod(reads = BACKREF, writes = BACKREF) - public IRubyObject index(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - int pos = RubyNumeric.num2int(arg1); - - if (pos < 0) { - pos += value.realSize; - if (pos < 0) { - if (arg0 instanceof RubyRegexp) { - context.getPreviousFrame().setBackRef(context.getRuntime().getNil()); - } - return context.getRuntime().getNil(); - } - } - - return indexCommon(pos, arg0, context); - } - - private IRubyObject indexCommon(int pos, IRubyObject sub, ThreadContext context) throws RaiseException { - if (sub instanceof RubyRegexp) { - RubyRegexp regSub = (RubyRegexp) sub; - - pos = regSub.adjustStartPos(this, pos, false); - pos = regSub.search(context, this, pos, false); - } else if (sub instanceof RubyFixnum) { - int c_int = RubyNumeric.fix2int(sub); - if (c_int < 0x00 || c_int > 0xFF) { - // out of byte range - // there will be no match for sure - return context.getRuntime().getNil(); - } - byte c = (byte) c_int; - byte[] bytes = value.bytes; - int end = value.begin + value.realSize; - - pos += value.begin; - for (; pos < end; pos++) { - if (bytes[pos] == c) { - return RubyFixnum.newFixnum(context.getRuntime(), pos - value.begin); - } - } - return context.getRuntime().getNil(); - } else if (sub instanceof RubyString) { - pos = strIndex((RubyString) sub, pos); - } else { - IRubyObject tmp = sub.checkStringType(); - - if (tmp.isNil()) { - throw context.getRuntime().newTypeError("type mismatch: " + sub.getMetaClass().getName() + " given"); - } - pos = strIndex((RubyString) tmp, pos); - } - - return pos == -1 ? context.getRuntime().getNil() : RubyFixnum.newFixnum(context.getRuntime(), pos); - } - - private int strIndex(RubyString sub, int offset) { - if (offset < 0) { - offset += value.realSize; - if (offset < 0) return -1; - } - - if (value.realSize - offset < sub.value.realSize) return -1; - if (sub.value.realSize == 0) return offset; - return value.indexOf(sub.value, offset); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two arguments. - */ - public IRubyObject rindex(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 1: - return rindex(context, args[0]); - case 2: - return rindex(context, args[0], args[1]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_rindex_m - * - */ - @JRubyMethod(reads = BACKREF, writes = BACKREF) - public IRubyObject rindex(ThreadContext context, IRubyObject arg0) { - return rindexCommon(arg0, value.realSize, context); - } - - /** rb_str_rindex_m - * - */ - @JRubyMethod(reads = BACKREF, writes = BACKREF) - public IRubyObject rindex(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - int pos = RubyNumeric.num2int(arg1); - - if (pos < 0) { - pos += value.realSize; - if (pos < 0) { - if (arg0 instanceof RubyRegexp) { - context.getPreviousFrame().setBackRef(context.getRuntime().getNil()); - } - return context.getRuntime().getNil(); - } - } - if (pos > value.realSize) pos = value.realSize; - - return rindexCommon(arg0, pos, context); - } - - private IRubyObject rindexCommon(final IRubyObject sub, int pos, ThreadContext context) throws RaiseException { - - if (sub instanceof RubyRegexp) { - RubyRegexp regSub = (RubyRegexp) sub; - if (regSub.length() > 0) { - pos = regSub.adjustStartPos(this, pos, true); - pos = regSub.search(context, this, pos, true); - } - if (pos >= 0) { - return RubyFixnum.newFixnum(context.getRuntime(), pos); - } - } else if (sub instanceof RubyString) { - pos = strRindex((RubyString) sub, pos); - if (pos >= 0) return RubyFixnum.newFixnum(context.getRuntime(), pos); - } else if (sub instanceof RubyFixnum) { - int c_int = RubyNumeric.fix2int(sub); - if (c_int < 0x00 || c_int > 0xFF) { - // out of byte range - // there will be no match for sure - return context.getRuntime().getNil(); - } - byte c = (byte) c_int; - - byte[] bytes = value.bytes; - int pbeg = value.begin; - int p = pbeg + pos; - - if (pos == value.realSize) { - if (pos == 0) { - return context.getRuntime().getNil(); - } - --p; - } - while (pbeg <= p) { - if (bytes[p] == c) { - return RubyFixnum.newFixnum(context.getRuntime(), p - value.begin); - } - p--; - } - return context.getRuntime().getNil(); - } else { - IRubyObject tmp = sub.checkStringType(); - if (tmp.isNil()) throw context.getRuntime().newTypeError("type mismatch: " + sub.getMetaClass().getName() + " given"); - pos = strRindex((RubyString) tmp, pos); - if (pos >= 0) return RubyFixnum.newFixnum(context.getRuntime(), pos); - } - - return context.getRuntime().getNil(); - } - - private int strRindex(RubyString sub, int pos) { - int subLength = sub.value.realSize; - - /* substring longer than string */ - if (value.realSize < subLength) return -1; - if (value.realSize - pos < subLength) pos = value.realSize - subLength; - - return value.lastIndexOf(sub.value, pos); - } - - /* rb_str_substr */ - public IRubyObject substr(int beg, int len) { - return substr(getRuntime(), beg, len); - } - - public IRubyObject substr(Ruby runtime, int beg, int len) { - int length = value.length(); - if (len < 0 || beg > length) return getRuntime().getNil(); - - if (beg < 0) { - beg += length; - if (beg < 0) return getRuntime().getNil(); - } - - int end = Math.min(length, beg + len); - return makeShared(getRuntime(), beg, end - beg); - } - - - - /* rb_str_replace */ - public IRubyObject replace(int beg, int len, RubyString replaceWith) { - if (beg + len >= value.length()) len = value.length() - beg; - - modify(); - value.unsafeReplace(beg,len,replaceWith.value); - - return infectBy(replaceWith); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the versions with one or two args - */ - public IRubyObject op_aref(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 1: - return op_aref(context, args[0]); - case 2: - return op_aref(context, args[0], args[1]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_aref, rb_str_aref_m - * - */ - @JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes = BACKREF) - public IRubyObject op_aref(ThreadContext context, IRubyObject arg1, IRubyObject arg2) { - if (arg1 instanceof RubyRegexp) { - if(((RubyRegexp)arg1).search(context, this, 0, false) >= 0) { - return RubyRegexp.nth_match(RubyNumeric.fix2int(arg2), context.getCurrentFrame().getBackRef()); - } - return context.getRuntime().getNil(); - } - return substr(context.getRuntime(), RubyNumeric.fix2int(arg1), RubyNumeric.fix2int(arg2)); - } - - /** rb_str_aref, rb_str_aref_m - * - */ - @JRubyMethod(name = {"[]", "slice"}, reads = BACKREF, writes = BACKREF) - public IRubyObject op_aref(ThreadContext context, IRubyObject arg) { - if (arg instanceof RubyRegexp) { - if(((RubyRegexp)arg).search(context, this, 0, false) >= 0) { - return RubyRegexp.nth_match(0, context.getCurrentFrame().getBackRef()); - } - return context.getRuntime().getNil(); - } else if (arg instanceof RubyString) { - return value.indexOf(stringValue(arg).value) != -1 ? - arg : context.getRuntime().getNil(); - } else if (arg instanceof RubyRange) { - long[] begLen = ((RubyRange) arg).begLen(value.length(), 0); - return begLen == null ? context.getRuntime().getNil() : - substr(context.getRuntime(), (int) begLen[0], (int) begLen[1]); - } - int idx = (int) arg.convertToInteger().getLongValue(); - - if (idx < 0) idx += value.length(); - if (idx < 0 || idx >= value.length()) return context.getRuntime().getNil(); - - return context.getRuntime().newFixnum(value.get(idx) & 0xFF); - } - - /** - * rb_str_subpat_set - * - */ - private void subpatSet(ThreadContext context, RubyRegexp regexp, int nth, IRubyObject repl) { - RubyMatchData match; - int start, end, len; - if (regexp.search(context, this, 0, false) < 0) throw context.getRuntime().newIndexError("regexp not matched"); - - match = (RubyMatchData)context.getCurrentFrame().getBackRef(); - - if (match.regs == null) { - if (nth >= 1) throw context.getRuntime().newIndexError("index " + nth + " out of regexp"); - if (nth < 0) { - if(-nth >= 1) throw context.getRuntime().newIndexError("index " + nth + " out of regexp"); - nth += 1; - } - start = match.begin; - if(start == -1) throw context.getRuntime().newIndexError("regexp group " + nth + " not matched"); - end = match.end; - } else { - if(nth >= match.regs.numRegs) throw context.getRuntime().newIndexError("index " + nth + " out of regexp"); - if(nth < 0) { - if(-nth >= match.regs.numRegs) throw context.getRuntime().newIndexError("index " + nth + " out of regexp"); - nth += match.regs.numRegs; - } - start = match.regs.beg[nth]; - if(start == -1) throw context.getRuntime().newIndexError("regexp group " + nth + " not matched"); - end = match.regs.end[nth]; - } - - len = end - start; - replace(start, len, stringValue(repl)); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with two or three args. - */ - public IRubyObject op_aset(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 2: - return op_aset(context, args[0], args[1]); - case 3: - return op_aset(context, args[0], args[1], args[2]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 2, 3); - return null; // not reached - } - } - - /** rb_str_aset, rb_str_aset_m - * - */ - @JRubyMethod(name = "[]=", reads = BACKREF) - public IRubyObject op_aset(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - if (arg0 instanceof RubyFixnum || arg0.respondsTo("to_int")) { // FIXME: RubyNumeric or RubyInteger instead? - int idx = RubyNumeric.fix2int(arg0); - - if (idx < 0) idx += value.length(); - - if (idx < 0 || idx >= value.length()) { - throw context.getRuntime().newIndexError("string index out of bounds"); - } - if (arg1 instanceof RubyFixnum) { - modify(); - value.set(idx, (byte) RubyNumeric.fix2int(arg1)); - } else { - replace(idx, 1, stringValue(arg1)); - } - return arg1; - } - if (arg0 instanceof RubyRegexp) { - RubyString repl = stringValue(arg1); - subpatSet(context, (RubyRegexp) arg0, 0, repl); - return repl; - } - if (arg0 instanceof RubyString) { - RubyString orig = (RubyString)arg0; - int beg = value.indexOf(orig.value); - if (beg < 0) throw context.getRuntime().newIndexError("string not matched"); - replace(beg, orig.value.length(), stringValue(arg1)); - return arg1; - } - if (arg0 instanceof RubyRange) { - long[] begLen = ((RubyRange) arg0).begLen(value.realSize, 2); - replace((int) begLen[0], (int) begLen[1], stringValue(arg1)); - return arg1; - } - throw context.getRuntime().newTypeError("wrong argument type"); - } - - /** rb_str_aset, rb_str_aset_m - * - */ - @JRubyMethod(name = "[]=", reads = BACKREF) - public IRubyObject op_aset(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) { - if (arg0 instanceof RubyRegexp) { - RubyString repl = stringValue(arg2); - int nth = RubyNumeric.fix2int(arg1); - subpatSet(context, (RubyRegexp) arg0, nth, repl); - return repl; - } - RubyString repl = stringValue(arg2); - int beg = RubyNumeric.fix2int(arg0); - int len = RubyNumeric.fix2int(arg1); - if (len < 0) throw context.getRuntime().newIndexError("negative length"); - int strLen = value.length(); - if (beg < 0) beg += strLen; - - if (beg < 0 || (beg > 0 && beg > strLen)) { - throw context.getRuntime().newIndexError("string index out of bounds"); - } - if (beg + len > strLen) len = strLen - beg; - - replace(beg, len, repl); - return repl; - } - - /** - * Variable arity version for compatibility. Not bound as a Ruby method. - * @deprecated Use the versions with one or two args. - */ - public IRubyObject slice_bang(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 1: - return slice_bang(context, args[0]); - case 2: - return slice_bang(context, args[0], args[1]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_slice_bang - * - */ - @JRubyMethod(name = "slice!", reads = BACKREF, writes = BACKREF) - public IRubyObject slice_bang(ThreadContext context, IRubyObject arg0) { - IRubyObject result = op_aref(context, arg0); - if (result.isNil()) return result; - - op_aset(context, arg0, RubyString.newEmptyString(context.getRuntime())); - return result; - } - - /** rb_str_slice_bang - * - */ - @JRubyMethod(name = "slice!", reads = BACKREF, writes = BACKREF) - public IRubyObject slice_bang(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - IRubyObject result = op_aref(context, arg0, arg1); - if (result.isNil()) return result; - - op_aset(context, arg0, arg1, RubyString.newEmptyString(context.getRuntime())); - return result; - } - - @JRubyMethod(name = {"succ", "next"}) - public IRubyObject succ(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.succ_bang(); - return str; - } - - @JRubyMethod(name = {"succ!", "next!"}) - public IRubyObject succ_bang() { - if (value.length() == 0) { - modifyCheck(); - return this; - } - - modify(); - - boolean alnumSeen = false; - int pos = -1; - int c = 0; - int n = 0; - for (int i = value.length() - 1; i >= 0; i--) { - c = value.get(i) & 0xFF; - if (isAlnum(c)) { - alnumSeen = true; - if ((isDigit(c) && c < '9') || (isLower(c) && c < 'z') || (isUpper(c) && c < 'Z')) { - value.set(i, (byte)(c + 1)); - pos = -1; - break; - } - pos = i; - n = isDigit(c) ? '1' : (isLower(c) ? 'a' : 'A'); - value.set(i, (byte)(isDigit(c) ? '0' : (isLower(c) ? 'a' : 'A'))); - } - } - if (!alnumSeen) { - for (int i = value.length() - 1; i >= 0; i--) { - c = value.get(i) & 0xFF; - if (c < 0xff) { - value.set(i, (byte)(c + 1)); - pos = -1; - break; - } - pos = i; - n = '\u0001'; - value.set(i, 0); - } - } - if (pos > -1) { - // This represents left most digit in a set of incremented - // values? Therefore leftmost numeric must be '1' and not '0' - // 999 -> 1000, not 999 -> 0000. whereas chars should be - // zzz -> aaaa and non-alnum byte values should be "\377" -> "\001\000" - value.insert(pos, (byte) n); - } - return this; - } - - /** rb_str_upto_m - * - */ - @JRubyMethod(name = "upto", required = 1, frame = true) - public IRubyObject upto(ThreadContext context, IRubyObject str, Block block) { - return upto(context, str, false, block); - } - - /* rb_str_upto */ - public IRubyObject upto(ThreadContext context, IRubyObject str, boolean excl, Block block) { - RubyString end = str.convertToString(); - - int n = value.cmp(end.value); - if (n > 0 || (excl && n == 0)) return this; - - IRubyObject afterEnd = end.callMethod(context, "succ"); - RubyString current = this; - - while (!current.op_equal(context, afterEnd).isTrue()) { - block.yield(context, current); - if (!excl && current.op_equal(context, end).isTrue()) break; - current = current.callMethod(context, "succ").convertToString(); - if (excl && current.op_equal(context, end).isTrue()) break; - if (current.value.realSize > end.value.realSize || current.value.realSize == 0) break; - } - - return this; - } - - /** rb_str_include - * - */ - @JRubyMethod(name = "include?", required = 1) - public RubyBoolean include_p(ThreadContext context, IRubyObject obj) { - if (obj instanceof RubyFixnum) { - int c = RubyNumeric.fix2int(obj); - for (int i = 0; i < value.length(); i++) { - if (value.get(i) == (byte)c) { - return context.getRuntime().getTrue(); - } - } - return context.getRuntime().getFalse(); - } - ByteList str = stringValue(obj).value; - return context.getRuntime().newBoolean(value.indexOf(str) != -1); - } - - /** - * Variable-arity version for compatibility. Not bound as a Ruby method. - * @deprecated Use the versions with zero or one args. - */ - public IRubyObject to_i(IRubyObject[] args) { - switch (args.length) { - case 0: - return to_i(); - case 1: - return to_i(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** rb_str_to_i - * - */ - @JRubyMethod(name = "to_i") - public IRubyObject to_i() { - return RubyNumeric.str2inum(getRuntime(), this, 10); - } - - /** rb_str_to_i - * - */ - @JRubyMethod(name = "to_i") - public IRubyObject to_i(IRubyObject arg0) { - long base = arg0.convertToInteger().getLongValue(); - return RubyNumeric.str2inum(getRuntime(), this, (int) base); - } - - /** rb_str_oct - * - */ - @JRubyMethod(name = "oct") - public IRubyObject oct(ThreadContext context) { - if (isEmpty()) return context.getRuntime().newFixnum(0); - - int base = 8; - - int ix = value.begin; - - while(ix < value.begin+value.realSize && ASCII.isSpace(value.bytes[ix] & 0xff)) { - ix++; - } - - int pos = (value.bytes[ix] == '-' || value.bytes[ix] == '+') ? ix+1 : ix; - if((pos+1) < value.begin+value.realSize && value.bytes[pos] == '0') { - if(value.bytes[pos+1] == 'x' || value.bytes[pos+1] == 'X') { - base = 16; - } else if(value.bytes[pos+1] == 'b' || value.bytes[pos+1] == 'B') { - base = 2; - } else if(value.bytes[pos+1] == 'd' || value.bytes[pos+1] == 'D') { - base = 10; - } - } - return RubyNumeric.str2inum(context.getRuntime(), this, base); - } - - /** rb_str_hex - * - */ - @JRubyMethod(name = "hex") - public IRubyObject hex(ThreadContext context) { - return RubyNumeric.str2inum(context.getRuntime(), this, 16); - } - - /** rb_str_to_f - * - */ - @JRubyMethod(name = "to_f") - public IRubyObject to_f() { - return RubyNumeric.str2fnum(getRuntime(), this); - } - - /** - * Variable arity version for compatibility. Not bound to a Ruby method. - * @deprecated Use the versions with zero, one, or two args. - */ - public RubyArray split(ThreadContext context, IRubyObject[] args) { - switch (args.length) { - case 0: - return split(context); - case 1: - return split(context, args[0]); - case 2: - return split(context, args[0], args[1]); - default: - Arity.raiseArgumentError(context.getRuntime(), args.length, 0, 2); - return null; // not reached - } - } - - /** rb_str_split_m - * - */ - @JRubyMethod(writes = BACKREF) - public RubyArray split(ThreadContext context) { - return split(context, context.getRuntime().getNil()); - } - - /** rb_str_split_m - * - */ - @JRubyMethod(writes = BACKREF) - public RubyArray split(ThreadContext context, IRubyObject arg0) { - return splitCommon(arg0, false, 0, 0, context); - } - - /** rb_str_split_m - * - */ - @JRubyMethod(writes = BACKREF) - public RubyArray split(ThreadContext context, IRubyObject arg0, IRubyObject arg1) { - final int lim = RubyNumeric.fix2int(arg1); - if (lim <= 0) { - return splitCommon(arg0, false, lim, 1, context); - } else { - if (lim == 1) return value.realSize == 0 ? context.getRuntime().newArray() : context.getRuntime().newArray(this); - return splitCommon(arg0, true, lim, 1, context); - } - } - - private RubyArray splitCommon(IRubyObject spat, final boolean limit, final int lim, final int i, ThreadContext context) { - final RubyArray result; - if (spat.isNil() && (spat = context.getRuntime().getGlobalVariables().get("$;")).isNil()) { - result = awkSplit(limit, lim, i); - } else { - if (spat instanceof RubyString && ((RubyString) spat).value.realSize == 1) { - RubyString strSpat = (RubyString) spat; - if (strSpat.value.bytes[strSpat.value.begin] == (byte) ' ') { - result = awkSplit(limit, lim, i); - } else { - result = split(context, spat, limit, lim, i); - } - } else { - result = split(context, spat, limit, lim, i); - } - } - - if (!limit && lim == 0) { - while (result.size() > 0 && ((RubyString) result.eltInternal(result.size() - 1)).value.realSize == 0) { - result.pop(); - } - } - - return result; - } - - private RubyArray split(ThreadContext context, IRubyObject pat, boolean limit, int lim, int i) { - Ruby runtime = context.getRuntime(); - - final Regex regex = getPattern(pat, true).getPattern(); - int beg, end, start; - - int begin = value.begin; - start = begin; - beg = 0; - - int range = value.begin + value.realSize; - final Matcher matcher = regex.matcher(value.bytes, value.begin, range); - - boolean lastNull = false; - RubyArray result = runtime.newArray(); - if (regex.numberOfCaptures() == 0) { // shorter path, no captures defined, no region will be returned - while ((end = matcher.search(start, range, Option.NONE)) >= 0) { - if (start == end + begin && matcher.getBegin() == matcher.getEnd()) { - if (value.realSize == 0) { - result.append(newEmptyString(runtime, getMetaClass())); - break; - } else if (lastNull) { - result.append(substr(runtime, beg, regex.getEncoding().length(value.bytes[begin + beg]))); - beg = start - begin; - } else { - if (start == range) { - start++; - } else { - start += regex.getEncoding().length(value.bytes[start]); - } - lastNull = true; - continue; - } - } else { - result.append(substr(beg, end - beg)); - beg = matcher.getEnd(); - start = begin + matcher.getEnd(); - } - lastNull = false; - if (limit && lim <= ++i) break; - } - } else { - while ((end = matcher.search(start, range, Option.NONE)) >= 0) { - final Region region = matcher.getRegion(); - if (start == end + begin && region.beg[0] == region.end[0]) { - if (value.realSize == 0) { - result.append(newEmptyString(runtime, getMetaClass())); - break; - } else if (lastNull) { - result.append(substr(beg, regex.getEncoding().length(value.bytes[begin + beg]))); - beg = start - begin; - } else { - if (start == range) { - start++; - } else { - start += regex.getEncoding().length(value.bytes[start]); - } - lastNull = true; - continue; - } - } else { - result.append(substr(beg, end - beg)); - beg = start = region.end[0]; - start += begin; - } - lastNull = false; - - for (int idx=1; idx<region.numRegs; idx++) { - if (region.beg[idx] == -1) continue; - if (region.beg[idx] == region.end[idx]) { - result.append(newEmptyString(runtime, getMetaClass())); - } else { - result.append(substr(region.beg[idx], region.end[idx] - region.beg[idx])); - } - } - if (limit && lim <= ++i) break; - } - } - - // only this case affects backrefs - context.getCurrentFrame().setBackRef(runtime.getNil()); - - if (value.realSize > 0 && (limit || value.realSize > beg || lim < 0)) { - if (value.realSize == beg) { - result.append(newEmptyString(runtime, getMetaClass())); - } else { - result.append(substr(beg, value.realSize - beg)); - } - } - - return result; - } - - private RubyArray awkSplit(boolean limit, int lim, int i) { - Ruby runtime = getRuntime(); - RubyArray result = runtime.newArray(); - - byte[]bytes = value.bytes; - int p = value.begin; - int endp = p + value.realSize; - - boolean skip = true; - - int end, beg = 0; - for (end = beg = 0; p < endp; p++) { - if (skip) { - if (ASCII.isSpace(bytes[p] & 0xff)) { - beg++; - } else { - end = beg + 1; - skip = false; - if (limit && lim <= i) break; - } - } else { - if (ASCII.isSpace(bytes[p] & 0xff)) { - result.append(makeShared(runtime, beg, end - beg)); - skip = true; - beg = end + 1; - if (limit) i++; - } else { - end++; - } - } - } - - if (value.realSize > 0 && (limit || value.realSize > beg || lim < 0)) { - if (value.realSize == beg) { - result.append(newEmptyString(runtime, getMetaClass())); - } else { - result.append(makeShared(runtime, beg, value.realSize - beg)); - } - } - return result; - } - - /** get_pat - * - */ - private final RubyRegexp getPattern(IRubyObject obj, boolean quote) { - if (obj instanceof RubyRegexp) { - return (RubyRegexp)obj; - } else if (!(obj instanceof RubyString)) { - IRubyObject val = obj.checkStringType(); - if (val.isNil()) throw getRuntime().newTypeError("wrong argument type " + obj.getMetaClass() + " (expected Regexp)"); - obj = val; - } - - return RubyRegexp.newRegexp(getRuntime(), ((RubyString)obj).value, 0, quote); - } - - /** rb_str_scan - * - */ - @JRubyMethod(name = "scan", required = 1, frame = true, reads = BACKREF, writes = BACKREF) - public IRubyObject scan(ThreadContext context, IRubyObject arg, Block block) { - Ruby runtime = context.getRuntime(); - Frame frame = context.getPreviousFrame(); - - final RubyRegexp rubyRegex = getPattern(arg, true); - final Regex regex = rubyRegex.getPattern(); - - int range = value.begin + value.realSize; - final Matcher matcher = regex.matcher(value.bytes, value.begin, range); - matcher.value = 0; // implicit start argument to scanOnce(NG) - - IRubyObject result; - if (!block.isGiven()) { - RubyArray ary = runtime.newArray(); - - if (regex.numberOfCaptures() == 0) { - while ((result = scanOnceNG(rubyRegex, matcher, range)) != null) ary.append(result); - } else { - while ((result = scanOnce(rubyRegex, matcher, range)) != null) ary.append(result); - } - - if (ary.size() > 0) { - rubyRegex.updateBackRef(context, this, frame, matcher); - } else { - frame.setBackRef(runtime.getNil()); - } - return ary; - } else { - byte[]bytes = value.bytes; - int size = value.realSize; - RubyMatchData match = null; - - if (regex.numberOfCaptures() == 0) { - while ((result = scanOnceNG(rubyRegex, matcher, range)) != null) { - match = rubyRegex.updateBackRef(context, this, frame, matcher); - match.use(); - block.yield(context, result); - modifyCheck(bytes, size); - } - } else { - while ((result = scanOnce(rubyRegex, matcher, range)) != null) { - match = rubyRegex.updateBackRef(context, this, frame, matcher); - match.use(); - block.yield(context, result); - modifyCheck(bytes, size); - } - } - frame.setBackRef(match == null ? runtime.getNil() : match); - return this; - } - } - - /** - * rb_enc_check - */ - @SuppressWarnings("unused") - private Encoding encodingCheck(RubyRegexp pattern) { - // For 1.9 compatibility, should check encoding compat between string and pattern - return pattern.getKCode().getEncoding(); - } - - // no group version - private IRubyObject scanOnceNG(RubyRegexp regex, Matcher matcher, int range) { - if (matcher.search(matcher.value + value.begin, range, Option.NONE) >= 0) { - int end = matcher.getEnd(); - if (matcher.getBegin() == end) { - if (value.realSize > end) { - matcher.value = end + regex.getPattern().getEncoding().length(value.bytes[value.begin + end]); - } else { - matcher.value = end + 1; - } - } else { - matcher.value = end; - } - return substr(matcher.getBegin(), end - matcher.getBegin()).infectBy(regex); - } - return null; - } - - // group version - private IRubyObject scanOnce(RubyRegexp regex, Matcher matcher, int range) { - if (matcher.search(matcher.value + value.begin, range, Option.NONE) >= 0) { - Region region = matcher.getRegion(); - int end = region.end[0]; - if (region.beg[0] == end) { - if (value.realSize > end) { - matcher.value = end + regex.getPattern().getEncoding().length(value.bytes[value.begin + end]); - } else { - matcher.value = end + 1; - } - } else { - matcher.value = end; - } - - RubyArray result = getRuntime().newArray(region.numRegs); - for (int i=1; i<region.numRegs; i++) { - int beg = region.beg[i]; - if (beg == -1) { - result.append(getRuntime().getNil()); - } else { - result.append(substr(beg, region.end[i] - beg).infectBy(regex)); - } - } - return result; - } - return null; - } - - private static final ByteList SPACE_BYTELIST = new ByteList(ByteList.plain(" ")); - - private final IRubyObject justify(IRubyObject arg0, char jflag) { - Ruby runtime = getRuntime(); - - int width = RubyFixnum.num2int(arg0); - - int f, flen = 0; - byte[]fbuf; - - IRubyObject pad; - - f = SPACE_BYTELIST.begin; - flen = SPACE_BYTELIST.realSize; - fbuf = SPACE_BYTELIST.bytes; - pad = runtime.getNil(); - - return justifyCommon(width, jflag, flen, fbuf, f, runtime, pad); - } - - private final IRubyObject justify(IRubyObject arg0, IRubyObject arg1, char jflag) { - Ruby runtime = getRuntime(); - - int width = RubyFixnum.num2int(arg0); - - int f, flen = 0; - byte[]fbuf; - - IRubyObject pad; - - pad = arg1.convertToString(); - ByteList fList = ((RubyString)pad).value; - f = fList.begin; - flen = fList.realSize; - - if (flen == 0) throw runtime.newArgumentError("zero width padding"); - - fbuf = fList.bytes; - - return justifyCommon(width, jflag, flen, fbuf, f, runtime, pad); - } - - private IRubyObject justifyCommon(int width, char jflag, int flen, byte[] fbuf, int f, Ruby runtime, IRubyObject pad) { - if (width < 0 || value.realSize >= width) return strDup(runtime); - - ByteList res = new ByteList(width); - res.realSize = width; - - int p = res.begin; - int pend; - byte[] pbuf = res.bytes; - - if (jflag != 'l') { - int n = width - value.realSize; - pend = p + ((jflag == 'r') ? n : n / 2); - if (flen <= 1) { - while (p < pend) { - pbuf[p++] = fbuf[f]; - } - } else { - int q = f; - while (p + flen <= pend) { - System.arraycopy(fbuf, f, pbuf, p, flen); - p += flen; - } - while (p < pend) { - pbuf[p++] = fbuf[q++]; - } - } - } - - System.arraycopy(value.bytes, value.begin, pbuf, p, value.realSize); - - if (jflag != 'r') { - p += value.realSize; - pend = res.begin + width; - if (flen <= 1) { - while (p < pend) { - pbuf[p++] = fbuf[f]; - } - } else { - while (p + flen <= pend) { - System.arraycopy(fbuf, f, pbuf, p, flen); - p += flen; - } - while (p < pend) { - pbuf[p++] = fbuf[f++]; - } - } - } - - RubyString resStr = new RubyString(runtime, getMetaClass(), res); - resStr.infectBy(this); - if (flen > 0) { - resStr.infectBy(pad); - } - return resStr; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */ - public IRubyObject ljust(IRubyObject [] args) { - switch (args.length) { - case 1: - return ljust(args[0]); - case 2: - return ljust(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_ljust - * - */ - @JRubyMethod - public IRubyObject ljust(IRubyObject arg0) { - return justify(arg0, 'l'); - } - - /** rb_str_ljust - * - */ - @JRubyMethod - public IRubyObject ljust(IRubyObject arg0, IRubyObject arg1) { - return justify(arg0, arg1, 'l'); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */ - public IRubyObject rjust(IRubyObject [] args) { - switch (args.length) { - case 1: - return rjust(args[0]); - case 2: - return rjust(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_rjust - * - */ - @JRubyMethod - public IRubyObject rjust(IRubyObject arg0) { - return justify(arg0, 'r'); - } - - /** rb_str_rjust - * - */ - @JRubyMethod - public IRubyObject rjust(IRubyObject arg0, IRubyObject arg1) { - return justify(arg0, arg1, 'r'); - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated use the one or two argument versions. - */ - public IRubyObject center(IRubyObject [] args) { - switch (args.length) { - case 1: - return center(args[0]); - case 2: - return center(args[0], args[1]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 1, 2); - return null; // not reached - } - } - - /** rb_str_center - * - */ - @JRubyMethod - public IRubyObject center(IRubyObject arg0) { - return justify(arg0, 'c'); - } - - /** rb_str_center - * - */ - @JRubyMethod - public IRubyObject center(IRubyObject arg0, IRubyObject arg1) { - return justify(arg0, arg1, 'c'); - } - - @JRubyMethod(name = "chop") - public IRubyObject chop(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.chop_bang(); - return str; - } - - /** rb_str_chop_bang - * - */ - @JRubyMethod(name = "chop!") - public IRubyObject chop_bang() { - int end = value.realSize - 1; - if (end < 0) return getRuntime().getNil(); - - if ((value.bytes[value.begin + end]) == '\n') { - if (end > 0 && (value.bytes[value.begin + end - 1]) == '\r') end--; - } - - view(0, end); - return this; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby - * - * @param args - * @return - * @deprecated Use the zero or one argument versions. - */ - public RubyString chomp(IRubyObject[] args) { - switch (args.length) { - case 0: - return chomp(); - case 1: - return chomp(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** rb_str_chop - * - */ - @JRubyMethod - public RubyString chomp() { - RubyString str = strDup(getRuntime()); - str.chomp_bang(); - return str; - } - - /** rb_str_chop - * - */ - @JRubyMethod - public RubyString chomp(IRubyObject arg0) { - RubyString str = strDup(getRuntime()); - str.chomp_bang(arg0); - return str; - } - - /** - * Variable-arity version for compatibility. Not bound to Ruby. - * @deprecated Use the zero or one argument versions. - */ - public IRubyObject chomp_bang(IRubyObject[] args) { - switch (args.length) { - case 0: - return chomp_bang(); - case 1: - return chomp_bang(args[0]); - default: - Arity.raiseArgumentError(getRuntime(), args.length, 0, 1); - return null; // not reached - } - } - - /** - * rb_str_chomp_bang - * - * In the common case, removes CR and LF characters in various ways depending on the value of - * the optional args[0]. - * If args.length==0 removes one instance of CR, CRLF or LF from the end of the string. - * If args.length>0 and args[0] is "\n" then same behaviour as args.length==0 . - * If args.length>0 and args[0] is "" then removes trailing multiple LF or CRLF (but no CRs at - * all(!)). - * @param args See method description. - */ - @JRubyMethod(name = "chomp!") - public IRubyObject chomp_bang() { - IRubyObject rsObj; - - int len = value.length(); - if (len == 0) return getRuntime().getNil(); - byte[]buff = value.bytes; - - rsObj = getRuntime().getGlobalVariables().get("$/"); - - if (rsObj == getRuntime().getGlobalVariables().getDefaultSeparator()) { - int realSize = value.realSize; - int begin = value.begin; - if (buff[begin + len - 1] == (byte)'\n') { - realSize--; - if (realSize > 0 && buff[begin + realSize - 1] == (byte)'\r') realSize--; - view(0, realSize); - } else if (buff[begin + len - 1] == (byte)'\r') { - realSize--; - view(0, realSize); - } else { - modifyCheck(); - return getRuntime().getNil(); - } - return this; - } - - return chompBangCommon(rsObj); - } - - /** - * rb_str_chomp_bang - * - * In the common case, removes CR and LF characters in various ways depending on the value of - * the optional args[0]. - * If args.length==0 removes one instance of CR, CRLF or LF from the end of the string. - * If args.length>0 and args[0] is "\n" then same behaviour as args.length==0 . - * If args.length>0 and args[0] is "" then removes trailing multiple LF or CRLF (but no CRs at - * all(!)). - * @param args See method description. - */ - @JRubyMethod(name = "chomp!") - public IRubyObject chomp_bang(IRubyObject arg0) { - return chompBangCommon(arg0); - } - - private IRubyObject chompBangCommon(IRubyObject rsObj) { - - if (rsObj.isNil()) { - return getRuntime().getNil(); - } - RubyString rs = rsObj.convertToString(); - int len = value.realSize; - int begin = value.begin; - if (len == 0) { - return getRuntime().getNil(); - } - byte[] buff = value.bytes; - int rslen = rs.value.realSize; - - if (rslen == 0) { - while (len > 0 && buff[begin + len - 1] == (byte) '\n') { - len--; - if (len > 0 && buff[begin + len - 1] == (byte) '\r') { - len--; - } - } - if (len < value.realSize) { - view(0, len); - return this; - } - return getRuntime().getNil(); - } - - if (rslen > len) { - return getRuntime().getNil(); - } - byte newline = rs.value.bytes[rslen - 1]; - - if (rslen == 1 && newline == (byte) '\n') { - buff = value.bytes; - int realSize = value.realSize; - if (buff[begin + len - 1] == (byte) '\n') { - realSize--; - if (realSize > 0 && buff[begin + realSize - 1] == (byte) '\r') { - realSize--; - } - view(0, realSize); - } else if (buff[begin + len - 1] == (byte) '\r') { - realSize--; - view(0, realSize); - } else { - modifyCheck(); - return getRuntime().getNil(); - } - return this; - } - - if (buff[begin + len - 1] == newline && rslen <= 1 || value.endsWith(rs.value)) { - view(0, value.realSize - rslen); - return this; - } - - return getRuntime().getNil(); - } - - /** rb_str_lstrip - * - */ - @JRubyMethod - public IRubyObject lstrip(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.lstrip_bang(); - return str; - } - - /** rb_str_lstrip_bang - */ - @JRubyMethod(name = "lstrip!") - public IRubyObject lstrip_bang() { - if (value.realSize == 0) return getRuntime().getNil(); - - int i=0; - while (i < value.realSize && ASCII.isSpace(value.bytes[value.begin + i] & 0xff)) i++; - - if (i > 0) { - view(i, value.realSize - i); - return this; - } - - return getRuntime().getNil(); - } - - /** rb_str_rstrip - * - */ - @JRubyMethod - public IRubyObject rstrip(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.rstrip_bang(); - return str; - } - - /** rb_str_rstrip_bang - */ - @JRubyMethod(name = "rstrip!") - public IRubyObject rstrip_bang() { - if (value.realSize == 0) return getRuntime().getNil(); - int i=value.realSize - 1; - - while (i >= 0 && value.bytes[value.begin+i] == 0) i--; - while (i >= 0 && ASCII.isSpace(value.bytes[value.begin + i] & 0xff)) i--; - - if (i < value.realSize - 1) { - view(0, i + 1); - return this; - } - - return getRuntime().getNil(); - } - - /** rb_str_strip - * - */ - @JRubyMethod - public IRubyObject strip(ThreadContext context) { - RubyString str = strDup(context.getRuntime()); - str.strip_bang(); - return str; - } - - /** rb_str_strip_bang - */ - @JRubyMethod(name = "strip!") - public IRubyObject strip_bang() { - IRubyObject l = lstrip_bang(); - IRubyObject r = rstrip_bang(); - - if(l.isNil() && r.isNil()) { - return l; - } - return this; - } - - /** rb_str_count - * - */ - @JRubyMethod(name = "count", required = 1, rest = true) - public IRubyObject count(IRubyObject[] args) { - if (args.length < 1) throw getRuntime().newArgumentError("wrong number of arguments"); - if (value.realSize == 0) return getRuntime().newFixnum(0); - - boolean[]table = new boolean[TRANS_SIZE]; - boolean init = true; - for (int i=0; i<args.length; i++) { - RubyString s = args[i].convertToString(); - s.setup_table(table, init); - init = false; - } - - int s = value.begin; - int send = s + value.realSize; - byte[]buf = value.bytes; - int i = 0; - - while (s < send) if (table[buf[s++] & 0xff]) i++; - - return getRuntime().newFixnum(i); - } - - /** rb_str_delete - * - */ - @JRubyMethod(name = "delete", required = 1, rest = true) - public IRubyObject delete(ThreadContext context, IRubyObject[] args) { - RubyString str = strDup(context.getRuntime()); - str.delete_bang(args); - return str; - } - - /** rb_str_delete_bang - * - */ - @JRubyMethod(name = "delete!", required = 1, rest = true) - public IRubyObject delete_bang(IRubyObject[] args) { - if (args.length < 1) throw getRuntime().newArgumentError("wrong number of arguments"); - - boolean[]squeeze = new boolean[TRANS_SIZE]; - - boolean init = true; - for (int i=0; i<args.length; i++) { - RubyString s = args[i].convertToString(); - s.setup_table(squeeze, init); - init = false; - } - - modify(); - - if (value.realSize == 0) return getRuntime().getNil(); - int s = value.begin; - int t = s; - int send = s + value.realSize; - byte[]buf = value.bytes; - boolean modify = false; - - while (s < send) { - if (squeeze[buf[s] & 0xff]) { - modify = true; - } else { - buf[t++] = buf[s]; - } - s++; - } - value.realSize = t - value.begin; - - if (modify) return this; - return getRuntime().getNil(); - } - - /** rb_str_squeeze - * - */ - @JRubyMethod(name = "squeeze", rest = true) - public IRubyObject squeeze(ThreadContext context, IRubyObject[] args) { - RubyString str = strDup(context.getRuntime()); - str.squeeze_bang(args); - return str; - } - - /** rb_str_squeeze_bang - * - */ - @JRubyMethod(name = "squeeze!", rest = true) - public IRubyObject squeeze_bang(IRubyObject[] args) { - if (value.realSize == 0) { - modifyCheck(); - return getRuntime().getNil(); - } - - final boolean squeeze[] = new boolean[TRANS_SIZE]; - - if (args.length == 0) { - for (int i=0; i<TRANS_SIZE; i++) squeeze[i] = true; - } else { - boolean init = true; - for (int i=0; i<args.length; i++) { - RubyString s = args[i].convertToString(); - s.setup_table(squeeze, init); - init = false; - } - } - - modify(); - - int s = value.begin; - int t = s; - int send = s + value.realSize; - byte[]buf = value.bytes; - int save = -1; - - while (s < send) { - int c = buf[s++] & 0xff; - if (c != save || !squeeze[c]) buf[t++] = (byte)(save = c); - } - - if (t - value.begin != value.realSize) { // modified - value.realSize = t - value.begin; - return this; - } - - return getRuntime().getNil(); - } - - /** rb_str_tr - * - */ - @JRubyMethod - public IRubyObject tr(ThreadContext context, IRubyObject src, IRubyObject repl) { - RubyString str = strDup(context.getRuntime()); - str.tr_trans(src, repl, false); - return str; - } - - /** rb_str_tr_bang - * - */ - @JRubyMethod(name = "tr!") - public IRubyObject tr_bang(IRubyObject src, IRubyObject repl) { - return tr_trans(src, repl, false); - } - - private static final class TR { - int gen, now, max; - int p, pend; - byte[]buf; - } - - private static final int TRANS_SIZE = 256; - - /** tr_setup_table - * - */ - private final void setup_table(boolean[]table, boolean init) { - final boolean[]buf = new boolean[TRANS_SIZE]; - final TR tr = new TR(); - int c; - - boolean cflag = false; - - tr.p = value.begin; - tr.pend = value.begin + value.realSize; - tr.buf = value.bytes; - tr.gen = tr.now = tr.max = 0; - - if (value.realSize > 1 && value.bytes[value.begin] == '^') { - cflag = true; - tr.p++; - } - - if (init) for (int i=0; i<TRANS_SIZE; i++) table[i] = true; - - for (int i=0; i<TRANS_SIZE; i++) buf[i] = cflag; - while ((c = trnext(tr)) >= 0) buf[c & 0xff] = !cflag; - for (int i=0; i<TRANS_SIZE; i++) table[i] = table[i] && buf[i]; - } - - /** tr_trans - * - */ - private final IRubyObject tr_trans(IRubyObject src, IRubyObject repl, boolean sflag) { - if (value.realSize == 0) return getRuntime().getNil(); - - ByteList replList = repl.convertToString().value; - - if (replList.realSize == 0) return delete_bang(new IRubyObject[]{src}); - - ByteList srcList = src.convertToString().value; - - final TR trsrc = new TR(); - final TR trrepl = new TR(); - - boolean cflag = false; - boolean modify = false; - - trsrc.p = srcList.begin; - trsrc.pend = srcList.begin + srcList.realSize; - trsrc.buf = srcList.bytes; - if (srcList.realSize >= 2 && srcList.bytes[srcList.begin] == '^') { - cflag = true; - trsrc.p++; - } - - trrepl.p = replList.begin; - trrepl.pend = replList.begin + replList.realSize; - trrepl.buf = replList.bytes; - - trsrc.gen = trrepl.gen = 0; - trsrc.now = trrepl.now = 0; - trsrc.max = trrepl.max = 0; - - int c; - final int[]trans = new int[TRANS_SIZE]; - if (cflag) { - for (int i=0; i<TRANS_SIZE; i++) trans[i] = 1; - while ((c = trnext(trsrc)) >= 0) trans[c & 0xff] = -1; - while ((c = trnext(trrepl)) >= 0); - for (int i=0; i<TRANS_SIZE; i++) { - if (trans[i] >= 0) trans[i] = trrepl.now; - } - } else { - for (int i=0; i<TRANS_SIZE; i++) trans[i] = -1; - while ((c = trnext(trsrc)) >= 0) { - int r = trnext(trrepl); - if (r == -1) r = trrepl.now; - trans[c & 0xff] = r; - } - } - - modify(); - - int s = value.begin; - int send = s + value.realSize; - byte sbuf[] = value.bytes; - - if (sflag) { - int t = s; - int c0, last = -1; - while (s < send) { - c0 = sbuf[s++]; - if ((c = trans[c0 & 0xff]) >= 0) { - if (last == c) continue; - last = c; - sbuf[t++] = (byte)(c & 0xff); - modify = true; - } else { - last = -1; - sbuf[t++] = (byte)c0; - } - } - - if (value.realSize > (t - value.begin)) { - value.realSize = t - value.begin; - modify = true; - } - } else { - while (s < send) { - if ((c = trans[sbuf[s] & 0xff]) >= 0) { - sbuf[s] = (byte)(c & 0xff); - modify = true; - } - s++; - } - } - - if (modify) return this; - return getRuntime().getNil(); - } - - /** trnext - * - */ - private final int trnext(TR t) { - byte [] buf = t.buf; - - for (;;) { - if (t.gen == 0) { - if (t.p == t.pend) return -1; - if (t.p < t.pend -1 && buf[t.p] == '\\') t.p++; - t.now = buf[t.p++]; - if (t.p < t.pend - 1 && buf[t.p] == '-') { - t.p++; - if (t.p < t.pend) { - if (t.now > ((int)buf[t.p] & 0xFF)) { - t.p++; - continue; - } - t.gen = 1; - t.max = (int)buf[t.p++] & 0xFF; - } - } - return t.now & 0xff; - } else if (++t.now < t.max) { - return t.now & 0xff; - } else { - t.gen = 0; - return t.max & 0xff; - } - } - } - - /** rb_str_tr_s - * - */ - @JRubyMethod - public IRubyObject tr_s(ThreadContext context, IRubyObject src, IRubyObject repl) { - RubyString str = strDup(context.getRuntime()); - str.tr_trans(src, repl, true); - return str; - } - - /** rb_str_tr_s_bang - * - */ - @JRubyMethod(name = "tr_s!") - public IRubyObject tr_s_bang(IRubyObject src, IRubyObject repl) { - return tr_trans(src, repl, true); - } - - /** rb_str_each_line - * - */ - @JRubyMethod(name = {"each_line", "each"}, required = 0, optional = 1, frame = true) - public IRubyObject each_line(ThreadContext context, IRubyObject[] args, Block block) { - byte newline; - int p = value.begin; - int pend = p + value.realSize; - int s; - int ptr = p; - int len = value.realSize; - int rslen; - IRubyObject line; - - - IRubyObject _rsep; - if (args.length == 0) { - _rsep = getRuntime().getGlobalVariables().get("$/"); - } else { - _rsep = args[0]; - } - - if(_rsep.isNil()) { - block.yield(context, this); - return this; - } - - RubyString rsep = stringValue(_rsep); - ByteList rsepValue = rsep.value; - byte[] strBytes = value.bytes; - - rslen = rsepValue.realSize; - - if(rslen == 0) { - newline = '\n'; - } else { - newline = rsepValue.bytes[rsepValue.begin + rslen-1]; - } - - s = p; - p+=rslen; - - for(; p < pend; p++) { - if(rslen == 0 && strBytes[p] == '\n') { - if(strBytes[++p] != '\n') { - continue; - } - while(p < pend && strBytes[p] == '\n') { - p++; - } - } - if(ptr<p && strBytes[p-1] == newline && - (rslen <= 1 || - ByteList.memcmp(rsepValue.bytes, rsepValue.begin, rslen, strBytes, p-rslen, rslen) == 0)) { - line = RubyString.newStringShared(getRuntime(), getMetaClass(), this.value.makeShared(s-ptr, p-s)); - line.infectBy(this); - block.yield(context, line); - modifyCheck(strBytes,len); - s = p; - } - } - - if(s != pend) { - if(p > pend) { - p = pend; - } - line = RubyString.newStringShared(getRuntime(), getMetaClass(), this.value.makeShared(s-ptr, p-s)); - line.infectBy(this); - block.yield(context, line); - } - - return this; - } - - /** - * rb_str_each_byte - */ - @JRubyMethod(name = "each_byte", frame = true) - public RubyString each_byte(ThreadContext context, Block block) { - Ruby runtime = getRuntime(); - // Check the length every iteration, since - // the block can modify this string. - for (int i = 0; i < value.length(); i++) { - block.yield(context, runtime.newFixnum(value.get(i) & 0xFF)); - } - return this; - } - - /** rb_str_intern - * - */ - public RubySymbol intern() { - String s = toString(); - if (s.length() == 0) { - throw getRuntime().newArgumentError("interning empty string"); - } - if (s.indexOf('\0') >= 0) { - throw getRuntime().newArgumentError("symbol string may not contain '\\0'"); - } - return getRuntime().newSymbol(s); - } - - @JRubyMethod(name = {"to_sym", "intern"}) - public RubySymbol to_sym() { - return intern(); - } - - @JRubyMethod(name = "sum", optional = 1) - public RubyInteger sum(IRubyObject[] args) { - if (args.length > 1) { - throw getRuntime().newArgumentError("wrong number of arguments (" + args.length + " for 1)"); - } - - long bitSize = 16; - if (args.length == 1) { - long bitSizeArg = ((RubyInteger) args[0].convertToInteger()).getLongValue(); - if (bitSizeArg > 0) { - bitSize = bitSizeArg; - } - } - - long result = 0; - for (int i = 0; i < value.length(); i++) { - result += value.get(i) & 0xFF; - } - return getRuntime().newFixnum(bitSize == 0 ? result : result % (long) Math.pow(2, bitSize)); - } - - /** string_to_c - * - */ - @JRubyMethod(name = "to_c", reads = BACKREF, writes = BACKREF, compat = CompatVersion.RUBY1_9) - public IRubyObject to_c(ThreadContext context) { - Ruby runtime = context.getRuntime(); - Frame frame = context.getCurrentFrame(); - IRubyObject backref = frame.getBackRef(); - if (backref != null && backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); - - IRubyObject s = RuntimeHelpers.invoke( - context, this, "gsub", - RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), - runtime.newString(new ByteList(new byte[]{'_'}))); - - RubyArray a = RubyComplex.str_to_c_internal(context, s); - - frame.setBackRef(backref); - - if (!a.eltInternal(0).isNil()) { - return a.eltInternal(0); - } else { - return RubyComplex.newComplexCanonicalize(context, RubyFixnum.zero(runtime)); - } - } - - /** string_to_r - * - */ - @JRubyMethod(name = "to_r", reads = BACKREF, writes = BACKREF, compat = CompatVersion.RUBY1_9) - public IRubyObject to_r(ThreadContext context) { - Ruby runtime = context.getRuntime(); - Frame frame = context.getCurrentFrame(); - IRubyObject backref = frame.getBackRef(); - if (backref != null && backref instanceof RubyMatchData) ((RubyMatchData)backref).use(); - - IRubyObject s = RuntimeHelpers.invoke( - context, this, "gsub", - RubyRegexp.newRegexp(runtime, Numeric.ComplexPatterns.underscores_pat), - runtime.newString(new ByteList(new byte[]{'_'}))); - - RubyArray a = RubyRational.str_to_r_internal(context, s); - - frame.setBackRef(backref); - - if (!a.eltInternal(0).isNil()) { - return a.eltInternal(0); - } else { - return RubyRational.newRationalCanonicalize(context, RubyFixnum.zero(runtime)); - } - } - - public static RubyString unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - RubyString result = newString(input.getRuntime(), input.unmarshalString()); - input.registerLinkTarget(result); - return result; - } - - /** - * @see org.jruby.util.Pack#unpack - */ - @JRubyMethod - public RubyArray unpack(IRubyObject obj) { - return Pack.unpack(getRuntime(), this.value, stringValue(obj).value); - } - - public void empty() { - value = ByteList.EMPTY_BYTELIST; - shareLevel = SHARE_LEVEL_BYTELIST; - } - - /** - * Mutator for internal string representation. - * - * @param value The new java.lang.String this RubyString should encapsulate - * @deprecated - */ - public void setValue(CharSequence value) { - view(ByteList.plain(value)); - } - - public void setValue(ByteList value) { - view(value); - } - - public CharSequence getValue() { - return toString(); - } - - public byte[] getBytes() { - return value.bytes(); - } - - public ByteList getByteList() { - return value; - } - - /** used by ar-jdbc - * - */ - public String getUnicodeValue() { - try { - return new String(value.bytes,value.begin,value.realSize, "UTF8"); - } catch (Exception e) { - throw new RuntimeException("Something's seriously broken with encodings", e); - } - } - - @Override - public IRubyObject to_java() { - return MiniJava.javaToRuby(getRuntime(), new String(getBytes())); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * Copyright (C) 2006 Ryan Bell <ryan.l.bell@gmail.com> - * Copyright (C) 2007 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2008 Vladimir Sizikov <vsizikov@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.ArrayList; -import java.util.List; - -import org.jruby.anno.FrameField; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.TypeConverter; -import org.jruby.util.io.InvalidValueException; -import org.jruby.util.io.ModeFlags; -import org.jruby.util.io.Stream; - -@JRubyClass(name="StringIO") -public class RubyStringIO extends RubyObject { - private static ObjectAllocator STRINGIO_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyStringIO(runtime, klass); - } - }; - - public static RubyClass createStringIOClass(final Ruby runtime) { - RubyClass stringIOClass = runtime.defineClass( - "StringIO", runtime.fastGetClass("Data"), STRINGIO_ALLOCATOR); - - stringIOClass.defineAnnotatedMethods(RubyStringIO.class); - stringIOClass.includeModule(runtime.getEnumerable()); - - return stringIOClass; - } - - @JRubyMethod(name = "open", optional = 2, frame = true, meta = true) - public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - RubyStringIO strio = (RubyStringIO)((RubyClass)recv).newInstance(context, args, Block.NULL_BLOCK); - IRubyObject val = strio; - - if (block.isGiven()) { - try { - val = block.yield(context, strio); - } finally { - strio.doFinalize(); - } - } - return val; - } - - protected RubyStringIO(Ruby runtime, RubyClass klass) { - super(runtime, klass); - } - - private long pos = 0L; - private int lineno = 0; - private boolean eof = false; - - /** - * ATTN: the value of internal might be reset to null - * (during StringIO.open with block), so watch out for that. - */ - private RubyString internal; - - // Has read/write been closed or is it still open for business - private boolean closedRead = false; - private boolean closedWrite = false; - - // Support IO modes that this object was opened with - ModeFlags modes; - - private void initializeModes(Object modeArgument) { - try { - if (modeArgument == null) { - modes = new ModeFlags(RubyIO.getIOModesIntFromString(getRuntime(), "r+")); - } else if (modeArgument instanceof Long) { - modes = new ModeFlags(((Long)modeArgument).longValue()); - } else { - modes = new ModeFlags(RubyIO.getIOModesIntFromString(getRuntime(), (String) modeArgument)); - } - } catch (InvalidValueException e) { - throw getRuntime().newErrnoEINVALError(); - } - setupModes(); - } - - @JRubyMethod(name = "initialize", optional = 2, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - Object modeArgument = null; - switch (args.length) { - case 0: - internal = RubyString.newEmptyString(getRuntime()); - modeArgument = "r+"; - break; - case 1: - internal = args[0].convertToString(); - modeArgument = internal.isFrozen() ? "r" : "r+"; - break; - case 2: - internal = args[0].convertToString(); - if (args[1] instanceof RubyFixnum) { - modeArgument = RubyFixnum.fix2long(args[1]); - } else { - modeArgument = args[1].convertToString().toString(); - } - break; - } - - initializeModes(modeArgument); - - if (modes.isWritable() && internal.isFrozen()) { - throw getRuntime().newErrnoEACCESError("Permission denied"); - } - - if (modes.isTruncate()) { - internal.modifyCheck(); - internal.empty(); - } - - return this; - } - - @JRubyMethod(visibility = Visibility.PRIVATE) - public IRubyObject initialize_copy(IRubyObject other) { - - RubyStringIO otherIO = (RubyStringIO) TypeConverter.convertToType( - other, getRuntime().fastGetClass("StringIO"), - MethodIndex.getIndex("to_strio"), "to_strio"); - - if (this == otherIO) { - return this; - } - - pos = otherIO.pos; - lineno = otherIO.lineno; - eof = otherIO.eof; - closedRead = otherIO.closedRead; - closedWrite = otherIO.closedWrite; - internal = otherIO.internal; - modes = otherIO.modes; - if (otherIO.isTaint()) { - setTaint(true); - } - - return this; - } - - @JRubyMethod(name = "<<", required = 1) - public IRubyObject append(ThreadContext context, IRubyObject arg) { - writeInternal(context, arg); - return this; - } - - @JRubyMethod(name = "binmode") - public IRubyObject binmode() { - return this; - } - - @JRubyMethod(name = "close", frame=true) - public IRubyObject close() { - checkInitialized(); - checkOpen(); - - closedRead = true; - closedWrite = true; - - return getRuntime().getNil(); - } - - private void doFinalize() { - closedRead = true; - closedWrite = true; - internal = null; - } - - @JRubyMethod(name = "closed?") - public IRubyObject closed_p() { - checkInitialized(); - return getRuntime().newBoolean(closedRead && closedWrite); - } - - @JRubyMethod(name = "close_read") - public IRubyObject close_read() { - checkReadable(); - closedRead = true; - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "closed_read?") - public IRubyObject closed_read_p() { - checkInitialized(); - return getRuntime().newBoolean(closedRead); - } - - @JRubyMethod(name = "close_write") - public IRubyObject close_write() { - checkWritable(); - closedWrite = true; - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "closed_write?") - public IRubyObject closed_write_p() { - checkInitialized(); - return getRuntime().newBoolean(closedWrite); - } - - @JRubyMethod(name = "each", optional = 1, frame = true, writes = FrameField.LASTLINE) - public IRubyObject each(ThreadContext context, IRubyObject[] args, Block block) { - IRubyObject line = gets(context, args); - - while (!line.isNil()) { - block.yield(context, line); - line = gets(context, args); - } - - return this; - } - - @JRubyMethod(name = "each_byte", frame = true) - public IRubyObject each_byte(ThreadContext context, Block block) { - checkReadable(); - Ruby runtime = context.getRuntime(); - ByteList bytes = internal.getByteList(); - - // Check the length every iteration, since - // the block can modify this string. - while (pos < bytes.length()) { - block.yield(context, runtime.newFixnum(bytes.get((int) pos++) & 0xFF)); - } - return runtime.getNil(); - } - - @JRubyMethod(name = "each_line", optional = 1, frame = true) - public IRubyObject each_line(ThreadContext context, IRubyObject[] args, Block block) { - return each(context, args, block); - } - - @JRubyMethod(name = {"eof", "eof?"}) - public IRubyObject eof() { - return getRuntime().newBoolean(isEOF()); - } - - private boolean isEOF() { - return (pos >= internal.getByteList().length()) || eof; - } - - @JRubyMethod(name = "fcntl") - public IRubyObject fcntl() { - throw getRuntime().newNotImplementedError("fcntl not implemented"); - } - - @JRubyMethod(name = "fileno") - public IRubyObject fileno() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "flush") - public IRubyObject flush() { - return this; - } - - @JRubyMethod(name = "fsync") - public IRubyObject fsync() { - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "getc") - public IRubyObject getc() { - checkReadable(); - if (pos >= internal.getByteList().length()) { - return getRuntime().getNil(); - } - return getRuntime().newFixnum(internal.getByteList().get((int)pos++) & 0xFF); - } - - private IRubyObject internalGets(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - - if (pos < internal.getByteList().realSize && !eof) { - boolean isParagraph = false; - - ByteList sep; - if (args.length > 0) { - if (args[0].isNil()) { - ByteList buf = internal.getByteList().makeShared( - (int)pos, internal.getByteList().realSize - (int)pos); - pos += buf.realSize; - return RubyString.newString(runtime, buf); - } - sep = args[0].convertToString().getByteList(); - if (sep.realSize == 0) { - isParagraph = true; - sep = Stream.PARAGRAPH_SEPARATOR; - } - } else { - sep = ((RubyString)runtime.getGlobalVariables().get("$/")).getByteList(); - } - - ByteList ss = internal.getByteList(); - - if (isParagraph) { - swallowLF(ss); - if (pos == ss.realSize) { - return runtime.getNil(); - } - } - - int ix = ss.indexOf(sep, (int)pos); - - ByteList add; - if (-1 == ix) { - ix = internal.getByteList().realSize; - add = new ByteList(new byte[0], false); - } else { - add = isParagraph? NEWLINE : sep; - } - - ByteList line = internal.getByteList().makeShared((int)pos, ix - (int)pos); - line.unshare(); - line.append(add); - line.invalidate(); - pos = ix + add.realSize; - lineno++; - - return RubyString.newString(runtime,line); - } - return runtime.getNil(); - } - - private void swallowLF(ByteList list) { - while (pos < list.realSize) { - if (list.get((int)pos) == '\n') { - pos++; - } else { - break; - } - } - } - - @JRubyMethod(name = "gets", optional = 1, writes = FrameField.LASTLINE) - public IRubyObject gets(ThreadContext context, IRubyObject[] args) { - checkReadable(); - - IRubyObject result = internalGets(context, args); - context.getCurrentFrame().setLastLine(result); - - return result; - } - - @JRubyMethod(name = {"tty?", "isatty"}) - public IRubyObject isatty() { - return getRuntime().getFalse(); - } - - @JRubyMethod(name = {"length", "size"}) - public IRubyObject length() { - checkFinalized(); - return getRuntime().newFixnum(internal.getByteList().length()); - } - - @JRubyMethod(name = "lineno") - public IRubyObject lineno() { - return getRuntime().newFixnum(lineno); - } - - @JRubyMethod(name = "lineno=", required = 1) - public IRubyObject set_lineno(IRubyObject arg) { - lineno = RubyNumeric.fix2int(arg); - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "path") - public IRubyObject path() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "pid") - public IRubyObject pid() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = {"pos", "tell"}) - public IRubyObject pos() { - return getRuntime().newFixnum(pos); - } - - @JRubyMethod(name = "pos=", required = 1) - public IRubyObject set_pos(IRubyObject arg) { - pos = RubyNumeric.fix2int(arg); - if (pos < 0) { - throw getRuntime().newErrnoEINVALError("Invalid argument"); - } - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "print", rest = true) - public IRubyObject print(ThreadContext context, IRubyObject[] args) { - Ruby runtime = context.getRuntime(); - if (args.length != 0) { - for (int i=0,j=args.length;i<j;i++) { - append(context, args[i]); - } - } else { - IRubyObject arg = runtime.getGlobalVariables().get("$_"); - append(context, arg.isNil() ? runtime.newString("nil") : arg); - } - IRubyObject sep = runtime.getGlobalVariables().get("$\\"); - if (!sep.isNil()) { - append(context, sep); - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "printf", required = 1, rest = true) - public IRubyObject printf(ThreadContext context, IRubyObject[] args) { - append(context, RubyKernel.sprintf(context, this, args)); - return getRuntime().getNil(); - } - - @JRubyMethod(name = "putc", required = 1) - public IRubyObject putc(IRubyObject obj) { - checkWritable(); - byte c = RubyNumeric.num2chr(obj); - checkFrozen(); - - internal.modify(); - ByteList bytes = internal.getByteList(); - if (modes.isAppendable()) { - pos = bytes.length(); - bytes.append(c); - } else { - if (pos >= bytes.length()) { - bytes.length((int)pos + 1); - } - - bytes.set((int) pos, c); - pos++; - } - - return obj; - } - - public static final ByteList NEWLINE = ByteList.create("\n"); - - @JRubyMethod(name = "puts", rest = true) - public IRubyObject puts(ThreadContext context, IRubyObject[] args) { - checkWritable(); - - // FIXME: the code below is a copy of RubyIO.puts, - // and we should avoid copy-paste. - - if (args.length == 0) { - callMethod(context, "write", RubyString.newStringShared(getRuntime(), NEWLINE)); - return getRuntime().getNil(); - } - - for (int i = 0; i < args.length; i++) { - String line; - - if (args[i].isNil()) { - line = "nil"; - } else { - IRubyObject tmp = args[i].checkArrayType(); - if (!tmp.isNil()) { - RubyArray arr = (RubyArray) tmp; - if (getRuntime().isInspecting(arr)) { - line = "[...]"; - } else { - inspectPuts(context, arr); - continue; - } - } else { - line = args[i].toString(); - } - } - - callMethod(context, "write", getRuntime().newString(line)); - - if (!line.endsWith("\n")) { - callMethod(context, "write", RubyString.newStringShared(getRuntime(), NEWLINE)); - } - } - return getRuntime().getNil(); - } - - private IRubyObject inspectPuts(ThreadContext context, RubyArray array) { - try { - getRuntime().registerInspecting(array); - return puts(context, array.toJavaArray()); - } finally { - getRuntime().unregisterInspecting(array); - } - } - - @SuppressWarnings("fallthrough") - @JRubyMethod(name = "read", optional = 2) - public IRubyObject read(IRubyObject[] args) { - checkReadable(); - - ByteList buf = null; - int length = 0; - int oldLength = 0; - RubyString originalString = null; - - switch (args.length) { - case 2: - originalString = args[1].convertToString(); - // must let original string know we're modifying, so shared buffers aren't damaged - originalString.modify(); - buf = originalString.getByteList(); - case 1: - if (!args[0].isNil()) { - length = RubyNumeric.fix2int(args[0]); - oldLength = length; - - if (length < 0) { - throw getRuntime().newArgumentError("negative length " + length + " given"); - } - if (length > 0 && pos >= internal.getByteList().length()) { - eof = true; - if (buf != null) buf.realSize = 0; - return getRuntime().getNil(); - } else if (eof) { - if (buf != null) buf.realSize = 0; - return getRuntime().getNil(); - } - break; - } - case 0: - oldLength = -1; - length = internal.getByteList().length(); - - if (length <= pos) { - eof = true; - if (buf == null) { - buf = new ByteList(); - } else { - buf.realSize = 0; - } - - return getRuntime().newString(buf); - } else { - length -= pos; - } - break; - default: - getRuntime().newArgumentError(args.length, 0); - } - - if (buf == null) { - int internalLength = internal.getByteList().length(); - - if (internalLength > 0) { - if (internalLength >= pos + length) { - buf = new ByteList(internal.getByteList(), (int) pos, length); - } else { - int rest = (int) (internal.getByteList().length() - pos); - - if (length > rest) length = rest; - buf = new ByteList(internal.getByteList(), (int) pos, length); - } - } - } else { - int rest = (int) (internal.getByteList().length() - pos); - - if (length > rest) length = rest; - - // Yow...this is ugly - buf.realSize = length; - buf.replace(0, length, internal.getByteList().bytes, (int) pos, length); - } - - if (buf == null) { - if (!eof) buf = new ByteList(); - length = 0; - } else { - length = buf.length(); - pos += length; - } - - if (oldLength < 0 || oldLength > length) eof = true; - - return originalString != null ? originalString : getRuntime().newString(buf); - } - - @JRubyMethod(name = "readchar") - public IRubyObject readchar() { - IRubyObject c = getc(); - - if (c.isNil()) throw getRuntime().newEOFError(); - - return c; - } - - @JRubyMethod(name = "readline", optional = 1, writes = FrameField.LASTLINE) - public IRubyObject readline(ThreadContext context, IRubyObject[] args) { - IRubyObject line = gets(context, args); - - if (line.isNil()) throw getRuntime().newEOFError(); - - return line; - } - - @JRubyMethod(name = "readlines", optional = 1) - public IRubyObject readlines(ThreadContext context, IRubyObject[] arg) { - checkReadable(); - - List<IRubyObject> lns = new ArrayList<IRubyObject>(); - while (!(isEOF())) { - IRubyObject line = internalGets(context, arg); - if (line.isNil()) { - break; - } - lns.add(line); - } - - return getRuntime().newArray(lns); - } - - @JRubyMethod(name = "reopen", required = 0, optional = 2) - public IRubyObject reopen(IRubyObject[] args) { - if (args.length == 1 && !(args[0] instanceof RubyString)) { - return initialize_copy(args[0]); - } - - // reset the state - doRewind(); - closedRead = false; - closedWrite = false; - return initialize(args, Block.NULL_BLOCK); - } - - @JRubyMethod(name = "rewind") - public IRubyObject rewind() { - doRewind(); - return RubyFixnum.zero(getRuntime()); - } - - private void doRewind() { - this.pos = 0L; - this.eof = false; - this.lineno = 0; - } - - @JRubyMethod(name = "seek", required = 1, optional = 1, frame=true) - public IRubyObject seek(IRubyObject[] args) { - // MRI 1.8.7 behavior: - // checkOpen(); - checkFinalized(); - long amount = RubyNumeric.num2long(args[0]); - int whence = Stream.SEEK_SET; - long newPosition = pos; - - if (args.length > 1 && !args[0].isNil()) whence = RubyNumeric.fix2int(args[1]); - - if (whence == Stream.SEEK_CUR) { - newPosition += amount; - } else if (whence == Stream.SEEK_END) { - newPosition = internal.getByteList().length() + amount; - } else { - newPosition = amount; - } - - if (newPosition < 0) throw getRuntime().newErrnoEINVALError(); - - pos = newPosition; - eof = false; - - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "string=", required = 1) - public IRubyObject set_string(IRubyObject arg) { - return reopen(new IRubyObject[] { arg.convertToString() }); - } - - @JRubyMethod(name = "sync=", required = 1) - public IRubyObject set_sync(IRubyObject args) { - return args; - } - - @JRubyMethod(name = "string") - public IRubyObject string() { - if (internal == null) { - return getRuntime().getNil(); - } else { - return internal; - } - } - - @JRubyMethod(name = "sync") - public IRubyObject sync() { - return getRuntime().getTrue(); - } - - @JRubyMethod(name = "sysread", optional = 2) - public IRubyObject sysread(IRubyObject[] args) { - IRubyObject obj = read(args); - - if (isEOF()) { - if (obj.isNil() || ((RubyString) obj).getByteList().length() == 0) { - throw getRuntime().newEOFError(); - } - } - - return obj; - } - - @JRubyMethod(name = "truncate", required = 1) - public IRubyObject truncate(IRubyObject arg) { - checkWritable(); - - int len = RubyFixnum.fix2int(arg); - if (len < 0) { - throw getRuntime().newErrnoEINVALError("negative legnth"); - } - - internal.modify(); - internal.getByteList().length(len); - return arg; - } - - @JRubyMethod(name = "ungetc", required = 1) - public IRubyObject ungetc(IRubyObject arg) { - checkReadable(); - - int c = RubyNumeric.num2int(arg); - if (pos == 0) return getRuntime().getNil(); - internal.modify(); - pos--; - - ByteList bytes = internal.getByteList(); - - if (bytes.length() <= pos) { - bytes.length((int)pos + 1); - } - - bytes.set((int) pos, c); - return getRuntime().getNil(); - } - - @JRubyMethod(name = {"write", "syswrite"}, required = 1) - public IRubyObject write(ThreadContext context, IRubyObject arg) { - return context.getRuntime().newFixnum(writeInternal(context, arg)); - } - - private int writeInternal(ThreadContext context, IRubyObject arg) { - checkWritable(); - checkFrozen(); - - RubyString val = arg.asString(); - internal.modify(); - - if (modes.isAppendable()) { - internal.getByteList().append(val.getByteList()); - pos = internal.getByteList().length(); - } else { - int left = internal.getByteList().length()-(int)pos; - internal.getByteList().replace((int)pos,Math.min(val.getByteList().length(),left),val.getByteList()); - pos += val.getByteList().length(); - } - - if (val.isTaint()) { - internal.setTaint(true); - } - - return val.getByteList().length(); - } - - /* rb: check_modifiable */ - @Override - protected void checkFrozen() { - checkInitialized(); - if (internal.isFrozen()) throw getRuntime().newIOError("not modifiable string"); - } - - /* rb: readable */ - private void checkReadable() { - checkInitialized(); - if (closedRead || !modes.isReadable()) { - throw getRuntime().newIOError("not opened for reading"); - } - } - - /* rb: writable */ - private void checkWritable() { - checkInitialized(); - if (closedWrite || !modes.isWritable()) { - throw getRuntime().newIOError("not opened for writing"); - } - - // Tainting here if we ever want it. (secure 4) - } - - private void checkInitialized() { - if (modes == null) { - throw getRuntime().newIOError("uninitialized stream"); - } - } - - private void checkFinalized() { - if (internal == null) { - throw getRuntime().newIOError("not opened"); - } - } - - private void checkOpen() { - if (closedRead && closedWrite) { - throw getRuntime().newIOError("closed stream"); - } - } - - private void setupModes() { - closedWrite = false; - closedRead = false; - - if (modes.isReadOnly()) closedWrite = true; - if (!modes.isReadable()) closedRead = true; - } -} -package org.jruby; - -import org.joni.Matcher; -import org.joni.Option; -import org.joni.Regex; -import org.joni.Region; -import org.joni.encoding.Encoding; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.exceptions.RaiseException; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; - -/** - * @author kscott - * - */ -@JRubyClass(name="StringScanner") -public class RubyStringScanner extends RubyObject { - - private RubyString str; - private int pos = 0; - private int lastPos = -1; - - private Region regs; - private int beg = -1; - private int end = -1; - // not to be confused with RubyObject's flags - private int scannerFlags; - - private static final int MATCHED_STR_SCN_F = 1 << 11; - - private static ObjectAllocator STRINGSCANNER_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyStringScanner(runtime, klass); - } - }; - - public static RubyClass createScannerClass(final Ruby runtime) { - RubyClass scannerClass = runtime.defineClass("StringScanner", runtime.getObject(), STRINGSCANNER_ALLOCATOR); - scannerClass.defineAnnotatedMethods(RubyStringScanner.class); - ThreadContext context = runtime.getCurrentContext(); - scannerClass.setConstant("Version", runtime.newString("0.7.0").freeze(context)); - scannerClass.setConstant("Id", runtime.newString("$Id: strscan.c 13506 2007-09-24 08:56:24Z nobu $").freeze(context)); - - RubyClass standardError = runtime.getStandardError(); - RubyClass error = scannerClass.defineClassUnder( - "Error", standardError, standardError.getAllocator()); - - RubyClass objClass = runtime.getObject(); - if (!objClass.isConstantDefined("ScanError")) { - objClass.defineConstant("ScanError", error); - } - - return scannerClass; - } - - private void clearMatched() { - scannerFlags &= ~MATCHED_STR_SCN_F; - } - - private void setMatched() { - scannerFlags |= MATCHED_STR_SCN_F; - } - - private boolean isMatched() { - return (scannerFlags & MATCHED_STR_SCN_F) != 0; - } - - private void check() { - if (str == null) throw getRuntime().newArgumentError("uninitialized StringScanner object"); - } - - protected RubyStringScanner(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - // second argument is allowed, but ignored (MRI) - @JRubyMethod(name = "initialize", required = 1, optional = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - str = args[0].convertToString(); - return this; - } - - @JRubyMethod(name = "initialize_copy", frame=true, visibility = Visibility.PRIVATE) - @Override - public IRubyObject initialize_copy(IRubyObject other) { - if (this == other) return this; - if (!(other instanceof RubyStringScanner)) { - throw getRuntime().newTypeError("wrong argument type " - + other.getMetaClass() + " (expected StringScanner)"); - } - - RubyStringScanner otherScanner = (RubyStringScanner)other; - str = otherScanner.str; - pos = otherScanner.pos; - lastPos = otherScanner.lastPos; - scannerFlags = otherScanner.scannerFlags; - - regs = otherScanner.regs != null ? otherScanner.regs.clone() : null; - beg = otherScanner.beg; - end = otherScanner.end; - - return this; - } - - @JRubyMethod(name = "reset") - public IRubyObject reset() { - check(); - pos = 0; - clearMatched(); - return this; - } - - @JRubyMethod(name = "terminate") - public IRubyObject terminate() { - check(); - pos = str.getByteList().realSize; - clearMatched(); - return this; - } - - @JRubyMethod(name = "clear") - public IRubyObject clear() { - check(); - getRuntime().getWarnings().warning(ID.DEPRECATED_METHOD, "StringScanner#clear is obsolete; use #terminate instead", "StringScanner#clear", "#terminate"); - return terminate(); - } - - @JRubyMethod(name = "string") - public RubyString string() { - return str; - } - - @JRubyMethod(name = "string=", required = 1) - public IRubyObject set_string(ThreadContext context, IRubyObject str) { - this.str = (RubyString) str.convertToString().strDup(context.getRuntime()).freeze(context); - pos = 0; - clearMatched(); - return str; - } - - @JRubyMethod(name = {"concat", "<<"}, required = 1) - public IRubyObject concat(IRubyObject obj) { - check(); - str.append(obj); // append will call convertToString() - return this; - } - - @JRubyMethod(name = {"pos", "pointer"}) - public RubyFixnum pos() { - check(); - return RubyFixnum.newFixnum(getRuntime(), pos); - } - - @JRubyMethod(name = {"pos=", "pointer="}) - public IRubyObject set_pos(IRubyObject pos) { - check(); - int i = RubyNumeric.num2int(pos); - int size = str.getByteList().realSize; - if (i < 0) i += size; - if (i < 0 || i > size) throw getRuntime().newRangeError("index out of range."); - this.pos = i; - return RubyFixnum.newFixnum(getRuntime(), i); - } - - private IRubyObject extractRange(Ruby runtime, int beg, int end) { - int size = str.getByteList().realSize; - if (beg > size) return getRuntime().getNil(); - if (end > size) end = size; - return str.makeShared(runtime, beg, end - beg); - } - - private IRubyObject extractBegLen(Ruby runtime, int beg, int len) { - assert len >= 0; - int size = str.getByteList().realSize; - if (beg > size) return getRuntime().getNil(); - if (beg + len > size) len = size - beg; - return str.makeShared(runtime, beg, len); - } - - private IRubyObject scan(IRubyObject regex, boolean succptr, boolean getstr, boolean headonly) { - if (!(regex instanceof RubyRegexp)) throw getRuntime().newTypeError("wrong argument type " + regex.getMetaClass() + " (expected Regexp)"); - check(); - - Regex pattern = ((RubyRegexp)regex).getPattern(); - - clearMatched(); - int rest = str.getByteList().realSize - pos; - if (rest < 0) return getRuntime().getNil(); - - ByteList value = str.getByteList(); - Matcher matcher = pattern.matcher(value.bytes, value.begin + pos, value.begin + value.realSize); - - final int ret; - if (headonly) { - ret = matcher.match(value.begin + pos, value.begin + value.realSize, Option.NONE); - } else { - ret = matcher.search(value.begin + pos, value.begin + value.realSize, Option.NONE); - } - - regs = matcher.getRegion(); - if (regs == null) { - beg = matcher.getBegin(); - end = matcher.getEnd(); - } else { - beg = regs.beg[0]; - end = regs.end[0]; - } - - if (ret < 0) return getRuntime().getNil(); - setMatched(); - - lastPos = pos; - if (succptr) pos += end; - return getstr ? extractBegLen(getRuntime(), lastPos, end) : RubyFixnum.newFixnum(getRuntime(), end); - } - - @JRubyMethod(name = "scan", required = 1) - public IRubyObject scan(IRubyObject regex) { - return scan(regex, true, true, true); - } - - @JRubyMethod(name = "match?", required = 1) - public IRubyObject match_p(IRubyObject regex) { - return scan(regex, false, false, true); - } - - @JRubyMethod(name = "skip", required = 1) - public IRubyObject skip(IRubyObject regex) { - return scan(regex, true, false, true); - } - - @JRubyMethod(name = "check", required = 1) - public IRubyObject check(IRubyObject regex) { - return scan(regex, false, true, true); - } - - @JRubyMethod(name = "scan_full", required = 3) - public IRubyObject scan_full(IRubyObject regex, IRubyObject s, IRubyObject f) { - return scan(regex, s.isTrue(), f.isTrue(), true); - } - - @JRubyMethod(name = "scan_until", required = 1) - public IRubyObject scan_until(IRubyObject regex) { - return scan(regex, true, true, false); - } - - @JRubyMethod(name = "exist?", required = 1) - public IRubyObject exist_p(IRubyObject regex) { - return scan(regex, false, false, false); - } - - @JRubyMethod(name = "skip_until", required = 1) - public IRubyObject skip_until(IRubyObject regex) { - return scan(regex, true, false, false); - } - - @JRubyMethod(name = "check_until", required = 1) - public IRubyObject check_until(IRubyObject regex) { - return scan(regex, false, true, false); - } - - @JRubyMethod(name = "search_full", required = 3) - public IRubyObject search_full(IRubyObject regex, IRubyObject s, IRubyObject f) { - return scan(regex, s.isTrue(), f.isTrue(), false); - } - - private void adjustRegisters() { - beg = 0; - end = pos - lastPos; - regs = null; - } - - @JRubyMethod(name = "getch") - public IRubyObject getch(ThreadContext context) { - check(); - clearMatched(); - - Ruby runtime = context.getRuntime(); - ByteList value = str.getByteList(); - - if (pos >= value.realSize) return runtime.getNil(); - - Encoding enc = runtime.getKCode().getEncoding(); - - int len; - if (enc.isSingleByte()) { - len = 1; - } else { - len = enc.length(value.bytes[value.begin + pos]); - } - - if (pos + len > value.realSize) len = value.realSize - pos; - lastPos = pos; - pos += len; - - setMatched(); - adjustRegisters(); - - return extractRange(runtime, lastPos + beg, lastPos + end); - } - - @JRubyMethod(name = "get_byte") - public IRubyObject get_byte(ThreadContext context) { - check(); - clearMatched(); - if (pos >= str.getByteList().realSize) return getRuntime().getNil(); - - lastPos = pos; - pos++; - - setMatched(); - adjustRegisters(); - - return extractRange(context.getRuntime(), lastPos + beg, lastPos + end); - } - - @JRubyMethod(name = "getbyte") - public IRubyObject getbyte(ThreadContext context) { - context.getRuntime().getWarnings().warning(ID.DEPRECATED_METHOD, - "StringScanner#getbyte is obsolete; use #get_byte instead", - "StringScanner#getbyte", "#get_byte"); - return get_byte(context); - } - - @JRubyMethod(name = "peek", required = 1) - public IRubyObject peek(ThreadContext context, IRubyObject length) { - check(); - - int len = RubyNumeric.num2int(length); - if (len < 0) { - throw context.getRuntime().newArgumentError("negative string size (or size too big)"); - } - - ByteList value = str.getByteList(); - if (pos >= value.realSize) return RubyString.newEmptyString(getRuntime()).infectBy(str); - if (pos + len > value.realSize) len = value.realSize - pos; - - return extractBegLen(context.getRuntime(), pos, len); - } - - @JRubyMethod(name = "peep", required = 1) - public IRubyObject peep(ThreadContext context, IRubyObject length) { - getRuntime().getWarnings().warning( - ID.DEPRECATED_METHOD, "StringScanner#peep is obsolete; use #peek instead", - "StringScanner#peep", "#peek"); - return peek(context, length); - } - - @JRubyMethod(name = "unscan") - public IRubyObject unscan() { - check(); - Ruby runtime = getRuntime(); - - if (!isMatched()) { - RubyClass errorClass = runtime.fastGetClass("StringScanner").fastGetClass("Error"); - throw new RaiseException(RubyException.newException( - runtime, errorClass, "unscan failed: previous match had failed")); - } - pos = lastPos; - clearMatched(); - return this; - } - - @JRubyMethod(name = "beginning_of_line?", alias = "bol?") - public IRubyObject bol_p() { - check(); - ByteList value = str.getByteList(); - if (pos > value.realSize) return getRuntime().getNil(); - if (pos == 0) return getRuntime().getTrue(); - return value.bytes[(value.begin + pos) - 1] == (byte)'\n' ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "eos?") - public RubyBoolean eos_p(ThreadContext context) { - check(); - return pos >= str.getByteList().realSize ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - @JRubyMethod(name = "empty?") - public RubyBoolean empty_p(ThreadContext context) { - getRuntime().getWarnings().warning(ID.DEPRECATED_METHOD, "StringScanner#empty? is obsolete; use #eos? instead", "StringScanner#empty?", "#eos?"); - return eos_p(context); - } - - @JRubyMethod(name = "rest?") - public RubyBoolean rest_p(ThreadContext context) { - check(); - return pos >= str.getByteList().realSize ? context.getRuntime().getFalse() : context.getRuntime().getTrue(); - } - - @JRubyMethod(name = "matched?") - public RubyBoolean matched_p(ThreadContext context) { - check(); - return isMatched() ? context.getRuntime().getTrue() : context.getRuntime().getFalse(); - } - - @JRubyMethod(name = "matched") - public IRubyObject matched(ThreadContext context) { - check(); - if (!isMatched()) return getRuntime().getNil(); - return extractRange(context.getRuntime(), lastPos + beg, lastPos + end); - } - - @JRubyMethod(name = "matched_size") - public IRubyObject matched_size() { - check(); - if (!isMatched()) return getRuntime().getNil(); - return RubyFixnum.newFixnum(getRuntime(), end - beg); - } - - @JRubyMethod(name = "matchedsize") - public IRubyObject matchedsize() { - getRuntime().getWarnings().warning(ID.DEPRECATED_METHOD, "StringScanner#matchedsize is obsolete; use #matched_size instead", - "StringScanner#matchedize", "#matched_size"); - return matched_size(); - } - - @JRubyMethod(name = "[]", required = 1) - public IRubyObject op_aref(ThreadContext context, IRubyObject idx) { - check(); - if (!isMatched()) return context.getRuntime().getNil(); - int i = RubyNumeric.num2int(idx); - - int numRegs = regs == null ? 1 : regs.numRegs; - if (i < 0) i += numRegs; - if (i < 0 || i >= numRegs) return context.getRuntime().getNil(); - - if (regs == null) { - assert i == 0; - if (beg == -1) return getRuntime().getNil(); - return extractRange(context.getRuntime(), lastPos + beg, lastPos + end); - } else { - if (regs.beg[i] == -1) return getRuntime().getNil(); - return extractRange(context.getRuntime(), lastPos + regs.beg[i], lastPos + regs.end[i]); - } - } - - @JRubyMethod(name = "pre_match") - public IRubyObject pre_match(ThreadContext context) { - check(); - if (!isMatched()) return context.getRuntime().getNil(); - return extractRange(context.getRuntime(), 0, lastPos + beg); - } - - @JRubyMethod(name = "post_match") - public IRubyObject post_match(ThreadContext context) { - check(); - if (!isMatched()) return context.getRuntime().getNil(); - return extractRange(context.getRuntime(), lastPos + end, str.getByteList().realSize); - } - - @JRubyMethod(name = "rest") - public IRubyObject rest(ThreadContext context) { - check(); - ByteList value = str.getByteList(); - if (pos >= value.realSize) return RubyString.newEmptyString(context.getRuntime()).infectBy(str); - return extractRange(context.getRuntime(), pos, value.realSize); - } - - @JRubyMethod(name = "rest_size") - public RubyFixnum rest_size() { - check(); - ByteList value = str.getByteList(); - if (pos >= value.realSize) return RubyFixnum.zero(getRuntime()); - return RubyFixnum.newFixnum(getRuntime(), value.realSize - pos); - } - - @JRubyMethod(name = "restsize") - public RubyFixnum restsize() { - getRuntime().getWarnings().warning(ID.DEPRECATED_METHOD, "StringScanner#restsize is obsolete; use #rest_size instead", "StringScanner#restsize", "#rest_size"); - return rest_size(); - } - - @JRubyMethod(name = "inspect") - @Override - public IRubyObject inspect() { - if (str == null) return inspect("(uninitialized)"); - if (pos >= str.getByteList().realSize) return inspect("fin"); - if (pos == 0) return inspect(pos + "/" + str.getByteList().realSize + " @ " + inspect2()); - return inspect(pos + "/" + str.getByteList().realSize + " " + inspect1() + " @ " + inspect2()); - } - - private IRubyObject inspect(String msg) { - IRubyObject result = getRuntime().newString("#<" + getMetaClass() + " " + msg + ">"); - if (str != null) result.infectBy(str); - return result; - } - - private static final int INSPECT_LENGTH = 5; - - private IRubyObject inspect1() { - if (pos == 0) return RubyString.newEmptyString(getRuntime()); - if (pos > INSPECT_LENGTH) { - return RubyString.newString(getRuntime(), "...".getBytes()).append(str.substr(pos - INSPECT_LENGTH, INSPECT_LENGTH)).inspect(); - } else { - return str.substr(0, pos).inspect(); - } - } - - private IRubyObject inspect2() { - if (pos >= str.getByteList().realSize) return RubyString.newEmptyString(getRuntime()); - int len = str.getByteList().realSize - pos; - if (len > INSPECT_LENGTH) { - return ((RubyString)str.substr(pos, INSPECT_LENGTH)).cat("...".getBytes()).inspect(); - } else { - return str.substr(pos, len).inspect(); - } - } - - @JRubyMethod(name = "must_C_version", meta = true) - public static IRubyObject mustCversion(IRubyObject recv) { - return recv; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2005 Charles O Nutter <headius@headius.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.List; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.Frame; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; -import org.jruby.util.IdUtil; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.exceptions.RaiseException; -import org.jruby.internal.runtime.methods.CallConfiguration; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.ClassIndex; - -/** - * @author jpetersen - */ -@JRubyClass(name="Struct") -public class RubyStruct extends RubyObject { - private IRubyObject[] values; - - /** - * Constructor for RubyStruct. - * @param runtime - * @param rubyClass - */ - public RubyStruct(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass); - - int size = RubyNumeric.fix2int(getInternalVariable((RubyClass)rubyClass, "__size__")); - - values = new IRubyObject[size]; - - for (int i = 0; i < size; i++) { - values[i] = getRuntime().getNil(); - } - } - - public static RubyClass createStructClass(Ruby runtime) { - // TODO: NOT_ALLOCATABLE_ALLOCATOR may be ok here, but it's unclear how Structs - // work with marshalling. Confirm behavior and ensure we're doing this correctly. JRUBY-415 - RubyClass structClass = runtime.defineClass("Struct", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setStructClass(structClass); - structClass.index = ClassIndex.STRUCT; - structClass.includeModule(runtime.getEnumerable()); - structClass.defineAnnotatedMethods(RubyStruct.class); - - return structClass; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.STRUCT; - } - - private static IRubyObject getInternalVariable(RubyClass type, String internedName) { - RubyClass structClass = type.getRuntime().getStructClass(); - IRubyObject variable; - - while (type != null && type != structClass) { - if ((variable = type.fastGetInternalVariable(internedName)) != null) { - return variable; - } - - type = type.getSuperClass(); - } - - return type.getRuntime().getNil(); - } - - private RubyClass classOf() { - return getMetaClass() instanceof MetaClass ? getMetaClass().getSuperClass() : getMetaClass(); - } - - private void modify() { - testFrozen("Struct is frozen"); - - if (!isTaint() && getRuntime().getSafeLevel() >= 4) { - throw getRuntime().newSecurityError("Insecure: can't modify struct"); - } - } - - @JRubyMethod - public RubyFixnum hash(ThreadContext context) { - Ruby runtime = getRuntime(); - int h = getMetaClass().getRealClass().hashCode(); - - for (int i = 0; i < values.length; i++) { - h = (h << 1) | (h < 0 ? 1 : 0); - h ^= RubyNumeric.num2long(values[i].callMethod(context, MethodIndex.HASH, "hash")); - } - - return runtime.newFixnum(h); - } - - private IRubyObject setByName(String name, IRubyObject value) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - modify(); - - for (int i = 0,k=member.getLength(); i < k; i++) { - if (member.eltInternal(i).asJavaString().equals(name)) { - return values[i] = value; - } - } - - throw notStructMemberError(name); - } - - private IRubyObject getByName(String name) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - for (int i = 0,k=member.getLength(); i < k; i++) { - if (member.eltInternal(i).asJavaString().equals(name)) { - return values[i]; - } - } - - throw notStructMemberError(name); - } - - // Struct methods - - /** Create new Struct class. - * - * MRI: rb_struct_s_def / make_struct - * - */ - @JRubyMethod(name = "new", required = 1, rest = true, frame = true, meta = true) - public static RubyClass newInstance(IRubyObject recv, IRubyObject[] args, Block block) { - String name = null; - boolean nilName = false; - Ruby runtime = recv.getRuntime(); - - if (args.length > 0) { - IRubyObject firstArgAsString = args[0].checkStringType(); - if (!firstArgAsString.isNil()) { - name = ((RubyString)firstArgAsString).getByteList().toString(); - } else if (args[0].isNil()) { - nilName = true; - } - } - - RubyArray member = runtime.newArray(); - - for (int i = (name == null && !nilName) ? 0 : 1; i < args.length; i++) { - member.append(runtime.newSymbol(args[i].asJavaString())); - } - - RubyClass newStruct; - RubyClass superClass = (RubyClass)recv; - - if (name == null || nilName) { - newStruct = RubyClass.newClass(runtime, superClass); - newStruct.setAllocator(STRUCT_INSTANCE_ALLOCATOR); - newStruct.makeMetaClass(superClass.getMetaClass()); - newStruct.inherit(superClass); - } else { - if (!IdUtil.isConstant(name)) { - throw runtime.newNameError("identifier " + name + " needs to be constant", name); - } - - IRubyObject type = superClass.getConstantAt(name); - if (type != null) { - ThreadContext context = runtime.getCurrentContext(); - Frame frame = context.getCurrentFrame(); - runtime.getWarnings().warn(ID.STRUCT_CONSTANT_REDEFINED, frame.getFile(), frame.getLine(), "redefining constant Struct::" + name, name); - superClass.remove_const(context, runtime.newString(name)); - } - newStruct = superClass.defineClassUnder(name, superClass, STRUCT_INSTANCE_ALLOCATOR); - } - - newStruct.index = ClassIndex.STRUCT; - - newStruct.fastSetInternalVariable("__size__", member.length()); - newStruct.fastSetInternalVariable("__member__", member); - - newStruct.getSingletonClass().defineAnnotatedMethods(StructMethods.class); - - // define access methods. - for (int i = (name == null && !nilName) ? 0 : 1; i < args.length; i++) { - final String memberName = args[i].asJavaString(); - // if we are storing a name as well, index is one too high for values - final int index = (name == null && !nilName) ? i : i - 1; - newStruct.addMethod(memberName, new DynamicMethod(newStruct, Visibility.PUBLIC, CallConfiguration.NO_FRAME_NO_SCOPE) { - @Override - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { - Arity.checkArgumentCount(self.getRuntime(), args, 0, 0); - return ((RubyStruct)self).get(index); - } - - @Override - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { - return ((RubyStruct)self).get(index); - } - - @Override - public DynamicMethod dup() { - return this; - } - }); - newStruct.addMethod(memberName + "=", new DynamicMethod(newStruct, Visibility.PUBLIC, CallConfiguration.NO_FRAME_NO_SCOPE) { - @Override - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject[] args, Block block) { - Arity.checkArgumentCount(self.getRuntime(), args, 1, 1); - return ((RubyStruct)self).set(args[0], index); - } - - @Override - public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg) { - return ((RubyStruct)self).set(arg, index); - } - - @Override - public DynamicMethod dup() { - return this; - } - }); - } - - if (block.isGiven()) { - // Struct bodies should be public by default, so set block visibility to public. JRUBY-1185. - block.getBinding().setVisibility(Visibility.PUBLIC); - block.yield(runtime.getCurrentContext(), null, newStruct, newStruct, false); - } - - return newStruct; - } - - // For binding purposes on the newly created struct types - public static class StructMethods { - @JRubyMethod(name = {"new", "[]"}, rest = true, frame = true) - public static IRubyObject newStruct(IRubyObject recv, IRubyObject[] args, Block block) { - return RubyStruct.newStruct(recv, args, block); - } - - @JRubyMethod - public static IRubyObject members(IRubyObject recv, Block block) { - return RubyStruct.members(recv, block); - } - } - - /** Create new Structure. - * - * MRI: struct_alloc - * - */ - public static RubyStruct newStruct(IRubyObject recv, IRubyObject[] args, Block block) { - RubyStruct struct = new RubyStruct(recv.getRuntime(), (RubyClass) recv); - - struct.callInit(args, block); - - return struct; - } - - @JRubyMethod(rest = true, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block unusedBlock) { - modify(); - - int size = RubyNumeric.fix2int(getInternalVariable(getMetaClass(), "__size__")); - - if (args.length > size) { - throw getRuntime().newArgumentError("struct size differs (" + args.length +" for " + size + ")"); - } - - for (int i = 0; i < args.length; i++) { - values[i] = args[i]; - } - - return getRuntime().getNil(); - } - - public static RubyArray members(IRubyObject recv, Block block) { - RubyArray member = (RubyArray) getInternalVariable((RubyClass) recv, "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - RubyArray result = recv.getRuntime().newArray(member.getLength()); - for (int i = 0,k=member.getLength(); i < k; i++) { - result.append(recv.getRuntime().newString(member.eltInternal(i).asJavaString())); - } - - return result; - } - - @JRubyMethod - public RubyArray members() { - return members(classOf(), Block.NULL_BLOCK); - } - - @JRubyMethod - public RubyArray select(ThreadContext context, Block block) { - RubyArray array = RubyArray.newArray(context.getRuntime()); - - for (int i = 0; i < values.length; i++) { - if (block.yield(context, values[i]).isTrue()) { - array.append(values[i]); - } - } - - return array; - } - - public IRubyObject set(IRubyObject value, int index) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - modify(); - - return values[index] = value; - } - - private RaiseException notStructMemberError(String name) { - return getRuntime().newNameError(name + " is not struct member", name); - } - - public IRubyObject get(int index) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - return values[index]; - } - - @Override - public void copySpecialInstanceVariables(IRubyObject clone) { - RubyStruct struct = (RubyStruct)clone; - struct.values = new IRubyObject[values.length]; - System.arraycopy(values, 0, struct.values, 0, values.length); - } - - @JRubyMethod(name = "==", required = 1) - public IRubyObject op_equal(ThreadContext context, IRubyObject other) { - if (this == other) return getRuntime().getTrue(); - if (!(other instanceof RubyStruct)) return getRuntime().getFalse(); - if (getMetaClass().getRealClass() != other.getMetaClass().getRealClass()) return getRuntime().getFalse(); - - Ruby runtime = getRuntime(); - RubyStruct otherStruct = (RubyStruct)other; - for (int i = 0; i < values.length; i++) { - if (!equalInternal(context, values[i], otherStruct.values[i])) return runtime.getFalse(); - } - return runtime.getTrue(); - } - - @JRubyMethod(name = "eql?", required = 1) - public IRubyObject eql_p(ThreadContext context, IRubyObject other) { - if (this == other) return getRuntime().getTrue(); - if (!(other instanceof RubyStruct)) return getRuntime().getFalse(); - if (getMetaClass() != other.getMetaClass()) return getRuntime().getFalse(); - - Ruby runtime = getRuntime(); - RubyStruct otherStruct = (RubyStruct)other; - for (int i = 0; i < values.length; i++) { - if (!eqlInternal(context, values[i], otherStruct.values[i])) return runtime.getFalse(); - } - return runtime.getTrue(); - } - - /** inspect_struct - * - */ - private IRubyObject inspectStruct(final ThreadContext context) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - ByteList buffer = new ByteList("#<struct ".getBytes()); - buffer.append(getMetaClass().getRealClass().getRealClass().getName().getBytes()); - buffer.append(' '); - - for (int i = 0,k=member.getLength(); i < k; i++) { - if (i > 0) buffer.append(',').append(' '); - // FIXME: MRI has special case for constants here - buffer.append(RubyString.objAsString(context, member.eltInternal(i)).getByteList()); - buffer.append('='); - buffer.append(inspect(context, values[i]).getByteList()); - } - - buffer.append('>'); - return getRuntime().newString(buffer); // OBJ_INFECT - } - - @JRubyMethod(name = {"inspect", "to_s"}) - public IRubyObject inspect(ThreadContext context) { - if (getRuntime().isInspecting(this)) return getRuntime().newString("#<struct " + getMetaClass().getRealClass().getName() + ":...>"); - - try { - getRuntime().registerInspecting(this); - return inspectStruct(context); - } finally { - getRuntime().unregisterInspecting(this); - } - } - - @JRubyMethod(name = {"to_a", "values"}) - public RubyArray to_a() { - return getRuntime().newArray(values); - } - - @JRubyMethod(name = {"size", "length"} ) - public RubyFixnum size() { - return getRuntime().newFixnum(values.length); - } - - @JRubyMethod(name = "each", backtrace = true) - public IRubyObject each(ThreadContext context, Block block) { - for (int i = 0; i < values.length; i++) { - block.yield(context, values[i]); - } - - return this; - } - - @JRubyMethod(frame = true) - public IRubyObject each_pair(ThreadContext context, Block block) { - RubyArray member = (RubyArray) getInternalVariable(classOf(), "__member__"); - - assert !member.isNil() : "uninitialized struct"; - - for (int i = 0; i < values.length; i++) { - block.yield(context, getRuntime().newArrayNoCopy(new IRubyObject[]{member.eltInternal(i), values[i]})); - } - - return this; - } - - @JRubyMethod(name = "[]", required = 1) - public IRubyObject aref(IRubyObject key) { - if (key instanceof RubyString || key instanceof RubySymbol) { - return getByName(key.asJavaString()); - } - - int idx = RubyNumeric.fix2int(key); - - idx = idx < 0 ? values.length + idx : idx; - - if (idx < 0) { - throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")"); - } else if (idx >= values.length) { - throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")"); - } - - return values[idx]; - } - - @JRubyMethod(name = "[]=", required = 2) - public IRubyObject aset(IRubyObject key, IRubyObject value) { - if (key instanceof RubyString || key instanceof RubySymbol) { - return setByName(key.asJavaString(), value); - } - - int idx = RubyNumeric.fix2int(key); - - idx = idx < 0 ? values.length + idx : idx; - - if (idx < 0) { - throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")"); - } else if (idx >= values.length) { - throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")"); - } - - modify(); - return values[idx] = value; - } - - // FIXME: This is copied code from RubyArray. Both RE, Struct, and Array should share one impl - // This is also hacky since I construct ruby objects to access ruby arrays through aref instead - // of something lower. - @JRubyMethod(rest = true) - public IRubyObject values_at(IRubyObject[] args) { - long olen = values.length; - RubyArray result = getRuntime().newArray(args.length); - - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof RubyFixnum) { - result.append(aref(args[i])); - continue; - } - - long beglen[]; - if (!(args[i] instanceof RubyRange)) { - } else if ((beglen = ((RubyRange) args[i]).begLen(olen, 0)) == null) { - continue; - } else { - int beg = (int) beglen[0]; - int len = (int) beglen[1]; - int end = len; - for (int j = 0; j < end; j++) { - result.append(aref(getRuntime().newFixnum(j + beg))); - } - continue; - } - result.append(aref(getRuntime().newFixnum(RubyNumeric.num2long(args[i])))); - } - - return result; - } - - public static void marshalTo(RubyStruct struct, MarshalStream output) throws java.io.IOException { - output.registerLinkTarget(struct); - output.dumpDefaultObjectHeader('S', struct.getMetaClass()); - - List members = ((RubyArray) getInternalVariable(struct.classOf(), "__member__")).getList(); - output.writeInt(members.size()); - - for (int i = 0; i < members.size(); i++) { - RubySymbol name = (RubySymbol) members.get(i); - output.dumpObject(name); - output.dumpObject(struct.values[i]); - } - } - - public static RubyStruct unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - Ruby runtime = input.getRuntime(); - - RubySymbol className = (RubySymbol) input.unmarshalObject(); - RubyClass rbClass = pathToClass(runtime, className.asJavaString()); - if (rbClass == null) { - throw runtime.newNameError("uninitialized constant " + className, className.asJavaString()); - } - - RubyArray mem = members(rbClass, Block.NULL_BLOCK); - - int len = input.unmarshalInt(); - IRubyObject[] values = new IRubyObject[len]; - for(int i = 0; i < len; i++) { - values[i] = runtime.getNil(); - } - RubyStruct result = newStruct(rbClass, values, Block.NULL_BLOCK); - input.registerLinkTarget(result); - for(int i = 0; i < len; i++) { - IRubyObject slot = input.unmarshalObject(); - if(!mem.eltInternal(i).toString().equals(slot.toString())) { - throw runtime.newTypeError("struct " + rbClass.getName() + " not compatible (:" + slot + " for :" + mem.eltInternal(i) + ")"); - } - result.aset(runtime.newFixnum(i), input.unmarshalObject()); - } - return result; - } - - private static RubyClass pathToClass(Ruby runtime, String path) { - // FIXME: Throw the right ArgumentError's if the class is missing - // or if it's a module. - return (RubyClass) runtime.getClassFromPath(path); - } - - private static ObjectAllocator STRUCT_INSTANCE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyStruct instance = new RubyStruct(runtime, klass); - - instance.setMetaClass(klass); - - return instance; - } - }; - - @Override - @JRubyMethod(required = 1) - public IRubyObject initialize_copy(IRubyObject arg) { - if (this == arg) return this; - RubyStruct original = (RubyStruct) arg; - - values = new IRubyObject[original.values.length]; - System.arraycopy(original.values, 0, values, 0, original.values.length); - - return this; - } - -} -/* - ***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Alan Moore <alan_moore@gmx.net> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Derek Berner <derek.berner@state.nm.us> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * Copyright (C) 2007 William N Dortch <bill.dortch@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.concurrent.locks.ReentrantLock; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Block; -import org.jruby.runtime.BlockCallback; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.marshal.UnmarshalStream; -import org.jruby.util.ByteList; - -/** - * Represents a Ruby symbol (e.g. :bar) - */ -@JRubyClass(name="Symbol") -public class RubySymbol extends RubyObject { - private final String symbol; - private final int id; - private final ByteList symbolBytes; - - /** - * - * @param runtime - * @param internedSymbol the String value of the new Symbol. This <em>must</em> - * have been previously interned - */ - private RubySymbol(Ruby runtime, String internedSymbol) { - super(runtime, runtime.getSymbol(), false); - // symbol string *must* be interned - - assert internedSymbol == internedSymbol.intern() : internedSymbol + " is not interned"; - - this.symbol = internedSymbol; - this.symbolBytes = ByteList.create(symbol); - - this.id = runtime.allocSymbolId(); - } - - public static RubyClass createSymbolClass(Ruby runtime) { - RubyClass symbolClass = runtime.defineClass("Symbol", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setSymbol(symbolClass); - RubyClass symbolMetaClass = symbolClass.getMetaClass(); - symbolClass.index = ClassIndex.SYMBOL; - symbolClass.kindOf = new RubyModule.KindOf() { - public boolean isKindOf(IRubyObject obj, RubyModule type) { - return obj instanceof RubySymbol; - } - }; - - symbolClass.defineAnnotatedMethods(RubySymbol.class); - symbolMetaClass.undefineMethod("new"); - - return symbolClass; - } - - @Override - public int getNativeTypeIndex() { - return ClassIndex.SYMBOL; - } - - /** rb_to_id - * - * @return a String representation of the symbol - */ - @Override - public String asJavaString() { - return symbol; - } - - /** short circuit for Symbol key comparison - * - */ - @Override - public final boolean eql(IRubyObject other) { - return other == this; - } - - @Override - public boolean isImmediate() { - return true; - } - - @Override - public RubyClass getSingletonClass() { - throw getRuntime().newTypeError("can't define singleton"); - } - - public static RubySymbol getSymbolLong(Ruby runtime, long id) { - return runtime.getSymbolTable().lookup(id); - } - - /* Symbol class methods. - * - */ - - public static RubySymbol newSymbol(Ruby runtime, String name) { - return runtime.getSymbolTable().getSymbol(name); - } - - @JRubyMethod(name = "to_i") - public RubyFixnum to_i() { - return getRuntime().newFixnum(id); - } - - @JRubyMethod(name = "to_int") - public RubyFixnum to_int() { - if (getRuntime().getVerbose().isTrue()) { - getRuntime().getWarnings().warn(ID.SYMBOL_AS_INTEGER, "treating Symbol as an integer"); - } - return to_i(); - } - - @JRubyMethod(name = "inspect") - @Override - public IRubyObject inspect() { - Ruby runtime = getRuntime(); - return runtime.newString(":" + - (isSymbolName(symbol) ? symbol : RubyString.newStringShared(runtime, symbolBytes).dump().toString())); - } - - @JRubyMethod(name = "to_s") - @Override - public IRubyObject to_s() { - return RubyString.newStringShared(getRuntime(), symbolBytes); - } - - @JRubyMethod(name = "id2name") - public IRubyObject id2name() { - return to_s(); - } - - @JRubyMethod(name = "===", required = 1) - @Override - public IRubyObject op_eqq(ThreadContext context, IRubyObject other) { - return super.op_equal(context, other); - } - - @Override - public RubyFixnum hash() { - return getRuntime().newFixnum(hashCode()); - } - - @Override - public int hashCode() { - return id; - } - - public int getId() { - return id; - } - - @Override - public boolean equals(Object other) { - return other == this; - } - - @JRubyMethod(name = "to_sym") - public IRubyObject to_sym() { - return this; - } - - @Override - public IRubyObject freeze(ThreadContext context) { - return this; - } - - @Override - public IRubyObject taint(ThreadContext context) { - return this; - } - - private static class ToProcCallback implements BlockCallback { - private RubySymbol symbol; - public ToProcCallback(RubySymbol symbol) { - this.symbol = symbol; - } - - public IRubyObject call(ThreadContext ctx, IRubyObject[] args, Block blk) { - IRubyObject[] currentArgs = args; - switch(currentArgs.length) { - case 0: throw symbol.getRuntime().newArgumentError("no receiver given"); - case 1: { - if((currentArgs[0] instanceof RubyArray) && ((RubyArray)currentArgs[0]).getLength() != 0) { - // This is needed to unpack stuff - currentArgs = ((RubyArray)currentArgs[0]).toJavaArrayMaybeUnsafe(); - IRubyObject[] args2 = new IRubyObject[currentArgs.length-1]; - System.arraycopy(currentArgs, 1, args2, 0, args2.length); - return RuntimeHelpers.invoke(ctx, currentArgs[0], symbol.symbol, args2); - } else { - return RuntimeHelpers.invoke(ctx, currentArgs[0], symbol.symbol); - } - } - default: { - IRubyObject[] args2 = new IRubyObject[currentArgs.length-1]; - System.arraycopy(currentArgs, 1, args2, 0, args2.length); - return RuntimeHelpers.invoke(ctx, currentArgs[0], symbol.symbol, args2); - } - } - } - } - /* - @JRubyMethod - public IRubyObject to_proc() { - return RubyProc.newProc(getRuntime(), - CallBlock.newCallClosure(this, getRuntime().getSymbol(), Arity.noArguments(), new ToProcCallback(this), getRuntime().getCurrentContext()), - Block.Type.PROC); - } - */ - private static boolean isIdentStart(char c) { - return ((c >= 'a' && c <= 'z')|| (c >= 'A' && c <= 'Z') - || c == '_'); - } - private static boolean isIdentChar(char c) { - return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') - || c == '_'); - } - - private static boolean isIdentifier(String s) { - if (s == null || s.length() <= 0) { - return false; - } - - if (!isIdentStart(s.charAt(0))) { - return false; - } - for (int i = 1; i < s.length(); i++) { - if (!isIdentChar(s.charAt(i))) { - return false; - } - } - - return true; - } - - /** - * is_special_global_name from parse.c. - * @param s - * @return - */ - private static boolean isSpecialGlobalName(String s) { - if (s == null || s.length() <= 0) { - return false; - } - - int length = s.length(); - - switch (s.charAt(0)) { - case '~': case '*': case '$': case '?': case '!': case '@': case '/': case '\\': - case ';': case ',': case '.': case '=': case ':': case '<': case '>': case '\"': - case '&': case '`': case '\'': case '+': case '0': - return length == 1; - case '-': - return (length == 1 || (length == 2 && isIdentChar(s.charAt(1)))); - - default: - // we already confirmed above that length > 0 - for (int i = 0; i < length; i++) { - if (!Character.isDigit(s.charAt(i))) { - return false; - } - } - } - return true; - } - - private static boolean isSymbolName(String s) { - if (s == null || s.length() < 1) { - return false; - } - - int length = s.length(); - - char c = s.charAt(0); - switch (c) { - case '$': - if (length > 1 && isSpecialGlobalName(s.substring(1))) { - return true; - } - return isIdentifier(s.substring(1)); - case '@': - int offset = 1; - if (length >= 2 && s.charAt(1) == '@') { - offset++; - } - - return isIdentifier(s.substring(offset)); - case '<': - return (length == 1 || (length == 2 && (s.equals("<<") || s.equals("<="))) || - (length == 3 && s.equals("<=>"))); - case '>': - return (length == 1) || (length == 2 && (s.equals(">>") || s.equals(">="))); - case '=': - return ((length == 2 && (s.equals("==") || s.equals("=~"))) || - (length == 3 && s.equals("==="))); - case '*': - return (length == 1 || (length == 2 && s.equals("**"))); - case '+': - return (length == 1 || (length == 2 && s.equals("+@"))); - case '-': - return (length == 1 || (length == 2 && s.equals("-@"))); - case '|': case '^': case '&': case '/': case '%': case '~': case '`': - return length == 1; - case '[': - return s.equals("[]") || s.equals("[]="); - } - - if (!isIdentStart(c)) { - return false; - } - - boolean localID = (c >= 'a' && c <= 'z'); - int last = 1; - - for (; last < length; last++) { - char d = s.charAt(last); - - if (!isIdentChar(d)) { - break; - } - } - - if (last == length) { - return true; - } else if (localID && last == length - 1) { - char d = s.charAt(last); - - return d == '!' || d == '?' || d == '='; - } - - return false; - } - - @JRubyMethod(name = "all_symbols", meta = true) - public static IRubyObject all_symbols(IRubyObject recv) { - return recv.getRuntime().getSymbolTable().all_symbols(); - } - - public static RubySymbol unmarshalFrom(UnmarshalStream input) throws java.io.IOException { - RubySymbol result = newSymbol(input.getRuntime(), RubyString.byteListToString(input.unmarshalString())); - input.registerLinkTarget(result); - return result; - } - - public static class SymbolTable { - static final int DEFAULT_INITIAL_CAPACITY = 2048; // *must* be power of 2! - static final int MAXIMUM_CAPACITY = 1 << 30; - static final float DEFAULT_LOAD_FACTOR = 0.75f; - - private final ReentrantLock tableLock = new ReentrantLock(); - private volatile SymbolEntry[] symbolTable; - private int size; - private int threshold; - private final float loadFactor; - private final Ruby runtime; - - public SymbolTable(Ruby runtime) { - this.runtime = runtime; - this.loadFactor = DEFAULT_LOAD_FACTOR; - this.threshold = (int)(DEFAULT_INITIAL_CAPACITY * DEFAULT_LOAD_FACTOR); - this.symbolTable = new SymbolEntry[DEFAULT_INITIAL_CAPACITY]; - } - - // note all fields are final -- rehash creates new entries when necessary. - // as documented in java.util.concurrent.ConcurrentHashMap.java, that will - // statistically affect only a small percentage (< 20%) of entries for a given rehash. - static class SymbolEntry { - final int hash; - final String name; - final RubySymbol symbol; - final SymbolEntry next; - - SymbolEntry(int hash, String name, RubySymbol symbol, SymbolEntry next) { - this.hash = hash; - this.name = name; - this.symbol = symbol; - this.next = next; - } - } - - public RubySymbol getSymbol(String name) { - int hash = name.hashCode(); - SymbolEntry[] table; - for (SymbolEntry e = (table = symbolTable)[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return e.symbol; - } - } - ReentrantLock lock; - (lock = tableLock).lock(); - try { - int potentialNewSize; - if ((potentialNewSize = size + 1) > threshold) { - table = rehash(); - } else { - table = symbolTable; - } - int index; - // try lookup again under lock - for (SymbolEntry e = table[index = hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return e.symbol; - } - } - String internedName; - RubySymbol symbol = new RubySymbol(runtime, internedName = name.intern()); - table[index] = new SymbolEntry(hash, internedName, symbol, table[index]); - size = potentialNewSize; - // write-volatile - symbolTable = table; - return symbol; - } finally { - lock.unlock(); - } - } - - public RubySymbol fastGetSymbol(String internedName) { - assert internedName == internedName.intern() : internedName + " is not interned"; - SymbolEntry[] table; - for (SymbolEntry e = (table = symbolTable)[internedName.hashCode() & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - return e.symbol; - } - } - ReentrantLock lock; - (lock = tableLock).lock(); - try { - int potentialNewSize; - if ((potentialNewSize = size + 1) > threshold) { - table = rehash(); - } else { - table = symbolTable; - } - int index; - int hash; - // try lookup again under lock - for (SymbolEntry e = table[index = (hash = internedName.hashCode()) & (table.length - 1)]; e != null; e = e.next) { - if (internedName == e.name) { - return e.symbol; - } - } - RubySymbol symbol = new RubySymbol(runtime, internedName); - table[index] = new SymbolEntry(hash, internedName, symbol, table[index]); - size = potentialNewSize; - // write-volatile - symbolTable = table; - return symbol; - } finally { - lock.unlock(); - } - } - - // backwards-compatibility, but threadsafe now - public RubySymbol lookup(String name) { - int hash = name.hashCode(); - SymbolEntry[] table; - for (SymbolEntry e = (table = symbolTable)[hash & (table.length - 1)]; e != null; e = e.next) { - if (hash == e.hash && name.equals(e.name)) { - return e.symbol; - } - } - return null; - } - - public RubySymbol lookup(long id) { - SymbolEntry[] table = symbolTable; - for (int i = table.length; --i >= 0; ) { - for (SymbolEntry e = table[i]; e != null; e = e.next) { - if (id == e.symbol.id) { - return e.symbol; - } - } - } - return null; - } - - public RubyArray all_symbols() { - SymbolEntry[] table = this.symbolTable; - RubyArray array = runtime.newArray(this.size); - for (int i = table.length; --i >= 0; ) { - for (SymbolEntry e = table[i]; e != null; e = e.next) { - array.append(e.symbol); - } - } - return array; - } - - // not so backwards-compatible here, but no one should have been - // calling this anyway. - @Deprecated - public void store(RubySymbol symbol) { - throw new UnsupportedOperationException(); - } - - private SymbolEntry[] rehash() { - SymbolEntry[] oldTable = symbolTable; - int oldCapacity; - if ((oldCapacity = oldTable.length) >= MAXIMUM_CAPACITY) { - return oldTable; - } - - int newCapacity = oldCapacity << 1; - SymbolEntry[] newTable = new SymbolEntry[newCapacity]; - threshold = (int)(newCapacity * loadFactor); - int sizeMask = newCapacity - 1; - SymbolEntry e; - for (int i = oldCapacity; --i >= 0; ) { - // We need to guarantee that any existing reads of old Map can - // proceed. So we cannot yet null out each bin. - e = oldTable[i]; - - if (e != null) { - SymbolEntry next = e.next; - int idx = e.hash & sizeMask; - - // Single node on list - if (next == null) - newTable[idx] = e; - - else { - // Reuse trailing consecutive sequence at same slot - SymbolEntry lastRun = e; - int lastIdx = idx; - for (SymbolEntry last = next; - last != null; - last = last.next) { - int k = last.hash & sizeMask; - if (k != lastIdx) { - lastIdx = k; - lastRun = last; - } - } - newTable[lastIdx] = lastRun; - - // Clone all remaining nodes - for (SymbolEntry p = e; p != lastRun; p = p.next) { - int k = p.hash & sizeMask; - SymbolEntry n = newTable[k]; - newTable[k] = new SymbolEntry(p.hash, p.name, p.symbol, n); - } - } - } - } - symbolTable = newTable; - return newTable; - } - - } -} -package org.jruby; - -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.HashMap; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ObjectMarshal; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.builtin.Variable; -import org.jruby.runtime.component.VariableEntry; -import org.jruby.runtime.marshal.MarshalStream; -import org.jruby.runtime.marshal.UnmarshalStream; - -@JRubyClass(name="SystemCallError", parent="StandardError") -public class RubySystemCallError extends RubyException { - private IRubyObject errno = getRuntime().getNil(); - - private final static Map<String, String> defaultMessages = new HashMap<String, String>(); - static { - defaultMessages.put("Errno::EPERM", "Operation not permitted"); - defaultMessages.put("Errno::ENOENT", "No such file or directory"); - defaultMessages.put("Errno::ESRCH", "No such process"); - defaultMessages.put("Errno::EINTR", "Interrupted system call"); - defaultMessages.put("Errno::EIO", "Input/output error"); - defaultMessages.put("Errno::ENXIO", "Device not configured"); - defaultMessages.put("Errno::E2BIG", "Argument list too long"); - defaultMessages.put("Errno::ENOEXEC", "Exec format error"); - defaultMessages.put("Errno::EBADF", "Bad file descriptor"); - defaultMessages.put("Errno::ECHILD", "No child processes"); - defaultMessages.put("Errno::EDEADLK", "Resource deadlock avoided"); - defaultMessages.put("Errno::ENOMEM", "Cannot allocate memory"); - defaultMessages.put("Errno::EACCES", "Permission denied"); - defaultMessages.put("Errno::EFAULT", "Bad address"); - defaultMessages.put("Errno::ENOTBLK", "Block device required"); - defaultMessages.put("Errno::EBUSY", "Resource busy"); - defaultMessages.put("Errno::EEXIST", "File exists"); - defaultMessages.put("Errno::EXDEV", "Cross-device link"); - defaultMessages.put("Errno::ENODEV", "Operation not supported by device"); - defaultMessages.put("Errno::ENOTDIR", "Not a directory"); - defaultMessages.put("Errno::EISDIR", "Is a directory"); - defaultMessages.put("Errno::EINVAL", "Invalid argument"); - defaultMessages.put("Errno::ENFILE", "Too many open files in system"); - defaultMessages.put("Errno::EMFILE", "Too many open files"); - defaultMessages.put("Errno::ENOTTY", "Inappropriate ioctl for device"); - defaultMessages.put("Errno::ETXTBSY", "Text file busy"); - defaultMessages.put("Errno::EFBIG", "File too large"); - defaultMessages.put("Errno::ENOSPC", "No space left on device"); - defaultMessages.put("Errno::ESPIPE", "Illegal seek"); - defaultMessages.put("Errno::EROFS", "Read-only file system"); - defaultMessages.put("Errno::EMLINK", "Too many links"); - defaultMessages.put("Errno::EPIPE", "Broken pipe"); - defaultMessages.put("Errno::EDOM", "Numerical argument out of domain"); - defaultMessages.put("Errno::ERANGE", "Result too large"); - defaultMessages.put("Errno::EAGAIN", "Resource temporarily unavailable"); - defaultMessages.put("Errno::EWOULDBLOCK", "Resource temporarily unavailable"); - defaultMessages.put("Errno::EINPROGRESS", "Operation now in progress"); - defaultMessages.put("Errno::EALREADY", "Operation already in progress"); - defaultMessages.put("Errno::ENOTSOCK", "Socket operation on non-socket"); - defaultMessages.put("Errno::EDESTADDRREQ", "Destination address required"); - defaultMessages.put("Errno::EMSGSIZE", "Message too long"); - defaultMessages.put("Errno::EPROTOTYPE", "Protocol wrong type for socket"); - defaultMessages.put("Errno::ENOPROTOOPT", "Protocol not available"); - defaultMessages.put("Errno::EPROTONOSUPPORT", "Protocol not supported"); - defaultMessages.put("Errno::ESOCKTNOSUPPORT", "Socket type not supported"); - defaultMessages.put("Errno::EPFNOSUPPORT", "Protocol family not supported"); - defaultMessages.put("Errno::EAFNOSUPPORT", "Address family not supported by protocol family"); - defaultMessages.put("Errno::EADDRINUSE", "Address already in use"); - defaultMessages.put("Errno::EADDRNOTAVAIL", "Can't assign requested address"); - defaultMessages.put("Errno::ENETDOWN", "Network is down"); - defaultMessages.put("Errno::ENETUNREACH", "Network is unreachable"); - defaultMessages.put("Errno::ENETRESET", "Network dropped connection on reset"); - defaultMessages.put("Errno::ECONNABORTED", "Software caused connection abort"); - defaultMessages.put("Errno::ECONNRESET", "Connection reset by peer"); - defaultMessages.put("Errno::ENOBUFS", "No buffer space available"); - defaultMessages.put("Errno::EISCONN", "Socket is already connected"); - defaultMessages.put("Errno::ENOTCONN", "Socket is not connected"); - defaultMessages.put("Errno::ESHUTDOWN", "Can't send after socket shutdown"); - defaultMessages.put("Errno::ETOOMANYREFS", "Too many references: can't splice"); - defaultMessages.put("Errno::ETIMEDOUT", "Operation timed out"); - defaultMessages.put("Errno::ECONNREFUSED", "Connection refused"); - defaultMessages.put("Errno::ELOOP", "Too many levels of symbolic links"); - defaultMessages.put("Errno::ENAMETOOLONG", "File name too long"); - defaultMessages.put("Errno::EHOSTDOWN", "Host is down"); - defaultMessages.put("Errno::EHOSTUNREACH", "No route to host"); - defaultMessages.put("Errno::ENOTEMPTY", "Directory not empty"); - defaultMessages.put("Errno::EUSERS", "Too many users"); - defaultMessages.put("Errno::EDQUOT", "Disc quota exceeded"); - defaultMessages.put("Errno::ESTALE", "Stale NFS file handle"); - defaultMessages.put("Errno::EREMOTE", "Too many levels of remote in path"); - defaultMessages.put("Errno::ENOLCK", "No locks available"); - defaultMessages.put("Errno::ENOSYS", "Function not implemented"); - defaultMessages.put("Errno::EOVERFLOW", "Value too large to be stored in data type"); - defaultMessages.put("Errno::EIDRM", "Identifier removed"); - defaultMessages.put("Errno::ENOMSG", "No message of desired type"); - defaultMessages.put("Errno::EILSEQ", "Illegal byte sequence"); - defaultMessages.put("Errno::EBADMSG", "Bad message"); - defaultMessages.put("Errno::EMULTIHOP", "EMULTIHOP (Reserved)"); - defaultMessages.put("Errno::ENODATA", "No message available on STREAM"); - defaultMessages.put("Errno::ENOLINK", "ENOLINK (Reserved)"); - defaultMessages.put("Errno::ENOSR", "No STREAM resources"); - defaultMessages.put("Errno::ENOSTR", "Not a STREAM"); - defaultMessages.put("Errno::EPROTO", "Protocol error"); - defaultMessages.put("Errno::ETIME", "STREAM ioctl timeout"); - defaultMessages.put("Errno::EOPNOTSUPP", "Operation not supported"); - defaultMessages.put("Errno::EOPNOTSUPP_DARWIN", "Operation not supported"); - } - - protected RubySystemCallError(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass, null); - } - - public RubySystemCallError(Ruby runtime, RubyClass rubyClass, String message, int errno) { - super(runtime, rubyClass, message); - this.errno = runtime.newFixnum(errno); - } - - private static ObjectAllocator SYSTEM_CALL_ERROR_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - RubyException instance = new RubySystemCallError(runtime, klass); - - instance.setMetaClass(klass); - - return instance; - } - }; - - private static final ObjectMarshal SYSTEM_CALL_ERROR_MARSHAL = new ObjectMarshal() { - public void marshalTo(Ruby runtime, Object obj, RubyClass type, - MarshalStream marshalStream) throws IOException { - RubySystemCallError exc = (RubySystemCallError) obj; - marshalStream.registerLinkTarget(exc); - - List<Variable<IRubyObject>> attrs = exc.getVariableList(); - attrs.add(new VariableEntry<IRubyObject>( - "mesg", exc.message == null ? runtime.getNil() : exc.message)); - attrs.add(new VariableEntry<IRubyObject>("errno", exc.errno)); - attrs.add(new VariableEntry<IRubyObject>("bt", exc.getBacktrace())); - marshalStream.dumpVariables(attrs); - } - - public Object unmarshalFrom(Ruby runtime, RubyClass type, - UnmarshalStream unmarshalStream) throws IOException { - RubySystemCallError exc = (RubySystemCallError) type.allocate(); - - unmarshalStream.registerLinkTarget(exc); - unmarshalStream.defaultVariablesUnmarshal(exc); - - exc.message = exc.removeInternalVariable("mesg"); - exc.errno = exc.removeInternalVariable("errno"); - exc.set_backtrace(exc.removeInternalVariable("bt")); - - return exc; - } - }; - - public static RubyClass createSystemCallErrorClass(Ruby runtime, RubyClass standardError) { - RubyClass exceptionClass = runtime.defineClass("SystemCallError", standardError, SYSTEM_CALL_ERROR_ALLOCATOR); - - exceptionClass.setMarshal(SYSTEM_CALL_ERROR_MARSHAL); - - runtime.callbackFactory(RubyClass.class); - exceptionClass.defineAnnotatedMethods(RubySystemCallError.class); - - return exceptionClass; - } - - @JRubyMethod(optional = 2, required=0, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block block) { - RubyClass sCallErorrClass = getRuntime().getSystemCallError(); - RubyClass klass = getMetaClass().getRealClass(); - - IRubyObject msg = getRuntime().getNil(); - IRubyObject err = getRuntime().getNil(); - - boolean isErrnoClass = !klass.equals(sCallErorrClass); - - if (!isErrnoClass) { - // one optional, one required args - Arity.checkArgumentCount(getRuntime(), args, 1, 2); - msg = args[0]; - if (args.length == 2) { - err = args[1]; - } - if (args.length == 1 && (msg instanceof RubyFixnum)) { - err = msg; - msg = getRuntime().getNil(); - } - } else { - // one optional and no required args - Arity.checkArgumentCount(getRuntime(), args, 0, 1); - if (args.length == 1) { - msg = args[0]; - } - // try to get errno out of the class - err = klass.fastGetConstant("Errno"); - } - - if (!err.isNil()) { - errno = err.convertToInteger(); - } - - String val = defaultMessages.get(klass.getName()); - if (val == null) { - val = "Unknown error"; - } - - // MRI behavior: we don't print errno for actual Errno errors - if (!errno.isNil() && !isErrnoClass) { - val += " " + errno.toString(); - } - - if (!msg.isNil()) { - val += " - " + msg.convertToString(); - } - - message = getRuntime().newString(val); - return this; - } - - @JRubyMethod - public IRubyObject errno() { - return errno; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ - -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -@JRubyClass(name="SystemExit", parent="Exception") -public class RubySystemExit extends RubyException { - IRubyObject status; - - private static ObjectAllocator SYSTEMEXIT_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubySystemExit(runtime, klass); - } - }; - - public static RubyClass createSystemExitClass(Ruby runtime, RubyClass exceptionClass) { - RubyClass systemExitClass = runtime.defineClass("SystemExit", exceptionClass, SYSTEMEXIT_ALLOCATOR); - - systemExitClass.defineAnnotatedMethods(RubySystemExit.class); - - return systemExitClass; - } - - public static RubySystemExit newInstance(Ruby runtime, int status) { - RubyClass exc = runtime.getSystemExit(); - IRubyObject[] exArgs = new IRubyObject[] { - runtime.newFixnum(status), - runtime.newString("exit") }; - return (RubySystemExit) exc.newInstance(runtime.getCurrentContext(), exArgs, Block.NULL_BLOCK); - } - - protected RubySystemExit(Ruby runtime, RubyClass exceptionClass) { - super(runtime, exceptionClass); - status = runtime.getNil(); - } - - @JRubyMethod(name = "initialize", optional = 2, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[]args, Block block) { - status = RubyFixnum.zero(getRuntime()); - if (args.length > 0 && args[0] instanceof RubyFixnum) { - status = args[0]; - IRubyObject[]tmpArgs = new IRubyObject[args.length - 1]; - System.arraycopy(args, 1, tmpArgs, 0, tmpArgs.length); - args = tmpArgs; - } - super.initialize(args, block); - return this; - } - - @JRubyMethod(name = "status") - public IRubyObject status() { - return status; - } - - @JRubyMethod(name = "success?") - public IRubyObject success_p() { - if (status.isNil()) return getRuntime().getTrue(); - if (status.equals(RubyFixnum.zero(getRuntime()))) return getRuntime().getTrue(); - return getRuntime().getFalse(); - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Jason Voegele <jason@jvoegele.com> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2002-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004-2005 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; -import java.nio.channels.Channel; -import java.nio.channels.SelectableChannel; -import java.nio.channels.SelectionKey; -import java.nio.channels.Selector; -import java.util.HashMap; -import java.util.Map; - -import java.util.Set; -import org.jruby.common.IRubyWarnings.ID; -import org.jruby.exceptions.RaiseException; -import org.jruby.exceptions.ThreadKill; -import org.jruby.internal.runtime.FutureThread; -import org.jruby.internal.runtime.NativeThread; -import org.jruby.internal.runtime.RubyRunnable; -import org.jruby.internal.runtime.ThreadLike; -import org.jruby.internal.runtime.ThreadService; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.locks.ReentrantLock; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.runtime.ObjectMarshal; -import org.jruby.runtime.Visibility; - -/** - * Implementation of Ruby's <code>Thread</code> class. Each Ruby thread is - * mapped to an underlying Java Virtual Machine thread. - * <p> - * Thread encapsulates the behavior of a thread of execution, including the main - * thread of the Ruby script. In the descriptions that follow, the parameter - * <code>aSymbol</code> refers to a symbol, which is either a quoted string or a - * <code>Symbol</code> (such as <code>:name</code>). - * - * Note: For CVS history, see ThreadClass.java. - */ -@JRubyClass(name="Thread") -public class RubyThread extends RubyObject { - private ThreadLike threadImpl; - private RubyFixnum priority; - private transient Map<IRubyObject, IRubyObject> threadLocalVariables; - private boolean abortOnException; - private IRubyObject finalResult; - private RaiseException exitingException; - private IRubyObject receivedException; - private RubyThreadGroup threadGroup; - - private final ThreadService threadService; - private volatile boolean isStopped = false; - private volatile boolean isDead = false; - public Object stopLock = new Object(); - - private volatile boolean killed = false; - public Object killLock = new Object(); - - public final ReentrantLock lock = new ReentrantLock(); - - private static final boolean DEBUG = false; - - protected RubyThread(Ruby runtime, RubyClass type) { - super(runtime, type); - this.threadService = runtime.getThreadService(); - finalResult = runtime.getNil(); - } - - /** - * Dispose of the current thread by removing it from its parent ThreadGroup. - */ - public void dispose() { - threadGroup.remove(this); - } - - public static RubyClass createThreadClass(Ruby runtime) { - // FIXME: In order for Thread to play well with the standard 'new' behavior, - // it must provide an allocator that can create empty object instances which - // initialize then fills with appropriate data. - RubyClass threadClass = runtime.defineClass("Thread", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setThread(threadClass); - - threadClass.defineAnnotatedMethods(RubyThread.class); - - RubyThread rubyThread = new RubyThread(runtime, threadClass); - // TODO: need to isolate the "current" thread from class creation - rubyThread.threadImpl = new NativeThread(rubyThread, Thread.currentThread()); - runtime.getThreadService().setMainThread(Thread.currentThread(), rubyThread); - - // set to default thread group - runtime.getDefaultThreadGroup().addDirectly(rubyThread); - - threadClass.setMarshal(ObjectMarshal.NOT_MARSHALABLE_MARSHAL); - - return threadClass; - } - - /** - * <code>Thread.new</code> - * <p> - * Thread.new( <i>[ arg ]*</i> ) {| args | block } -> aThread - * <p> - * Creates a new thread to execute the instructions given in block, and - * begins running it. Any arguments passed to Thread.new are passed into the - * block. - * <pre> - * x = Thread.new { sleep .1; print "x"; print "y"; print "z" } - * a = Thread.new { print "a"; print "b"; sleep .2; print "c" } - * x.join # Let the threads finish before - * a.join # main thread exits... - * </pre> - * <i>produces:</i> abxyzc - */ - @JRubyMethod(name = {"new", "fork"}, rest = true, frame = true, meta = true) - public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Block block) { - return startThread(recv, args, true, block); - } - - /** - * Basically the same as Thread.new . However, if class Thread is - * subclassed, then calling start in that subclass will not invoke the - * subclass's initialize method. - */ - @JRubyMethod(name = "start", rest = true, frame = true, meta = true) - public static RubyThread start(IRubyObject recv, IRubyObject[] args, Block block) { - return startThread(recv, args, false, block); - } - - public static RubyThread adopt(IRubyObject recv, Thread t) { - return adoptThread(recv, t, Block.NULL_BLOCK); - } - - private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) { - final Ruby runtime = recv.getRuntime(); - final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv); - - rubyThread.threadImpl = new NativeThread(rubyThread, t); - ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread); - - context.preAdoptThread(); - - // set to default thread group - runtime.getDefaultThreadGroup().addDirectly(rubyThread); - - return rubyThread; - } - - @JRubyMethod(name = "initialize", rest = true, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject[] args, Block block) { - Ruby runtime = getRuntime(); - if (!block.isGiven()) throw runtime.newThreadError("must be called with a block"); - - RubyRunnable runnable = new RubyRunnable(this, args, block); - if (RubyInstanceConfig.POOLING_ENABLED) { - threadImpl = new FutureThread(this, runnable); - } else { - Thread thread = new Thread(runnable); - thread.setDaemon(true); - threadImpl = new NativeThread(this, thread); - } - - // set to default thread group - runtime.getDefaultThreadGroup().addDirectly(this); - - threadImpl.start(); - - // We yield here to hopefully permit the target thread to schedule - // MRI immediately schedules it, so this is close but not exact - Thread.yield(); - - return this; - } - - private static RubyThread startThread(final IRubyObject recv, final IRubyObject[] args, boolean callInit, Block block) { - RubyThread rubyThread = new RubyThread(recv.getRuntime(), (RubyClass) recv); - - if (callInit) { - rubyThread.callInit(args, block); - } else { - // for Thread::start, which does not call the subclass's initialize - rubyThread.initialize(args, block); - } - - return rubyThread; - } - - private void ensureNotCurrent() { - if (this == getRuntime().getCurrentContext().getThread()) { - throw new RuntimeException("internal thread method called from another thread"); - } - } - - public synchronized void cleanTerminate(IRubyObject result) { - finalResult = result; - isStopped = true; - isDead = true; - } - - public void pollThreadEvents() { - pollThreadEvents(getRuntime().getCurrentContext()); - } - - public void pollThreadEvents(ThreadContext context) { - // check for criticalization *before* locking ourselves - threadService.waitForCritical(); - - if (killed) throwThreadKill(); - if (receivedException != null) receivedAnException(context); - } - - private void throwThreadKill() { - throw new ThreadKill(); - } - - /** - * Returns the status of the global ``abort on exception'' condition. The - * default is false. When set to true, will cause all threads to abort (the - * process will exit(0)) if an exception is raised in any thread. See also - * Thread.abort_on_exception= . - */ - @JRubyMethod(name = "abort_on_exception", meta = true) - public static RubyBoolean abort_on_exception_x(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - return runtime.isGlobalAbortOnExceptionEnabled() ? runtime.getTrue() : runtime.getFalse(); - } - - @JRubyMethod(name = "abort_on_exception=", required = 1, meta = true) - public static IRubyObject abort_on_exception_set_x(IRubyObject recv, IRubyObject value) { - recv.getRuntime().setGlobalAbortOnExceptionEnabled(value.isTrue()); - return value; - } - - @JRubyMethod(name = "current", meta = true) - public static RubyThread current(IRubyObject recv) { - return recv.getRuntime().getCurrentContext().getThread(); - } - - @JRubyMethod(name = "main", meta = true) - public static RubyThread main(IRubyObject recv) { - return recv.getRuntime().getThreadService().getMainThread(); - } - - @JRubyMethod(name = "pass", meta = true) - public static IRubyObject pass(IRubyObject recv) { - Ruby runtime = recv.getRuntime(); - ThreadService ts = runtime.getThreadService(); - boolean critical = ts.getCritical(); - - ts.setCritical(false); - - Thread.yield(); - - ts.setCritical(critical); - - return recv.getRuntime().getNil(); - } - - @JRubyMethod(name = "list", meta = true) - public static RubyArray list(IRubyObject recv) { - RubyThread[] activeThreads = recv.getRuntime().getThreadService().getActiveRubyThreads(); - - return recv.getRuntime().newArrayNoCopy(activeThreads); - } - - private IRubyObject getSymbolKey(IRubyObject originalKey) { - if (originalKey instanceof RubySymbol) { - return originalKey; - } else if (originalKey instanceof RubyString) { - return getRuntime().newSymbol(originalKey.asJavaString()); - } else if (originalKey instanceof RubyFixnum) { - getRuntime().getWarnings().warn(ID.FIXNUMS_NOT_SYMBOLS, "Do not use Fixnums as Symbols"); - throw getRuntime().newArgumentError(originalKey + " is not a symbol"); - } else { - throw getRuntime().newTypeError(originalKey + " is not a symbol"); - } - } - - private synchronized Map<IRubyObject, IRubyObject> getThreadLocals() { - if (threadLocalVariables == null) { - threadLocalVariables = new HashMap<IRubyObject, IRubyObject>(); - } - return threadLocalVariables; - } - - @JRubyMethod(name = "[]", required = 1) - public IRubyObject op_aref(IRubyObject key) { - IRubyObject value; - if ((value = getThreadLocals().get(getSymbolKey(key))) != null) { - return value; - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "[]=", required = 2) - public IRubyObject op_aset(IRubyObject key, IRubyObject value) { - key = getSymbolKey(key); - - getThreadLocals().put(key, value); - return value; - } - - @JRubyMethod(name = "abort_on_exception") - public RubyBoolean abort_on_exception() { - return abortOnException ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "abort_on_exception=", required = 1) - public IRubyObject abort_on_exception_set(IRubyObject val) { - abortOnException = val.isTrue(); - return val; - } - - @JRubyMethod(name = "alive?") - public RubyBoolean alive_p() { - return !isDead && threadImpl.isAlive() ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "join", optional = 1, backtrace = true) - public IRubyObject join(IRubyObject[] args) { - long timeoutMillis = Long.MAX_VALUE; - if (args.length > 0) { - if (args.length > 1) { - throw getRuntime().newArgumentError(args.length,1); - } - // MRI behavior: value given in seconds; converted to Float; less - // than or equal to zero returns immediately; returns nil - timeoutMillis = (long)(1000.0D * args[0].convertToFloat().getValue()); - if (timeoutMillis <= 0) { - // TODO: not sure that we should skip calling join() altogether. - // Thread.join() has some implications for Java Memory Model, etc. - if (threadImpl.isAlive()) { - return getRuntime().getNil(); - } else { - return this; - } - } - } - if (isCurrent()) { - throw getRuntime().newThreadError("thread tried to join itself"); - } - try { - if (threadService.getCritical()) { - // If the target thread is sleeping or stopped, wake it - synchronized (stopLock) { - stopLock.notify(); - } - - // interrupt the target thread in case it's blocking or waiting - // WARNING: We no longer interrupt the target thread, since this usually means - // interrupting IO and with NIO that means the channel is no longer usable. - // We either need a new way to handle waking a target thread that's waiting - // on IO, or we need to accept that we can't wake such threads and must wait - // for them to complete their operation. - //threadImpl.interrupt(); - } - - RubyThread currentThread = getRuntime().getCurrentContext().getThread(); - final long timeToWait = Math.min(timeoutMillis, 200); - - // We need this loop in order to be able to "unblock" the - // join call without actually calling interrupt. - long start = System.currentTimeMillis(); - while(true) { - currentThread.pollThreadEvents(); - threadImpl.join(timeToWait); - if (!threadImpl.isAlive()) { - break; - } - if (System.currentTimeMillis() - start > timeoutMillis) { - break; - } - } - } catch (InterruptedException ie) { - ie.printStackTrace(); - assert false : ie; - } catch (ExecutionException ie) { - ie.printStackTrace(); - assert false : ie; - } - - if (exitingException != null) { - throw exitingException; - } - - if (threadImpl.isAlive()) { - return getRuntime().getNil(); - } else { - return this; - } - } - - @JRubyMethod(name = "value") - public IRubyObject value() { - join(new IRubyObject[0]); - synchronized (this) { - return finalResult; - } - } - - @JRubyMethod(name = "group") - public IRubyObject group() { - if (threadGroup == null) { - return getRuntime().getNil(); - } - - return threadGroup; - } - - void setThreadGroup(RubyThreadGroup rubyThreadGroup) { - threadGroup = rubyThreadGroup; - } - - @JRubyMethod(name = "inspect") - @Override - public IRubyObject inspect() { - // FIXME: There's some code duplication here with RubyObject#inspect - StringBuilder part = new StringBuilder(); - String cname = getMetaClass().getRealClass().getName(); - part.append("#<").append(cname).append(":0x"); - part.append(Integer.toHexString(System.identityHashCode(this))); - - if (threadImpl.isAlive()) { - if (isStopped) { - part.append(getRuntime().newString(" sleep")); - } else if (killed) { - part.append(getRuntime().newString(" aborting")); - } else { - part.append(getRuntime().newString(" run")); - } - } else { - part.append(" dead"); - } - - part.append(">"); - return getRuntime().newString(part.toString()); - } - - @JRubyMethod(name = "key?", required = 1) - public RubyBoolean key_p(IRubyObject key) { - key = getSymbolKey(key); - - return getRuntime().newBoolean(getThreadLocals().containsKey(key)); - } - - @JRubyMethod(name = "keys") - public RubyArray keys() { - IRubyObject[] keys = new IRubyObject[getThreadLocals().size()]; - - return RubyArray.newArrayNoCopy(getRuntime(), getThreadLocals().keySet().toArray(keys)); - } - - @JRubyMethod(name = "critical=", required = 1, meta = true) - public static IRubyObject critical_set(IRubyObject receiver, IRubyObject value) { - receiver.getRuntime().getThreadService().setCritical(value.isTrue()); - - return value; - } - - @JRubyMethod(name = "critical", meta = true) - public static IRubyObject critical(IRubyObject receiver) { - return receiver.getRuntime().newBoolean(receiver.getRuntime().getThreadService().getCritical()); - } - - @JRubyMethod(name = "stop", meta = true) - public static IRubyObject stop(IRubyObject receiver) { - RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread(); - Object stopLock = rubyThread.stopLock; - - synchronized (stopLock) { - rubyThread.pollThreadEvents(); - try { - rubyThread.isStopped = true; - // attempt to decriticalize all if we're the critical thread - receiver.getRuntime().getThreadService().setCritical(false); - - stopLock.wait(); - } catch (InterruptedException ie) { - rubyThread.pollThreadEvents(); - } - rubyThread.isStopped = false; - } - - return receiver.getRuntime().getNil(); - } - - @JRubyMethod(name = "kill", required = 1, frame = true, meta = true) - public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block) { - if (!(rubyThread instanceof RubyThread)) throw receiver.getRuntime().newTypeError(rubyThread, receiver.getRuntime().getThread()); - return ((RubyThread)rubyThread).kill(); - } - - @JRubyMethod(name = "exit", frame = true, meta = true) - public static IRubyObject s_exit(IRubyObject receiver, Block block) { - RubyThread rubyThread = receiver.getRuntime().getThreadService().getCurrentContext().getThread(); - - rubyThread.killed = true; - // attempt to decriticalize all if we're the critical thread - receiver.getRuntime().getThreadService().setCritical(false); - - throw new ThreadKill(); - } - - @JRubyMethod(name = "stop?") - public RubyBoolean stop_p() { - // not valid for "dead" state - return getRuntime().newBoolean(isStopped); - } - - @JRubyMethod(name = "wakeup") - public RubyThread wakeup() { - synchronized (stopLock) { - stopLock.notifyAll(); - } - - return this; - } - - @JRubyMethod(name = "priority") - public RubyFixnum priority() { - return priority; - } - - @JRubyMethod(name = "priority=", required = 1) - public IRubyObject priority_set(IRubyObject priority) { - // FIXME: This should probably do some translation from Ruby priority levels to Java priority levels (until we have green threads) - int iPriority = RubyNumeric.fix2int(priority); - - if (iPriority < Thread.MIN_PRIORITY) { - iPriority = Thread.MIN_PRIORITY; - } else if (iPriority > Thread.MAX_PRIORITY) { - iPriority = Thread.MAX_PRIORITY; - } - - this.priority = RubyFixnum.newFixnum(getRuntime(), iPriority); - - if (threadImpl.isAlive()) { - threadImpl.setPriority(iPriority); - } - return this.priority; - } - - @JRubyMethod(name = "raise", optional = 2, frame = true) - public IRubyObject raise(IRubyObject[] args, Block block) { - ensureNotCurrent(); - Ruby runtime = getRuntime(); - - if (DEBUG) System.out.println("thread " + Thread.currentThread() + " before raising"); - RubyThread currentThread = getRuntime().getCurrentContext().getThread(); - try { - while (!(currentThread.lock.tryLock() && this.lock.tryLock())) { - if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock(); - } - - currentThread.pollThreadEvents(); - if (DEBUG) System.out.println("thread " + Thread.currentThread() + " raising"); - receivedException = prepareRaiseException(runtime, args, block); - - // If the target thread is sleeping or stopped, wake it - synchronized (stopLock) { - stopLock.notify(); - } - - // interrupt the target thread in case it's blocking or waiting - // WARNING: We no longer interrupt the target thread, since this usually means - // interrupting IO and with NIO that means the channel is no longer usable. - // We either need a new way to handle waking a target thread that's waiting - // on IO, or we need to accept that we can't wake such threads and must wait - // for them to complete their operation. - //threadImpl.interrupt(); - - // new interrupt, to hopefully wake it out of any blocking IO - this.interrupt(); - } finally { - if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock(); - if (this.lock.isHeldByCurrentThread()) this.lock.unlock(); - } - - return this; - } - - private IRubyObject prepareRaiseException(Ruby runtime, IRubyObject[] args, Block block) { - if(args.length == 0) { - IRubyObject lastException = runtime.getGlobalVariables().get("$!"); - if(lastException.isNil()) { - return new RaiseException(runtime, runtime.getRuntimeError(), "", false).getException(); - } - return lastException; - } - - IRubyObject exception; - ThreadContext context = getRuntime().getCurrentContext(); - - if(args.length == 1) { - if(args[0] instanceof RubyString) { - return runtime.getRuntimeError().newInstance(context, args, block); - } - - if(!args[0].respondsTo("exception")) { - return runtime.newTypeError("exception class/object expected").getException(); - } - exception = args[0].callMethod(context, "exception"); - } else { - if (!args[0].respondsTo("exception")) { - return runtime.newTypeError("exception class/object expected").getException(); - } - - exception = args[0].callMethod(context, "exception", args[1]); - } - - if (!runtime.getException().isInstance(exception)) { - return runtime.newTypeError("exception object expected").getException(); - } - - if (args.length == 3) { - ((RubyException) exception).set_backtrace(args[2]); - } - - return exception; - } - - @JRubyMethod(name = "run") - public IRubyObject run() { - // if stopped, unstop - synchronized (stopLock) { - if (isStopped) { - isStopped = false; - stopLock.notifyAll(); - } - } - - return this; - } - - public void sleep(long millis) throws InterruptedException { - assert this == getRuntime().getCurrentContext().getThread(); - synchronized (stopLock) { - pollThreadEvents(); - try { - isStopped = true; - stopLock.wait(millis); - } finally { - isStopped = false; - pollThreadEvents(); - } - } - } - - @JRubyMethod(name = "status") - public IRubyObject status() { - if (threadImpl.isAlive()) { - if (isStopped || currentSelector != null && currentSelector.isOpen()) { - return getRuntime().newString("sleep"); - } else if (killed) { - return getRuntime().newString("aborting"); - } - - return getRuntime().newString("run"); - } else if (exitingException != null) { - return getRuntime().getNil(); - } else { - return getRuntime().getFalse(); - } - } - - @JRubyMethod(name = {"kill", "exit", "terminate"}) - public IRubyObject kill() { - // need to reexamine this - RubyThread currentThread = getRuntime().getCurrentContext().getThread(); - - // If the killee thread is the same as the killer thread, just die - if (currentThread == this) throwThreadKill(); - - try { - if (DEBUG) System.out.println("thread " + Thread.currentThread() + " trying to kill"); - while (!(currentThread.lock.tryLock() && this.lock.tryLock())) { - if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock(); - } - - currentThread.pollThreadEvents(); - - if (DEBUG) System.out.println("thread " + Thread.currentThread() + " succeeded with kill"); - killed = true; - - // If the target thread is sleeping or stopped, wake it - synchronized (stopLock) { - stopLock.notify(); - } - - // interrupt the target thread in case it's blocking or waiting - // WARNING: We no longer interrupt the target thread, since this usually means - // interrupting IO and with NIO that means the channel is no longer usable. - // We either need a new way to handle waking a target thread that's waiting - // on IO, or we need to accept that we can't wake such threads and must wait - // for them to complete their operation. - //threadImpl.interrupt(); - - // new interrupt, to hopefully wake it out of any blocking IO - this.interrupt(); - } finally { - if (currentThread.lock.isHeldByCurrentThread()) currentThread.lock.unlock(); - if (this.lock.isHeldByCurrentThread()) this.lock.unlock(); - } - - try { - threadImpl.join(); - } catch (InterruptedException ie) { - // we were interrupted, check thread events again - currentThread.pollThreadEvents(); - } catch (ExecutionException ie) { - // we were interrupted, check thread events again - currentThread.pollThreadEvents(); - } - - return this; - } - - @JRubyMethod(name = {"kill!", "exit!", "terminate!"}) - public IRubyObject kill_bang() { - throw getRuntime().newNotImplementedError("Thread#kill!, exit!, and terminate! are not safe and not supported"); - } - - @JRubyMethod(name = "safe_level") - public IRubyObject safe_level() { - throw getRuntime().newNotImplementedError("Thread-specific SAFE levels are not supported"); - } - - private boolean isCurrent() { - return threadImpl.isCurrent(); - } - - public void exceptionRaised(RaiseException exception) { - assert isCurrent(); - - RubyException rubyException = exception.getException(); - Ruby runtime = rubyException.getRuntime(); - if (runtime.getSystemExit().isInstance(rubyException)) { - threadService.getMainThread().raise(new IRubyObject[] {rubyException}, Block.NULL_BLOCK); - } else if (abortOnException(runtime)) { - runtime.printError(rubyException); - RubyException systemExit = RubySystemExit.newInstance(runtime, 1); - systemExit.message = rubyException.message; - systemExit.set_backtrace(rubyException.backtrace()); - threadService.getMainThread().raise(new IRubyObject[] {systemExit}, Block.NULL_BLOCK); - return; - } else if (runtime.getDebug().isTrue()) { - runtime.printError(exception.getException()); - } - exitingException = exception; - } - - private boolean abortOnException(Ruby runtime) { - return (runtime.isGlobalAbortOnExceptionEnabled() || abortOnException); - } - - public static RubyThread mainThread(IRubyObject receiver) { - return receiver.getRuntime().getThreadService().getMainThread(); - } - - private Selector currentSelector; - - @Deprecated - public boolean selectForAccept(RubyIO io) { - return select(io, SelectionKey.OP_ACCEPT); - } - - public boolean select(RubyIO io, int ops) { - Channel channel = io.getChannel(); - - if (channel instanceof SelectableChannel) { - SelectableChannel selectable = (SelectableChannel)channel; - - synchronized (selectable.blockingLock()) { - boolean oldBlocking = selectable.isBlocking(); - - try { - selectable.configureBlocking(false); - - io.addBlockingThread(this); - currentSelector = selectable.provider().openSelector(); - - SelectionKey key = selectable.register(currentSelector, ops); - - int result = currentSelector.select(); - - // check for thread events, in case we've been woken up to die - pollThreadEvents(); - - if (result == 1) { - Set<SelectionKey> keySet = currentSelector.selectedKeys(); - - if (keySet.iterator().next() == key) { - return true; - } - } - - return false; - } catch (IOException ioe) { - throw io.getRuntime().newRuntimeError("Error with selector: " + ioe); - } finally { - if (currentSelector != null) { - try { - currentSelector.close(); - } catch (IOException ioe) { - throw io.getRuntime().newRuntimeError("Could not close selector"); - } - } - currentSelector = null; - io.removeBlockingThread(this); - try { - selectable.configureBlocking(oldBlocking); - } catch (IOException ioe) { - // ignore; I don't like doing it, but it seems like we - // really just need to make all channels non-blocking by - // default and use select when implementing blocking ops, - // so if this remains set non-blocking, perhaps it's not - // such a big deal... - } - } - } - } else { - // can't select, just have to do a blocking call - return true; - } - } - - public void interrupt() { - if (currentSelector != null) { - currentSelector.wakeup(); - } - } - - public void beforeBlockingCall() { - isStopped = true; - } - - public void afterBlockingCall() { - isStopped = false; - } - - private void receivedAnException(ThreadContext context) { - // clear this so we don't keep re-throwing - IRubyObject raiseException = receivedException; - receivedException = null; - RubyModule kernelModule = getRuntime().getKernel(); - if (DEBUG) { - System.out.println("thread " + Thread.currentThread() + " before propagating exception: " + killed); - } - kernelModule.callMethod(context, "raise", raiseException); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.util.HashMap; -import java.util.Map; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; - -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * Implementation of Ruby's <code>ThreadGroup</code> class. This is currently - * just a stub. - * <p> - * - * @author Charles O Nutter (headius@headius.com) - */ -@JRubyClass(name="ThreadGroup") -public class RubyThreadGroup extends RubyObject { - private Map<Integer, IRubyObject> rubyThreadList = new HashMap<Integer, IRubyObject>(); - private boolean enclosed = false; - - // ENEBO: Can these be fast? - public static RubyClass createThreadGroupClass(Ruby runtime) { - RubyClass threadGroupClass = runtime.defineClass("ThreadGroup", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setThreadGroup(threadGroupClass); - - threadGroupClass.defineAnnotatedMethods(RubyThreadGroup.class); - - // create the default thread group - RubyThreadGroup defaultThreadGroup = new RubyThreadGroup(runtime, threadGroupClass); - runtime.setDefaultThreadGroup(defaultThreadGroup); - threadGroupClass.defineConstant("Default", defaultThreadGroup); - - return threadGroupClass; - } - - @JRubyMethod(name = "new", frame = true, meta = true) - public static IRubyObject newInstance(IRubyObject recv, Block block) { - return new RubyThreadGroup(recv.getRuntime(), (RubyClass)recv); - } - - @JRubyMethod(name = "add", required = 1, frame = true) - public synchronized IRubyObject add(IRubyObject rubyThread, Block block) { - if (!(rubyThread instanceof RubyThread)) throw getRuntime().newTypeError(rubyThread, getRuntime().getThread()); - - // synchronize on the RubyThread for threadgroup updates - if (isFrozen()) { - throw getRuntime().newTypeError("can't add to frozen ThreadGroup"); - } - - RubyThread thread = (RubyThread)rubyThread; - - // we only add live threads - if (thread.alive_p().isTrue()) { - addDirectly(thread); - } - - return this; - } - - void addDirectly(RubyThread rubyThread) { - synchronized (rubyThread) { - IRubyObject oldGroup = rubyThread.group(); - if (oldGroup != getRuntime().getNil()) { - RubyThreadGroup threadGroup = (RubyThreadGroup) oldGroup; - threadGroup.rubyThreadList.remove(System.identityHashCode(rubyThread)); - } - - rubyThread.setThreadGroup(this); - rubyThreadList.put(System.identityHashCode(rubyThread), rubyThread); - } - } - - public synchronized void remove(RubyThread rubyThread) { - rubyThread.setThreadGroup(null); - rubyThreadList.remove(System.identityHashCode(rubyThread)); - } - - @JRubyMethod(name = "enclose", frame = true) - public IRubyObject enclose(Block block) { - enclosed = true; - - return this; - } - - @JRubyMethod(name = "enclosed?", frame = true) - public IRubyObject enclosed_p(Block block) { - return new RubyBoolean(getRuntime(), enclosed); - } - - @JRubyMethod(name = "list", frame = true) - public synchronized IRubyObject list(Block block) { - return getRuntime().newArrayNoCopy((IRubyObject[]) rubyThreadList.values().toArray(new IRubyObject[rubyThreadList.size()])); - } - - private RubyThreadGroup(Ruby runtime, RubyClass type) { - super(runtime, type); - } - -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2001 Chad Fowler <chadfowler@chadfowler.com> - * Copyright (C) 2001-2004 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002 Benoit Cerrina <b.cerrina@wanadoo.fr> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Joey Gibson <joey@joeygibson.com> - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * Copyright (C) 2006 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2006 Ola Bini <ola.bini@ki.se> - * Copyright (C) 2006 Miguel Covarrubias <mlcovarrubias@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.lang.ref.SoftReference; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.ClassIndex; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.util.ByteList; -import org.jruby.util.RubyDateFormat; - -/** The Time class. - * - * @author chadfowler, jpetersen - */ -@JRubyClass(name="Time", include="Comparable") -public class RubyTime extends RubyObject { - public static final String UTC = "UTC"; - private DateTime dt; - private long usec; - - private final static DateTimeFormatter ONE_DAY_CTIME_FORMATTER = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss yyyy").withLocale(Locale.ENGLISH); - private final static DateTimeFormatter TWO_DAY_CTIME_FORMATTER = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss yyyy").withLocale(Locale.ENGLISH); - - private final static DateTimeFormatter TO_S_FORMATTER = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss Z yyyy").withLocale(Locale.ENGLISH); - private final static DateTimeFormatter TO_S_UTC_FORMATTER = DateTimeFormat.forPattern("EEE MMM dd HH:mm:ss 'UTC' yyyy").withLocale(Locale.ENGLISH); - - // There are two different popular TZ formats: legacy (AST+3:00:00, GMT-3), and - // newer one (US/Pacific, America/Los_Angeles). This pattern is to detect - // the legacy TZ format in order to convert it to the newer format - // understood by Java API. - private static final Pattern TZ_PATTERN - = Pattern.compile("(\\D+?)([\\+-]?)(\\d+)(:\\d+)?(:\\d+)?"); - - private static final ByteList TZ_STRING = ByteList.create("TZ"); - - public static DateTimeZone getLocalTimeZone(Ruby runtime) { - RubyString tzVar = runtime.newString(TZ_STRING); - RubyHash h = ((RubyHash)runtime.getObject().fastGetConstant("ENV")); - IRubyObject tz = h.op_aref(runtime.getCurrentContext(), tzVar); - if (tz == null || ! (tz instanceof RubyString)) { - return DateTimeZone.getDefault(); - } else { - String zone = tz.toString(); - DateTimeZone cachedZone = runtime.getLocalTimezoneCache().get(zone); - - if (cachedZone != null) return cachedZone; - - String originalZone = zone; - - // Value of "TZ" property is of a bit different format, - // which confuses the Java's TimeZone.getTimeZone(id) method, - // and so, we need to convert it. - - Matcher tzMatcher = TZ_PATTERN.matcher(zone); - if (tzMatcher.matches()) { - String sign = tzMatcher.group(2); - String hours = tzMatcher.group(3); - String minutes = tzMatcher.group(4); - - // GMT+00:00 --> Etc/GMT, see "MRI behavior" - // comment below. - if (("00".equals(hours) || "0".equals(hours)) - && (minutes == null || ":00".equals(minutes) || ":0".equals(minutes))) { - zone = "Etc/GMT"; - } else { - // Invert the sign, since TZ format and Java format - // use opposite signs, sigh... Also, Java API requires - // the sign to be always present, be it "+" or "-". - sign = ("-".equals(sign)? "+" : "-"); - - // Always use "GMT" since that's required by Java API. - zone = "GMT" + sign + hours; - - if (minutes != null) { - zone += minutes; - } - } - } - - // MRI behavior: With TZ equal to "GMT" or "UTC", Time.now - // is *NOT* considered as a proper GMT/UTC time: - // ENV['TZ']="GMT" - // Time.now.gmt? ==> false - // ENV['TZ']="UTC" - // Time.now.utc? ==> false - // Hence, we need to adjust for that. - if ("GMT".equalsIgnoreCase(zone) || "UTC".equalsIgnoreCase(zone)) { - zone = "Etc/" + zone; - } - - DateTimeZone dtz = DateTimeZone.forTimeZone(TimeZone.getTimeZone(zone)); - runtime.getLocalTimezoneCache().put(originalZone, dtz); - return dtz; - } - } - - public RubyTime(Ruby runtime, RubyClass rubyClass) { - super(runtime, rubyClass); - } - - public RubyTime(Ruby runtime, RubyClass rubyClass, DateTime dt) { - super(runtime, rubyClass); - this.dt = dt; - } - - // We assume that these two time instances - // occurred at the same time. - private static final long BASE_TIME_MILLIS = System.currentTimeMillis(); - private static final long BASE_TIME_NANOS = System.nanoTime(); - - private static ObjectAllocator TIME_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - long usecsPassed = (System.nanoTime() - BASE_TIME_NANOS) / 1000L; - long millisTime = BASE_TIME_MILLIS + usecsPassed / 1000L; - long usecs = usecsPassed % 1000L; - - DateTimeZone dtz = getLocalTimeZone(runtime); - DateTime dt = new DateTime(millisTime, dtz); - RubyTime rt = new RubyTime(runtime, klass, dt); - rt.setUSec(usecs); - - return rt; - } - }; - - public static RubyClass createTimeClass(Ruby runtime) { - RubyClass timeClass = runtime.defineClass("Time", runtime.getObject(), TIME_ALLOCATOR); - timeClass.index = ClassIndex.TIME; - runtime.setTime(timeClass); - - timeClass.includeModule(runtime.getComparable()); - - timeClass.defineAnnotatedMethods(RubyTime.class); - - return timeClass; - } - - public void setUSec(long usec) { - this.usec = usec; - } - - public long getUSec() { - return usec; - } - - public void updateCal(DateTime dt) { - this.dt = dt; - } - - protected long getTimeInMillis() { - return dt.getMillis(); // For JDK 1.4 we can use "cal.getTimeInMillis()" - } - - public static RubyTime newTime(Ruby runtime, long milliseconds) { - return newTime(runtime, new DateTime(milliseconds)); - } - - public static RubyTime newTime(Ruby runtime, DateTime dt) { - return new RubyTime(runtime, runtime.getTime(), dt); - } - - public static RubyTime newTime(Ruby runtime, DateTime dt, long usec) { - RubyTime t = new RubyTime(runtime, runtime.getTime(), dt); - t.setUSec(usec); - return t; - } - - @Override - public Class<?> getJavaClass() { - return Date.class; - } - - @JRubyMethod(name = "initialize_copy", required = 1) - @Override - public IRubyObject initialize_copy(IRubyObject original) { - if (!(original instanceof RubyTime)) { - throw getRuntime().newTypeError("Expecting an instance of class Time"); - } - - RubyTime originalTime = (RubyTime) original; - - // We can just use dt, since it is immutable - dt = originalTime.dt; - usec = originalTime.usec; - - return this; - } - - @JRubyMethod(name = "succ") - public RubyTime succ() { - return newTime(getRuntime(),dt.plusSeconds(1)); - } - - @JRubyMethod(name = {"gmtime", "utc"}) - public RubyTime gmtime() { - dt = dt.withZone(DateTimeZone.UTC); - return this; - } - - @JRubyMethod(name = "localtime") - public RubyTime localtime() { - dt = dt.withZone(getLocalTimeZone(getRuntime())); - return this; - } - - @JRubyMethod(name = {"gmt?", "utc?", "gmtime?"}) - public RubyBoolean gmt() { - return getRuntime().newBoolean(dt.getZone().getID().equals("UTC")); - } - - @JRubyMethod(name = {"getgm", "getutc"}) - public RubyTime getgm() { - return newTime(getRuntime(), dt.withZone(DateTimeZone.UTC), getUSec()); - } - - @JRubyMethod(name = "getlocal") - public RubyTime getlocal() { - return newTime(getRuntime(), dt.withZone(getLocalTimeZone(getRuntime())), getUSec()); - } - - @JRubyMethod(name = "strftime", required = 1) - public RubyString strftime(IRubyObject format) { - final RubyDateFormat rubyDateFormat = new RubyDateFormat("-", Locale.US); - rubyDateFormat.applyPattern(format.toString()); - rubyDateFormat.setDateTime(dt); - String result = rubyDateFormat.format(null); - return getRuntime().newString(result); - } - - @JRubyMethod(name = ">=", required = 1) - public IRubyObject op_ge(ThreadContext context, IRubyObject other) { - if (other instanceof RubyTime) { - return getRuntime().newBoolean(cmp((RubyTime) other) >= 0); - } - - return RubyComparable.op_ge(context, this, other); - } - - @JRubyMethod(name = ">", required = 1) - public IRubyObject op_gt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyTime) { - return getRuntime().newBoolean(cmp((RubyTime) other) > 0); - } - - return RubyComparable.op_gt(context, this, other); - } - - @JRubyMethod(name = "<=", required = 1) - public IRubyObject op_le(ThreadContext context, IRubyObject other) { - if (other instanceof RubyTime) { - return getRuntime().newBoolean(cmp((RubyTime) other) <= 0); - } - - return RubyComparable.op_le(context, this, other); - } - - @JRubyMethod(name = "<", required = 1) - public IRubyObject op_lt(ThreadContext context, IRubyObject other) { - if (other instanceof RubyTime) { - return getRuntime().newBoolean(cmp((RubyTime) other) < 0); - } - - return RubyComparable.op_lt(context, this, other); - } - - private int cmp(RubyTime other) { - long millis = getTimeInMillis(); - long millis_other = other.getTimeInMillis(); - long usec_other = other.usec; - - if (millis > millis_other || (millis == millis_other && usec > usec_other)) { - return 1; - } else if (millis < millis_other || (millis == millis_other && usec < usec_other)) { - return -1; - } - - return 0; - } - - @JRubyMethod(name = "+", required = 1) - public IRubyObject op_plus(IRubyObject other) { - long time = getTimeInMillis(); - - if (other instanceof RubyTime) { - throw getRuntime().newTypeError("time + time ?"); - } - long adjustment = (long) (RubyNumeric.num2dbl(other) * 1000000); - int micro = (int) (adjustment % 1000); - adjustment = adjustment / 1000; - - time += adjustment; - - RubyTime newTime = new RubyTime(getRuntime(), getMetaClass()); - newTime.dt = new DateTime(time).withZone(dt.getZone()); - newTime.setUSec(micro); - - return newTime; - } - - private IRubyObject opMinus(RubyTime other) { - long time = getTimeInMillis() * 1000 + getUSec(); - - time -= other.getTimeInMillis() * 1000 + other.getUSec(); - - return RubyFloat.newFloat(getRuntime(), time / 1000000.0); // float number of seconds - } - - @JRubyMethod(name = "-", required = 1) - public IRubyObject op_minus(IRubyObject other) { - if (other instanceof RubyTime) return opMinus((RubyTime) other); - - long time = getTimeInMillis(); - long adjustment = (long) (RubyNumeric.num2dbl(other) * 1000000); - int micro = (int) (adjustment % 1000); - adjustment = adjustment / 1000; - - time -= adjustment; - - RubyTime newTime = new RubyTime(getRuntime(), getMetaClass()); - newTime.dt = new DateTime(time).withZone(dt.getZone()); - newTime.setUSec(micro); - - return newTime; - } - - @JRubyMethod(name = "===", required = 1) - @Override - public IRubyObject op_eqq(ThreadContext context, IRubyObject other) { - return (RubyNumeric.fix2int(callMethod(context, MethodIndex.OP_SPACESHIP, "<=>", other)) == 0) ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "<=>", required = 1) - public IRubyObject op_cmp(ThreadContext context, IRubyObject other) { - if (other instanceof RubyTime) { - return context.getRuntime().newFixnum(cmp((RubyTime) other)); - } - - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "eql?", required = 1) - @Override - public IRubyObject eql_p(IRubyObject other) { - if (other instanceof RubyTime) { - RubyTime otherTime = (RubyTime)other; - return (usec == otherTime.usec && getTimeInMillis() == otherTime.getTimeInMillis()) ? getRuntime().getTrue() : getRuntime().getFalse(); - } - return getRuntime().getFalse(); - } - - @JRubyMethod(name = {"asctime", "ctime"}) - public RubyString asctime() { - DateTimeFormatter simpleDateFormat; - - if (dt.getDayOfMonth() < 10) { - simpleDateFormat = ONE_DAY_CTIME_FORMATTER; - } else { - simpleDateFormat = TWO_DAY_CTIME_FORMATTER; - } - String result = simpleDateFormat.print(dt); - return getRuntime().newString(result); - } - - @JRubyMethod(name = {"to_s", "inspect"}) - @Override - public IRubyObject to_s() { - DateTimeFormatter simpleDateFormat; - if (dt.getZone() == DateTimeZone.UTC) { - simpleDateFormat = TO_S_UTC_FORMATTER; - } else { - simpleDateFormat = TO_S_FORMATTER; - } - - String result = simpleDateFormat.print(dt); - - return getRuntime().newString(result); - } - - @JRubyMethod(name = "to_a") - @Override - public RubyArray to_a() { - return getRuntime().newArrayNoCopy(new IRubyObject[] { sec(), min(), hour(), mday(), month(), - year(), wday(), yday(), isdst(), zone() }); - } - - @JRubyMethod(name = "to_f") - public RubyFloat to_f() { - long time = getTimeInMillis(); - time = time * 1000 + usec; - return RubyFloat.newFloat(getRuntime(), time / 1000000.0); - } - - @JRubyMethod(name = {"to_i", "tv_sec"}) - public RubyInteger to_i() { - return getRuntime().newFixnum(getTimeInMillis() / 1000); - } - - @JRubyMethod(name = {"usec", "tv_usec"}) - public RubyInteger usec() { - return getRuntime().newFixnum(dt.getMillisOfSecond() * 1000 + getUSec()); - } - - public void setMicroseconds(long mic) { - long millis = getTimeInMillis() % 1000; - long withoutMillis = getTimeInMillis() - millis; - withoutMillis += (mic / 1000); - dt = dt.withMillis(withoutMillis); - usec = mic % 1000; - } - - public long microseconds() { - return getTimeInMillis() % 1000 * 1000 + usec; - } - - @JRubyMethod(name = "sec") - public RubyInteger sec() { - return getRuntime().newFixnum(dt.getSecondOfMinute()); - } - - @JRubyMethod(name = "min") - public RubyInteger min() { - return getRuntime().newFixnum(dt.getMinuteOfHour()); - } - - @JRubyMethod(name = "hour") - public RubyInteger hour() { - return getRuntime().newFixnum(dt.getHourOfDay()); - } - - @JRubyMethod(name = {"mday", "day"}) - public RubyInteger mday() { - return getRuntime().newFixnum(dt.getDayOfMonth()); - } - - @JRubyMethod(name = {"month", "mon"}) - public RubyInteger month() { - return getRuntime().newFixnum(dt.getMonthOfYear()); - } - - @JRubyMethod(name = "year") - public RubyInteger year() { - return getRuntime().newFixnum(dt.getYear()); - } - - @JRubyMethod(name = "wday") - public RubyInteger wday() { - return getRuntime().newFixnum((dt.getDayOfWeek()%7)); - } - - @JRubyMethod(name = "yday") - public RubyInteger yday() { - return getRuntime().newFixnum(dt.getDayOfYear()); - } - - @JRubyMethod(name = {"gmt_offset", "gmtoff", "utc_offset"}) - public RubyInteger gmt_offset() { - int offset = dt.getZone().getOffsetFromLocal(dt.getMillis()); - - return getRuntime().newFixnum((int)(offset/1000)); - } - - @JRubyMethod(name = {"isdst", "dst?"}) - public RubyBoolean isdst() { - return getRuntime().newBoolean(!dt.getZone().isStandardOffset(dt.getMillis())); - } - - @JRubyMethod(name = "zone") - public RubyString zone() { - String zone = dt.getZone().getShortName(dt.getMillis()); - if(zone.equals("+00:00")) { - zone = "GMT"; - } - return getRuntime().newString(zone); - } - - public void setDateTime(DateTime dt) { - this.dt = dt; - } - - public DateTime getDateTime() { - return this.dt; - } - - public Date getJavaDate() { - return this.dt.toDate(); - } - - @JRubyMethod(name = "hash") - @Override - public RubyFixnum hash() { - // modified to match how hash is calculated in 1.8.2 - return getRuntime().newFixnum((int)(((dt.getMillis() / 1000) ^ microseconds()) << 1) >> 1); - } - - @JRubyMethod(name = "_dump", optional = 1, frame = true) - public RubyString dump(IRubyObject[] args, Block unusedBlock) { - RubyString str = (RubyString) mdump(new IRubyObject[] { this }); - str.syncVariables(this.getVariableList()); - return str; - } - - public RubyObject mdump(final IRubyObject[] args) { - RubyTime obj = (RubyTime)args[0]; - DateTime dateTime = obj.dt.withZone(DateTimeZone.UTC); - byte dumpValue[] = new byte[8]; - int pe = - 0x1 << 31 | - (dateTime.getYear()-1900) << 14 | - (dateTime.getMonthOfYear()-1) << 10 | - dateTime.getDayOfMonth() << 5 | - dateTime.getHourOfDay(); - int se = - dateTime.getMinuteOfHour() << 26 | - dateTime.getSecondOfMinute() << 20 | - (dateTime.getMillisOfSecond() * 1000 + (int)usec); // dump usec, not msec - - for(int i = 0; i < 4; i++) { - dumpValue[i] = (byte)(pe & 0xFF); - pe >>>= 8; - } - for(int i = 4; i < 8 ;i++) { - dumpValue[i] = (byte)(se & 0xFF); - se >>>= 8; - } - return RubyString.newString(obj.getRuntime(), new ByteList(dumpValue,false)); - } - - @JRubyMethod(name = "initialize", frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(Block block) { - return this; - } - - /* Time class methods */ - - public static IRubyObject s_new(IRubyObject recv, IRubyObject[] args, Block block) { - Ruby runtime = recv.getRuntime(); - RubyTime time = new RubyTime(runtime, (RubyClass) recv, new DateTime(getLocalTimeZone(runtime))); - time.callInit(args,block); - return time; - } - - /** - * @deprecated Use {@link #newInstance(ThreadContext, IRubyObject)} - */ - @Deprecated - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) { - return newInstance(context, recv); - } - - @JRubyMethod(name = "now", backtrace = true, meta = true) - public static IRubyObject newInstance(ThreadContext context, IRubyObject recv) { - IRubyObject obj = ((RubyClass) recv).allocate(); - obj.getMetaClass().getBaseCallSites()[RubyClass.CS_IDX_INITIALIZE].call(context, obj); - return obj; - } - - @JRubyMethod(name = "at", meta = true) - public static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg) { - Ruby runtime = context.getRuntime(); - final RubyTime time; - - if (arg instanceof RubyTime) { - RubyTime other = (RubyTime) arg; - time = new RubyTime(runtime, (RubyClass) recv, other.dt); - time.setUSec(other.getUSec()); - } else { - time = new RubyTime(runtime, (RubyClass) recv, - new DateTime(0L, getLocalTimeZone(runtime))); - - long seconds = RubyNumeric.num2long(arg); - long millisecs = 0; - long microsecs = 0; - - // In the case of two arguments, MRI will discard the portion of - // the first argument after a decimal point (i.e., "floor"). - // However in the case of a single argument, any portion after - // the decimal point is honored. - if (arg instanceof RubyFloat) { - double dbl = ((RubyFloat) arg).getDoubleValue(); - long micro = (long) ((dbl - seconds) * 1000000); - millisecs = micro / 1000; - microsecs = micro % 1000; - } - time.setUSec(microsecs); - time.dt = time.dt.withMillis(seconds * 1000 + millisecs); - } - - time.getMetaClass().getBaseCallSites()[RubyClass.CS_IDX_INITIALIZE].call(context, time); - - return time; - } - - @JRubyMethod(name = "at", meta = true) - public static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2) { - Ruby runtime = context.getRuntime(); - - RubyTime time = new RubyTime(runtime, (RubyClass) recv, - new DateTime(0L, getLocalTimeZone(runtime))); - - long seconds = RubyNumeric.num2long(arg1); - long millisecs = 0; - long microsecs = 0; - - long tmp = RubyNumeric.num2long(arg2); - millisecs = tmp / 1000; - microsecs = tmp % 1000; - - time.setUSec(microsecs); - time.dt = time.dt.withMillis(seconds * 1000 + millisecs); - - time.getMetaClass().getBaseCallSites()[RubyClass.CS_IDX_INITIALIZE].call(context, time); - - return time; - } - - @JRubyMethod(name = {"local", "mktime"}, required = 1, optional = 9, meta = true) - public static RubyTime new_local(IRubyObject recv, IRubyObject[] args) { - return createTime(recv, args, false); - } - - @JRubyMethod(name = {"utc", "gm"}, required = 1, optional = 9, meta = true) - public static RubyTime new_utc(IRubyObject recv, IRubyObject[] args) { - return createTime(recv, args, true); - } - - @JRubyMethod(name = "_load", required = 1, frame = true, meta = true) - public static RubyTime load(IRubyObject recv, IRubyObject from, Block block) { - return s_mload(recv, (RubyTime)(((RubyClass)recv).allocate()), from); - } - - protected static RubyTime s_mload(IRubyObject recv, RubyTime time, IRubyObject from) { - Ruby runtime = recv.getRuntime(); - - DateTime dt = new DateTime(DateTimeZone.UTC); - - byte[] fromAsBytes = null; - fromAsBytes = from.convertToString().getBytes(); - if(fromAsBytes.length != 8) { - throw runtime.newTypeError("marshaled time format differ"); - } - int p=0; - int s=0; - for (int i = 0; i < 4; i++) { - p |= ((int)fromAsBytes[i] & 0xFF) << (8 * i); - } - for (int i = 4; i < 8; i++) { - s |= ((int)fromAsBytes[i] & 0xFF) << (8 * (i - 4)); - } - if ((p & (1<<31)) == 0) { - dt = dt.withMillis(p * 1000L + s); - } else { - p &= ~(1<<31); - dt = dt.withYear(((p >>> 14) & 0xFFFF) + 1900); - dt = dt.withMonthOfYear(((p >>> 10) & 0xF) + 1); - dt = dt.withDayOfMonth(((p >>> 5) & 0x1F)); - dt = dt.withHourOfDay((p & 0x1F)); - dt = dt.withMinuteOfHour(((s >>> 26) & 0x3F)); - dt = dt.withSecondOfMinute(((s >>> 20) & 0x3F)); - // marsaling dumps usec, not msec - dt = dt.withMillisOfSecond((s & 0xFFFFF) / 1000); - dt = dt.withZone(getLocalTimeZone(runtime)); - time.setUSec((s & 0xFFFFF) % 1000); - } - time.setDateTime(dt); - return time; - } - - private static final String[] MONTHS = {"jan", "feb", "mar", "apr", "may", "jun", - "jul", "aug", "sep", "oct", "nov", "dec"}; - - private static final Map<String, Integer> MONTHS_MAP = new HashMap<String, Integer>(); - static { - for (int i = 0; i < MONTHS.length; i++) { - MONTHS_MAP.put(MONTHS[i], i + 1); - } - } - - private static final int[] time_min = {1, 0, 0, 0, Integer.MIN_VALUE}; - private static final int[] time_max = {31, 23, 59, 60, Integer.MAX_VALUE}; - - private static final int ARG_SIZE = 7; - - private static RubyTime createTime(IRubyObject recv, IRubyObject[] args, boolean gmt) { - Ruby runtime = recv.getRuntime(); - int len = ARG_SIZE; - - if (args.length == 10) { - args = new IRubyObject[] { args[5], args[4], args[3], args[2], args[1], args[0], runtime.getNil() }; - } else { - // MRI accepts additional wday argument which appears to be ignored. - len = args.length; - - if (len < ARG_SIZE) { - IRubyObject[] newArgs = new IRubyObject[ARG_SIZE]; - System.arraycopy(args, 0, newArgs, 0, args.length); - for (int i = len; i < ARG_SIZE; i++) { - newArgs[i] = runtime.getNil(); - } - args = newArgs; - len = ARG_SIZE; - } - } - - if (args[0] instanceof RubyString) { - args[0] = RubyNumeric.str2inum(runtime, (RubyString) args[0], 10, false); - } - - int year = (int) RubyNumeric.num2long(args[0]); - int month = 1; - - if (len > 1) { - if (!args[1].isNil()) { - IRubyObject tmp = args[1].checkStringType(); - if (!tmp.isNil()) { - String monthString = tmp.toString().toLowerCase(); - Integer monthInt = MONTHS_MAP.get(monthString); - - if (monthInt != null) { - month = monthInt; - } else { - try { - month = Integer.parseInt(monthString); - } catch (NumberFormatException nfExcptn) { - throw runtime.newArgumentError("Argument out of range."); - } - } - } else { - month = (int) RubyNumeric.num2long(args[1]); - } - } - if (1 > month || month > 12) { - throw runtime.newArgumentError("Argument out of range: for month: " + month); - } - } - - int[] int_args = { 1, 0, 0, 0, 0, 0 }; - - for (int i = 0; int_args.length >= i + 2; i++) { - if (!args[i + 2].isNil()) { - if (!(args[i + 2] instanceof RubyNumeric)) { - args[i + 2] = args[i + 2].callMethod( - runtime.getCurrentContext(), "to_i"); - } - - long value = RubyNumeric.num2long(args[i + 2]); - if (time_min[i] > value || value > time_max[i]) { - throw runtime.newArgumentError("argument out of range."); - } - int_args[i] = (int) value; - } - } - - if (0 <= year && year < 39) { - year += 2000; - } else if (69 <= year && year < 139) { - year += 1900; - } - - DateTimeZone dtz; - if (gmt) { - dtz = DateTimeZone.UTC; - } else { - dtz = getLocalTimeZone(runtime); - } - - DateTime dt; - // set up with min values and then add to allow rolling over - try { - dt = new DateTime(year, 1, 1, 0, 0 , 0, 0, dtz); - - dt = dt.plusMonths(month - 1) - .plusDays(int_args[0] - 1) - .plusHours(int_args[1]) - .plusMinutes(int_args[2]) - .plusSeconds(int_args[3]); - } catch (org.joda.time.IllegalFieldValueException e) { - throw runtime.newArgumentError("time out of range"); - } - - RubyTime time = new RubyTime(runtime, (RubyClass) recv, dt); - // Ignores usec if 8 args (for compatibility with parsedate) or if not supplied. - if (args.length != 8 && !args[6].isNil()) { - int usec = int_args[4] % 1000; - int msec = int_args[4] / 1000; - - if (int_args[4] < 0) { - msec -= 1; - usec += 1000; - } - time.dt = dt.withMillis(dt.getMillis() + msec); - time.setUSec(usec); - } - - time.callInit(IRubyObject.NULL_ARRAY, Block.NULL_BLOCK); - return time; - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2004 Charles O Nutter <headius@headius.com> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.internal.runtime.methods.DynamicMethod; -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -/** - * - * Note: This was renamed from UnboundMethod.java - * - * @author jpetersen - */ -@JRubyClass(name="UnboundMethod", parent="Method") -public class RubyUnboundMethod extends RubyMethod { - protected RubyUnboundMethod(Ruby runtime) { - super(runtime, runtime.getUnboundMethod()); - } - - public static RubyUnboundMethod newUnboundMethod( - RubyModule implementationModule, - String methodName, - RubyModule originModule, - String originName, - DynamicMethod method) { - RubyUnboundMethod newMethod = new RubyUnboundMethod(implementationModule.getRuntime()); - - newMethod.implementationModule = implementationModule; - newMethod.methodName = methodName; - newMethod.originModule = originModule; - newMethod.originName = originName; - newMethod.method = method; - - return newMethod; - } - - public static RubyClass defineUnboundMethodClass(Ruby runtime) { - // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415 - RubyClass newClass = - runtime.defineClass("UnboundMethod", runtime.getMethod(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - runtime.setUnboundMethod(newClass); - - newClass.defineAnnotatedMethods(RubyUnboundMethod.class); - - return newClass; - } - - /** - * @see org.jruby.RubyMethod#call(IRubyObject[]) - */ - @JRubyMethod(name = {"call", "[]"}, rest = true, frame = true) - @Override - public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) { - throw context.getRuntime().newTypeError("you cannot call unbound method; bind first"); - } - - /** - * @see org.jruby.RubyMethod#unbind() - */ - @JRubyMethod(name = "unbind", frame = true) - @Override - public RubyUnboundMethod unbind(Block block) { - return this; - } - - @JRubyMethod(name = "bind", required = 1, frame = true) - public RubyMethod bind(ThreadContext context, IRubyObject aReceiver, Block block) { - RubyClass receiverClass = aReceiver.getMetaClass(); - - if (!originModule.isInstance(aReceiver)) { - if (originModule instanceof MetaClass) { - throw context.getRuntime().newTypeError("singleton method called for a different object"); - } else if (receiverClass instanceof MetaClass && receiverClass.getMethods().containsKey(originName)) { - throw context.getRuntime().newTypeError("method `" + originName + "' overridden"); - } else if ( - !(originModule.isModule() ? originModule.isInstance(aReceiver) : aReceiver.getType() == originModule)) { - // FIX replace type() == ... with isInstanceOf(...) - throw context.getRuntime().newTypeError("bind argument must be an instance of " + originModule.getName()); - } - } - return RubyMethod.newMethod(implementationModule, methodName, receiverClass, originName, method, aReceiver); - } - - @JRubyMethod(name = "clone") - @Override - public RubyMethod rbClone() { - return newUnboundMethod(implementationModule, methodName, originModule, originName, method); - } - - @JRubyMethod(name = "to_proc", frame = true) - @Override - public IRubyObject to_proc(ThreadContext context, Block unusedBlock) { - return super.to_proc(context, unusedBlock); - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2007 Ola Bini <ola.bini@gmail.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.IOException; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import java.util.regex.Pattern; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyModule; - -import org.jruby.runtime.Block; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.builtin.IRubyObject; - -import org.jruby.javasupport.JavaEmbedUtils; - -import org.jruby.javasupport.JavaUtil; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.MethodIndex; -import org.jruby.runtime.Visibility; - -import org.jruby.yaml.JRubyRepresenter; -import org.jruby.yaml.JRubyConstructor; -import org.jruby.yaml.JRubySerializer; -import org.jruby.util.IOInputStream; -import org.jruby.util.IOOutputStream; - -import org.jvyamlb.Representer; -import org.jvyamlb.Constructor; -import org.jvyamlb.ParserImpl; -import org.jvyamlb.PositioningParserImpl; -import org.jvyamlb.Scanner; -import org.jvyamlb.ScannerImpl; -import org.jvyamlb.Composer; -import org.jvyamlb.ComposerImpl; -import org.jvyamlb.PositioningScannerImpl; -import org.jvyamlb.PositioningComposerImpl; -import org.jvyamlb.Serializer; -import org.jvyamlb.ResolverImpl; -import org.jvyamlb.EmitterImpl; -import org.jvyamlb.exceptions.YAMLException; -import org.jvyamlb.YAMLConfig; -import org.jvyamlb.YAML; -import org.jvyamlb.PositioningScanner; -import org.jvyamlb.Positionable; -import org.jvyamlb.Position; - -/** - * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a> - */ -@JRubyModule(name="YAML") -public class RubyYAML { - public static RubyModule createYAMLModule(Ruby runtime) { - RubyModule result = runtime.defineModule("YAML"); - - runtime.getKernel().callMethod(runtime.getCurrentContext(),"require", runtime.newString("stringio")); - - result.defineAnnotatedMethods(RubyYAML.class); - - RubyClass obj = runtime.getObject(); - RubyClass clazz = runtime.getClassClass(); - RubyClass hash = runtime.getHash(); - RubyClass array = runtime.getArray(); - RubyClass struct = runtime.getStructClass(); - RubyClass exception = runtime.getException(); - RubyClass string = runtime.getString(); - RubyClass symbol = runtime.getSymbol(); - RubyClass range = runtime.getRange(); - RubyClass regexp = runtime.getRegexp(); - RubyClass time = runtime.getTime(); - RubyClass date = runtime.fastGetClass("Date"); - RubyClass fixnum = runtime.getFixnum(); - RubyClass bignum = runtime.getBignum(); - RubyClass flt = runtime.getFloat(); - RubyClass trueClass = runtime.getTrueClass(); - RubyClass falseClass = runtime.getFalseClass(); - RubyClass nilClass = runtime.getNilClass(); - - clazz.defineAnnotatedMethods(YAMLClassMethods.class); - - obj.defineAnnotatedMethods(YAMLObjectMethods.class); - - hash.defineAnnotatedMethods(YAMLHashMethods.class); - - array.defineAnnotatedMethods(YAMLArrayMethods.class); - - struct.defineAnnotatedMethods(YAMLStructMethods.class); - - exception.defineAnnotatedMethods(YAMLExceptionMethods.class); - - string.defineAnnotatedMethods(YAMLStringMethods.class); - - symbol.defineAnnotatedMethods(YAMLSymbolMethods.class); - - range.defineAnnotatedMethods(YAMLRangeMethods.class); - - regexp.defineAnnotatedMethods(YAMLRegexpMethods.class); - - time.defineAnnotatedMethods(YAMLTimeMethods.class); - - date.defineAnnotatedMethods(YAMLDateMethods.class); - - bignum.defineAnnotatedMethods(YAMLNumericMethods.class); - - fixnum.defineAnnotatedMethods(YAMLNumericMethods.class); - - flt.defineAnnotatedMethods(YAMLNumericMethods.class); - - trueClass.defineAnnotatedMethods(YAMLTrueMethods.class); - - falseClass.defineAnnotatedMethods(YAMLFalseMethods.class); - - nilClass.defineAnnotatedMethods(YAMLNilMethods.class); - - runtime.setObjectToYamlMethod(runtime.getObject().searchMethod("to_yaml")); - - return result; - } - - @JRubyMethod(name = "dump", required = 1, optional = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject dump(IRubyObject self, IRubyObject[] args) { - IRubyObject obj = args[0]; - Ruby runtime = self.getRuntime(); - IRubyObject val = runtime.newArray(obj); - if(args.length>1) { - return RuntimeHelpers.invoke(runtime.getCurrentContext(), self,"dump_all", val, args[1]); - } else { - return self.callMethod(runtime.getCurrentContext(),"dump_all", val); - } - } - - @JRubyMethod(name = "dump_all", required = 1, optional = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject dump_all(IRubyObject self, IRubyObject[] args) { - ThreadContext context = self.getRuntime().getCurrentContext(); - RubyArray objs = (RubyArray)args[0]; - IRubyObject io = null; - IRubyObject io2 = null; - if(args.length == 2 && args[1] != null && !args[1].isNil()) { - io = args[1]; - } - YAMLConfig cfg = YAML.config().version("1.0"); - IOOutputStream iox = null; - if(null == io) { - io2 = self.getRuntime().fastGetClass("StringIO").callMethod(context, "new"); - iox = new IOOutputStream(io2); - } else { - iox = new IOOutputStream(io); - } - Serializer ser = new JRubySerializer(new EmitterImpl(iox,cfg),new ResolverImpl(),cfg); - try { - ser.open(); - Representer r = new JRubyRepresenter(ser, cfg); - for(Iterator iter = objs.getList().iterator();iter.hasNext();) { - r.represent(iter.next()); - } - ser.close(); - } catch(IOException e) { - throw self.getRuntime().newIOErrorFromException(e); - } - if(null == io) { - io2.callMethod(context, "rewind"); - return io2.callMethod(context, "read"); - } else { - return io; - } - } - - @JRubyMethod(name = "_parse_internal", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject parse_internal(IRubyObject self, IRubyObject arg) { - boolean debug = self.getRuntime().getDebug().isTrue(); - IRubyObject io = check_yaml_port(arg); - Scanner scn = null; - try { - if(io instanceof RubyString) { - scn = debug ? new PositioningScannerImpl(((RubyString)io).getByteList()) : new ScannerImpl(((RubyString)io).getByteList()); - } else { - scn = debug ? new PositioningScannerImpl(new IOInputStream(io)) : new ScannerImpl(new IOInputStream(io)); - } - Composer ctor = - debug ? - new PositioningComposerImpl(new PositioningParserImpl((PositioningScanner)scn,YAML.config().version("1.0")),new ResolverImpl()) : - new ComposerImpl(new ParserImpl(scn,YAML.config().version("1.0")),new ResolverImpl()) - ; - if(ctor.checkNode()) { - return JavaEmbedUtils.javaToRuby(self.getRuntime(),ctor.getNode()); - } - return self.getRuntime().getNil(); - } catch(YAMLException e) { - if(self.getRuntime().getDebug().isTrue()) { - Position.Range range = ((Positionable)e).getRange(); - throw self.getRuntime().newArgumentError("syntax error on " + range.start + ":" + range.end + ": " + e.getMessage()); - } else { - throw self.getRuntime().newArgumentError("syntax error:" + e.getMessage()); - } - } - } - - @JRubyMethod(name = "load", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject load(IRubyObject self, IRubyObject arg) { - boolean debug = self.getRuntime().getDebug().isTrue(); - IRubyObject io = check_yaml_port(arg); - Scanner scn = null; - try { - if(io instanceof RubyString) { - scn = debug ? new PositioningScannerImpl(((RubyString)io).getByteList()) : new ScannerImpl(((RubyString)io).getByteList()); - } else { - scn = debug ? new PositioningScannerImpl(new IOInputStream(io)) : new ScannerImpl(new IOInputStream(io)); - } - Constructor ctor = - debug ? - new JRubyConstructor(self, new PositioningComposerImpl(new PositioningParserImpl((PositioningScanner)scn,YAML.config().version("1.0")),new ResolverImpl())) : - new JRubyConstructor(self, new ComposerImpl(new ParserImpl(scn,YAML.config().version("1.0")),new ResolverImpl())) - ; - if(ctor.checkData()) { - return JavaEmbedUtils.javaToRuby(self.getRuntime(),ctor.getData()); - } - return self.getRuntime().getNil(); - } catch(YAMLException e) { - if(self.getRuntime().getDebug().isTrue()) { - Position.Range range = ((Positionable)e).getRange(); - throw self.getRuntime().newArgumentError("syntax error on " + range.start + ":" + range.end + ": " + e.getMessage()); - } else { - throw self.getRuntime().newArgumentError("syntax error:" + e.getMessage()); - } - } - } - - @JRubyMethod(name = "load_file", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject load_file(IRubyObject self, IRubyObject arg) { - Ruby runtime = self.getRuntime(); - ThreadContext context = runtime.getCurrentContext(); - IRubyObject io = RuntimeHelpers.invoke(context, runtime.getFile(),"open", arg, runtime.newString("r")); - IRubyObject val = self.callMethod(context,"load", io); - io.callMethod(context, "close"); - return val; - } - - @JRubyMethod(name = "each_document", required = 1, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject each_document(IRubyObject self, IRubyObject arg, Block block) { - boolean debug = self.getRuntime().getDebug().isTrue(); - ThreadContext context = self.getRuntime().getCurrentContext(); - IRubyObject io = arg; - Scanner scn = null; - try { - if(io instanceof RubyString) { - scn = debug ? new PositioningScannerImpl(((RubyString)io).getByteList()) : new ScannerImpl(((RubyString)io).getByteList()); - } else { - scn = debug ? new PositioningScannerImpl(new IOInputStream(io)) : new ScannerImpl(new IOInputStream(io)); - } - Constructor ctor = - debug ? - new JRubyConstructor(self, new PositioningComposerImpl(new PositioningParserImpl((PositioningScanner)scn,YAML.config().version("1.0")),new ResolverImpl())) : - new JRubyConstructor(self, new ComposerImpl(new ParserImpl(scn,YAML.config().version("1.0")),new ResolverImpl())) - ; - while(ctor.checkData()) { - block.yield(context, JavaEmbedUtils.javaToRuby(self.getRuntime(),ctor.getData())); - } - return self.getRuntime().getNil(); - } catch(YAMLException e) { - if(self.getRuntime().getDebug().isTrue()) { - Position.Range range = ((Positionable)e).getRange(); - throw self.getRuntime().newArgumentError("syntax error on " + range.start + ":" + range.end + ": " + e.getMessage()); - } else { - throw self.getRuntime().newArgumentError("syntax error:" + e.getMessage()); - } - } - } - - @JRubyMethod(name = "load_documents", required = 1, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject load_documents(IRubyObject self, IRubyObject arg, Block block) { - boolean debug = self.getRuntime().getDebug().isTrue(); - ThreadContext context = self.getRuntime().getCurrentContext(); - IRubyObject io = check_yaml_port(arg); - Scanner scn = null; - try { - if(io instanceof RubyString) { - scn = debug ? new PositioningScannerImpl(((RubyString)io).getByteList()) : new ScannerImpl(((RubyString)io).getByteList()); - } else { - scn = debug ? new PositioningScannerImpl(new IOInputStream(io)) : new ScannerImpl(new IOInputStream(io)); - } - Constructor ctor = - debug ? - new JRubyConstructor(self, new PositioningComposerImpl(new PositioningParserImpl((PositioningScanner)scn,YAML.config().version("1.0")),new ResolverImpl())) : - new JRubyConstructor(self, new ComposerImpl(new ParserImpl(scn,YAML.config().version("1.0")),new ResolverImpl())) - ; - while(ctor.checkData()) { - block.yield(context, JavaEmbedUtils.javaToRuby(self.getRuntime(),ctor.getData())); - } - return self.getRuntime().getNil(); - } catch(YAMLException e) { - if(self.getRuntime().getDebug().isTrue()) { - Position.Range range = ((Positionable)e).getRange(); - throw self.getRuntime().newArgumentError("syntax error on " + range.start + ":" + range.end + ": " + e.getMessage()); - } else { - throw self.getRuntime().newArgumentError("syntax error:" + e.getMessage()); - } - } - } - - @JRubyMethod(name = "load_stream", required = 1, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject load_stream(IRubyObject self, IRubyObject arg) { - boolean debug = self.getRuntime().getDebug().isTrue(); - ThreadContext context = self.getRuntime().getCurrentContext(); - IRubyObject d = self.getRuntime().getNil(); - IRubyObject io = arg; - Scanner scn = null; - try { - if(io instanceof RubyString) { - scn = debug ? new PositioningScannerImpl(((RubyString)io).getByteList()) : new ScannerImpl(((RubyString)io).getByteList()); - } else { - scn = debug ? new PositioningScannerImpl(new IOInputStream(io)) : new ScannerImpl(new IOInputStream(io)); - } - Constructor ctor = - debug ? - new JRubyConstructor(self, new PositioningComposerImpl(new PositioningParserImpl((PositioningScanner)scn,YAML.config().version("1.0")),new ResolverImpl())) : - new JRubyConstructor(self, new ComposerImpl(new ParserImpl(scn,YAML.config().version("1.0")),new ResolverImpl())) - ; - while(ctor.checkData()) { - if(d.isNil()) { - d = self.getRuntime().fastGetModule("YAML").fastGetClass("Stream").callMethod(context,"new", d); - } - d.callMethod(context,"add", JavaEmbedUtils.javaToRuby(self.getRuntime(),ctor.getData())); - } - return d; - } catch(YAMLException e) { - if(self.getRuntime().getDebug().isTrue()) { - Position.Range range = ((Positionable)e).getRange(); - throw self.getRuntime().newArgumentError("syntax error on " + range.start + ":" + range.end + ": " + e.getMessage()); - } else { - throw self.getRuntime().newArgumentError("syntax error:" + e.getMessage()); - } - } - } - - @JRubyMethod(name = "dump_stream", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject dump_stream(IRubyObject self, IRubyObject[] args) { - ThreadContext context = self.getRuntime().getCurrentContext(); - IRubyObject stream = self.getRuntime().fastGetModule("YAML").fastGetClass("Stream").callMethod(context, "new"); - for(int i=0,j=args.length;i<j;i++) { - stream.callMethod(context,"add", args[i]); - } - return stream.callMethod(context, "emit"); - } - - @JRubyMethod(name = "quick_emit_node", required = 1, rest = true, frame = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject quick_emit_node(IRubyObject self, IRubyObject[] args, Block block) { - return block.yield(self.getRuntime().getCurrentContext(), args[0]); - } - -// @JRubyMethod(name = "quick_emit_node", rest = true, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject quick_emit(IRubyObject self, IRubyObject[] args) { - return self.getRuntime().getNil(); - } - - // prepares IO port type for load (ported from ext/syck/rubyext.c) - private static IRubyObject check_yaml_port(IRubyObject port) { - if (port instanceof RubyString) { - // OK - } - else if (port.respondsTo("read")) { - if (port.respondsTo("binmode")) { - ThreadContext context = port.getRuntime().getCurrentContext(); - port.callMethod(context, "binmode"); - } - } - else { - throw port.getRuntime().newTypeError("instance of IO needed"); - } - return port; - } - - @JRubyClass(name="Hash") - public static class YAMLHashMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject hash_to_yaml_node(IRubyObject self, IRubyObject arg) { - Ruby runtime = self.getRuntime(); - ThreadContext context = runtime.getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "map", self.callMethod(context, "taguri"), self, self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Object") - public static class YAMLObjectMethods { - @JRubyMethod(name = "to_yaml_properties") - public static IRubyObject obj_to_yaml_properties(IRubyObject self) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return self.callMethod(context, "instance_variables").callMethod(context, "sort"); - } - @JRubyMethod(name = "to_yaml_style") - public static IRubyObject obj_to_yaml_style(IRubyObject self) { - return self.getRuntime().getNil(); - } - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject obj_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - Map mep = (Map)(new RubyHash(self.getRuntime())); - RubyArray props = (RubyArray)self.callMethod(context, "to_yaml_properties"); - for(Iterator iter = props.getList().iterator(); iter.hasNext();) { - String m = iter.next().toString(); - mep.put(self.getRuntime().newString(m.substring(1)), self.callMethod(context,"instance_variable_get", self.getRuntime().newString(m))); - } - return RuntimeHelpers.invoke(context, arg, "map", self.callMethod(context, "taguri"), (IRubyObject)mep, self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "to_yaml", rest = true) - public static IRubyObject obj_to_yaml(IRubyObject self, IRubyObject[] args) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return self.getRuntime().fastGetModule("YAML").callMethod(context,"dump", self); - } - @JRubyMethod(name = "taguri") - public static IRubyObject obj_taguri(IRubyObject self) { - return self.getRuntime().newString("!ruby/object:" + self.getType().getName()); - } - } - - @JRubyClass(name="Class") - public static class YAMLClassMethods { - @JRubyMethod(name = "to_yaml", rest = true) - public static IRubyObject class_to_yaml(IRubyObject self, IRubyObject[] args) { - throw self.getRuntime().newTypeError("can't dump anonymous class " + self.getType().getName()); - } - } - - @JRubyClass(name="Array") - public static class YAMLArrayMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject array_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "seq", self.callMethod(context, "taguri"), self, self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Struct") - public static class YAMLStructMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject struct_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - Map mep = (Map)(new RubyHash(self.getRuntime())); - for(Iterator iter = ((RubyArray)self.callMethod(context, "members")).getList().iterator();iter.hasNext();) { - IRubyObject key = self.getRuntime().newString(iter.next().toString()); - mep.put(key,self.callMethod(context,MethodIndex.AREF, "[]", key)); - } - for(Iterator iter = ((RubyArray)self.callMethod(context, "to_yaml_properties")).getList().iterator(); iter.hasNext();) { - String m = iter.next().toString(); - mep.put(self.getRuntime().newString(m.substring(1)), self.callMethod(context,"instance_variable_get", self.getRuntime().newString(m))); - } - return RuntimeHelpers.invoke(context, arg, "map", self.callMethod(context, "taguri"), (IRubyObject)mep, self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "taguri") - public static IRubyObject struct_taguri(IRubyObject self) { - return self.getRuntime().newString("!ruby/struct:" + self.getType().getName()); - } - } - - @JRubyClass(name="Exception") - public static class YAMLExceptionMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject exception_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - Map mep = (Map)(new RubyHash(self.getRuntime())); - mep.put(self.getRuntime().newString("message"),self.callMethod(context, "message")); - for(Iterator iter = ((RubyArray)self.callMethod(context, "to_yaml_properties")).getList().iterator(); iter.hasNext();) { - String m = iter.next().toString(); - mep.put(self.getRuntime().newString(m.substring(1)), self.callMethod(context,"instance_variable_get", self.getRuntime().newString(m))); - } - return RuntimeHelpers.invoke(context, arg,"map", self.callMethod(context, "taguri"), (IRubyObject)mep, self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "taguri") - public static IRubyObject exception_taguri(IRubyObject self) { - return self.getRuntime().newString("!ruby/exception:" + self.getType().getName()); - } - } - - private static final Pattern AFTER_NEWLINE = Pattern.compile("\n.+", Pattern.DOTALL); - @JRubyClass(name="String") - public static class YAMLStringMethods { - @JRubyMethod(name = "is_complex_yaml?") - public static IRubyObject string_is_complex(IRubyObject self) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return (self.callMethod(context, "to_yaml_style").isTrue() || - ((List)self.callMethod(context, "to_yaml_properties")).isEmpty() || - AFTER_NEWLINE.matcher(self.toString()).find()) ? self.getRuntime().getTrue() : self.getRuntime().getFalse(); - } - @JRubyMethod(name = "is_binary_data?") - public static IRubyObject string_is_binary(IRubyObject self) { - ThreadContext context = self.getRuntime().getCurrentContext(); - if(self.callMethod(context, MethodIndex.EMPTY_P, "empty?").isTrue()) { - return self.getRuntime().getNil(); - } - return self.toString().indexOf('\0') != -1 ? self.getRuntime().getTrue() : self.getRuntime().getFalse(); - } - private static JRubyRepresenter into(IRubyObject arg) { - IRubyObject jobj = arg.getInstanceVariables().fastGetInstanceVariable("@java_object"); - if(jobj != null) { - return (JRubyRepresenter)(((org.jruby.javasupport.JavaObject)jobj).getValue()); - } - return null; - } - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject string_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - Ruby rt = self.getRuntime(); - if(self.callMethod(context, "is_binary_data?").isTrue()) { - return RuntimeHelpers.invoke(context, arg, "scalar", rt.newString("tag:yaml.org,2002:binary"), rt.newArray(self).callMethod(context, "pack", rt.newString("m")), rt.newString("|")); - } - if(((List)self.callMethod(context, "to_yaml_properties")).isEmpty()) { - JRubyRepresenter rep = into(arg); - if(rep != null) { - try { - return JavaUtil.convertJavaToRuby(rt,rep.scalar(self.callMethod(context, "taguri").toString(),self.convertToString().getByteList(),self.toString().startsWith(":") ? "\"" : self.callMethod(context, "to_yaml_style").toString())); - } catch(IOException e) { - throw rt.newIOErrorFromException(e); - } - } else { - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self, self.toString().startsWith(":") ? rt.newString("\"") : self.callMethod(context, "to_yaml_style")); - } - } - - Map mep = (Map)(new RubyHash(self.getRuntime())); - mep.put(self.getRuntime().newString("str"),rt.newString(self.toString())); - for(Iterator iter = ((RubyArray)self.callMethod(context, "to_yaml_properties")).getList().iterator(); iter.hasNext();) { - String m = iter.next().toString(); - mep.put(self.getRuntime().newString(m), self.callMethod(context,"instance_variable_get", self.getRuntime().newString(m))); - } - return RuntimeHelpers.invoke(context, arg, "map", self.callMethod(context, "taguri"), (IRubyObject)mep, self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Symbol") - public static class YAMLSymbolMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject symbol_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self.callMethod(context, "inspect"), self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "taguri") - public static IRubyObject symbol_taguri(IRubyObject self) { - return self.getRuntime().newString("tag:yaml.org,2002:str"); - } - } - - @JRubyClass(name="Numeric") - public static class YAMLNumericMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject numeric_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - String val = self.toString(); - if("Infinity".equals(val)) { - val = ".Inf"; - } else if("-Infinity".equals(val)) { - val = "-.Inf"; - } else if("NaN".equals(val)) { - val = ".NaN"; - } - return RuntimeHelpers.invoke(context, arg,"scalar", self.callMethod(context, "taguri"), self.getRuntime().newString(val), self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Range") - public static class YAMLRangeMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject range_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - Map mep = (Map)(new RubyHash(self.getRuntime())); - mep.put(self.getRuntime().newString("begin"),self.callMethod(context, "begin")); - mep.put(self.getRuntime().newString("end"),self.callMethod(context, "end")); - mep.put(self.getRuntime().newString("excl"),self.callMethod(context, "exclude_end?")); - for(Iterator iter = ((RubyArray)self.callMethod(context, "to_yaml_properties")).getList().iterator(); iter.hasNext();) { - String m = iter.next().toString(); - mep.put(self.getRuntime().newString(m.substring(1)), self.callMethod(context,"instance_variable_get", self.getRuntime().newString(m))); - } - return RuntimeHelpers.invoke(context, arg, "map", self.callMethod(context, "taguri"), (IRubyObject)mep, self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Regexp") - public static class YAMLRegexpMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject regexp_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self.callMethod(context, "inspect"), self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Time") - public static class YAMLTimeMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject time_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - IRubyObject tz = self.getRuntime().newString("Z"); - IRubyObject difference_sign = self.getRuntime().newString("-"); - self = self.dup(); - if(!self.callMethod(context, "utc?").isTrue()) { - IRubyObject utc_same_instant = self.callMethod(context, "utc"); - IRubyObject utc_same_writing = RuntimeHelpers.invoke(context, self.getRuntime().getTime(), "utc", new IRubyObject[]{ - self.callMethod(context, "year"),self.callMethod(context, "month"),self.callMethod(context, "day"),self.callMethod(context, "hour"), - self.callMethod(context, "min"),self.callMethod(context, "sec"),self.callMethod(context, "usec")}); - IRubyObject difference_to_utc = utc_same_writing.callMethod(context,MethodIndex.OP_MINUS, "-", utc_same_instant); - IRubyObject absolute_difference; - if(difference_to_utc.callMethod(context,MethodIndex.OP_LT, "<", RubyFixnum.zero(self.getRuntime())).isTrue()) { - difference_sign = self.getRuntime().newString("-"); - absolute_difference = RubyFixnum.zero(self.getRuntime()).callMethod(context,MethodIndex.OP_MINUS, "-", difference_to_utc); - } else { - difference_sign = self.getRuntime().newString("+"); - absolute_difference = difference_to_utc; - } - IRubyObject difference_minutes = absolute_difference.callMethod(context,"/", self.getRuntime().newFixnum(60)).callMethod(context, "round"); - tz = self.getRuntime().newString("%s%02d:%02d").callMethod(context,"%", self.getRuntime().newArrayNoCopy(new IRubyObject[]{difference_sign,difference_minutes.callMethod(context,"/", self.getRuntime().newFixnum(60)),difference_minutes.callMethod(context,"%", self.getRuntime().newFixnum(60))})); - } - IRubyObject standard = self.callMethod(context,"strftime", self.getRuntime().newString("%Y-%m-%d %H:%M:%S")); - if(self.callMethod(context, "usec").callMethod(context, "nonzero?").isTrue()) { - standard = standard.callMethod(context, MethodIndex.OP_PLUS, "+", self.getRuntime().newString(".%06d").callMethod(context,"%", self.getRuntime().newArray(self.callMethod(context, "usec")))); - } - standard = standard.callMethod(context,MethodIndex.OP_PLUS, "+", self.getRuntime().newString(" %s").callMethod(context,"%", self.getRuntime().newArray(tz))); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), standard, self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="Date") - public static class YAMLDateMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject date_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self.callMethod(context, MethodIndex.TO_S, "to_s"), self.callMethod(context, "to_yaml_style")); - } - } - - @JRubyClass(name="TrueClass") - public static class YAMLTrueMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject true_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self.callMethod(context, MethodIndex.TO_S, "to_s"), self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "taguri") - public static IRubyObject true_taguri(IRubyObject self) { - return self.getRuntime().newString("tag:yaml.org,2002:bool"); - } - } - - @JRubyClass(name="FalseClass") - public static class YAMLFalseMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject false_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg, "scalar", self.callMethod(context, "taguri"), self.callMethod(context, MethodIndex.TO_S, "to_s"), self.callMethod(context, "to_yaml_style")); - } - @JRubyMethod(name = "taguri") - public static IRubyObject false_taguri(IRubyObject self) { - return self.getRuntime().newString("tag:yaml.org,2002:bool"); - } - } - - @JRubyClass(name="NilClass") - public static class YAMLNilMethods { - @JRubyMethod(name = "to_yaml_node", required = 1) - public static IRubyObject nil_to_yaml_node(IRubyObject self, IRubyObject arg) { - ThreadContext context = self.getRuntime().getCurrentContext(); - return RuntimeHelpers.invoke(context, arg,"scalar", self.callMethod(context, "taguri"), self.getRuntime().newString(""), self.callMethod(context, "to_yaml_style")); - } - } -}// RubyYAML -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2006 Ola Bini <ola@ologix.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import java.io.InputStream; -import java.io.IOException; - -import java.util.List; -import java.util.ArrayList; - -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import org.jruby.anno.FrameField; -import org.jruby.anno.JRubyMethod; -import org.jruby.anno.JRubyClass; -import org.jruby.anno.JRubyModule; - -import org.jruby.exceptions.RaiseException; -import org.jruby.javasupport.util.RuntimeHelpers; -import org.jruby.runtime.Arity; - -import org.jruby.runtime.Block; -import org.jruby.runtime.ObjectAllocator; -import org.jruby.runtime.ThreadContext; -import org.jruby.runtime.Visibility; -import org.jruby.runtime.builtin.IRubyObject; - -import org.jruby.util.IOInputStream; -import org.jruby.util.IOOutputStream; -import org.jruby.util.CRC32Ext; -import org.jruby.util.Adler32Ext; -import org.jruby.util.ZlibInflate; -import org.jruby.util.ZlibDeflate; - -import org.jruby.util.ByteList; - -@JRubyModule(name="Zlib") -public class RubyZlib { - /** Create the Zlib module and add it to the Ruby runtime. - * - */ - public static RubyModule createZlibModule(Ruby runtime) { - RubyModule result = runtime.defineModule("Zlib"); - - RubyClass gzfile = result.defineClassUnder("GzipFile", runtime.getObject(), RubyGzipFile.GZIPFILE_ALLOCATOR); - gzfile.defineAnnotatedMethods(RubyGzipFile.class); - - RubyClass gzreader = result.defineClassUnder("GzipReader", gzfile, RubyGzipReader.GZIPREADER_ALLOCATOR); - gzreader.includeModule(runtime.getEnumerable()); - gzreader.defineAnnotatedMethods(RubyGzipReader.class); - - RubyClass standardError = runtime.getStandardError(); - RubyClass zlibError = result.defineClassUnder("Error", standardError, standardError.getAllocator()); - gzreader.defineClassUnder("Error", zlibError, zlibError.getAllocator()); - - RubyClass gzwriter = result.defineClassUnder("GzipWriter", gzfile, RubyGzipWriter.GZIPWRITER_ALLOCATOR); - gzwriter.defineAnnotatedMethods(RubyGzipWriter.class); - - result.defineConstant("ZLIB_VERSION",runtime.newString("1.2.1")); - result.defineConstant("VERSION",runtime.newString("0.6.0")); - - result.defineConstant("BINARY",runtime.newFixnum(0)); - result.defineConstant("ASCII",runtime.newFixnum(1)); - result.defineConstant("UNKNOWN",runtime.newFixnum(2)); - - result.defineConstant("DEF_MEM_LEVEL",runtime.newFixnum(8)); - result.defineConstant("MAX_MEM_LEVEL",runtime.newFixnum(9)); - - result.defineConstant("OS_UNIX",runtime.newFixnum(3)); - result.defineConstant("OS_UNKNOWN",runtime.newFixnum(255)); - result.defineConstant("OS_CODE",runtime.newFixnum(11)); - result.defineConstant("OS_ZSYSTEM",runtime.newFixnum(8)); - result.defineConstant("OS_VMCMS",runtime.newFixnum(4)); - result.defineConstant("OS_VMS",runtime.newFixnum(2)); - result.defineConstant("OS_RISCOS",runtime.newFixnum(13)); - result.defineConstant("OS_MACOS",runtime.newFixnum(7)); - result.defineConstant("OS_OS2",runtime.newFixnum(6)); - result.defineConstant("OS_AMIGA",runtime.newFixnum(1)); - result.defineConstant("OS_QDOS",runtime.newFixnum(12)); - result.defineConstant("OS_WIN32",runtime.newFixnum(11)); - result.defineConstant("OS_ATARI",runtime.newFixnum(5)); - result.defineConstant("OS_MSDOS",runtime.newFixnum(0)); - result.defineConstant("OS_CPM",runtime.newFixnum(9)); - result.defineConstant("OS_TOPS20",runtime.newFixnum(10)); - - result.defineConstant("DEFAULT_STRATEGY",runtime.newFixnum(0)); - result.defineConstant("FILTERED",runtime.newFixnum(1)); - result.defineConstant("HUFFMAN_ONLY",runtime.newFixnum(2)); - - result.defineConstant("NO_FLUSH",runtime.newFixnum(0)); - result.defineConstant("SYNC_FLUSH",runtime.newFixnum(2)); - result.defineConstant("FULL_FLUSH",runtime.newFixnum(3)); - result.defineConstant("FINISH",runtime.newFixnum(4)); - - result.defineConstant("NO_COMPRESSION",runtime.newFixnum(0)); - result.defineConstant("BEST_SPEED",runtime.newFixnum(1)); - result.defineConstant("DEFAULT_COMPRESSION",runtime.newFixnum(-1)); - result.defineConstant("BEST_COMPRESSION",runtime.newFixnum(9)); - - result.defineConstant("MAX_WBITS",runtime.newFixnum(15)); - - result.defineAnnotatedMethods(RubyZlib.class); - - result.defineClassUnder("StreamEnd",zlibError, zlibError.getAllocator()); - result.defineClassUnder("StreamError",zlibError, zlibError.getAllocator()); - result.defineClassUnder("BufError",zlibError, zlibError.getAllocator()); - result.defineClassUnder("NeedDict",zlibError, zlibError.getAllocator()); - result.defineClassUnder("MemError",zlibError, zlibError.getAllocator()); - result.defineClassUnder("VersionError",zlibError, zlibError.getAllocator()); - result.defineClassUnder("DataError",zlibError, zlibError.getAllocator()); - - RubyClass gzError = gzfile.defineClassUnder("Error",zlibError, zlibError.getAllocator()); - gzfile.defineClassUnder("CRCError",gzError, gzError.getAllocator()); - gzfile.defineClassUnder("NoFooter",gzError, gzError.getAllocator()); - gzfile.defineClassUnder("LengthError",gzError, gzError.getAllocator()); - - // ZStream actually *isn't* allocatable - RubyClass zstream = result.defineClassUnder("ZStream", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR); - zstream.defineAnnotatedMethods(ZStream.class); - zstream.undefineMethod("new"); - - RubyClass infl = result.defineClassUnder("Inflate", zstream, Inflate.INFLATE_ALLOCATOR); - infl.defineAnnotatedMethods(Inflate.class); - - RubyClass defl = result.defineClassUnder("Deflate", zstream, Deflate.DEFLATE_ALLOCATOR); - defl.defineAnnotatedMethods(Deflate.class); - - runtime.getKernel().callMethod(runtime.getCurrentContext(),"require",runtime.newString("stringio")); - - return result; - } - - @JRubyClass(name="Zlib::Error", parent="StandardError") - public static class Error {} - @JRubyClass(name="Zlib::StreamEnd", parent="Zlib::Error") - public static class StreamEnd extends Error {} - @JRubyClass(name="Zlib::StreamError", parent="Zlib::Error") - public static class StreamError extends Error {} - @JRubyClass(name="Zlib::BufError", parent="Zlib::Error") - public static class BufError extends Error {} - @JRubyClass(name="Zlib::NeedDict", parent="Zlib::Error") - public static class NeedDict extends Error {} - @JRubyClass(name="Zlib::MemError", parent="Zlib::Error") - public static class MemError extends Error {} - @JRubyClass(name="Zlib::VersionError", parent="Zlib::Error") - public static class VersionError extends Error {} - @JRubyClass(name="Zlib::DataError", parent="Zlib::Error") - public static class DataError extends Error {} - - @JRubyMethod(name = "zlib_version", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject zlib_version(IRubyObject recv) { - return ((RubyModule)recv).fastGetConstant("ZLIB_VERSION"); - } - - @JRubyMethod(name = "version", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject version(IRubyObject recv) { - return ((RubyModule)recv).fastGetConstant("VERSION"); - } - - @JRubyMethod(name = "crc32", optional = 2, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject crc32(IRubyObject recv, IRubyObject[] args) throws Exception { - args = Arity.scanArgs(recv.getRuntime(),args,0,2); - long crc = 0; - ByteList bytes = null; - - if (!args[0].isNil()) bytes = args[0].convertToString().getByteList(); - if (!args[1].isNil()) crc = RubyNumeric.num2long(args[1]); - - CRC32Ext ext = new CRC32Ext((int)crc); - if (bytes != null) { - ext.update(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - } - - return recv.getRuntime().newFixnum(ext.getValue()); - } - - @JRubyMethod(name = "adler32", optional = 2, module = true, visibility = Visibility.PRIVATE) - public static IRubyObject adler32(IRubyObject recv, IRubyObject[] args) throws Exception { - args = Arity.scanArgs(recv.getRuntime(),args,0,2); - int adler = 1; - ByteList bytes = null; - if (!args[0].isNil()) bytes = args[0].convertToString().getByteList(); - if (!args[1].isNil()) adler = RubyNumeric.fix2int(args[1]); - - Adler32Ext ext = new Adler32Ext(adler); - if (bytes != null) { - ext.update(bytes.unsafeBytes(), bytes.begin(), bytes.length()); // it's safe since adler.update doesn't modify the array - } - return recv.getRuntime().newFixnum(ext.getValue()); - } - - private final static long[] crctab = new long[]{ - 0L, 1996959894L, 3993919788L, 2567524794L, 124634137L, 1886057615L, 3915621685L, 2657392035L, 249268274L, 2044508324L, 3772115230L, 2547177864L, 162941995L, - 2125561021L, 3887607047L, 2428444049L, 498536548L, 1789927666L, 4089016648L, 2227061214L, 450548861L, 1843258603L, 4107580753L, 2211677639L, 325883990L, - 1684777152L, 4251122042L, 2321926636L, 335633487L, 1661365465L, 4195302755L, 2366115317L, 997073096L, 1281953886L, 3579855332L, 2724688242L, 1006888145L, - 1258607687L, 3524101629L, 2768942443L, 901097722L, 1119000684L, 3686517206L, 2898065728L, 853044451L, 1172266101L, 3705015759L, 2882616665L, 651767980L, - 1373503546L, 3369554304L, 3218104598L, 565507253L, 1454621731L, 3485111705L, 3099436303L, 671266974L, 1594198024L, 3322730930L, 2970347812L, 795835527L, - 1483230225L, 3244367275L, 3060149565L, 1994146192L, 31158534L, 2563907772L, 4023717930L, 1907459465L, 112637215L, 2680153253L, 3904427059L, 2013776290L, - 251722036L, 2517215374L, 3775830040L, 2137656763L, 141376813L, 2439277719L, 3865271297L, 1802195444L, 476864866L, 2238001368L, 4066508878L, 1812370925L, - 453092731L, 2181625025L, 4111451223L, 1706088902L, 314042704L, 2344532202L, 4240017532L, 1658658271L, 366619977L, 2362670323L, 4224994405L, 1303535960L, - 984961486L, 2747007092L, 3569037538L, 1256170817L, 1037604311L, 2765210733L, 3554079995L, 1131014506L, 879679996L, 2909243462L, 3663771856L, 1141124467L, - 855842277L, 2852801631L, 3708648649L, 1342533948L, 654459306L, 3188396048L, 3373015174L, 1466479909L, 544179635L, 3110523913L, 3462522015L, 1591671054L, - 702138776L, 2966460450L, 3352799412L, 1504918807L, 783551873L, 3082640443L, 3233442989L, 3988292384L, 2596254646L, 62317068L, 1957810842L, 3939845945L, - 2647816111L, 81470997L, 1943803523L, 3814918930L, 2489596804L, 225274430L, 2053790376L, 3826175755L, 2466906013L, 167816743L, 2097651377L, 4027552580L, - 2265490386L, 503444072L, 1762050814L, 4150417245L, 2154129355L, 426522225L, 1852507879L, 4275313526L, 2312317920L, 282753626L, 1742555852L, 4189708143L, - 2394877945L, 397917763L, 1622183637L, 3604390888L, 2714866558L, 953729732L, 1340076626L, 3518719985L, 2797360999L, 1068828381L, 1219638859L, 3624741850L, - 2936675148L, 906185462L, 1090812512L, 3747672003L, 2825379669L, 829329135L, 1181335161L, 3412177804L, 3160834842L, 628085408L, 1382605366L, 3423369109L, - 3138078467L, 570562233L, 1426400815L, 3317316542L, 2998733608L, 733239954L, 1555261956L, 3268935591L, 3050360625L, 752459403L, 1541320221L, 2607071920L, - 3965973030L, 1969922972L, 40735498L, 2617837225L, 3943577151L, 1913087877L, 83908371L, 2512341634L, 3803740692L, 2075208622L, 213261112L, 2463272603L, - 3855990285L, 2094854071L, 198958881L, 2262029012L, 4057260610L, 1759359992L, 534414190L, 2176718541L, 4139329115L, 1873836001L, 414664567L, 2282248934L, - 4279200368L, 1711684554L, 285281116L, 2405801727L, 4167216745L, 1634467795L, 376229701L, 2685067896L, 3608007406L, 1308918612L, 956543938L, 2808555105L, - 3495958263L, 1231636301L, 1047427035L, 2932959818L, 3654703836L, 1088359270L, 936918000L, 2847714899L, 3736837829L, 1202900863L, 817233897L, 3183342108L, - 3401237130L, 1404277552L, 615818150L, 3134207493L, 3453421203L, 1423857449L, 601450431L, 3009837614L, 3294710456L, 1567103746L, 711928724L, 3020668471L, - 3272380065L, 1510334235L, 755167117}; - - @JRubyMethod(name = "crc_table", module = true, visibility = Visibility.PRIVATE) - public static IRubyObject crc_table(IRubyObject recv) { - List<IRubyObject> ll = new ArrayList<IRubyObject>(crctab.length); - for(int i=0;i<crctab.length;i++) { - ll.add(recv.getRuntime().newFixnum(crctab[i])); - } - return recv.getRuntime().newArray(ll); - } - - - @JRubyClass(name="Zlib::ZStream") - public static abstract class ZStream extends RubyObject { - protected boolean closed = false; - protected boolean ended = false; - protected boolean finished = false; - - protected abstract int internalTotalOut(); - protected abstract boolean internalStreamEndP(); - protected abstract void internalEnd(); - protected abstract void internalReset(); - protected abstract int internalAdler(); - protected abstract IRubyObject internalFinish() throws Exception; - protected abstract int internalTotalIn(); - protected abstract void internalClose(); - - public ZStream(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - @JRubyMethod(name = "initialize", frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(Block unusedBlock) { - return this; - } - - @JRubyMethod(name = "flust_next_out") - public IRubyObject flush_next_out() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "total_out") - public IRubyObject total_out() { - return getRuntime().newFixnum(internalTotalOut()); - } - - @JRubyMethod(name = "stream_end?") - public IRubyObject stream_end_p() { - return internalStreamEndP() ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "data_type") - public IRubyObject data_type() { - return getRuntime().fastGetModule("Zlib").fastGetConstant("UNKNOWN"); - } - - @JRubyMethod(name = "closed?") - public IRubyObject closed_p() { - return closed ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "ended?") - public IRubyObject ended_p() { - return ended ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "end") - public IRubyObject end() { - if(!ended) { - internalEnd(); - ended = true; - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "reset") - public IRubyObject reset() { - internalReset(); - return getRuntime().getNil(); - } - - @JRubyMethod(name = "avail_out") - public IRubyObject avail_out() { - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "avail_out=", required = 1) - public IRubyObject set_avail_out(IRubyObject p1) { - return p1; - } - - @JRubyMethod(name = "adler") - public IRubyObject adler() { - return getRuntime().newFixnum(internalAdler()); - } - - @JRubyMethod(name = "finish") - public IRubyObject finish() throws Exception { - if(!finished) { - finished = true; - return internalFinish(); - } - return RubyString.newEmptyString(getRuntime()); - } - - @JRubyMethod(name = "avail_in") - public IRubyObject avail_in() { - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "flush_next_in") - public IRubyObject flush_next_in() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "total_in") - public IRubyObject total_in() { - return getRuntime().newFixnum(internalTotalIn()); - } - - @JRubyMethod(name = "finished?") - public IRubyObject finished_p() { - return finished ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "close") - public IRubyObject close() { - if(!closed) { - internalClose(); - closed = true; - } - return getRuntime().getNil(); - } - } - - @JRubyClass(name="Zlib::Inflate", parent="Zlib::ZStream") - public static class Inflate extends ZStream { - protected static final ObjectAllocator INFLATE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Inflate(runtime, klass); - } - }; - - @JRubyMethod(name = "inflate", required = 1, meta = true) - public static IRubyObject s_inflate(IRubyObject recv, IRubyObject string) throws Exception { - return ZlibInflate.s_inflate(recv,string.convertToString().getByteList()); - } - - public Inflate(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private ZlibInflate infl; - - @JRubyMethod(name = "initialize", rest = true, visibility = Visibility.PRIVATE) - public IRubyObject _initialize(IRubyObject[] args) throws Exception { - infl = new ZlibInflate(this); - return this; - } - - @JRubyMethod(name = "<<", required = 1) - public IRubyObject append(IRubyObject arg) { - infl.append(arg); - return this; - } - - @JRubyMethod(name = "sync_point?") - public IRubyObject sync_point_p() { - return infl.sync_point(); - } - - @JRubyMethod(name = "set_dictionary", required = 1) - public IRubyObject set_dictionary(IRubyObject arg) throws Exception { - return infl.set_dictionary(arg); - } - - @JRubyMethod(name = "inflate", required = 1) - public IRubyObject inflate(IRubyObject string) throws Exception { - return infl.inflate(string.convertToString().getByteList()); - } - - @JRubyMethod(name = "sync", required = 1) - public IRubyObject sync(IRubyObject string) { - return infl.sync(string); - } - - protected int internalTotalOut() { - return infl.getInflater().getTotalOut(); - } - - protected boolean internalStreamEndP() { - return infl.getInflater().finished(); - } - - protected void internalEnd() { - infl.getInflater().end(); - } - - protected void internalReset() { - infl.getInflater().reset(); - } - - protected int internalAdler() { - return infl.getInflater().getAdler(); - } - - protected IRubyObject internalFinish() throws Exception { - infl.finish(); - return getRuntime().getNil(); - } - - public IRubyObject finished_p() { - return infl.getInflater().finished() ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - protected int internalTotalIn() { - return infl.getInflater().getTotalIn(); - } - - protected void internalClose() { - infl.close(); - } - } - - @JRubyClass(name="Zlib::Deflate", parent="Zlib::ZStream") - public static class Deflate extends ZStream { - protected static final ObjectAllocator DEFLATE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new Deflate(runtime, klass); - } - }; - - @JRubyMethod(name = "deflate", required = 1, optional = 1, meta = true) - public static IRubyObject s_deflate(IRubyObject recv, IRubyObject[] args) throws Exception { - args = Arity.scanArgs(recv.getRuntime(),args,1,1); - int level = -1; - if(!args[1].isNil()) { - level = RubyNumeric.fix2int(args[1]); - } - return ZlibDeflate.s_deflate(recv,args[0].convertToString().getByteList(),level); - } - - public Deflate(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private ZlibDeflate defl; - - @JRubyMethod(name = "initialize", optional = 4, visibility = Visibility.PRIVATE) - public IRubyObject _initialize(IRubyObject[] args) throws Exception { - args = Arity.scanArgs(getRuntime(),args,0,4); - int level = -1; - int window_bits = 15; - int memlevel = 8; - int strategy = 0; - if(!args[0].isNil()) { - level = RubyNumeric.fix2int(args[0]); - } - if(!args[1].isNil()) { - window_bits = RubyNumeric.fix2int(args[1]); - } - if(!args[2].isNil()) { - memlevel = RubyNumeric.fix2int(args[2]); - } - if(!args[3].isNil()) { - strategy = RubyNumeric.fix2int(args[3]); - } - defl = new ZlibDeflate(this,level,window_bits,memlevel,strategy); - return this; - } - - @JRubyMethod(name = "<<", required = 1) - public IRubyObject append(IRubyObject arg) throws Exception { - defl.append(arg); - return this; - } - - @JRubyMethod(name = "params", required = 2) - public IRubyObject params(IRubyObject level, IRubyObject strategy) { - defl.params(RubyNumeric.fix2int(level),RubyNumeric.fix2int(strategy)); - return getRuntime().getNil(); - } - - @JRubyMethod(name = "set_dictionary", required = 1) - public IRubyObject set_dictionary(IRubyObject arg) throws Exception { - return defl.set_dictionary(arg); - } - - @JRubyMethod(name = "flush", optional = 1) - public IRubyObject flush(IRubyObject[] args) throws Exception { - int flush = 2; // SYNC_FLUSH - if(args.length == 1) { - if(!args[0].isNil()) { - flush = RubyNumeric.fix2int(args[0]); - } - } - return defl.flush(flush); - } - - @JRubyMethod(name = "deflate", required = 1, optional = 1) - public IRubyObject deflate(IRubyObject[] args) throws Exception { - args = Arity.scanArgs(getRuntime(),args,1,1); - int flush = 0; // NO_FLUSH - if(!args[1].isNil()) { - flush = RubyNumeric.fix2int(args[1]); - } - return defl.deflate(args[0].convertToString().getByteList(),flush); - } - - protected int internalTotalOut() { - return defl.getDeflater().getTotalOut(); - } - - protected boolean internalStreamEndP() { - return defl.getDeflater().finished(); - } - - protected void internalEnd() { - defl.getDeflater().end(); - } - - protected void internalReset() { - defl.getDeflater().reset(); - } - - protected int internalAdler() { - return defl.getDeflater().getAdler(); - } - - protected IRubyObject internalFinish() throws Exception { - return defl.finish(); - } - - protected int internalTotalIn() { - return defl.getDeflater().getTotalIn(); - } - - protected void internalClose() { - defl.close(); - } - } - - @JRubyClass(name="Zlib::GzipFile") - public static class RubyGzipFile extends RubyObject { - @JRubyClass(name="Zlib::GzipFile::Error", parent="Zlib::Error") - public static class Error {} - @JRubyClass(name="Zlib::GzipFile::CRCError", parent="Zlib::GzipFile::Error") - public static class CRCError extends Error {} - @JRubyClass(name="Zlib::GzipFile::NoFooter", parent="Zlib::GzipFile::Error") - public static class NoFooter extends Error {} - @JRubyClass(name="Zlib::GzipFile::LengthError", parent="Zlib::GzipFile::Error") - public static class LengthError extends Error {} - - private static IRubyObject wrap(ThreadContext context, RubyGzipFile instance, - IRubyObject io, Block block) throws IOException { - if (block.isGiven()) { - try { - block.yield(context, instance); - - return instance.getRuntime().getNil(); - } finally { - if (!instance.isClosed()) instance.close(); - } - } - - return io; - } - - @JRubyMethod(name = "wrap", required = 1, frame = true, meta = true) - public static IRubyObject wrap(ThreadContext context, IRubyObject recv, IRubyObject io, Block block) throws IOException { - Ruby runtime = recv.getRuntime(); - RubyGzipFile instance; - - // TODO: People extending GzipWriter/reader will break. Find better way here. - if (recv == runtime.getModule("Zlib").getClass("GzipWriter")) { - instance = RubyGzipWriter.newGzipWriter(recv, new IRubyObject[] { io }, block); - } else { - instance = RubyGzipReader.newInstance(recv, new IRubyObject[] { io }, block); - } - - return wrap(context, instance, io, block); - } - - protected static final ObjectAllocator GZIPFILE_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyGzipFile(runtime, klass); - } - }; - - @JRubyMethod(name = "new", frame = true, meta = true) - public static RubyGzipFile newInstance(IRubyObject recv, Block block) { - RubyClass klass = (RubyClass)recv; - - RubyGzipFile result = (RubyGzipFile) klass.allocate(); - - result.callInit(new IRubyObject[0], block); - - return result; - } - - protected boolean closed = false; - protected boolean finished = false; - private int os_code = 255; - private int level = -1; - private String orig_name; - private String comment; - protected IRubyObject realIo; - private IRubyObject mtime; - - public RubyGzipFile(Ruby runtime, RubyClass type) { - super(runtime, type); - mtime = runtime.getNil(); - } - - @JRubyMethod(name = "os_code") - public IRubyObject os_code() { - return getRuntime().newFixnum(os_code); - } - - @JRubyMethod(name = "closed?") - public IRubyObject closed_p() { - return closed ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - protected boolean isClosed() { - return closed; - } - - @JRubyMethod(name = "orig_name") - public IRubyObject orig_name() { - return orig_name == null ? getRuntime().getNil() : getRuntime().newString(orig_name); - } - - @JRubyMethod(name = "to_io") - public IRubyObject to_io() { - return realIo; - } - - @JRubyMethod(name = "comment") - public IRubyObject comment() { - return comment == null ? getRuntime().getNil() : getRuntime().newString(comment); - } - - @JRubyMethod(name = "crc") - public IRubyObject crc() { - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "mtime") - public IRubyObject mtime() { - return mtime; - } - - @JRubyMethod(name = "sync") - public IRubyObject sync() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "finish") - public IRubyObject finish() throws IOException { - if (!finished) { - //io.finish(); - } - finished = true; - return realIo; - } - - @JRubyMethod(name = "close") - public IRubyObject close() throws IOException { - return null; - } - - @JRubyMethod(name = "level") - public IRubyObject level() { - return getRuntime().newFixnum(level); - } - - @JRubyMethod(name = "sync=", required = 1) - public IRubyObject set_sync(IRubyObject ignored) { - return getRuntime().getNil(); - } - } - - @JRubyClass(name="Zlib::GzipReader", parent="Zlib::GzipFile", include="Enumerable") - public static class RubyGzipReader extends RubyGzipFile { - @JRubyClass(name="Zlib::GzipReader::Error", parent="Zlib::GzipReader") - public static class Error {} - protected static final ObjectAllocator GZIPREADER_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyGzipReader(runtime, klass); - } - }; - - @JRubyMethod(name = "new", rest = true, frame = true, meta = true) - public static RubyGzipReader newInstance(IRubyObject recv, IRubyObject[] args, Block block) { - RubyClass klass = (RubyClass)recv; - RubyGzipReader result = (RubyGzipReader)klass.allocate(); - result.callInit(args, block); - return result; - } - - @JRubyMethod(name = "open", required = 1, frame = true, meta = true) - public static IRubyObject open(final ThreadContext context, IRubyObject recv, IRubyObject filename, Block block) throws IOException { - Ruby runtime = recv.getRuntime(); - IRubyObject io = RuntimeHelpers.invoke(context, runtime.getFile(), "open", filename, runtime.newString("rb")); - RubyGzipFile instance = newInstance(recv, new IRubyObject[]{io}, Block.NULL_BLOCK); - - return RubyGzipFile.wrap(context, instance, io, block); - } - - public RubyGzipReader(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private int line; - private InputStream io; - - @JRubyMethod(name = "initialize", required = 1, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize(IRubyObject io, Block unusedBlock) { - realIo = io; - try { - this.io = new GZIPInputStream(new IOInputStream(io)); - } catch (IOException e) { - Ruby runtime = io.getRuntime(); - RubyClass errorClass = runtime.fastGetModule("Zlib").fastGetClass("GzipReader").fastGetClass("Error"); - throw new RaiseException(RubyException.newException(runtime, errorClass, e.getMessage())); - } - - line = 1; - - return this; - } - - @JRubyMethod(name = "rewind") - public IRubyObject rewind() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "lineno") - public IRubyObject lineno() { - return getRuntime().newFixnum(line); - } - - @JRubyMethod(name = "readline", writes = FrameField.LASTLINE) - public IRubyObject readline(ThreadContext context) throws IOException { - IRubyObject dst = gets(context, new IRubyObject[0]); - if (dst.isNil()) { - throw getRuntime().newEOFError(); - } - return dst; - } - - public IRubyObject internalGets(IRubyObject[] args) throws IOException { - ByteList sep = ((RubyString)getRuntime().getGlobalVariables().get("$/")).getByteList(); - if (args.length > 0) { - sep = args[0].convertToString().getByteList(); - } - return internalSepGets(sep); - } - - private IRubyObject internalSepGets(ByteList sep) throws IOException { - ByteList result = new ByteList(); - int ce = io.read(); - while (ce != -1 && sep.indexOf(ce) == -1) { - result.append((byte)ce); - ce = io.read(); - } - line++; - result.append(sep); - return RubyString.newString(getRuntime(),result); - } - - @JRubyMethod(name = "gets", optional = 1, writes = FrameField.LASTLINE) - public IRubyObject gets(ThreadContext context, IRubyObject[] args) throws IOException { - IRubyObject result = internalGets(args); - if (!result.isNil()) { - context.getCurrentFrame().setLastLine(result); - } - return result; - } - - private final static int BUFF_SIZE = 4096; - - @JRubyMethod(name = "read", optional = 1) - public IRubyObject read(IRubyObject[] args) throws IOException { - if (args.length == 0 || args[0].isNil()) { - ByteList val = new ByteList(10); - byte[] buffer = new byte[BUFF_SIZE]; - int read = io.read(buffer); - while (read != -1) { - val.append(buffer,0,read); - read = io.read(buffer); - } - return RubyString.newString(getRuntime(),val); - } - - int len = RubyNumeric.fix2int(args[0]); - if (len < 0) { - throw getRuntime().newArgumentError("negative length " + len + " given"); - } else if (len > 0) { - byte[] buffer = new byte[len]; - int toRead = len; - int offset = 0; - int read = 0; - while (toRead > 0) { - read = io.read(buffer,offset,toRead); - if (read == -1) { - break; - } - toRead -= read; - offset += read; - } // hmm... - return RubyString.newString(getRuntime(),new ByteList(buffer,0,len-toRead,false)); - } - - return RubyString.newEmptyString(getRuntime()); - } - - @JRubyMethod(name = "lineno=", required = 1) - public IRubyObject set_lineno(IRubyObject lineArg) { - line = RubyNumeric.fix2int(lineArg); - return lineArg; - } - - @JRubyMethod(name = "pos") - public IRubyObject pos() { - return RubyFixnum.zero(getRuntime()); - } - - @JRubyMethod(name = "readchar") - public IRubyObject readchar() throws IOException { - int value = io.read(); - if (value == -1) { - throw getRuntime().newEOFError(); - } - return getRuntime().newFixnum(value); - } - - @JRubyMethod(name = "getc") - public IRubyObject getc() throws IOException { - int value = io.read(); - return value == -1 ? getRuntime().getNil() : getRuntime().newFixnum(value); - } - - private boolean isEof() throws IOException { - return ((GZIPInputStream)io).available() != 1; - } - - @JRubyMethod(name = "close") - public IRubyObject close() throws IOException { - if (!closed) { - io.close(); - } - this.closed = true; - return getRuntime().getNil(); - } - - @JRubyMethod(name = "eof") - public IRubyObject eof() throws IOException { - return isEof() ? getRuntime().getTrue() : getRuntime().getFalse(); - } - - @JRubyMethod(name = "eof?") - public IRubyObject eof_p() throws IOException { - return eof(); - } - - @JRubyMethod(name = "unused") - public IRubyObject unused() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "tell") - public IRubyObject tell() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "each", optional = 1, frame = true) - public IRubyObject each(ThreadContext context, IRubyObject[] args, Block block) throws IOException { - ByteList sep = ((RubyString)getRuntime().getGlobalVariables().get("$/")).getByteList(); - - if (args.length > 0 && !args[0].isNil()) { - sep = args[0].convertToString().getByteList(); - } - - while (!isEof()) { - block.yield(context, internalSepGets(sep)); - } - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "ungetc", required = 1) - public IRubyObject ungetc(IRubyObject arg) { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "readlines", optional = 1) - public IRubyObject readlines(IRubyObject[] args) throws IOException { - List<IRubyObject> array = new ArrayList<IRubyObject>(); - - if (args.length != 0 && args[0].isNil()) { - array.add(read(new IRubyObject[0])); - } else { - ByteList seperator = ((RubyString)getRuntime().getGlobalVariables().get("$/")).getByteList(); - if (args.length > 0) { - seperator = args[0].convertToString().getByteList(); - } - while (!isEof()) { - array.add(internalSepGets(seperator)); - } - } - return getRuntime().newArray(array); - } - - @JRubyMethod(name = "each_byte", frame = true) - public IRubyObject each_byte(ThreadContext context, Block block) throws IOException { - int value = io.read(); - - while (value != -1) { - block.yield(context, getRuntime().newFixnum(value)); - value = io.read(); - } - - return getRuntime().getNil(); - } - } - - @JRubyClass(name="Zlib::GzipWriter", parent="Zlib::GzipFile") - public static class RubyGzipWriter extends RubyGzipFile { - protected static final ObjectAllocator GZIPWRITER_ALLOCATOR = new ObjectAllocator() { - public IRubyObject allocate(Ruby runtime, RubyClass klass) { - return new RubyGzipWriter(runtime, klass); - } - }; - - @JRubyMethod(name = "new", rest = true, frame = true, meta = true) - public static RubyGzipWriter newGzipWriter(IRubyObject recv, IRubyObject[] args, Block block) { - RubyClass klass = (RubyClass)recv; - - RubyGzipWriter result = (RubyGzipWriter)klass.allocate(); - result.callInit(args, block); - return result; - } - - @JRubyMethod(name = "open", required = 1, optional = 2, frame = true, meta = true) - public static IRubyObject open(final ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) throws IOException { - Ruby runtime = recv.getRuntime(); - IRubyObject level = runtime.getNil(); - IRubyObject strategy = runtime.getNil(); - - if (args.length > 1) { - level = args[1]; - if (args.length > 2) strategy = args[2]; - } - - IRubyObject io = RuntimeHelpers.invoke(context, runtime.getFile(), "open", args[0], runtime.newString("wb")); - RubyGzipFile instance = newGzipWriter(recv, new IRubyObject[]{io, level, strategy}, Block.NULL_BLOCK); - - return RubyGzipFile.wrap(context, instance, io, block); - } - - public RubyGzipWriter(Ruby runtime, RubyClass type) { - super(runtime, type); - } - - private GZIPOutputStream io; - - @JRubyMethod(name = "initialize", required = 1, rest = true, frame = true, visibility = Visibility.PRIVATE) - public IRubyObject initialize2(IRubyObject[] args, Block unusedBlock) throws IOException { - realIo = (RubyObject)args[0]; - this.io = new GZIPOutputStream(new IOOutputStream(args[0])); - - return this; - } - - @JRubyMethod(name = "close") - public IRubyObject close() throws IOException { - if (!closed) { - io.close(); - } - this.closed = true; - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "append", required = 1) - public IRubyObject append(IRubyObject p1) throws IOException { - this.write(p1); - return this; - } - - @JRubyMethod(name = "printf", required = 1, rest = true) - public IRubyObject printf(ThreadContext context, IRubyObject[] args) throws IOException { - write(RubyKernel.sprintf(context, this, args)); - return context.getRuntime().getNil(); - } - - @JRubyMethod(name = "print", rest = true) - public IRubyObject print(IRubyObject[] args) throws IOException { - if (args.length != 0) { - for (int i = 0, j = args.length; i < j; i++) { - write(args[i]); - } - } - - IRubyObject sep = getRuntime().getGlobalVariables().get("$\\"); - if (!sep.isNil()) { - write(sep); - } - - return getRuntime().getNil(); - } - - @JRubyMethod(name = "pos") - public IRubyObject pos() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "orig_name=", required = 1) - public IRubyObject set_orig_name(IRubyObject ignored) { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "comment=", required = 1) - public IRubyObject set_comment(IRubyObject ignored) { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "putc", required = 1) - public IRubyObject putc(IRubyObject p1) throws IOException { - io.write(RubyNumeric.fix2int(p1)); - return p1; - } - - @JRubyMethod(name = "puts", rest = true) - public IRubyObject puts(ThreadContext context, IRubyObject[] args) throws IOException { - RubyStringIO sio = (RubyStringIO)getRuntime().fastGetClass("StringIO").newInstance(context, new IRubyObject[0], Block.NULL_BLOCK); - sio.puts(context, args); - write(sio.string()); - - return getRuntime().getNil(); - } - - public IRubyObject finish() throws IOException { - if (!finished) { - io.finish(); - } - finished = true; - return realIo; - } - - @JRubyMethod(name = "flush", optional = 1) - public IRubyObject flush(IRubyObject[] args) throws IOException { - if (args.length == 0 || args[0].isNil() || RubyNumeric.fix2int(args[0]) != 0) { // Zlib::NO_FLUSH - io.flush(); - } - return getRuntime().getNil(); - } - - @JRubyMethod(name = "mtime=", required = 1) - public IRubyObject set_mtime(IRubyObject ignored) { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "tell") - public IRubyObject tell() { - return getRuntime().getNil(); - } - - @JRubyMethod(name = "write", required = 1) - public IRubyObject write(IRubyObject p1) throws IOException { - ByteList bytes = p1.convertToString().getByteList(); - io.write(bytes.unsafeBytes(), bytes.begin(), bytes.length()); - return getRuntime().newFixnum(bytes.length()); - } - } -} -/***** BEGIN LICENSE BLOCK ***** - * Version: CPL 1.0/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Common Public - * License Version 1.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.eclipse.org/legal/cpl-v10.html - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * Copyright (C) 2002 Jan Arne Petersen <jpetersen@uni-bonn.de> - * Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se> - * Copyright (C) 2004 Thomas E Enebo <enebo@acm.org> - * Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de> - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the CPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the CPL, the GPL or the LGPL. - ***** END LICENSE BLOCK *****/ -package org.jruby; - -import org.jruby.runtime.Arity; -import org.jruby.runtime.Block; -import org.jruby.runtime.builtin.IRubyObject; -import org.jruby.runtime.callback.Callback; - -/** - * - * @author jpetersen - */ -public final class TopSelfFactory { - - /** - * Constructor for TopSelfFactory. - */ - private TopSelfFactory() { - super(); - } - - public static IRubyObject createTopSelf(final Ruby runtime) { - IRubyObject topSelf = new RubyObject(runtime, runtime.getObject()); - - topSelf.getSingletonClass().defineFastMethod("to_s", new Callback() { - /** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) - */ - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) { - return runtime.newString("main"); - } - - /** - * @see org.jruby.runtime.callback.Callback#getArity() - */ - public Arity getArity() { - return Arity.noArguments(); - } - }); - - // The following three methods must be defined fast, since they expect to modify the current frame - // (i.e. they expect no frame will be allocated for them). JRUBY-1185. - topSelf.getSingletonClass().defineFastPrivateMethod("include", new Callback() { - /** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) - */ - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block block) { - runtime.secure(4); - return runtime.getObject().include(args); - } - - /** - * @see org.jruby.runtime.callback.Callback#getArity() - */ - public Arity getArity() { - return Arity.optional(); - } - }); - - topSelf.getSingletonClass().defineFastPrivateMethod("public", new Callback() { - /** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) - */ - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - return runtime.getObject().rbPublic(recv.getRuntime().getCurrentContext(), args); - } - - /** - * @see org.jruby.runtime.callback.Callback#getArity() - */ - public Arity getArity() { - return Arity.optional(); - } - }); - - topSelf.getSingletonClass().defineFastPrivateMethod("private", new Callback() { - /** - * @see org.jruby.runtime.callback.Callback#execute(IRubyObject, IRubyObject[]) - */ - public IRubyObject execute(IRubyObject recv, IRubyObject[] args, Block unusedBlock) { - return runtime.getObject().rbPrivate(recv.getRuntime().getCurrentContext(), args); - } - - /** - * @see org.jruby.runtime.callback.Callback#getArity() - */ - public Arity getArity() { - return Arity.optional(); - } - }); - - return topSelf; - } -} diff --git a/test/scanners/java/suite.rb b/test/scanners/java/suite.rb deleted file mode 100644 index b6d5067..0000000 --- a/test/scanners/java/suite.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ScannerTests - class Java < CodeRay::TestCase - end -end
\ No newline at end of file |