Commit Graph

1754 Commits

Author SHA1 Message Date
kipp%netscape.com
feff21ed38 r=jband; fixed a memory leak
git-svn-id: svn://10.0.0.236/trunk@49841 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 14:56:41 +00:00
mccabe%netscape.com
1664bd1228 Initial checkin of TestScan.java, a simple driver for generating and printing various kinds of parse trees, and for profiling scanning, parsing and compiling.
git-svn-id: svn://10.0.0.236/trunk@49792 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 03:47:04 +00:00
dmose%mozilla.org
de7b2e5e74 update license boilerplate to NPL dual w/GPL, r=norris@netscape,a=norris@netscape.com
git-svn-id: svn://10.0.0.236/trunk@49783 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 01:42:01 +00:00
dmose%mozilla.org
239d60872d update license boilerplate to NPL dual w/GPL, r=norris@netscape,a=norris@netscape.com
git-svn-id: svn://10.0.0.236/trunk@49766 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:44:05 +00:00
rogerl%netscape.com
4c19332cbb First cut at errors as exceptions - These changes should be benign since
the errors are being wrapped by runtime exceptions and still need to be
explicitly caught (this is happening in the interpreter, but not in
generated code).


git-svn-id: svn://10.0.0.236/trunk@49760 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:21:07 +00:00
waterson%netscape.com
9145c77cc4 Bug 15367. Dump 'class' instead of 'file/line' for NS_LOG_REFCNT. r=shaver,dp
git-svn-id: svn://10.0.0.236/trunk@49757 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-05 00:07:54 +00:00
norris%netscape.com
288c2fdcfb Fix up makefiles; previous patch was mis-applied.
git-svn-id: svn://10.0.0.236/trunk@49733 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-04 21:31:21 +00:00
norris%netscape.com
19a71ea13f Fix bug found by Andrew Wason (see below).
Problem was that one transformation of a node to GETVAR wasn't protected by a check of inWithStatement().

======================================
Subject:
        multiple scopes
   Date:
        Fri, 01 Oct 1999 12:39:14 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




When I create two scopes, and one scope evaulates a string in the other
scope, it works.  However, if I do this while handling an exception thrown
within a JavaAdapter method, it fails with an exception.

Run the attached Java program with the two script files.  scope1.js
evaluates a string "printMessage" in the scope of scope2.js.  This returns
a function object which is then invoked.  This works in 3 cases, but fails
in the 4th (in the catch in the JavaAdapter).  Even in the 4th case where
it fails, printing the function object looks normal.

Am I doing something wrong, or is there a bug here?

java CrossScope scope1.js scope2.js

Outside of JavaAdapter
works before exception
works after exception
Inside of JavaAdapter
works before exception
Caught exception
pma=
function printMessage(msg) {
     java.lang.System.out.println(msg);
}

Exception in thread "main" org.mozilla.javascript.JavaScriptException:
org.mozilla.javascript.EvaluatorException: The undefined value has no
properties.
         at
org.mozilla.javascript.JavaScriptException.wrapException(JavaScriptException
.java:61)
         at
org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java,
Compiled Code)
         at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1256)
         at org.mozilla.javascript.Interpreter.interpret(Interpreter.java,
Compiled Code)
         at
org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java:49)
         at
org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java:37)
         at org.mozilla.javascript.Context.evaluateReader(Context.java:697)
         at CrossScope.<init>(CrossScope.java:30)
         at CrossScope.main(CrossScope.java:10)


Thanks,
Andrew

import java.io.*;
import org.mozilla.javascript.*;

public class CrossScope {
	private Context m_jsContext;
	private Scriptable m_scope1;
	private Scriptable m_scope2;

	public static void main(String args[]) throws Exception {
		new CrossScope(args[0], args[1]);
	}

	private CrossScope(String strFile1, String strFile2) throws Exception {
		// Associate Context with main thread
		m_jsContext = Context.enter();
                m_jsContext.setOptimizationLevel(-1);

		// Init scope1, expose Scope object
  		m_scope1 = m_jsContext.initStandardObjects(new ImporterTopLevel());
		m_scope1.put("Scope", m_scope1, this);

		// Init scope2
		m_scope2 = m_jsContext.initStandardObjects(new ImporterTopLevel());

		// Run script in scope2
		Reader r2 = new FileReader(strFile2);
		m_jsContext.evaluateReader(m_scope2, r2, strFile2, 1, null);

		// Eval input JS in scope1 - it can in turn eval JS over in scope2
		Reader r1 = new FileReader(strFile1);
		Object obj = m_jsContext.evaluateReader(m_scope1, r1, strFile1, 1, null);
		if (obj instanceof Throwable)
			((Throwable)obj).printStackTrace();

		m_jsContext.exit();
	}

