Commit Graph

622 Commits

Author SHA1 Message Date
nboyd%atg.com
16a01c6105 Fix 79568. 2001-05-09 13:59:29 +00:00
beard%netscape.com
cdc467d85a Removed ListenerCollection.java, added ListenerArray.java. 2001-05-08 22:56:43 +00:00
beard%netscape.com
d34d7267e4 Officially retiring all sources in mozilla/js/rhino/org, in favor of sources in mozilla/js/rhino/src & mozilla/js/rhino/toolsrc. 2001-05-08 22:50:01 +00:00
beard%netscape.com
ace78ee37e Officially retiring all sources in mozilla/js/rhino/org, in favor of sources in mozilla/js/rhino/src & mozilla/js/rhino/toolsrc. 2001-05-08 22:28:17 +00:00
nboyd%atg.com
66b3d8aae3 Change use of deprecated method. 2001-05-08 13:51:18 +00:00
nboyd%atg.com
991a880e56 Commit missing messages for new idswitch tool. 2001-05-08 13:42:56 +00:00
nboyd%atg.com
49ee5104a9 Subject:
Rhino: optimization for NativeFunction.java
        Date:
             Mon, 07 May 2001 14:19:59 +0200
       From:
             Igor Bukanov <igor.bukanov@windriver.com>
 Organization:
             Wind River
         To:
             Norris Boyd <nboyd@atg.com>

Hi, Norris!

This is the first of 3 patches that are completly independent from each
other.

Currently in NativeFunction its name stored as the first element in the
names array. But this lead to creation of a single element array for
each FunctionObject and for each script function that does not have
arguments or variables. The attached patch splits NativeFunction names
into simple functionName and argNames arrays and adjust code elsewhere
accordingly. This patch can increase memory footprint for anonymous
script functions without arguments because it adds additional field to
each NativeFunction, but I do not think this is a case to worry about.

Regards, Igor
2001-05-08 13:40:22 +00:00
nboyd%atg.com
bd685b66b2 Subject: Rhino: execMethod/methodArity cleanup.
Date: Mon, 07 May 2001 14:25:34 +0200
From: Igor Bukanov <igor.bukanov@windriver.com>
Organization: Wind River
To: Norris Boyd <nboyd@atg.com>

The current code that implements execMethod/methodArity for IdFunction
support returns an arbitrary value for id that is not known. This is not
very good behavior because it may hide bugs in the id support and it
also does not allow to distinguish ids that are used for function  from
ids used for properties like String.length.

To fix this I changed semantic of the methodArity method to return -1
for an unknown/non-method id and added code to throw an exception for
bad ids. This change requires to adjust all NativeSomething objects that
use IdScriptabl and after a release all such interface changes would be
no go, but is not a release yet, right?

I also eliminated the "IdFunction f" argument from
IdFunction.Master.methodArity and the tagId field from IdFunction. When
I wrote  the initial code for IdFunction.java, I added that just to be
able to use same id number in a class that implements IdFunction.Master
and its descendants via checking idTag. But that does not work in
general because IdScriptable can use id for non-function fields as well
so to avoid id clashes another way should be used. For example, if
someone would like to extend NativeMath to support more functionality,
he can use:

class Math2: extends NativeMath {
     private static idBase;

     {
         if (idBase == 0) idBase = super.getMaximumId();
     }

      public int methodArity(int methodId) {
          switch (methodId - idBase) {
             case Id_foo: return 2;
             case Id_bar: return 3;
         }
         return super.methodArity(methodId);
     }

