rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
| meta
stringlengths 141
403
|
---|---|---|---|
public AbstractMetaClass(IRuby runtime, RubyClass metaClass, RubyClass superClass, RubyModule parentModule, String name) { super(runtime, metaClass, superClass, parentModule, name); | protected AbstractMetaClass(IRuby runtime, RubyClass metaClass, RubyClass superClass, SinglyLinkedList parentCRef, String name, Class builtinClass) { super(runtime, metaClass, superClass, parentCRef, name); this.builtinClass = builtinClass; | public AbstractMetaClass(IRuby runtime, RubyClass metaClass, RubyClass superClass, RubyModule parentModule, String name) { super(runtime, metaClass, superClass, parentModule, name); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/a1b8fc1d456e3d5c6e01579b88773383068aa85c/AbstractMetaClass.java/buggy/src/org/jruby/runtime/builtin/meta/AbstractMetaClass.java |
return ((RubyArray)ary).m_initialize(argv.length > 0 ? (RubyFixnum)argv[0] : null, argv.length > 1 ? (RubyObject)argv[1] : null); | return ((RubyArray)ary).m_initialize((RubyObject[])argv); | public VALUE rb_ary_initialize(VALUE[] argv, VALUE ary) { return ((RubyArray)ary).m_initialize(argv.length > 0 ? (RubyFixnum)argv[0] : null, argv.length > 1 ? (RubyObject)argv[1] : null); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/658d41dfe4d2bc92a7ecefae9ca04e116d2c290b/RubyOriginalMethods.java/buggy/org/jruby/original/RubyOriginalMethods.java |
return ((RubyModule)klass).m_attr((RubySymbol)argv[0], argv.length > 1 ? (RubyBoolean)argv[1] : ruby.getFalse()); | return ((RubyModule)klass).m_attr((RubySymbol)argv[0], (RubyObject[])argv); | public VALUE rb_mod_attr(VALUE[] argv, VALUE klass) { return ((RubyModule)klass).m_attr((RubySymbol)argv[0], argv.length > 1 ? (RubyBoolean)argv[1] : ruby.getFalse()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/658d41dfe4d2bc92a7ecefae9ca04e116d2c290b/RubyOriginalMethods.java/buggy/org/jruby/original/RubyOriginalMethods.java |
return RubyModule.m_newModule(ruby, (RubyClass)klass); | return RubyModule.m_new(ruby, (RubyObject)klass); | public VALUE rb_module_s_new(VALUE klass) { return RubyModule.m_newModule(ruby, (RubyClass)klass); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/658d41dfe4d2bc92a7ecefae9ca04e116d2c290b/RubyOriginalMethods.java/buggy/org/jruby/original/RubyOriginalMethods.java |
if (getToken(n+1).kind == WORD && getToken(n+1).image.equals(keyword)) | if (getToken(n).kind == WORD && getToken(n).image.equals(keyword)) | boolean lookahead_keyword(String keyword) throws ParseException { int n=1; if (getToken(n).kind == WS) ++n; if (getToken(n+1).kind == WORD && getToken(n+1).image.equals(keyword)) return true; else return false; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/6a0e6304bb469bba21d023d3e90cd11605e8c1cf/WMParser_impl.java/clean/webmacro/src/org/webmacro/parser/WMParser_impl.java |
System.out.println("Argument " + i + ": " + arg.type + " " + arg.id); | void parse_args(ArgDescriptor[] args, DirectiveArgs da) throws ParseException { try { for (int i=0; i < args.length; ) { ArgDescriptor arg = args[i]; System.out.println("Argument " + i + ": " + arg.type + " " + arg.id); if (arg.type == Directive.ArgType_GROUP) parse_arg_group(args, i, da); else if (arg.type == Directive.ArgType_CHOICE) { for (int j=0; j<arg.subordinateArgs; j++) { // Each child is a GROUP, so we want to look at child's first child ArgDescriptor child = args[arg.children[j]]; if (lookahead_keyword(args[child.children[0]].keyword)) parse_arg_group(args, arg.children[j], da); } } else { Object o = parse_arg(arg); da.setArg(arg.id, o); } System.out.println("Next " + i + " is " + arg.nextArg); i = arg.nextArg; } } catch (BuildException e) { throw new ParseException("BuildException", e); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/6a0e6304bb469bba21d023d3e90cd11605e8c1cf/WMParser_impl.java/clean/webmacro/src/org/webmacro/parser/WMParser_impl.java |
|
System.out.println("Next " + i + " is " + arg.nextArg); | void parse_args(ArgDescriptor[] args, DirectiveArgs da) throws ParseException { try { for (int i=0; i < args.length; ) { ArgDescriptor arg = args[i]; System.out.println("Argument " + i + ": " + arg.type + " " + arg.id); if (arg.type == Directive.ArgType_GROUP) parse_arg_group(args, i, da); else if (arg.type == Directive.ArgType_CHOICE) { for (int j=0; j<arg.subordinateArgs; j++) { // Each child is a GROUP, so we want to look at child's first child ArgDescriptor child = args[arg.children[j]]; if (lookahead_keyword(args[child.children[0]].keyword)) parse_arg_group(args, arg.children[j], da); } } else { Object o = parse_arg(arg); da.setArg(arg.id, o); } System.out.println("Next " + i + " is " + arg.nextArg); i = arg.nextArg; } } catch (BuildException e) { throw new ParseException("BuildException", e); } } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/6a0e6304bb469bba21d023d3e90cd11605e8c1cf/WMParser_impl.java/clean/webmacro/src/org/webmacro/parser/WMParser_impl.java |
|
System.out.println("Processing subdirective " + subd.name); | DirectiveBuilder parse_directive(String directive) throws ParseException, ParseException { DirectiveBuilder db=null; DirectiveDescriptor descriptor=null; Subdirective subd; try { descriptor = (DirectiveDescriptor) broker.get("org.webmacro.directive.Directive", directive); if (!descriptor.valid) throw new ParseException("Descriptor for directive " + directive + " is not valid"); } catch (Exception e) { throw new ParseException("Exception fetching directive "+directive + System.getProperty("line.separator"), e); } db = new DirectiveBuilder(descriptor); parse_args(descriptor.args, db); if (descriptor.subdirectives != null && descriptor.subdirectives.length > 0) { DirectiveArgs da; while ((subd = lookahead_subdirective(descriptor.subdirectives)) != null) { System.out.println("Processing subdirective " + subd.name); SubdirectiveStart(); try { da = db.newSubdirective(subd.id); } catch (BuildException e) { throw new ParseException("BuildException", e); }; parse_args(subd.args, da); System.out.println("Done with subdirective " + subd.name); } } OptionalWs(); return db; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/6a0e6304bb469bba21d023d3e90cd11605e8c1cf/WMParser_impl.java/clean/webmacro/src/org/webmacro/parser/WMParser_impl.java |
|
System.out.println("Done with subdirective " + subd.name); | DirectiveBuilder parse_directive(String directive) throws ParseException, ParseException { DirectiveBuilder db=null; DirectiveDescriptor descriptor=null; Subdirective subd; try { descriptor = (DirectiveDescriptor) broker.get("org.webmacro.directive.Directive", directive); if (!descriptor.valid) throw new ParseException("Descriptor for directive " + directive + " is not valid"); } catch (Exception e) { throw new ParseException("Exception fetching directive "+directive + System.getProperty("line.separator"), e); } db = new DirectiveBuilder(descriptor); parse_args(descriptor.args, db); if (descriptor.subdirectives != null && descriptor.subdirectives.length > 0) { DirectiveArgs da; while ((subd = lookahead_subdirective(descriptor.subdirectives)) != null) { System.out.println("Processing subdirective " + subd.name); SubdirectiveStart(); try { da = db.newSubdirective(subd.id); } catch (BuildException e) { throw new ParseException("BuildException", e); }; parse_args(subd.args, da); System.out.println("Done with subdirective " + subd.name); } } OptionalWs(); return db; } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/6a0e6304bb469bba21d023d3e90cd11605e8c1cf/WMParser_impl.java/clean/webmacro/src/org/webmacro/parser/WMParser_impl.java |
|
public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) | public void ReInit(java.io.Reader dstream, int startline, int startcolumn, int buffersize) | public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/24d9ef23d787da791b5e1f6fbf8aa3cd7d26224b/ASCII_CharStream.java/buggy/webmacro/src/org/webmacro/parser/ASCII_CharStream.java |
ReInit(dstream, startline, startcolumn, 4096); | inputStream = dstream; line = startline; column = startcolumn - 1; if (bufA == null || bufA.size != buffersize) bufA = new Buffer(buffersize); if (bufB == null || bufB.size != buffersize) bufB = new Buffer(buffersize); curBuf = bufA; otherBuf = bufB; curBuf.curPos = otherBuf.dataLen = -1; curBuf.dataLen = otherBuf.dataLen = 0; prevCharIsLF = prevCharIsCR = false; tokenBeginPos = -1; tokenBeginBuf = null; backupChars = 0; | public void ReInit(java.io.InputStream dstream, int startline, int startcolumn) { ReInit(dstream, startline, startcolumn, 4096); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/24d9ef23d787da791b5e1f6fbf8aa3cd7d26224b/ASCII_CharStream.java/buggy/webmacro/src/org/webmacro/parser/ASCII_CharStream.java |
public ASCII_CharStream(java.io.InputStream dstream, int startline, int startcolumn) | public ASCII_CharStream(java.io.Reader dstream, int startline, int startcolumn, int buffersize) | public ASCII_CharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/24d9ef23d787da791b5e1f6fbf8aa3cd7d26224b/ASCII_CharStream.java/buggy/webmacro/src/org/webmacro/parser/ASCII_CharStream.java |
this(dstream, startline, startcolumn, 4096); | ReInit(dstream, startline, startcolumn, buffersize); | public ASCII_CharStream(java.io.InputStream dstream, int startline, int startcolumn) { this(dstream, startline, startcolumn, 4096); } | 52513 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52513/24d9ef23d787da791b5e1f6fbf8aa3cd7d26224b/ASCII_CharStream.java/buggy/webmacro/src/org/webmacro/parser/ASCII_CharStream.java |
if (attributeInfo.isReadable()) { String getterName = attributeInfo.getGetterName(); MethodMetadata getter = classMetadata.getMethod(new OperationSignature(getterName, new String[] {})); if (getter != null) { getter.put("persistent", "true"); } } if (attributeInfo.isWritable()) { String setterName = attributeInfo.getSetterName(); MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {attributeInfo.getType()})); if (setter != null) { setter.put("persistent", "true"); } } | public void addClassMetadata(ClassMetadata classMetadata) { Class type = classMetadata.getType(); GBeanInfo gbeanInfo = getGBeanInfo(type); if (gbeanInfo == null) { return; } classMetadata.put("j2eeType", gbeanInfo.getJ2eeType()); Set attributes = gbeanInfo.getAttributes(); Set references = gbeanInfo.getReferences(); Map attributeTypes = new HashMap(attributes.size() + references.size()); for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next(); if (attributeInfo.isReadable()) { String getterName = attributeInfo.getGetterName(); MethodMetadata getter = classMetadata.getMethod(new OperationSignature(getterName, new String[] {})); if (getter != null) { getter.put("persistent", "true"); } } if (attributeInfo.isWritable()) { String setterName = attributeInfo.getSetterName(); MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {attributeInfo.getType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(attributeInfo.getType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(attributeInfo.getName(), attributeType); } for (Iterator iterator = references.iterator(); iterator.hasNext();) { GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); String setterName = referenceInfo.getSetterName(); if (setterName != null) { MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {referenceInfo.getProxyType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(referenceInfo.getProxyType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(referenceInfo.getName(), attributeType); } List constructorArgNames = gbeanInfo.getConstructor().getAttributeNames(); List constructorArgTypes = new ArrayList(constructorArgNames.size()); for (Iterator iterator = constructorArgNames.iterator(); iterator.hasNext();) { String constructorArgName = (String) iterator.next(); constructorArgTypes.add(attributeTypes.get(constructorArgName)); } if (!constructorArgTypes.contains(null)) { ConstructorMetadata constructor = classMetadata.getConstructor(new ConstructorSignature(constructorArgTypes)); if (constructor != null) { constructor.put("always-use", "true"); for (ListIterator iterator = constructor.getParameters().listIterator(); iterator.hasNext();) { ParameterMetadata parameter = (ParameterMetadata) iterator.next(); String name = (String) constructorArgNames.get(iterator.previousIndex()); parameter.put("name", name); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/6a661ce4fbc3261ed4b3a744b1e1919df53cbbf7/GeronimoMetadataProvider.java/buggy/kernel/src/java/org/gbean/geronimo/GeronimoMetadataProvider.java |
|
String setterName = referenceInfo.getSetterName(); if (setterName != null) { MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {referenceInfo.getProxyType()})); if (setter != null) { setter.put("persistent", "true"); } } | public void addClassMetadata(ClassMetadata classMetadata) { Class type = classMetadata.getType(); GBeanInfo gbeanInfo = getGBeanInfo(type); if (gbeanInfo == null) { return; } classMetadata.put("j2eeType", gbeanInfo.getJ2eeType()); Set attributes = gbeanInfo.getAttributes(); Set references = gbeanInfo.getReferences(); Map attributeTypes = new HashMap(attributes.size() + references.size()); for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next(); if (attributeInfo.isReadable()) { String getterName = attributeInfo.getGetterName(); MethodMetadata getter = classMetadata.getMethod(new OperationSignature(getterName, new String[] {})); if (getter != null) { getter.put("persistent", "true"); } } if (attributeInfo.isWritable()) { String setterName = attributeInfo.getSetterName(); MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {attributeInfo.getType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(attributeInfo.getType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(attributeInfo.getName(), attributeType); } for (Iterator iterator = references.iterator(); iterator.hasNext();) { GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); String setterName = referenceInfo.getSetterName(); if (setterName != null) { MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {referenceInfo.getProxyType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(referenceInfo.getProxyType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(referenceInfo.getName(), attributeType); } List constructorArgNames = gbeanInfo.getConstructor().getAttributeNames(); List constructorArgTypes = new ArrayList(constructorArgNames.size()); for (Iterator iterator = constructorArgNames.iterator(); iterator.hasNext();) { String constructorArgName = (String) iterator.next(); constructorArgTypes.add(attributeTypes.get(constructorArgName)); } if (!constructorArgTypes.contains(null)) { ConstructorMetadata constructor = classMetadata.getConstructor(new ConstructorSignature(constructorArgTypes)); if (constructor != null) { constructor.put("always-use", "true"); for (ListIterator iterator = constructor.getParameters().listIterator(); iterator.hasNext();) { ParameterMetadata parameter = (ParameterMetadata) iterator.next(); String name = (String) constructorArgNames.get(iterator.previousIndex()); parameter.put("name", name); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/6a661ce4fbc3261ed4b3a744b1e1919df53cbbf7/GeronimoMetadataProvider.java/buggy/kernel/src/java/org/gbean/geronimo/GeronimoMetadataProvider.java |
|
parameter.put("name", name); | parameter.put("name", fixPropertyName(name)); | public void addClassMetadata(ClassMetadata classMetadata) { Class type = classMetadata.getType(); GBeanInfo gbeanInfo = getGBeanInfo(type); if (gbeanInfo == null) { return; } classMetadata.put("j2eeType", gbeanInfo.getJ2eeType()); Set attributes = gbeanInfo.getAttributes(); Set references = gbeanInfo.getReferences(); Map attributeTypes = new HashMap(attributes.size() + references.size()); for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next(); if (attributeInfo.isReadable()) { String getterName = attributeInfo.getGetterName(); MethodMetadata getter = classMetadata.getMethod(new OperationSignature(getterName, new String[] {})); if (getter != null) { getter.put("persistent", "true"); } } if (attributeInfo.isWritable()) { String setterName = attributeInfo.getSetterName(); MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {attributeInfo.getType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(attributeInfo.getType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(attributeInfo.getName(), attributeType); } for (Iterator iterator = references.iterator(); iterator.hasNext();) { GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); String setterName = referenceInfo.getSetterName(); if (setterName != null) { MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {referenceInfo.getProxyType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(referenceInfo.getProxyType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(referenceInfo.getName(), attributeType); } List constructorArgNames = gbeanInfo.getConstructor().getAttributeNames(); List constructorArgTypes = new ArrayList(constructorArgNames.size()); for (Iterator iterator = constructorArgNames.iterator(); iterator.hasNext();) { String constructorArgName = (String) iterator.next(); constructorArgTypes.add(attributeTypes.get(constructorArgName)); } if (!constructorArgTypes.contains(null)) { ConstructorMetadata constructor = classMetadata.getConstructor(new ConstructorSignature(constructorArgTypes)); if (constructor != null) { constructor.put("always-use", "true"); for (ListIterator iterator = constructor.getParameters().listIterator(); iterator.hasNext();) { ParameterMetadata parameter = (ParameterMetadata) iterator.next(); String name = (String) constructorArgNames.get(iterator.previousIndex()); parameter.put("name", name); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/6a661ce4fbc3261ed4b3a744b1e1919df53cbbf7/GeronimoMetadataProvider.java/buggy/kernel/src/java/org/gbean/geronimo/GeronimoMetadataProvider.java |
if (!persistentProperties.isEmpty()) { classMetadata.put("persistentProperties", persistentProperties); } | public void addClassMetadata(ClassMetadata classMetadata) { Class type = classMetadata.getType(); GBeanInfo gbeanInfo = getGBeanInfo(type); if (gbeanInfo == null) { return; } classMetadata.put("j2eeType", gbeanInfo.getJ2eeType()); Set attributes = gbeanInfo.getAttributes(); Set references = gbeanInfo.getReferences(); Map attributeTypes = new HashMap(attributes.size() + references.size()); for (Iterator iterator = attributes.iterator(); iterator.hasNext();) { GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next(); if (attributeInfo.isReadable()) { String getterName = attributeInfo.getGetterName(); MethodMetadata getter = classMetadata.getMethod(new OperationSignature(getterName, new String[] {})); if (getter != null) { getter.put("persistent", "true"); } } if (attributeInfo.isWritable()) { String setterName = attributeInfo.getSetterName(); MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {attributeInfo.getType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(attributeInfo.getType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(attributeInfo.getName(), attributeType); } for (Iterator iterator = references.iterator(); iterator.hasNext();) { GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next(); String setterName = referenceInfo.getSetterName(); if (setterName != null) { MethodMetadata setter = classMetadata.getMethod(new OperationSignature(setterName, new String[] {referenceInfo.getProxyType()})); if (setter != null) { setter.put("persistent", "true"); } } Class attributeType = null; try { attributeType = ClassLoading.loadClass(referenceInfo.getProxyType(), type.getClassLoader()); } catch (ClassNotFoundException ignored) { // couldn't load the type.. just proceed and we'll skip the constructor declaration } attributeTypes.put(referenceInfo.getName(), attributeType); } List constructorArgNames = gbeanInfo.getConstructor().getAttributeNames(); List constructorArgTypes = new ArrayList(constructorArgNames.size()); for (Iterator iterator = constructorArgNames.iterator(); iterator.hasNext();) { String constructorArgName = (String) iterator.next(); constructorArgTypes.add(attributeTypes.get(constructorArgName)); } if (!constructorArgTypes.contains(null)) { ConstructorMetadata constructor = classMetadata.getConstructor(new ConstructorSignature(constructorArgTypes)); if (constructor != null) { constructor.put("always-use", "true"); for (ListIterator iterator = constructor.getParameters().listIterator(); iterator.hasNext();) { ParameterMetadata parameter = (ParameterMetadata) iterator.next(); String name = (String) constructorArgNames.get(iterator.previousIndex()); parameter.put("name", name); } } } } | 52533 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/52533/6a661ce4fbc3261ed4b3a744b1e1919df53cbbf7/GeronimoMetadataProvider.java/buggy/kernel/src/java/org/gbean/geronimo/GeronimoMetadataProvider.java |
|
return getRuntime().newString(getName()); | return getRuntime().newString(getBaseName() == null ? "" : getName()); | public RubyString name() { return getRuntime().newString(getName()); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/fa18cf1c1506d7dcf515c410c6af2e9ea36a87fe/RubyModule.java/clean/src/org/jruby/RubyModule.java |
if (ruby_iter.iter == ITER_PRE) { | if (rubyIter.getIter() == Iter.ITER_PRE) { | private BLOCK BEGIN_CALLARGS() { BLOCK tmp_block = ruby_block; if (ruby_iter.iter == ITER_PRE) { ruby_block = ruby_block.prev; } PUSH_ITER(ITER_NOT); return tmp_block; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
PUSH_ITER(ITER_NOT); | rubyIter.push(Iter.ITER_NOT); | private BLOCK BEGIN_CALLARGS() { BLOCK tmp_block = ruby_block; if (ruby_iter.iter == ITER_PRE) { ruby_block = ruby_block.prev; } PUSH_ITER(ITER_NOT); return tmp_block; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
POP_ITER(); | rubyIter.pop(); | private void END_CALLARGS(BLOCK tmp_block) { ruby_block = tmp_block; POP_ITER(); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
_block.iter = ruby_iter.iter; | _block.iter = rubyIter.getIter(); | private BLOCK PUSH_BLOCK(NODE v, NODE b, VALUE self) { BLOCK _block = new BLOCK(); // _block.tag = new_blktag(); _block.var = v; _block.body = b; _block.self = self; _block.frame = rubyFrame; _block.klass = ruby_class; // _block.frame.file = ruby_sourcefile; // _block.frame.line = ruby_sourceline; _block.scope = getRuby().rubyScope; _block.prev = ruby_block; _block.iter = ruby_iter.iter; _block.vmode = scope_vmode; _block.flags = BLOCK_D_SCOPE; _block.dyna_vars = getDynamicVars(); ruby_block = _block; return _block; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through */ /* default: JUMP_TAG(state); } }*/ break; | while (true) { BLOCK _block = PUSH_BLOCK(node.nd_var(), node.nd_body(), self); try { rubyIter.push(Iter.ITER_PRE); if (node.nd_type() == NODE_ITER) { result = eval(self, node.nd_iter()); } else { _block.flags &= ~BLOCK_D_SCOPE; BLOCK tmp_block = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_iter()); END_CALLARGS(tmp_block); result = recv.getRubyClass().call(recv, ruby.intern("each"), null, 0); } rubyIter.pop(); break; } catch (RetryException rExcptn) { POP_BLOCK(_block); } catch (ReturnException rExcptn) { POP_BLOCK(_block); result = rExcptn.getReturnValue(); break; } catch (BreakException bExcptn) { POP_BLOCK(_block); result = ruby.getNil(); break; } } return result; | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ | if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); if (node.nd_stts().nd_type() == NODE_RESTARGS && ((RubyArray)result).length() == 1) { result = ((RubyArray)result).entry(0); } } else { result = ruby.getNil(); } return yield0(result, null, null, false); | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); | rubyIter.push(rubyIter.getIter() != Iter.ITER_NOT ? Iter.ITER_PRE : Iter.ITER_NOT); | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
POP_ITER(); | rubyIter.pop(); | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
if (ruby.rubyScope.getLocalVars() == null) { throw new RuntimeException("BUG: unexpected block argument"); } if (isBlockGiven()) { result = getRuby().getNil(); ruby.rubyScope.setLocalVars(node.nd_cnt(), result); return result; } else { | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
|
} | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
|
/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; | if (rubyFrame.getArgs().size() != 1) { throw new RubyArgumentException("wrong # of arguments(" + rubyFrame.getArgs().size() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), (RubyObject)rubyFrame.getArgs().get(0)); | public RubyObject eval(RubyObject self, NODE n) { NODE node = n; RubyBoolean cond = null; RubyObject[] args = null; RubyObject result = null; // int state; // RubyOriginalMethods rom = getRuby().getOriginalMethods(); while (true) { if (node == null) { return getRuby().getNil(); } switch (node.nd_type()) { case NODE_BLOCK: while (node.nd_next() != null) { eval(self, node.nd_head()); node = node.nd_next(); } node = node.nd_head(); break; case NODE_POSTEXE: // rb_f_END(); node.nd_set_type(NODE_NIL); /* exec just once */ return getRuby().getNil(); /* begin .. end without clauses */ case NODE_BEGIN: node = node.nd_body(); break; /* nodes for speed-up(default match) */ case NODE_MATCH: //return rom.rb_reg_match2(node.nd_head().nd_lit()); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH2: //return rom.rb_reg_match(eval(node.nd_recv()), eval(node.nd_value())); return getRuby().getNil(); /* nodes for speed-up(literal match) */ case NODE_MATCH3: //VALUE r = eval(node.nd_recv()); //VALUE l = eval(node.nd_value()); //if (r instanceof RubyString) { // return rom.rb_reg_match(l, r); //} else { // return rom.rb_funcall(r, match, 1, l); //} return getRuby().getNil(); /* node for speed-up(top-level loop for -n/-p) */ case NODE_OPT_N:/* PUSH_TAG(PROT_NONE); switch (state = EXEC_TAG()) { case 0: opt_n_next: while (!NIL_P(rb_gets())) { opt_n_redo: rb_eval(self, node->nd_body); } break; case TAG_REDO: state = 0; goto opt_n_redo; case TAG_NEXT: state = 0; goto opt_n_next; case TAG_BREAK: state = 0; default: break; } POP_TAG(); if (state) JUMP_TAG(state); RETURN(Qnil);*/ return getRuby().getNil(); case NODE_SELF: return self; case NODE_NIL: return getRuby().getNil(); case NODE_TRUE: return getRuby().getTrue(); case NODE_FALSE: return getRuby().getFalse(); case NODE_IF: // ruby_sourceline = node.nd_line(); cond = (RubyBoolean)eval(self, node.nd_cond()); if (cond.isTrue()) { node = node.nd_body(); } else { node = node.nd_else(); } break; case NODE_WHEN: while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); }*/ // ruby_sourcefile = tag.nd_file; // ruby_sourceline = tag.nd_line(); if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj = eval(self, tag.nd_head().nd_head()); if (!(obj instanceof RubyArray)) { obj = RubyArray.m_newArray(getRuby(), obj); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { if (((RubyBoolean)((RubyArray)obj).entry(i)).isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head())).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_CASE: RubyObject obj = eval(self, node.nd_head()); node = node.nd_body(); while (node != null) { NODE tag; if (node.nd_type() != NODE_WHEN) { break; } tag = node.nd_head(); while (tag != null) {/* if (trace_func) { call_trace_func("line", tag->nd_file, nd_line(tag), self, ruby_frame->last_func, ruby_frame->last_class); } ruby_sourcefile = tag->nd_file; ruby_sourceline = nd_line(tag);*/ if (tag.nd_head().nd_type() == NODE_WHEN) { RubyObject obj2 = eval(self, tag.nd_head().nd_head()); if (!(obj2 instanceof RubyArray)) { obj2 = RubyArray.m_newArray(getRuby(), obj2); } for (int i = 0; i < ((RubyArray)obj).length(); i++) { RubyBoolean eqq = (RubyBoolean)((RubyArray)obj2).entry(i).funcall(getRuby().intern("==="), obj); if (eqq.isTrue()) { node = node.nd_body(); break; } } tag = tag.nd_next(); continue; } if (((RubyBoolean)eval(self, tag.nd_head()).funcall(getRuby().intern("==="), obj)).isTrue()) { node = node.nd_body(); break; } tag = tag.nd_next(); } node = node.nd_next(); } return getRuby().getNil(); case NODE_WHILE: while (eval(self, node.nd_cond()).isTrue()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_UNTIL: while (eval(self, node.nd_cond()).isFalse()) { while (true) { try { eval(self, node.nd_body()); break; } catch (RedoException rExcptn) { } catch (NextException nExcptn) { break; } catch (BreakException bExcptn) { return getRuby().getNil(); } } } return getRuby().getNil(); case NODE_BLOCK_PASS: //return block_pass(node); return null; case NODE_ITER: case NODE_FOR:/* { iter_retry: PUSH_TAG(PROT_FUNC); PUSH_BLOCK(node->nd_var, node->nd_body); state = EXEC_TAG(); if (state == 0) { PUSH_ITER(ITER_PRE); if (nd_type(node) == NODE_ITER) { result = rb_eval(self, node->nd_iter); } else { VALUE recv; char *file = ruby_sourcefile; int line = ruby_sourceline; _block.flags &= ~BLOCK_D_SCOPE; BEGIN_CALLARGS; recv = rb_eval(self, node->nd_iter); END_CALLARGS; ruby_sourcefile = file; ruby_sourceline = line; result = rb_call(CLASS_OF(recv),recv,each,0,0,0); } POP_ITER(); } else if (_block.tag->dst == state) { state &= TAG_MASK; if (state == TAG_RETURN) { result = prot_tag->retval; } } POP_BLOCK(); POP_TAG(); switch (state) { case 0: break; case TAG_RETRY: goto iter_retry; case TAG_BREAK: result = Qnil; break; case TAG_RETURN: return_value(result); */ /* fall through *//* default: JUMP_TAG(state); } }*/ break; case NODE_BREAK: throw new BreakException(); case NODE_NEXT: throw new NextException(); case NODE_REDO: throw new RedoException(); case NODE_RETRY: throw new RetryException(); case NODE_RESTARGS: result = eval(self, node.nd_head()); if (!(result instanceof RubyArray)) { result = obj = RubyArray.m_newArray(getRuby(), result); } return result; case NODE_YIELD:/* if (node.nd_stts) { result = rb_eval(self, node->nd_stts); if (nd_type(node->nd_stts) == NODE_RESTARGS && RARRAY(result)->len == 1) { result = RARRAY(result)->ptr[0]; } } else { result = Qnil; } result = rb_yield_0(result, 0, 0, 0); break;*/ case NODE_RESCUE:/* retry_entry: { volatile VALUE e_info = ruby_errinfo; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_head); } POP_TAG(); if (state == TAG_RAISE) { NODE * volatile resq = node->nd_resq; ruby_sourceline = nd_line(node); while (resq) { if (handle_rescue(self, resq)) { state = 0; PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, resq->nd_body); } POP_TAG(); if (state == TAG_RETRY) { state = 0; ruby_errinfo = Qnil; goto retry_entry; } if (state != TAG_RAISE) { ruby_errinfo = e_info; } break; } resq = resq->nd_head; /* next rescue */ /** } * } * else if (node->nd_else) { /* else clause given *//* if (!state) { /* no exception raised *//* result = rb_eval(self, node->nd_else); } } if (state) JUMP_TAG(state); } break;*/ case NODE_ENSURE:/* PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { result = eval(node.nd_head()); } POP_TAG(); if (node.nd_ensr()) { VALUE retval = prot_tag->retval; /* save retval *//* VALUE errinfo = ruby_errinfo; rb_eval(self, node->nd_ensr); return_value(retval); ruby_errinfo = errinfo; } if (state) JUMP_TAG(state); break;*/ case NODE_AND: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isFalse()) { return cond; } node = node.nd_2nd(); break; case NODE_OR: cond = (RubyBoolean)eval(self, node.nd_1st()); if (cond.isTrue()) { return cond; } node = node.nd_2nd(); break; case NODE_NOT: return RubyBoolean.m_newBoolean(getRuby(), eval(self, node.nd_1st()).isFalse()); case NODE_DOT2: case NODE_DOT3: result = RubyRange.m_newRange(getRuby(), eval(self, node.nd_beg()), eval(self, node.nd_end()), node.nd_type() == NODE_DOT3); if (node.nd_state() != 0) { return result; } if (node.nd_beg().nd_type() == NODE_LIT && (node.nd_beg().nd_lit() instanceof RubyFixnum) && node.nd_end().nd_type() == NODE_LIT && (node.nd_end().nd_lit() instanceof RubyFixnum)) { node.nd_set_type(NODE_LIT); node.nd_lit(result); } else { node.nd_state(1L); } return result; case NODE_FLIP2: /* like AWK */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { if (RTEST(rb_eval(self, node->nd_beg))) { ruby_scope->local_vars[node->nd_cnt] = RTEST(rb_eval(self, node->nd_end))?Qfalse:Qtrue; result = Qtrue; } else { result = Qfalse; } } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_FLIP3: /* like SED */ //RubyBoolean result;/* if (ruby_scope->local_vars == 0) { rb_bug("unexpected local variable"); } if (!RTEST(ruby_scope->local_vars[node->nd_cnt])) { result = RTEST(rb_eval(self, node->nd_beg)) ? Qtrue : Qfalse; ruby_scope->local_vars[node->nd_cnt] = result; } else { if (RTEST(rb_eval(self, node->nd_end))) { ruby_scope->local_vars[node->nd_cnt] = Qfalse; } result = Qtrue; }*/ return result; case NODE_RETURN: if (node.nd_stts() != null) { result = eval(self, node.nd_stts()); } else { result = ruby.getNil(); } throw new ReturnException(result); case NODE_ARGSCAT: return ((RubyArray)eval(self, node.nd_head())).m_concat(eval(self, node.nd_body())); case NODE_ARGSPUSH: return ((RubyArray)eval(self, node.nd_head()).m_dup()).push(eval(self, node.nd_body())); case NODE_CALL: // TMP_PROTECT; BLOCK tmpBlock = BEGIN_CALLARGS(); RubyObject recv = eval(self, node.nd_recv()); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return recv.getRubyClass().call(recv, (RubyId)node.nd_mid(), args, 0); case NODE_FCALL: // TMP_PROTECT; tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); return self.getRubyClass().call(self, (RubyId)node.nd_mid(), args, 1); case NODE_VCALL: return self.getRubyClass().call(self, (RubyId)node.nd_mid(), null, 2); case NODE_SUPER: case NODE_ZSUPER: // TMP_PROTECT; if (rubyFrame.getLastClass() == null) { throw new RubyNameException("superclass method '" + rubyFrame.getLastFunc().toName() + "' disabled"); } if (node.nd_type() == NODE_ZSUPER) { List argsList = rubyFrame.getArgs(); args = (RubyObject[])argsList.toArray(new RubyObject[argsList.size()]); } else { tmpBlock = BEGIN_CALLARGS(); args = setupArgs(self, node.nd_args()); END_CALLARGS(tmpBlock); } PUSH_ITER(ruby_iter.iter != 0 ? ITER_PRE : ITER_NOT); result = rubyFrame.getLastClass().getSuperClass().call(rubyFrame.getSelf(), rubyFrame.getLastFunc(), args, 3); POP_ITER(); return result; case NODE_SCOPE: /*NODE saved_cref = null; FRAME frame = ruby_frame; frame.tmp = ruby_frame; ruby_frame = frame; PUSH_SCOPE(); PUSH_TAG(PROT_NONE); if (node->nd_rval) { saved_cref = ruby_cref; ruby_cref = (NODE*)node->nd_rval; ruby_frame->cbase = node->nd_rval; }*/ if (node.nd_tbl() != null) { List tmp = Collections.nCopies(node.nd_tbl()[0].intValue() + 1, ruby.getNil()); ShiftableList vars = new ShiftableList(new ArrayList(tmp)); vars.set(0, (VALUE)node); vars.shift(1); getRuby().rubyScope.setLocalVars(vars); getRuby().rubyScope.setLocalTbl(node.nd_tbl()); } else { getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalTbl(null); }/* if ((state = EXEC_TAG()) == 0) { result = rb_eval(self, node->nd_next); } POP_TAG(); POP_SCOPE(); ruby_frame = frame.tmp; if (saved_cref) ruby_cref = saved_cref; if (state) JUMP_TAG(state); } break; */ case NODE_OP_ASGN1: // TMP_PROTECT; recv = eval(self, node.nd_recv()); NODE rval = node.nd_args().nd_head(); args = setupArgs(self, node.nd_args().nd_next()); ArrayList argsList = new ArrayList(Arrays.asList(args)); argsList.remove(args.length - 1); RubyBoolean val = (RubyBoolean)recv.funcall(getRuby().intern("[]"), (RubyObject[])argsList.toArray(new RubyObject[argsList.size()])); switch (node.nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, rval); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, rval); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, rval)); } args[args.length - 1] = val; return recv.funcall(getRuby().intern("[]="), args); case NODE_OP_ASGN2: ID id = node.nd_next().nd_vid(); recv = eval(self, node.nd_recv()); val = (RubyBoolean)recv.funcall((RubyId)id, (RubyObject[])null); switch (node.nd_next().nd_mid().intValue()) { case 0: /* OR */ if (val.isTrue()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; case 1: /* AND */ if (val.isFalse()) { return val; } val = (RubyBoolean)eval(self, node.nd_value()); break; default: val = (RubyBoolean)val.funcall((RubyId)node.nd_mid(), eval(self, node.nd_value())); } // rom.rb_funcall2(recv, node.nd_next().nd_aid(), 1, &val); return val; case NODE_OP_ASGN_AND: cond = (RubyBoolean)eval(self, node.nd_head()); if (cond.isFalse()) { return cond; } node = node.nd_value(); break; case NODE_OP_ASGN_OR: cond = (RubyBoolean)eval(self, node.nd_head()); if ((node.nd_aid() != null && !self.isIvarDefined((RubyId)node.nd_aid())) || cond.isFalse()) { node = node.nd_value(); break; } return cond; case NODE_MASGN: return massign(self, node, eval(self, node.nd_value()), false); case NODE_LASGN: // if (ruby.ruby_scope.local_vars == null) { // rb_bug("unexpected local variable assignment"); // } result = eval(self, node.nd_value()); getRuby().rubyScope.setLocalVars(node.nd_cnt(), result); return result; case NODE_DASGN: result = eval(self, node.nd_value()); RubyVarmap.assign(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_DASGN_CURR: result = eval(self, node.nd_value()); RubyVarmap.assignCurrent(ruby, (RubyId)node.nd_vid(), result); return result; case NODE_GASGN: result = eval(self, node.nd_value()); ((RubyGlobalEntry)node.nd_entry()).set(result); return result; case NODE_IASGN: result = eval(self, node.nd_value()); self.setIvar((RubyId)node.nd_vid(), result); return result; case NODE_CDECL: if (ruby_class == null) { throw new RubyTypeException("no class/module to define constant"); } result = eval(self, node.nd_value()); ruby_class.setConstant((RubyId)node.nd_vid(), result); return result; case NODE_CVDECL: if (ruby_cbase == null) { throw new RubyTypeException("no class/module to define class variable"); } result = eval(self, node.nd_value()); if (ruby_cbase.isSingleton()) { ruby_cbase.getIv("__attached__").getCvarSingleton().declareCvar((RubyId)node.nd_vid(), result); return result; } ruby_cbase.declareCvar((RubyId)node.nd_vid(), result); return result; case NODE_CVASGN: result = eval(self, node.nd_value()); self.getCvarSingleton().setCvar((RubyId)node.nd_vid(), result); return result; case NODE_LVAR: //if (getRuby().ruby_scope.local_vars == null) { // rb_bug("unexpected local variable"); // } return (RubyObject)getRuby().rubyScope.getLocalVars(node.nd_cnt()); case NODE_DVAR: return getDynamicVars().getRef((RubyId)node.nd_vid()); case NODE_GVAR: return ((RubyGlobalEntry)node.nd_entry()).get(); case NODE_IVAR: return self.getIvar((RubyId)node.nd_vid()); case NODE_CONST: return getConstant((NODE)rubyFrame.getCbase(), (RubyId)node.nd_vid(), self); case NODE_CVAR: /* normal method */ if (ruby_cbase == null) { return self.getRubyClass().getCvar((RubyId)node.nd_vid()); } if (!ruby_cbase.isSingleton()) { return ruby_cbase.getCvar((RubyId)node.nd_vid()); } return ruby_cbase.getIv("__attached__").getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_CVAR2: /* singleton method */ return self.getCvarSingleton().getCvar((RubyId)node.nd_vid()); case NODE_BLOCK_ARG: // if (ruby_scope.local_vars() == null) { // rom.rb_bug("unexpected block argument"); // } // if (rom.rb_block_given_p()) { // result = rom.rb_f_lambda(); // ruby_scope.local_vars()[node.nd_cnt()] = result; // } else { return getRuby().getNil(); // } case NODE_COLON2: RubyModule rubyClass = (RubyModule)eval(self, node.nd_head());/* switch (TYPE(klass)) { case T_CLASS: case T_MODULE: break; default: return rom.rb_funcall(klass, node.nd_mid(), 0, 0); }*/ return rubyClass.getConstant((RubyId)node.nd_mid()); case NODE_COLON3: return getRuby().getObjectClass().getConstant((RubyId)node.nd_mid()); case NODE_NTH_REF: // return rom.rb_reg_nth_match(node.nd_nth(), MATCH_DATA); return null; case NODE_BACK_REF: /*switch ((char)node.nd_nth()) { case '&': return rom.rb_reg_last_match(MATCH_DATA); case '`': return rom.rb_reg_match_pre(MATCH_DATA); case '\'': return rom.rb_reg_match_post(MATCH_DATA); case '+': return rom.rb_reg_match_last(MATCH_DATA); default: rom.rb_bug("unexpected back-ref"); }*/ case NODE_HASH:/* RubyHash hash = RubyHash.m_newHash(); RubyObject key, val; NODE list = node.nd_head(); while (list != null) { key = eval(self, list.nd_head()); list = list.nd_next(); if (list == null) { rom.rb_bug("odd number list for Hash"); } val = eval(self, list.nd_head()); list = list.nd_next(); hash.aset(key, val); } return hash;*/ case NODE_ZARRAY: /* zero length list */ return RubyArray.m_newArray(getRuby()); case NODE_ARRAY: RubyArray ary = (RubyArray)RubyArray.m_newArray(getRuby(), node.nd_alen()); for (int i = 0; node != null ; node = node.nd_next()) { ary.getArray().set(i++, eval(self, node.nd_head())); } return ary; case NODE_STR: return ((RubyObject)node.nd_lit()).m_to_s(); case NODE_DSTR: case NODE_DXSTR: case NODE_DREGX: case NODE_DREGX_ONCE:/* NODE list = node.nd_next(); RubyString str = RubyString.m_newString(getRuby(), (RubyObject)node.nd_lit()); RubyString str2; while (list != null) { if (list.nd_head() != null) { switch (list.nd_head().nd_type()) { case NODE_STR: str2 = (RubyString)list.nd_head().nd_lit(); break; case NODE_EVSTR: result = ruby_errinfo; ruby_errinfo = Qnil; ruby_sourceline = nd_line(node); ruby_in_eval++; list.nd_head(compile(list.nd_head().nd_lit(), ruby_sourcefile,ruby_sourceline)); ruby_eval_tree = 0; ruby_in_eval--; if (ruby_nerrs > 0) { compile_error("string expansion"); } if (!NIL_P(result)) ruby_errinfo = result; /* fall through *//* default: str2 = (RubyString)rom.rb_obj_as_string(eval(list.nd_head())); break; } str.append(str2); str.infectObject(str2); } list = list.nd_next(); } switch (node.nd_type()) { case NODE_DREGX: return rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); case NODE_DREGX_ONCE: /* regexp expand once *//* VALUE result = rom.rb_reg_new(str.getString(), str.getString().length(), node.nd_cflag()); node.nd_set_type(NODE_LIT); node.nd_lit(result); return result; case NODE_DXSTR: return rom.rb_funcall(this, '`', 1, str); default: return str; }*/ return null; case NODE_XSTR: return self.funcall(getRuby().intern("`"), (RubyObject)node.nd_lit()); case NODE_LIT: return (RubyObject)node.nd_lit(); case NODE_ATTRSET:/* if (ruby_frame.argc() != 1) { throw new RubyArgumentException("wrong # of arguments(" + ruby_frame.argc() + "for 1)"); } return self.setIvar((RubyId)node.nd_vid(), ruby_frame.argv()[0]); */ return null; case NODE_DEFN: if (node.nd_defn() != null) { int noex; if (ruby_class == null) { throw new RubyTypeException("no class to add method"); } //if (ruby_class == getRuby().getObjectClass() && node.nd_mid() == init) { // rom.rb_warn("redefining Object#initialize may cause infinite loop"); //} //if (node.nd_mid() == __id__ || node.nd_mid() == __send__) { // rom.rb_warn("redefining `%s' may cause serious problem", ((RubyId)node.nd_mid()).toName()); //} // ruby_class.setFrozen(true); NODE body = ruby_class.searchMethod((RubyId)node.nd_mid()); RubyObject origin = ruby_class.getMethodOrigin((RubyId)node.nd_mid()); if (body != null){ // if (ruby_verbose.isTrue() && ruby_class == origin && body.nd_cnt() == 0) { // rom.rb_warning("discarding old %s", ((RubyId)node.nd_mid()).toName()); // } // if (node.nd_noex() != 0) { /* toplevel */ /* should upgrade to rb_warn() if no super was called inside? */ // rom.rb_warning("overriding global function `%s'", ((RubyId)node.nd_mid()).toName()); // } } if (isScope(SCOPE_PRIVATE) || node.nd_mid().equals(ruby.intern("initialize"))) { noex = NOEX_PRIVATE; } else if (isScope(SCOPE_PROTECTED)) { noex = NOEX_PROTECTED; } else if (ruby_class == getRuby().getObjectClass()) { noex = node.nd_noex(); } else { noex = NOEX_PUBLIC; } if (body != null && origin == ruby_class && (body.nd_noex() & NOEX_UNDEF) != 0) { noex |= NOEX_UNDEF; } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); ruby_class.addMethod((RubyId)node.nd_mid(), defn, noex); // rb_clear_cache_by_id(node.nd_mid()); if (scope_vmode == SCOPE_MODFUNC) { ruby_class.getSingletonClass().addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC); ruby_class.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } if (ruby_class.isSingleton()) { ruby_class.getIv("__attached__").funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } else { // ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); } } return getRuby().getNil(); case NODE_DEFS: if (node.nd_defn() != null) { recv = eval(self, node.nd_recv()); if (getRuby().getSecurityLevel() >= 4 && !recv.isTaint()) { throw new RubySecurityException("Insecure; can't define singleton method"); } /*if (FIXNUM_P(recv) || SYMBOL_P(recv)) { rb_raise(rb_eTypeError, "can't define singleton method \"%s\" for %s", rb_id2name(node.nd_mid()), rb_class2name(CLASS_OF(recv))); }*/ // not needed in jruby if (recv.isFrozen()) { throw new RubyFrozenException("object"); } rubyClass = recv.getSingletonClass(); NODE body = (NODE)rubyClass.getMethods().get((RubyId)node.nd_mid()); if (body != null) { if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("redefining method prohibited"); } /*if (RTEST(ruby_verbose)) { rb_warning("redefine %s", rb_id2name(node.nd_mid())); }*/ } NODE defn = node.nd_defn().copyNodeScope(ruby_cref); defn.nd_rval(ruby_cref); rubyClass.addMethod((RubyId)node.nd_mid(), defn, NOEX_PUBLIC | (body != null ? body.nd_noex() & NOEX_UNDEF : 0)); // rb_clear_cache_by_id(node.nd_mid()); recv.funcall(getRuby().intern("singleton_method_added"), ((RubyId)node.nd_mid()).toSymbol()); } return getRuby().getNil(); case NODE_UNDEF: if (ruby_class == null) { throw new RubyTypeException("no class to undef method"); } ruby_class.undef((RubyId)node.nd_mid()); return getRuby().getNil(); case NODE_ALIAS: if (ruby_class == null) { throw new RubyTypeException("no class to make alias"); } ruby_class.aliasMethod((RubyId)node.nd_new(), (RubyId)node.nd_old()); ruby_class.funcall(getRuby().intern("method_added"), ((RubyId)node.nd_mid()).toSymbol()); return getRuby().getNil(); case NODE_VALIAS: //rb_alias_variable(node.nd_new(), node.nd_old()); return getRuby().getNil(); case NODE_CLASS: RubyModule superClass; if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } if (node.nd_super() != null) { superClass = getSuperClass(self, node.nd_super()); } else { superClass = null; } rubyClass = null; // if ((ruby_class == getRuby().getObjectClass()) && rb_autoload_defined(node.nd_cname())) { // rb_autoload_load(node.nd_cname()); // } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { rubyClass = (RubyClass)ruby_class.getConstant((RubyId)node.nd_cname()); } if (rubyClass != null) { if (!rubyClass.isClass()) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a class"); } if (superClass != null) { RubyModule tmp = rubyClass.getSuperClass(); if (tmp.isSingleton()) { tmp = tmp.getSuperClass(); } while (tmp.isIncluded()) { tmp = tmp.getSuperClass(); } if (tmp != superClass) { superClass = tmp; //goto override_class; } } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending class prohibited"); } // rb_clear_cache(); } else { //override_class: if (superClass == null) { superClass = getRuby().getObjectClass(); } rubyClass = getRuby().defineClassId((RubyId)node.nd_cname(), (RubyClass)superClass); ruby_class.setConstant((RubyId)node.nd_cname(), rubyClass); rubyClass.setClassPath((RubyClass)ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_MODULE: if (ruby_class == null) { throw new RubyTypeException("no outer class/module"); } RubyModule module = null; if ((ruby_class == getRuby().getObjectClass()) && getRuby().isAutoloadDefined((RubyId)node.nd_cname())) { // getRuby().rb_autoload_load(node.nd_cname()); } if (ruby_class.isConstantDefined((RubyId)node.nd_cname())) { module = (RubyModule)ruby_class.getConstant((RubyId)node.nd_cname()); } if (module != null) { if (!(module instanceof RubyModule)) { throw new RubyTypeException(((RubyId)node.nd_cname()).toName() + " is not a module"); } if (getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException("extending module prohibited"); } } else { module = getRuby().defineModuleId((RubyId)node.nd_cname()); ruby_class.setConstant((RubyId)node.nd_cname(), module); module.setClassPath(ruby_class, ((RubyId)node.nd_cname()).toName()); } if (ruby_wrapper != null) { module.getSingletonClass().includeModule(ruby_wrapper); module.includeModule(ruby_wrapper); } return setupModule(module, node.nd_body()); case NODE_SCLASS: rubyClass = (RubyClass)eval(self, node.nd_recv()); if (rubyClass.isSpecialConst()) { throw new RubyTypeException("no virtual class for " + rubyClass.getRubyClass().toName()); } if (getRuby().getSecurityLevel() >= 4 && !rubyClass.isTaint()) { throw new RubySecurityException("Insecure: can't extend object"); } if (rubyClass.getRubyClass().isSingleton()) { // rb_clear_cache(); } rubyClass = rubyClass.getSingletonClass(); if (ruby_wrapper != null) { rubyClass.getSingletonClass().includeModule(ruby_wrapper); rubyClass.includeModule(ruby_wrapper); } return setupModule(rubyClass, node.nd_body()); case NODE_DEFINED: // String buf; // String desc = is_defined(self, node.nd_head(), buf); // // if (desc) { // result = rb_str_new2(desc); // } else { // result = Qnil; // } case NODE_NEWLINE: // ruby_sourcefile = node.nd_file; // ruby_sourceline = node.nd_nth(); // if (trace_func) { // call_trace_func("line", ruby_sourcefile, ruby_sourceline, self, // ruby_frame.last_func(), // ruby_frame.last_class()); // } node = node.nd_next(); break; default: // rom.rb_bug("unknown node type %d", nd_type(node)); } } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
rubyFrame = new Frame(); | rubyFrame = new Frame(ruby); | public Frame getRubyFrame() { if (rubyFrame == null) { rubyFrame = new Frame(); } return rubyFrame; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
iter iter = new iter(); | public void init() { // FRAME frame = new FRAME(); iter iter = new iter(); int state; if (initialized) { return; } initialized = true; topFrame = getRubyFrame(); ruby_iter = iter; // rb_origenviron = environ; // Init_stack(0); // Init_heap(); // PUSH_SCOPE(); getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalVars(null); // top_scope = getRuby().ruby_scope; /* default visibility is private at toplevel */ // SET_SCOPE(SCOPE_PRIVATE); // PUSH_TAG( PROT_NONE ); // if ((state = EXEC_TAG()) == 0) { // rb_call_inits(); ruby_class = getRuby().getObjectClass(); // ruby_frame.self = ruby_top_self; // top_cref = new NODE(NODE_CREF, getRuby().getObjectClass(), null, null); // ruby_cref = top_cref; rubyFrame.setCbase((VALUE)ruby_cref); // rb_define_global_const( "TOPLEVEL_BINDING", rb_f_binding( ruby_top_self ) ); // ruby_prog_init(); // } // POP_TAG(); // if (state != 0) { // error_print(); // } // POP_SCOPE(); // ruby_scope = top_scope; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
|
ruby_iter = iter; | rubyIter = new Iter(); | public void init() { // FRAME frame = new FRAME(); iter iter = new iter(); int state; if (initialized) { return; } initialized = true; topFrame = getRubyFrame(); ruby_iter = iter; // rb_origenviron = environ; // Init_stack(0); // Init_heap(); // PUSH_SCOPE(); getRuby().rubyScope.setLocalVars(null); getRuby().rubyScope.setLocalVars(null); // top_scope = getRuby().ruby_scope; /* default visibility is private at toplevel */ // SET_SCOPE(SCOPE_PRIVATE); // PUSH_TAG( PROT_NONE ); // if ((state = EXEC_TAG()) == 0) { // rb_call_inits(); ruby_class = getRuby().getObjectClass(); // ruby_frame.self = ruby_top_self; // top_cref = new NODE(NODE_CREF, getRuby().getObjectClass(), null, null); // ruby_cref = top_cref; rubyFrame.setCbase((VALUE)ruby_cref); // rb_define_global_const( "TOPLEVEL_BINDING", rb_f_binding( ruby_top_self ) ); // ruby_prog_init(); // } // POP_TAG(); // if (state != 0) { // error_print(); // } // POP_SCOPE(); // ruby_scope = top_scope; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/f1e2c45b99e6f9a2be3f15f5fd7ad91c7e086a2c/RubyInterpreter.java/clean/org/jruby/interpreter/RubyInterpreter.java |
RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; | RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyString path = null; | RubyString path = null; | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } | if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } | String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } | if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } | if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
FindClassPathResult list = res; | FindClassPathResult list = res; | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } | while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; | FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
value.getInstanceVariables().foreach(this, arg); | value.getInstanceVariables().foreach(this, arg); | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | public int execute(Object _key, Object _value, Object _res) { // Cast the values. RubyId key = null; try { key = (RubyId) _key; } catch (ClassCastException ccExcptn) { key = getRuby().intern((String) _key); System.out.println("key isn't ID: \"" + _key + "\""); } if (!(_value instanceof RubyObject)) { return RubyMapMethod.CONTINUE; } RubyObject value = (RubyObject) _value; FindClassPathResult res = (FindClassPathResult) _res; RubyString path = null; if (!key.isConstId()) { return RubyMapMethod.CONTINUE; } String name = key.toName(); if (res.path != null) { path = (RubyString) res.path.m_dup(); path.m_cat("::"); path.m_cat(name); } else { path = RubyString.m_newString(getRuby(), name); } if (value == res.klass) { res.name = key; res.path = path; return RubyMapMethod.STOP; } if (value.m_kind_of(getRuby().getClasses().getModuleClass()).isTrue()) { if (value.getInstanceVariables() == null) { return RubyMapMethod.CONTINUE; } FindClassPathResult list = res; while (list != null) { if (list.track == value) { return RubyMapMethod.CONTINUE; } list = list.prev; } FindClassPathResult arg = new FindClassPathResult(); arg.name = null; arg.path = path; arg.klass = res.klass; arg.track = value; arg.prev = res; value.getInstanceVariables().foreach(this, arg); if (arg.name != null) { res.name = arg.name; res.path = arg.path; return RubyMapMethod.STOP; } } return RubyMapMethod.CONTINUE; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this.recvClass = recvClass; this.id = id; this.noex = noex; } | this.recvClass = recvClass; this.id = id; this.noex = noex; } | public GetMethodBodyResult(RubyModule recvClass, RubyId id, int noex) { this.recvClass = recvClass; this.id = id; this.noex = noex; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return body; } | return body; } | public Node getBody() { return body; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return id; } | return id; } | public RubyId getId() { return id; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return noex; } | return noex; } | public int getNoex() { return noex; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return recvClass; } | return recvClass; } | public RubyModule getRecvClass() { return recvClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this.body = body; } | this.body = body; } | public void setBody(Node body) { this.body = body; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this.id = id; } | this.id = id; } | public void setId(RubyId id) { this.id = id; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this.noex = noex; } | this.noex = noex; } | public void setNoex(int noex) { this.noex = noex; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this.recvClass = recvClass; } | this.recvClass = recvClass; } | public void setRecvClass(RubyModule recvClass) { this.recvClass = recvClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
this(ruby, null); } | this(ruby, null); } | public RubyModule(Ruby ruby) { this(ruby, null); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
||
int noex = Constants.NOEX_PUBLIC; | int noex = Constants.NOEX_PUBLIC; | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } | if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
String name = id.toName(); | String name = id.toName(); | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyId attrIV = getRuby().intern("@" + name); | RubyId attrIV = getRuby().intern("@" + name); | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); funcall(getRuby().intern("method_added"), id.toSymbol()); } | if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); funcall(getRuby().intern("method_added"), id.toSymbol()); } | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | public void addAttribute(RubyId id, boolean read, boolean write, boolean ex) { // RubyInterpreter intrprtr = getRuby().getInterpreter(); int noex = Constants.NOEX_PUBLIC; if (ex) { if (getRuby().getActMethodScope() == Constants.SCOPE_PRIVATE) { noex = Constants.NOEX_PRIVATE; } else if (getRuby().getActMethodScope() == Constants.SCOPE_PROTECTED) { noex = Constants.NOEX_PROTECTED; } else { noex = Constants.NOEX_PUBLIC; } } String name = id.toName(); RubyId attrIV = getRuby().intern("@" + name); if (read) { addMethod(id, new NodeFactory(getRuby()).newIVar(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } if (write) { id = getRuby().intern(name + "="); addMethod(id, new NodeFactory(getRuby()).newAttrSet(attrIV), noex); // id.clearCache(); funcall(getRuby().intern("method_added"), id.toSymbol()); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } | if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } | public void addMethod(RubyId id, Node node, int noex) { if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } if (getRuby().getSecurityLevel() >= 4 && !isTaint()) { throw new RubySecurityException(getRuby(), "Insecure: can't define method"); } if (isFrozen()) { throw new RubyFrozenException(getRuby(), "class/module"); } Node body = new NodeFactory(getRuby()).newMethod(node, noex); methods.put(id, body); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (getRuby().getSecurityLevel() >= 4 && !isTaint()) { throw new RubySecurityException(getRuby(), "Insecure: can't define method"); } if (isFrozen()) { throw new RubyFrozenException(getRuby(), "class/module"); } Node body = new NodeFactory(getRuby()).newMethod(node, noex); methods.put(id, body); } | if (getRuby().getSecurityLevel() >= 4 && !isTaint()) { throw new RubySecurityException(getRuby(), "Insecure: can't define method"); } if (isFrozen()) { throw new RubyFrozenException(getRuby(), "class/module"); } Node body = new NodeFactory(getRuby()).newMethod(node, noex); methods.put(id, body); } | public void addMethod(RubyId id, Node node, int noex) { if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } if (getRuby().getSecurityLevel() >= 4 && !isTaint()) { throw new RubySecurityException(getRuby(), "Insecure: can't define method"); } if (isFrozen()) { throw new RubyFrozenException(getRuby(), "class/module"); } Node body = new NodeFactory(getRuby()).newMethod(node, noex); methods.put(id, body); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
testFrozen(); | testFrozen(); | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (oldId == newId) { return; } | if (oldId == newId) { return; } | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } | if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
MethodNode methodNode = searchMethod(oldId); | MethodNode methodNode = searchMethod(oldId); | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyModule origin = null; | RubyModule origin = null; | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { return; } origin = methodNode.getMethodOrigin(); | if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { return; } origin = methodNode.getMethodOrigin(); | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
Node body = methodNode.getBodyNode(); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } | Node body = methodNode.getBodyNode(); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
NodeFactory nf = new NodeFactory(getRuby()); | NodeFactory nf = new NodeFactory(getRuby()); | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | public void aliasMethod(RubyId newId, RubyId oldId) { testFrozen(); if (oldId == newId) { return; } if (this == getRuby().getClasses().getObjectClass()) { getRuby().secure(4); } MethodNode methodNode = searchMethod(oldId); RubyModule origin = null; if (methodNode == null || methodNode.getBodyNode() == null) { if (isModule()) { methodNode = getRuby().getClasses().getObjectClass().searchMethod(oldId); origin = methodNode.getMethodOrigin(); } } if (methodNode == null || methodNode.getBodyNode() == null) { // print_undef( klass, def ); return; //CEF } origin = methodNode.getMethodOrigin(); Node body = methodNode.getBodyNode(); // methodNode.setCnt(methodNode.nd_cnt() + 1); if (body instanceof FBodyNode) { /* was alias */ oldId = body.getMId(); origin = (RubyModule) body.getOrigin(); body = body.getBodyNode(); } NodeFactory nf = new NodeFactory(getRuby()); methods.put( newId, nf.newMethod(nf.newFBody(body, oldId, origin), methodNode.getNoex())); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
aliasMethod(newId.toId(), oldId.toId()); | aliasMethod(newId.toId(), oldId.toId()); | public RubyModule alias_method(RubyObject newId, RubyObject oldId) { aliasMethod(newId.toId(), oldId.toId()); return this; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return this; } | return this; } | public RubyModule alias_method(RubyObject newId, RubyObject oldId) { aliasMethod(newId.toId(), oldId.toId()); return this; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (isSingleton()) { if (getInstanceVariables() == null) { setInstanceVariables(new RubyHashMap()); } | if (isSingleton()) { if (getInstanceVariables() == null) { setInstanceVariables(new RubyHashMap()); } | public void attachSingletonClass(RubyObject rbObject) { if (isSingleton()) { if (getInstanceVariables() == null) { setInstanceVariables(new RubyHashMap()); } getInstanceVariables().put(getRuby().intern("__atached__"), rbObject); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
getInstanceVariables().put(getRuby().intern("__atached__"), rbObject); } } | getInstanceVariables().put(getRuby().intern("__atached__"), rbObject); } } | public void attachSingletonClass(RubyObject rbObject) { if (isSingleton()) { if (getInstanceVariables() == null) { setInstanceVariables(new RubyHashMap()); } getInstanceVariables().put(getRuby().intern("__atached__"), rbObject); } } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); | RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyModule klass = this; RubyId id = mid; int noex; Node body; | RubyModule klass = this; RubyId id = mid; int noex; Node body; | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } | if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); | klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } | if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
||
public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
||
public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
||
return klass.call0(recv, id, args, body, false); } | return klass.call0(recv, id, args, body, false); } | public RubyObject call( RubyObject recv, RubyId mid, RubyPointer args, int scope) { RubyMethodCacheEntry ent = RubyMethodCacheEntry.getEntry(getRuby(), this, mid); RubyModule klass = this; RubyId id = mid; int noex; Node body; if (ent != null) { if (ent.getMethod() == null) { throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } klass = ent.getOrigin(); id = ent.getMid0(); noex = ent.getNoex(); body = ent.getMethod(); } else { GetMethodBodyResult gmbr = getMethodBody(id, 0); klass = gmbr.getRecvClass(); id = gmbr.getId(); noex = gmbr.getNoex(); body = gmbr.getBody(); if (body == null) { if (scope == 3) { throw new RubyNameException( getRuby(), "super: no superclass method '" + mid.toName() + "'"); } throw new RuntimeException("undefined method " + mid.toName() + " for " + recv + ":" + recv.getRubyClass().toName()); } } // if (mid != missing) { // /* receiver specified form for private method */ // if ((noex & NOEX_PRIVATE) && scope == 0) // return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV); // /* self must be kind of a specified form for private method */ // if ((noex & NOEX_PROTECTED)) { // VALUE defined_class = klass; // while (TYPE(defined_class) == T_ICLASS) // defined_class = RBASIC(defined_class)->klass; // if (!rb_obj_is_kind_of(ruby_frame->self, defined_class)) // return rb_undefined(recv, mid, argc, argv, CSTAT_PROT); // } // } // ... return klass.call0(recv, id, args, body, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { | RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
||
if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } | if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); | RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); | RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); | getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return result; } | return result; } | public RubyObject call0( RubyObject recv, RubyId id, RubyPointer args, Node body, boolean noSuper) { // ... if (getRuby().getIter().getIter() == RubyIter.ITER_PRE) { getRuby().getIter().push(RubyIter.ITER_CUR); } else { getRuby().getIter().push(RubyIter.ITER_NOT); } RubyFrame frame = getRuby().getRubyFrame(); frame.push(); frame.setLastFunc(id); frame.setLastClass(noSuper ? null : this); frame.setSelf(recv); frame.setArgs(args); RubyObject result = ((CallableNode) body).call(getRuby(), recv, id, args, noSuper); getRuby().getRubyFrame().pop(); getRuby().getIter().pop(); return result; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyModule tmp = this; while (tmp != null) { if (tmp.getInstanceVariables() != null && tmp.getInstanceVariables().get(id) != null) { if (tmp.isTaint() && getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException( getRuby(), "Insecure: can't modify class variable"); } tmp.getInstanceVariables().put(id, value); } tmp = tmp.getSuperClass(); } setAv(id, value, false); } | RubyModule tmp = this; while (tmp != null) { if (tmp.getInstanceVariables() != null && tmp.getInstanceVariables().get(id) != null) { if (tmp.isTaint() && getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException( getRuby(), "Insecure: can't modify class variable"); } tmp.getInstanceVariables().put(id, value); } tmp = tmp.getSuperClass(); } setAv(id, value, false); } | public void declareClassVar(RubyId id, RubyObject value) { RubyModule tmp = this; while (tmp != null) { if (tmp.getInstanceVariables() != null && tmp.getInstanceVariables().get(id) != null) { if (tmp.isTaint() && getRuby().getSecurityLevel() >= 4) { throw new RubySecurityException( getRuby(), "Insecure: can't modify class variable"); } tmp.getInstanceVariables().put(id, value); } tmp = tmp.getSuperClass(); } setAv(id, value, false); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
} | } | public void defineAlias(String oldName, String newName) { } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
} | } | public void defineAttribute(String name, boolean read, boolean write) { } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyClass newClass = getRuby().defineClassId(getRuby().intern(name), superClass); | RubyClass newClass = getRuby().defineClassId(getRuby().intern(name), superClass); | public RubyClass defineClassUnder(String name, RubyClass superClass) { RubyClass newClass = getRuby().defineClassId(getRuby().intern(name), superClass); setConstant(getRuby().intern(name), newClass); newClass.setClassPath(this, name); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
setConstant(getRuby().intern(name), newClass); newClass.setClassPath(this, name); | setConstant(getRuby().intern(name), newClass); newClass.setClassPath(this, name); | public RubyClass defineClassUnder(String name, RubyClass superClass) { RubyClass newClass = getRuby().defineClassId(getRuby().intern(name), superClass); setConstant(getRuby().intern(name), newClass); newClass.setClassPath(this, name); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
return newClass; } | return newClass; } | public RubyClass defineClassUnder(String name, RubyClass superClass) { RubyClass newClass = getRuby().defineClassId(getRuby().intern(name), superClass); setConstant(getRuby().intern(name), newClass); newClass.setClassPath(this, name); return newClass; } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
RubyId id = getRuby().intern(name); | RubyId id = getRuby().intern(name); | public void defineClassVariable(String name, RubyObject value) { RubyId id = getRuby().intern(name); if (!id.isClassId()) { throw new RubyNameException(getRuby(), "wrong class variable name " + name); } declareClassVar(id, value); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
if (!id.isClassId()) { throw new RubyNameException(getRuby(), "wrong class variable name " + name); } | if (!id.isClassId()) { throw new RubyNameException(getRuby(), "wrong class variable name " + name); } | public void defineClassVariable(String name, RubyObject value) { RubyId id = getRuby().intern(name); if (!id.isClassId()) { throw new RubyNameException(getRuby(), "wrong class variable name " + name); } declareClassVar(id, value); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
declareClassVar(id, value); } | declareClassVar(id, value); } | public void defineClassVariable(String name, RubyObject value) { RubyId id = getRuby().intern(name); if (!id.isClassId()) { throw new RubyNameException(getRuby(), "wrong class variable name " + name); } declareClassVar(id, value); } | 50661 /local/tlutelli/issta_data/temp/all_java5context/java/2006_temp/2006/50661/0a7181933af700ea8025a4197f3a5ebcc08333c3/RubyModule.java/buggy/org/jruby/RubyModule.java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.