	public Object scope1Eval(String str) throws JavaScriptException {
			Context cx = Context.enter(m_jsContext);
			Object objResult = cx.evaluateString(m_scope1, str, "scope1EvalString", 1, null);
			cx.exit();
			return objResult;
	}

	public Object scope2Eval(String str) throws JavaScriptException {
			Context cx = Context.enter(m_jsContext);
			Object objResult = cx.evaluateString(m_scope2, str, "scope2EvalString", 1, null);
			cx.exit();
			return objResult;
	}
}


// Scope1

importPackage(java.lang);

System.out.println("Outside of JavaAdapter");

try {
	var pm = Scope.scope2Eval("printMessage");
	pm("works before exception");
	System.arraycopy(null, 5, null, 5, 100);
} catch (e) {
	var pma = Scope.scope2Eval("printMessage");
	pma("works after exception");
}

var obj = new Runnable() {
	run: function() {
		System.out.println("Inside of JavaAdapter");
		try {
			var pm = Scope.scope2Eval("printMessage");
			pm("works before exception");
			System.arraycopy(null, 5, null, 5, 100);
		} catch (e) {
			System.out.println("Caught exception");
			var pma = Scope.scope2Eval("printMessage");
			System.out.println("pma=" + pma);
			pma("works after exception");
		}
	}
};

obj.run();



// Scope2

function printMessage(msg) {
	java.lang.System.out.println(msg);
}


git-svn-id: svn://10.0.0.236/trunk@49726 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-04 18:27:30 +00:00
beard%netscape.com
75c8c9cd12 changed from directly using "MSL ShLibRuntime.Lib" to using "NSLibraryStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49691 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:47:12 +00:00
beard%netscape.com
da97767078 changed from directly using "MSL DropInRuntime.Lib" to using "NSComponentStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49690 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:46:23 +00:00
beard%netscape.com
cd941313ec changed from directly using "MSL ShLibRuntime.Lib" to using "NSLibraryStartup.o" to enable GC leak detector. r=smfr
git-svn-id: svn://10.0.0.236/trunk@49686 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-03 20:23:01 +00:00
norris%netscape.com
c3494a9ffb Fix the following bugs:
14443 "Same origin" security policy may be circumvented using docu
14820 Fixing up the relationship between nsCodeBasePrincipal and n
14919 Crash in JS MM code
Reviewed by mstoltz, approved by scc.


git-svn-id: svn://10.0.0.236/trunk@49647 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-02 03:41:37 +00:00
norris%netscape.com
69ec6c9b26 Contribution from Andrew Wason:
Subject:
        optimizer Makefiles
   Date:
        Fri, 01 Oct 1999 14:50:05 -0400
   From:
        Andrew Wason <aw@softcom.com>
     To:
        norris@netscape.com
    CC:
        Howard Lin <howard@softcom.com>




Norris,

Here are patches to the Rhino Makefiles to build the optimizer package and
the jsc compiler.  They also fix a problem with "gmake clean".

Andrew
--
Andrew Wason
SoftCom, Inc.
aw@softcom.com