      public Object execMethod
          (int methodId, IdFunction f,
           Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
          throws JavaScriptException
      {
          switch (methodId - idBase) {
             case Id_foo: return ...;
             case Id_bar: return ...;
         }
          return super.execMethod(methodId, f, cx, scope, thisObj, args);
     }

      protected int getMaximumId() { return idBase + MAX_ID; }

      protected String getIdName(int id) {
          switch (id - idBase) {
             case Id_foo: return "for";
             case Id_bar: return "bar";
         }
         return super.getIdName(id);
     }
     ...
     private static final int
         Id_foo = 1,
         Id_bar = 2,
         MAX_ID = 2;

etc.


Note that a simpler solution to make MAX_ID field public in NativeMath
and write in Math2:
     private static final int
         Id_foo = NativeMath.MAX_ID + 1,
         Id_bar = NativeMath.MAX_ID + 2,
         MAX_ID = NativeMath.MAX_ID + 2;

does not work because in this way adding any new id to NativeMath would
break binary compatibility with Math2.
2001-05-08 13:36:16 +00:00
nboyd%atg.com
9129bdc5d6 Subject:
Rhino: fix for race conditions in listeners code in Context.java
        Date:
             Mon, 07 May 2001 14:22:57 +0200
       From:
             Igor Bukanov <igor.bukanov@windriver.com>
 Organization:
             Wind River
         To:
             Norris Boyd <nboyd@atg.com>

The current code for listeners and contextListeners in Context.java is
not race condition free. If contextListeners Vector would be modified
during context event firing loops, the code can produce
index-out-of-bounds exception. The problem with listeners array is more
subbtle and comes from the fact that ListenerCollection.java uses code like:
         for(Enumeration enum = getAllListeners();enum.hasMoreElements();) {
             Object listener = enum.nextElement();
             if(iface.isInstance(listener)) {
                 array.addElement(listener);
             }
         }
where getAllListeners() uses Vector.elements to get element enumeration.
But to work with such enumeration in a thread safe way, one has to
synchronized against Vector, otherwise between enum.hasMoreElements()
and enum.nextElement() the last element can be removed.

Initially I thought to fix ListenerCollection and use it for
contextListeners as well, but then I realized that in its current form
ListenerCollection is very inefficient (it produces too many objects
just to get simple array to fire events), so I wrote ListenerArray.java
and use it in Context.java. It makes life simpler and shrinks code as well.
2001-05-08 13:33:43 +00:00
nboyd%atg.com
e4bf1b6548 Fix problems noted in following mail:
Subject:
        rhino bug(s)
   Date:
        Mon, 30 Apr 2001 23:07:00 -0700
   From:
        Mike Dixon <MDixon@placeware.com>
     To:
        nboyd@atg.com




hi.  i'm a happy rhino user, and just stumbled across what looks like a
pretty basic bug in the property stuff on ScriptableObject...  (i'm running
1.5, but it looks like this code hasn't changed in CVS.)  since it looks
like you're actively developing (even though it's been a while since
1.5...) i figured you might be interested -- apologies if i missed a more
formal bug reporting process...

the symptom was that i got a "Hashtable internal error" thrown from
getSlotToSet.  reading the code, here's what i think could happen:

- create a new object (slots.length is initially 5)
- add 3 properties
- delete those 3 properties

(now count == 0, and slots[i] == REMOVED for 3 values of i)

- add 2 more properties

now assume that you're unlucky, and that these two hash to different values
than the first three; now you have 2 elements of slots[] containing real
slots, and the other three containing REMOVED.

now what happens when you try to create another slot?  getSlotToSet is only
willing to put something in a null slot[], and you haven't got one, so you
get the internal error.

writing this message encouraged me to try to write a test case to reproduce
it, and in fact it's trivial:

   js> x={}; x.a=x.b=x.c=1; delete x.a; delete x.b; delete x.c; x.d=x.e=1
   1
   js> x.whatever=1
(boom)

by the way, while reading the code i also noticed what looks like another,
less consequential bug: addSlot increments count before deciding to grow
the table, which is done with a recursive call, which will cause count to
be incremented again -- right?  as far as i can tell, setting count too big
will only cause it to grow the table a little early next time, so it
doesn't really matter, but it looks wrong.

                                                        .mike.
2001-05-06 23:56:34 +00:00
nboyd%atg.com
a426bf2e85 New updates from Igor. 2001-05-05 18:25:00 +00:00
beard%netscape.com
9c797b19b6 Allow building with javac from JDK 1.1.8. 2001-05-04 22:41:12 +00:00
nboyd%atg.com
3d11fc509c Make the debugger's main class be Main.java to match convention. 2001-05-04 15:22:10 +00:00
nboyd%atg.com
a89f7ff632 Re-apply changes since repository copy. 2001-05-04 15:20:26 +00:00
beard%netscape.com
e58e72baa7 Now builds two sub-projects, jscore.mcp, jstools.mcp and merges the resulting jar files into js.jar. This uses the new source tree organization. 2001-05-01 17:24:48 +00:00
beard%netscape.com
9499e65b11 Builds org.mozilla.javascript.tools.* classes. 2001-05-01 17:19:16 +00:00
beard%netscape.com
3f651fabb5 Builds core org.mozilla.* classes. 2001-05-01 17:18:14 +00:00
beard%netscape.com
29d9c8b87e Reverted back to old directory structure. 2001-04-27 22:57:30 +00:00
beard%netscape.com
5a22dc57e8 Restore revision history. 2001-04-27 19:45:52 +00:00
beard%netscape.com
ad25062b57 Restore revision history. 2001-04-27 19:37:39 +00:00
beard%netscape.com
7475f14841 Restore revision history. 2001-04-27 18:57:38 +00:00
beard%netscape.com
3f57dc791f Reconstructed using new rhino/src and rhino/toolsrc directory organization. 2001-04-25 22:32:20 +00:00
nboyd%atg.com
96688e7cd8 Finish javadoc fix. 2001-04-25 17:11:34 +00:00
nboyd%atg.com
fead2a0852 Fix javadoc with new directory structure. 2001-04-25 14:36:15 +00:00
nboyd%atg.com
32d98dbdc2 UPdate name of debugger main class. 2001-04-25 13:46:46 +00:00
nboyd%atg.com
ee9e0cc866 Fix javadoc generation. 2001-04-25 00:24:18 +00:00
nboyd%atg.com
a895548450 Make the default just build core. 2001-04-24 21:06:34 +00:00
nboyd%atg.com
f80a784ecb Move files to rhino/toolsrc. 2001-04-24 20:43:37 +00:00
nboyd%atg.com
1944203c68 Move files to rhino/toolsrc 2001-04-24 20:42:14 +00:00
nboyd%atg.com
823e33c1e7 Move files to rhino/src. 2001-04-24 20:39:47 +00:00
nboyd%atg.com
ef919d6f1e Somehow removed these right after I added them. 2001-04-24 20:36:58 +00:00
nboyd%atg.com
711c087f8e Massive reconfiguration of the cvs directory structure:
mozilla/js/rhino/org is now distributed between
mozilla/js/rhino/src and mozilla/js/rhino/toolsrc.
The build.xml has been split in three.
Docs now live in the project directory.

These changes mean that the cvs directories mirror the distribution and thus a distribution
will build the same way as a cvs build.
2001-04-24 20:31:31 +00:00
nboyd%atg.com
e97e80635e Break dependency between core and tools. 2001-04-24 18:08:46 +00:00
nboyd%atg.com
b6331020dc Igor's latest patches, with some regression fixes. 2001-04-24 12:57:45 +00:00
nboyd%atg.com
8584f9aa43 Convert to IdScriptable form.
Patch from Igor.
2001-04-20 14:29:56 +00:00
beard%netscape.com
426dfab4d7 loadClassName: use current class loader to find classes, before calling Class.forName(). 2001-04-19 17:31:34 +00:00
nboyd%atg.com
5199af3051 Latest patches from Igor. 2001-04-19 12:52:39 +00:00
beard%netscape.com
e183541072 Removed hard tabs, removed unnecessary cast, (Scriptable)null. 2001-04-18 20:50:58 +00:00
nboyd%atg.com
1f40b84b6c Hi, Norris!
I attach optimization patch for NativeDate that makes all js... methods
private, removes passing of unnecessary parameters and replaces
checkInstance by realThis call with false as the third parameter.


Regards, Igor

Hi, Norris!

Here is another small optimization for NativeDate in DayFromMonth method
where it replaces arrays by few ifs.

Regards, Igor
2001-04-17 13:54:45 +00:00
nboyd%atg.com
39f51f6c80 Subject:
Rhino: patch for IdScriptable.java and question about useDynamicScope
        Date:
             Mon, 16 Apr 2001 17:55:19 +0200
       From:
             Igor Bukanov <igor.bukanov@windriver.com>
 Organization:
             Wind River
         To:
             Norris Boyd <nboyd@atg.com>




Hi, Norris!

Here is a patch to IdScriptable.java that fixes sealed semantic and
makes Something.prototype.constructor to behave just as having DONTENUM
attribute, not DONTENUM|READONLY|PERMANENT. It also renames
seal_function to sealFunctions.

I also have a following question. I added nextInstanceCheck to
IdScriptable.java and its usage in realThis in NativeDate to emulate
code from FunctionObject where it looks up prototype in search for
NativeSomething instance if useDynamicScope is true. But could you
describe why it is necessary? I can understand why doing something like

var proto = new Date();
function Test() { }
Test.prototype = proto;
var test = new Test();
print(test.getDay()); // same as proto.getDay()

would be useful in ceratain situations, but what it has to do with
shared scopes?

Regards, Igor
2001-04-16 19:29:48 +00:00
nboyd%atg.com
c83b74d6be Updates from Igor. 2001-04-11 23:29:23 +00:00
nboyd%atg.com
474433c5db Need to pop activation stack. 2001-04-11 23:28:47 +00:00
nboyd%atg.com
096c704d7a Fixes from Igor. 2001-04-11 13:44:09 +00:00
nboyd%atg.com
dfea48c35c Fix race condition in method. 2001-04-11 13:43:07 +00:00
nboyd%atg.com
5425d1691b Make default for generatingDebug flag be true for compilation and false for interpretation. 2001-04-11 13:42:26 +00:00
nboyd%atg.com
77435b1a17 New file from Igor. 2001-04-10 14:21:24 +00:00
nboyd%atg.com
64bdadc1e0 Add Igor's changes to make generation of id strings by tool. 2001-04-10 13:20:02 +00:00
beard%netscape.com
479d30c766 Synchronized with latest sources. 2001-04-10 07:09:43 +00:00
nboyd%atg.com
a717446397 Remove SecuritySupport code that doesn't apply to the Invoker case. 2001-04-10 01:47:50 +00:00
nboyd%atg.com
48141e355a Revert default of generatingDebug back to false to fix regressions. 2001-04-09 23:52:04 +00:00
nboyd%atg.com
517b2d35e4 Fix NPE. 2001-04-09 23:43:19 +00:00
nboyd%atg.com
a867dbf67d Subject:
Minor fix to JSDebugger
        Date:
             Wed, 28 Mar 2001 16:34:24 -0800
       From:
             Christopher Oliver <coliver@mminternet.com>
 Organization:
             Primary Interface LLC
         To:
             nboyd@atg.com




Hi Norris,

Attached is a minor fix to the JSDebugger GUI that causes the tool-bar buttons to all have the same width.
I checked out and modified a file from CVS today.  See the screenshot below.

Cheers,

Chris
2001-03-29 01:44:45 +00:00
nboyd%atg.com
8adfb2b57f Fix problem where errors wouldn't get source positions. 2001-03-28 14:42:37 +00:00
nboyd%atg.com
0173c9bc63 Fix 73555. 2001-03-27 14:01:53 +00:00
nboyd%atg.com
53f72f3639 Fix bug 72921. 2001-03-22 21:56:12 +00:00
nboyd%atg.com
5f7badd05f Print name of function in toString 2001-03-12 19:05:36 +00:00
nboyd%atg.com
77fee58f07 Infinity/Math.min(0,-0) should produce -Infinity 2001-03-12 16:53:02 +00:00
nboyd%atg.com
dfacb25c9f Close thread hazard hole. 2001-03-12 14:55:47 +00:00
nboyd%atg.com
f1901fba16 More changes from Igor. 2001-03-10 11:51:15 +00:00
nboyd%atg.com
4e07e9b5bf Add method to set security support after creation. 2001-03-10 11:50:50 +00:00
matthias%sorted.org
712e352a43 replicated SpiderMonkey fix for bug 67773 2001-03-06 13:57:01 +00:00
matthias%sorted.org
8d348ad77e * made shell.Global a subclass of ImporterTopLevel
* fixed ImporterTopLevel constructor - it now calls
cx.initStandardObjects before defining any functions. The old
constructor is still around for backwards compatibility.
2001-03-05 08:46:10 +00:00
nboyd%atg.com
534fc4e412 More changes from Igor. 2001-03-01 19:28:37 +00:00
matthias%sorted.org
ebbd7aaa6c fixed two instances where prefix match would return undefined instead of null 2001-03-01 16:52:23 +00:00
matthias%sorted.org
6413b694ba getInstance now uses ScriptableObject.getProperty instead of
Scriptable.get. This way Global can (again) be used in prototype
chain.
2001-03-01 13:33:55 +00:00
nboyd%atg.com
a91023590b Commit new scheme for builtin objects, courtesy of
Igor Bukanov <igor@icesoft.no>. This new scheme is
faster and consumes less memory.
2001-02-26 16:16:46 +00:00
nboyd%atg.com
3f5e828b80 Change ClassOutput to take a top-level boolean parameter. 2001-02-26 15:32:15 +00:00
nboyd%atg.com
b02120e058 Add top-level boolean parameter so ClassOutput implementors can determine
which class to load to execute a script.
2001-02-26 15:28:17 +00:00
nboyd%atg.com
446ea9e8da Real fix for last problem. 2001-02-22 14:45:10 +00:00
nboyd%atg.com
25a2852250 Subject:
Rhino Context.setTargetClassFileName() null pointer exception
        Date:
             Tue, 20 Feb 2001 15:28:20 -0800
       From:
             "Ryan Manwiller" <rdm@europa.com>
 Organization:
             Another Netscape Collabra Server User
 Newsgroups:
             netscape.public.mozilla.jseng




I'm setting the file name to compile to a file. However, on subsequent
compiles, I don't want to compile to a file, so I tried
setTargetClassFileName(null). This causes a NullPpinterException in
OptClassNameHelper.setTargetClassFileName(OptClassNameHelper.java:76)

It seems that Context.setTargetClassFileName() should check for null.

Thanks
2001-02-21 02:08:05 +00:00
nboyd%atg.com
82bd85bfce Fix for problem:
Subject:
             Rhino Exception Handling: Inconsistency btw Old/New Versions of 1.5
        Date:
             Mon, 05 Feb 2001 06:07:07 -0800
       From:
             Timothy Bergeron <bergeron@resumerabbit.com>
 Organization:
             Another Netscape Collabra Server User
 Newsgroups:
             netscape.public.mozilla.jseng




I've been using Rhino for about a year with almost no problems. However,
I downloaded the latest Rhino tip (rhino15R2pre) and discovered a
significant difference in exception handling.

I rely heavily on JavaScript code like the following:

try {
   var em  = new ExceptionMaker();
   em.npe();  // method throws a java.lang.NullPointerException
   //em.ae();  // method throws a Packages.AutomationException
}
catch (e if (e instanceof java.lang.NullPointerException)) {
   java.lang.System.out.println("Caught a NullPointerException");
   e.printStackTrace();
}
catch (e if (e instanceof Packages.AutomationException)) {
   java.lang.System.out.println("Caught an AutomationException");
}
catch (e) {
   java.lang.System.out.println("Caught an unexpected exception: "+e);
}
finally {
   java.lang.System.out.println("Finally!");
}

Previous Rhino versions worked as expected. The exception thrown from
within the host object would be caught and the appropriate actions could
be taken.

With the most recent tip, the thrown exceptions simply are not caught
within the JavaScript. They propagate back to the Java function invoking
the (in my case) Context.evaluateReader() method.

Running the above JS fragement with the older tip displayed the
following stack trace (when the NullPointerException was caught):

Rhino Version: JavaScript-Java 1.5 release 1 2000 03 15
Caught a NullPointerException
java.lang.NullPointerException
        at java.lang.Throwable.<init>(Throwable.java:84)
        at java.lang.Exception.<init>(Exception.java:35)
        at java.lang.RuntimeException.<init>(RuntimeException.java:39)
        at
java.lang.NullPointerException.<init>(NullPointerException.java:45)
        at ExceptionMaker.jsFunction_npe(ExceptionMaker.java:13)
        at java.lang.reflect.Method.invoke(Native Method)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:497)
        at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1205)
        at org.mozilla.javascript.gen.c1.call(exception.js:3)
        at org.mozilla.javascript.gen.c1.exec(exception.js)
        at
