зеркало из https://github.com/mozilla/pjs.git
Fixes for NervousText example.
This commit is contained in:
Родитель
5d42d30699
Коммит
530119248e
|
@ -294,7 +294,7 @@ public class FunctionObject extends NativeFunction {
|
|||
* @param name the name of the methods to find
|
||||
* @return an array of the found methods, or null if no methods
|
||||
* by that name were found.
|
||||
* @see java.lang.Class#getDeclaredMethods
|
||||
* @see java.lang.Class#getMethods
|
||||
*/
|
||||
public static Method[] findMethods(Class clazz, String name) {
|
||||
return findMethods(getMethodList(clazz), name);
|
||||
|
@ -335,10 +335,22 @@ public class FunctionObject extends NativeFunction {
|
|||
Method[] cached = methodsCache; // get once to avoid synchronization
|
||||
if (cached != null && cached[0].getDeclaringClass() == clazz)
|
||||
return cached;
|
||||
Method[] methods = clazz.getDeclaredMethods();
|
||||
boolean getMethodsCalled = false;
|
||||
Method[] methods;
|
||||
try {
|
||||
// getDeclaredMethods may be rejected by the security manager
|
||||
methods = clazz.getDeclaredMethods();
|
||||
} catch (SecurityException e) {
|
||||
// but getMethods is more expensive
|
||||
getMethodsCalled = true;
|
||||
methods = clazz.getMethods();
|
||||
}
|
||||
int count = 0;
|
||||
for (int i=0; i < methods.length; i++) {
|
||||
if (!Modifier.isPublic(methods[i].getModifiers())) {
|
||||
if (getMethodsCalled
|
||||
? !Modifier.isPublic(methods[i].getModifiers())
|
||||
: methods[i].getDeclaringClass() != clazz)
|
||||
{
|
||||
methods[i] = null;
|
||||
} else {
|
||||
count++;
|
||||
|
|
|
@ -1470,7 +1470,7 @@ public class Codegen extends Interpreter {
|
|||
variableObjectLocal = reserveWordLocal(2);
|
||||
thisObjLocal = reserveWordLocal(3);
|
||||
|
||||
if (!cx.hasCompileFunctionsWithDynamicScope()) {
|
||||
if (inFunction && !cx.hasCompileFunctionsWithDynamicScope()) {
|
||||
aload(funObjLocal);
|
||||
classFile.add(ByteCode.INVOKEINTERFACE,
|
||||
"org/mozilla/javascript/Scriptable",
|
||||
|
|
|
@ -76,7 +76,8 @@ public class Main {
|
|||
*
|
||||
*/
|
||||
public static String[] processOptions(Context cx, String args[]) {
|
||||
cx.setTargetPackage(""); // default to no package
|
||||
cx.setTargetPackage(""); // default to no package
|
||||
cx.setGeneratingDebug(false); // default to no symbols
|
||||
for (int i=0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (!arg.startsWith("-")) {
|
||||
|
@ -98,7 +99,7 @@ public class Main {
|
|||
cx.setOptimizationLevel(optLevel);
|
||||
continue;
|
||||
}
|
||||
if (arg.equals("-debuglevel") && ++i < args.length) {
|
||||
if (false && arg.equals("-debuglevel") && ++i < args.length) {
|
||||
int debugLevel = Integer.parseInt(args[i]);
|
||||
cx.setDebugLevel(debugLevel);
|
||||
continue;
|
||||
|
|
|
@ -90,12 +90,14 @@ msg.uncaughtJSException =\
|
|||
msg.jsc.usage =\
|
||||
Didn''t understand "{0}". \n\
|
||||
Valid arguments are: \n\
|
||||
\ -version 100|110|120|130 \n\
|
||||
\ -version 100|110|120|130|140|150 \n\
|
||||
\ -opt [1-9] \n\
|
||||
\ -debug \n\
|
||||
\ -debuglevel [0-9]\n\
|
||||
\ -nosource \n\
|
||||
\ -o outfile.class
|
||||
\ -o outfile.class \n\
|
||||
\ -package packageName \n\
|
||||
\ -extends extendsClassName \n\
|
||||
\ -implements implementsClassName
|
||||
|
||||
|
||||
msg.no.file =\
|
||||
|
|
|
@ -294,7 +294,7 @@ public class FunctionObject extends NativeFunction {
|
|||
* @param name the name of the methods to find
|
||||
* @return an array of the found methods, or null if no methods
|
||||
* by that name were found.
|
||||
* @see java.lang.Class#getDeclaredMethods
|
||||
* @see java.lang.Class#getMethods
|
||||
*/
|
||||
public static Method[] findMethods(Class clazz, String name) {
|
||||
return findMethods(getMethodList(clazz), name);
|
||||
|
@ -335,10 +335,22 @@ public class FunctionObject extends NativeFunction {
|
|||
Method[] cached = methodsCache; // get once to avoid synchronization
|
||||
if (cached != null && cached[0].getDeclaringClass() == clazz)
|
||||
return cached;
|
||||
Method[] methods = clazz.getDeclaredMethods();
|
||||
boolean getMethodsCalled = false;
|
||||
Method[] methods;
|
||||
try {
|
||||
// getDeclaredMethods may be rejected by the security manager
|
||||
methods = clazz.getDeclaredMethods();
|
||||
} catch (SecurityException e) {
|
||||
// but getMethods is more expensive
|
||||
getMethodsCalled = true;
|
||||
methods = clazz.getMethods();
|
||||
}
|
||||
int count = 0;
|
||||
for (int i=0; i < methods.length; i++) {
|
||||
if (!Modifier.isPublic(methods[i].getModifiers())) {
|
||||
if (getMethodsCalled
|
||||
? !Modifier.isPublic(methods[i].getModifiers())
|
||||
: methods[i].getDeclaringClass() != clazz)
|
||||
{
|
||||
methods[i] = null;
|
||||
} else {
|
||||
count++;
|
||||
|
|
|
@ -1470,7 +1470,7 @@ public class Codegen extends Interpreter {
|
|||
variableObjectLocal = reserveWordLocal(2);
|
||||
thisObjLocal = reserveWordLocal(3);
|
||||
|
||||
if (!cx.hasCompileFunctionsWithDynamicScope()) {
|
||||
if (inFunction && !cx.hasCompileFunctionsWithDynamicScope()) {
|
||||
aload(funObjLocal);
|
||||
classFile.add(ByteCode.INVOKEINTERFACE,
|
||||
"org/mozilla/javascript/Scriptable",
|
||||
|
|
|
@ -76,7 +76,8 @@ public class Main {
|
|||
*
|
||||
*/
|
||||
public static String[] processOptions(Context cx, String args[]) {
|
||||
cx.setTargetPackage(""); // default to no package
|
||||
cx.setTargetPackage(""); // default to no package
|
||||
cx.setGeneratingDebug(false); // default to no symbols
|
||||
for (int i=0; i < args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (!arg.startsWith("-")) {
|
||||
|
@ -98,7 +99,7 @@ public class Main {
|
|||
cx.setOptimizationLevel(optLevel);
|
||||
continue;
|
||||
}
|
||||
if (arg.equals("-debuglevel") && ++i < args.length) {
|
||||
if (false && arg.equals("-debuglevel") && ++i < args.length) {
|
||||
int debugLevel = Integer.parseInt(args[i]);
|
||||
cx.setDebugLevel(debugLevel);
|
||||
continue;
|
||||
|
|
|
@ -90,12 +90,14 @@ msg.uncaughtJSException =\
|
|||
msg.jsc.usage =\
|
||||
Didn''t understand "{0}". \n\
|
||||
Valid arguments are: \n\
|
||||
\ -version 100|110|120|130 \n\
|
||||
\ -version 100|110|120|130|140|150 \n\
|
||||
\ -opt [1-9] \n\
|
||||
\ -debug \n\
|
||||
\ -debuglevel [0-9]\n\
|
||||
\ -nosource \n\
|
||||
\ -o outfile.class
|
||||
\ -o outfile.class \n\
|
||||
\ -package packageName \n\
|
||||
\ -extends extendsClassName \n\
|
||||
\ -implements implementsClassName
|
||||
|
||||
|
||||
msg.no.file =\
|
||||
|
|
Загрузка…
Ссылка в новой задаче