git-svn-id: svn://10.0.0.236/trunk@49613 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 22:58:48 +00:00
norris%netscape.com
34f7a63ece \t doesn't work on Windows.
git-svn-id: svn://10.0.0.236/trunk@49612 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-01 22:56:30 +00:00
kipp%netscape.com
29f22b7a81 Convert to a module from a component
git-svn-id: svn://10.0.0.236/trunk@49497 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-30 21:47:04 +00:00
kipp%netscape.com
72f4eb33d6 Fixed shutdown related memory leaks
git-svn-id: svn://10.0.0.236/trunk@49462 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-30 21:12:33 +00:00
beard%netscape.com
a2370105c8 fixed output directory
git-svn-id: svn://10.0.0.236/trunk@49308 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:11:58 +00:00
beard%netscape.com
8ce70dfe45 fixed source folder name
git-svn-id: svn://10.0.0.236/trunk@49307 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:10:25 +00:00
beard%netscape.com
ea14ed5e8f build debugger with CW Pro 4.
git-svn-id: svn://10.0.0.236/trunk@49306 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 16:07:22 +00:00
beard%netscape.com
b828a0f15c builds the optimizer using CW Pro 4.
git-svn-id: svn://10.0.0.236/trunk@49305 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 15:55:29 +00:00
sfraser%netscape.com
7c61e9da87 More type mismatch fixing for shavear
git-svn-id: svn://10.0.0.236/trunk@49279 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 03:07:27 +00:00
shaver%netscape.com
a2616788dd nsIRegistry scriptability update, r=dveditz,dp,alecf a=leaf,chofmann
git-svn-id: svn://10.0.0.236/trunk@49273 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-29 02:36:54 +00:00
dmose%mozilla.org
ec2434440d update license boilerplate to NPL-1.1 dual-licensed with the GPL. a=brendan, r=brendan.
git-svn-id: svn://10.0.0.236/trunk@49258 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-28 23:12:09 +00:00
norris%netscape.com
df9854bffc Add example of classfile generation.
git-svn-id: svn://10.0.0.236/trunk@49159 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 23:21:01 +00:00
norris%netscape.com
55a4a7f1c5 Changes for classfile generation.
git-svn-id: svn://10.0.0.236/trunk@49158 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 23:17:29 +00:00
rogerl%netscape.com
e2eb39f437 Better error handling for interpreter.
git-svn-id: svn://10.0.0.236/trunk@49137 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:47:51 +00:00
rogerl%netscape.com
9d23668623 Changes from Kurt Westerfield to improve error messages from Interpreter
by passing line/file data through bytecode.


git-svn-id: svn://10.0.0.236/trunk@49136 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:47:05 +00:00
rogerl%netscape.com
66e62f8b11 Stash originating source file for error reporting
git-svn-id: svn://10.0.0.236/trunk@49135 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:45:26 +00:00
rogerl%netscape.com
7d983f2350 ECMA 3 array length error handling.
git-svn-id: svn://10.0.0.236/trunk@49133 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:44:30 +00:00
rogerl%netscape.com
bdc0de911c Execute exec in the global scope.
git-svn-id: svn://10.0.0.236/trunk@49132 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:43:40 +00:00
rogerl%netscape.com
ab738e226a New tokens to support better error messages from Interpreter.
git-svn-id: svn://10.0.0.236/trunk@49131 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:43:07 +00:00
rogerl%netscape.com
f1024009ea Added -c <classpath> option to specify, you guessed it, a classpath.
git-svn-id: svn://10.0.0.236/trunk@49130 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 17:41:44 +00:00
shaver%netscape.com
849a96453e unlock in fun_enumProperty, r,a=brendan
git-svn-id: svn://10.0.0.236/trunk@49125 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 08:24:36 +00:00
shaver%netscape.com
796d9f28d8 properly unlock object, preventing ugly crash with |if (foo in noFoo)|
git-svn-id: svn://10.0.0.236/trunk@49118 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 06:04:54 +00:00
shaver%netscape.com
cd3d51e117 Fix leak of native path in AutoRegisterComponents.
Save registry data for failed components.
Make the loader work again (fix suffix length and init crash).
Better error reporting.