org.mozilla.javascript.Context.evaluateReader(Context.java:739)
        at js.main(js.java:14)
Finally!

When run with the latest tip, the output is:

Rhino Version: JavaScript-Java 1.5 release 1 2000 03
15                                          Finally!
Exception in thread "main" java.lang.NullPointerException
        at java.lang.Throwable.<init>(Throwable.java:84)
        at java.lang.Exception.<init>(Exception.java:35)
        at java.lang.RuntimeException.<init>(RuntimeException.java:39)
        at
java.lang.NullPointerException.<init>(NullPointerException.java:45)
        at ExceptionMaker.jsFunction_npe(ExceptionMaker.java:13)
        at inv2.invoke()
        at
org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:843)
        at
org.mozilla.javascript.FunctionObject.call(FunctionObject.java:486)
        at
org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1199)
        at org.mozilla.javascript.gen.c1.call(Unknown Source)
        at org.mozilla.javascript.gen.c1.exec(Unknown Source)
        at
org.mozilla.javascript.Context.evaluateReader(Context.java:778)
        at js.main(js.java:14)

Curiously, both Rhino versions seem to be returning the same string from
Context.getImplementionVerison();

Anyway, the results from the two runs are clearly different: In the
first case, the exception is thown, the correct catch block is invoked
(hence the stace trace), and the finally block is invoked. In the second
case, the exception is thrown, the finally block is invoked, and the
exception is handled by the calling Java method rather than being
handled by the JavaScript code.

After some research, it appears this change was introducted by a
modification to FunctionObject.call()  (See
http://bugzilla.mozilla.org/show_bug.cgi?id=64788) which used to have:

       try {
            Object result = (method != null)
                            ? method.invoke(thisObj, invokeArgs)
                            : ctor.newInstance(invokeArgs);
            return hasVoidReturn ? Undefined.instance : result;
        }

but now has:

            Object result = method == null ?
ctor.newInstance(invokeArgs)
                                           : doInvoke(thisObj,
invokeArgs);

If I comment out the new code and replace it with the old, the expected
exception handling returns. Is this just an oversight or the new
expected behavior? Are there any negative side effects (other then the
speed decrease in method invocation) if I use the latest tip but use the
old method invocation procedure in FunctionObject.call() rather than the
new?
2001-02-08 18:56:58 +00:00
nboyd%atg.com
e5473d8fda Subject:
Re: [Rhino in Java] compiling .js to class file gives "bad local" error
        Date:
             Wed, 31 Jan 2001 09:41:45 +0100
       From:
             "Sylvia E. Schleutermann" <ses@h-m-s.com>
 Organization:
             .hms Health Management Systems
 Newsgroups:
             netscape.public.mozilla.jseng
  References:
             1 , 2




I have found out some more. Looking really quickly over the JVM specs, I
found that
indeed the astore-command requires that the variables index be below 128.
However,
the book also said that if more index space is needed, a "wide" command can
be used to
be able to address up to 65xxx variables.
Question: is there a possibility to integrate this "wide"-command into the
class compiler?
Some option, that can be set?  Or am I on the wrong tracks?

Please help, since I want to avoid spreading the script over many classes to
avoid the
size limitation. Cheers, Sylvia


Sylvia E. Schleutermann <ses@h-m-s.com> wrote in message
news:956sv9$9g53@secnews.netscape.com...
> I have found out that it is definitely the number of variables.
> I removed all variables and then the script compiled into class files
> with one base class and inner classes for each function in the script.
>
> What is the limitation exactly, i.e. does anyone know how many (global)
> variables
> I can use? Or is there some other kind of work around?
>
> Cheers, Sylvia
>
>
> Sylvia E. Schleutermann <ses@h-m-s.com> wrote in message
> news:956qtv$6kh3@secnews.netscape.com...
> > Hello,
> > when compiling a *.js file to class file, I get a "bad local" runtime
> > exception.
> > Stepping through the source, the following happens in reverse order:
> >
> > Codegen.xstore (75, 58, 209)
> >     -> in the switch - default case, there is a comparison
> >         for local (=209), which is compared to Byte.MAX_VALUE (=127).
> >         When greater, the above exception is thrown.
> >
> > Codegen.astore (209)
> >     -> calls Codegen.xstore (ByteCode.ASTORE_0, ByteCode.ASTORE, 209)
> >
> > Codegen.generatePrologue (<context>, <tree>, true, -1) // -1 is
> > directParameterCount
> >     -> sets itsZeroArgArray = getNewWordLocal(); // here, the 209 is
> > produced
> >     -> calls astore (itsZeroArgArray)
> >
> > From what I can read from the source code, the 209 seems to be a counter
> for
> > "locals", perhaps
> > local variables?? The function that is being compiled does initialize
many
> > variables - would it help
> > to move the initialize code out of the function into separate code
blocks?
> >
> > The function looks like this
> >
> > function rule_Disclaimer()
> > {
> >     try { VAR1 = <init code 1>;} catch (exception) { VAR1 = <default
init
> > code 1>; }
> >     try { VAR2 = <init code 2>;} catch (exception) { VAR2 = <default
init
> > code 2>;}
> >         ... (about 58 such variables)
> >
> >     var cond = true;
> >
> >     < rest of code>
> > }
> >
> > When I compile the script for interpreted mode, all works well. The
> > variables VAR1 to VAR58 are to be global
> > variables (global to the whole script).
> >
> > I appreciate any help! Thanks, Sylvia
> >
> >
>
>
2001-02-02 15:20:03 +00:00
matthias%sorted.org
f39acf5399 introduced "sync" helper function for converting a Javascript function
into a Java-style synchronized method
2001-01-31 13:05:21 +00:00
matthias%sorted.org
e5ae12e585 added support for implementing Java-style synchronized methods in Javascript 2001-01-31 13:02:42 +00:00
matthias%sorted.org
4aee7d25d7 added support for incremental/prefix matching of regular
expressions. The method "prefix" on a RegExp behaves exactly the same
as the "exec" method except it returns "undefined" if the match failed
because there was an insufficient number of characters in the
input. E.g.
/^foo/.prefix("foo")	=> ["foo"] (just like exec)
/^foo/.prefix("fox")	=> null (just like exec)
/^foo/.prefix("fo")	=> undefined (whereas exec returns null)
2001-01-30 16:38:21 +00:00
nboyd%atg.com
42056e97d4 Fix bug:
Subject:
             [Rhino] Question
        Date:
             Tue, 30 Jan 2001 20:18:21 +0900
       From:
             "get21" <get21@secsm.org>
 Organization:
             Another Netscape Collabra Server User
 Newsgroups:
             netscape.public.mozilla.jseng




I found something unusual to me when I hacking the Rhino source code.

In tagify method of NativeString Class,

When it adds tag to its string(this.string), it does not use quotation
marks.

For example, the result of tagify("A HREF", "A", value) in
jsFunction_link(String value) is

<A HREF=Some Value>Original String Value</A>

Not,

<A HREF="Some Value">Original String Value</A>

This question might sound silly, but I'm curious why.

Thanks in advance,

Nam

--
email : get21@secsm.org
home : http://get21.secsm.org
phone : 011-9092-1802
2001-01-30 13:47:19 +00:00
nboyd%atg.com
362492aef1 ECMA mandates a ToPrimitive on Date constructor arguments that we didn't have. 2001-01-25 19:56:54 +00:00
matthias%sorted.org
f989805f9a cleaned up indentation. no code changes. 2001-01-25 18:46:38 +00:00
nboyd%atg.com
665f459571 Move Invoker out as a top-level class so that it doesn't get javadoc'd
with FunctionObject (it must be public).
2001-01-24 15:49:21 +00:00
nboyd%atg.com
6ddf348d98 Alternative fix for problem in the following email:
Subject:
        minor Rhino bug
   Date:
        Tue, 23 Jan 2001 13:14:51 -0800
   From:
        dave russo <d-russo@ti.com>
     To:
        nboyd@atg.com
    CC:
        d-russo@ti.com




Norris,

While using the new Rhino debugger (from the latest tip) I started to get "No
Context associated with current Thread" exceptions when expanding host objects
in the "Context:" debugger window.

In looking at the code, I discovered that NativeObject.toString seems to assume
that Context.getContext() may return null.  In fact, getContext() always returns
a non-null context or throws an exception.

I changed NativeObject.toString to never throw an exception (see below) and this
eliminated the problem I was seeing (of course).

It would be nice to incorporate this in a future Rhino tip or, if this change is
inappropriate, any guidance would be appreciated.  Thanks in advance.

I changed NativeObject.toString to:

    public String toString() {
        try {
            Context cx = Context.getContext();
            return jsFunction_toString(cx, this, null, null);
        }
        catch (Exception e) {
            return "[object " + getClassName() + "]";
        }
    }

from:

   public String toString() {
        Context cx = Context.getContext();
        if (cx != null)
            return jsFunction_toString(cx, this, null, null);
        else
            return "[object " + getClassName() + "]";
    }
2001-01-24 15:16:37 +00:00
nboyd%atg.com
389c4e220e Subject:
Re: Small usage simplification for Rhino
       Date:
            Tue, 23 Jan 2001 16:01:42 +0100
      From:
            Igor Bukanov <igor@icesoft.no>
        To:
            Norris Boyd <nboyd@atg.com>
 References:
            1 , 2 , 3 , 4




Norris Boyd wrote:

> Thanks. I've patched in your changes and checked it into CVS.

I also looked at other places with similar pattern of few lines of
common code to construct error messages. The following was occurred too
often not to avoid temptations to move it to a separated function:

NativeGlobal.constructError(
Context.getContext(), "TypeError",
ScriptRuntime.getMessage1("msg.default.value", arg),
this)

It can be replaced by
NativeGlobal.typeError1("msg.default.value", arg, this)

There are other similar usages but they are not to frequent to bother
with code reduction because even the above replacement saves just 200
bytes in uncompressed jars (it is expensive to introduce new methods in
Java).

In any case, if you think it makes any sense, patches are attached. They
are made via
diff -cbB javascript.orig javascript > patch_context
diff -bB javascript.orig javascript > patch_std
from org/mozilla directory.

Regards, Igor
2001-01-23 19:35:35 +00:00
nboyd%atg.com
1a357f5fda Fix problem:
Subject:
        Recent rhino broke security support
   Date:
        Tue, 23 Jan 2001 08:07:45 -0500
   From:
        "Kurt Westerfeld" <kurt@managedobjects.com>
     To:
        "Norris Boyd" <nboyd@atg.com>


Norris.....I like the changes made to FunctionObject to do method invocation
much faster.  Very slick.

Problem tho: this mechanism does not veer into the security support plugin
on context for defining a class.  This is crucial do creating event adapter
code later in applet environments.

I'm going to look into this, but perhaps you could probably make the changes
faster than I.

Unfortunately for us, we found this problem yesterday at a customer site.
:-(  Shame on us.

________________________________________________________________________
  Kurt Westerfeld
  Senior Software Architect
  Managed Objects
  mailto:kwester@ManagedObjects.com
  703.770.7225
  http://www.ManagedObjects.com

  Managed Objects: manage technology > rule business
2001-01-23 17:48:41 +00:00
nboyd%atg.com
8ed55e98dd Fix formatting 2001-01-23 14:24:39 +00:00
rogerl%netscape.com
3d250fdec1 More fixes for #64285 - i had mis-merged from SpiderMonkey. 2001-01-22 22:30:37 +00:00
nboyd%atg.com
e737c6d867 Subject:
Re: Small usage simplification for Rhino
       Date:
            Mon, 22 Jan 2001 20:32:12 +0100
      From:
            Igor Bukanov <igor@icesoft.no>
        To:
            Norris Boyd <nboyd@atg.com>
 References:
            1 , 2




Norris Boyd wrote:

> Sounds like a good change to reduce codesize. I'll take the patches for the
> changes.
>
> Thanks,
> Norris

I made this patch, the files in the attachment were produced via:
diff -bB javascript.orig javascript -c > patch_context
and
diff -bB javascript.orig javascript > patch_std

run from org/mozilla directory.

This patch reduces uncopressed Rhino jar by 3K.

>
> Igor Bukanov wrote:
>
>
>> Hi, Noris!
>>
>> To shorten/cleanup usage of getMessage and reportRuntimeError methods
>> from org/mozilla/javascript/Context.java I suggest to add few utility
>> methods like
>>
>>      static String getMessage0(String messageId) {
>>          return getMessage(messageId, null);
>>      }
>>
>>      static String getMessage1(String messageId, Object arg1) {
>>          Object[] arguments = {arg1};
>>          return getMessage(messageId, arguments);
>>      }
>>
>>      static String getMessage2(String messageId, Object arg1, Object arg2) {
>>          Object[] arguments = {arg1, arg2};
>>          return getMessage(messageId, arguments);
>>      }
>>
>>      static String getMessage3
>>          (String messageId, Object arg1, Object arg2, Object arg3) {
>>          Object[] arguments = {arg1, arg2, arg3};
>>          return getMessage(messageId, arguments);
>>      }
>>
>> and
>>
>>      static EvaluatorException reportRuntimeError0(String messageId) {
>>          return reportRuntimeError(getMessage0(messageId));
>>      }
>>
>>      static EvaluatorException reportRuntimeError1
>>          (String messageId, Object arg1)
>>      {
>>          return reportRuntimeError(getMessage1(messageId, arg1));
>>      }
>>
>>      static EvaluatorException reportRuntimeError2
>>          (String messageId, Object arg1, Object arg2)
>>      {
>>          return reportRuntimeError(getMessage2(messageId, arg1, arg2));
>>      }
>>
>>      static EvaluatorException reportRuntimeError3
>>          (String messageId, Object arg1, Object arg2, Object arg3)
>>      {
>>          return reportRuntimeError(getMessage3(messageId, arg1, arg2,
>> arg3));
>>      }
>>
>> This allows to write, for example, instead of
>>
>>               Object[] args = { Integer.toString(base) };
>>               throw Context.reportRuntimeError(getMessage
>>                                                ("msg.bad.radix", args));
>> simply
>>               throw Context.reportRuntimeError1(
>>                   "msg.bad.radix", Integer.toString(base));
>>
>> which is not only easy to read but also generates less code.
>>
>> I attach my patch to Context.java to implement this plus a patch to
>> ScriptRuntime.java that utilizes the additions. The patches are in
>> standard and context versions.
>>
>> If you think that this make sense to incorporate, I can send a patch
>> that utilizes this everywhere.
>>
>>   ------------------------------------------------------------------------
>>                                  Name: patch.context.Context.java
>>    patch.context.Context.java    Type: Plain Text (text/plain)
>>                              Encoding: base64
>>
>>                              Name: patch.std.Context.java
>>    patch.std.Context.java    Type: Plain Text (text/plain)
>>                          Encoding: base64
>>
>>                                        Name: patch.context.ScriptRuntime.java
>>    patch.context.ScriptRuntime.java    Type: Plain Text (text/plain)
>>                                    Encoding: base64
>>
>>                                    Name: patch.std.ScriptRuntime.java
>>    patch.std.ScriptRuntime.java    Type: Plain Text (text/plain)
>>                                Encoding: base64
>>
>>               Name: all.zip
>>    all.zip    Type: Zip Compressed Data (application/x-zip-compressed)
>>           Encoding: base64
2001-01-22 20:28:34 +00:00
rogerl%netscape.com
aeca31a7bd Merged Monkey bits, fix for bug #57631, /()/ was parsed incorrectly. 2001-01-18 23:39:00 +00:00
rogerl%netscape.com
bbcf08a5c3 Merged changes from Monkey - see bug #64285. 2001-01-18 22:49:11 +00:00
nboyd%atg.com
08a188c69b Subject:
[Fwd: My Mistake in ScriptRuntime method]]]
   Date:
        Tue, 16 Jan 2001 15:48:26 +0100
   From:
        Igor Bukanov <igor@icesoft.no>
     To:
        Norris Boyd <nboyd@atg.com>