git-svn-id: svn://10.0.0.236/trunk@49114 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 02:22:25 +00:00
kipp%netscape.com
4cc8490c48 Init all variables, not just some of them
git-svn-id: svn://10.0.0.236/trunk@49059 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 20:07:20 +00:00
beard%netscape.com
6274b5bb2a Fixed looking up 'length' property in Function objects: needed to look up prototype chain for zero arguments. Cleaned up some more, always storing Boolean.TRUE in local hash tables, rather than the method, methodKey or methodName.
git-svn-id: svn://10.0.0.236/trunk@49044 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 09:24:23 +00:00
beard%netscape.com
3750775dd6 Added ClassSignature, a key for caching generated adapter classes. Now passing superName, rather than superClass to constructor generation methods.
git-svn-id: svn://10.0.0.236/trunk@49040 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 08:11:24 +00:00
beard%netscape.com
60fa791547 Fixed generateSuper when override has void return type.
git-svn-id: svn://10.0.0.236/trunk@49021 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 01:37:32 +00:00
norris%netscape.com
9ac59bacd6 Shorten name to make Mac developers happy.
git-svn-id: svn://10.0.0.236/trunk@49005 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 21:05:41 +00:00
norris%netscape.com
8d83a6f90d Patches from Kurt Westerfeld for JavaScript property access to JavaBeans.
Subject:
        Re: [Fwd: [Bug 13658] Changed - Rhino: null pointer exception on class with duplicate field/method]
   Date:
        Mon, 13 Sep 1999 20:57:32 -0400
   From:
        "Kurt Westerfeld" <kurt@westerfeld.com>
     To:
        "Norris Boyd" <norris@netscape.com>




I do have a patch for this, but it is intermixed with some other changes
that I have implemented for the get/set on Java instances (per my LC3
proposal).  The bug requires changes that are a little involved actually;
basically it seems that when getting the default value for a "field and
methods" (which combines the same-named entities), the prototype of the
parent scope is deref-ed, and the parent scope is null.  Hence, the scope
must be passed into the the cloned field and method values.

Also, the NativeJavaClass implementation passed "false" for isStatic on the
constructor of the FieldAndMethods Hashtable, which results in classes
having instance methods.  Bad.  I haven't filed a bug on that yet.
Additionally, I fixed a couple other NullPointerException nigglies thrown in
when exceptions are propagated in the same area.  Finally, when getting the
default value for the field, it is helpful to convert a Scriptable to string
when that is requested (as when typing in the console).

I am attaching the changed files.  The LC3++ code can be removed if you
want, which I can do for you but it will take a little longer.  What is your
preference?

-----Original Message-----
From: Norris Boyd <norris@netscape.com>
To: Kurt Westerfeld <kurt@westerfeld.com>
Date: Monday, September 13, 1999 4:54 PM
Subject: [Fwd: [Bug 13658] Changed - Rhino: null pointer exception on class
with duplicate field/method]


>Kurt,
>
>Is this the bug that your patch fixes?
>
>Thanks,
>Norris
>


git-svn-id: svn://10.0.0.236/trunk@49002 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 20:41:43 +00:00
norris%netscape.com
63f9f43324 Remove '.js' from SECTION.
git-svn-id: svn://10.0.0.236/trunk@49000 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 20:16:55 +00:00
norris%netscape.com
734180f200 Propagate files from old netscape code.
git-svn-id: svn://10.0.0.236/trunk@48997 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 20:05:59 +00:00
norris%netscape.com
78fc4f7d32 Implement the "cast" of java class objects so that js objects in java adapters can
use 'this' for the implemented java interface.


git-svn-id: svn://10.0.0.236/trunk@48986 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 18:20:08 +00:00
beard%netscape.com
027ec65e17 Added "generateSuper" which generates a method called "super$method()" which when called calls "super.method()." This is provided to support full sub-classing of Java classes from JavaScript.
git-svn-id: svn://10.0.0.236/trunk@48984 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 18:17:05 +00:00
beard%netscape.com
594e0d302c added a prototype field, so that a wrapped JavaAdapter can preserve the delegate object's original prototype chain.
git-svn-id: svn://10.0.0.236/trunk@48980 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 16:52:23 +00:00
beard%netscape.com
35b28d6457 setAdapterProto: now splices in wrapper's prototype, rather than replacing object's original prototype chain. seems to work fine.
git-svn-id: svn://10.0.0.236/trunk@48979 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 16:51:25 +00:00
mscott%netscape.com
1949443bf0 fix build bustage for dp.
git-svn-id: svn://10.0.0.236/trunk@48956 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 02:52:46 +00:00
dp%netscape.com
339b69262a Fixing jsloader not to hold reference to component manager. (shaver)
Some initialization of members and checking at desctruction. (dp)


git-svn-id: svn://10.0.0.236/trunk@48952 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-24 01:37:44 +00:00
rogerl%netscape.com
eb09a8178e New error for wacky array lengths, ECMA 3
git-svn-id: svn://10.0.0.236/trunk@48931 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-23 23:19:00 +00:00