Hi, Norris!

With my previous patch to fix in
org/mozilla/javascript/ScriptRuntime.java Integer.MIN_VALUE as index
problem I also added a bug to the unrelated code: I tried to minimize
object creation and unfortunately that untested "optimization" slippet
into my patch as well.

I replaced the lines 290, 291 in toNumber(String s) method from

String sub = s.substring(start, end+1);
if (sub.equals("Infinity"))

to

if (s.regionMatches(start, "Infinity", 0, 8))

But that should be
if (start + 7 == end && s.regionMatches(start, "Infinity", 0, 8))

Sory for troubles, Igor





290c290
<             if (s.regionMatches(start, "Infinity", 0, 8))
---
>             if (start + 7 == end && s.regionMatches(start, "Infinity", 0, 8))
2001-01-16 20:20:36 +00:00
nboyd%atg.com
b3d6830b8b Expand tutorial. 2001-01-16 15:24:23 +00:00
nboyd%atg.com
4d54695ee1 Fix 64788 Make method invocation 10x faster with following code.... 2001-01-14 01:19:58 +00:00
beard%netscape.com
0ef1cd4d6e Keeping up with current Rhino sources. Removed Frame.java, Added DebugFrame.java, DebuggableEngineImpl.java. 2001-01-12 20:42:17 +00:00
nboyd%atg.com
bbae607060 Update comment; operator is part of ECMA. 2001-01-12 16:30:04 +00:00
nboyd%atg.com
1e13a69fde Add removeThreadLocal method. 2001-01-12 16:29:26 +00:00
nboyd%atg.com
8ca97fa895 Fix infinite loop in example. 2001-01-12 16:28:36 +00:00
nboyd%atg.com
b8ac59c406 Subject:
Re: Debugger problem
        Date:
             Mon, 08 Jan 2001 14:16:30 -0800
       From:
             Christopher Oliver <coliver@mminternet.com>
 Organization:
             Primary Interface LLC
         To:
             Kurt Westerfeld <kurt@ManagedObjects.com>
         CC:
             Norris Boyd <nboyd@atg.com>
  References:
             1 , 2 , 3




Kurt, Norris,

Yes, with the change to the shell this should be possible.  The problem before
was that if you loaded the same file with different relative path names, two
different windows in the debugger were created because everything (windows,
breakpoints, etc) is keyed off the source name.

The attached file contains the fix (and includes the workaround for
Desktop.getSelectedFrame).

There are still some bugs in transferring focus between the windows in the
Desktop.  I haven't had time to track down the problem or a solution.

Chris

Kurt Westerfeld wrote:

> I would point out that "Source Name" of a script isn't necessarily a
> filename.  In our system, scripts are run remotely from a script library
> that has no file system backing.  Canonicalizing the file names is really
> unnecessary.
>
> Can't you just modify JSDebugger to not care what the name of the file is?
> If access to the original script is unavailable except through the file
> system, I'd be surprised.
>
> ----- Original Message -----
> From: Christopher Oliver <coliver@mminternet.com>
> To: Kurt Westerfeld <kurt@ManagedObjects.com>
> Cc: Norris Boyd <nboyd@atg.com>
> Sent: Sunday, January 07, 2001 2:23 AM
> Subject: Re: Debugger problem
>
> > Hi Kurt,
> >
> > I rather would say that it is a problem with the processFile method in the
> > shell's Main class.  If you change the current working directory or the
> value
> > of the System property "user.dir" after compiling a script, relative path
> names
> > can become ambiguous.  Norris, would it be ok to modify the shell to
> > "canonicalize" the names of files it compiles?  That way the source name
> that
> > shows up in the stack and in DebuggableScript will always be unique.  For
> > example:
> >
> > public static void processFile(Context cx, Scriptable scope,
> >                                    String filename)
> >     {
> >             Reader in = null;
> >             try {
> >                 in = new PushbackReader(new FileReader(filename));
> >                 int c = in.read();
> >                 // Support the executable script #! syntax:  If
> >                 // the first line begins with a '#', treat the whole
> >                 // line as a comment.
> >                 if (c == '#') {
> >                     while ((c = in.read()) != -1) {
> >                         if (c == '\n' || c == '\r')
> >                             break;
> >                     }
> >                     ((PushbackReader) in).unread(c);
> >                 } else {
> >                     // No '#' line, just reopen the file and forget it
> >                     // ever happened.  OPT closing and reopening
> >                     // undoubtedly carries some cost.  Is this faster
> >                     // or slower than leaving the PushbackReader
> >                     // around?
> >                     in.close();
> >                     in = new FileReader(filename);
> >                 }
> >                 filename = new java.io.File(filename).getCanonicalPath();
> > <<<====== Add this
> >             }
> >             catch (FileNotFoundException ex) {
> >                 Context.reportError(ToolErrorReporter.getMessage(
> >                     "msg.couldnt.open",
> >                     filename));
> >                 exitCode = EXITCODE_FILE_NOT_FOUND;
> >                 return;
> >             } catch (IOException ioe) {
> >                 globalState.getErr().println(ioe.toString());
> >             }
> >
> >             // Here we evalute the entire contents of the file as
> >             // a script. Text is printed only if the print() function
> >             // is called.
> >             evaluateReader(cx, scope, in, filename, 1);
> >     }
> >
> >
> > Attached is *my* latest version of the debugger code.  Norris, have you
> made
> > any progress on cvs commit priveledges?  The attached version fixes a
> number of
> > GUI bugs:
> >
> > 1) If you undocked the Variables window and popped up the Context
> combo-box and
> > then closed the window with the system menu, the Context pop-up was not
> cleaned
> > up properly.
> > 2) The first time you minimize a file window it appeared to dissappear
> when you
> > tried to restore it.  This was due to the fact that I forgot to "pack" its
> > contents and as a result its requested size was 0x0.
> >
> > I also added a menu item to toggle whether to break on exceptions and one
> which
> > allows you to open (and compile) a JavaScript file without actually
> executing
> > it.
> >
> > I have also attached a Word document with some basic documentation for the
> > Debugger.
> >
> > Note that this version also includes all the changes to support debugging
> > scripts in the AWT dispatch thread.
> >
> > Chris
> >
> > Kurt Westerfeld wrote:
> >
> > > Hello.  I ran into a null pointer exception in JSDebugger tonight, and I
> > > thought I'd drop you a note.
> > >
> > > The problem line is 2336, where a breakpoint is hit.  To simulate, load
> the
> > > debugger using the command line syntax on a file that has not been
> resolved
> > > to cannonical path.
> > >
> > > Example,
> > >
> > >      jshell -debug -f \myfile.fs
> > >
> > > At any rate, the "handleCompilationDone" routine takes \myfile.fs and
> turns
> > > it into a canonical path.  If you hit a breakpoint in this file and say
> > > "go", when the breakpoint hits the file is not found, because the same
> > > canonical path resolution is not done.  The resolution seems dubious,
> since
> > > it is only done in the compilation done callback, but I don't know the
> best
> > > way to suggest a fix since it seems that code had some purpose.
> > >
> > > Anyway, thought you'd wanna know.
> > >
> > > ________________________________________________________________________
> > >   Kurt Westerfeld
> > >   Senior Software Architect
> > >   Managed Objects
> > >   mailto:kwester@ManagedObjects.com
> > >   703.770.7225
> > >   http://www.ManagedObjects.com
> > >
> > >   Managed Objects: manage technology > rule business
> >



   JSDebugger.java

                    Name:
                          JSDebugger.java
                    Type:
                          Java Class File (java/*)
                 Encoding:
                          base64
2001-01-09 14:10:40 +00:00
nboyd%atg.com
864bb13d47 Missed checkin of new file. 2001-01-09 13:39:22 +00:00
nboyd%atg.com
cbf2c6d0b4 Clean up debug APIs.
* Make use of DebuggableEngine interface to keep Context API smaller
* Change org.mozilla.javascript.debug.Frame to DebugFrame to avoid
  confusion with java.awt.Frame
2001-01-08 21:41:25 +00:00
nboyd%atg.com
05afc92b5d Fix for 1.1 compatibility. 2001-01-08 14:34:21 +00:00
nboyd%atg.com
db930451b8 Fix classloader problem from last checkin. 2001-01-08 02:13:28 +00:00
nboyd%atg.com
1de208b764 Canonicalize file names to help debugger. 2001-01-08 02:12:52 +00:00