Compare commits

...

569 Commits

Author SHA1 Message Date
fur%netscape.com
fbfd7f01fe Include jscpucfg.h or jsautocfg.h to determine endianness. Don't
rely on __LITTLE_ENDIAN or any other non-XP macros.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@46322 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-08 06:46:34 +00:00
fur%netscape.com
73f2660ed2 Sync w/ trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@45010 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 17:42:13 +00:00
fur%netscape.com
fee90a8957 Sync with trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@45009 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 17:40:00 +00:00
fur%netscape.com
6ec5dfc64d Merge changes from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@45007 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 17:31:41 +00:00
fur%netscape.com
a06b5c6b43 Backing out Patrick's change which could conceivably cause an incorrect
JSContext to be used when invoking n.j.JSObject methods from Java.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44986 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 06:33:08 +00:00
fur%netscape.com
355b53b5fe Add missing comma
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44985 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 06:31:09 +00:00
fur%netscape.com
5c64026eac Propagating BeOS change from trunk.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44984 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 06:30:48 +00:00
fur%netscape.com
7325e1c20f + Propagating Travis' LiveConnect changes from trunk
+ Eliminating Patrick Beard's changes which cause JS to execute using the JSContext
  used to create a JSObject.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44983 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 06:30:13 +00:00
fur%netscape.com
0bbdc94cc4 Propagate Travis' aggregation fixes from the trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44982 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-28 06:17:01 +00:00
rogerl%netscape.com
ec9253f786 Fixed \x handling for ecma 2 - must have a pair of hex digits.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44218 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-24 01:10:34 +00:00
rogerl%netscape.com
0500df149a Fixed bad math in calculating \<decimal digits>.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44186 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-24 00:35:14 +00:00
rogerl%netscape.com
de3fa77ffc Handling undefined and other wacky values for limit arg to .split
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44168 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-23 23:41:27 +00:00
rogerl%netscape.com
518d51a9ec Maintaining old \<digit> behaviour for compatibility.
Fixed bug in not resetting paren contents for failed optional sub
expression.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44167 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-23 23:16:30 +00:00
rogerl%netscape.com
fab904a686 Removed spurious commented-out line
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@44165 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-23 22:10:45 +00:00
rogerl%netscape.com
9ad512eeab Changed lastIndex to unsigned. Re-wrote \NNN handling for 1.5 spec.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41602 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-30 20:43:49 +00:00
rogerl%netscape.com
21fc1f7e73 Removed bytecode length. Changed lastIndex to unsigned.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41601 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-30 20:42:09 +00:00
rogerl%netscape.com
58ab95e611 New error messages for regexp.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41600 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-30 20:41:35 +00:00
brendan%mozilla.org
c3f008663a Fix warnings reported at http://tinderbox.mozilla.org/SeaMonkey/warnings.html, mostly unsigned/signed bothers.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41566 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-30 00:46:36 +00:00
rogerl%netscape.com
9fa3c9698f Fixed bug for setting prototype property of closure object - wasn't getting
through to constructor.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41174 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-26 23:43:23 +00:00
rogerl%netscape.com
9769518cba jsexn.c - fixed compile errors for building errors-as-exceptions code
jsinterp.c - fixed not releasing lock for property for 'in' operator
jsregexp.c - formatting changes. Fixed quantifier off-by-one and null
termination in character class bugs. Allow empty character class.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@41172 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-26 23:24:56 +00:00
brendan%mozilla.org
e2231f6a3a Eliminate warning about unsigned/signed == comparison.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@40868 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-23 08:25:03 +00:00
brendan%mozilla.org
f598b3e021 Add new flag to js_DecompileValueGenerator calls.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@40867 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-23 08:23:13 +00:00
brendan%mozilla.org
e93ab2efac Bugs, bugs bugs:
- js_DecompileValueGenerator had rusted due to bytecode/source-note changes,
  or maybe parts of it never worked right.  Anyway, it now does not induce a
  crashing underflow in the decompiler.  As part of this fix, it now takes a
  checkStack flag telling whether to look for the jsval v argument on the JS
  stack.  The calls from ImportProperty, js_SetProperty, and js_DeleteProperty
  pass in v a jsval for the property id, which should not be sought after on
  the stack (it might happen to be there due to o['p'] = 2, but we want to
  decompile o["p"], not "p").
- js_DecompileValueGenerator would load a generating pc even if the value v
  did not match the pc's corresponding stack item!  Oops.  This lead to less
  than idea diagnostics.
- js_DecompileValueGenerator was also not mapping JSOP_TRAP to the real op at
  a sufficiently early and univeral point in its control flow.
- Fix PopOff to assert and check for stack underflow in the decompiler, and
  beef up PushOff too (it asserted, but did not check).
- js_ReportIsNotFunction now avoids JS_InternString by indexing directly into
  cx->runtime->atomState.typeAtoms with the result of JS_TypeOfValue.
- Removed unnecessary local GC root reserved by non-zero trailing member of
  obj_eval's JSFunctionSpec initializer.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@40866 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-23 08:14:42 +00:00
mccabe%netscape.com
79938c01fa Fix warnings flagged by the auto-warnings page http://tinderbox.mozilla.org/SeaMonkey/warnings.html . Thanks slamm.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@40656 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-22 10:37:35 +00:00
mccabe%netscape.com
1859233a0b Changes to support building on Alpha NT.
Patches courtesy bob meader <bob@guiduck.com> who seems to be working fast and furious on this port.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@40596 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-22 04:11:11 +00:00
mccabe%netscape.com
28c740b405 Propagate fixes from the tip.
jsdtoa.c 3.2 -> 3.3: Handle ARM endian-ness

jsdate.c 3.18 -> 3.19: Don't clamp date in new Date(year, month, date) to 1 on date < 1.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@39777 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-16 22:43:21 +00:00
brendan%mozilla.org
2156d2be56 Warning abatement.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@39486 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-15 02:47:06 +00:00
brendan%mozilla.org
a3fdd6235d - Fix for..in bug where ECMA 12.6.3 steps 5 and 6 are reversed: the effect was
to define an unbound global variable used to enumerate an empty object, when
  the standard says no variable should be defined.
- Clean up minor nits, make comment style match prevailing, tighten up for..in
  element-indexing special case comments.
- Fix js_Invoke to take CONSTRUCT and INTERNAL flags arg instead of a construct
  boolean arg and the JSStackFrame internalCall mis-located boolean non-arg.
  Use these flags correctly in all calls (previous version failed to set the
  bogus frame.internalCall around js_Invoke calls from jsfun.c and jsstr.c).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@39476 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-15 02:29:34 +00:00
brendan%mozilla.org
44e6c3dc85 Sync with trunk rev 3.23.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@39249 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-14 09:59:39 +00:00
brendan%mozilla.org
e8616bb5ed Rip out assign hack, simplify boolean value synthesis, minor cleanups.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37627 18797224-902f-48f8-a5cc-f745e15eee43
1999-07-01 02:25:47 +00:00
brendan%netscape.com
4facd47a6e - Add (jsatomid) cast to GET_ATOM_INDEX to abate warnings.
- Fix js_GetAtom fallibility by returning &dummy on assert-botch "can't happen"
  index out of range case.
- js_InitAtomMap needn't bother nulling ale->next with tmp save
- js_InitAtomState explicit tail fusion for FROB via goto bad, and early memset
  (I know, JSRuntime is cleared already and it contains the atom state ... but
  jsatom.c doesn't know that).
- Clear all ATOM_ flags save ATOM_PINNED when creating a new atom.
- Cleanup xtra, ALIGNNUM, etc. useless variables, use JSVAL_ALIGN and JS_MAX.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37314 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-29 02:20:48 +00:00
brendan%netscape.com
f53b9bf184 Final part of 8042 fix: always initialize frame.internalCall.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37295 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-29 00:22:22 +00:00
brendan%netscape.com
84c04e6a6d Forgot externs before JS_PUBLIC_API calls for ArgumentFormatter functions.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37294 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-29 00:21:38 +00:00
brendan%netscape.com
fe10d5d381 OK, final fix not to impute JS_ARGUMENT_FORMATTER_DEFINED from va_start (duh).
Despite my stupidity here, I must say that over-includers elsewhere of both
jspubtd.h and jsapi.h, and even jscntxt.h, with system headers intermixed, suck
a lot too.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37160 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-28 04:51:23 +00:00
brendan%netscape.com
789e71d9af Shoot me now.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37159 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-28 04:37:10 +00:00
brendan%netscape.com
9321d6682b *Clone* JSArgumentFormatter typedef from jspubtd.h to jsapi.h to cope with bad
includers who grab jspubtd.h first, then stdarg.h, then jsapi.h.  Suckage.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37158 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-28 04:06:30 +00:00
brendan%netscape.com
9fe2aa2ca2 Added custom JS_{Convert,Push}Arguments{,VA} formatter function support for
use by XPConnect and other clients.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@37156 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-28 03:15:25 +00:00
brendan%netscape.com
04ddf77eef Remove gratuitous include of <string.h>.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36987 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-26 03:32:46 +00:00
brendan%netscape.com
09729fd690 - Rename js_CallFunctionValue to js_InternalCall to distinguish it from all
"external" calls compiled from scripts, which have stack budget depth slots
  under the return value slot for the call expression's generating pc.
- New internalCall packed boolean flag in JSStackFrame to distinguish callers
  of js_InternalCall so the generating pc isn't mistakenly stored depth slots
  below stack space allocated on-the-fly for internal call args/rval.
- Fixed bugzilla bug 8042, finally by storing the call expression's generating
  pc -- but only for external calls.
- Whitespace policing, gratuitous parenthesization reduction, etc.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36986 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-26 03:31:15 +00:00
brendan%netscape.com
c79334436c Eliminate assignment in condition.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36983 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-26 03:01:14 +00:00
fur%netscape.com
046ce3b5dc Merged Patrick's OJI-specific changes from the trunk. They should not affect
standalone LiveConnect.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36674 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-24 05:19:04 +00:00
fur%netscape.com
a661ab5259 Eliminated -fullwarn compiler option as it is excessively noisy
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36672 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-24 04:06:03 +00:00
rogerl%netscape.com
826ba71ddb Added tree deletion to RegExp finalizer
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36618 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 21:57:23 +00:00
fur%netscape.com
9df8eca261 Removing shaver/brendan fix for #8042 since it's apparently buggy
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36577 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 19:43:07 +00:00
fur%netscape.com
8372413ff3 Add line-editor code from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36565 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 14:37:35 +00:00
fur%netscape.com
d42976d59d Enable EDITLINE support
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36564 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 14:26:02 +00:00
fur%netscape.com
d24eb0c782 Fixed potentially dangerous expression, vp[-fp->script->depth]
Here, an unary minus was applied to unsigned integer value, with an
unsigned result.  On machines where pointers are 64 bits and integers are
32-bits, this will not have the intended result.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36545 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:26:37 +00:00
fur%netscape.com
0335741901 Include jsosdep.h for JS_HAS_LONG_LONG flag
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36544 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:18:56 +00:00
fur%netscape.com
48e66b0e7f use OBJ_THIS_OBJECT in SPROP_[GS]ET to make with(native_obj) work correctly
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36543 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:17:19 +00:00
fur%netscape.com
08defea6d7 From briano:
Fix for QNX, and any other platform that doesn't have memory.h


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36542 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:15:32 +00:00
fur%netscape.com
975e0e362a fix CHECK_BRANCH fencepost
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36540 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:05:13 +00:00
fur%netscape.com
33a2edccfc Propagate changes from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36539 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 08:03:39 +00:00
fur%netscape.com
26aaa4202d Merge shaver's NO_STATIC_LIB change from the trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36533 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:36:52 +00:00
fur%netscape.com
6e4d5d85f1 Briano's changes from the trunk:
Rename 'huge' to 'really_large' since the former is a compiler keyword on QNX.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36532 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:35:56 +00:00
fur%netscape.com
0abe8629bb Propagate SCO change from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36531 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:24:50 +00:00
fur%netscape.com
16cc9dc3a9 Propogate EDITLINE changes from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36530 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:22:18 +00:00
fur%netscape.com
0205e1b7b9 Merging Brendan's changes from thetrunk:
- "varargs" counterpart to JS_ConvertArguments, JS_ConvertArgumentsVA.
- JS_PushArguments{,VA} and JS_PopArguments to convert a list of C/C++ values
  passed as actual arguments into an 'jsval *argv' on the JS stack.
- Clean up and robustify ConvertArgs test command in the js shell.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36527 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:17:17 +00:00
shaver%netscape.com
c0800e4292 fix 8042 (decompile function-return-value better)
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36526 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:12:46 +00:00
fur%netscape.com
44f6440277 Sync up with trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36525 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 07:08:15 +00:00
fur%netscape.com
ac0b428d56 Merge Brendan's changes from the trunk:
- "varargs" counterpart to JS_ConvertArguments, JS_ConvertArgumentsVA.
- JS_PushArguments{,VA} and JS_PopArguments to convert a list of C/C++ values
  passed as actual arguments into an 'jsval *argv' on the JS stack.
- Clean up and robustify ConvertArgs test command in the js shell.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36522 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-23 06:42:37 +00:00
fur%netscape.com
e0e6bba682 Restored LXR magic span tags. Also, made numerous minor tweaks and updated
Build section to match current behavior.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36377 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-22 22:41:37 +00:00
fur%netscape.com
bebb6591d0 For backwards-compatibility, restore original API behavior so that
JS_DestroyContext() forces a garbage collection.  Added the new
JS_DestroyContextNoGC() when implicit GC is undesirable.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@36259 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-22 06:53:50 +00:00
bjorn%netscape.com
3c1a81432a This checkin fixes two problems.
1. The cleanup code for returning a fat lock to the pool was moved
into js_SuspendThread, to make it symmetric with its allocation.
2. There is now a vector of global locks, each with an associated free list
of fat locks. By vectorizing the global locks, we decrease the contention.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35881 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-18 22:37:39 +00:00
fur%netscape.com
164e644851 Real fix for bug fixed in last check-in
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35746 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-16 23:32:08 +00:00
fur%netscape.com
e28f099ddb If two threads race for reflecting a single Java object in to JS and entering it into
the java_obj_reflections hash table, the losing thread leaves behind a JSObject
(a wrapper around a Java object) that is GC'ed sometime later.  There was a problem
in that the orphaned JSObject still contained a reference to the Java object it
was supposed to wrap, hence causing a possibly failed attempt by the finalizer to
remove it from the hash table.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35724 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-16 19:22:26 +00:00
mccabe%netscape.com
ee5a76d98b Propagating a fix that made it into the tip, 05/04/99 00:12, v. 3.3.
Fix to 5301. Revert from using fd_copysign from the libmath emulation library to using the system copysign.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35557 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-16 00:07:53 +00:00
rogerl%netscape.com
9a49b757fb Bug #7635. instanceof chain walk now starts with object prototype.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35515 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-15 23:27:46 +00:00
fur%netscape.com
6b926e4950 Forgot to release java_obj_reflections_monitor for one control path
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35464 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-15 23:00:23 +00:00
fur%netscape.com
5019a3c5b9 When trying to associate an error report with some code, walk the stack until we
find a caller frame that is associated with some script rather than native code.
Otherwise, some errors don't get file/line-number info.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35455 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-15 19:03:13 +00:00
fur%netscape.com
9ac73e3124 Fixed bug in method overloading resolution that would sometimes result in
resolution to an inappropriate method when java.lang.String arguments are
involved.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35453 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-15 18:32:00 +00:00
fur%netscape.com
20bf98292d There's a bug in JDK1.1 such that exceptions in constructors
do not get propagated to JNI callers, i.e. ExceptionOccurred()
returns NULL.  For this case, make up a JS error string and
throw that as the exception instead.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@35452 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-15 18:29:54 +00:00
fur%netscape.com
a1adcfd4c6 Fix #7771: Crash when Array.prototype.sort() applied to a JavaArray
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34948 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-12 01:14:08 +00:00
fur%netscape.com
cd06317d05 Fix #7771: Crash when Array.prototype.sort() applied to a JavaArray
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34947 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-12 01:13:42 +00:00
jband%netscape.com
a9cc2970c0 fix for bug 7698. Have the prop state object call the right object when doing the JSENUMERATE_DESTROY and make sure that the object does not get gc'd first
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34829 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-11 19:19:22 +00:00
fur%netscape.com
c01031dcb2 Fix non-threadsafe compile
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34805 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-11 18:47:54 +00:00
fur%netscape.com
da31d13ec5 Fix BugSplat #354877:
The code to prevent infinite recursions when reflecting Java class members
was malfunctioning in multithreaded environments because the reflection
code had only two states: "no members reflected yet" and
"member reflection complete".  I added a third state:
"member reflection in progress", which is used only to inhibit infinite
recursion.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34735 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-11 02:14:10 +00:00
fur%netscape.com
e1b0908632 Fix #354852: Release java_obj_reflection_monitor before doing an allocation that
could result in a GC.  Otherwise, we might deadlock.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34728 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-11 01:07:18 +00:00
rogerl%netscape.com
dd9145fcf5 Fix bug #7625, num_toString for negative numbers with base != 10.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34517 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-10 00:28:56 +00:00
jband%netscape.com
27454bc38d removing unused file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34253 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-08 21:05:19 +00:00
fur%netscape.com
cb18b19c46 + Fixed thread_list corruption bug
+ Assert-botch when attempting to detach a thread from LiveConnect that
  has already been detached.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34180 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-08 05:22:31 +00:00
taek%netscape.com
a38a6bc16c forgot to force native threads
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34158 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-08 02:06:28 +00:00
taek%netscape.com
ac15592e5f Changes from Christian Kaiser to support Linux 2.2 builds
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34112 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-07 22:44:16 +00:00
taek%netscape.com
9804662800 Changes per Christian Kaiser for Linux 2.2
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@34111 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-07 22:43:39 +00:00
jband%netscape.com
65d80b8466 make js_AllocStack, js_FreeStack, and js_Invoke, FRIEND functions so that they can be used by our good friend xpconnect.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33594 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-03 21:39:08 +00:00
rogerl%netscape.com
965c11842c Blew off 'caller' property - it was deemed a security risk, bug #7224
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33432 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-02 20:15:17 +00:00
rogerl%netscape.com
0a495234b4 Need to allow quantifier with no max specified.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33430 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-02 18:33:58 +00:00
fur%netscape.com
887a21a0e7 + Doh ! Fix awful misspelling of JSJ_THREADSAFE
+ Clear up race condition in find_jsjava_thread()


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33380 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-02 01:08:27 +00:00
fur%netscape.com
efca1506bd Doh ! Fix awful misspelling of JSJ_THREADSAFE
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33379 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-02 01:07:32 +00:00
fur%netscape.com
91158a94cb Eliminate C++ comments
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33327 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-01 18:30:32 +00:00
taek%netscape.com
ae2cc93515 Changing the location of JDK since not locally installed for Linux 2.2
on shabadoo


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33076 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-28 01:21:03 +00:00
rogerl%netscape.com
c270ae3981 have to hold and then free the string passed to the error reporter - it
can't do that for us.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33064 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-28 00:47:52 +00:00
rogerl%netscape.com
6f4eb491de Free other error report message pieces, too.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@33063 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-28 00:46:46 +00:00
rogerl%netscape.com
c707508714 Bug #6359 and other changes motivated by Waldemar's definition.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@32757 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-26 22:27:08 +00:00
rogerl%netscape.com
f58d6c411b Removed 'scopeChain != parent' test for swallowing the function name for
nested functions, this allows :

s = "print('typeof g = ' + typeof g); \n function g()";
function t(p)
{
	eval(p);
}

The function definition was not being seen by the typeof.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@32748 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-26 22:13:25 +00:00
fur%netscape.com
dcc66fb3a0 The JSContext associated with a Java thread should not be cleared until the
outermost return from Java back into JS.  The code changes to fix this
bug are very pervasive, but it was mostly a matter of replicating similar
code in a large number of places.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@32472 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-21 21:20:27 +00:00
fur%netscape.com
c6d8fdb4a1 Optimization to avoid excessive condition variable notifications in JS_EndRequest().
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@32389 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-20 08:04:15 +00:00
fur%netscape.com
b4a66cfc99 JS_SuspendRequest() => JS_EndRequest()
JS_ResumeRequest() => JS_BeginRequest()


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@32388 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-20 08:00:23 +00:00
rogerl%netscape.com
f2ddafa75e Removed useless param for matchNonGreedyKid - don't need to re-run the paren
kids since we stop at the minimal case


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31493 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 23:05:30 +00:00
rogerl%netscape.com
fffea903d8 Fixed C++ stye comments, other warnings from IRIX build.
Also removed setting of bitmap[0] to missing.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31474 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 22:20:22 +00:00
fur%netscape.com
c009b8e4da Fix #352034: Anonymous function literal crashes XDR script thaw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31437 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 18:56:52 +00:00
fur%netscape.com
953180821d Fix #359178:
Sandwich calls to from JS to Java in JS_SuspendRequest()/JS_ResumeRequest()
pairs.  This prevents deadlock when the Java method being invoked causes
creation of another JS thread which then attempts a garbage collection.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31388 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 02:51:30 +00:00
fur%netscape.com
0bb2e88fe0 Part of fix for #351976:
Pass a JSRuntime to js_RemoveRoot() rather than a JSContext.  This is needed
during LiveConnect-associated Java finalization which can occur on a Java
thread which is not associated with any JSContext.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31374 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 02:14:07 +00:00
fur%netscape.com
d9d8155903 Fix #351976:
Allow Java finalization of wrapped JS objects *after* the JSContext
that was used to create the wrapper has been destroyed.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31370 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-13 02:10:48 +00:00
rogerl%netscape.com
64ed8f2b55 New regexp functionality merged from Dev_BRANCH
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31304 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 22:35:09 +00:00
mccabe%netscape.com
0ce684e959 Propagating fixes that made it into the tip.
- Add a jsclass flag to allow us to tell when an object native is an nsISupports.  (in this case, for integrating xpcom well with functions exposed through idlc glue, but it could prove useful in the future.

- Fix to jsscan.c to properly hand the case where \r\r ends a buffer or segment without it resulting in reads past the end of the buffer.  Fix to bugzilla bug 5947.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@31266 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-12 07:48:45 +00:00
(no author)
986d13c1f7 This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@30886 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-09 10:22:41 +00:00
fur%netscape.com
0aa6a5db5e Fix for Bug #351492. Crash when serializing large strings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@30622 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-07 00:26:44 +00:00
fur%netscape.com
e0d15ea7d9 Add -taso option when building lcshell
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@30407 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-05 19:50:51 +00:00
fur%netscape.com
4ac9dc131d Clean up OSF1 warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@30406 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-05 19:40:24 +00:00
fur%netscape.com
b7535ac0ea Fix NULL-pointer crashes
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@30404 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-05 19:35:53 +00:00
fur%netscape.com
12657eb0fb Don't force a GC every time a JSContext is destroyed
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@29737 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-28 18:26:13 +00:00
fur%netscape.com
b7933c7e32 Copied from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@29417 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-27 06:41:33 +00:00
fur%netscape.com
41de941212 Merged in a bunch of minor changes from the trunk. These changes
should never have been put into the trunk without also putting them
into the branch, but some people are stupider than others.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@29416 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-27 06:41:08 +00:00
fur%netscape.com
14a9d9707a Ensure that Java strings are NUL-terminated when passed to JS
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@29387 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-27 04:45:57 +00:00
fur%netscape.com
a681ff5887 Fix for 350323 - Deserialized strings ought to be NUL-terminated
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@29385 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-27 04:42:36 +00:00
fur%netscape.com
a93b32c92a Remove code that indirectly causes assert-botch on shutdown
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@28785 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-23 02:49:20 +00:00
fur%netscape.com
5cac420f14 Set DEFINES/INCLUDES correctly for thread-safe LiveConnect
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@28783 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-23 02:21:41 +00:00
fur%netscape.com
8004e1197e Fix some JSJ_THREADSAFE bit-rot
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@28782 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-23 02:19:58 +00:00
fur%netscape.com
f3363cc91e Merge in OJI bug fixes and sync up w/ trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@28029 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-19 05:13:43 +00:00
bjorn%netscape.com
9230455c06 Fixed a nasty race condition in js_Enqueue. Now, I've resorted to using
an array of global locks for protecting the suspending and resuming of
threads. The old scheme used busy waiting using atomic set, which was
no good. The change in jsapi.c and jslock.h comes from adding an argument
to js_SetupLocks (the new argument sets the size of the global lock array).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@27948 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-16 23:26:37 +00:00
mccabe%netscape.com
3960dc9ee5 Backwards-compatible versioned behavior for getYear(), for legacy scripts.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@27543 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-15 04:16:15 +00:00
(no author)
0c0ec2821c This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@27150 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-12 08:57:07 +00:00
taek%netscape.com
f1e069a0b5 Changes to support AIX4.2 per Anthony Moore
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26816 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-08 19:07:31 +00:00
taek%netscape.com
99bb12444a changes to support AIX 4.2 per Anthony Moore
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26815 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-08 19:06:18 +00:00
norris%netscape.com
767898db6f Back out rogerl's latest changes to regexps. Will wait till later
to hit the tip with them.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26631 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-07 00:31:14 +00:00
fur%netscape.com
3c8b7655d6 JS_DestroyContext() should implicitly call JS_EndRequest(), rather than
forcing the caller to call JS_EndRequest() before JS_DestroyContext().  The
latter leads to a race condition in which it's possible for another thread
to enter the garbage collector while context destruction is in progress.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26485 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-06 18:25:47 +00:00
rogerl%netscape.com
29e83f3f00 Fix Mac errors/warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26480 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-06 18:13:06 +00:00
norris%netscape.com
f58c655e5f Merge changes from SpiderMonkeyDev_BRANCH. This will obsolete that branch.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26399 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-06 01:28:03 +00:00
fur%netscape.com
cbd36689b8 Fixed a race condition in which two threads added the same identifier to
the atom table at about the same time.  Before this fix, double-freeing
of the atom identifier was a possibility.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26134 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-03 01:58:51 +00:00
jband%netscape.com
0c9f1faa8f js_DefaultValue now accepts that it is OK for a request with hint of JSTYPE_OBJECT to result in an object of type JSTYPE_FUNCTION. This is done so that objects that happen to have 'call' ops will not fail when being 'converted' to 'Object'. This Fix is going onto the trunk, SpiderMonkeyDev_BRANCH, and SpiderMonkey140_BRANCH
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@26104 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-02 23:17:14 +00:00
bjorn%netscape.com
11577bea97 Fixed js_SuspendThread and js_ResumeThread to restore busy flag
before returning.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@25234 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-26 21:57:24 +00:00
norris%netscape.com
8b21f213f2 Propagate fixes from SpiderMonkeyDev_BRANCH
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@25113 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-25 19:41:58 +00:00
mccabe%netscape.com
85b9e9e338 Removed support for the JSFILE define. Not to be confused with the
'jsfile' js file object, the JSFINE define conditionally compiled
support for allowing the javascript scanner to read from filehandles.
We've decided that it's more annoying to support not supporting that
feature, so we enable it all of the time.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@25055 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-25 03:54:21 +00:00
wynholds%netscape.com
4d44d44aa6 new way to create shared libs on AIX 4.2 -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@25009 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-24 23:00:00 +00:00
wynholds%netscape.com
cb143c735d not setting optimized to -O all the time. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@25008 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-24 22:46:17 +00:00
wynholds%netscape.com
67ac0c53b7 adding new flags for vishy. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24853 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 17:56:33 +00:00
fur%netscape.com
40537730db Fix for Bugzilla #1282: When traversing GC roots, check to make sure that
the root is a pointer and not a JS scalar, such as a boolean or null.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24849 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 17:22:57 +00:00
fur%netscape.com
73f07616ca Mac warning fixes from Kathy Brade
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24802 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 06:46:09 +00:00
mccabe%netscape.com
e37c6c58e4 Fix to bugzilla bug 4088; fixed javascript Date string parsing to
handle 12:30 AM and 12:30 PM properly.

(Previously, the code just added 12 hours whenever it saw PM.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24779 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 02:48:01 +00:00
rogerl%netscape.com
cfefdf035b First stab at fixing use of \0 as search string terminator.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24391 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-19 01:17:11 +00:00
mccabe%netscape.com
26b643e9cf Fixed broken C apis js_DateGetYear, etc. to deal correctly with invalid dates. (They previously returned (int) <the date value> which gave MIN_INT for invalid (NaN) dates - a departure from the previous behavior of returning 0.)
Added js_DateIsValid api to detect invalid dates.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24362 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-18 23:09:19 +00:00
wynholds%netscape.com
0ed5bbeda3 putting the name of js14lc30.jar in a central place. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24340 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-18 21:40:47 +00:00
wynholds%netscape.com
d22fe3ce0b now building full (debug linked with msvcrt.dll) and idgfull (debug linked with msvcrtd.dll) -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@24189 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-16 00:06:02 +00:00
rogerl%netscape.com
0bcfd5c015 When allowing find_split to bump-along past the end of the string, return
-1 as the result (except for 1.2 compatibility). This handles :

"hi".split(new RegExp())

which should return a 2 entry array

["h", "i"]

but had been returning an empty third entry because find_split wanted to
allow it's caller the opportunity to handle end-of-string conditions.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23995 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-12 22:53:02 +00:00
rogerl%netscape.com
11d157cd32 Remove // comment.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23949 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-12 18:14:37 +00:00
wynholds%netscape.com
ed256cba9a NSPR 3.1beta -> 3.1 -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23648 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-11 01:46:20 +00:00
rogerl%netscape.com
afea1b0d6d Oops, left in a debug flag.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23601 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-10 22:59:32 +00:00
rogerl%netscape.com
465e3db54a Changed parser to allow \0 by testing for end-of-string pointer instead of
null termination. This may need to settle down a little. (Bug #344852)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23436 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-10 01:13:06 +00:00
rogerl%netscape.com
3ebdcb2f29 enum value for FORELEM2 was missing the to-string convert after previous
bug fix for indexing enumerator. Bug #344855


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@23367 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-09 21:36:13 +00:00
brendan%netscape.com
a198deb328 Avoid dangling else (egcs warns about it) and else-after-return.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22548 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-02 08:27:59 +00:00
brendan%netscape.com
ad167c6106 - Added 'W' format to JS_ConvertArguments, for conversion to string and return
via a jschar* out parameter.
- Fused common string conversion and argv[i] GC-rooting code in JS_ConvertArgs.
- Added to cvtargs test command, which really needs to stop using a hardwired
  format string!
- Fixed char-typed fgetc-receiving variable to be of int type for correct EOF
  comparison on machines with unsigned chars.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22509 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-02 02:38:45 +00:00
wynholds%netscape.com
6cc77db7b6 need to add the jar path for the class files. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22235 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 23:04:36 +00:00
wynholds%netscape.com
c8d1223362 making depedency checking work on java files. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22232 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 22:56:50 +00:00
wynholds%netscape.com
f0c9781f09 gotta point to the jar executable. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22116 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 16:45:13 +00:00
wynholds%netscape.com
3f3ecbc08a getting NT to build java classes. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22018 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 02:02:25 +00:00
wynholds%netscape.com
6b9bdfec42 adding java classes to build and putting jar file in distribution. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@22013 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 01:28:53 +00:00
rogerl%netscape.com
b5361f54b7 Moved anchoring from EOL and into mainstream, fixed some weird edge case
behaviours from BOL and EOL.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21778 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-24 19:21:42 +00:00
wynholds%netscape.com
31431e4dcd i guess we are staying with ld for linking. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21661 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-23 23:51:12 +00:00
wynholds%netscape.com
3c0b753eb3 using NT version of NSPR now, not 95 version. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21660 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-23 23:48:15 +00:00
wynholds%netscape.com
6c4639603b getting things inline with ES4.0. hope MS likes this, too. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21655 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-23 22:10:11 +00:00
fur%netscape.com
6135a00aba Get rid of useless platform ifdef tests
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21649 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-23 20:20:36 +00:00
wynholds%netscape.com
7e021bc7b6 nspr lib is now nspr3.lib on NT, not libnspr3.lib. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21344 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-19 22:20:16 +00:00
wynholds%netscape.com
e72e613ee4 changes to nspr 3.1beta -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21340 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-19 21:44:01 +00:00
wynholds%netscape.com
0f8ee32b40 more name things. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21335 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-19 21:28:47 +00:00
wynholds%netscape.com
d469ea9fb0 fixes for 3.1 beta NSPR drop. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21334 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-19 21:25:22 +00:00
wynholds%netscape.com
6563f56749 going to nspr 3.1beta -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21268 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-19 03:02:24 +00:00
wynholds%netscape.com
7cfa27ae3e new name for jsj. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21145 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-18 16:34:50 +00:00
jband%netscape.com
df2143dd3e changed MAP_IS_NATIVE to allow for objects that have their own jsObjectOps but still use the slots in the 'normal' manner - same change as made on SpiderMonkeyDev_BRANCH
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21127 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-18 04:58:46 +00:00
fur%netscape.com
8f5eecd125 Build jsj.dll w/o linking to a specific Java DLL
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21089 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-18 02:02:16 +00:00
fur%netscape.com
f5bd095197 Really, this time: Don't put debug information in PDB files. Leave it in the
DLL's and OBJ's.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21082 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-18 01:04:11 +00:00
fur%netscape.com
bb573693da It's now possible to build the LiveConnect library without linking to a
particular Java library.  Now, the same jsj.dll can work with either JDK1.1
or JDK1.2.  Note that the LC shell must still link with Java.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21081 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-18 01:03:25 +00:00
fur%netscape.com
6b0ec81b7d Don't create PDB file when linking
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21040 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 23:20:45 +00:00
brendan%netscape.com
a298bbdd7a QuoteString must escape backslash (duh; thanks to mccabe).
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@21029 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 22:36:49 +00:00
wynholds%netscape.com
4704eaa6b0 adding support for IRIX 6.5 n32. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20855 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 02:20:08 +00:00
wynholds%netscape.com
27b2b41087 adding file for IRIX 6.5. for now, the same as 6.2 and 6.3 -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20843 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 01:38:51 +00:00
wynholds%netscape.com
5482ed1dd6 only add jsautocfg.h to HFILES if it is not prebuilt. but if it is, where is it?
-mw


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20603 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 19:19:01 +00:00
wynholds%netscape.com
18990eae9f adding jsautocfg.h to package. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20593 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 18:56:35 +00:00
wynholds%netscape.com
98fed0e388 1) HP shared libraries use .sl now (not .so)
2) liveconnect libraries called libjsj now (not jsj)
-mw


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20501 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 02:25:28 +00:00
wynholds%netscape.com
05b3c1feba now packaging all .h, .tbl, and .msg files in include directory. also including static libraries in lib directory. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20496 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 01:57:59 +00:00
wynholds%netscape.com
763a52754a not including libnspr anymore. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20446 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 23:07:34 +00:00
shaver%netscape.com
869b786447 fix leaking of object lock count during XDR function decode
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@20111 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-09 05:08:40 +00:00
wynholds%netscape.com
877ec80ac9 fixing linux NSPR-getting problem. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@19857 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-05 16:39:04 +00:00
shaver%netscape.com
2d4fb99438 XDR should know about exceptions, and should also correctly handle source notes
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@19467 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-03 17:32:36 +00:00
wynholds%netscape.com
8937da7e07 NSPR_VERSION 19980120 -> v3.0 -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@19366 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-02 20:09:04 +00:00
brendan%netscape.com
c1ae1240f0 - Fix egregious bug: missing 0 terminator at end of js_EscapeMap.
- Fix QuoteString so it doesn't stop on an embedded \u0000 in its input string.
- Add some comments to QuoteString.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@19073 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-30 01:42:33 +00:00
fur%netscape.com
39978272c7 Build with debug information embedded inside DLL instead of separate .pdb file.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@18915 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-28 07:43:22 +00:00
rogerl%netscape.com
e35e5fc1a2 Bug #331783 - separate initialization from increment for 'for in' loop
with index expression in order to prevent side-effects from occuring
when the for loop stops (as in 'for (p[i++] in obj)...')


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@18831 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-28 00:07:24 +00:00
rogerl%netscape.com
72970118bb Forgive EOLONLY from having to be anchored as it handles it itself.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@18040 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-19 23:49:07 +00:00
rogerl%netscape.com
0b8141bb35 Merged bug fixes back from Dev branch :
- /|a/ was interpreted as literal
- {} didn't back-track
- NONxxx opcodes didn't handle end of string
- NCCLASS allowed end of string
- /(a*)/ didn't have ANCHOR opcode


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@18024 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-19 20:15:47 +00:00
rogerl%netscape.com
cf6032ba80 Changed GrowBuffer to double the existing length of the token buffer instead
of growing linearally. This helps for really, really big string literals.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@17910 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-16 02:51:11 +00:00
brendan%netscape.com
f4d17774f7 Fix anchoring and multiline bol-matching to handle empty match at end (mozilla bug 2157).
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@17210 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-06 00:38:00 +00:00
fur%netscape.com
fbdad4090a Use new -n32 ABI instead of old, -32 one
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16629 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-18 02:20:19 +00:00
shaver%netscape.com
2a051d9305 fix up AddRoot handling
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16572 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-17 16:23:56 +00:00
rogerl%netscape.com
49a03a8d3a Fixes for wide chars, debugging output + handling ucflats in alternates.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16358 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-14 19:31:46 +00:00
rogerl%netscape.com
e8c1dbab30 Moving into release branch - no line number for not a function error
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16357 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-14 19:22:50 +00:00
rogerl%netscape.com
134056767c Moving fix into release branch - bug #336744, decompile of function
containing eval


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16356 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-14 19:20:20 +00:00
fur%netscape.com
5d4f73f8d9 Minor changes to exception-handling code:
+ Cleanup unused variables
  + Fix use of uninitialized variable class_descriptor
  + Fix release of reference to java_class.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16075 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-09 19:25:45 +00:00
coop%netscape.com
2c0f27d985 Added support for "throw null". Surfaced GC problem.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@16059 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-09 16:56:34 +00:00
coop%netscape.com
440708a434 Replace superfluous do_report code with call to jsj_ReportError.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15962 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-08 04:04:15 +00:00
coop%netscape.com
adb1a82ea5 Removed case for JSTYPE_LIMIT and added special case for JSTYPE_VOID.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15943 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-08 00:21:03 +00:00
coop%netscape.com
a7d94f9340 Get proper class descriptor from java_obj in vreport_java_error - allows for
proper unwrapping of exceptions held in JSException objects.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15788 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-04 17:30:41 +00:00
coop%netscape.com
a99d73f83f Trimmed exception code.
Replaced comment reference to JSTYPE_LIMIT.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15644 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-02 20:05:32 +00:00
fur%netscape.com
8b62670504 Added JavaClass constructor, which takes an instance of java.lang.Class as
an argument and returns the corresponding JavaClass object.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15615 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-02 03:59:41 +00:00
fur%netscape.com
ca76e82e7a Compiler-generated file shouldn't be checked in
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15502 18797224-902f-48f8-a5cc-f745e15eee43
1998-12-01 04:23:35 +00:00
wynholds%netscape.com
e53f7bebb4 getting rid of nsinstall-target dependency. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15210 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-24 00:58:33 +00:00
fur%netscape.com
e3f7dcc298 JRI not used anymore
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15143 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-23 00:04:40 +00:00
fur%netscape.com
b2663eab6a Initialization of Java object->JSObject hash table was occurring in the wrong
place, resulting in new hash tables created for every JSContext.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15141 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-22 23:27:59 +00:00
fur%netscape.com
3afc15660d Added more paranoid DEBUG-only code.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15140 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-22 23:26:13 +00:00
fur%netscape.com
e4c99be06d Get rid of 16-bit resource definition file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15139 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-22 23:25:37 +00:00
fur%netscape.com
34d98661bc No more non-threadsafe JavaToJSSavedState struct
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15138 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-22 23:24:57 +00:00
fur%netscape.com
75d9ce90d0 Added OJI-include of prtypes.h, because OJI's version of jni.h depends on
HAVE_LONG_LONG.  (Why aren't we using the standard jni.h ?)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15114 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-21 23:28:20 +00:00
fur%netscape.com
c28d22e190 No longer needed
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15113 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-21 22:54:17 +00:00
fur%netscape.com
d763678802 JSException JNI header file is not needed.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15112 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-21 22:53:39 +00:00
fur%netscape.com
d2ec51db02 Changed some ifdef JSJ_THREADSAFE code back to JS_THREADSAFE, as it shouldn't
have changed in the first place.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15111 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-21 22:52:53 +00:00
fur%netscape.com
8118d76c54 Was out of sync with .java file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15110 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-21 21:49:33 +00:00
fur%netscape.com
1e545e45f4 + Fix the last few thread-safety nits.
+ Allow LiveConnect thread-safety to be turned off, even
  if JS_THREADSAFE is set (for OJI, which supplies their own thread-safety)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@15039 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-20 20:15:44 +00:00
fur%netscape.com
773987c3dc Fix bug #335589: Rounding should be done *before* out-of-range check
when converting JS number to Java integral type.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14969 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-20 00:16:40 +00:00
fur%netscape.com
0405c4e93f Fix #335449:
ECMA's [[DefaultValue]] operator is busted for functions & closures
  when hint != String


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14942 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-19 09:10:00 +00:00
fur%netscape.com
88ac0c1df0 Added explicit method overload resolution for Java constructors in addition
to the existing schemes for instance and static methods.  (Originally, this
was not going to be a feature of LC3, but cbegle demonstrated why it was
necessary.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14916 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-19 00:03:03 +00:00
fur%netscape.com
b3e84af06b Fix bug #335392. (Assert-botch when explicitly resolving a non-overloaded
static method.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14897 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-18 22:18:04 +00:00
fur%netscape.com
7aed5cdcb5 Merge changes from 9/20/98 OJI version of LiveConnect.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14886 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-18 20:37:30 +00:00
fur%netscape.com
90daf10163 *** empty log message ***
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14752 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-16 21:33:09 +00:00
fur%netscape.com
f5156071db Eliminate string=>boolean conversions
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14751 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-16 21:32:52 +00:00
(no author)
3f66410d0e This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14630 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-13 22:49:03 +00:00
fur%netscape.com
68da4b0d15 Conversion of JS NaN to any Java integral type now results in an error.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14496 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-12 04:55:38 +00:00
fur%netscape.com
b247b70b8f Eliminated the following as legal conversions:
JS null    ==> any Java primitive type
  JS number  ==> boolean
  JavaObject ==> boolean
  JavaArray  ==> boolean


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14495 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-12 04:54:57 +00:00
fur%netscape.com
61a8633ee5 Changed the rules for LC3 conversion from JS undefined to be more like LC1 and
less like LC2.  To wit, converting from JS undefined to any Java value except
a java.lang.String results in an error.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14493 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-12 03:35:37 +00:00
fur%netscape.com
195415f91a Fix possible use before set
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14492 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-12 03:33:53 +00:00
fur%netscape.com
2245830eca Propagating fix to 333916 from SpiderMonkeyDev_BRANCH
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14410 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-11 04:20:03 +00:00
fur%netscape.com
226e7c6182 + Be aggressive about deleting local JNI references. (Theoretically, it
shouldn't be necessary to free such references, but otherwise they might
  only be collected if the JVM uses a conservative stack-scanning GC.)

+ Fix problem in which JavaClassDescriptor's were not being fully free'ed at
  shutdown.

+ Disabled ref-counting of JavaClassDescriptors.  It's relatively common
  to develop cycles in the graph of JavaClassDescriptors, which leads to
  unused JavaClassDescriptors.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14409 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-11 04:13:10 +00:00
fur%netscape.com
759f28cd80 Be aggressive about deleting local JNI references. (Theoretically, it
shouldn't be necessary to free such references, but otherwise they might
only be collected if the JVM uses a conservative stack-scanning GC.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14365 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 21:51:08 +00:00
coop%netscape.com
d34d20f735 Implemented changes to primitve type exception throwing as suggested by fur.
Namely:
- poke Java fields directly (native code) rather than with Java accessor methods
- handling of NULL as object
- proper use of class_descriptor


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14362 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 20:08:29 +00:00
fur%netscape.com
8d3b460728 + Be aggressive about deleting local JNI references. (Theoretically, it
shouldn't be necessary to free such references, but otherwise they might
  only be collected if the JVM uses a conservative stack-scanning GC.)
+ Don't propagate reported JS warnings as JSExceptions.
+ Don't propagate JS error reports that are the result of JS exceptions,
  since the originating exception will later be processed.
+ Touched up white-space, formatting, comments


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14357 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:24:36 +00:00
fur%netscape.com
e888619c62 Be aggressive about deleting local JNI references. (Theoretically, it
shouldn't be necessary to free such references, but otherwise they might
only be collected if the JVM uses a conservative stack-scanning GC.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14356 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:19:55 +00:00
fur%netscape.com
ccaa088be9 Renumbered to eliminate gap in numerical sequence. The gap was causing
the wrong error string to be displayed in some cases.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14354 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:09:32 +00:00
fur%netscape.com
02417b3d15 + Fixed leakage of fatal initialization error string
+ Cleaned up formatting, white-space, comments


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14353 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:09:18 +00:00
fur%netscape.com
e0cf93383f + Improved error message when failing to convert from a non-numeric JS
type to a numeric Java type
+ Be aggressive about deleting local JNI references.  (Theoretically, it
  shouldn't be necessary to free such references, but otherwise they might
  only be collected if the JVM uses a conservative stack-scanning GC.)
+ Eliminated 'ifdef LIVECONNECT_IMPROVEMENTS' code, since it was all unused
+ Cleaned up formatting, white-space, comments


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14352 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:08:46 +00:00
fur%netscape.com
93b52b4c6b Be aggressive about deleting local JNI references. (Theoretically, it
shouldn't be necessary to free such references, but otherwise they might
only be collected if the JVM uses a conservative stack-scanning GC.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14351 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:08:11 +00:00
fur%netscape.com
524971b786 + Eliminated undesirable tab characters
+ Free local JNI reference to Java class.  (Theoretically, it shouldn't be
  necessary to free such references, but otherwise they are only collected
  if the JVM uses a conservative stack-scanning GC.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14350 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:06:41 +00:00
fur%netscape.com
0feefb7733 Eliminated undesirable tab characters
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14349 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-10 18:06:16 +00:00
fur%netscape.com
df197a44ac Added note about dual-GC problem
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14254 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-08 02:01:55 +00:00
fur%netscape.com
2cc51c1051 Added new sections:
+ Table of Contents
  + Limitations/To-Do
  + Sample LiveConnect shell interactions

Updated sections:

  + Build instructions
  + Introduction
  + Compatibility


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14252 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-08 01:49:47 +00:00
fur%netscape.com
b8cb580424 1) Fixed bug when converting from java.lang.Boolean to JS boolean that
affected only JS1.2 and older (non-ECMA mode).

2) Conversion of JS underfined to Java boolean is now an error (previously
   converted to false).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14229 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-07 03:11:40 +00:00
coop%netscape.com
712ca7d5ca Added basic support for proper native type throwing/handling.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14195 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-06 15:18:41 +00:00
shaver%netscape.com
3dc5e3dd91 added new jsXPCOM stuff from bjorn
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14158 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-05 20:55:16 +00:00
mang%netscape.com
f140c0c81b Fixed path problems. Now works and stuff.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14029 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-04 02:01:56 +00:00
mang%netscape.com
52d6b91235 Recur into fdlibm directory.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14017 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 23:12:56 +00:00
mccabe%netscape.com
55dc58958a Propagate cls@seawood.org fix:
Removed some MKLINUX & MACLINUX ifdefs. Replace a couple with
(defined(linux) && defined(__powerpc__)).  Added glibc ifndefs to
strdup declarations.  Fixed problem with stderr under glibc 2.1.

Patch submitted by Tom Rini <trini@kernel.crashing.org>.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@14015 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 22:51:28 +00:00
mang%netscape.com
682df8db3e For autoconf.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13984 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 14:21:21 +00:00
mang%netscape.com
8ed39db9a8 Revved to match Makefile
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13983 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 14:08:14 +00:00
mang%netscape.com
33d0464867 More cruft removal.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13982 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 13:39:35 +00:00
mang%netscape.com
490b91850b Added dependency on jslibmath.h
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13981 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 13:30:38 +00:00
mang%netscape.com
25da940352 Don't build or link useless files.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13980 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 13:16:04 +00:00
mang%netscape.com
f0ca36ba7d Need the real ld. Available on most (all?) platforms.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13979 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 12:27:16 +00:00
mang%netscape.com
480dbe043f fdlibm makefile.win
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13978 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 12:02:26 +00:00
mang%netscape.com
19b9471938 fdlibm Makefile
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13973 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 09:35:31 +00:00
mang%netscape.com
68fe0d88b6 Statically link jsmath.o against libfdm.a so as to link in only those
math routines that are needed.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13952 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 05:57:54 +00:00
mang%netscape.com
a6fcbc6e38 Sometimes I forget that the whole world doesn't use GNU tools.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13950 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 05:45:11 +00:00
mang%netscape.com
a0f85cea3a Post release cleanup.
Removed unnecessary defines (fd_fmod will be used later).
Removal of unnecessary files in fdlibm to follow.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13947 18797224-902f-48f8-a5cc-f745e15eee43
1998-11-03 01:29:14 +00:00
fur%netscape.com
3f5735fcf7 Added more compiler build flags so that we use the correct libc DLL and optimization settings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13784 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-31 02:58:41 +00:00
mang%netscape.com
0ab0796234 Backed out use of fd_floor on IRIX. See bugsplat bug #332475.
IRIX system floor now fails this special case:
Infinity/Math.floor(-0) = Infinity  FAILED! expected: -Infinity


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13780 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-31 01:32:50 +00:00
jband%netscape.com
0e145d79c2 modified makefile and readme to more easily support tree structure in jsjava.jar
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13776 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-31 00:54:54 +00:00
jband%netscape.com
3e89c252c4 updated README
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13741 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-30 21:41:20 +00:00
jband%netscape.com
6e0204a004 improved comments
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13740 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-30 21:38:52 +00:00
shaver%netscape.com
4b9ed1baa8 allow additional flags to the linker, so we can specify soname and such; need variants for other Unix platforms, but do those later
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13728 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-30 18:09:50 +00:00
norris%netscape.com
b9f4c69e12 Update release string format.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13687 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 23:31:24 +00:00
bjorn%netscape.com
5f6a0b9c3a Patch which fixes a problem in the alignment code. I wasn't taking sizeof(JSString)
properly.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13683 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 22:38:41 +00:00
fur%netscape.com
f68735a6bb wtc sez': Get rid of use of obsolete NSPR20 build var.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13676 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 21:59:30 +00:00
fur%netscape.com
8616bd54f5 Removing obsolete file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13675 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 21:51:46 +00:00
fur%netscape.com
09e0785f68 Removing obsolete/unused files.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13674 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 21:50:22 +00:00
fur%netscape.com
dd8953010a Removed uses of obsolete NSPR20 build variable
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13673 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 21:43:17 +00:00
fur%netscape.com
a67d8ed2fe + Updated build directions for all platforms.
+ Added table of contents.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13663 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 20:00:58 +00:00
shaver%netscape.com
935f0e5ac8 need to poke the GC when hitting the cache on a set
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13645 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 03:55:53 +00:00
fur%netscape.com
97aa1f7699 Ignore generated files
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13643 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 02:15:23 +00:00
fur%netscape.com
f399e21216 Reporting of uncaught exceptions should occur when JS_HAS_EXCEPTIONS is set,
even if JS_HAS_ERROR_EXCEPTIONS is not.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13642 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 02:09:34 +00:00
coop%netscape.com
823cb6e29e Made constructor for wrappedException private and removed deprecation warning.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13638 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 00:43:38 +00:00
fur%netscape.com
84e135cd01 Restore build prosperity for Mac LiveConnect after ref/src merge.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13637 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 00:24:05 +00:00
fur%netscape.com
ac3516411a No real change: Reorganized a few .c files that had fallen out of their folder.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13636 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 00:23:02 +00:00
mang%netscape.com
db237360fa Added section for AIX, thus fixing several bugs.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13634 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 00:16:38 +00:00
fur%netscape.com
92e443d317 Restore Mac-specific Java file, lost in the ref/src transition
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13633 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-29 00:12:41 +00:00
rogerl%netscape.com
87c9e8ae4d Changed references to stdout and stderr to generic file handles so that all
output can be redirected to a file. This is needed for the mac where shell
redirection is not an option.
Added MAC_TEST_HACK that uses this redirection and also parses a text file
to build the argv/argc values.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13632 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 22:12:01 +00:00
fur%netscape.com
3fa38c1d6a Added a workaround for a bug in AIX JDK1.1.6 (See #331620), in which
static initializers are not run when a static field is referenced from
native code.  The problem does not manifest itself if the field is
accessed from Java code, so we first call some Java code to access
the fields of interest before attempting to read them from native code.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13621 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 20:22:22 +00:00
norris%netscape.com
ce487f127c Fix 331720 Continue to label in for..in doesn't work
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13612 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 20:13:50 +00:00
fur%netscape.com
cc1651828e We allow conversion from NaN numbers to Java integral types, but not when
the NaN is the result of conversion from a non-number, e.g. a string.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13609 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 17:59:10 +00:00
fur%netscape.com
22f7fd9b4a Fixed two related bugs in overloaded method resolution:
+ The precedence of java.lang.String was higher than it should have been
  + When an ambiguous method match was reported, the best-matching method
    was being left off the list.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13605 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 17:06:01 +00:00
mccabe%netscape.com
ad72e12927 Added proposed methods Object.prototype.hasOwnProperty,
Object.prototype.propertyIsEnumerable,
Object.prototype.isPrototypeOf... all turned off for v140 in
jsconfig.h.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13603 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 06:31:55 +00:00
fur%netscape.com
b6ada3318c Fix for #331634: Inability to invoke Java method when a method and field have
the same name.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13598 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 05:26:58 +00:00
bjorn%netscape.com
82ac5c4e2f Fixes for AIX and SunOS. AIX now compiles and runs in optimized mode as well,
and SunOS now compiles for common architecture when JS_THREADSAFE is not set.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13595 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 04:07:35 +00:00
wynholds%netscape.com
5430e4b688 for use with creating source jar file. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13586 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 02:25:31 +00:00
wynholds%netscape.com
33219cbcb1 adding shipSource target which will, yep, you guessed it, ship the source. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13582 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 02:03:45 +00:00
mang%netscape.com
e10c7eb54b Replace native exp on Linux opt build.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13578 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-28 00:39:25 +00:00
mang%netscape.com
70bd48b576 Math.toSource() == 'Math'
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13577 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 23:56:19 +00:00
bjorn%netscape.com
6bc17963c7 *** empty log message ***
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13576 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 23:53:01 +00:00
mang%netscape.com
168c0f6f50 Want to use some fdlibm functions but fdlibm broken on OSF1/alpha.
See bugsplat bugs 331500, 332038


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13572 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 23:07:40 +00:00
fur%netscape.com
eef72a91bc More LC3 features:
+ The __proto__ property of JavaObjects can be assigned and the
  prototype chain of these objects is searched, just as the engine's
  built-in js_ObjectOps routines do.  This is a featurette for the
  NGLayout DOM.

+ Static Java methods and fields can now be accessed via LiveConnect
  through an instance of a Java class, just as in Java itself.

+ Instances of java.lang.String "inherit" the standard ECMA string
  methods of String.prototype.  (All of the ECMA string methods
  convert the Java string to a JS string before operating on it.)

+ Similarly, instances of Java arrays "inherit" the standard ECMA
  array methods of Array.prototype.  (Not all of these methods work
  properly on JavaArray objects, however, since the 'length' property
  is read-only.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13571 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 22:28:03 +00:00
rogerl%netscape.com
76e06e7e4d Bug from field - unicode handling messed up with 2 or more unicode literal
characters ("i" only) - missing multiply and endian problem.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13570 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 21:57:10 +00:00
rogerl%netscape.com
6d03a825d3 Bug #331349, previous fix to disallow object to function conversion was too
sweeping, screwing up closures. Now we proceed with the convert if a call op
exists in the class.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13567 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 18:45:54 +00:00
shaver%netscape.com
9a0cc72a2d quell (spurious) warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13565 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 16:57:19 +00:00
norris%netscape.com
6139484b7e Fix warnings.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13548 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 04:53:40 +00:00
fur%netscape.com
b576db0575 Eliminated gcc warnings, some spurious, some indicative of real bugs:
Spurious warnings:
jsobj.c: In function `js_EnterSharpObject':
    jsobj.c: In function `js_obj_toSource':
    jsobj.c:365: warning: `nchars' might be used uninitialized in this function
    jsobj.c: In function `obj_eval':
    jsobj.c:588: warning: `implicitWith' might be used uninitialized in this function
    jsobj.c: In function `js_DefineProperty':
    jsobj.c:1323: warning: `_c' might be used uninitialized in this function
    jsobj.c: In function `js_LookupProperty':
    jsobj.c:1394: warning: `_c' might be used uninitialized in this function
    jsobj.c: In function `js_FindProperty':
    jsobj.c:1472: warning: `lastobj' might be used uninitialized in this function
    jsobj.c: In function `js_GetProperty':
    jsobj.c:1599: warning: `_c' might be used uninitialized in this function
    jsobj.c: In function `js_SetProperty':
    jsobj.c:1645: warning: `protoid' might be used uninitialized in this function
    jsobj.c:1646: warning: `protogetter' might be used uninitialized in this function
    jsobj.c:1646: warning: `protosetter' might be used uninitialized in this function
    jsobj.c:1647: warning: `protoattrs' might be used uninitialized in this function
    jsobj.c:1665: warning: `_c' might be used uninitialized in this function
    jsobj.c: In function `js_DeleteProperty':
    jsobj.c:1939: warning: `_c' might be used uninitialized in this function

Warnings indicating real bugs:
jsobj.c: In function `js_EnterSharpObject':
    jsobj.c:252: warning: `sharpid' might be used uninitialized in this function


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13547 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 04:35:50 +00:00
fur%netscape.com
1858d69e49 Fixed gcc warnings (and real bugs indicated by warnings)
Spurious warnings:
jsdtoa.c: In function `JS_strtod':
    jsdtoa.c:1210: warning: `bb' might be used uninitialized in this function
    jsdtoa.c:1210: warning: `bd' might be used uninitialized in this function
    jsdtoa.c:1210: warning: `bs' might be used uninitialized in this function
    jsdtoa.c:1210: warning: `delta' might be used uninitialized in this function
    jsdtoa.c: In function `JS_dtoa':
    jsdtoa.c:1913: warning: `ilim1' might be used uninitialized in this function

Real errors:
    jsdtoa.c: In function `JS_dtoa':
    jsdtoa.c:1913: warning: `ilim' might be used uninitialized in this function
    jsdtoa.c:1915: warning: `spec_case' might be used uninitialized in this function
    jsdtoa.c:1921: warning: `mlo' might be used uninitialized in this function


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13539 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 03:10:55 +00:00
mccabe%netscape.com
76326b2efb Warning fix to 331245.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13536 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 02:53:22 +00:00
fur%netscape.com
06a7abeacf Fix allocation bug caused by use of initialized variable, discovered via gcc warning
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13531 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 01:21:16 +00:00
mang%netscape.com
2ae04afc70 Added section for OSF1. Fixes lots of ecma math bugs.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13526 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-27 00:18:43 +00:00
norris%netscape.com
754415d2a7 Fix "js -f x.js" for Christine.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13496 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 22:59:10 +00:00
norris%netscape.com
d719a6f851 Fix warnings, and clean up memory leak.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13482 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 21:23:56 +00:00
waldemar%netscape.com
cdcef88024 Fixed Mac warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13479 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 21:16:28 +00:00
jband%netscape.com
34fd322859 adding READMEs
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13478 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 21:09:49 +00:00
jband%netscape.com
d848312079 adding a doc
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13475 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 20:45:49 +00:00
mccabe%netscape.com
cdc32c49b5 Fix warnings:
jsstr.c: In function `str_escape':
jsstr.c💯 warning: `mask' might be used uninitialized in this function
jsstr.c: In function `str_split':
jsstr.c:1415: warning: `limit' might be used uninitialized in this function
jsstr.c: In function `tagify':
jsstr.c:1746: warning: `parlen' might be used uninitialized in this function


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13473 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 20:22:17 +00:00
jband%netscape.com
93a992bb20 fixed compile error when JS_THREADSAFE used
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13470 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 20:13:52 +00:00
mccabe%netscape.com
256ad44f6c Quiet these warnings:
jsarray.c: In function `IdIsIndex':
jsarray.c:81: warning: `c' might be used uninitialized in this function
jsarray.c: In function `array_splice':
jsarray.c:948: warning: `obj2' might be used uninitialized in this function


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13469 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 20:10:29 +00:00
jband%netscape.com
c76f45fb75 adding two helper batchfiles
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13468 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 20:09:33 +00:00
norris%netscape.com
a7a3555cc8 Fix warnings.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13466 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 19:39:13 +00:00
rogerl%netscape.com
3140821cd1 #318482, recursive death arising from defining valueOf to be the this object
is now a version 1.2 feature only.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13462 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 19:16:08 +00:00
rogerl%netscape.com
befd55d8ba #318482, recursive death arising from defining valueOf to be the this object
is now only a version 1.2 feature, but the error mechanism needed to be
protected from failure even so.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13460 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 19:15:01 +00:00
norris%netscape.com
3962bfda99 Fix warnings under gcc.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13458 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 18:39:01 +00:00
norris%netscape.com
faca6b626e "js -f foo.js" wasn't working correctly.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13455 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 18:13:40 +00:00
fur%netscape.com
8c1af11605 Eliminate gcc warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13452 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 17:41:35 +00:00
fur%netscape.com
6c8f42225c + Eliminated unused JavaMemberVal struct/type
+ Tweaked JS->Java method overload resolution
   + Don't allow JavaArrays to be passed as arguments to Java methods
     that accept scalar numeric types, since there's no meaningful
     conversion available.
   + Permit JavaObjects and JavaArrays to be passed to Java methods
     that accept a boolean argument for backward-compatibility.

+ Added explicit overload-method resolution to override ambiguous cases, e.g.
  m = java.lang.String["valueOf(char[],int,int)"]
  return m(myCharArray, 3, 7);


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13443 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 07:03:41 +00:00
norris%netscape.com
847bebb065 Implement X.Y.Z implementation version.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13442 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 05:44:04 +00:00
norris%netscape.com
2c9b897958 Fix 330840 monkey - assertion failure in import expression decompilation
Wrong length for JSOP_IMPORTELEM.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13440 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-26 05:38:22 +00:00
bjorn%netscape.com
b01cc3080f Added volatile to avoid bug in gcc
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13434 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-25 22:45:22 +00:00
bjorn%netscape.com
9cd7750dd1 move_sym_to_front avoids aliasing problem on AIX
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13432 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-25 22:17:57 +00:00
mang%netscape.com
ed9c4d7ee1 Don't use fdlibm by default.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13408 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-24 01:49:17 +00:00
bjorn%netscape.com
ceb34941c8 Changed the typedef of JSCList to work around what seems to be a bug in gcc and xlc (AIX).
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13407 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 23:56:29 +00:00
mang%netscape.com
f20e53875b Don't use fdlibm by default.
There can be problems with endian-ness.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13406 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 23:53:45 +00:00
norris%netscape.com
7c8275aae3 Use %p to print out pointer values: works better on 64 bit machines.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13405 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 21:35:56 +00:00
jband%netscape.com
30e0d801a7 fix default target - msdev bug in writing out .mak file!
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13397 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 20:34:18 +00:00
fur%netscape.com
a899984e09 Added fdlibm
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13393 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 19:43:52 +00:00
coop%netscape.com
54e5a64304 Constructors are once again public, but have been marked as deprecated so
that people won't get too fond of using them.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13392 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 19:23:36 +00:00
fur%netscape.com
4016979d0d Added fdlibm
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13391 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 19:16:28 +00:00
fur%netscape.com
663693cafe Ignore .pdb files
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13388 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 18:24:44 +00:00
wynholds%netscape.com
aed4dd4310 fixing NT build with new fdlibm stuff and an old error gone unnoticed until now. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13379 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 17:30:41 +00:00
norris%netscape.com
6c7c73d822 Fix 330845 digital unix: arithmetic exception in string stuff:
Expression "argv[argc-1]", where argc == 0 and argc was a 32 bit unsigned quantity,
was causing a memory exception on the 64 bit machine because it was evaluating as
argv[0xffffffff] rather than argv[-1].


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13376 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 16:51:08 +00:00
wynholds%netscape.com
28c93d2218 fixing fdlibm stuff. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13374 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 16:35:58 +00:00
norris%netscape.com
ca95b9b63a Add patch number.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13373 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 15:35:41 +00:00
mang%netscape.com
67d738630a Landing of MANG_MATH_10231998
Replaces many system math routines with ECMA/IEEE compliant routines
from fdlibm.
These new routines are big and slow, so there are platform specific
defines in jslibmath.h that determine which fdlibm routines to use.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13372 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 10:16:50 +00:00
(no author)
f018a06aa7 This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13371 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 09:14:03 +00:00
norris%netscape.com
eb89b3d136 Fix 330071 Remove catch condition support from 1.4
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13364 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 05:51:29 +00:00
wynholds%netscape.com
6c156d7134 fixed ship target to correctly take into account any variation of JS_THREADSAFE and JS_LIVECONNECT. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13354 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 01:20:32 +00:00
mccabe%netscape.com
7f123a804d Sigh. Turn of reflection of runtime errors as exceptions.
Because the immediate demand for it in the client seems to have
lessened somewhat, and because it makes our cross-engine story make
more sense for external customers if we wait 'till it's implemented
for both engines.

Also, attempting to make exceptions work cleanly in a cross-context way
turned out to be difficult; it probably makes sense to take a step
back and look at how to find the best solution for the long term
development of the language.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13353 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 00:37:15 +00:00
wynholds%netscape.com
ec0edbcba0 adding HPUX 10.20 config makefiles. they are just copies of HPUX 10.10 makefiles. hope they work. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13351 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-23 00:30:46 +00:00
norris%netscape.com
2687debc8e Fix bug 330462 monkey: decompilation of comma op causes ASSERT/script failure
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13347 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-22 23:55:09 +00:00
mccabe%netscape.com
5fb184d473 Another fix to 329807.
Rather than nulling out the error reporter during the execution of
'load', replace it with a new error reporter that ignores all error
reports with the JSREPORT_EXCEPTION flag set.

Also fix a bug in jsexn.c where I was failing to actually set that
flag, and Eich-ify a few curly-brace placements.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13313 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-22 19:55:11 +00:00
mccabe%netscape.com
4885772ba8 Fix to 330589. Back out a tree-rewriting of foo[0] -> foo.0 because
the resulting code decompiles to foo.0.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13301 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-22 03:44:56 +00:00
rogerl%netscape.com
3d0da2df12 Bug #310514 - for eror report on calling toString on a not-function, was
calling toString to get the name of the object. Duh. Now calls getTypeName.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13290 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-22 00:05:16 +00:00
rogerl%netscape.com
030655be79 Bug #324451 - eval was bailing out early if the arg was not a string, and
so skipping the indirect-eval check.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13289 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-22 00:01:49 +00:00
fur%netscape.com
c21e3de07e Match changes in Makefile for auto-generating jsautocfg.h
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13279 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 21:43:59 +00:00
mccabe%netscape.com
f654a47a49 Fix to 329807.
'load' in the shell makes 'toplevel' calls to the js interpreter, so
the mechanism for detecting and reporting uncaught exceptions at the
top level kicks in prematurely.  To work around this problem, I set
the error reporter to NULL.  A better fix might be to use a custom
error reporter for load that knew to ignore exception error reports,
expecting that the javascript context calling load would catch or
report them.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13276 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 20:52:43 +00:00
norris%netscape.com
c11ef38890 Fix 330074 arguments object uses Array.prototype.toString
Unfortunately, I can see no way to version this behavior.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13275 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 20:45:41 +00:00
norris%netscape.com
d8f121d794 Better debugging code for printing objects.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13273 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 20:19:46 +00:00
rogerl%netscape.com
47f4088f27 Bug #330051 - previous fix for end of string with empty sep. should have
been 1.2 only and should have set the sep->length to 1 in order to break
out of the split loop.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13264 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 18:02:24 +00:00
rogerl%netscape.com
9d8444be44 Plugging a memory leak whenever an error is reported.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13261 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-21 17:54:30 +00:00
wynholds%netscape.com
0bd94e4384 CFLAGS needs to be +='ed, not ='ed. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13206 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 17:02:13 +00:00
wynholds%netscape.com
e0a486e300 need another include directory in liveconnect directory. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13205 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 16:47:16 +00:00
fur%netscape.com
4bf9c6a227 Fixed INCLUDES problem when JS_THREADSAFE is set
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13199 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 15:32:46 +00:00
fur%netscape.com
3277bdac18 Auto-generate jsautocfg.h instead of using checked-in jscpucfg.h file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13192 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 07:32:26 +00:00
fur%netscape.com
87c868ffbe Improve clobber rule
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13191 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 07:31:21 +00:00
fur%netscape.com
5f6bbab561 Eliminate dependency on jscpucfg.h for Windows
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13186 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 05:00:16 +00:00
fur%netscape.com
55cebfe0cb It turns out that even though we were generating jscpucfg.h, we weren't
using it.  Rather the static, checked-in version was being used.  Fixed, now.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13185 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 04:42:33 +00:00
fur%netscape.com
26c815ff77 Generate jscpucfg.h on Unix platforms rather than relying on per-platform
static definitions.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13181 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 03:24:47 +00:00
fur%netscape.com
facfc365cb Ignore generated files
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13143 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-20 00:09:26 +00:00
fur%netscape.com
63ace590d6 Get rid of -D_SVID_GETTOD
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13142 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-19 23:59:29 +00:00
mccabe%netscape.com
31c250eee9 Fix from Joe Keane to avoid reiniting the scanner except when
necessary.  Thanks!

From: Joe Keane <jgk@jgk.org>  Fri 19:11
Subject:                       Re: JS_SetVersion not
To:                            Mike McCabe <mccabe@netscape.com>

The main caller i saw was libmocha.  In `win_run_timeout', it calls
`JS_SetVersion' twice every time there's a JavaScript timeout; it sets
the version before running the expression, then it sets it back when
it's done.  It looks like a couple times per second, not the worst
thing in the world, but nice to get rid of if it's easy enough.

I had some question about whether it's doing something dumb and it can
be improved.  This may be true, but there are some other callers, for
example it gets called indirectly by `PL_HandleEvent'.  Overall it
seems like a simple and pretty right thing to do anyway.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13134 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-19 22:15:39 +00:00
jband%netscape.com
60b5308f58 Added JSD support for DebugErrorHook
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13069 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-17 06:18:16 +00:00
jband%netscape.com
d2b9c6a168 - added 'DebugErrorHook' which (when present) is called before the ErrorReporter. And in cases where an error exception is raised but the ErrorReporter is not called. This allows for the debugger catching errors when they happen that the ErrorReporter will not now see until they become uncaught errors. This also simplifies the debugger by not having it try to track an ErrorReporter chain. This now works more like the Rhino system.
- #if 0'd js_ReportCompileError which is no longer used (replaced by js_ReportCompileErrorNumber). I'm all for cutting this out of the codebase. Shall we just do that?


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13061 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-17 02:26:19 +00:00
jband%netscape.com
b6525cde8b fix script leakage if !JS_HAS_ERROR_EXCEPTIONS
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13060 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-17 02:11:27 +00:00
bjorn%netscape.com
c4741a81fe Made cc be the default.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13022 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 21:47:52 +00:00
bjorn%netscape.com
0649a670ac Moved declaration of FAR to satisfy 'cc' on Dec Unix.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@13020 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 21:45:44 +00:00
bjorn%netscape.com
d418df2eb7 Extra config stuff for cc on OSF.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12998 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 18:16:26 +00:00
bjorn%netscape.com
e86bd6fd57 switch for OSF1.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12997 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 18:13:53 +00:00
jband%netscape.com
6d79b5ec64 fix 'typedef struct' redefinition - problem for jsd too before it becomes a build issue
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12992 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 10:36:20 +00:00
jband%netscape.com
46800959c2 fix build bustage on Unix due to 'typedef struct' redefinition - the Windows compiler didn't mind
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12991 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 10:26:22 +00:00
mccabe%netscape.com
e29596b37b Fix the javascript-visible Exception constructor to make objects of
jsclass Exception.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12987 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 09:34:29 +00:00
mccabe%netscape.com
1419ca574a Make the toSource stuff #if JS_HAS_TOSOURCE
Viva jsconfig.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12985 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 09:21:22 +00:00
jband%netscape.com
e5892b8370 Added support for throw hook. Added locals() and args() to jsdb to demonstrate/test JSDValue/JSDProperty stuff
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12972 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 04:07:41 +00:00
jband%netscape.com
60fe37f18d added save/restore/drop of JSExceptionState. This allows opaque scheme for doing evals and stuff on a context without screwing up the state of the exception information. This helps now with rooting the saved exception and will help more later if additional hidden exception information is added to the context; e.g. source location of thrown exception, etc. Also added throw hook. This is necessary since the relationship between the exceptions and error reporter changed
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12971 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 04:03:46 +00:00
fur%netscape.com
98c0f47746 Fix AIX build bustage
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12970 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 03:58:25 +00:00
fur%netscape.com
55a926e2c4 Fix gcc warning
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12969 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 03:58:07 +00:00
fur%netscape.com
f7387ecdae Fix gettimeofday() on Solaris for the umpteenth time
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12968 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 03:51:56 +00:00
fur%netscape.com
ecf83e4f36 + HAVE_LONG_LONG ==> JS_HAVE_LONG_LONG, so as to avoid conflict with NSPR
macro of the same name.
+ Changed JS_HAVE_LONG_LONG to be defined on Linux, since we compile with
  gcc on that platform.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12963 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-16 03:42:06 +00:00
bjorn%netscape.com
7d02cdd1c2 changed from int to unsigned int in alignment code.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12921 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 21:06:57 +00:00
mang%netscape.com
0bd5df16b7 Include jsfile.h only when building with JS_HAS_FILE_OBJECT
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12917 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 20:55:02 +00:00
mccabe%netscape.com
145eb6f922 Toss the cx->exceptionProtos vector and go to looking up exception
prototypes by using the the constructor names in the current context.
This has some failure modes if users have overwritten the
constructors, but they seem tolerable:

js> sil
1: ReferenceError: sil is not defined
js> ReferenceError = 'foo'
foo
js> sil
3: Exception: sil is not defined
js> Exception = 'bar'
bar
js> sil
5: [object Exception]


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12878 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 08:46:59 +00:00
mccabe%netscape.com
f98b15d6d3 Update js.c from the previous behavior of ignoring errors tagged as
exceptions - this caused toplevel compile errors to be ignored.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12877 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 08:35:03 +00:00
fur%netscape.com
da9f65325b Propagated changes from JS_STABLE_10131998_BRANCH, required to build mozilla.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12861 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 03:07:09 +00:00
mang%netscape.com
25bbd958a9 Now duplicate string instead of trying to modify read-only memory on Unix
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12860 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 02:58:12 +00:00
bjorn%netscape.com
3e8f4b2074 Change so that the local structure used to represent a JS pointer is aligned
modulo 8 rather than 4.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12852 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-15 01:22:15 +00:00
mang%netscape.com
6547ff01ff Added NPL
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12834 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 22:04:23 +00:00
wynholds%netscape.com
dd55af2615 xlC_r on AIX seems to not be able to hand C++ comments. seems kinds stupid, but what the hell? so i changed it to a C-style comment. no hard no foul.
-mw


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12831 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 21:42:37 +00:00
wynholds%netscape.com
619f867c2d ship target now supports JS_LIVECONNECT to be defined or undefined. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12829 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 21:36:29 +00:00
rogerl%netscape.com
2ffc6eb8cf Bug #315139 - for character split and empty separator, return string length
for end of string.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12828 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 21:32:11 +00:00
rogerl%netscape.com
444ed356ed Fix precedence issue (inappropriate distributive use)
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12826 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 20:58:31 +00:00
mccabe%netscape.com
ad709b1cfa GC_MARK the pending exception as a GCTHING rather than as a jsval
during garbage collection.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12794 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-14 07:13:34 +00:00
mccabe%netscape.com
90dc42fec0 Fix warnings.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12714 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 19:44:39 +00:00
mccabe%netscape.com
7b3a25dde6 Further work on errors as exceptions -
Changes to js.c back out much of the error-checking code of the
previous checkin; proper exception handling now requires fewer changes
to the host.

Exception prototypes are per-context, with no way (yet) to have
instanceof work properly with exceptions from other contexts.
Per-runtime prototypes (to make instanceof work naturally) worked OK,
but sealing these objects to prevent leaking information between
threads turned out to be hairy.  (Because Exception.prototype.toString
needed sealing too...)

Errors for which a corresponding exception is thrown are suppressed,
and compile errors are always suppressed except at the top level.
Entry functions in jsapi.c now detect failure of calls to the
interpreter and call the error reporter if an exception was raised;
exception-savvy hosts may provide an error reporter that ignores these
reports by checking JSREPORT_EXCEPTION in the report flags.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12686 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 09:58:28 +00:00
mang%netscape.com
3b086e1130 JS File Object (not fully implemented yet)
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12662 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 03:20:37 +00:00
jband%netscape.com
43ea6c73ea Added reflection of JSDValue, JSDProperty, and JSDObject stuff to jsdb. Initial support for this in debugger.js
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12646 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 01:02:25 +00:00
jband%netscape.com
8b37303301 added a comment
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12644 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 00:57:53 +00:00
bjorn%netscape.com
a9d4091b08 Updated js_list_scope_lookup() to use void pointers for casting, instead
of JSSymbol. This removed a problem on AIX where the compiler shuffled
code around, thinking that it was safe to do so. Waldemar helped me
track this one down.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12638 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-13 00:17:36 +00:00
fur%netscape.com
0e74fd5849 Merge changes from trunk
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12621 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 22:32:49 +00:00
fur%netscape.com
9bbc9990a2 Fix JS_FRIEND_DATA for Mac
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12614 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 22:12:08 +00:00
fur%netscape.com
5cea729be2 Updated file for JS1.4
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12606 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 21:01:57 +00:00
fur%netscape.com
c7838f766a Get rid of obsolete files
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12588 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 18:40:42 +00:00
norris%netscape.com
d6adc823ec Fix bug 299903 Inheriting from a Date object causes crash
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12582 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 17:54:44 +00:00
fur%netscape.com
65fea2e956 Remove out-of-date MSVC5 project files
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12580 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 17:37:11 +00:00
fur%netscape.com
bc6d33a86b Get rid of isatty() warning on Windows
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12577 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 16:43:17 +00:00
(no author)
f9446c3323 This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12554 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 08:05:38 +00:00
fur%netscape.com
f2dde02af9 1) Fixed bug in which incorrect netscape.javascript.JSException constructor
was being called when wrapping JavaScript exception objects thrown as
   a result of evaluating JavaScript from Java.

2) Implemented improved LiveConnect overloaded method resolution as described
   in the spec: http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html
   (Explicit method specification not yet implemented, however).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12551 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 07:32:14 +00:00
jband%netscape.com
41ebf8c0e0 Added type info to handles to support automatic 'dropping' of JSDValues (to be supported soon). Added name prop to handles to avoid toString having to repeatedly create the name on the fly. Also misc cleanup.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12545 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-12 02:39:27 +00:00
fur%netscape.com
ab971b977f Changed files for building JS for Mac after js ref/src merge
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12499 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 03:17:19 +00:00
fur%netscape.com
9c77f182aa Fix use of uninitialized variable.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12498 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 03:16:23 +00:00
fur%netscape.com
b25aef6c55 Privatize some names that conflict with NSPR identifiers missed in the first round of js ref/src merging.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12497 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 03:13:38 +00:00
fur%netscape.com
a82b563a25 Kill Mac warnings
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12496 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 03:11:30 +00:00
jband%netscape.com
02314c78f6 turn off debug tracing output
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12490 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 02:23:56 +00:00
jband%netscape.com
425d07341a added JSObject tracking system that supports iterating all JSObjects with info about the source line that created them and the source line and name of their constructors
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12488 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 02:10:07 +00:00
fur%netscape.com
268dfb88cb Fix to make JSObject native methods load on unix
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12485 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 00:53:33 +00:00
fur%netscape.com
bc2ec58a7b Get rid of outdated Java implementation of JSObject.equals(). It was replaced by native code a long time ago.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12483 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 00:53:05 +00:00
fur%netscape.com
cf373daa53 Don't use deprecated PrintStream API
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12482 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-10 00:52:03 +00:00
coop%netscape.com
7fe8465ded Changed constructor JSException(Object) to public so that Java users can
throw exceptions to JS cleanly.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12427 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-09 15:38:08 +00:00
mccabe%netscape.com
37ec2963c9 Added NPL.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12421 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-09 08:11:32 +00:00
fur%netscape.com
5ea0bc5e25 Revert to my non-standard, but more tabular white-space formatting
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12385 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-09 01:17:24 +00:00
fur%netscape.com
a492c3a964 Fix for #328274 (Unable to pass JS objects to Java)
Thanks to coop for noticing the problem.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12384 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-09 01:16:45 +00:00
rogerl%netscape.com
a256793772 #324451 - disallow indirect calls to eval
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12367 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:51:18 +00:00
rogerl%netscape.com
fa7759865b #324451 - if eval not invoked with CALLSPECIAL, then complain that it was
called indirectly, not allowed for new ECMA.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12366 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:50:06 +00:00
rogerl%netscape.com
7a57c4b47a #324451 - CALLSPECIAL opcode for detecting indirect calls to eval
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12365 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:48:57 +00:00
rogerl%netscape.com
a2ebae060e #324451 - detect direct call of eval and use CALLSPECIAl opcode instead
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12364 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:48:14 +00:00
rogerl%netscape.com
a8dc44aaa9 #324451 - Added callSpecial opcode to identify indirect eval calls
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12363 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:46:29 +00:00
rogerl%netscape.com
3c18b0c3ba #324451 Added eval to atomState so that we can detect indirect calls to eval
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12362 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 23:42:03 +00:00
coop%netscape.com
c122de69b8 Made all constructors private.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12347 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 21:57:30 +00:00
coop%netscape.com
4a3d57e324 Changed references to JSWrappedException to point to JSException instead.
Fixed nesting for vreport_java_error that prevented pending exception from
being set or cleared properly.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12306 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 20:16:51 +00:00
coop%netscape.com
a3f846bbf0 Changed references to JSWrappedException to point to JSException instead.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12305 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 20:12:36 +00:00
coop%netscape.com
189fd42355 JSWrappedException: removed
JSException: now extends RuntimeException
	     added Object wrappedException
	     added new constructor that takes an Object
	     added instance method getWrappedException(), returns wrappedException.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12304 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-08 20:08:01 +00:00
jband%netscape.com
63410ef469 added debug hook for notification of JSObject new and finalize
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12229 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 22:07:37 +00:00
norris%netscape.com
7f25afca90 Sigh. Back out fix that caused regressions.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12224 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 21:34:44 +00:00
jband%netscape.com
81d08cb271 support for resume with returnVal or throwVal
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12148 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 01:55:53 +00:00
jband%netscape.com
deefcc6b8d support for throwing from hook, prep for client checkin: fix locks, mods to makefile.win
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12147 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 01:52:25 +00:00
jband%netscape.com
e9b1c82736 added JSTRAP_THROW -- support for throwing an exception from any of the three kinds of interpreter hooks: interrupt, pc trap, debugger keyword
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12146 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 01:39:30 +00:00
wynholds%netscape.com
27a80cf6d2 some hacky stuff to get NT building right with gmake -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12141 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 01:15:11 +00:00
mccabe%netscape.com
1022f9e0ce Initialize cx->throwing to JS_FALSE #if JS_HAS_EXCEPTIONS!
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12139 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 00:54:26 +00:00
jband%netscape.com
c9bb9195dd only call JS_DestroyScript on non-NULL script in shell Load
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12138 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 00:43:20 +00:00
wynholds%netscape.com
095999e32b getting NT stuff build build EXEs correctly/at all -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12136 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-07 00:40:51 +00:00
wynholds%netscape.com
d76a5a9080 oops, typo for HP package. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12127 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:52:55 +00:00
wynholds%netscape.com
a70e9a2aaa NT executables end in .exe ! -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12126 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:51:33 +00:00
wynholds%netscape.com
e359fd71fc HP uses libnspr21.sl -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12124 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:47:50 +00:00
wynholds%netscape.com
04e1b5c3d1 NT uses a different nsinstall (built into shmsdos.exe) -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12122 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:44:53 +00:00
wynholds%netscape.com
fa2407ee2e don't forget this header file. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12121 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:32:06 +00:00
wynholds%netscape.com
49bb4bd95c package the right files on NT. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12120 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:30:18 +00:00
wynholds%netscape.com
3c49adc57b packaging libnspr21.so now. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12116 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:26:34 +00:00
wynholds%netscape.com
3f7cdf786b only use EXPORT_JS_API while building libjs.dll -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12113 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:07:41 +00:00
wynholds%netscape.com
78fba657bd LOOP_OVER_DIRS now can go only one level deep at a time -m
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12112 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 23:05:04 +00:00
wynholds%netscape.com
5b6a656e48 now NT's link line will create the right .lib and .pdb -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12091 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 21:42:00 +00:00
wynholds%netscape.com
fbbe5d2674 we need to use a JDK built especially for HP-UX10 (not 11) because on 11 it links with libm.sl.2, and on 10 it links with libm.sl.1. anyway, on 10, we don't have libm.2 so we obviously need the right one. i put it in /share/builds/components/jdk/1.1.5/HP-UX10/... -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12086 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 21:23:42 +00:00
wynholds%netscape.com
d9d717001f using cc instead of gcc (stupid gcc on HP). -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12085 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 21:21:08 +00:00
wynholds%netscape.com
1dde42d623 HP has to use native c compiler now, but hey, gcc just wasn't cutting it. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12049 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 19:39:46 +00:00
wynholds%netscape.com
1ed0446da5 get the link line right for NT. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12046 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 16:29:47 +00:00
wynholds%netscape.com
3fd73fdffd jsref_opt.jar and jsref_dbg.jar -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12045 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 16:18:16 +00:00
wynholds%netscape.com
cfa1a86909 a fix for UNIX on LOOP_OVER_DIRS -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12044 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 15:53:36 +00:00
coop%netscape.com
6b78529f1f Removed references to getWrappedException java method.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12043 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 14:46:50 +00:00
norris%netscape.com
4fd0fc55ca Fix bug 327540 "monkey: crash in some negative tests"
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@12025 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 04:08:25 +00:00
norris%netscape.com
b1e460a74a Fix 325843 "function f(a){var a,b;} asserts/crashes"
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11980 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 00:26:15 +00:00
wynholds%netscape.com
a5a20628a0 HP 10.10 stuff -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11977 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 00:19:22 +00:00
wynholds%netscape.com
d9eb58cdec need this to get HP linking. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11976 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-06 00:18:34 +00:00
wynholds%netscape.com
037c43596e uses reltools now
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11974 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:59:25 +00:00
wynholds%netscape.com
79b38ca130 get liveconnect building on NT
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11973 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:52:02 +00:00
wynholds%netscape.com
2f59039158 NT specific stuff
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11972 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:50:12 +00:00
wynholds%netscape.com
d32e31eda5 make DIRS NT friendly
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11971 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:49:23 +00:00
wynholds%netscape.com
ccf4b130af links correctly with NSPR on NT
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11970 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:46:20 +00:00
coop%netscape.com
c66acfa187 JSWrappedException wraps a JavaScript exception in a java.lang.Object wrapper.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11968 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:39:09 +00:00
coop%netscape.com
89d32f85be Removed "if 0"s referencing JSWrappedException code.
Changed references to JSWrappedException to reflect changes to that objects
structure, ie. JSWrappedException now contains a java.lang.Object instead
of an integer.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11967 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:35:22 +00:00
coop%netscape.com
0f8d890868 Removed "if 0"s referencing JSWrappedException code.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11966 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:32:28 +00:00
coop%netscape.com
3c8ae5aafe Removed "if 0"s referencing JSWrapped exception code.
Changed throw_any_pending_js_error_as_a_java_exception to reflect the
new make-up/construction of JSWrappedException (contains an java.lang.Object
instead of an integer).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11965 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:31:35 +00:00
coop%netscape.com
f909920e91 Removed "if 0"s for references to JSWrappedException.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11963 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 23:27:26 +00:00
wynholds%netscape.com
ad73f38c85 installing programs to dist/bin directory now, and giving the owner write permissions. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11945 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 21:58:28 +00:00
wynholds%netscape.com
e18fa8a56f added ship target for packaging. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11944 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 21:57:50 +00:00
wynholds%netscape.com
e81b4d3657 this is the right config file for DEC, not dgux.mk. i dunno what version of uname that comes from. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11940 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 21:23:13 +00:00
wynholds%netscape.com
19c49a56be get DEC building -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11939 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 21:22:33 +00:00
wynholds%netscape.com
3e2489f92c point to java stuff for HP. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11934 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 20:55:29 +00:00
wynholds%netscape.com
b9e217c7e8 get HP 11 to link shared libraries. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11933 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 20:53:57 +00:00
wynholds%netscape.com
940ee6966f using /share/builds/components/jdk/1.1.6/IRIX instead of /usr/java so everybody can use it!. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11925 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 19:30:18 +00:00
wynholds%netscape.com
13337f0a89 using /share/builds/components/jdk/1.1.6/IRIX instead of /usr/java so we can all use it! -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11924 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 19:29:04 +00:00
wynholds%netscape.com
aabb8920ae need to hack AIX 4.1 to grab 4.2 because 4.1 doesn't exist. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11918 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 19:15:11 +00:00
wynholds%netscape.com
bd32e33753 trying to get AIX 4.1 to build, but no real luck yet. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11917 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 19:13:14 +00:00
wynholds%netscape.com
c68e984b99 link with libdl.a when doing threadsafe builds (NSPR needs it). -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11912 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 18:34:01 +00:00
wynholds%netscape.com
35b4a8183d get AIX 4.1.5 building. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11911 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 18:33:22 +00:00
wynholds%netscape.com
f746d5d6c5 added SunOS5.6.mk file to get it building. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11910 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 18:07:21 +00:00
wynholds%netscape.com
dccd95eeaa new target to grab NSPR from /share/builds/components. for use with JS_THREADSAFE standalone builds. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11909 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 17:46:30 +00:00
mccabe%netscape.com
0dc9a5a868 Be more paranoid in various ways about properly handling exceptions,
from compilation or execution.  Load is now somewhat more exception-savvy.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11899 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 09:56:06 +00:00
mccabe%netscape.com
f46f66eea8 Change some engine semantics to propagate exceptions better.
js_DefaultValue and a few other places used js_TryMethod,
js_TryValueOf.  The return value of these functions was always ignored
(well, was void) even if they found a method to call and that method
raised an exception.  As a result, functions like valueOf which might
have been user-defined to throw an exception didn't end up propagating
the exception.

I changed js_TryMethod, js_TryValueOf, and JS_ConvertStub (which calls
js_TryValueOf) to propagate failure.  Note that they'll still succeed
if they fail to find an appropriate method value to call.  (so 'Try'
still means something in this context.)  js_DefaultValue now uses
these return values to decide how to proceed.

As a result js_DefaultValue and obj->convert now may fail in a few
places where they previously did not.  I think that this is best in
terms of making the engine interpret a consistent language, but it
might trip us up on old code.  Fingers now crossed.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11898 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 09:40:59 +00:00
mccabe%netscape.com
8ade5f78d3 If compiletime errors are already reflected as exceptions, suppress
any compiletime errors that don't occur at the top level.  The intent
is to retain as much as possible the existing behavior of giving
multiple compile error messages for toplevel compiles.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11897 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 09:16:07 +00:00
mccabe%netscape.com
58a8a3d984 Only look for enclosing try/catch statements on abrupt frame exit when
returning failure with a pending exception, not just when there's a
pending exception.  (The pending exception could have been an
uncleared exception another script in the same context.)


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11896 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 09:07:48 +00:00
mccabe%netscape.com
e539af4e6f Fix to 318250. Disable an assert that was firing for a
default-value-throws-exn object used in an expression.  Code exists to
handle the case for which the assertion failed, but it was effectively
disabled in debug builds.  Anybody know the history of this one?


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11895 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 08:17:48 +00:00
norris%netscape.com
27e172913a Fix 299903 Inheriting from a Date object causes crash
and Actra global regexp problem (Function clone of regexp object because
it is of type Function).


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11894 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-05 06:32:34 +00:00
fur%netscape.com
b54505be31 Changed PR_* to JS_* names
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11890 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-04 23:18:51 +00:00
fur%netscape.com
2433dae015 Propagating README from js/ref
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11889 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-04 23:16:44 +00:00
mccabe%netscape.com
c2bcde8466 Only raise an exception for the first syntax error that's reported on
any given compile.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11843 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-03 03:27:13 +00:00
mccabe%netscape.com
90fb1dfb90 Comment fix.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11842 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-03 03:23:08 +00:00
val4%cornell.edu
132d1f5b26 Minor modification to readme reflecting the changes in the directory structure.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11791 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 19:42:37 +00:00
val4%cornell.edu
4c69c950da Looks like CRs on this file were scred up, which didn't allow MSDEV to
open them properly. Hopefully, it will work now.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11781 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 18:35:59 +00:00
coop%netscape.com
d5329cfd00 Added NPL.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11772 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:30:56 +00:00
coop%netscape.com
83cb0cf419 Added code to vreport_java_error that reports, sets and clears JS exceptions
based on the type of java exception encountered. Parts referencing
JSWrappedException are currently commented out.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11771 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:30:11 +00:00
coop%netscape.com
d3eee3f5c6 Added extern references for class JSWrappedException. Currently commented out.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11770 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:27:48 +00:00
coop%netscape.com
c78787a61a Added code to throw_any_pending_js_error_as_a_java_exception which
wraps an exception in a JSWrappedException wrapper. Currently commented
out.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11769 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:26:18 +00:00
coop%netscape.com
fd99e42a1e Added references (jclass, jmethodID, etc.) for JSWrappedException class.
Class does not currently exist, so references are commented out.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11768 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:23:46 +00:00
coop%netscape.com
f536714915 Added NPL for all classes.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11767 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 15:21:41 +00:00
shaver%netscape.com
16977a5881 fix Linux build of shared JS
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11740 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-02 02:02:23 +00:00
(no author)
d58d92ba30 This commit was manufactured by cvs2svn to create branch
'SpiderMonkey140_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11725 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 23:57:01 +00:00
bjorn%netscape.com
70aa311f1a Some final touches to the make system, just when you thought they
were all over... I got rid of the silly JS_STATIC. More pain than
pleasure, really.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11713 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 22:11:21 +00:00
wynholds%netscape.com
d6d4547e60 adding nsinstall-target target which will build the nsinstall executable needed for gmake export. -mw
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11678 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 19:32:00 +00:00
bjorn%netscape.com
cddb4bee49 Changed environment flag from JS_THREADSAFE to USE_NSPR.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11670 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 17:53:22 +00:00
bjorn%netscape.com
215e4f521a Added '+' to CFLAGS definition.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11649 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 04:52:28 +00:00
bjorn%netscape.com
b374ece734 Added JS_STATIC flag which, when set, links LiveConnect statically with JS.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11648 18797224-902f-48f8-a5cc-f745e15eee43
1998-10-01 04:47:20 +00:00
bjorn%netscape.com
db88d15e60 IRIX 6.2 support for LiveConnect.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11620 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 23:30:52 +00:00
bjorn%netscape.com
17a3a3fede IRIX6.2 support.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11619 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 23:30:14 +00:00
bjorn%netscape.com
802ea94da2 Changes to make export work from inside liveconnect.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11618 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 23:28:20 +00:00
bjorn%netscape.com
87987c22eb LC support for IRIX.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11617 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 23:24:05 +00:00
mccabe%netscape.com
92e75b047c Fix to 320443. Restructure jsinterp.c to always check a raised
exception against any enclosing try statement within the current frame
before attempting to return from the frame.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11612 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 22:34:13 +00:00
bjorn%netscape.com
d72d172d7a Fixes to properly generate the executable 'jsj'.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11611 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 22:33:44 +00:00
rogerl%netscape.com
8e7b173eef ErrorNumber handling changes to support UC
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11607 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 21:51:59 +00:00
rogerl%netscape.com
d898e8430d Fixed bug #104766. DecompileFunctionBody needs to set the scope in its
JSPrinter arg.
Changed error number handling code to support UC version as well.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11606 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 21:50:52 +00:00
rogerl%netscape.com
55edce6a15 Fixed bug #104766. DecompileFunctionBody needs to set the scope in its
JSPrinter arg.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11603 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 21:48:00 +00:00
rogerl%netscape.com
f962f59ccc Fixing bugs #310514, 310502 - calling function.toString, .call & .apply
on non-function objects now results in a runtime error.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11599 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 21:30:26 +00:00
bjorn%netscape.com
75187e5e57 DIST is now a variable set in Makefile.ref so that the export rule
can be made to export to a chosen directory.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11572 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 18:13:50 +00:00
bjorn%netscape.com
3522f2112e Removed JDK include.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11566 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 17:14:29 +00:00
bjorn%netscape.com
b2bc5afac7 New support for AIX.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11565 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 17:14:12 +00:00
bjorn%netscape.com
1b857628d4 AIX 4.2 make support.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11564 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 16:59:47 +00:00
fur%netscape.com
4034d6af4c Added MKSHLIB macro
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11528 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 03:45:54 +00:00
bjorn%netscape.com
1d5e647e2c Added includes.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11527 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 03:10:19 +00:00
bjorn%netscape.com
2aabababd7 New support for standalone make system.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11526 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 03:08:00 +00:00
fur%netscape.com
024311a2ab Fixed an incorrect assertion that I believe was intended to confirm that
all JS roots pointed into the GC'able JS arena, but which wasn't coded correctly.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11525 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 03:03:15 +00:00
mccabe%netscape.com
55fcddec90 Changed some remaining messages from js_ReportCompileError(<hardcoded
string>) to js_ReportCompileErrorNumber(<error number>).  To make
runtime exceptions work for lexical errors, because the mechanism
piggybacks off of js_ReportCompileErrorNumber.

Also propagated a free->JS_free change.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11522 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-30 01:53:45 +00:00
bjorn%netscape.com
0c95c94909 Fixes to the assembly for SPARC v8, and to accommodate for new source
tree.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11478 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 23:32:29 +00:00
bjorn%netscape.com
8da98334c6 Fixed the test when the pointer is busy (tst -> cmp)
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11474 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 23:18:26 +00:00
shaver%netscape.com
defa10fc43 added Linux config file
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11469 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 22:54:37 +00:00
bjorn%netscape.com
f0cdddb20c Changed assertion in CompareAndSwap to look for nv != -1.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11465 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 22:47:27 +00:00
fur%netscape.com
a17e03c381 Re-fixed comment
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11419 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 20:35:44 +00:00
shaver%netscape.com
595794ecfe don't overwrite catchall jump with rethrow address
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11414 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 19:14:36 +00:00
shaver%netscape.com
1a0b1b8a29 fix catchall-after-catchguard spurious error
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11347 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 09:50:04 +00:00
fur%netscape.com
670d4d69fa Moved from js/ref to js/src
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11326 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 05:56:30 +00:00
fur%netscape.com
c5a6bb1af7 Migrated LiveConnect from js/ref to js/src.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11325 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-29 05:55:25 +00:00
jband%netscape.com
00a574acf2 added call to new JSD unicode function JSD_AppendUCSourceText to simplify shell and remove truncation hackery (which really just got pushed into JSD)
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11257 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-28 20:37:22 +00:00
jband%netscape.com
68900225d1 - removed MY_XP junk, abandon Win16, assume that realloc works
- removed HACK_FOR_OLD_JS
- made JS_LOWLEVEL_SOURCE work in jsdb
- added Unicode JSD_AppendUCSourceText to simplify shells
- some gratuitous whitespace reformatting


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11256 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-28 20:34:46 +00:00
mccabe%netscape.com
97a1eacae2 Propagate mcafee fix: Added Rhapsody to the long list of OS's that
can't handle localtime_r().


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11235 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-28 19:41:17 +00:00
jband%netscape.com
1061a7961a Source notes for line numbers are generated at the top of js_EmitTree. The code generation in the TOK_TRY case was bypassing this code (i.e. emitting code for source lines before recursing into js_EmitTree). So, I brokeout that linenumber code into a macro to be inlined at the top of js_EmitTree and also into a static function that can be called elsewhere -- I didn't want to force an extra (and often unneeded) function call at the top of each invocation of js_EmitTree, nor inline 15 lines of code in a bunch of places, so this seemed a good compromise. This substantially fixes lineno errors in try/catch/finally code. There are still non-lineno problems in that code that shaver and coop are looking at - so this code in not final.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11210 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-28 08:02:43 +00:00
jband%netscape.com
95f197f31a function mis-declared as JS_FRIEND_DATA. changed to JS_FRIEND_API
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11209 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-28 07:51:21 +00:00
jband%netscape.com
aeb19b804e fix CompileTokenStream to always call js_CloseTokenStream. It was not doing so on syntax errors. This caused .js files loaded in the shell to be left open and would also fail to have JSPRINCIPALS_DROP be called in cases where principles are used.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11069 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-25 21:15:49 +00:00
norris%netscape.com
22b83ef992 Back out breaking change.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11017 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-25 04:36:13 +00:00
mccabe%netscape.com
cf89f9dbea Fix to xp problem on solaris. Use 1-argument form of gettimeofday #if
defined( SOLARIS ) - hack borrowed from ref/prtime.c.  Why wasn't it
needed in src/prmjtime.c previously?


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@11006 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-25 00:58:26 +00:00
norris%netscape.com
b9f52d961c Fix bug 299903 Inheriting from a Date object causes crash.
The test code is

     function MyDate() { this.foo = "bar"; }
     MyDate.prototype = new Date();
     x = new MyDate();
     print(x.toString())

The problem is that object x is created with an associated class of date_class, but with an undefined value in the private slot. Then when
date_getProlog is called on x, the JS_InstanceOf test passes since the class of the object is date_class, but then a bogus pointer is returned
since there isn't really a double in the private data slot.


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10983 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 23:30:36 +00:00
jband%netscape.com
b9b66713eb added build() to js.c to display date/time of build in shell. Uses __DATE__ and __TIME__ which are supposed to be ansi C -- tested on Windows and Linux
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10975 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 22:52:07 +00:00
fur%netscape.com
3287009b56 Added/deleted files to accomodate ref/src merge.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10903 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 07:44:22 +00:00
jband%netscape.com
d0ad9c946c last automatic conversion of js/ref/jsd to js/jsd based on fur's conversion system of js/ref to js/src
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10900 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 07:22:17 +00:00
jband%netscape.com
b3c707fd61 removed NETSCAPE_INTERNAL. Made JS_IsAssigning a JS_FRIEND_API with a warning in jsapi.h that the function might be removed in the future
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10899 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 07:17:59 +00:00
fur%netscape.com
03332fd3ac Final changes merged from js/ref
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10897 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 05:40:16 +00:00
fur%netscape.com
ef97812295 + Make JS1.4 build in Mozilla
+ Get rid of all uses of NSPR20 macro


git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10893 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 04:16:35 +00:00
fur%netscape.com
ca0614a7b6 Converted README to README.html
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10892 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 04:15:15 +00:00
fur%netscape.com
4c1594b677 Changes for merged js ref/src.
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10886 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 03:55:11 +00:00
fur%netscape.com
914637bd3e Fixed JS_FRIEND_* macros
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10882 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 03:18:10 +00:00
fur%netscape.com
91dbe3c171 Added extern C declarations for inclusion into C++
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10881 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 03:17:55 +00:00
fur%netscape.com
c3bd0c5f7d Fix PR_EXTERN
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10878 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-24 02:41:11 +00:00
jband%netscape.com
cff140c431 adding a PR_PUBLIC_XXX conversions back in
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10809 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 18:45:12 +00:00
fur%netscape.com
923990dd99 Updated dependencies
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10785 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 07:44:40 +00:00
fur%netscape.com
45291c870a More name substitutions for ref/src merge
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10784 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 07:40:51 +00:00
jband%netscape.com
33d0d8a72b improved makefiles. added javawrap
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10768 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 04:01:03 +00:00
fur%netscape.com
2066c6b9ce Got rid of OS-dependent header files. Everything is in jsosdep.h now
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10765 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 02:37:53 +00:00
jband%netscape.com
46e77ac0e1 change path make standalone debugger work
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10735 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 01:42:03 +00:00
jband%netscape.com
7507e060b5 moved from ref/samples. work with ref/src merged js. ripped out jsd and jsdebugger build stuff
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10734 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 01:23:33 +00:00
jband%netscape.com
1cc86f1b54 jsd to go with ref/src merge. first checkin of new java stuff and jsdb
git-svn-id: svn://10.0.0.236/branches/SpiderMonkey140_BRANCH@10733 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-23 01:22:09 +00:00
388 changed files with 51539 additions and 10533 deletions

18
mozilla/js/jsd/README Normal file
View File

@@ -0,0 +1,18 @@
/* jband - 10/26/98 - */
js/jsd contains code for debugging support for the C-based JavaScript engine
in js/src.
Currently the makefiles are for Win32 only (using MS nmake.exe from MSDEV 4.2).
jsd.mak will build a standalone dll. jsdshell.mak will build the dll and also
a version of the js/src/js.c shell which will launch a Java VM and run the
JavaSript Debugger (built in js/jsdj). This version assumes that you have a
JRE compatible JVM installed. Only Windows is supported for this Java-based
debugging.
Though only Windows makefiles are supplied, the basic code in js/jsd should
compile for other platforms -- it is a newer version of code that builds and
ships with Communicator 4.x on many platforms.
js/jsd/jsdb is a console debugger using only native code (see README in that
directory)

View File

@@ -16,26 +16,20 @@
* Reserved.
*/
#ifndef nspr_linux_defs_h___
#define nspr_linux_defs_h___
/*
* This supplies non-functional stubs for a couple of JNI functions we need
* in order to link LiveConnect
*/
#include <linux/autoconf.h>
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#include "jni.h"
/*
* ELF linux supports dl* functions.
* Allow ELF functions for static or modular ELF support.
*/
#if defined(CONFIG_BINFMT_ELF) || defined(CONFIG_BINFMT_ELF_MODULE)
#define HAVE_DLL
#define USE_DLFCN
#else
#undef HAVE_DLL
#undef USE_DLFCN
#endif
jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * ignored)
{
return 0;
}
#define NEED_TIME_R
jint JNICALL JNI_CreateJavaVM(JavaVM ** vm, JNIEnv ** env, void * ignored)
{
return 0;
}
#endif /* nspr_linux_defs_h___ */

View File

@@ -0,0 +1,33 @@
JSDJNI = .
#CLASS_DIR_BASE = $(JSDJNI)\..\..\..\jsdj\dist\classes
# until jsdj moves to mozilla...
CLASS_DIR_BASE = $(JSDJNI)\..\..\..\..\..\ns\js\jsdj\dist\classes
GEN = $(JSDJNI)\_jni
HEADER_FILE = $(GEN)\jsdjnih.h
PACKAGE_SLASH = netscape\jsdebug
PACKAGE_DOT = netscape.jsdebug
STD_CLASSPATH = -classpath $(CLASS_DIR_BASE);$(CLASSPATH)
CLASSES_WITH_NATIVES = \
$(PACKAGE_DOT).DebugController \
$(PACKAGE_DOT).JSPC \
$(PACKAGE_DOT).JSSourceTextProvider \
$(PACKAGE_DOT).JSStackFrameInfo \
$(PACKAGE_DOT).JSThreadState \
$(PACKAGE_DOT).Script \
$(PACKAGE_DOT).SourceTextProvider \
$(PACKAGE_DOT).ThreadStateBase \
$(PACKAGE_DOT).Value
all: $(GEN)
@echo generating JNI headers
@javah -jni -o "$(HEADER_FILE)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
$(GEN) :
@mkdir $(GEN)
clean:
@if exist $(HEADER_FILE) @del $(HEADER_FILE) > NUL

View File

@@ -0,0 +1,134 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
* Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/*
* Portable JRE support functions - pared this down to minimal set I need
*/
#include <string.h>
#include <stdlib.h>
#include <jni.h>
#include "jre.h"
/*
* Exits the runtime with the specified error message.
*/
void
JRE_FatalError(JNIEnv *env, const char *msg)
{
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
}
(*env)->FatalError(env, msg);
}
/*
* Parses a runtime version string. Returns 0 if the successful, otherwise
* returns -1 if the format of the version string was invalid.
*/
jint
JRE_ParseVersion(const char *ver, char **majorp, char **minorp, char **microp)
{
int n1 = 0, n2 = 0, n3 = 0;
sscanf(ver, "%*[0-9]%n.%*[0-9]%n.%*[0-9a-zA-Z]%n", &n1, &n2, &n3);
if (n1 == 0 || n2 == 0) {
return -1;
}
if (n3 != 0) {
if (n3 != (int)strlen(ver)) {
return -1;
}
} else if (n2 != (int)strlen(ver)) {
return -1;
}
*majorp = JRE_Malloc(n1 + 1);
strncpy(*majorp, ver, n1);
(*majorp)[n1] = 0;
*minorp = JRE_Malloc(n2 - n1);
strncpy(*minorp, ver + n1 + 1, n2 - n1 - 1);
(*minorp)[n2 - n1 - 1] = 0;
if (n3 != 0) {
*microp = JRE_Malloc(n3 - n2);
strncpy(*microp, ver + n2 + 1, n3 - n2 - 1);
(*microp)[n3 - n2 - 1] = 0;
}
return 0;
}
/*
* Creates a version number string from the specified major, minor, and
* micro version numbers.
*/
char *
JRE_MakeVersion(const char *major, const char *minor, const char *micro)
{
char *ver = 0;
if (major != 0 && minor != 0) {
int len = strlen(major) + strlen(minor);
if (micro != 0) {
ver = JRE_Malloc(len + strlen(micro) + 3);
sprintf(ver, "%s.%s.%s", major, minor, micro);
} else {
ver = JRE_Malloc(len + 2);
sprintf(ver, "%s.%s", major, minor);
}
}
return ver;
}
/*
* Allocate memory or die.
*/
void *
JRE_Malloc(size_t size)
{
void *p = malloc(size);
if (p == 0) {
perror("malloc");
exit(1);
}
return p;
}

View File

@@ -0,0 +1,85 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
* Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/*
* Portable JRE support functions - pared this down to minimal set I need
*/
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "jre_md.h"
/*
* Java runtime settings.
*/
typedef struct JRESettings {
char *javaHome; /* Java home directory */
char *runtimeLib; /* Runtime shared library or DLL */
char *classPath; /* Default class path */
char *compiler; /* Just-in-time (JIT) compiler */
char *majorVersion; /* Major version of runtime */
char *minorVersion; /* Minor version of runtime */
char *microVersion; /* Micro version of runtime */
} JRESettings;
/*
* JRE functions.
*/
void *JRE_LoadLibrary(const char *path);
void JRE_UnloadLibrary(void *handle);
jint JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargsp);
jint JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp,
void *vmargsp);
jint JRE_GetCurrentSettings(JRESettings *set);
jint JRE_GetSettings(JRESettings *set, const char *ver);
jint JRE_GetDefaultSettings(JRESettings *set);
jint JRE_ParseVersion(const char *version,
char **majorp, char **minorp, char **microp);
char *JRE_MakeVersion(const char *major, const char *minor, const char *micro);
void *JRE_Malloc(size_t size);
void JRE_FatalError(JNIEnv *env, const char *msg);
char *JRE_GetDefaultRuntimeLib(const char *dir);
char *JRE_GetDefaultClassPath(const char *dir);

View File

@@ -0,0 +1,290 @@
/*
* @(#)jre_md.c 1.6 97/05/15 David Connelly
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/*
* Win32 specific JRE support functions
*/
#include <windows.h>
#include <stdlib.h>
#include <jni.h>
#include "jre.h"
#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment"
#define JDK_KEY "Software\\JavaSoft\\Java Development Kit"
#define RUNTIME_LIB "javai.dll"
/* From jre_main.c */
extern jboolean debug;
/* Forward Declarations */
jint LoadSettings(JRESettings *set, HKEY key);
jint GetSettings(JRESettings *set, const char *version, const char *keyname);
char *GetStringValue(HKEY key, const char *name);
/*
* Retrieve settings from registry for current runtime version. Returns
* 0 if successful otherwise returns -1 if no installed runtime was found
* or the registry data was invalid.
*/
jint
JRE_GetCurrentSettings(JRESettings *set)
{
jint r = -1;
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) == 0) {
char *ver = GetStringValue(key, "CurrentVersion");
if (ver != 0) {
r = JRE_GetSettings(set, ver);
}
free(ver);
RegCloseKey(key);
}
return r;
}
/*
* Retrieves settings from registry for specified runtime version.
* Searches for either installed JRE and JDK runtimes. Returns 0 if
* successful otherwise returns -1 if requested version of runtime
* could not be found.
*/
jint
JRE_GetSettings(JRESettings *set, const char *version)
{
if (GetSettings(set, version, JRE_KEY) != 0) {
return GetSettings(set, version, JDK_KEY);
}
return 0;
}
jint
GetSettings(JRESettings *set, const char *version, const char *keyname)
{
HKEY key;
int r = -1;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &key) == 0) {
char *major, *minor, *micro = 0;
if (JRE_ParseVersion(version, &major, &minor, &micro) == 0) {
HKEY subkey;
char *ver = JRE_MakeVersion(major, minor, 0);
set->majorVersion = major;
set->minorVersion = minor;
if (RegOpenKeyEx(key, ver, 0, KEY_READ, &subkey) == 0) {
if ((r = LoadSettings(set, subkey)) == 0) {
if (micro != 0) {
if (set->microVersion == 0 ||
strcmp(micro, set->microVersion) != 0) {
r = -1;
}
}
}
RegCloseKey(subkey);
}
free(ver);
}
RegCloseKey(key);
}
return r;
}
/*
* Load runtime settings from specified registry key. Returns 0 if
* successful otherwise -1 if the registry data was invalid.
*/
static jint
LoadSettings(JRESettings *set, HKEY key)
{
/* Full path name of JRE home directory (required) */
set->javaHome = GetStringValue(key, "JavaHome");
if (set->javaHome == 0) {
return -1;
}
/* Full path name of JRE runtime DLL */
set->runtimeLib = GetStringValue(key, "RuntimeLib");
if (set->runtimeLib == 0) {
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
}
/* Class path setting to override default */
set->classPath = GetStringValue(key, "ClassPath");
if (set->classPath == 0) {
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
}
/* Optional JIT compiler library name */
set->compiler = GetStringValue(key, "Compiler");
/* Release micro-version */
set->microVersion = GetStringValue(key, "MicroVersion");
return 0;
}
/*
* Returns string data for the specified registry value name, or
* NULL if not found.
*/
static char *
GetStringValue(HKEY key, const char *name)
{
DWORD type, size;
char *value = 0;
if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 &&
type == REG_SZ ) {
value = JRE_Malloc(size);
if (RegQueryValueEx(key, name, 0, 0, value, &size) != 0) {
free(value);
value = 0;
}
}
return value;
}
/*
* Returns default runtime settings based on location of this program.
* Makes best attempt at determining location of runtime. Returns 0
* if successful or -1 if a runtime could not be found.
*/
jint
JRE_GetDefaultSettings(JRESettings *set)
{
char buf[MAX_PATH], *bp;
int n;
// Try to obtain default value for Java home directory based on
// location of this executable.
if ((n = GetModuleFileName(0, buf, MAX_PATH)) == 0) {
return -1;
}
bp = buf + n;
while (*--bp != '\\') ;
bp -= 4;
if (bp < buf || strnicmp(bp, "\\bin", 4) != 0) {
return -1;
}
*bp = '\0';
set->javaHome = strdup(buf);
// Get default runtime library
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
// Get default class path
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
// Reset other fields since these are unknown
set->compiler = 0;
set->majorVersion = 0;
set->minorVersion = 0;
set->microVersion = 0;
return 0;
}
/*
* Return default runtime library for specified Java home directory.
*/
char *
JRE_GetDefaultRuntimeLib(const char *dir)
{
char *cp = JRE_Malloc(strlen(dir) + sizeof(RUNTIME_LIB) + 8);
sprintf(cp, "%s\\bin\\" RUNTIME_LIB, dir);
return cp;
}
/*
* Return default class path for specified Java home directory.
*/
char *
JRE_GetDefaultClassPath(const char *dir)
{
char *cp = JRE_Malloc(strlen(dir) * 4 + 64);
sprintf(cp, "%s\\lib\\rt.jar;%s\\lib\\i18n.jar;%s\\lib\\classes.zip;"
"%s\\classes", dir, dir, dir, dir);
return cp;
}
/*
* Loads the runtime library corresponding to 'libname' and returns
* an opaque handle to the library.
*/
void *
JRE_LoadLibrary(const char *path)
{
return (void *)LoadLibrary(path);
}
/*
* Unloads the runtime library associated with handle.
*/
void
JRE_UnloadLibrary(void *handle)
{
FreeLibrary(handle);
}
/*
* Loads default VM args for the specified runtime library handle.
*/
jint
JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargs)
{
FARPROC proc = GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
return proc != 0 ? ((*proc)(vmargs), 0) : -1;
}
/*
* Creates a Java VM for the specified runtime library handle.
*/
jint
JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp, void *vmargs)
{
FARPROC proc = GetProcAddress(handle, "JNI_CreateJavaVM");
return proc != 0 ? (*proc)(vmp, envp, vmargs) : -1;
}
/*
* Entry point for JREW (Windows-only) version of the runtime loader.
* This entry point is called when the '-subsystem:windows' linker
* option is used, and will cause the resulting executable to run
* detached from the console.
*/
/**
* int WINAPI
* WinMain(HINSTANCE inst, HINSTANCE prevInst, LPSTR cmdLine, int cmdShow)
* {
* __declspec(dllimport) char **__initenv;
*
* __initenv = _environ;
* exit(main(__argc, __argv));
* }
*/

View File

@@ -0,0 +1,36 @@
/*
* @(#)jre_md.h 1.1 97/05/19 David Connelly
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/*
* Win32 specific JRE support definitions
*/
#define FILE_SEPARATOR '\\'
#define PATH_SEPARATOR ';'

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,349 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
* Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
*/
/*
* Code to start a Java VM (*some* code from the JRE)
*/
#include "jsdj.h"
/***************************************************************************/
#ifdef JSD_STANDALONE_JAVA_VM
#include "jre.h"
static char* more_classpath[] =
{
{"..\\..\\jsdj\\dist\\classes"},
{"..\\..\\jsdj\\dist\\classes\\ifc11.jar"},
/*
* {"..\\..\\..\\jsdj\\dist\\classes"},
* {"..\\..\\..\\jsdj\\dist\\classes\\ifc12.jar"},
*/
/*
* {"..\\..\\samples\\jslogger"},
* {"classes"},
* {"ifc12.jar"},
* {"jsd10.jar"},
* {"jsdeb15.jar"}
*/
};
#define MORE_CLASSPATH_COUNT (sizeof(more_classpath)/sizeof(more_classpath[0]))
/*
* static char main_class[] = "callnative";
* static char main_class[] = "simpleIFC";
* static char* params[] = {"16 Dec 1997"};
* #define PARAM_COUNT (sizeof(params)/sizeof(params[0]))
*/
/*
* static char main_class[] = "netscape/jslogger/JSLogger";
* static char main_class[] = "LaunchJSDebugger";
*/
static char main_class[] = "com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger";
static char* params[] = {NULL};
#define PARAM_COUNT 0
/* Globals */
static char **props; /* User-defined properties */
static int numProps, maxProps; /* Current, max number of properties */
static void *handle;
static JavaVM *jvm;
static JNIEnv *env;
/* Check for null value and return */
#define NULL_CHECK(e) if ((e) == 0) return 0
/*
* Adds a user-defined system property definition.
*/
void AddProperty(char *def)
{
if (numProps >= maxProps) {
if (props == 0) {
maxProps = 4;
props = JRE_Malloc(maxProps * sizeof(char **));
} else {
char **tmp;
maxProps *= 2;
tmp = JRE_Malloc(maxProps * sizeof(char **));
memcpy(tmp, props, numProps * sizeof(char **));
free(props);
props = tmp;
}
}
props[numProps++] = def;
}
/*
* Deletes a property definition by name.
*/
void DeleteProperty(const char *name)
{
int i;
for (i = 0; i < numProps; ) {
char *def = props[i];
char *c = strchr(def, '=');
int n;
if (c != 0) {
n = c - def;
} else {
n = strlen(def);
}
if (strncmp(name, def, n) == 0) {
if (i < --numProps) {
memmove(&props[i], &props[i+1], (numProps-i) * sizeof(char **));
}
} else {
i++;
}
}
}
/*
* Creates an array of Java string objects from the specified array of C
* strings. Returns 0 if the array could not be created.
*/
jarray NewStringArray(JNIEnv *env, char **cpp, int count)
{
jclass cls;
jarray ary;
int i;
NULL_CHECK(cls = (*env)->FindClass(env, "java/lang/String"));
NULL_CHECK(ary = (*env)->NewObjectArray(env, count, cls, 0));
for (i = 0; i < count; i++) {
jstring str = (*env)->NewStringUTF(env, *cpp++);
NULL_CHECK(str);
(*env)->SetObjectArrayElement(env, ary, i, str);
(*env)->DeleteLocalRef(env, str);
}
return ary;
}
/***************************************************************************/
static JNIEnv*
_CreateJavaVM(void)
{
JNIEnv* env = NULL;
JDK1_1InitArgs vmargs;
JRESettings set;
printf("Starting Java...\n");
if(JRE_GetCurrentSettings(&set) != 0)
{
if(JRE_GetDefaultSettings(&set) != 0)
{
fprintf(stderr, "Could not locate Java runtime\n");
return NULL;
}
}
/* Load runtime library */
handle = JRE_LoadLibrary(set.runtimeLib);
if (handle == 0) {
fprintf(stderr, "Could not load runtime library: %s\n",
set.runtimeLib);
return NULL;
}
/* Add pre-defined system properties */
if (set.javaHome != 0) {
char *def = JRE_Malloc(strlen(set.javaHome) + 16);
sprintf(def, "java.home=%s", set.javaHome);
AddProperty(def);
}
if (set.compiler != 0) {
char *def = JRE_Malloc(strlen(set.compiler) + 16);
sprintf(def, "java.compiler=%s", set.compiler);
AddProperty(def);
}
/*
* The following is used to specify that we require at least
* JNI version 1.1. Currently, this field is not checked but
* will be starting with JDK/JRE 1.2. The value returned after
* calling JNI_GetDefaultJavaVMInitArgs() is the actual JNI version
* supported, and is always higher that the requested version.
*/
vmargs.version = 0x00010001;
if (JRE_GetDefaultJavaVMInitArgs(handle, &vmargs) != 0) {
fprintf(stderr, "Could not initialize Java VM\n");
return NULL;
}
/* Tack on our classpath */
if(MORE_CLASSPATH_COUNT)
{
int i;
int size = strlen(set.classPath) + 1;
char sep[2];
sep[0] = PATH_SEPARATOR;
sep[1] = 0;
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
size += strlen(more_classpath[i]) + 1;
vmargs.classpath = malloc(size);
if(vmargs.classpath == 0)
{
fprintf(stderr, "malloc error\n");
return NULL;
}
strcpy(vmargs.classpath, set.classPath);
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
{
strcat(vmargs.classpath, sep);
strcat(vmargs.classpath, more_classpath[i]);
}
}
else
{
vmargs.classpath = set.classPath;
}
/*
* fprintf(stderr, "classpath: %s\n", vmargs.classpath);
*/
/* Set user-defined system properties for Java VM */
if (props != 0) {
if (numProps == maxProps) {
char **tmp = JRE_Malloc((numProps + 1) * sizeof(char **));
memcpy(tmp, props, numProps * sizeof(char **));
free(props);
props = tmp;
}
props[numProps] = 0;
vmargs.properties = props;
}
/* verbose? */
/*
* vmargs.verbose = JNI_TRUE;
*/
/* Load and initialize Java VM */
if (JRE_CreateJavaVM(handle, &jvm, &env, &vmargs) != 0) {
fprintf(stderr, "Could not create Java VM\n");
return NULL;
}
/* Free properties */
if (props != 0) {
free(props);
}
return env;
}
static JSBool
_StartDebuggerFE(JNIEnv* env)
{
jclass clazz;
jmethodID mid;
jarray args;
/* Find class */
clazz = (*env)->FindClass(env, main_class);
if (clazz == 0) {
fprintf(stderr, "Class not found: %s\n", main_class);
return JS_FALSE;
}
/* Find main method of class */
mid = (*env)->GetStaticMethodID(env, clazz, "main",
"([Ljava/lang/String;)V");
if (mid == 0) {
fprintf(stderr, "In class %s: public static void main(String args[])"
" is not defined\n");
return JS_FALSE;
}
/* Invoke main method */
args = NewStringArray(env, params, PARAM_COUNT);
if (args == 0) {
JRE_FatalError(env, "Couldn't build argument list for main\n");
}
(*env)->CallStaticVoidMethod(env, clazz, mid, args);
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
}
return JS_TRUE;
}
JNIEnv*
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
{
JNIEnv* env = NULL;
env = _CreateJavaVM();
if( ! env )
return NULL;
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
if( ! jsdj_RegisterNatives(jsdjc) )
return NULL;
if( ! _StartDebuggerFE(env) )
return NULL;
return env;
}
#endif /* JSD_STANDALONE_JAVA_VM */
/***************************************************************************/

147
mozilla/js/jsd/java/jsdj.h Normal file
View File

@@ -0,0 +1,147 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Header for JavaScript Debugger JNI support (internal functions)
*/
#ifndef jsdj_h___
#define jsdj_h___
/* Get jstypes.h included first. After that we can use PR macros for doing
* this extern "C" stuff!
*/
#ifdef __cplusplus
extern "C"
{
#endif
#include "jstypes.h"
#ifdef __cplusplus
}
#endif
JS_BEGIN_EXTERN_C
#include "jsutil.h" /* Added by JSIFY */
#include "jshash.h" /* Added by JSIFY */
#include "jsdjava.h"
#include "jsobj.h"
#include "jsfun.h"
#include "jsdbgapi.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
JS_END_EXTERN_C
JS_BEGIN_EXTERN_C
/***************************************************************************/
/* defines copied from Java sources.
** NOTE: javah used to put these in the h files, but with JNI does not seem
** to do this anymore. Be careful with synchronization of these
**
*/
/* From: ThreadStateBase.java */
#define THR_STATUS_UNKNOWN 0x01
#define THR_STATUS_ZOMBIE 0x02
#define THR_STATUS_RUNNING 0x03
#define THR_STATUS_SLEEPING 0x04
#define THR_STATUS_MONWAIT 0x05
#define THR_STATUS_CONDWAIT 0x06
#define THR_STATUS_SUSPENDED 0x07
#define THR_STATUS_BREAK 0x08
#define DEBUG_STATE_DEAD 0x01
#define DEBUG_STATE_RUN 0x02
#define DEBUG_STATE_RETURN 0x03
#define DEBUG_STATE_THROW 0x04
/***************************************************************************/
/* Our structures */
typedef struct JSDJContext
{
JSDContext* jsdc;
JSHashTable* envTable;
jobject controller;
JSDJ_UserCallbacks callbacks;
void* user;
JSBool ownJSDC;
} JSDJContext;
/***************************************************************************/
/* Code validation support */
#ifdef DEBUG
extern void JSDJ_ASSERT_VALID_CONTEXT(JSDJContext* jsdjc);
#else
#define JSDJ_ASSERT_VALID_CONTEXT(x) ((void)0)
#endif
/***************************************************************************/
/* higher level functions */
extern JSDJContext*
jsdj_SimpleInitForSingleContextMode(JSDContext* jsdc,
JSDJ_GetJNIEnvProc getEnvProc, void* user);
extern JSBool
jsdj_SetSingleContextMode();
extern JSDJContext*
jsdj_CreateContext();
extern void
jsdj_DestroyContext(JSDJContext* jsdjc);
extern void
jsdj_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
void* user);
extern void
jsdj_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
extern JNIEnv*
jsdj_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
extern void
jsdj_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
extern JSDContext*
jsdj_GetJSDContext(JSDJContext* jsdjc);
extern JSBool
jsdj_RegisterNatives(JSDJContext* jsdjc);
/***************************************************************************/
#ifdef JSD_STANDALONE_JAVA_VM
extern JNIEnv*
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
/**
* extern JNIEnv*
* jsdj_CreateJavaVM(JSDContext* jsdc);
*/
#endif /* JSD_STANDALONE_JAVA_VM */
/***************************************************************************/
JS_END_EXTERN_C
#endif /* jsdj_h___ */

View File

@@ -0,0 +1,110 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Public functions to reflect JSD into Java
*/
#include "jsdj.h"
JSDJ_PUBLIC_API(JSDJContext*)
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
JSDJ_GetJNIEnvProc getEnvProc, void* user)
{
return jsdj_SimpleInitForSingleContextMode(jsdc, getEnvProc, user);
}
JSDJ_PUBLIC_API(JSBool)
JSDJ_SetSingleContextMode()
{
return jsdj_SetSingleContextMode();
}
JSDJ_PUBLIC_API(JSDJContext*)
JSDJ_CreateContext()
{
return jsdj_CreateContext();
}
JSDJ_PUBLIC_API(void)
JSDJ_DestroyContext(JSDJContext* jsdjc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
jsdj_DestroyContext(jsdjc);
}
JSDJ_PUBLIC_API(void)
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
void* user)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
JS_ASSERT(!callbacks ||
(callbacks->size > 0 &&
callbacks->size <= sizeof(JSDJ_UserCallbacks)));
jsdj_SetUserCallbacks(jsdjc, callbacks, user);
}
JSDJ_PUBLIC_API(void)
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
JS_ASSERT(env);
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
}
JSDJ_PUBLIC_API(JNIEnv*)
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
return jsdj_GetJNIEnvForCurrentThread(jsdjc);
}
JSDJ_PUBLIC_API(void)
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
JS_ASSERT(jsdc);
jsdj_SetJSDContext(jsdjc, jsdc);
}
JSDJ_PUBLIC_API(JSDContext*)
JSDJ_GetJSDContext(JSDJContext* jsdjc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
return jsdj_GetJSDContext(jsdjc);
}
JSDJ_PUBLIC_API(JSBool)
JSDJ_RegisterNatives(JSDJContext* jsdjc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
return jsdj_RegisterNatives(jsdjc);
}
/***************************************************************************/
#ifdef JSD_STANDALONE_JAVA_VM
JSDJ_PUBLIC_API(JNIEnv*)
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
{
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
return jsdj_CreateJavaVMAndStartDebugger(jsdjc);
}
#endif /* JSD_STANDALONE_JAVA_VM */
/***************************************************************************/

View File

@@ -0,0 +1,133 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Header for JavaScript Debugger JNI interfaces
*/
#ifndef jsdjava_h___
#define jsdjava_h___
/* Get jstypes.h included first. After that we can use PR macros for doing
* this extern "C" stuff!
*/
#ifdef __cplusplus
extern "C"
{
#endif
#include "jstypes.h"
#ifdef __cplusplus
}
#endif
JS_BEGIN_EXTERN_C
#include "jsdebug.h"
#include "jni.h"
JS_END_EXTERN_C
JS_BEGIN_EXTERN_C
/*
* The linkage of JSDJ API functions differs depending on whether the file is
* used within the JSDJ library or not. Any source file within the JSDJ
* libraray should define EXPORT_JSDJ_API whereas any client of the library
* should not.
*/
#ifdef EXPORT_JSDJ_API
#define JSDJ_PUBLIC_API(t) JS_EXPORT_API(t)
#define JSDJ_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
#else
#define JSDJ_PUBLIC_API(t) JS_IMPORT_API(t)
#define JSDJ_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
#endif
#define JSDJ_FRIEND_API(t) JSDJ_PUBLIC_API(t)
#define JSDJ_FRIEND_DATA(t) JSDJ_PUBLIC_DATA(t)
/***************************************************************************/
/* Opaque typedefs for handles */
typedef struct JSDJContext JSDJContext;
/***************************************************************************/
/* High Level functions */
#define JSDJ_START_SUCCESS 1
#define JSDJ_START_FAILURE 2
#define JSDJ_STOP 3
typedef void
(*JSDJ_StartStopProc)(JSDJContext* jsdjc, int event, void *user);
typedef JNIEnv*
(*JSDJ_GetJNIEnvProc)(JSDJContext* jsdjc, void* user);
/* This struct could have more fields in future versions */
typedef struct
{
uintN size; /* size of this struct (init before use)*/
JSDJ_StartStopProc startStop;
JSDJ_GetJNIEnvProc getJNIEnv;
} JSDJ_UserCallbacks;
extern JSDJ_PUBLIC_API(JSDJContext*)
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
JSDJ_GetJNIEnvProc getEnvProc, void* user);
extern JSDJ_PUBLIC_API(JSBool)
JSDJ_SetSingleContextMode();
extern JSDJ_PUBLIC_API(JSDJContext*)
JSDJ_CreateContext();
extern JSDJ_PUBLIC_API(void)
JSDJ_DestroyContext(JSDJContext* jsdjc);
extern JSDJ_PUBLIC_API(void)
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
void* user);
extern JSDJ_PUBLIC_API(void)
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
extern JSDJ_PUBLIC_API(JNIEnv*)
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
extern JSDJ_PUBLIC_API(void)
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
extern JSDJ_PUBLIC_API(JSDContext*)
JSDJ_GetJSDContext(JSDJContext* jsdjc);
extern JSDJ_PUBLIC_API(JSBool)
JSDJ_RegisterNatives(JSDJContext* jsdjc);
/***************************************************************************/
#ifdef JSD_STANDALONE_JAVA_VM
extern JSDJ_PUBLIC_API(JNIEnv*)
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
#endif /* JSD_STANDALONE_JAVA_VM */
/***************************************************************************/
JS_END_EXTERN_C
#endif /* jsdjava_h___ */

View File

@@ -0,0 +1,78 @@
PROJ = jsdjava
JSDJAVA = .
JSD = $(JSDJAVA)\..
JS = $(JSD)\..\src
JSPROJ = js32
JSDPROJ = jsd
!IF "$(BUILD_OPT)" != ""
OBJ = Release
CC_FLAGS = /DNDEBUG
!ELSE
OBJ = Debug
CC_FLAGS = /DDEBUG
LINK_FLAGS = /DEBUG
!ENDIF
QUIET=@
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/I $(JS)\
/I $(JSD)\
/I $(JSDJAVA)\
/DDEBUG /DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
/DJSD_THREADSAFE\
/DEXPORT_JSDJ_API\
/DJSDEBUGGER\
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
/I $(JSDJAVA)\jre\
/I $(JSDJAVA)\jre\win32\
/DJSD_STANDALONE_JAVA_VM\
!ENDIF
$(CC_FLAGS)\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
LLIBS = kernel32.lib advapi32.lib \
$(JS)\$(OBJ)\$(JSPROJ).lib $(JSD)\$(OBJ)\$(JSDPROJ).lib
CPP=cl.exe
LINK32=link.exe
all: $(OBJ) $(OBJ)\$(PROJ).dll
$(OBJ)\$(PROJ).dll: \
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
$(OBJ)\jsd_jvm.obj \
$(OBJ)\jre.obj \
$(OBJ)\jre_md.obj \
!ENDIF
$(OBJ)\jsdjava.obj \
$(OBJ)\jsd_jntv.obj
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
{$(JSDJAVA)}.c{$(OBJ)}.obj :
$(QUIET)$(CPP) $(CFLAGS)
{$(JSDJAVA)\jre}.c{$(OBJ)}.obj :
$(QUIET)$(CPP) $(CFLAGS)
{$(JSDJAVA)\jre\win32}.c{$(OBJ)}.obj :
$(QUIET)$(CPP) $(CFLAGS)
$(OBJ) :
$(QUIET)mkdir $(OBJ)
clean:
@echo deleting old output
$(QUIET)del $(OBJ)\*.pch >NUL
$(QUIET)del $(OBJ)\*.obj >NUL
$(QUIET)del $(OBJ)\*.exp >NUL
$(QUIET)del $(OBJ)\*.lib >NUL
$(QUIET)del $(OBJ)\*.idb >NUL
$(QUIET)del $(OBJ)\*.pdb >NUL
$(QUIET)del $(OBJ)\*.dll >NUL

View File

@@ -0,0 +1,147 @@
PROJ = nativejsengine
PACKAGE_DOT = com.netscape.nativejsengine
NJSE = .
TESTS = $(NJSE)\tests
GEN = $(NJSE)\_jni
JSD = $(NJSE)\..
JS = $(JSD)\..\src
JSDJAVA = $(JSD)\java
JSPROJ = js32
JSDPROJ = jsd
JSDJAVAPROJ = jsdjava
EXPORT_BIN_BASE_DIR = $(NJSE)\..\..\jsdj\dist\bin
EXPORT_CLASSES_BASE_DIR = $(NJSE)\..\..\jsdj\dist\classes
!IF "$(BUILD_OPT)" != ""
OBJ = Release
CC_FLAGS = /DNDEBUG
!ELSE
OBJ = Debug
CC_FLAGS = /DDEBUG
LINK_FLAGS = /DEBUG
!ENDIF
QUIET=@
EXPORT_BIN_DIR = $(EXPORT_BIN_BASE_DIR)\$(OBJ)
STD_CLASSPATH = -classpath $(EXPORT_CLASSES_BASE_DIR);$(CLASSPATH)
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
/I $(JS)\
/I $(JSD)\
/I $(JSDJAVA)\
/DJSDEBUGGER\
/DJSD_THREADSAFE\
$(CC_FLAGS)\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:console /incremental:no /DLL /machine:I386 \
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
LLIBS = kernel32.lib advapi32.lib \
$(JS)\$(OBJ)\$(JSPROJ).lib \
$(JSD)\$(OBJ)\$(JSDPROJ).lib \
$(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).lib
CPP=cl.exe
LINK32=link.exe
CLASSES_WITH_NATIVES = \
$(PACKAGE_DOT).JSRuntime\
$(PACKAGE_DOT).JSContext
all: $(GEN) $(OBJ) dlls mkjniheaders $(OBJ)\$(PROJ).dll export_binaries
$(OBJ)\$(PROJ).dll: \
$(OBJ)\nativejsengine.obj
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
.c{$(OBJ)}.obj:
$(QUIET)$(CPP) $(CFLAGS)
$(GEN) :
@mkdir $(GEN)
$(OBJ) :
@mkdir $(OBJ)
dlls :
$(QUIET)cd ..\..\src
!IF "$(BUILD_OPT)" != ""
$(QUIET)nmake -f js.mak CFG="js - Win32 Release"
!ELSE
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug"
!ENDIF
$(QUIET)cd ..\jsd\javawrap
$(QUIET)cd ..
$(QUIET)nmake -f jsd.mak JSD_THREADSAFE=1 $(OPT)
$(QUIET)cd javawrap
$(QUIET)cd ..\java
$(QUIET)nmake -f jsdjava.mak $(OPT)
$(QUIET)cd ..\javawrap
export_binaries : mk_export_dirs
@echo exporting binaries
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).dll $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).dll $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).pdb $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(OBJ)\$(PROJ).pdb $(EXPORT_BIN_DIR) >NUL
$(QUIET)copy $(OBJ)\$(PROJ).dll $(EXPORT_BIN_DIR) >NUL
mkjniheaders :
@echo generating JNI header
$(QUIET)javah -jni -d "$(GEN)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
@touch *.c >NUL
mk_export_dirs:
@if not exist $(JS)\..\jsdj\dist\NUL @mkdir $(JS)\..\jsdj\dist
@if not exist $(JS)\..\jsdj\dist\bin\NUL @mkdir $(JS)\..\jsdj\dist\bin
@if not exist $(EXPORT_BIN_DIR)\NUL @mkdir $(EXPORT_BIN_DIR)
#mktest :
# @echo compiling Java test file
# @sj $(JAVAFLAGS) $(TEST_CLASSPATH) $(TESTS)\Main.java
# @echo copying js and jsd dlls
# @copy $(JS)\$(OBJ)\$(JSPROJ).dll $(OBJ) >NUL
# @copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(OBJ) >NUL
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(OBJ) >NUL
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(OBJ) >NUL
# @copy $(TESTS)\*.js $(OBJ) >NUL
clean:
@echo deleting old output
$(QUIET)del $(OBJ)\*.pch >NUL
$(QUIET)del $(OBJ)\*.obj >NUL
$(QUIET)del $(OBJ)\*.exp >NUL
$(QUIET)del $(OBJ)\*.lib >NUL
$(QUIET)del $(OBJ)\*.idb >NUL
$(QUIET)del $(OBJ)\*.pdb >NUL
$(QUIET)del $(OBJ)\*.dll >NUL
$(QUIET)del $(GEN)\*.h >NUL
deep_clean: clean
$(QUIET)cd ..\..\src
!IF "$(BUILD_OPT)" != ""
$(QUIET)nmake -f js.mak CFG="js - Win32 Release" clean
!ELSE
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug" clean
!ENDIF
$(QUIET)cd ..\jsd\javawrap
$(QUIET)cd ..
$(QUIET)nmake -f jsd.mak clean
$(QUIET)cd javawrap
$(QUIET)cd ..\java
$(QUIET)nmake -f jsdjava.mak clean
$(QUIET)cd ..\javawrap

1
mozilla/js/jsd/javawrap/mk.bat Executable file
View File

@@ -0,0 +1 @@
nmake -f javawrap.mak %1 %2 %3 %4 %5

View File

@@ -0,0 +1,616 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "_jni/com_netscape_nativejsengine_JSRuntime.h"
#include "_jni/com_netscape_nativejsengine_JSContext.h"
#include "jsapi.h"
#include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */
#ifdef JSDEBUGGER
#include "jsdebug.h"
#include "jsdjava.h"
#endif
/***************************************************************************/
#define ASSERT_RETURN_VOID(x) \
JS_BEGIN_MACRO \
if(!(x)) \
{ \
JS_ASSERT(0); \
return; \
} \
JS_END_MACRO
#define ASSERT_RETURN_VALUE(x,v)\
JS_BEGIN_MACRO \
if(!(x)) \
{ \
JS_ASSERT(0); \
return v; \
} \
JS_END_MACRO
#define CHECK_RETURN_VOID(x) \
JS_BEGIN_MACRO \
if(!(x)) \
{ \
return; \
} \
JS_END_MACRO
#define CHECK_RETURN_VALUE(x,v) \
JS_BEGIN_MACRO \
if(!(x)) \
{ \
return v; \
} \
JS_END_MACRO
#define ASSERT_GOTO(x,w) \
JS_BEGIN_MACRO \
if(!(x)) \
{ \
JS_ASSERT(0); \
goto w; \
} \
JS_END_MACRO
#define CHECK_GOTO(x,w) \
JS_BEGIN_MACRO \
if(!(x)) \
{ \
goto w; \
} \
JS_END_MACRO
#ifdef DEBUG
#define ASSERT_CLEAR_EXCEPTION(e) \
JS_BEGIN_MACRO \
if((*e)->ExceptionOccurred(e)) \
{ \
(*e)->ExceptionDescribe(e); \
JS_ASSERT(0); \
} \
(*e)->ExceptionClear(e); \
JS_END_MACRO
#else /* ! DEBUG */
#define ASSERT_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
#endif /* DEBUG */
#define CHECK_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
/***************************************************************************/
typedef struct ContextInfo {
JNIEnv* env;
jobject contextObject;
} ContextInfo;
/***************************************************************************/
#ifdef JSDEBUGGER
static void
_jamSourceIntoJSD(JSContext *cx, const char* src, int len, const char* filename)
{
jclass clazz_self;
jclass clazz;
JSDJContext* jsdjc;
jobject rtObject;
jobject contextObject;
jmethodID mid;
jfieldID fid;
ContextInfo* info;
JNIEnv* env;
info = (ContextInfo*) JS_GetContextPrivate(cx);
ASSERT_RETURN_VOID(info);
env = info->env;
ASSERT_RETURN_VOID(env);
contextObject = info->contextObject;
ASSERT_RETURN_VOID(contextObject);
clazz_self = (*env)->GetObjectClass(env, contextObject);
ASSERT_RETURN_VOID(clazz_self);
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
"Lcom/netscape/nativejsengine/JSRuntime;");
ASSERT_RETURN_VOID(fid);
rtObject = (*env)->GetObjectField(env, contextObject, fid);
ASSERT_RETURN_VOID(rtObject);
clazz = (*env)->GetObjectClass(env, rtObject);
ASSERT_RETURN_VOID(clazz);
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
ASSERT_RETURN_VOID(mid);
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
if(jsdjc)
{
JSDContext* jsdc;
jsdc = JSDJ_GetJSDContext(jsdjc);
ASSERT_RETURN_VOID(jsdc);
JSD_AddFullSourceText(jsdc, src, len, filename);
}
}
#endif
static JSBool
_loadSingleFile(JSContext *cx, JSObject *obj, const char* filename)
{
char* buf;
FILE* file;
int file_len;
jsval result;
errno = 0;
file = fopen(filename, "rb");
if (!file) {
JS_ReportError(cx, "can't open %s: %s", filename, strerror(errno));
return JS_FALSE;
}
fseek(file, 0, SEEK_END);
file_len = ftell(file);
fseek(file, 0, SEEK_SET);
if(! file_len) {
fclose(file);
JS_ReportError(cx, "%s is empty", filename);
return JS_FALSE;
}
buf = (char*) malloc(file_len);
if(! buf) {
fclose(file);
JS_ReportError(cx, "memory alloc error while trying to read %s", filename);
return JS_FALSE;
}
fread(buf, 1, file_len, file);
fclose(file);
#ifdef JSDEBUGGER
_jamSourceIntoJSD(cx, buf, file_len, filename);
#endif
JS_EvaluateScript(cx, obj, buf, file_len, filename, 1, &result);
free(buf);
return JS_TRUE;
}
static void _sendPrintStringToJava(JNIEnv* env, jobject contextObject,
jmethodID mid, const char* str)
{
if(! str)
return;
(*env)->CallObjectMethod(env, contextObject, mid,
(*env)->NewStringUTF(env, str));
}
static JSBool
Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
uintN i, n;
JSString *str;
ContextInfo* info;
jmethodID mid;
jclass clazz;
JNIEnv* env;
info = (ContextInfo*) JS_GetContextPrivate(cx);
ASSERT_RETURN_VALUE(info, JS_FALSE);
env = info->env;
ASSERT_RETURN_VALUE(env, JS_FALSE);
clazz = (*env)->GetObjectClass(env, info->contextObject);
ASSERT_RETURN_VALUE(clazz, JS_FALSE);
mid = (*env)->GetMethodID(env, clazz, "_print", "(Ljava/lang/String;)V");
ASSERT_RETURN_VALUE(mid, JS_FALSE);
for (i = n = 0; i < argc; i++) {
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
if(i)
_sendPrintStringToJava(env, info->contextObject, mid, "");
_sendPrintStringToJava(env, info->contextObject, mid, JS_GetStringBytes(str));
n++;
}
if (n)
_sendPrintStringToJava(env, info->contextObject, mid, "\n");
return JS_TRUE;
}
static JSBool
Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
if (argc > 0 && JSVAL_IS_INT(argv[0]))
*rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVAL_TO_INT(argv[0])));
else
*rval = INT_TO_JSVAL(JS_GetVersion(cx));
return JS_TRUE;
}
static JSBool
Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
uintN i;
JSString *str;
const char *filename;
for (i = 0; i < argc; i++) {
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
argv[i] = STRING_TO_JSVAL(str);
filename = JS_GetStringBytes(str);
if(! _loadSingleFile(cx, obj, filename))
return JS_FALSE;
}
return JS_TRUE;
}
static JSFunctionSpec shell_functions[] = {
{"version", Version, 0},
{"load", Load, 1},
{"print", Print, 0},
{0}
};
static void
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
ContextInfo* info;
jmethodID mid;
jclass clazz;
JNIEnv* env;
jobject msg = NULL;
jobject filename = NULL;
jobject lineBuf = NULL;
int lineno = 0;
int offset = 0;
info = (ContextInfo*) JS_GetContextPrivate(cx);
ASSERT_RETURN_VOID(info);
env = info->env;
ASSERT_RETURN_VOID(env);
clazz = (*env)->GetObjectClass(env, info->contextObject);
ASSERT_RETURN_VOID(clazz);
mid = (*env)->GetMethodID(env, clazz, "_reportError",
"(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)V");
ASSERT_RETURN_VOID(mid);
if(message)
msg = (*env)->NewStringUTF(env, message);
if(report)
{
lineno = report->lineno;
if(report->filename)
filename = (*env)->NewStringUTF(env, report->filename);
if(report->linebuf)
{
lineBuf = (*env)->NewStringUTF(env, report->linebuf);
if(report->tokenptr)
offset = report->tokenptr - report->linebuf;
}
}
(*env)->CallObjectMethod(env, info->contextObject, mid,
msg, filename, lineno, lineBuf, offset);
}
static JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
/*
* Class: com_netscape_nativejsengine_JSRuntime
* Method: _init
* Signature: (Z)Z
*/
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSRuntime__1init
(JNIEnv * env, jobject self, jboolean enableDebugging)
{
JSRuntime *rt;
jclass clazz;
jfieldID fid;
rt = JS_NewRuntime(8L * 1024L * 1024L);
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
clazz = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
(*env)->SetLongField(env, self, fid, (long) rt);
#ifdef JSDEBUGGER
if(enableDebugging)
{
JSDJContext* jsdjc;
JSDContext* jsdc;
jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
jsdjc = JSDJ_CreateContext();
ASSERT_RETURN_VALUE(jsdjc, JNI_FALSE);
JSDJ_SetJSDContext(jsdjc, jsdc);
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
fid = (*env)->GetFieldID(env, clazz, "_nativeDebugSupport", "J");
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
(*env)->SetLongField(env, self, fid, (long) jsdjc);
}
#else
if(enableDebugging)
printf("ERROR - Context created with enableDebugging flag, but no debugging support compiled in!");
#endif
return JNI_TRUE;
}
/*
* Class: com_netscape_nativejsengine_JSRuntime
* Method: _exit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSRuntime__1exit
(JNIEnv * env, jobject self)
{
jfieldID fid;
jclass clazz;
JSRuntime *rt;
JSContext *iterp = NULL;
clazz = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VOID(clazz);
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
ASSERT_RETURN_VOID(fid);
rt = (JSRuntime *) (*env)->GetLongField(env, self, fid);
ASSERT_RETURN_VOID(rt);
/*
* Can't kill runtime if it holds any contexts
*
* However, JSD may make it's own context(s), so don't ASSERT
*/
CHECK_RETURN_VOID(!JS_ContextIterator(rt, &iterp));
printf("runtime = %d\n", (int)rt);
JS_DestroyRuntime(rt);
}
/***************************************************************************/
/*
* Class: com_netscape_nativejsengine_JSContext
* Method: _init
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSContext__1init
(JNIEnv *env, jobject self)
{
JSContext *cx;
JSObject *glob;
jfieldID fid;
jmethodID mid;
JSRuntime *rt;
jobject rtObject;
jclass clazz;
jclass clazz_self;
JSBool ok;
ContextInfo* info;
#ifdef JSDEBUGGER
JSDJContext* jsdjc;
#endif
clazz_self = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VALUE(clazz_self, JNI_FALSE);
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
"Lcom/netscape/nativejsengine/JSRuntime;");
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
rtObject = (*env)->GetObjectField(env, self, fid);
ASSERT_RETURN_VALUE(rtObject, JNI_FALSE);
clazz = (*env)->GetObjectClass(env, rtObject);
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
mid = (*env)->GetMethodID(env, clazz, "getNativeRuntime", "()J");
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
rt = (JSRuntime *) (*env)->CallObjectMethod(env, rtObject, mid);
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
cx = JS_NewContext(rt, 8192);
ASSERT_RETURN_VALUE(cx, JNI_FALSE);
JS_SetErrorReporter(cx, my_ErrorReporter);
glob = JS_NewObject(cx, &global_class, NULL, NULL);
ASSERT_RETURN_VALUE(glob, JNI_FALSE);
ok = JS_InitStandardClasses(cx, glob);
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
ok = JS_DefineFunctions(cx, glob, shell_functions);
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
(*env)->SetLongField(env, self, fid, (long) cx);
info = (ContextInfo*) malloc(sizeof(ContextInfo));
ASSERT_RETURN_VALUE(info, JNI_FALSE);
info->env = env;
info->contextObject = self;
JS_SetContextPrivate(cx, info);
#ifdef JSDEBUGGER
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
if(jsdjc)
{
JSDContext* jsdc = JSDJ_GetJSDContext(jsdjc);
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
JSD_JSContextInUse(jsdc, cx);
}
#endif
return JNI_TRUE;
}
/*
* Class: com_netscape_nativejsengine_JSContext
* Method: _exit
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1exit
(JNIEnv *env, jobject self)
{
jfieldID fid;
jclass clazz;
JSContext *cx;
ContextInfo* info;
clazz = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VOID(clazz);
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
ASSERT_RETURN_VOID(fid);
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
ASSERT_RETURN_VOID(cx);
info = (ContextInfo*) JS_GetContextPrivate(cx);
ASSERT_RETURN_VOID(info);
free(info);
printf("context = %d\n", (int)cx);
JS_DestroyContext(cx);
}
/*
* Class: com_netscape_nativejsengine_JSContext
* Method: _eval
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1eval
(JNIEnv * env, jobject self, jstring str, jstring filename, jint lineno)
{
jfieldID fid;
jclass clazz_self;
JSContext *cx;
JSObject *glob;
jsval rval;
int len;
const char* Cstr;
const char* Cfilename;
jboolean isCopy;
clazz_self = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VOID(clazz_self);
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
ASSERT_RETURN_VOID(fid);
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
ASSERT_RETURN_VOID(cx);
glob = JS_GetGlobalObject(cx);
ASSERT_RETURN_VOID(glob);
len = (*env)->GetStringUTFLength(env, str);
Cstr = (*env)->GetStringUTFChars(env, str, &isCopy);
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
#ifdef JSDEBUGGER
/*
* XXX this just overwrites any previous source for this url!
*/
_jamSourceIntoJSD(cx, Cstr, len, Cfilename);
#endif
JS_EvaluateScript(cx, glob, Cstr, len, Cfilename, lineno, &rval);
(*env)->ReleaseStringUTFChars(env, str, Cstr);
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
}
/*
* Class: com_netscape_nativejsengine_JSContext
* Method: _load
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1load
(JNIEnv *env, jobject self, jstring filename)
{
jfieldID fid;
jclass clazz;
JSContext *cx;
const char* Cfilename;
jboolean isCopy;
JSObject *glob;
clazz = (*env)->GetObjectClass(env, self);
ASSERT_RETURN_VOID(clazz);
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
ASSERT_RETURN_VOID(fid);
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
ASSERT_RETURN_VOID(cx);
glob = JS_GetGlobalObject(cx);
ASSERT_RETURN_VOID(glob);
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
_loadSingleFile(cx, glob, Cfilename);
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
}

File diff suppressed because it is too large Load Diff

70
mozilla/js/jsd/jsd.mak Normal file
View File

@@ -0,0 +1,70 @@
PROJ = jsd
JSD = .
JS = $(JSD)\..\src
JSPROJ = js32
!IF "$(BUILD_OPT)" != ""
OBJ = Release
CC_FLAGS = /DNDEBUG
!ELSE
OBJ = Debug
CC_FLAGS = /DDEBUG
LINK_FLAGS = /DEBUG
!ENDIF
QUIET=@
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/I $(JS)\
/I $(JSD)\
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
/DJSDEBUGGER\
!IF "$(JSD_THREADSAFE)" != ""
/DJSD_THREADSAFE\
!ENDIF
/DEXPORT_JSD_API\
$(CC_FLAGS)\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
LLIBS = kernel32.lib advapi32.lib $(JS)\$(OBJ)\$(JSPROJ).lib
# unused... user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib
CPP=cl.exe
LINK32=link.exe
all: $(OBJ) $(OBJ)\$(PROJ).dll
$(OBJ)\$(PROJ).dll: \
$(OBJ)\jsdebug.obj \
$(OBJ)\jsd_atom.obj \
$(OBJ)\jsd_high.obj \
$(OBJ)\jsd_hook.obj \
$(OBJ)\jsd_obj.obj \
$(OBJ)\jsd_scpt.obj \
$(OBJ)\jsd_stak.obj \
$(OBJ)\jsd_step.obj \
$(OBJ)\jsd_text.obj \
$(OBJ)\jsd_lock.obj \
$(OBJ)\jsd_val.obj
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
{$(JSD)}.c{$(OBJ)}.obj :
$(QUIET)$(CPP) $(CFLAGS)
$(OBJ) :
$(QUIET)mkdir $(OBJ)
clean:
@echo deleting old output
$(QUIET)del $(OBJ)\*.pch >NUL
$(QUIET)del $(OBJ)\*.obj >NUL
$(QUIET)del $(OBJ)\*.exp >NUL
$(QUIET)del $(OBJ)\*.lib >NUL
$(QUIET)del $(OBJ)\*.idb >NUL
$(QUIET)del $(OBJ)\*.pdb >NUL
$(QUIET)del $(OBJ)\*.dll >NUL

159
mozilla/js/jsd/jsd_atom.c Normal file
View File

@@ -0,0 +1,159 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* JavaScript Debugging support - Atom support
*/
#include "jsd.h"
/* #define TEST_ATOMS 1 */
#ifdef TEST_ATOMS
static void
_testAtoms(JSDContext*jsdc)
{
JSDAtom* atom0 = jsd_AddAtom(jsdc, "foo");
JSDAtom* atom1 = jsd_AddAtom(jsdc, "foo");
JSDAtom* atom2 = jsd_AddAtom(jsdc, "bar");
JSDAtom* atom3 = jsd_CloneAtom(jsdc, atom1);
JSDAtom* atom4 = jsd_CloneAtom(jsdc, atom2);
const char* c0 = JSD_ATOM_TO_STRING(atom0);
const char* c1 = JSD_ATOM_TO_STRING(atom1);
const char* c2 = JSD_ATOM_TO_STRING(atom2);
const char* c3 = JSD_ATOM_TO_STRING(atom3);
const char* c4 = JSD_ATOM_TO_STRING(atom4);
jsd_DropAtom(jsdc, atom0);
jsd_DropAtom(jsdc, atom1);
jsd_DropAtom(jsdc, atom2);
jsd_DropAtom(jsdc, atom3);
jsd_DropAtom(jsdc, atom4);
}
#endif
JS_STATIC_DLL_CALLBACK(intN)
_atom_smasher(JSHashEntry *he, intN i, void *arg)
{
JS_ASSERT(he);
JS_ASSERT(he->value);
JS_ASSERT(((JSDAtom*)(he->value))->str);
free(((JSDAtom*)(he->value))->str);
free(he->value);
he->value = NULL;
he->key = NULL;
return HT_ENUMERATE_NEXT;
}
JS_STATIC_DLL_CALLBACK(intN)
_compareAtomKeys(const void *v1, const void *v2)
{
return 0 == strcmp((const char*)v1, (const char*)v2);
}
JS_STATIC_DLL_CALLBACK(intN)
_compareAtoms(const void *v1, const void *v2)
{
return 0 == strcmp(((JSDAtom*)v1)->str, ((JSDAtom*)v2)->str);
}
JSBool
jsd_CreateAtomTable(JSDContext* jsdc)
{
jsdc->atoms = JS_NewHashTable(256, JS_HashString,
_compareAtomKeys, _compareAtoms,
NULL, NULL);
#ifdef TEST_ATOMS
_testAtoms(jsdc);
#endif
return (JSBool) jsdc->atoms;
}
void
jsd_DestroyAtomTable(JSDContext* jsdc)
{
if( jsdc->atoms )
{
JS_HashTableEnumerateEntries(jsdc->atoms, _atom_smasher, NULL);
JS_HashTableDestroy(jsdc->atoms);
jsdc->atoms = NULL;
}
}
JSDAtom*
jsd_AddAtom(JSDContext* jsdc, const char* str)
{
JSDAtom* atom;
if(!str)
{
JS_ASSERT(0);
return NULL;
}
JSD_LOCK_ATOMS(jsdc);
atom = (JSDAtom*) JS_HashTableLookup(jsdc->atoms, str);
if( atom )
atom->refcount++;
else
{
atom = (JSDAtom*) malloc(sizeof(JSDAtom));
if( atom )
{
atom->str = strdup(str);
atom->refcount = 1;
if(!JS_HashTableAdd(jsdc->atoms, atom->str, atom))
{
free(atom->str);
free(atom);
atom = NULL;
}
}
}
JSD_UNLOCK_ATOMS(jsdc);
return atom;
}
JSDAtom*
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom)
{
JSD_LOCK_ATOMS(jsdc);
atom->refcount++;
JSD_UNLOCK_ATOMS(jsdc);
return atom;
}
void
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom)
{
JSD_LOCK_ATOMS(jsdc);
if(! --atom->refcount)
{
JS_HashTableRemove(jsdc->atoms, atom->str);
free(atom->str);
free(atom);
}
JSD_UNLOCK_ATOMS(jsdc);
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,39 +17,38 @@
*/
/*
** JavaScript Debugger Navigator API - 'High Level' functions
*/
* JavaScript Debugging support - 'High Level' functions
*/
#include "jsd.h"
/***************************************************************************/
/* use a global context for now (avoid direct references to it!) */
static JSDContext _static_context;
/* these are global now, they transcend our concept of JSDContext...*/
/* XXX not 'static' because of old Mac CodeWarrior bug */
JSCList _jsd_context_list = JS_INIT_STATIC_CLIST(&_jsd_context_list);
/* these are used to connect JSD_SetUserCallbacks() with JSD_DebuggerOn() */
static JSD_UserCallbacks _callbacks;
static void* _user;
static JSTaskState* _jstaskstate;
static PRThread * _dangerousThread1;
static void* _user = NULL;
static JSRuntime* _jsrt = NULL;
#ifdef DEBUG
void JSD_ASSERT_VALID_CONTEXT( JSDContext* jsdc )
{
PR_ASSERT( jsdc == &_static_context );
PR_ASSERT( jsdc->inited );
PR_ASSERT( jsdc->jstaskstate );
PR_ASSERT( jsdc->jscontexts );
}
#ifdef JSD_HAS_DANGEROUS_THREAD
static void* _dangerousThread = NULL;
#endif
static PRHashNumber
_hash_root(const void *key)
#ifdef JSD_THREADSAFE
void* _jsd_global_lock = NULL;
#endif
#ifdef DEBUG
void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc)
{
PRHashNumber num = (PRHashNumber) key;
return num >> 2;
JS_ASSERT(jsdc->inited);
JS_ASSERT(jsdc->jsrt);
JS_ASSERT(jsdc->dumbContext);
JS_ASSERT(jsdc->glob);
}
#endif
static JSClass global_class = {
"JSDGlobal", 0,
@@ -57,242 +56,293 @@ static JSClass global_class = {
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
static JSDContext*
NewJSDContext(void)
static JSBool
_validateUserCallbacks(JSD_UserCallbacks* callbacks)
{
JSDContext* jsdc = &_static_context;
return !callbacks ||
(callbacks->size && callbacks->size <= sizeof(JSD_UserCallbacks));
}
static JSDContext*
_newJSDContext(JSRuntime* jsrt,
JSD_UserCallbacks* callbacks,
void* user)
{
JSDContext* jsdc = NULL;
if( ! jsrt )
return NULL;
if( ! _validateUserCallbacks(callbacks) )
return NULL;
jsdc = (JSDContext*) calloc(1, sizeof(JSDContext));
if( ! jsdc )
goto label_newJSDContext_failure;
if( ! JSD_INIT_LOCKS(jsdc) )
goto label_newJSDContext_failure;
JS_INIT_CLIST(&jsdc->links);
jsdc->jsrt = jsrt;
if( callbacks )
memcpy(&jsdc->userCallbacks, callbacks, callbacks->size);
if( jsdc->inited )
return NULL;
jsdc->user = user;
if( ! _jstaskstate )
return NULL;
#ifdef JSD_HAS_DANGEROUS_THREAD
jsdc->dangerousThread = _dangerousThread;
#endif
memset( jsdc, 0, sizeof(JSDContext) );
jsdc->jstaskstate = _jstaskstate;
JS_INIT_CLIST(&jsdc->threadsStates);
JS_INIT_CLIST(&jsdc->scripts);
JS_INIT_CLIST(&jsdc->sources);
JS_INIT_CLIST(&jsdc->removedSources);
PR_INIT_CLIST(&jsdc->threadsStates);
jsdc->sourceAlterCount = 1;
jsdc->dumbContext = JS_NewContext( _jstaskstate, 256 );
if( ! jsd_CreateAtomTable(jsdc) )
goto label_newJSDContext_failure;
if( ! jsd_InitObjectManager(jsdc) )
goto label_newJSDContext_failure;
jsdc->dumbContext = JS_NewContext(jsdc->jsrt, 256);
if( ! jsdc->dumbContext )
return NULL;
goto label_newJSDContext_failure;
jsdc->glob = JS_NewObject(jsdc->dumbContext, &global_class, NULL, NULL);
if( ! jsdc->glob )
return NULL;
goto label_newJSDContext_failure;
if( ! JS_InitStandardClasses(jsdc->dumbContext, jsdc->glob) )
return NULL;
jsdc->jscontexts = PR_NewHashTable(256, _hash_root,
PR_CompareValues, PR_CompareValues,
NULL, NULL);
if( ! jsdc->jscontexts )
return NULL;
goto label_newJSDContext_failure;
jsdc->inited = JS_TRUE;
return jsdc;
}
PR_STATIC_CALLBACK(PRIntn)
_hash_entry_zapper(PRHashEntry *he, PRIntn i, void *arg)
{
PR_FREEIF(he->value);
he->value = NULL;
he->key = NULL;
return HT_ENUMERATE_NEXT;
JSD_LOCK();
JS_INSERT_LINK(&jsdc->links, &_jsd_context_list);
JSD_UNLOCK();
return jsdc;
label_newJSDContext_failure:
jsd_DestroyObjectManager(jsdc);
jsd_DestroyAtomTable(jsdc);
if( jsdc )
free(jsdc);
return NULL;
}
static void
DestroyJSDContext( JSDContext* jsdc )
_destroyJSDContext(JSDContext* jsdc)
{
JSD_ASSERT_VALID_CONTEXT(jsdc);
if( jsdc->jscontexts )
{
PR_HashTableEnumerateEntries(jsdc->jscontexts, _hash_entry_zapper, NULL);
PR_HashTableDestroy(jsdc->jscontexts);
}
jsdc->inited = JS_FALSE;
}
JSDContext*
jsd_GetDefaultJSDContext(void)
{
JSDContext* jsdc = &_static_context;
if( ! jsdc->inited )
return NULL;
return jsdc;
JSD_LOCK();
JS_REMOVE_LINK(&jsdc->links);
JSD_UNLOCK();
jsd_DestroyObjectManager(jsdc);
jsd_DestroyAtomTable(jsdc);
jsdc->inited = JS_FALSE;
/*
* We should free jsdc here, but we let it leak in case there are any
* asynchronous hooks calling into the system using it as a handle
*
* XXX we also leak the locks
*/
}
/***************************************************************************/
JSDContext*
jsd_DebuggerOnForUser(JSRuntime* jsrt,
JSD_UserCallbacks* callbacks,
void* user)
{
JSDContext* jsdc;
JSContext* iter = NULL;
jsdc = _newJSDContext(jsrt, callbacks, user);
if( ! jsdc )
return NULL;
/* set hooks here */
JS_SetNewScriptHookProc(jsdc->jsrt, jsd_NewScriptHookProc, jsdc);
JS_SetDestroyScriptHookProc(jsdc->jsrt, jsd_DestroyScriptHookProc, jsdc);
JS_SetDebuggerHandler(jsdc->jsrt, jsd_DebuggerHandler, jsdc);
JS_SetExecuteHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
JS_SetCallHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
JS_SetThrowHook(jsdc->jsrt, jsd_ThrowHandler, jsdc);
JS_SetDebugErrorHook(jsdc->jsrt, jsd_DebugErrorHook, jsdc);
#ifdef LIVEWIRE
LWDBG_SetNewScriptHookProc(jsd_NewScriptHookProc, jsdc);
#endif
if( jsdc->userCallbacks.setContext )
jsdc->userCallbacks.setContext(jsdc, jsdc->user);
return jsdc;
}
JSDContext*
jsd_DebuggerOn(void)
{
JSDContext* jsdc = NewJSDContext();
JSContext* iter = NULL;
JSContext* cx;
if( ! jsdc )
return NULL;
/* set hooks here */
JS_SetNewScriptHookProc( jsdc->jstaskstate, jsd_NewScriptHookProc, jsdc );
JS_SetDestroyScriptHookProc( jsdc->jstaskstate, jsd_DestroyScriptHookProc, jsdc );
/* enumerate contexts for JSTaskState and add them to our table */
while( NULL != (cx = JS_ContextIterator(jsdc->jstaskstate, &iter)) )
jsd_JSContextUsed( jsdc, cx );
if( _callbacks.setContext )
_callbacks.setContext( jsdc, _user );
return jsdc;
JS_ASSERT(_jsrt);
JS_ASSERT(_validateUserCallbacks(&_callbacks));
return jsd_DebuggerOnForUser(_jsrt, &_callbacks, _user);
}
void
jsd_DebuggerOff(JSDContext* jsdc)
{
/* clear hooks here */
JS_SetNewScriptHookProc( jsdc->jstaskstate, NULL, NULL );
JS_SetDestroyScriptHookProc( jsdc->jstaskstate, NULL, NULL );
JS_SetNewScriptHookProc(jsdc->jsrt, NULL, NULL);
JS_SetDestroyScriptHookProc(jsdc->jsrt, NULL, NULL);
JS_SetDebuggerHandler(jsdc->jsrt, NULL, NULL);
JS_SetExecuteHook(jsdc->jsrt, NULL, NULL);
JS_SetCallHook(jsdc->jsrt, NULL, NULL);
JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
JS_SetThrowHook(jsdc->jsrt, NULL, NULL);
JS_SetDebugErrorHook(jsdc->jsrt, NULL, NULL);
#ifdef LIVEWIRE
LWDBG_SetNewScriptHookProc(NULL,NULL);
#endif
/* clean up */
jsd_DestroyAllJSDScripts( jsdc );
jsd_DestroyAllSources( jsdc );
jsd_DestroyAllJSDScripts(jsdc);
jsd_DestroyAllSources(jsdc);
DestroyJSDContext( jsdc );
_destroyJSDContext(jsdc);
if( _callbacks.setContext )
_callbacks.setContext( NULL, _user );
if( jsdc->userCallbacks.setContext )
jsdc->userCallbacks.setContext(NULL, jsdc->user);
}
void
jsd_SetUserCallbacks(JSTaskState* jstaskstate, JSD_UserCallbacks* callbacks, void* user)
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user)
{
_jstaskstate = jstaskstate;
_jsrt = jsrt;
_user = user;
_dangerousThread1 = PR_CurrentThread();
#ifdef JSD_HAS_DANGEROUS_THREAD
_dangerousThread = JSD_CURRENT_THREAD();
#endif
if( callbacks )
memcpy( &_callbacks, callbacks, sizeof(JSD_UserCallbacks) );
memcpy(&_callbacks, callbacks, sizeof(JSD_UserCallbacks));
else
memset( &_callbacks, 0 , sizeof(JSD_UserCallbacks) );
if( _callbacks.setContext && _static_context.inited )
_callbacks.setContext( &_static_context, _user );
memset(&_callbacks, 0 , sizeof(JSD_UserCallbacks));
}
JSDContextWrapper*
jsd_JSDContextWrapperForJSContext( JSDContext* jsdc, JSContext* context )
JSDContext*
jsd_JSDContextForJSContext(JSContext* context)
{
return (JSDContextWrapper*) PR_HashTableLookup(jsdc->jscontexts, context);
}
JSDContext* iter;
JSDContext* jsdc = NULL;
JSRuntime* runtime = JS_GetRuntime(context);
PR_STATIC_CALLBACK(void)
jsd_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
JSD_LOCK();
for( iter = (JSDContext*)_jsd_context_list.next;
iter != (JSDContext*)&_jsd_context_list;
iter = (JSDContext*)iter->links.next )
{
if( runtime == iter->jsrt )
{
jsdc = iter;
break;
}
}
JSD_UNLOCK();
return jsdc;
}
JS_STATIC_DLL_CALLBACK(JSBool)
jsd_DebugErrorHook(JSContext *cx, const char *message,
JSErrorReport *report, void *closure)
{
JSDContextWrapper* wrapper;
JSDContext* jsdc;
PRUintn action = JSD_ERROR_REPORTER_PASS_ALONG;
jsdc = jsd_GetDefaultJSDContext();
JSDContext* jsdc = (JSDContext*) closure;
JSD_ErrorReporter errorReporter;
void* errorReporterData;
if( ! jsdc )
{
PR_ASSERT(0);
return;
JS_ASSERT(0);
return JS_TRUE;
}
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return JS_TRUE;
wrapper = jsd_JSDContextWrapperForJSContext( jsdc, cx );
if( ! wrapper )
{
PR_ASSERT(0);
return;
}
/* local in case hook gets cleared on another thread */
JSD_LOCK();
errorReporter = jsdc->errorReporter;
errorReporterData = jsdc->errorReporterData;
JSD_UNLOCK();
if( jsdc->errorReporter && ! jsd_IsCurrentThreadDangerous() )
action = jsdc->errorReporter(jsdc, cx, message, report,
jsdc->errorReporterData);
if(!errorReporter)
return JS_TRUE;
switch(action)
switch(errorReporter(jsdc, cx, message, report, errorReporterData))
{
case JSD_ERROR_REPORTER_PASS_ALONG:
if( wrapper->originalErrorReporter )
wrapper->originalErrorReporter(cx, message, report);
break;
case JSD_ERROR_REPORTER_RETURN:
break;
return JS_TRUE;
case JSD_ERROR_REPORTER_RETURN:
return JS_FALSE;
case JSD_ERROR_REPORTER_DEBUG:
{
JSDThreadState* jsdthreadstate;
jsval rval;
JSD_ExecutionHookProc hook;
void* hookData;
if( ! jsdc->debugBreakHook )
return;
/* local in case hook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->debugBreakHook;
hookData = jsdc->debugBreakHookData;
JSD_UNLOCK();
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
if( jsdthreadstate )
{
(*jsdc->debugBreakHook)(jsdc, jsdthreadstate,
JSD_HOOK_DEBUG_REQUESTED,
jsdc->debugBreakHookData );
jsd_DestroyThreadState(jsdc, jsdthreadstate);
}
jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUG_REQUESTED,
hook, hookData, &rval);
/* XXX Should make this dependent on ExecutionHook retval */
return JS_TRUE;
}
default:;
case JSD_ERROR_REPORTER_CLEAR_RETURN:
if(report && JSREPORT_IS_EXCEPTION(report->flags))
JS_ClearPendingException(cx);
return JS_FALSE;
default:
JS_ASSERT(0);
break;
}
}
void
jsd_JSContextUsed( JSDContext* jsdc, JSContext* context )
{
JSDContextWrapper* wrapper;
wrapper = jsd_JSDContextWrapperForJSContext(jsdc, context);
if( wrapper )
{
/* error reporters are sometimes overwritten by other code... */
JSErrorReporter oldrep = JS_SetErrorReporter(context, jsd_ErrorReporter);
if( jsd_ErrorReporter != oldrep )
wrapper->originalErrorReporter = oldrep;
return;
}
/* else... */
wrapper = PR_NEWZAP(JSDContextWrapper);
if( ! wrapper )
return;
if( ! PR_HashTableAdd(jsdc->jscontexts, context, wrapper ) )
{
PR_FREEIF(wrapper);
return;
}
wrapper->context = context;
wrapper->jsdc = jsdc;
/* add our error reporter */
wrapper->originalErrorReporter = JS_SetErrorReporter(context, jsd_ErrorReporter);
/* add our printer */
/* add our loader */
}
JSD_ErrorReporter
jsd_SetErrorReporter( JSDContext* jsdc, JSD_ErrorReporter reporter, void* callerdata)
{
JSD_ErrorReporter old = jsdc->errorReporter;
jsdc->errorReporter = reporter;
jsdc->errorReporterData = callerdata;
return old;
return JS_TRUE;
}
JSBool
jsd_IsCurrentThreadDangerous()
jsd_SetErrorReporter(JSDContext* jsdc,
JSD_ErrorReporter reporter,
void* callerdata)
{
return PR_CurrentThread() == _dangerousThread1;
JSD_LOCK();
jsdc->errorReporter = reporter;
jsdc->errorReporterData = callerdata;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_GetErrorReporter(JSDContext* jsdc,
JSD_ErrorReporter* reporter,
void** callerdata)
{
JSD_LOCK();
if( reporter )
*reporter = jsdc->errorReporter;
if( callerdata )
*callerdata = jsdc->errorReporterData;
JSD_UNLOCK();
return JS_TRUE;
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,85 +17,244 @@
*/
/*
** JavaScript Debugger Navigator API - Hook support
*/
* JavaScript Debugging support - Hook support
*/
#include "jsd.h"
JSTrapStatus PR_CALLBACK
JSTrapStatus JS_DLL_CALLBACK
jsd_InterruptHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
void *closure)
{
PRUintn hookanswer = JSD_HOOK_RETURN_CONTINUE;
JSDThreadState* jsdthreadstate;
JSDScript* jsdscript;
JSDContext* jsdc = (JSDContext*) closure;
if( jsd_IsCurrentThreadDangerous() )
return JSTRAP_CONTINUE;
JSD_ExecutionHookProc hook;
void* hookData;
if( ! jsdc || ! jsdc->inited )
return JSTRAP_CONTINUE;
jsd_JSContextUsed(jsdc, cx);
if( ! jsdc->interruptHook )
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return JSTRAP_CONTINUE;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return JSTRAP_CONTINUE;
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
if( jsdthreadstate )
{
hookanswer =
(*jsdc->interruptHook)(jsdc, jsdthreadstate,
JSD_HOOK_INTERRUPTED,
jsdc->interruptHookData );
#ifdef LIVEWIRE
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
return JSTRAP_CONTINUE;
#endif
/* local in case jsdc->interruptHook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->interruptHook;
hookData = jsdc->interruptHookData;
JSD_UNLOCK();
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_INTERRUPTED,
hook, hookData, rval);
}
JSTrapStatus JS_DLL_CALLBACK
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
jsval *rval, void *closure)
{
JSDScript* jsdscript;
JSDContext* jsdc = (JSDContext*) closure;
JSD_ExecutionHookProc hook;
void* hookData;
if( ! jsdc || ! jsdc->inited )
return JSTRAP_CONTINUE;
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return JSTRAP_CONTINUE;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return JSTRAP_CONTINUE;
/* local in case jsdc->debuggerHook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->debuggerHook;
hookData = jsdc->debuggerHookData;
JSD_UNLOCK();
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUGGER_KEYWORD,
hook, hookData, rval);
}
JSTrapStatus JS_DLL_CALLBACK
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
jsval *rval, void *closure)
{
JSDScript* jsdscript;
JSDContext* jsdc = (JSDContext*) closure;
JSD_ExecutionHookProc hook;
void* hookData;
JS_GetPendingException(cx, rval);
if( ! jsdc || ! jsdc->inited )
return JSD_HOOK_RETURN_CONTINUE_THROW;
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return JSD_HOOK_RETURN_CONTINUE_THROW;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return JSD_HOOK_RETURN_CONTINUE_THROW;
/* local in case jsdc->throwHook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->throwHook;
hookData = jsdc->throwHookData;
JSD_UNLOCK();
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
hook, hookData, rval);
}
JSTrapStatus
jsd_CallExecutionHook(JSDContext* jsdc,
JSContext *cx,
uintN type,
JSD_ExecutionHookProc hook,
void* hookData,
jsval* rval)
{
uintN hookanswer = JSD_HOOK_THROW == type ?
JSD_HOOK_RETURN_CONTINUE_THROW :
JSD_HOOK_RETURN_CONTINUE;
JSDThreadState* jsdthreadstate;
if(hook && NULL != (jsdthreadstate = jsd_NewThreadState(jsdc,cx)))
{
hookanswer = hook(jsdc, jsdthreadstate, type, hookData, rval);
jsd_DestroyThreadState(jsdc, jsdthreadstate);
}
*rval = NULL; /* XXX fix this!!! */
if( JSD_HOOK_RETURN_ABORT == hookanswer )
return JSTRAP_ERROR;
return JSTRAP_CONTINUE; /* XXX fix this!!! */
switch(hookanswer)
{
case JSD_HOOK_RETURN_ABORT:
case JSD_HOOK_RETURN_HOOK_ERROR:
return JSTRAP_ERROR;
case JSD_HOOK_RETURN_RET_WITH_VAL:
return JSTRAP_RETURN;
case JSD_HOOK_RETURN_THROW_WITH_VAL:
return JSTRAP_THROW;
case JSD_HOOK_RETURN_CONTINUE:
break;
case JSD_HOOK_RETURN_CONTINUE_THROW:
/* only makes sense for jsd_ThrowHandler (which init'd rval) */
JS_ASSERT(JSD_HOOK_THROW == type);
return JSTRAP_THROW;
default:
JS_ASSERT(0);
break;
}
return JSTRAP_CONTINUE;
}
JSBool
jsd_SetInterruptHook(JSDContext* jsdc,
jsd_SetInterruptHook(JSDContext* jsdc,
JSD_ExecutionHookProc hook,
void* callerdata)
{
jsdc->interruptHook = hook;
JSD_LOCK();
jsdc->interruptHookData = callerdata;
jsdc->interruptHook = hook;
JS_SetInterrupt(jsdc->jsrt, jsd_InterruptHandler, (void*) jsdc);
JSD_UNLOCK();
return JS_SetInterrupt(jsdc->jstaskstate, jsd_InterruptHandler, (void*) jsdc);
return JS_TRUE;
}
JSBool
jsd_ClearInterruptHook(JSDContext* jsdc)
jsd_ClearInterruptHook(JSDContext* jsdc)
{
JSD_LOCK();
JS_ClearInterrupt(jsdc->jsrt, NULL, NULL );
jsdc->interruptHook = NULL;
return JS_ClearInterrupt(jsdc->jstaskstate, NULL, NULL );
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_SetDebugBreakHook(JSDContext* jsdc,
jsd_SetDebugBreakHook(JSDContext* jsdc,
JSD_ExecutionHookProc hook,
void* callerdata)
{
jsdc->debugBreakHook = hook;
JSD_LOCK();
jsdc->debugBreakHookData = callerdata;
jsdc->debugBreakHook = hook;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_ClearDebugBreakHook(JSDContext* jsdc)
jsd_ClearDebugBreakHook(JSDContext* jsdc)
{
JSD_LOCK();
jsdc->debugBreakHook = NULL;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_SetDebuggerHook(JSDContext* jsdc,
JSD_ExecutionHookProc hook,
void* callerdata)
{
JSD_LOCK();
jsdc->debuggerHookData = callerdata;
jsdc->debuggerHook = hook;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_ClearDebuggerHook(JSDContext* jsdc)
{
JSD_LOCK();
jsdc->debuggerHook = NULL;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_SetThrowHook(JSDContext* jsdc,
JSD_ExecutionHookProc hook,
void* callerdata)
{
JSD_LOCK();
jsdc->throwHookData = callerdata;
jsdc->throwHook = hook;
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_ClearThrowHook(JSDContext* jsdc)
{
JSD_LOCK();
jsdc->throwHook = NULL;
JSD_UNLOCK();
return JS_TRUE;
}

View File

@@ -16,6 +16,10 @@
* Reserved.
*/
/* this is all going away... replaced by code in js/jsd/java */
#if 0
#include "native.h"
#include "jsdebug.h"
@@ -794,4 +798,4 @@ void netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector(struct Hnetsc
}
#endif

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,8 +17,220 @@
*/
/*
* 2/17/98 jband
* This is a temporary placeholder for this file
* to supporet adding this file to existing makefiles before
* the real file is pulled in off of a branch
*/
* JavaScript Debugging support - Locking and threading support
*/
/*
* ifdef JSD_USE_NSPR_LOCKS then you musat build and run against NSPR2.
* Otherwise, there are stubs that can be filled in with your own locking
* code. Also, note that these stubs include a jsd_CurrentThread()
* implementation that only works on Win32 - this is needed for the inprocess
* Java-based debugger.
*/
#include "jsd.h"
#ifdef JSD_THREADSAFE
#ifdef JSD_USE_NSPR_LOCKS
#include "prlock.h"
#include "prthread.h"
#ifdef JSD_ATTACH_THREAD_HACK
#include "pprthred.h" /* need this as long as JS_AttachThread is needed */
#endif
typedef struct JSDStaticLock
{
void* owner;
PRLock* lock;
int count;
#ifdef DEBUG
uint16 sig;
#endif
} JSDStaticLock;
/*
* This exists to wrap non-NSPR theads (e.g. Java threads) in NSPR wrappers.
* XXX We ignore the memory leak issue.
* It is claimed that future versions of NSPR will automatically wrap on
* the call to PR_GetCurrentThread.
*
* XXX We ignore the memory leak issue - i.e. we never call PR_DetachThread.
*
*/
#undef _CURRENT_THREAD
#ifdef JSD_ATTACH_THREAD_HACK
#define _CURRENT_THREAD(out) \
JS_BEGIN_MACRO \
out = (void*) PR_GetCurrentThread(); \
if(!out) \
out = (void*) JS_AttachThread(PR_USER_THREAD,PR_PRIORITY_NORMAL,NULL);\
JS_ASSERT(out); \
JS_END_MACRO
#else
#define _CURRENT_THREAD(out) \
JS_BEGIN_MACRO \
out = (void*) PR_GetCurrentThread(); \
JS_ASSERT(out); \
JS_END_MACRO
#endif
#ifdef DEBUG
#define JSD_LOCK_SIG 0x10CC10CC
void ASSERT_VALID_LOCK(JSDStaticLock* lock)
{
JS_ASSERT(lock);
JS_ASSERT(lock->lock);
JS_ASSERT(lock->count >= 0);
JS_ASSERT((! lock->count && ! lock->owner) || (lock->count && lock->owner));
JS_ASSERT(lock->sig == (uint16) JSD_LOCK_SIG);
}
#else
#define ASSERT_VALID_LOCK(x) ((void)0)
#endif
void*
jsd_CreateLock()
{
JSDStaticLock* lock;
if( ! (lock = calloc(1, sizeof(JSDStaticLock))) ||
! (lock->lock = PR_NewLock()) )
{
if(lock)
{
free(lock);
lock = NULL;
}
}
#ifdef DEBUG
if(lock) lock->sig = (uint16) JSD_LOCK_SIG;
#endif
return lock;
}
void
jsd_Lock(JSDStaticLock* lock)
{
void* me;
_CURRENT_THREAD(me);
ASSERT_VALID_LOCK(lock);
if(lock->owner == me)
lock->count++;
else
{
PR_Lock(lock->lock); /* this can block... */
JS_ASSERT(lock->owner == 0);
lock->count = 1;
lock->owner = me;
}
ASSERT_VALID_LOCK(lock);
}
void
jsd_Unlock(JSDStaticLock* lock)
{
void* me;
ASSERT_VALID_LOCK(lock);
_CURRENT_THREAD(me);
if(lock->owner != me)
{
JS_ASSERT(0); /* it's an error to unlock a lock you don't own */
return;
}
if(--lock->count == 0)
{
lock->owner = NULL;
PR_Unlock(lock->lock);
}
ASSERT_VALID_LOCK(lock);
}
#ifdef DEBUG
JSBool
jsd_IsLocked(JSDStaticLock* lock)
{
void* me;
ASSERT_VALID_LOCK(lock);
_CURRENT_THREAD(me);
return lock->owner == me ? JS_TRUE : JS_FALSE;
}
#endif /* DEBUG */
void*
jsd_CurrentThread()
{
void* me;
_CURRENT_THREAD(me);
return me;
}
#else /* ! JSD_USE_NSPR_LOCKS */
#ifdef WIN32
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
#pragma message("!! you are compiling the stubbed version of jsd_lock.c !!")
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
#endif
/*
* NOTE: 'Real' versions of these locks must be reentrant in the sense that
* they support nested calls to lock and unlock.
*/
void*
jsd_CreateLock()
{
return (void*)1;
}
void
jsd_Lock(void* lock)
{
}
void
jsd_Unlock(void* lock)
{
}
#ifdef DEBUG
JSBool
jsd_IsLocked(void* lock)
{
return JS_TRUE;
}
#endif /* DEBUG */
/*
* This Windows only thread id code is here to allow the Java-based
* JSDebugger to work with the single threaded js.c shell (even without
* real locking and threading support).
*/
#ifdef WIN32
/* bogus (but good enough) declaration*/
extern void* __stdcall GetCurrentThreadId(void);
#endif
void*
jsd_CurrentThread()
{
#ifdef WIN32
return GetCurrentThreadId();
#else
return (void*)1;
#endif
}
#endif /* JSD_USE_NSPR_LOCKS */
#endif /* JSD_THREADSAFE */

View File

@@ -17,22 +17,37 @@
*/
/*
* sinix.h
* 5/18/96
* Taken from nec.h by Christian.Kaiser@mch.sni.de
* Header for JavaScript Debugging support - Locking and threading functions
*/
#ifndef nspr_sinix_defs_h___
#define nspr_sinix_defs_h___
#undef HAVE_STACK_GROWING_UP
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define HAVE_WEAK_IO_SYMBOLS
#define HAVE_WEAK_MALLOC_SYMBOLS
#define HAVE_DLL
#define USE_DLFCN
#ifndef jsd_lock_h___
#define jsd_lock_h___
#define NEED_TIME_R
/*
* If you want to support threading and locking, define JSD_THREADSAFE and
* implement the functions below.
*/
#endif /* nspr_sinix_defs_h___ */
/*
* NOTE: These locks must be reentrant in the sense that they support
* nested calls to lock and unlock.
*/
extern void*
jsd_CreateLock();
extern void
jsd_Lock(void* lock);
extern void
jsd_Unlock(void* lock);
#ifdef DEBUG
extern JSBool
jsd_IsLocked(void* lock);
#endif /* DEBUG */
extern void*
jsd_CurrentThread();
#endif /* jsd_lock_h___ */

307
mozilla/js/jsd/jsd_obj.c Normal file
View File

@@ -0,0 +1,307 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* JavaScript Debugging support - Object support
*/
#include "jsd.h"
/*
* #define JSD_TRACE 1
*/
#ifdef JSD_TRACE
#define TRACEOBJ(jsdc, jsdobj, which) _traceObj(jsdc, jsdobj, which)
static char *
_describeObj(JSDContext* jsdc, JSDObject *jsdobj)
{
return
JS_smprintf("%0x new'd in %s at line %d using ctor %s in %s at line %d",
(int)jsdobj,
JSD_GetObjectNewURL(jsdc, jsdobj),
JSD_GetObjectNewLineNumber(jsdc, jsdobj),
JSD_GetObjectConstructorName(jsdc, jsdobj),
JSD_GetObjectConstructorURL(jsdc, jsdobj),
JSD_GetObjectConstructorLineNumber(jsdc, jsdobj));
}
static void
_traceObj(JSDContext* jsdc, JSDObject* jsdobj, int which)
{
char* description;
if( !jsdobj )
return;
description = _describeObj(jsdc, jsdobj);
printf("%s : %s\n",
which == 0 ? "new " :
which == 1 ? "final" :
"ctor ",
description);
if(description)
free(description);
}
#else
#define TRACEOBJ(jsdc, jsdobj, which) ((void)0)
#endif /* JSD_TRACE */
#ifdef DEBUG
void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj)
{
JS_ASSERT(jsdobj);
JS_ASSERT(!JS_CLIST_IS_EMPTY(&jsdobj->links));
JS_ASSERT(jsdobj->obj);
}
#endif
static void
_destroyJSDObject(JSDContext* jsdc, JSDObject* jsdobj)
{
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
JS_REMOVE_LINK(&jsdobj->links);
JS_HashTableRemove(jsdc->objectsTable, jsdobj->obj);
if(jsdobj->newURL)
jsd_DropAtom(jsdc, jsdobj->newURL);
if(jsdobj->ctorURL)
jsd_DropAtom(jsdc, jsdobj->ctorURL);
if(jsdobj->ctorName)
jsd_DropAtom(jsdc, jsdobj->ctorName);
free(jsdobj);
}
static JSDObject*
_createJSDObject(JSDContext* jsdc, JSContext *cx, JSObject *obj)
{
JSDObject* jsdobj;
JSStackFrame* fp;
JSStackFrame* iter = NULL;
const char* newURL;
jsbytecode* pc;
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
jsdobj = (JSDObject*) calloc(1, sizeof(JSDObject));
if( jsdobj )
{
JS_INIT_CLIST(&jsdobj->links);
JS_APPEND_LINK(&jsdobj->links, &jsdc->objectsList);
jsdobj->obj = obj;
JS_HashTableAdd(jsdc->objectsTable, obj, jsdobj);
/* walk the stack to find js frame (if any) causing creation */
while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
{
if( !JS_IsNativeFrame(cx, fp) )
{
JSScript* script = JS_GetFrameScript(cx, fp);
if( !script )
continue;
newURL = JS_GetScriptFilename(cx, script);
if( newURL )
jsdobj->newURL = jsd_AddAtom(jsdc, newURL);
pc = JS_GetFramePC(cx, fp);
if( pc )
jsdobj->newLineno = JS_PCToLineNumber(cx, script, pc);
break;
}
}
}
return jsdobj;
}
void JS_DLL_CALLBACK
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure)
{
JSDObject* jsdobj;
JSDContext* jsdc = (JSDContext*) closure;
if( ! jsdc || ! jsdc->inited )
return;
JSD_LOCK_OBJECTS(jsdc);
if(isNew)
{
jsdobj = _createJSDObject(jsdc, cx, obj);
TRACEOBJ(jsdc, jsdobj, 0);
}
else
{
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
if( jsdobj )
{
TRACEOBJ(jsdc, jsdobj, 1);
_destroyJSDObject(jsdc, jsdobj);
}
}
JSD_UNLOCK_OBJECTS(jsdc);
}
void
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
JSStackFrame *fp)
{
JSDObject* jsdobj;
JSScript* script;
JSDScript* jsdscript;
const char* ctorURL;
const char* ctorName;
JSD_LOCK_OBJECTS(jsdc);
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
if( jsdobj && !jsdobj->ctorURL && !JS_IsNativeFrame(cx, fp) )
{
script = JS_GetFrameScript(cx, fp);
if( script )
{
ctorURL = JS_GetScriptFilename(cx, script);
if( ctorURL )
jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL);
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( jsdscript )
{
ctorName = jsd_GetScriptFunctionName(jsdc, jsdscript);
if( ctorName )
jsdobj->ctorName = jsd_AddAtom(jsdc, ctorName);
}
jsdobj->ctorLineno = JS_GetScriptBaseLineNumber(cx, script);
}
}
TRACEOBJ(jsdc, jsdobj, 3);
JSD_UNLOCK_OBJECTS(jsdc);
}
JS_STATIC_DLL_CALLBACK(JSHashNumber)
_hash_root(const void *key)
{
return ((JSHashNumber) key) >> 2; /* help lame MSVC1.5 on Win16 */
}
JSBool
jsd_InitObjectManager(JSDContext* jsdc)
{
JS_INIT_CLIST(&jsdc->objectsList);
jsdc->objectsTable = JS_NewHashTable(256, _hash_root,
JS_CompareValues, JS_CompareValues,
NULL, NULL);
return (JSBool) jsdc->objectsTable;
}
void
jsd_DestroyObjectManager(JSDContext* jsdc)
{
JSD_LOCK_OBJECTS(jsdc);
while( !JS_CLIST_IS_EMPTY(&jsdc->objectsList) )
_destroyJSDObject(jsdc, (JSDObject*)JS_NEXT_LINK(&jsdc->objectsList));
JS_HashTableDestroy(jsdc->objectsTable);
JSD_UNLOCK_OBJECTS(jsdc);
}
JSDObject*
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp)
{
JSDObject *jsdobj = *iterp;
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
if( !jsdobj )
jsdobj = (JSDObject *)jsdc->objectsList.next;
if( jsdobj == (JSDObject *)&jsdc->objectsList )
return NULL;
*iterp = (JSDObject*) jsdobj->links.next;
return jsdobj;
}
JSObject*
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj)
{
return jsdobj->obj;
}
const char*
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj)
{
if( jsdobj->newURL )
return JSD_ATOM_TO_STRING(jsdobj->newURL);
return NULL;
}
uintN
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
{
return jsdobj->newLineno;
}
const char*
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj)
{
if( jsdobj->ctorURL )
return JSD_ATOM_TO_STRING(jsdobj->ctorURL);
return NULL;
}
uintN
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
{
return jsdobj->ctorLineno;
}
const char*
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj)
{
if( jsdobj->ctorName )
return JSD_ATOM_TO_STRING(jsdobj->ctorName);
return NULL;
}
JSDObject*
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj)
{
JSDObject* jsdobj;
JSD_LOCK_OBJECTS(jsdc);
jsdobj = (JSDObject*) JS_HashTableLookup(jsdc->objectsTable, jsobj);
JSD_UNLOCK_OBJECTS(jsdc);
return jsdobj;
}
JSDObject*
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval)
{
return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
}
JSDValue*
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj)
{
return jsd_NewValue(jsdc, OBJECT_TO_JSVAL(jsdobj->obj));
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,17 +17,10 @@
*/
/*
** JavaScript Debugger Navigator API - Script support
*/
* JavaScript Debugging support - Script support
*/
#include "jsd.h"
#ifdef NSPR20
#ifdef XP_MAC
#include "prpriv.h"
#else
#include "private/prpriv.h"
#endif
#endif
/* Comment this out to disable (NT specific) dumping as we go */
/*
@@ -39,75 +32,130 @@
#define NOT_SET_YET -1
/***************************************************************************/
PRCList jsd_script_list = PR_INIT_STATIC_CLIST(&jsd_script_list);
#ifdef DEBUG
void JSD_ASSERT_VALID_SCRIPT( JSDScript* jsdscript )
void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript)
{
PR_ASSERT( jsdscript );
PR_ASSERT( jsdscript->script );
JS_ASSERT(jsdscript);
JS_ASSERT(jsdscript->script);
}
void JSD_ASSERT_VALID_EXEC_HOOK( JSDExecHook* jsdhook )
void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook)
{
PR_ASSERT( jsdhook );
PR_ASSERT( jsdhook->hook );
JS_ASSERT(jsdhook);
JS_ASSERT(jsdhook->hook);
}
#endif
#ifdef LIVEWIRE
static JSBool
HasFileExtention(const char* name, const char* ext)
{
int i;
int len = strlen(ext);
const char* p = strrchr(name,'.');
if( !p )
return JS_FALSE;
p++;
for(i = 0; i < len; i++ )
{
JS_ASSERT(islower(ext[i]));
if( 0 == p[i] || tolower(p[i]) != ext[i] )
return JS_FALSE;
}
if( 0 != p[i] )
return JS_FALSE;
return JS_TRUE;
}
#endif /* LIVEWIRE */
static JSDScript*
NewJSDScript( JSDContext* jsdc,
_newJSDScript(JSDContext* jsdc,
JSContext *cx,
JSScript *script,
JSFunction* function )
JSFunction* function)
{
JSDScript* jsdscript;
PRUintn lineno;
uintN lineno;
const char* raw_filename;
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
/* these are inlined javascript: urls and we can't handle them now */
lineno = (PRUintn) JS_GetScriptBaseLineNumber(cx, script);
lineno = (uintN) JS_GetScriptBaseLineNumber(cx, script);
if( lineno == 0 )
return NULL;
jsdscript = PR_NEWZAP(JSDScript);
jsdscript = (JSDScript*) calloc(1, sizeof(JSDScript));
if( ! jsdscript )
return NULL;
raw_filename = JS_GetScriptFilename(cx,script);
PR_APPEND_LINK(&jsdscript->links, &jsd_script_list);
JS_APPEND_LINK(&jsdscript->links, &jsdc->scripts);
jsdscript->jsdc = jsdc;
jsdscript->script = script;
jsdscript->function = function;
jsdscript->lineBase = lineno;
jsdscript->lineExtent = (PRUintn)NOT_SET_YET;
jsdscript->url = (char*)jsd_BuildNormalizedURL(JS_GetScriptFilename(cx,script));
jsdscript->lineExtent = (uintN)NOT_SET_YET;
#ifndef LIVEWIRE
jsdscript->url = (char*) jsd_BuildNormalizedURL(raw_filename);
#else
jsdscript->app = LWDBG_GetCurrentApp();
if( jsdscript->app && raw_filename )
{
jsdscript->url = jsdlw_BuildAppRelativeFilename(jsdscript->app, raw_filename);
if( function )
{
jsdscript->lwscript =
LWDBG_GetScriptOfFunction(jsdscript->app,
JS_GetFunctionName(function));
/* also, make sure this file is added to filelist if is .js file */
if( HasFileExtention(raw_filename,"js") ||
HasFileExtention(raw_filename,"sjs") )
{
jsdlw_PreLoadSource(jsdc, jsdscript->app, raw_filename, JS_FALSE);
}
}
else
{
jsdscript->lwscript = LWDBG_GetCurrentTopLevelScript();
}
}
#endif
PR_INIT_CLIST(&jsdscript->hooks);
JS_INIT_CLIST(&jsdscript->hooks);
return jsdscript;
}
static void
DestroyJSDScript( JSDContext* jsdc,
JSDScript* jsdscript )
_destroyJSDScript(JSDContext* jsdc,
JSDScript* jsdscript)
{
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
/* destroy all hooks */
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
PR_REMOVE_LINK(&jsdscript->links);
PR_FREEIF(jsdscript->url);
JS_REMOVE_LINK(&jsdscript->links);
if(jsdscript->url)
free(jsdscript->url);
PR_FREEIF(jsdscript);
if(jsdscript)
free(jsdscript);
}
/***************************************************************************/
#ifdef JSD_DUMP
static void
DumpJSDScript( JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
_dumpJSDScript(JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
{
const char* name;
const char* fun;
PRUintn base;
PRUintn extent;
uintN base;
uintN extent;
char Buf[256];
name = jsd_GetScriptFilename(jsdc, jsdscript);
@@ -125,54 +173,32 @@ DumpJSDScript( JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
}
static void
DumpJSDScriptList( JSDContext* jsdc )
_dumpJSDScriptList( JSDContext* jsdc )
{
JSDScript* iterp = NULL;
JSDScript* jsdscript = NULL;
OutputDebugString( "*** JSDScriptDump\n" );
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
DumpJSDScript( jsdc, jsdscript, " script: " );
_dumpJSDScript( jsdc, jsdscript, " script: " );
}
#endif /* JSD_DUMP */
/***************************************************************************/
#ifndef JSD_SIMULATION
static PRMonitor *jsd_script_mon = NULL;
#endif /* JSD_SIMULATION */
void
jsd_LockScriptSubsystem(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
if (jsd_script_mon == NULL)
jsd_script_mon = PR_NewNamedMonitor("jsd-script-monitor");
PR_EnterMonitor(jsd_script_mon);
#endif /* JSD_SIMULATION */
}
void
jsd_UnlockScriptSubsystem(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
PR_ExitMonitor(jsd_script_mon);
#endif /* JSD_SIMULATION */
}
void
jsd_DestroyAllJSDScripts( JSDContext* jsdc )
{
JSDScript *jsdscript;
JSDScript *next;
for (jsdscript = (JSDScript*)jsd_script_list.next;
jsdscript != (JSDScript*)&jsd_script_list;
jsdscript = next)
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
for( jsdscript = (JSDScript*)jsdc->scripts.next;
jsdscript != (JSDScript*)&jsdc->scripts;
jsdscript = next )
{
next = (JSDScript*)jsdscript->links.next;
DestroyJSDScript( jsdc, jsdscript );
_destroyJSDScript( jsdc, jsdscript );
}
}
@@ -182,9 +208,12 @@ jsd_FindJSDScript( JSDContext* jsdc,
{
JSDScript *jsdscript;
for (jsdscript = (JSDScript *)jsd_script_list.next;
jsdscript != (JSDScript *)&jsd_script_list;
jsdscript = (JSDScript *)jsdscript->links.next) {
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
for( jsdscript = (JSDScript *)jsdc->scripts.next;
jsdscript != (JSDScript *)&jsdc->scripts;
jsdscript = (JSDScript *)jsdscript->links.next )
{
if (jsdscript->script == script)
return jsdscript;
}
@@ -196,14 +225,33 @@ jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp)
{
JSDScript *jsdscript = *iterp;
if (!jsdscript)
jsdscript = (JSDScript *)jsd_script_list.next;
if (jsdscript == (JSDScript *)&jsd_script_list)
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
if( !jsdscript )
jsdscript = (JSDScript *)jsdc->scripts.next;
if( jsdscript == (JSDScript *)&jsdc->scripts )
return NULL;
*iterp = (JSDScript *)jsdscript->links.next;
*iterp = (JSDScript*) jsdscript->links.next;
return jsdscript;
}
JSBool
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript)
{
JSDScript *current;
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
for( current = (JSDScript *)jsdc->scripts.next;
current != (JSDScript *)&jsdc->scripts;
current = (JSDScript *)current->links.next )
{
if(jsdscript == current)
return JS_TRUE;
}
return JS_FALSE;
}
const char*
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript)
{
@@ -218,13 +266,13 @@ jsd_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript)
return JS_GetFunctionName(jsdscript->function);
}
PRUintn
uintN
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript)
{
return jsdscript->lineBase;
}
PRUintn
uintN
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript)
{
if( NOT_SET_YET == jsdscript->lineExtent )
@@ -232,88 +280,120 @@ jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript)
return jsdscript->lineExtent;
}
prword_t
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, PRUintn line)
jsuword
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line)
{
return (prword_t) JS_LineNumberToPC(jsdc->dumbContext,
#ifdef LIVEWIRE
if( jsdscript && jsdscript->lwscript )
{
uintN newline;
jsdlw_RawToProcessedLineNumber(jsdc, jsdscript, line, &newline);
if( line != newline )
line = newline;
}
#endif
return (jsuword) JS_LineNumberToPC(jsdc->dumbContext,
jsdscript->script, line );
}
PRUintn
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
uintN
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
{
PRUintn first = jsdscript->lineBase;
PRUintn last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
PRUintn line = JS_PCToLineNumber(jsdc->dumbContext,
uintN first = jsdscript->lineBase;
uintN last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
uintN line = JS_PCToLineNumber(jsdc->dumbContext,
jsdscript->script, (jsbytecode*)pc);
if( line < first )
return first;
if( line > last )
return last;
#ifdef LIVEWIRE
if( jsdscript && jsdscript->lwscript )
{
uintN newline;
jsdlw_ProcessedToRawLineNumber(jsdc, jsdscript, line, &newline);
line = newline;
}
#endif
return line;
}
JSD_ScriptHookProc
JSBool
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata)
{
JSD_ScriptHookProc oldHook = jsdc->scriptHook;
JSD_LOCK();
jsdc->scriptHook = hook;
jsdc->scriptHookData = callerdata;
return oldHook;
JSD_UNLOCK();
return JS_TRUE;
}
JSD_ScriptHookProc
jsd_GetScriptHook(JSDContext* jsdc)
JSBool
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata)
{
return jsdc->scriptHook;
}
JSD_LOCK();
if( hook )
*hook = jsdc->scriptHook;
if( callerdata )
*callerdata = jsdc->scriptHookData;
JSD_UNLOCK();
return JS_TRUE;
}
/***************************************************************************/
void PR_CALLBACK
void JS_DLL_CALLBACK
jsd_NewScriptHookProc(
JSContext *cx,
const char *filename, /* URL this script loads from */
PRUintn lineno, /* line where this script starts */
uintN lineno, /* line where this script starts */
JSScript *script,
JSFunction *fun,
void* callerdata )
{
JSDScript* jsdscript = NULL;
JSDContext* jsdc = (JSDContext*) callerdata;
if( jsd_IsCurrentThreadDangerous() )
return;
JSD_ScriptHookProc hook;
void* hookData;
JSD_ASSERT_VALID_CONTEXT(jsdc);
jsd_LockScriptSubsystem(jsdc);
jsd_JSContextUsed(jsdc, cx);
jsdscript = NewJSDScript( jsdc, cx, script, fun );
if( ! jsdscript )
{
jsd_UnlockScriptSubsystem(jsdc);
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return;
}
#ifdef LIVEWIRE
if( 1 == lineno )
jsdlw_PreLoadSource(jsdc, LWDBG_GetCurrentApp(), filename, JS_TRUE );
#endif
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = _newJSDScript(jsdc, cx, script, fun);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return;
#ifdef JSD_DUMP
if( jsdscript )
{
DumpJSDScript( jsdc, jsdscript, "***NEW Script: " );
DumpJSDScriptList( jsdc );
}
JSD_LOCK_SCRIPTS(jsdc);
_dumpJSDScript(jsdc, jsdscript, "***NEW Script: ");
_dumpJSDScriptList( jsdc );
JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */
if( jsdc->scriptHook )
jsdc->scriptHook( jsdc, jsdscript, TRUE, jsdc->scriptHookData );
jsd_UnlockScriptSubsystem(jsdc);
/* local in case jsdc->scriptHook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->scriptHook;
hookData = jsdc->scriptHookData;
JSD_UNLOCK();
if( hook )
hook(jsdc, jsdscript, JS_TRUE, hookData);
}
void PR_CALLBACK
void JS_DLL_CALLBACK
jsd_DestroyScriptHookProc(
JSContext *cx,
JSScript *script,
@@ -321,51 +401,59 @@ jsd_DestroyScriptHookProc(
{
JSDScript* jsdscript = NULL;
JSDContext* jsdc = (JSDContext*) callerdata;
JSD_ScriptHookProc hook;
void* hookData;
if( jsd_IsCurrentThreadDangerous() )
return;
JSD_ASSERT_VALID_CONTEXT(jsdc);
jsd_LockScriptSubsystem(jsdc);
jsd_JSContextUsed(jsdc, cx);
jsdscript = jsd_FindJSDScript( jsdc, script );
if( ! jsdscript )
{
jsd_UnlockScriptSubsystem(jsdc);
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return;
}
#ifdef JSD_DUMP
DumpJSDScript( jsdc, jsdscript, "***DESTROY Script: " );
#endif /* JSD_DUMP */
if( jsdc->scriptHook )
jsdc->scriptHook( jsdc, jsdscript, FALSE, jsdc->scriptHookData );
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return;
DestroyJSDScript( jsdc, jsdscript );
#ifdef JSD_DUMP
DumpJSDScriptList( jsdc );
JSD_LOCK_SCRIPTS(jsdc);
_dumpJSDScript(jsdc, jsdscript, "***DESTROY Script: ");
JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */
jsd_UnlockScriptSubsystem(jsdc);
/* local in case hook gets cleared on another thread */
JSD_LOCK();
hook = jsdc->scriptHook;
hookData = jsdc->scriptHookData;
JSD_UNLOCK();
if( hook )
hook(jsdc, jsdscript, JS_FALSE, hookData);
JSD_LOCK_SCRIPTS(jsdc);
_destroyJSDScript(jsdc, jsdscript);
JSD_UNLOCK_SCRIPTS(jsdc);
#ifdef JSD_DUMP
JSD_LOCK_SCRIPTS(jsdc);
_dumpJSDScriptList(jsdc);
JSD_UNLOCK_SCRIPTS(jsdc);
#endif /* JSD_DUMP */
}
/***************************************************************************/
static JSDExecHook*
FindHook( JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
_findHook(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
{
JSDExecHook* jsdhook;
PRCList* list = &jsdscript->hooks;
JSCList* list = &jsdscript->hooks;
for (jsdhook = (JSDExecHook*)list->next;
for( jsdhook = (JSDExecHook*)list->next;
jsdhook != (JSDExecHook*)list;
jsdhook = (JSDExecHook*)jsdhook->links.next)
jsdhook = (JSDExecHook*)jsdhook->links.next )
{
if (jsdhook->pc == pc)
return jsdhook;
@@ -373,45 +461,82 @@ FindHook( JSDContext* jsdc, JSDScript* jsdscript, prword_t pc)
return NULL;
}
JSTrapStatus PR_CALLBACK
static JSBool
_isActiveHook(JSDContext* jsdc, JSScript *script, JSDExecHook* jsdhook)
{
JSDExecHook* current;
JSCList* list;
JSDScript* jsdscript;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
if( ! jsdscript)
{
JSD_UNLOCK_SCRIPTS(jsdc);
return JS_FALSE;
}
list = &jsdscript->hooks;
for( current = (JSDExecHook*)list->next;
current != (JSDExecHook*)list;
current = (JSDExecHook*)current->links.next )
{
if(current == jsdhook)
{
JSD_UNLOCK_SCRIPTS(jsdc);
return JS_TRUE;
}
}
JSD_UNLOCK_SCRIPTS(jsdc);
return JS_FALSE;
}
JSTrapStatus JS_DLL_CALLBACK
jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
void *closure)
{
PRUintn hookanswer = JSD_HOOK_RETURN_CONTINUE;
JSDThreadState* jsdthreadstate;
JSDExecHook* jsdhook = (JSDExecHook*) closure;
JSD_ExecutionHookProc hook;
void* hookData;
JSDContext* jsdc;
JSDScript* jsdscript;
if( jsd_IsCurrentThreadDangerous() )
JSD_LOCK();
if( NULL == (jsdc = jsd_JSDContextForJSContext(cx)) ||
! _isActiveHook(jsdc, script, jsdhook) )
{
JSD_UNLOCK();
return JSTRAP_CONTINUE;
}
JSD_ASSERT_VALID_EXEC_HOOK(jsdhook);
PR_ASSERT(jsdhook->pc == (prword_t)pc);
PR_ASSERT(jsdhook->jsdscript->script == script);
JS_ASSERT(jsdhook->pc == (jsuword)pc);
JS_ASSERT(jsdhook->jsdscript->script == script);
JS_ASSERT(jsdhook->jsdscript->jsdc == jsdc);
hook = jsdhook->hook;
hookData = jsdhook->callerdata;
jsdscript = jsdhook->jsdscript;
/* do not use jsdhook-> after this point */
JSD_UNLOCK();
jsdc = jsdhook->jsdscript->jsdc;
if( ! jsdc || ! jsdc->inited )
return JSTRAP_CONTINUE;
jsd_JSContextUsed(jsdc, cx);
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
return JSTRAP_CONTINUE;
jsdthreadstate = jsd_NewThreadState(jsdc,cx);
if( jsdthreadstate )
{
hookanswer =
(*jsdhook->hook)(jsdc, jsdthreadstate,
JSD_HOOK_BREAKPOINT,
jsdhook->callerdata );
#ifdef LIVEWIRE
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
return JSTRAP_CONTINUE;
#endif
jsd_DestroyThreadState(jsdc, jsdthreadstate);
}
*rval = NULL; /* XXX fix this!!! */
if( JSD_HOOK_RETURN_ABORT == hookanswer )
return JSTRAP_ERROR;
return JSTRAP_CONTINUE; /* XXX fix this!!! */
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_BREAKPOINT,
hook, hookData, rval);
}
@@ -419,16 +544,21 @@ jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
JSBool
jsd_SetExecutionHook(JSDContext* jsdc,
JSDScript* jsdscript,
prword_t pc,
jsuword pc,
JSD_ExecutionHookProc hook,
void* callerdata)
{
JSDExecHook* jsdhook;
JSD_LOCK();
if( ! hook )
return jsd_ClearExecutionHook(jsdc, jsdscript, pc);
{
jsd_ClearExecutionHook(jsdc, jsdscript, pc);
JSD_UNLOCK();
return JS_TRUE;
}
jsdhook = FindHook(jsdc, jsdscript, pc);
jsdhook = _findHook(jsdc, jsdscript, pc);
if( jsdhook )
{
jsdhook->hook = hook;
@@ -437,7 +567,7 @@ jsd_SetExecutionHook(JSDContext* jsdc,
}
/* else... */
jsdhook = PR_NEWZAP(JSDExecHook);
jsdhook = (JSDExecHook*)calloc(1, sizeof(JSDExecHook));
if( ! jsdhook )
return JS_FALSE;
jsdhook->jsdscript = jsdscript;
@@ -448,34 +578,40 @@ jsd_SetExecutionHook(JSDContext* jsdc,
if( ! JS_SetTrap(jsdc->dumbContext, jsdscript->script,
(jsbytecode*)pc, jsd_TrapHandler, (void*) jsdhook) )
{
PR_FREEIF(jsdhook);
free(jsdhook);
return JS_FALSE;
}
PR_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
JS_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
JSD_UNLOCK();
return JS_TRUE;
}
JSBool
jsd_ClearExecutionHook(JSDContext* jsdc,
JSDScript* jsdscript,
prword_t pc)
jsuword pc)
{
JSDExecHook* jsdhook;
jsdhook = FindHook(jsdc, jsdscript, pc);
JSD_LOCK();
jsdhook = _findHook(jsdc, jsdscript, pc);
if( ! jsdhook )
{
PR_ASSERT(0);
JS_ASSERT(0);
JSD_UNLOCK();
return JS_FALSE;
}
JS_ClearTrap(jsdc->dumbContext, jsdscript->script,
(jsbytecode*)pc, NULL, NULL );
PR_REMOVE_LINK(&jsdhook->links);
PR_FREEIF(jsdhook);
JS_REMOVE_LINK(&jsdhook->links);
free(jsdhook);
JSD_UNLOCK();
return JS_TRUE;
}
@@ -483,15 +619,19 @@ JSBool
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript)
{
JSDExecHook* jsdhook;
PRCList* list = &jsdscript->hooks;
JSCList* list = &jsdscript->hooks;
JSD_LOCK();
while( (JSDExecHook*)list != (jsdhook = (JSDExecHook*)list->next) )
{
PR_REMOVE_LINK(&jsdhook->links);
PR_FREEIF(jsdhook);
JS_REMOVE_LINK(&jsdhook->links);
free(jsdhook);
}
JS_ClearScriptTraps(jsdc->dumbContext, jsdscript->script);
JSD_UNLOCK();
return JS_TRUE;
}
@@ -501,8 +641,28 @@ jsd_ClearAllExecutionHooks(JSDContext* jsdc)
JSDScript* jsdscript;
JSDScript* iterp = NULL;
JSD_LOCK();
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
JSD_UNLOCK();
return JS_TRUE;
}
void
jsd_ScriptCreated(JSDContext* jsdc,
JSContext *cx,
const char *filename, /* URL this script loads from */
uintN lineno, /* line where this script starts */
JSScript *script,
JSFunction *fun)
{
jsd_NewScriptHookProc(cx, filename, lineno, script, fun, jsdc);
}
void
jsd_ScriptDestroyed(JSDContext* jsdc,
JSContext *cx,
JSScript *script)
{
jsd_DestroyScriptHookProc(cx, script, jsdc);
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,71 +17,63 @@
*/
/*
** JavaScript Debugger Navigator API - Call Stack support
*/
* JavaScript Debugging support - Call stack support
*/
#include "jsd.h"
#ifdef NSPR20
#ifdef XP_MAC
#include "prpriv.h"
#else
#include "private/prpriv.h"
#endif
#endif
#ifdef DEBUG
void JSD_ASSERT_VALID_THREAD_STATE( JSDThreadState* jsdthreadstate )
void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate)
{
PR_ASSERT(jsdthreadstate);
PR_ASSERT(jsdthreadstate->stackDepth > 0);
JS_ASSERT(jsdthreadstate);
JS_ASSERT(jsdthreadstate->stackDepth > 0);
}
void JSD_ASSERT_VALID_STACK_FRAME( JSDStackFrameInfo* jsdframe )
void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe)
{
PR_ASSERT(jsdframe);
PR_ASSERT(jsdframe->jsdthreadstate);
JS_ASSERT(jsdframe);
JS_ASSERT(jsdframe->jsdthreadstate);
}
#endif
static JSDStackFrameInfo*
AddNewFrame( JSDContext* jsdc,
_addNewFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSScript* script,
prword_t pc,
JSObject* object,
JSObject* thisp,
JSStackFrame* fp )
jsuword pc,
JSStackFrame* fp)
{
JSDStackFrameInfo* jsdframe;
JSDScript* jsdscript;
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if( ! jsdscript )
return NULL;
jsdframe = PR_NEWZAP(JSDStackFrameInfo);
jsdframe = (JSDStackFrameInfo*) calloc(1, sizeof(JSDStackFrameInfo));
if( ! jsdframe )
return NULL;
jsdframe->jsdthreadstate = jsdthreadstate;
jsdframe->jsdscript = jsdscript ;
jsdframe->pc = pc ;
jsdframe->object = object ;
jsdframe->thisp = thisp ;
jsdframe->fp = fp ;
PR_APPEND_LINK(&jsdframe->links, &jsdthreadstate->stack);
JS_APPEND_LINK(&jsdframe->links, &jsdthreadstate->stack);
jsdthreadstate->stackDepth++;
return jsdframe;
}
static void
DestroyFrame(JSDStackFrameInfo* jsdframe)
_destroyFrame(JSDStackFrameInfo* jsdframe)
{
/* kill any alloc'd objects in frame here... */
PR_FREEIF(jsdframe);
if( jsdframe )
free(jsdframe);
}
@@ -92,31 +84,36 @@ jsd_NewThreadState(JSDContext* jsdc, JSContext *cx )
JSStackFrame * iter = NULL;
JSStackFrame * fp;
jsdthreadstate = PR_NEWZAP(JSDThreadState);
jsdthreadstate = (JSDThreadState*)calloc(1, sizeof(JSDThreadState));
if( ! jsdthreadstate )
return NULL;
jsdthreadstate->context = cx;
jsdthreadstate->thread = PR_CurrentThread();
PR_INIT_CLIST(&jsdthreadstate->stack);
jsdthreadstate->thread = JSD_CURRENT_THREAD();
JS_INIT_CLIST(&jsdthreadstate->stack);
jsdthreadstate->stackDepth = 0;
while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
{
JSScript* script = JS_GetFrameScript(cx, fp);
prword_t pc = (prword_t) JS_GetFramePC(cx, fp);
jsuword pc = (jsuword) JS_GetFramePC(cx, fp);
if( ! script || ! pc || JS_IsNativeFrame(cx, fp) )
continue;
AddNewFrame( jsdc, jsdthreadstate, script, pc,
JS_GetFrameObject(cx, fp),
JS_GetFrameThis(cx, fp), fp );
_addNewFrame( jsdc, jsdthreadstate, script, pc, fp );
}
/* if there is no stack, then this threadstate can not be constructed */
if( 0 == jsdthreadstate->stackDepth )
{
free(jsdthreadstate);
return NULL;
}
jsd_LockThreadsStates(jsdc);
PR_APPEND_LINK(&jsdthreadstate->links, &jsdc->threadsStates);
jsd_UnlockThreadStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
JS_APPEND_LINK(&jsdthreadstate->links, &jsdc->threadsStates);
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdthreadstate;
}
@@ -125,50 +122,35 @@ void
jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
JSDStackFrameInfo* jsdframe;
PRCList* list;
int64 i;
JSCList* list;
#ifndef NSPR20
LL_I2L(i,100);
#endif
/* we need to wait if someone else is using the threadstate */
jsd_LockThreadsStates(jsdc);
while( jsdthreadstate->wait )
{
jsd_UnlockThreadStates(jsdc);
#ifndef NSPR20
PR_Sleep(i);
#else
PR_Sleep(PR_MicrosecondsToInterval(100));
#endif
jsd_LockThreadsStates(jsdc);
}
PR_REMOVE_LINK(&jsdthreadstate->links);
jsd_UnlockThreadStates(jsdc);
JSD_ASSERT_VALID_THREAD_STATE(jsdthreadstate);
JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread);
JSD_LOCK_THREADSTATES(jsdc);
JS_REMOVE_LINK(&jsdthreadstate->links);
JSD_UNLOCK_THREADSTATES(jsdc);
list = &jsdthreadstate->stack;
while( (JSDStackFrameInfo*)list != (jsdframe = (JSDStackFrameInfo*)list->next) )
{
PR_REMOVE_LINK(&jsdframe->links);
DestroyFrame(jsdframe);
JS_REMOVE_LINK(&jsdframe->links);
_destroyFrame(jsdframe);
}
PR_FREEIF(jsdthreadstate);
free(jsdthreadstate);
}
PRUintn
uintN
jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
PRUintn count = 0;
uintN count = 0;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidThreadState(jsdc, jsdthreadstate) )
count = jsdthreadstate->stackDepth;
jsd_UnlockThreadStates(jsdc);
JSD_UNLOCK_THREADSTATES(jsdc);
return count;
}
@@ -178,12 +160,11 @@ jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
JSDStackFrameInfo* jsdframe = NULL;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidThreadState(jsdc, jsdthreadstate) )
jsdframe = (JSDStackFrameInfo*) PR_LIST_HEAD(&jsdthreadstate->stack);
jsd_UnlockThreadStates(jsdc);
jsdframe = (JSDStackFrameInfo*) JS_LIST_HEAD(&jsdthreadstate->stack);
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdframe;
}
@@ -195,13 +176,13 @@ jsd_GetCallingStackFrame(JSDContext* jsdc,
{
JSDStackFrameInfo* nextjsdframe = NULL;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
if( PR_LIST_HEAD(&jsdframe->links) != &jsdframe->jsdthreadstate->stack )
nextjsdframe = (JSDStackFrameInfo*) PR_LIST_HEAD(&jsdframe->links);
if( JS_LIST_HEAD(&jsdframe->links) != &jsdframe->jsdthreadstate->stack )
nextjsdframe = (JSDStackFrameInfo*) JS_LIST_HEAD(&jsdframe->links);
jsd_UnlockThreadStates(jsdc);
JSD_UNLOCK_THREADSTATES(jsdc);
return nextjsdframe;
}
@@ -213,58 +194,130 @@ jsd_GetScriptForStackFrame(JSDContext* jsdc,
{
JSDScript* jsdscript = NULL;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
jsdscript = jsdframe->jsdscript;
jsd_UnlockThreadStates(jsdc);
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdscript;
}
prword_t
jsuword
jsd_GetPCForStackFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe)
{
prword_t pc = 0;
jsuword pc = 0;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
pc = jsdframe->pc;
jsd_UnlockThreadStates(jsdc);
JSD_UNLOCK_THREADSTATES(jsdc);
return pc;
}
JSDValue*
jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe)
{
JSObject* obj;
JSDValue* jsdval = NULL;
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
{
obj = JS_GetFrameCallObject(jsdthreadstate->context, jsdframe->fp);
if(obj)
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
}
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdval;
}
JSDValue*
jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe)
{
JSObject* obj;
JSDValue* jsdval = NULL;
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
{
obj = JS_GetFrameScopeChain(jsdthreadstate->context, jsdframe->fp);
if(obj)
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
}
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdval;
}
JSDValue*
jsd_GetThisForStackFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe)
{
JSObject* obj;
JSDValue* jsdval = NULL;
JSD_LOCK_THREADSTATES(jsdc);
if( jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
{
obj = JS_GetFrameThis(jsdthreadstate->context, jsdframe->fp);
if(obj)
jsdval = JSD_NewValue(jsdc, OBJECT_TO_JSVAL(obj));
}
JSD_UNLOCK_THREADSTATES(jsdc);
return jsdval;
}
JSBool
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe,
const char *bytes, PRUintn length,
const char *filename, PRUintn lineno, jsval *rval)
const char *bytes, uintN length,
const char *filename, uintN lineno, jsval *rval)
{
JSBool retval;
JSBool valid;
JSExceptionState* exceptionState;
JSContext* cx;
jsd_LockThreadsStates(jsdc);
JS_ASSERT(JSD_CURRENT_THREAD() == jsdthreadstate->thread);
if( ! jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
{
jsd_UnlockThreadStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe);
JSD_UNLOCK_THREADSTATES(jsdc);
if( ! valid )
return JS_FALSE;
}
jsdthreadstate->wait++ ;
jsd_UnlockThreadStates(jsdc);
retval = JS_EvaluateInStackFrame(jsdthreadstate->context, jsdframe->fp,
bytes, length, filename, lineno, rval);
cx = jsdthreadstate->context;
JS_ASSERT(cx);
jsd_LockThreadsStates(jsdc);
jsdthreadstate->wait-- ;
jsd_UnlockThreadStates(jsdc);
exceptionState = JS_SaveExceptionState(cx);
jsd_StartingEvalUsingFilename(jsdc, filename);
retval = JS_EvaluateInStackFrame(cx, jsdframe->fp, bytes, length,
filename, lineno, rval);
jsd_FinishedEvalUsingFilename(jsdc, filename);
JS_RestoreExceptionState(cx, exceptionState);
return retval;
}
@@ -275,72 +328,37 @@ jsd_ValToStringInStackFrame(JSDContext* jsdc,
JSDStackFrameInfo* jsdframe,
jsval val)
{
JSString* jsstr = NULL;
JSBool valid;
JSString* retval;
JSExceptionState* exceptionState;
JSContext* cx;
jsd_LockThreadsStates(jsdc);
JSD_LOCK_THREADSTATES(jsdc);
valid = jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe);
JSD_UNLOCK_THREADSTATES(jsdc);
if( ! jsd_IsValidFrameInThreadState(jsdc, jsdthreadstate, jsdframe) )
{
jsd_UnlockThreadStates(jsdc);
if( ! valid )
return NULL;
}
jsdthreadstate->wait++ ;
jsd_UnlockThreadStates(jsdc);
jsstr = JS_ValueToString(jsdthreadstate->context, val);
cx = jsdthreadstate->context;
JS_ASSERT(cx);
jsd_LockThreadsStates(jsdc);
jsdthreadstate->wait-- ;
jsd_UnlockThreadStates(jsdc);
exceptionState = JS_SaveExceptionState(cx);
retval = JS_ValueToString(cx, val);
JS_RestoreExceptionState(cx, exceptionState);
return jsstr;
}
/***************************************************************************/
#ifndef JSD_SIMULATION
static PRMonitor *jsd_threadstate_mon = NULL;
#endif /* JSD_SIMULATION */
void
jsd_LockThreadsStates(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
if (jsd_threadstate_mon == NULL)
jsd_threadstate_mon = PR_NewNamedMonitor("jsd-threadstate-monitor");
PR_EnterMonitor(jsd_threadstate_mon);
#endif /* JSD_SIMULATION */
}
void
jsd_UnlockThreadStates(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
PR_ExitMonitor(jsd_threadstate_mon);
#endif /* JSD_SIMULATION */
}
JSBool
jsd_ThreadStatesIsLocked(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
return jsd_threadstate_mon && PR_InMonitor(jsd_threadstate_mon);
#else
return JS_TRUE;
#endif /* JSD_SIMULATION */
return retval;
}
JSBool
jsd_IsValidThreadState(JSDContext* jsdc,
JSDThreadState* jsdthreadstate )
JSDThreadState* jsdthreadstate)
{
JSDThreadState *cur;
PR_ASSERT( jsd_ThreadStatesIsLocked(jsdc) );
JS_ASSERT( JSD_THREADSTATES_LOCKED(jsdc) );
for (cur = (JSDThreadState*)jsdc->threadsStates.next;
for( cur = (JSDThreadState*)jsdc->threadsStates.next;
cur != (JSDThreadState*)&jsdc->threadsStates;
cur = (JSDThreadState*)cur->links.next )
{
@@ -353,9 +371,9 @@ jsd_IsValidThreadState(JSDContext* jsdc,
JSBool
jsd_IsValidFrameInThreadState(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
JSDStackFrameInfo* jsdframe )
JSDStackFrameInfo* jsdframe)
{
PR_ASSERT( jsd_ThreadStatesIsLocked(jsdc) );
JS_ASSERT(JSD_THREADSTATES_LOCKED(jsdc));
if( ! jsd_IsValidThreadState(jsdc, jsdthreadstate) )
return JS_FALSE;
@@ -367,3 +385,45 @@ jsd_IsValidFrameInThreadState(JSDContext* jsdc,
return JS_TRUE;
}
static JSContext*
_getContextForThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
JSBool valid;
JSD_LOCK_THREADSTATES(jsdc);
valid = jsd_IsValidThreadState(jsdc, jsdthreadstate);
JSD_UNLOCK_THREADSTATES(jsdc);
if( valid )
return jsdthreadstate->context;
return NULL;
}
JSDValue*
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate)
{
JSContext* cx;
jsval val;
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
return NULL;
if(JS_GetPendingException(cx, &val))
return jsd_NewValue(jsdc, val);
return NULL;
}
JSBool
jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
JSDValue* jsdval)
{
JSContext* cx;
if(!(cx = _getContextForThreadState(jsdc, jsdthreadstate)))
return JS_FALSE;
if(jsdval)
JS_SetPendingException(cx, JSD_GetValueWrappedJSVal(jsdc, jsdval));
else
JS_ClearPendingException(cx);
return JS_TRUE;
}

116
mozilla/js/jsd/jsd_step.c Normal file
View File

@@ -0,0 +1,116 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* JavaScript Debugging support - Stepping support
*/
#include "jsd.h"
/*
* #define JSD_TRACE 1
*/
#ifdef JSD_TRACE
static char*
_indentSpaces(int i)
{
#define MAX_INDENT 63
static char* p = NULL;
if(!p)
{
p = calloc(1, MAX_INDENT+1);
if(!p) return "";
memset(p, ' ', MAX_INDENT);
}
if(i > MAX_INDENT) return p;
return p + MAX_INDENT-i;
}
static void
_interpreterTrace(JSDContext* jsdc, JSContext *cx, JSStackFrame *fp,
JSBool before, JSBool *ok)
{
JSDScript* jsdscript = NULL;
JSScript * script;
static indent = 0;
char* buf;
const char* funName = NULL;
script = JS_GetFrameScript(cx, fp);
if(script)
{
JSD_LOCK_SCRIPTS(jsdc);
jsdscript = jsd_FindJSDScript(jsdc, script);
JSD_UNLOCK_SCRIPTS(jsdc);
if(jsdscript)
funName = JSD_GetScriptFunctionName(jsdc, jsdscript);
}
if(!funName)
funName = "TOP_LEVEL";
if(before)
{
buf = JS_smprintf("%sentering %s %s this: %0x\n",
_indentSpaces(indent++),
funName,
JS_IsContructorFrame(cx, fp) ? "constructing":"",
(int)JS_GetFrameThis(cx, fp));
}
else
{
buf = JS_smprintf("%sleaving %s\n",
_indentSpaces(--indent),
funName);
}
JS_ASSERT(indent >= 0);
if(!buf)
return;
printf(buf);
free(buf);
}
#endif
void * JS_DLL_CALLBACK
jsd_InterpreterHook(JSContext *cx, JSStackFrame *fp, JSBool before,
JSBool *ok, void *closure)
{
JSDContext* jsdc = (JSDContext*) closure;
if( ! jsdc || ! jsdc->inited )
return NULL;
if(before && JS_IsContructorFrame(cx, fp))
jsd_Constructing(jsdc, cx, JS_GetFrameThis(cx, fp), fp);
#ifdef JSD_TRACE
_interpreterTrace(jsdc, cx, fp, before, ok);
return closure;
#else
return NULL;
#endif
/*
* use this before calling any hook...
* if( JSD_IS_DANGEROUS_THREAD(jsdc) )
* return NULL;
*/
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -17,182 +17,149 @@
*/
/*
** JavaScript Debugger Navigator API - Source Text functions
*/
* JavaScript Debugging support - Source Text functions
*/
#include "jsd.h"
#ifdef NSPR20
#ifdef XP_MAC
#include "prpriv.h"
#else
#include "private/prpriv.h"
#endif
#endif
/**
* XXX convert this and jsd_conv so that all accumulation of text done here
* Also, use handle oriented alloc for Win16 64k limit problem
*/
PRCList jsd_source_list = PR_INIT_STATIC_CLIST(&jsd_source_list);
PRCList jsd_removed_source_list = PR_INIT_STATIC_CLIST(&jsd_removed_source_list);
/***************************************************************************/
/*
* typedef enum
* {
* JSD_SOURCE_INITED,
* JSD_SOURCE_PARTIAL,
* JSD_SOURCE_COMPLETED,
* JSD_SOURCE_ABORTED,
* JSD_SOURCE_FAILED
*
* } JSDSourceStatus;
*/
#ifdef DEBUG
void JSD_ASSERT_VALID_SOURCE_TEXT( JSDSourceText* jsdsrc )
void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc)
{
PR_ASSERT( jsdsrc );
PR_ASSERT( jsdsrc->url );
JS_ASSERT(jsdsrc);
JS_ASSERT(jsdsrc->url);
}
#endif
/***************************************************************************/
/* XXX add serial number instead of dirty */
/* XXX add notification */
static PRUintn g_alterCount = 1;
static void
ClearText( JSDContext* jsdc, JSDSourceText* jsdsrc )
_clearText(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
if( jsdsrc->text )
MY_XP_HUGE_FREE(jsdsrc->text);
free(jsdsrc->text);
jsdsrc->text = NULL;
jsdsrc->textLength = 0;
jsdsrc->textSpace = 0;
jsdsrc->status = JSD_SOURCE_CLEARED;
jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = g_alterCount++ ;
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
jsdsrc->doingEval = JS_FALSE;
}
static JSBool
AppendText( JSDContext* jsdc, JSDSourceText* jsdsrc,
const char* text, size_t length )
_appendText(JSDContext* jsdc, JSDSourceText* jsdsrc,
const char* text, size_t length)
{
#define MEMBUF_GROW 1000
PRUintn neededSize = jsdsrc->textLength + length;
uintN neededSize = jsdsrc->textLength + length;
if( neededSize > jsdsrc->textSpace )
{
MY_XP_HUGE_CHAR_PTR pBuf;
PRUintn iNewSize;
char* newBuf;
uintN iNewSize;
/* if this is the first alloc, the req might be all that's needed*/
if( ! jsdsrc->textSpace )
iNewSize = length;
iNewSize = length;
else
iNewSize = (neededSize * 5 / 4) + MEMBUF_GROW;
iNewSize = (neededSize * 5 / 4) + MEMBUF_GROW;
pBuf = (MY_XP_HUGE_CHAR_PTR) MY_XP_HUGE_ALLOC(iNewSize);
if( pBuf )
newBuf = (char*) realloc(jsdsrc->text, iNewSize);
if( ! newBuf )
{
if( jsdsrc->text )
/* try again with the minimal size really asked for */
iNewSize = neededSize;
newBuf = (char*) realloc(jsdsrc->text, iNewSize);
if( ! newBuf )
{
MY_XP_HUGE_MEMCPY(pBuf, jsdsrc->text, jsdsrc->textLength);
MY_XP_HUGE_FREE(jsdsrc->text);
/* out of memory */
_clearText( jsdc, jsdsrc );
jsdsrc->status = JSD_SOURCE_FAILED;
return JS_FALSE;
}
jsdsrc->text = pBuf;
jsdsrc->textSpace = iNewSize;
}
else
{
/* LTNOTE: throw an out of memory exception */
ClearText( jsdc, jsdsrc );
jsdsrc->status = JSD_SOURCE_FAILED;
return JS_FALSE;
}
jsdsrc->text = newBuf;
jsdsrc->textSpace = iNewSize;
}
MY_XP_HUGE_MEMCPY( &jsdsrc->text[jsdsrc->textLength], text, length );
memcpy(jsdsrc->text + jsdsrc->textLength, text, length);
jsdsrc->textLength += length;
return JS_TRUE;
}
static JSDSourceText*
NewSource( JSDContext* jsdc, const char* url )
_newSource(JSDContext* jsdc, const char* url)
{
JSDSourceText* jsdsrc = PR_NEWZAP(JSDSourceText);
JSDSourceText* jsdsrc = (JSDSourceText*)calloc(1,sizeof(JSDSourceText));
if( ! jsdsrc )
return NULL;
jsdsrc->url = (char*) url; /* already a copy */
jsdsrc->status = JSD_SOURCE_INITED;
jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = g_alterCount++ ;
jsdsrc->url = (char*) url; /* already a copy */
jsdsrc->status = JSD_SOURCE_INITED;
jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
return jsdsrc;
}
static void
DestroySource( JSDContext* jsdc, JSDSourceText* jsdsrc )
_destroySource(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
PR_ASSERT( NULL == jsdsrc->text ); /* must ClearText() first */
MY_XP_FREE(jsdsrc->url);
MY_XP_FREE(jsdsrc);
JS_ASSERT(NULL == jsdsrc->text); /* must _clearText() first */
free(jsdsrc->url);
free(jsdsrc);
}
static void
RemoveSource( JSDContext* jsdc, JSDSourceText* jsdsrc )
_removeSource(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
PR_REMOVE_LINK(&jsdsrc->links);
ClearText( jsdc, jsdsrc );
DestroySource( jsdc, jsdsrc );
JS_REMOVE_LINK(&jsdsrc->links);
_clearText(jsdc, jsdsrc);
_destroySource(jsdc, jsdsrc);
}
static JSDSourceText*
AddSource( JSDContext* jsdc, const char* url )
_addSource(JSDContext* jsdc, const char* url)
{
JSDSourceText* jsdsrc = NewSource( jsdc, url );
JSDSourceText* jsdsrc = _newSource(jsdc, url);
if( ! jsdsrc )
return NULL;
PR_INSERT_LINK(&jsdsrc->links, &jsd_source_list);
JS_INSERT_LINK(&jsdsrc->links, &jsdc->sources);
return jsdsrc;
}
static void
MoveSourceToFront( JSDContext* jsdc, JSDSourceText* jsdsrc )
_moveSourceToFront(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
PR_REMOVE_LINK(&jsdsrc->links);
PR_INSERT_LINK(&jsdsrc->links, &jsd_source_list);
JS_REMOVE_LINK(&jsdsrc->links);
JS_INSERT_LINK(&jsdsrc->links, &jsdc->sources);
}
static void
MoveSourceToRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
_moveSourceToRemovedList(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
ClearText(jsdc, jsdsrc);
PR_REMOVE_LINK(&jsdsrc->links);
PR_INSERT_LINK(&jsdsrc->links, &jsd_removed_source_list);
_clearText(jsdc, jsdsrc);
JS_REMOVE_LINK(&jsdsrc->links);
JS_INSERT_LINK(&jsdsrc->links, &jsdc->removedSources);
}
static void
RemoveSourceFromRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
_removeSourceFromRemovedList( JSDContext* jsdc, JSDSourceText* jsdsrc )
{
PR_REMOVE_LINK(&jsdsrc->links);
DestroySource( jsdc, jsdsrc );
JS_REMOVE_LINK(&jsdsrc->links);
_destroySource( jsdc, jsdsrc );
}
static JSBool
IsSourceInSourceList( JSDContext* jsdc, JSDSourceText* jsdsrcToFind )
_isSourceInSourceList(JSDContext* jsdc, JSDSourceText* jsdsrcToFind)
{
JSDSourceText *jsdsrc;
for (jsdsrc = (JSDSourceText*)jsd_source_list.next;
jsdsrc != (JSDSourceText*)&jsd_source_list;
for( jsdsrc = (JSDSourceText*)jsdc->sources.next;
jsdsrc != (JSDSourceText*)&jsdc->sources;
jsdsrc = (JSDSourceText*)jsdsrc->links.next )
{
if( jsdsrc == jsdsrcToFind )
@@ -201,26 +168,26 @@ IsSourceInSourceList( JSDContext* jsdc, JSDSourceText* jsdsrcToFind )
return JS_FALSE;
}
/* compare strings in a case insensitive manner with a length limit
/* compare strings in a case insensitive manner with a length limit
*/
static int
strncasecomp (const char* one, const char * two, int n)
{
const char *pA;
const char *pB;
for(pA=one, pB=two;; pA++, pB++)
{
int tmp;
if (pA == one+n)
return 0;
if (!(*pA && *pB))
return *pA - *pB;
tmp = MY_XP_TO_LOWER(*pA) - MY_XP_TO_LOWER(*pB);
if (tmp)
return tmp;
}
const char *pA;
const char *pB;
for(pA=one, pB=two;; pA++, pB++)
{
int tmp;
if (pA == one+n)
return 0;
if (!(*pA && *pB))
return *pA - *pB;
tmp = tolower(*pA) - tolower(*pB);
if (tmp)
return tmp;
}
}
static char file_url_prefix[] = "file:";
@@ -234,63 +201,40 @@ jsd_BuildNormalizedURL( const char* url_string )
if( ! url_string )
return NULL;
if (!MY_XP_STRNCASECMP(url_string, file_url_prefix, FILE_URL_PREFIX_LEN) &&
if (!strncasecomp(url_string, file_url_prefix, FILE_URL_PREFIX_LEN) &&
url_string[FILE_URL_PREFIX_LEN + 0] == '/' &&
url_string[FILE_URL_PREFIX_LEN + 1] == '/') {
new_url_string = PR_smprintf("%s%s",
new_url_string = JS_smprintf("%s%s",
file_url_prefix,
url_string + FILE_URL_PREFIX_LEN + 2);
} else {
new_url_string = MY_XP_STRDUP(url_string);
new_url_string = strdup(url_string);
}
return new_url_string;
}
/***************************************************************************/
#ifndef JSD_SIMULATION
static PRMonitor *jsd_text_mon = NULL;
#endif /* JSD_SIMULATION */
void
jsd_LockSourceTextSubsystem(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
if (jsd_text_mon == NULL)
jsd_text_mon = PR_NewNamedMonitor("jsd-text-monitor");
PR_EnterMonitor(jsd_text_mon);
#endif /* JSD_SIMULATION */
}
void
jsd_UnlockSourceTextSubsystem(JSDContext* jsdc)
{
#ifndef JSD_SIMULATION
PR_ExitMonitor(jsd_text_mon);
#endif /* JSD_SIMULATION */
}
void
jsd_DestroyAllSources( JSDContext* jsdc )
{
JSDSourceText *jsdsrc;
JSDSourceText *next;
for (jsdsrc = (JSDSourceText*)jsd_source_list.next;
jsdsrc != (JSDSourceText*)&jsd_source_list;
jsdsrc = next)
for( jsdsrc = (JSDSourceText*)jsdc->sources.next;
jsdsrc != (JSDSourceText*)&jsdc->sources;
jsdsrc = next )
{
next = (JSDSourceText*)jsdsrc->links.next;
RemoveSource( jsdc, jsdsrc );
_removeSource( jsdc, jsdsrc );
}
for (jsdsrc = (JSDSourceText*)jsd_removed_source_list.next;
jsdsrc != (JSDSourceText*)&jsd_removed_source_list;
jsdsrc = next)
for( jsdsrc = (JSDSourceText*)jsdc->removedSources.next;
jsdsrc != (JSDSourceText*)&jsdc->removedSources;
jsdsrc = next )
{
next = (JSDSourceText*)jsdsrc->links.next;
RemoveSourceFromRemovedList( jsdc, jsdsrc );
_removeSourceFromRemovedList( jsdc, jsdsrc );
}
}
@@ -300,9 +244,9 @@ jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp)
{
JSDSourceText *jsdsrc = *iterp;
if (!jsdsrc)
jsdsrc = (JSDSourceText *)jsd_source_list.next;
if (jsdsrc == (JSDSourceText *)&jsd_source_list)
if( !jsdsrc )
jsdsrc = (JSDSourceText *)jsdc->sources.next;
if( jsdsrc == (JSDSourceText *)&jsdc->sources )
return NULL;
*iterp = (JSDSourceText *)jsdsrc->links.next;
return jsdsrc;
@@ -313,10 +257,11 @@ jsd_FindSourceForURL(JSDContext* jsdc, const char* url)
{
JSDSourceText *jsdsrc;
for (jsdsrc = (JSDSourceText *)jsd_source_list.next;
jsdsrc != (JSDSourceText *)&jsd_source_list;
jsdsrc = (JSDSourceText *)jsdsrc->links.next) {
if (0 == strcmp(jsdsrc->url, url))
for( jsdsrc = (JSDSourceText *)jsdc->sources.next;
jsdsrc != (JSDSourceText *)&jsdc->sources;
jsdsrc = (JSDSourceText *)jsdsrc->links.next )
{
if( 0 == strcmp(jsdsrc->url, url) )
return jsdsrc;
}
return NULL;
@@ -330,7 +275,7 @@ jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc)
JSBool
jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
const char** ppBuf, int* pLen )
const char** ppBuf, intN* pLen )
{
*ppBuf = jsdsrc->text;
*pLen = jsdsrc->textLength;
@@ -343,7 +288,7 @@ jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc)
if( JSD_SOURCE_INITED != jsdsrc->status &&
JSD_SOURCE_PARTIAL != jsdsrc->status )
{
ClearText(jsdc, jsdsrc);
_clearText(jsdc, jsdsrc);
}
}
@@ -365,16 +310,16 @@ jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty)
jsdsrc->dirty = dirty;
}
PRUintn
uintN
jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
return jsdsrc->alterCount;
}
PRUintn
uintN
jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc)
{
return ++jsdsrc->alterCount;
return jsdsrc->alterCount = jsdc->sourceAlterCount++;
}
/***************************************************************************/
@@ -415,20 +360,35 @@ jsd_NewSourceText(JSDContext* jsdc, const char* url)
JSDSourceText* jsdsrc;
const char* new_url_string;
jsd_LockSourceTextSubsystem(jsdc);
JSD_LOCK_SOURCE_TEXT(jsdc);
#ifdef LIVEWIRE
new_url_string = url; /* we take ownership of alloc'd string */
#else
new_url_string = jsd_BuildNormalizedURL(url);
#endif
if( ! new_url_string )
return NULL;
jsdsrc = jsd_FindSourceForURL(jsdc, new_url_string);
if( jsdsrc )
MoveSourceToRemovedList(jsdc, jsdsrc);
{
if( jsdsrc->doingEval )
{
#ifdef LIVEWIRE
free((char*)new_url_string);
#endif
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL;
}
else
_moveSourceToRemovedList(jsdc, jsdsrc);
}
jsdsrc = AddSource( jsdc, new_url_string );
jsdsrc = _addSource( jsdc, new_url_string );
jsd_UnlockSourceTextSubsystem(jsdc);
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return jsdsrc;
}
@@ -440,32 +400,148 @@ jsd_AppendSourceText(JSDContext* jsdc,
size_t length,
JSDSourceStatus status)
{
jsd_LockSourceTextSubsystem(jsdc);
JSD_LOCK_SOURCE_TEXT(jsdc);
if( ! IsSourceInSourceList( jsdc, jsdsrc ) )
if( jsdsrc->doingEval )
{
RemoveSourceFromRemovedList( jsdc, jsdsrc );
jsd_UnlockSourceTextSubsystem(jsdc);
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL;
}
if( text && length && ! AppendText( jsdc, jsdsrc, text, length ) )
if( ! _isSourceInSourceList( jsdc, jsdsrc ) )
{
_removeSourceFromRemovedList( jsdc, jsdsrc );
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL;
}
if( text && length && ! _appendText( jsdc, jsdsrc, text, length ) )
{
jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = g_alterCount++ ;
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
jsdsrc->status = JSD_SOURCE_FAILED;
MoveSourceToRemovedList(jsdc, jsdsrc);
jsd_UnlockSourceTextSubsystem(jsdc);
_moveSourceToRemovedList(jsdc, jsdsrc);
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL;
}
jsdsrc->dirty = JS_TRUE;
jsdsrc->alterCount = g_alterCount++ ;
jsdsrc->alterCount = jsdc->sourceAlterCount++ ;
jsdsrc->status = status;
DEBUG_ITERATE_SOURCES(jsdc);
jsd_UnlockSourceTextSubsystem(jsdc);
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return jsdsrc;
}
JSDSourceText*
jsd_AppendUCSourceText(JSDContext* jsdc,
JSDSourceText* jsdsrc,
const jschar* text, /* *not* zero terminated */
size_t length,
JSDSourceStatus status)
{
#define UNICODE_TRUNCATE_BUF_SIZE 1024
static char* buf = NULL;
int remaining = length;
if(!text || !length)
return jsd_AppendSourceText(jsdc, jsdsrc, NULL, 0, status);
JSD_LOCK_SOURCE_TEXT(jsdc);
if(!buf)
{
buf = malloc(UNICODE_TRUNCATE_BUF_SIZE);
if(!buf)
{
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return NULL;
}
}
while(remaining && jsdsrc) {
int bytes = JS_MIN(remaining, UNICODE_TRUNCATE_BUF_SIZE);
int i;
for(i = 0; i < bytes; i++)
buf[i] = (const char) *(text++);
jsdsrc = jsd_AppendSourceText(jsdc,jsdsrc,
buf, bytes,
JSD_SOURCE_PARTIAL);
remaining -= bytes;
}
if(jsdsrc && status != JSD_SOURCE_PARTIAL)
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc, NULL, 0, status);
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return jsdsrc;
}
/* convienence function for adding complete source of url in one call */
JSBool
jsd_AddFullSourceText(JSDContext* jsdc,
const char* text, /* *not* zero terminated */
size_t length,
const char* url)
{
JSDSourceText* jsdsrc;
JSD_LOCK_SOURCE_TEXT(jsdc);
jsdsrc = jsd_NewSourceText(jsdc, url);
if( jsdsrc )
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
text, length, JSD_SOURCE_PARTIAL );
if( jsdsrc )
jsdsrc = jsd_AppendSourceText(jsdc, jsdsrc,
NULL, 0, JSD_SOURCE_COMPLETED );
JSD_UNLOCK_SOURCE_TEXT(jsdc);
return jsdsrc ? JS_TRUE : JS_FALSE;
}
/***************************************************************************/
void
jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url)
{
JSDSourceText* jsdsrc;
/* NOTE: We leave it locked! */
JSD_LOCK_SOURCE_TEXT(jsdc);
jsdsrc = jsd_FindSourceForURL(jsdc, url);
if(jsdsrc)
{
#if 0
#ifndef JSD_LOWLEVEL_SOURCE
JS_ASSERT(! jsdsrc->doingEval);
#endif
#endif
jsdsrc->doingEval = JS_TRUE;
}
}
void
jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url)
{
JSDSourceText* jsdsrc;
/* NOTE: We ASSUME it is locked! */
jsdsrc = jsd_FindSourceForURL(jsdc, url);
if(jsdsrc)
{
#if 0
#ifndef JSD_LOWLEVEL_SOURCE
/*
* when using this low level source addition, this jsdsrc might
* not have existed before the eval, but does exist now (without
* this flag set!)
*/
JS_ASSERT(jsdsrc->doingEval);
#endif
#endif
jsdsrc->doingEval = JS_FALSE;
}
JSD_UNLOCK_SOURCE_TEXT(jsdc);
}

601
mozilla/js/jsd/jsd_val.c Normal file
View File

@@ -0,0 +1,601 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* JavaScript Debugging support - Value and Property support
*/
#include "jsd.h"
#ifdef DEBUG
void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval)
{
JS_ASSERT(jsdval);
JS_ASSERT(jsdval->nref > 0);
if(!JS_CLIST_IS_EMPTY(&jsdval->props))
{
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS));
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
}
if(jsdval->proto)
{
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO));
JS_ASSERT(jsdval->proto->nref > 0);
}
if(jsdval->parent)
{
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT));
JS_ASSERT(jsdval->parent->nref > 0);
}
if(jsdval->ctor)
{
JS_ASSERT(CHECK_BIT_FLAG(jsdval->flags, GOT_CTOR));
JS_ASSERT(jsdval->ctor->nref > 0);
}
}
void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop)
{
JS_ASSERT(jsdprop);
JS_ASSERT(jsdprop->name);
JS_ASSERT(jsdprop->name->nref > 0);
JS_ASSERT(jsdprop->val);
JS_ASSERT(jsdprop->val->nref > 0);
if(jsdprop->alias)
JS_ASSERT(jsdprop->alias->nref > 0);
}
#endif
JSBool
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_OBJECT(jsdval->val);
}
JSBool
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_NUMBER(jsdval->val);
}
JSBool
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_INT(jsdval->val);
}
JSBool
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_DOUBLE(jsdval->val);
}
JSBool
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_STRING(jsdval->val);
}
JSBool
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_BOOLEAN(jsdval->val);
}
JSBool
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_NULL(jsdval->val);
}
JSBool
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_VOID(jsdval->val);
}
JSBool
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_PRIMITIVE(jsdval->val);
}
JSBool
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval)
{
return JSVAL_IS_FUNCTION(jsdc->dumbContext, jsdval->val);
}
JSBool
jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
jsval val = jsdval->val;
JSFunction* fun;
JSExceptionState* exceptionState;
if(!JSVAL_IS_OBJECT(val))
return JS_FALSE;
if(JSVAL_IS_FUNCTION(cx, val))
{
exceptionState = JS_SaveExceptionState(cx);
fun = JS_ValueToFunction(cx, val);
JS_RestoreExceptionState(cx, exceptionState);
if(!fun)
{
JS_ASSERT(0);
return JS_FALSE;
}
return JS_GetFunctionScript(cx, fun) ? JS_FALSE : JS_TRUE;
}
return JSVAL_TO_OBJECT(val) && OBJ_IS_NATIVE(JSVAL_TO_OBJECT(val));
}
/***************************************************************************/
JSBool
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_BOOLEAN(val))
return JS_FALSE;
return JSVAL_TO_BOOLEAN(val);
}
int32
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_INT(val))
return 0;
return JSVAL_TO_INT(val);
}
jsdouble*
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!JSVAL_IS_DOUBLE(val))
return 0;
return JSVAL_TO_DOUBLE(val);
}
JSString*
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
JSExceptionState* exceptionState;
if(!jsdval->string)
{
/* if the jsval is a string, then we don't need to double root it */
if(JSVAL_IS_STRING(jsdval->val))
jsdval->string = JSVAL_TO_STRING(jsdval->val);
else
{
exceptionState = JS_SaveExceptionState(cx);
jsdval->string = JS_ValueToString(cx, jsdval->val);
JS_RestoreExceptionState(cx, exceptionState);
if(jsdval->string)
{
if(!JS_AddRoot(cx, &jsdval->string))
jsdval->string = NULL;
}
}
}
return jsdval->string;
}
const char*
jsd_GetValueFunctionName(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
jsval val = jsdval->val;
JSFunction* fun;
JSExceptionState* exceptionState;
if(!jsdval->funName && JSVAL_IS_FUNCTION(cx, val))
{
exceptionState = JS_SaveExceptionState(cx);
fun = JS_ValueToFunction(cx, val);
JS_RestoreExceptionState(cx, exceptionState);
if(!fun)
return NULL;
jsdval->funName = JS_GetFunctionName(fun);
}
return jsdval->funName;
}
/***************************************************************************/
JSDValue*
jsd_NewValue(JSDContext* jsdc, jsval val)
{
JSDValue* jsdval;
if(!(jsdval = (JSDValue*) calloc(1, sizeof(JSDValue))))
return NULL;
if(JSVAL_IS_GCTHING(val))
{
if(!JS_AddRoot(jsdc->dumbContext, &jsdval->val))
{
free(jsdval);
return NULL;
}
}
jsdval->val = val;
jsdval->nref = 1;
JS_INIT_CLIST(&jsdval->props);
return jsdval;
}
void
jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval)
{
JS_ASSERT(jsdval->nref > 0);
if(0 == --jsdval->nref)
{
jsd_RefreshValue(jsdc, jsdval);
if(JSVAL_IS_GCTHING(jsdval->val))
JS_RemoveRoot(jsdc->dumbContext, &jsdval->val);
free(jsdval);
}
}
jsval
jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval)
{
return jsdval->val;
}
static JSDProperty* _newProperty(JSDContext* jsdc, JSPropertyDesc* pd,
uintN additionalFlags)
{
JSDProperty* jsdprop;
if(!(jsdprop = (JSDProperty*) calloc(1, sizeof(JSDProperty))))
return NULL;
JS_INIT_CLIST(&jsdprop->links);
jsdprop->nref = 1;
jsdprop->flags = pd->flags | additionalFlags;
jsdprop->slot = pd->slot;
if(!(jsdprop->name = jsd_NewValue(jsdc, pd->id)))
goto new_prop_fail;
if(!(jsdprop->val = jsd_NewValue(jsdc, pd->value)))
goto new_prop_fail;
if((jsdprop->flags & JSDPD_ALIAS) &&
!(jsdprop->alias = jsd_NewValue(jsdc, pd->alias)))
goto new_prop_fail;
return jsdprop;
new_prop_fail:
jsd_DropProperty(jsdc, jsdprop);
return NULL;
}
static void _freeProps(JSDContext* jsdc, JSDValue* jsdval)
{
JSDProperty* jsdprop;
while(jsdprop = (JSDProperty*)jsdval->props.next,
jsdprop != (JSDProperty*)&jsdval->props)
{
JS_REMOVE_AND_INIT_LINK(&jsdprop->links);
jsd_DropProperty(jsdc, jsdprop);
}
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
CLEAR_BIT_FLAG(jsdval->flags, GOT_PROPS);
}
static JSBool _buildProps(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
JSPropertyDescArray pda;
uintN i;
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdval->props));
JS_ASSERT(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)));
JS_ASSERT(JSVAL_IS_OBJECT(jsdval->val));
if(!JSVAL_IS_OBJECT(jsdval->val) || JSVAL_IS_NULL(jsdval->val))
return JS_FALSE;
if(!JS_GetPropertyDescArray(cx, JSVAL_TO_OBJECT(jsdval->val), &pda))
return JS_FALSE;
for(i = 0; i < pda.length; i++)
{
JSDProperty* prop = _newProperty(jsdc, &pda.array[i], 0);
if(!prop)
{
_freeProps(jsdc, jsdval);
break;
}
JS_APPEND_LINK(&prop->links, &jsdval->props);
}
JS_PutPropertyDescArray(cx, &pda);
SET_BIT_FLAG(jsdval->flags, GOT_PROPS);
return !JS_CLIST_IS_EMPTY(&jsdval->props);
}
#undef DROP_CLEAR_VALUE
#define DROP_CLEAR_VALUE(jsdc, x) if(x){jsd_DropValue(jsdc,x); x = NULL;}
void
jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval)
{
JSContext* cx = jsdc->dumbContext;
if(jsdval->string)
{
/* if the jsval is a string, then we didn't need to root the string */
if(!JSVAL_IS_STRING(jsdval->val))
JS_RemoveRoot(cx, &jsdval->string);
jsdval->string = NULL;
}
jsdval->funName = NULL;
jsdval->className = NULL;
DROP_CLEAR_VALUE(jsdc, jsdval->proto);
DROP_CLEAR_VALUE(jsdc, jsdval->parent);
DROP_CLEAR_VALUE(jsdc, jsdval->ctor);
_freeProps(jsdc, jsdval);
jsdval->flags = 0;
}
/***************************************************************************/
uintN
jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval)
{
JSDProperty* jsdprop;
uintN count = 0;
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)))
if(!_buildProps(jsdc, jsdval))
return 0;
for(jsdprop = (JSDProperty*)jsdval->props.next;
jsdprop != (JSDProperty*)&jsdval->props;
jsdprop = (JSDProperty*)jsdprop->links.next)
{
count++;
}
return count;
}
JSDProperty*
jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp)
{
JSDProperty* jsdprop = *iterp;
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROPS)))
{
JS_ASSERT(!jsdprop);
if(!_buildProps(jsdc, jsdval))
return NULL;
}
if(!jsdprop)
jsdprop = (JSDProperty*)jsdval->props.next;
if(jsdprop == (JSDProperty*)&jsdval->props)
return NULL;
*iterp = (JSDProperty*)jsdprop->links.next;
JS_ASSERT(jsdprop);
jsdprop->nref++;
return jsdprop;
}
JSDProperty*
jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name)
{
JSContext* cx = jsdc->dumbContext;
JSDProperty* jsdprop;
JSDProperty* iter = NULL;
JSObject* obj;
uintN attrs = 0;
JSBool found;
JSPropertyDesc pd;
const jschar * nameChars;
size_t nameLen;
jsval val;
if(!jsd_IsValueObject(jsdc, jsdval))
return NULL;
/* If we already have the prop, then return it */
while(NULL != (jsdprop = jsd_IterateProperties(jsdc, jsdval, &iter)))
{
JSString* propName = jsd_GetValueString(jsdc, jsdprop->name);
if(propName && !JS_CompareStrings(propName, name))
return jsdprop;
JSD_DropProperty(jsdc, jsdprop);
}
/* Not found in property list, look it up explicitly */
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
return NULL;
nameChars = JS_GetStringChars(name);
nameLen = JS_GetStringLength(name);
/* It's OK if this fails - we just don't get attribs */
JS_GetUCPropertyAttributes(cx, obj, nameChars, nameLen, &attrs, &found);
if(!JS_GetUCProperty(cx, obj, nameChars, nameLen, &val))
return NULL;
/* XXX screwy! no good way to detect that property does not exist at all */
if(!found && JSVAL_IS_VOID(val))
return NULL;
pd.id = STRING_TO_JSVAL(name);
pd.value = val;
pd.alias = pd.slot = pd.spare = 0;
pd.flags = 0
| (attrs & JSPROP_ENUMERATE) ? JSPD_ENUMERATE : 0
| (attrs & JSPROP_READONLY) ? JSPD_READONLY : 0
| (attrs & JSPROP_PERMANENT) ? JSPD_PERMANENT : 0;
return _newProperty(jsdc, &pd, JSDPD_HINTED);
}
JSDValue*
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval)
{
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PROTO)))
{
JSObject* obj;
JSObject* proto;
JS_ASSERT(!jsdval->proto);
SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
if(!JSVAL_IS_OBJECT(jsdval->val))
return NULL;
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
return NULL;
if(!(proto = OBJ_GET_PROTO(jsdc->dumbContext,obj)))
return NULL;
jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
}
if(jsdval->proto)
jsdval->proto->nref++;
return jsdval->proto;
}
JSDValue*
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval)
{
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_PARENT)))
{
JSObject* obj;
JSObject* parent;
JS_ASSERT(!jsdval->parent);
SET_BIT_FLAG(jsdval->flags, GOT_PARENT);
if(!JSVAL_IS_OBJECT(jsdval->val))
return NULL;
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
return NULL;
if(!(parent = OBJ_GET_PARENT(jsdc->dumbContext,obj)))
return NULL;
jsdval->parent = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(parent));
}
if(jsdval->parent)
jsdval->parent->nref++;
return jsdval->parent;
}
JSDValue*
jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval)
{
if(!(CHECK_BIT_FLAG(jsdval->flags, GOT_CTOR)))
{
JSObject* obj;
JSObject* proto;
JSObject* ctor;
JS_ASSERT(!jsdval->ctor);
SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
if(!JSVAL_IS_OBJECT(jsdval->val))
return NULL;
if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
return NULL;
if(!(proto = OBJ_GET_PROTO(jsdc->dumbContext,obj)))
return NULL;
if(!(ctor = JS_GetConstructor(jsdc->dumbContext,proto)))
return NULL;
jsdval->ctor = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(ctor));
}
if(jsdval->ctor)
jsdval->ctor->nref++;
return jsdval->ctor;
}
const char*
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval)
{
jsval val = jsdval->val;
if(!jsdval->className && JSVAL_IS_OBJECT(val))
{
JSObject* obj;
if(!(obj = JSVAL_TO_OBJECT(val)))
return NULL;
if(OBJ_GET_CLASS(jsdc->dumbContext, obj))
jsdval->className = OBJ_GET_CLASS(jsdc->dumbContext, obj)->name;
}
return jsdval->className;
}
/***************************************************************************/
/***************************************************************************/
JSDValue*
jsd_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop)
{
jsdprop->name->nref++;
return jsdprop->name;
}
JSDValue*
jsd_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop)
{
jsdprop->val->nref++;
return jsdprop->val;
}
JSDValue*
jsd_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop)
{
if(jsdprop->alias)
jsdprop->alias->nref++;
return jsdprop->alias;
}
uintN
jsd_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop)
{
return jsdprop->flags;
}
uintN
jsd_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop)
{
return jsdprop->slot;
}
void
jsd_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop)
{
JS_ASSERT(jsdprop->nref > 0);
if(0 == --jsdprop->nref)
{
JS_ASSERT(JS_CLIST_IS_EMPTY(&jsdprop->links));
DROP_CLEAR_VALUE(jsdc, jsdprop->val);
DROP_CLEAR_VALUE(jsdc, jsdprop->name);
DROP_CLEAR_VALUE(jsdc, jsdprop->alias);
free(jsdprop);
}
}

View File

@@ -0,0 +1,12 @@
/* jband - 10/26/98 - */
js/jsd/jsdb is a console debugger using only native code. It is experimental.
The only makefile supplied is for Win32.
jsdb.mak will build a debugger enabled js/src/js.c shell. The debugger is
implemented by reflecting the JSD api into JavaScript. The actual debugger
logic is fully implemented in debugger.js. The debugger can debug itself. It
can also be modified and reloaded at runtime.
The JavaScript keyword 'debugger' is used to break into the debugger. A 'help()'
command is supplied to show available commands when exectution is stopped.

File diff suppressed because it is too large Load Diff

46
mozilla/js/jsd/jsdb/f.js Normal file
View File

@@ -0,0 +1,46 @@
/**
* for(var p in Script.scripts) {
*
* var script = Script.scripts[p];
* var handle = script.handle;
* var base = script.base;
* var limit = base + script.extent;
*
* print(script+"\n");
*
* for(var i = base; i < limit; i++) {
* var pc = jsd.GetClosestPC(handle,i)
* var hascode = String(pc).length && i == jsd.GetClosestLine(handle,pc);
* print("line "+i+" "+ (hascode ? "has code" : "has NO code"));
* }
* print("...............................\n");
* }
*/
function rlocals()
{
var retval = "";
var name = "___UNIQUE_NAME__";
var fun = ""+
"var text = \\\"\\\";"+
"for(var p in ob)"+
"{"+
" if(text != \\\"\\\")"+
" text += \\\",\\\";"+
" text += p;"+
"}"+
"return text;";
reval(name+" = new Function(\"ob\",\""+fun+"\")");
// show(name);
retval = _reval([name+"("+"arguments.callee"+")"]);
reval("delete "+name);
return retval;
}
function e(a)
{
return eval(a);
}

449
mozilla/js/jsd/jsdb/jsdb.c Normal file
View File

@@ -0,0 +1,449 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* JSDB public and callback functions
*/
#include "jsdbpriv.h"
/***************************************************************************/
JS_STATIC_DLL_CALLBACK(void)
_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
int i, j, k, n;
fputs("jsdb: ", stderr);
if (!report) {
fprintf(stderr, "%s\n", message);
return;
}
if (report->filename)
fprintf(stderr, "%s, ", report->filename);
if (report->lineno)
fprintf(stderr, "line %u: ", report->lineno);
fputs(message, stderr);
if (!report->linebuf) {
putc('\n', stderr);
return;
}
fprintf(stderr, ":\n%s\n", report->linebuf);
n = report->tokenptr - report->linebuf;
for (i = j = 0; i < n; i++) {
if (report->linebuf[i] == '\t') {
for (k = (j + 8) & ~7; j < k; j++)
putc('.', stderr);
continue;
}
putc('.', stderr);
j++;
}
fputs("^\n", stderr);
}
JS_STATIC_DLL_CALLBACK(void)
jsdb_ScriptHookProc(JSDContext* jsdc,
JSDScript* jsdscript,
JSBool creating,
void* callerdata)
{
JSDB_Data* data = (JSDB_Data*) callerdata;
JSFunction* fun;
if(data->jsScriptHook &&
NULL != (fun = JS_ValueToFunction(data->cxDebugger, data->jsScriptHook)))
{
jsval result;
jsval args[2] = {P2H_SCRIPT(data->cxDebugger, jsdscript),
creating ? JSVAL_TRUE : JSVAL_FALSE };
JS_CallFunction(data->cxDebugger, NULL, fun, 2, args, &result);
}
}
uintN JS_DLL_CALLBACK
jsdb_ExecHookHandler(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
uintN type,
void* callerdata,
jsval* rval)
{
uintN ourRetVal = JSD_HOOK_RETURN_CONTINUE;
jsval result;
JSFunction* fun;
int answer;
JSDB_Data* data = (JSDB_Data*) callerdata;
JS_ASSERT(data);
/* if we're already stopped, then don't stop */
if(data->jsdthreadstate)
return JSD_HOOK_RETURN_CONTINUE;
if(!jsdb_SetThreadState(data, jsdthreadstate))
goto label_bail;
if(data->jsExecutionHook &&
NULL != (fun = JS_ValueToFunction(data->cxDebugger, data->jsExecutionHook)))
{
jsval arg = INT_TO_JSVAL((int)type);
if(!JS_CallFunction(data->cxDebugger, NULL, fun, 1, &arg, &result))
goto label_bail;
if(!JSVAL_IS_INT(result))
goto label_bail;
answer = JSVAL_TO_INT(result);
if((answer == JSD_HOOK_RETURN_RET_WITH_VAL ||
answer == JSD_HOOK_RETURN_THROW_WITH_VAL) &&
!jsdb_EvalReturnExpression(data, rval))
{
goto label_bail;
}
if(answer >= JSD_HOOK_RETURN_HOOK_ERROR &&
answer <= JSD_HOOK_RETURN_CONTINUE_THROW)
ourRetVal = answer;
else
ourRetVal = JSD_HOOK_RETURN_CONTINUE;
}
label_bail:
jsdb_SetThreadState(data, NULL);
return ourRetVal;
}
typedef enum
{
ARG_MSG = 0,
ARG_FILENAME,
ARG_LINENO,
ARG_LINEBUF,
ARG_TOKEN_OFFSET,
ARG_LIMIT
} ER_ARGS;
uintN JS_DLL_CALLBACK
jsdb_ErrorReporter(JSDContext* jsdc,
JSContext* cx,
const char* message,
JSErrorReport* report,
void* callerdata)
{
uintN ourRetVal = JSD_ERROR_REPORTER_PASS_ALONG;
jsval result;
JSFunction* fun;
int32 answer;
JSDB_Data* data = (JSDB_Data*) callerdata;
JS_ASSERT(data);
if(data->jsErrorReporterHook &&
NULL != (fun = JS_ValueToFunction(data->cxDebugger,
data->jsErrorReporterHook)))
{
jsval args[ARG_LIMIT] = {JSVAL_NULL};
if(message)
args[ARG_MSG] =
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, message));
if(report && report->filename)
args[ARG_FILENAME] =
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, report->filename));
if(report && report->linebuf)
args[ARG_LINEBUF] =
STRING_TO_JSVAL(JS_NewStringCopyZ(cx, report->linebuf));
if(report)
args[ARG_LINENO] =
INT_TO_JSVAL(report->lineno);
if(report && report->linebuf && report->tokenptr)
args[ARG_TOKEN_OFFSET] =
INT_TO_JSVAL((int)(report->tokenptr - report->linebuf));
if(!JS_CallFunction(data->cxDebugger, NULL, fun, ARG_LIMIT, args, &result))
return ourRetVal;
if(JS_ValueToInt32(data->cxDebugger, result, &answer))
ourRetVal = (uintN) answer;
}
return ourRetVal;
}
JS_STATIC_DLL_CALLBACK(JSBool)
Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
uintN i;
JSString *str;
const char *filename;
JSScript *script;
JSBool ok;
jsval result;
ok = JS_TRUE;
for (i = 0; i < argc; i++) {
str = JS_ValueToString(cx, argv[i]);
if (!str) {
ok = JS_FALSE;
break;
}
argv[i] = STRING_TO_JSVAL(str);
filename = JS_GetStringBytes(str);
errno = 0;
script = JS_CompileFile(cx, obj, filename);
if (!script)
continue;
ok = JS_ExecuteScript(cx, obj, script, &result);
JS_DestroyScript(cx, script);
if (!ok)
break;
}
JS_GC(cx);
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
return ok;
}
JS_STATIC_DLL_CALLBACK(JSBool)
Write(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSString *str = JS_ValueToString(cx, argv[0]);
if (!str)
return JS_FALSE;
printf(JS_GetStringBytes(str));
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
return JS_TRUE;
}
JS_STATIC_DLL_CALLBACK(JSBool)
Gets(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char buf[1024];
if(! gets(buf))
return JS_FALSE;
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buf));
return JS_TRUE;
}
JS_STATIC_DLL_CALLBACK(JSBool)
Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
if (argc > 0 && JSVAL_IS_INT(argv[0]))
*rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVAL_TO_INT(argv[0])));
else
*rval = INT_TO_JSVAL(JS_GetVersion(cx));
return JS_TRUE;
}
JS_STATIC_DLL_CALLBACK(JSBool)
SafeEval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
static char default_filename[] = "jsdb_eval";
/* JSContext *cx2; */
JSString* textJSString;
char* filename;
int32 lineno;
JSDB_Data* data = (JSDB_Data*) JS_GetContextPrivate(cx);
JS_ASSERT(data);
if(argc < 1 || !(textJSString = JS_ValueToString(cx, argv[0])))
{
JS_ReportError(cx, "safeEval requires source text as a first argument");
return JS_FALSE;
}
if(argc < 2)
filename = default_filename;
else
{
JSString* filenameJSString;
if(!(filenameJSString = JS_ValueToString(cx, argv[1])))
{
JS_ReportError(cx, "safeEval passed non-string filename as 2nd param");
return JS_FALSE;
}
filename = JS_GetStringBytes(filenameJSString);
}
if(argc < 3)
lineno = 1;
else
{
if(!JS_ValueToInt32(cx, argv[2], &lineno))
{
JS_ReportError(cx, "safeEval passed non-int lineno as 3rd param");
return JS_FALSE;
}
}
if(! JS_EvaluateScript(cx, obj,
JS_GetStringBytes(textJSString),
JS_GetStringLength(textJSString),
filename, lineno, rval))
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,""));
return JS_TRUE;
}
JS_STATIC_DLL_CALLBACK(JSBool)
NativeBreak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
#ifdef _WINDOWS
_asm int 3;
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,"did _asm int 3;"));
#else
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,"only supported for Windows"));
#endif
return JS_TRUE;
}
static JSFunctionSpec debugger_functions[] = {
{"version", Version, 0},
{"load", Load, 1},
{"write", Write, 0},
{"gets", Gets, 0},
{"safeEval", SafeEval, 3},
{"nativeBreak", NativeBreak, 0},
{0}
};
static JSClass debugger_global_class = {
"debugger_global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
/***************************************************************************/
#ifdef JSD_LOWLEVEL_SOURCE
/*
* This facilitates sending source to JSD (the debugger system) in the shell
* where the source is loaded using the JSFILE hack in jsscan. The function
* below is used as a callback for the jsdbgapi JS_SetSourceHandler hook.
* A more normal embedding (e.g. mozilla) loads source itself and can send
* source directly to JSD without using this hook scheme.
*/
static void
SendSourceToJSDebugger(const char *filename, uintN lineno,
jschar *str, size_t length,
void **listenerTSData, JSDContext* jsdc)
{
JSDSourceText *jsdsrc = (JSDSourceText *) *listenerTSData;
if (!jsdsrc) {
if (!filename)
filename = "typein";
if (1 == lineno) {
jsdsrc = JSD_NewSourceText(jsdc, filename);
} else {
jsdsrc = JSD_FindSourceForURL(jsdc, filename);
if (jsdsrc && JSD_SOURCE_PARTIAL !=
JSD_GetSourceStatus(jsdc, jsdsrc)) {
jsdsrc = NULL;
}
}
}
if (jsdsrc) {
jsdsrc = JSD_AppendUCSourceText(jsdc,jsdsrc, str, length,
JSD_SOURCE_PARTIAL);
}
*listenerTSData = jsdsrc;
}
#endif /* JSD_LOWLEVEL_SOURCE */
static JSBool
_initReturn(const char* str, JSBool retval)
{
if(str)
printf("%s\n", str);
if(retval)
; /* printf("debugger initialized\n"); */
else
{
JS_ASSERT(0);
printf("debugger FAILED to initialize\n");
}
return retval;
}
#define MAX_DEBUGGER_DEPTH 3
JS_EXPORT_API(JSBool)
JSDB_InitDebugger(JSRuntime* rt, JSDContext* jsdc, int depth)
{
jsval rvalIgnore;
static char load_deb[] = "load('debugger.js')";
JSDB_Data* data = (JSDB_Data*) calloc(1, sizeof(JSDB_Data));
if(!data)
return _initReturn("memory alloc error", JS_FALSE);
data->rtTarget = rt;
data->jsdcTarget = jsdc;
data->debuggerDepth = depth+1;
if(!(data->rtDebugger = JS_NewRuntime(8L * 1024L * 1024L)))
return _initReturn("debugger runtime creation error", JS_FALSE);
if(!(data->cxDebugger = JS_NewContext(data->rtDebugger, 8192)))
return _initReturn("debugger creation error", JS_FALSE);
JS_SetContextPrivate(data->cxDebugger, data);
JS_SetErrorReporter(data->cxDebugger, _ErrorReporter);
if(!(data->globDebugger =
JS_NewObject(data->cxDebugger, &debugger_global_class, NULL, NULL)))
return _initReturn("debugger global object creation error", JS_FALSE);
if(!JS_InitStandardClasses(data->cxDebugger, data->globDebugger))
return _initReturn("debugger InitStandardClasses error", JS_FALSE);
if(!JS_DefineFunctions(data->cxDebugger, data->globDebugger, debugger_functions))
return _initReturn("debugger DefineFunctions error", JS_FALSE);
if(!jsdb_ReflectJSD(data))
return _initReturn("debugger reflection of JSD API error", JS_FALSE);
if(data->debuggerDepth < MAX_DEBUGGER_DEPTH)
{
JSDContext* jsdc;
if(!(jsdc = JSD_DebuggerOnForUser(data->rtDebugger, NULL, NULL)))
return _initReturn("failed to create jsdc for nested debugger", JS_FALSE);
JSD_JSContextInUse(jsdc, data->cxDebugger);
if(!JSDB_InitDebugger(data->rtDebugger, jsdc, data->debuggerDepth))
return _initReturn("failed to init nested debugger", JS_FALSE);
}
JSD_SetScriptHook(jsdc, jsdb_ScriptHookProc, data);
JSD_SetDebuggerHook(jsdc, jsdb_ExecHookHandler, data);
JSD_SetThrowHook(jsdc, jsdb_ExecHookHandler, data);
JSD_SetDebugBreakHook(jsdc, jsdb_ExecHookHandler, data);
JSD_SetErrorReporter(jsdc, jsdb_ErrorReporter, data);
#ifdef JSD_LOWLEVEL_SOURCE
JS_SetSourceHandler(data->rtDebugger, SendSourceToJSDebugger, jsdc);
#endif /* JSD_LOWLEVEL_SOURCE */
JS_EvaluateScript(data->cxDebugger, data->globDebugger,
load_deb, sizeof(load_deb)-1, "jsdb_autoload", 1,
&rvalIgnore);
return _initReturn(NULL, JS_TRUE);
}

View File

@@ -16,22 +16,35 @@
* Reserved.
*/
#ifndef jsmacos_h___
#define jsmacos_h___
//
// This file contains all changes and additions that need to be made to the
// runtime for the Macintosh platform hosting the Metrowerks environment.
// This file should only be included in Macintosh builds.
//
/*
* Public headers for JSDB
*/
#ifndef jsdb_h___
#define jsdb_h___
/* Get jstypes.h included first. After that we can use PR macros for doing
* this extern "C" stuff!
*/
#ifdef __cplusplus
extern "C"
{
#endif
#include "jstypes.h"
#ifdef __cplusplus
}
#endif
JS_BEGIN_EXTERN_C
#include "jsapi.h"
#include "jsdebug.h"
JS_END_EXTERN_C
JS_BEGIN_EXTERN_C
#include <stddef.h>
extern void* reallocSmaller(void* block, size_t newSize);
extern char* strdup(const char* str);
extern JS_EXPORT_API(JSBool)
JSDB_InitDebugger(JSRuntime* rt, JSDContext* jsdc, int depth);
JS_END_EXTERN_C
#endif /* jsmacos_h___ */
#endif /* jsdb_h___ */

View File

@@ -0,0 +1,102 @@
PROJ = jsdb
JSDB = .
JSD = $(JSDB)\..
JSSRC = $(JSD)\..\src
!IF "$(BUILD_OPT)" != ""
OBJ = Release
CC_FLAGS = /DNDEBUG
!ELSE
OBJ = Debug
CC_FLAGS = /DDEBUG
LINK_FLAGS = /DEBUG
!ENDIF
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/I $(JSSRC)\
/I $(JSD)\
/I $(JSDB)\
$(CC_FLAGS)\
/DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
/DJSDEBUGGER\
/DJSDEBUGGER_C_UI\
/DJSD_LOWLEVEL_SOURCE\
/DJSFILE\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 $(LINK_FLAGS)\
/pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
LLIBS = kernel32.lib advapi32.lib $(JSSRC)\$(OBJ)\js32.lib $(JSD)\$(OBJ)\jsd.lib
CPP=cl.exe
LINK32=link.exe
all: $(OBJ) dlls $(OBJ)\$(PROJ).exe $(OBJ)\debugger.js
HEADERS = $(JSDB)\jsdb.h \
$(JSDB)\jsdbpriv.h
OBJECTS = $(OBJ)\js.obj \
$(OBJ)\jsdb.obj \
$(OBJ)\jsdrefl.obj
$(OBJECTS) : $(HEADERS)
$(OBJ)\$(PROJ).exe: $(OBJECTS)
$(LINK32) $(LFLAGS) $** $(LLIBS)
.c{$(OBJ)}.obj:
$(CPP) $(CFLAGS)
{$(JSSRC)}.c.obj:
$(CPP) $(CFLAGS)
$(OBJ) :
mkdir $(OBJ)
$(OBJ)\js32.dll :
@cd ..\..\src
@nmake -f js.mak CFG="js - Win32 Debug"
@cd ..\jsd\jsdb
@echo Copying dll from js/src
@copy $(JSSRC)\$(OBJ)\js32.dll $(OBJ) >NUL
@copy $(JSSRC)\$(OBJ)\js32.pdb $(OBJ) >NUL
$(OBJ)\jsd.dll :
@cd ..
@nmake -f jsd.mak JSD_THREADSAFE=1
@cd jsdb
@echo Copying dll from js/jsd
@copy $(JSD)\$(OBJ)\jsd.dll $(OBJ) >NUL
@copy $(JSD)\$(OBJ)\jsd.pdb $(OBJ) >NUL
dlls : $(OBJ)\js32.dll $(OBJ)\jsd.dll
$(OBJ)\debugger.js: *.js
@echo Copying *.js
@copy *.js $(OBJ) >NUL
clean:
@echo Deleting built files
@del $(OBJ)\*.pch >NUL
@del $(OBJ)\*.obj >NUL
@del $(OBJ)\*.exp >NUL
@del $(OBJ)\*.lib >NUL
@del $(OBJ)\*.idb >NUL
@del $(OBJ)\*.pdb >NUL
@del $(OBJ)\*.dll >NUL
@del $(OBJ)\*.exe >NUL
deep_clean: clean
@cd ..\..\src
@nmake -f js.mak CFG="js - Win32 Debug" clean
@cd ..\jsd\jsdb
@cd ..
@nmake -f jsd.mak clean
@cd jsdb

View File

@@ -0,0 +1,117 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Private Headers for JSDB
*/
#ifndef jsdbpriv_h___
#define jsdbpriv_h___
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */
#include "jsprf.h"
#include "jsdbgapi.h"
#include "jsdb.h"
/***************************************************************************/
typedef struct JSDB_Data
{
JSDContext* jsdcTarget;
JSRuntime* rtTarget;
JSRuntime* rtDebugger;
JSContext* cxDebugger;
JSObject* globDebugger;
JSObject* jsdOb;
jsval jsScriptHook;
jsval jsExecutionHook;
jsval jsErrorReporterHook;
JSDThreadState* jsdthreadstate;
int debuggerDepth;
} JSDB_Data;
extern JSBool
jsdb_ReflectJSD(JSDB_Data* data);
/***********************************/
/*
* System to store JSD_xxx handles in jsvals. This supports tracking the
* handle's type - both for debugging and for automatic 'dropping' of
* reference counted handle types (e.g. JSDValue).
*/
typedef enum
{
JSDB_GENERIC = 0,
JSDB_CONTEXT,
JSDB_SCRIPT,
JSDB_SOURCETEXT,
JSDB_THREADSTATE,
JSDB_STACKFRAMEINFO,
JSDB_VALUE,
JSDB_PROPERTY,
JSDB_OBJECT
} JSDBHandleType;
#define H2P_GENERIC(cx,val) (void*) jsdb_HandleValToPointer((cx),(val),JSDB_GENERIC)
#define H2P_CONTEXT(cx,val) (JSDContext*) jsdb_HandleValToPointer((cx),(val),JSDB_CONTEXT)
#define H2P_SCRIPT(cx,val) (JSDScript*) jsdb_HandleValToPointer((cx),(val),JSDB_SCRIPT)
#define H2P_SOURCETEXT(cx,val) (JSDSourceText*) jsdb_HandleValToPointer((cx),(val),JSDB_SOURCETEXT)
#define H2P_THREADSTATE(cx,val) (JSDThreadState*) jsdb_HandleValToPointer((cx),(val),JSDB_THREADSTATE)
#define H2P_STACKFRAMEINFO(cx,val) (JSDStackFrameInfo*) jsdb_HandleValToPointer((cx),(val),JSDB_STACKFRAMEINFO)
#define H2P_VALUE(cx,val) (JSDValue*) jsdb_HandleValToPointer((cx),(val),JSDB_VALUE)
#define H2P_PROPERTY(cx,val) (JSDProperty*) jsdb_HandleValToPointer((cx),(val),JSDB_PROPERTY)
#define H2P_OBJECT(cx,val) (JSDObject*) jsdb_HandleValToPointer((cx),(val),JSDB_OBJECT)
#define P2H_GENERIC(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_GENERIC)
#define P2H_CONTEXT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_CONTEXT)
#define P2H_SCRIPT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_SCRIPT)
#define P2H_SOURCETEXT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_SOURCETEXT)
#define P2H_THREADSTATE(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_THREADSTATE)
#define P2H_STACKFRAMEINFO(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_STACKFRAMEINFO)
#define P2H_VALUE(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_VALUE)
#define P2H_PROPERTY(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_PROPERTY)
#define P2H_OBJECT(cx,ptr) jsdb_PointerToNewHandleVal((cx),(ptr),JSDB_OBJECT)
extern jsval
jsdb_PointerToNewHandleVal(JSContext *cx, void* ptr, JSDBHandleType type);
extern void*
jsdb_HandleValToPointer(JSContext *cx, jsval val, JSDBHandleType type);
/***********************************/
extern JSBool
jsdb_SetThreadState(JSDB_Data* data, JSDThreadState* jsdthreadstate);
extern uintN JS_DLL_CALLBACK
jsdb_ExecHookHandler(JSDContext* jsdc,
JSDThreadState* jsdthreadstate,
uintN type,
void* callerdata,
jsval* rval);
extern JSBool
jsdb_EvalReturnExpression(JSDB_Data* data, jsval* rval);
#endif /* jsdbpriv_h___ */

File diff suppressed because it is too large Load Diff

1
mozilla/js/jsd/jsdb/mk.bat Executable file
View File

@@ -0,0 +1 @@
nmake -f jsdb.mak %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -0,0 +1,56 @@
// some tests...
function set_a(a) {this.a = a;}
function set_b(b) {this.b = b;}
function set_c(c) {this.c = c;}
function f_ctor(a,b,c)
{
this.set_a = set_a;
this.set_b = set_b;
this.set_c = set_c;
// NOTE: these break JSD_LOWLEVEL_SOURCE in shell debugger
this.get_a = new Function("return this.a;");
// this.get_b = new Function("return this.b;");
// this.get_c = new Function("return this.c;");
// this.get_a = function() {return this.a;};
this.get_b = function() {return this.b;};
this.get_c = function() {return this.c;};
this.set_a(a);
this.set_b(b);
this.set_c(c);
}
function f2_ctor(param)
{
this.A = new f_ctor(1,2,3);
this.b = new f_ctor("A","B","C");
this.number = param;
}
function callMe()
{
var A = new f2_ctor(1);
debugger;
var b = new f2_ctor(5);
}
function foo(a,b,c,d,e,f)
{
var g;
var h;
var i;
var j;
debugger;
}
A = new f2_ctor(0);
AA = new f2_ctor(100);
callMe();
foo(1,2,3,4,5);
A.A.set_b(8);
print(A.A.get_b());

View File

@@ -0,0 +1 @@
load('objects.js')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

112
mozilla/js/jsd/jsdshell.mak Normal file
View File

@@ -0,0 +1,112 @@
PROJ = jsdshell
JSD = .
JSDJAVA = $(JSD)\java
JS = $(JSD)\..\src
RUN = $(JSD)\run
JSPROJ = js32
JSDPROJ = jsd
JSDJAVAPROJ = jsdjava
!IF "$(BUILD_OPT)" != ""
OPT = BUILD_OPT=1
OBJ = Release
CC_FLAGS = /DNDEBUG
!ELSE
OPT =
OBJ = Debug
CC_FLAGS = /DDEBUG
LINK_FLAGS = /DEBUG
!ENDIF
QUIET=@
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/I $(JS)\
/I $(JSD)\
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
/DJSDEBUGGER\
!IF "$(JSDEBUGGER_JAVA_UI)" != ""
/I $(JSDJAVA)\
/DJSDEBUGGER_JAVA_UI\
/DJSD_STANDALONE_JAVA_VM\
!ENDIF
/DJSD_LOWLEVEL_SOURCE\
/DJSFILE\
$(CC_FLAGS)\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 \
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
LLIBS = kernel32.lib advapi32.lib \
$(JS)\$(OBJ)\$(JSPROJ).lib \
$(JSD)\$(OBJ)\$(JSDPROJ).lib \
$(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).lib
CPP=cl.exe
LINK32=link.exe
all: $(OBJ) $(RUN) dlls $(OBJ)\$(PROJ).exe copy_binaries
$(OBJ)\$(PROJ).exe: \
$(OBJ)\js.obj
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
{$(JS)}.c{$(OBJ)}.obj :
$(QUIET)$(CPP) $(CFLAGS)
dlls :
$(QUIET)cd ..\src
!IF "$(BUILD_OPT)" != ""
$(QUIET)nmake -f js.mak CFG="js - Win32 Release"
!ELSE
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug"
!ENDIF
$(QUIET)cd ..\jsd
$(QUIET)nmake -f jsd.mak JSD_THREADSAFE=1 $(OPT)
$(QUIET)cd java
$(QUIET)nmake -f jsdjava.mak JSD_STANDALONE_JAVA_VM=1 $(OPT)
$(QUIET)cd ..
copy_binaries :
@echo copying binaries
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).dll $(RUN) >NUL
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(RUN) >NUL
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(RUN) >NUL
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(RUN) >NUL
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).dll $(RUN) >NUL
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).pdb $(RUN) >NUL
$(QUIET)copy $(OBJ)\$(PROJ).pdb $(RUN) >NUL
$(QUIET)copy $(OBJ)\$(PROJ).exe $(RUN) >NUL
$(OBJ) :
$(QUIET)mkdir $(OBJ)
$(RUN) :
$(QUIET)mkdir $(RUN)
clean:
@echo deleting old output
$(QUIET)del $(OBJ)\js.obj >NUL
$(QUIET)del $(OBJ)\$(PROJ).pch >NUL
$(QUIET)del $(OBJ)\$(PROJ)*.idb >NUL
$(QUIET)del $(OBJ)\$(PROJ).pdb >NUL
$(QUIET)del $(OBJ)\$(PROJ).exe >NUL
$(QUIET)del $(RUN)\*.pdb >NUL
$(QUIET)del $(RUN)\*.exe >NUL
$(QUIET)del $(RUN)\*.dll >NUL
deep_clean: clean
$(QUIET)cd ..\src
!IF "$(BUILD_OPT)" != ""
$(QUIET)nmake -f js.mak CFG="js - Win32 Release" clean
!ELSE
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug" clean
!ENDIF
$(QUIET)cd ..\jsd
$(QUIET)nmake -f jsd.mak clean
$(QUIET)cd java
$(QUIET)nmake -f jsdjava.mak clean
$(QUIET)cd ..

View File

@@ -16,6 +16,10 @@
* Reserved.
*/
/* this is all going away... replaced by code in js/jsd/java */
#if 0
#ifndef XP_MAC
#include "_stubs/netscape_jsdebug_Script.c"
#include "_stubs/netscape_jsdebug_DebugController.c"
@@ -31,3 +35,5 @@
#include "netscape_jsdebug_JSPC.c"
#include "n_j_JSSourceTextProvider.c"
#endif
#endif

View File

@@ -1,35 +1,29 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#// The contents of this file are subject to the Netscape Public License
#// Version 1.0 (the "NPL"); you may not use this file except in
#// compliance with the NPL. You may obtain a copy of the NPL at
#// http://www.mozilla.org/NPL/
#//
#// Software distributed under the NPL is distributed on an "AS IS" basis,
#// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
#// for the specific language governing rights and limitations under the
#// NPL.
#//
#// The Initial Developer of this code under the NPL is Netscape
#// Communications Corporation. Portions created by Netscape are
#// Copyright (C) 1998 Netscape Communications Corporation. All Rights
#// Reserved.
IGNORE_MANIFEST=1
#
#//------------------------------------------------------------------------
#//
#// Specify the depth of the current directory relative to the
#// root of NS
#//
#//------------------------------------------------------------------------
DEPTH=..\..
include <$(DEPTH)\config\config.mak>
DEPTH = ..\..
# Turn on/off depending on
!ifdef MOZ_JSD
DIRS = classes
!ifdef MOZ_OJI
# DIRS = java classes
!endif
#//------------------------------------------------------------------------
@@ -41,87 +35,58 @@ DIRS = classes
DLLNAME = jsd$(MOZ_BITS)$(VERSION_NUMBER)
PDBFILE = $(DLLNAME).pdb
MAPFILE = $(DLLNAME).map
RESFILE = $(DLLNAME).res
RESFILE = jsd$(MOZ_BITS)40.res
DLL =.\$(OBJDIR)\$(DLLNAME).dll
MAKE_OBJ_TYPE = DLL
!if "$(MOZ_BITS)" != "16"
LINCS = -I$(PUBLIC)/java \
-I$(PUBLIC)/applet \
-I$(DEPTH)\include
LINCS = -I$(DEPTH)\include \
-I$(PUBLIC)\js
!endif
!if "$(MOZ_BITS)" == "16"
DEFFILE = $(DLLNAME).def
!endif
# LCFLAGS= $(LCFLAGS) -DEXPORT_JSD_API -DJSD_THREADSAFE
LLIBS= $(LIBNSPR) \
$(DIST)\lib\js$(MOZ_BITS)$(VERSION_NUMBER).lib \
$(DIST)\lib\jrt$(MOZ_BITS)$(VERSION_NUMBER).lib
!ifdef MOZ_OJI
$(DIST)\lib\oji$(MOZ_BITS).lib
!endif
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib
!endif
#//------------------------------------------------------------------------
#//
#// Define the files necessary to build the target (ie. OBJS)
#//
#//------------------------------------------------------------------------
OBJS = \
.\$(OBJDIR)\jsdebug.obj \
.\$(OBJDIR)\jsd_high.obj \
.\$(OBJDIR)\jsd_hook.obj \
.\$(OBJDIR)\jsd_lock.obj \
.\$(OBJDIR)\jsd_scpt.obj \
.\$(OBJDIR)\jsd_stak.obj \
.\$(OBJDIR)\jsd_step.obj \
.\$(OBJDIR)\jsd_text.obj \
.\$(OBJDIR)\jsd_val.obj \
$(NULL)
#//------------------------------------------------------------------------
#//
#// install headers
#//
#//------------------------------------------------------------------------
INSTALL_DIR=$(PUBLIC)\jsdebug
INSTALL_DIR=$(PUBLIC)\jsd
INSTALL_FILE_LIST= \
jsdebug.h \
$(NULL)
MODULE=jsdebug
REQUIRES=java js nspr
CSRCS= \
jsdebug.c \
jsd_high.c \
jsd_hook.c \
!ifdef MOZ_JSD
jsdstubs.c \
jsd_java.c \
!endif
jsd_scpt.c \
jsd_stak.c \
jsd_text.c
LIBRARY_NAME=jsd
!ifdef MOZ_JSD
JDK_GEN=netscape.jsdebug.Script netscape.jsdebug.DebugController \
netscape.jsdebug.JSThreadState netscape.jsdebug.JSStackFrameInfo \
netscape.jsdebug.JSPC netscape.jsdebug.JSSourceTextProvider \
netscape.jsdebug.JSErrorReporter
!endif
EXPORTS=jsdebug.h
C_OBJS= \
.\$(OBJDIR)\jsdebug.obj \
.\$(OBJDIR)\jsd_high.obj \
.\$(OBJDIR)\jsd_hook.obj \
!ifdef MOZ_JSD
.\$(OBJDIR)\jsdstubs.obj \
.\$(OBJDIR)\jsd_java.obj \
!endif
.\$(OBJDIR)\jsd_scpt.obj \
.\$(OBJDIR)\jsd_stak.obj \
.\$(OBJDIR)\jsd_text.obj
!if "$(MOZ_BITS)" != "16"
LINCS=-I$(XPDIST)\public\java -I$(XPDIST)\public\js \
-I$(XPDIST)\public\nspr
!endif
#//------------------------------------------------------------------------
#//
#// Include the common makefile rules
@@ -133,18 +98,6 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
$(RM_R) _gen
$(RM_R) _stubs
.\$(OBJDIR)\jsdstubs.o: \
$(JDK_STUB_DIR)\netscape_jsdebug_Script.c \
$(JDK_STUB_DIR)\netscape_jsdebug_DebugController.c \
$(JDK_STUB_DIR)\netscape_jsdebug_JSThreadState.c \
$(JDK_STUB_DIR)\netscape_jsdebug_JSStackFrameInfo.c \
$(JDK_STUB_DIR)\netscape_jsdebug_JSPC.c \
$(JDK_STUB_DIR)\netscape_jsdebug_JSSourceTextProvider.c
export:: INSTALL_FILES

4
mozilla/js/jsd/mkshell.bat Executable file
View File

@@ -0,0 +1,4 @@
@echo off
REM nmake -f jsdshell.mak JSDEBUGGER_JAVA_UI=1 LIVECONNECT=1 %1 %2 %3 %4 %5
@echo on
nmake -f jsdshell.mak JSDEBUGGER_JAVA_UI=1 %1 %2 %3 %4 %5

View File

@@ -11,6 +11,7 @@ The notable subdirs are:
build - stuff to build the code
classes - trees of source files
dist - generated output dir
doc - some documents
ifcui - auxilary pieces of the JavaScript Debugger
jslogger - auxilary pieces of a smaple JavaScript logging app
stub_classes - stubbed out mozilla classes to allow standalone debugging
@@ -22,9 +23,3 @@ The source to the debugger lives in:
All building is done in:
jsdj/build
***************************************************************************
*** 09/15/98
*** NOTE: some of this relates to code in js/jsd that is not yet checked in.
*** New stuff in js/jsd will go in when new js/src lands (later this week).
*** I decided to check this in anyway...
***************************************************************************

View File

@@ -13,7 +13,7 @@ to the public. The flag 'NO_RHINO=1' is necessary for many of the makefile
targets when used outside of Netscape.
There is code here to also build a Corba/iiop connection for remote debugging to
a Netscape Internal version of Enterprise Server 3.51. This is not fully
a Netscape internal version of Enterprise Server 3.51. This is not fully
functional on the server side. You should normally use the NO_CORBA=1 build
flag. If you want to play with this stuff then you need an install of ES3.51 and
you need to set the ES3_ROOT environment variable to point to that install.
@@ -29,5 +29,43 @@ up to date :).
There are a few .bat files for convenience to build the targets I often build.
'mk_ifcui_std_with_rhino.bat' will build the whole thing (except Corba parts)
and ASSUMEs that you want Rhino support and that you have already built Rhino
in the 'correct' relative directory.
The directory structure used at Netscape for Rhino is:
someroot/ns/js/rhino
someroot/mozilla/js/src
someroot/mozilla/js/jsd
someroot/mozilla/js/jsdj
where 'someroot' can be anything. The salient point is that from the jsdj/build
directory the relative path to the rhino classes is:
.\..\..\..\..\ns\js\rhino
This can be adjusted by hacking the 'RHINO_CLASSES' var near the top of
jsdj.mak.
------------------------
FOR THE JS 1.4 RELEASE:
Rhino (JavaScript for Java) is packaged as 'jsjava.jar'. It unzips so that the
root directory is named 'jsjava'.
To simplify building js/jsdj for this release jsdj.mak has been modified to
include:
RHINO_CLASSROOT = $(BUILD_DIR)\..\..\jsjava
RHINO_CLASSES = $(RHINO_CLASSROOT)\js.jar;$(RHINO_CLASSROOT)\jsdebug.jar
This supports unzipping jsjava.jar into mozilla/js for a directory tree like:
someroot/mozilla/js/jsjava
someroot/mozilla/js/src
someroot/mozilla/js/jsd
someroot/mozilla/js/jsdj
mk_ifcui_std_with_rhino.bat can then be run from mozilla/js/jsdj/build to build
all of js/jsdj including Rhino support.

View File

@@ -0,0 +1,31 @@
#
# This requires -vpackage_name=whatever.the.name.of.the.package.is
#
BEGIN{
print
print "/* generated by gen_date.awk to provide access to build date at runtime */"
print
print "package "package_name";"
print
print "class BuildDate"
print "{"
print strftime(" // %A, %B %d, %Y at %I:%M %p");
print
print " public static final long buildDate = " systime() "000L;"
print
print " public static final java.util.Date date()"
print " {"
print " return new java.util.Date(buildDate);"
print " }"
print
print " public static final String display()"
print " {"
print " return date().toString();"
print " }"
print "}"
}

View File

@@ -0,0 +1,16 @@
#
# This requires -vpackage_name=name.of.the.package -vvalue=[true|false]
#
BEGIN{
print
print "/* generated by gen_dbg.awk to set DEBUG on or off */"
print
print "package "package_name";"
print
print "public interface AS"
print "{"
print " public static final boolean S = "value";"
print " public static final boolean DEBUG = "value";"
print "}"
}

View File

@@ -0,0 +1,534 @@
# jband - 09/14/98
BUILD_DIR = .
DIST = $(BUILD_DIR)\..\dist
DIST_CLASSES = $(BUILD_DIR)\..\dist\classes
CLASS_SRC = $(BUILD_DIR)\..\classes
JSDEBUGGING_DIR = $(BUILD_DIR)\..\classes\com\netscape\jsdebugging
PALOMAR_DIR = $(JSDEBUGGING_DIR)\ifcui\palomar
IFC_DIST_FILE = $(DIST_CLASSES)\ifc11.jar
!IF "$(NO_RHINO)" == ""
RHINO_CLASSROOT = $(BUILD_DIR)\..\..\jsjava
RHINO_CLASSES = $(RHINO_CLASSROOT)\js.jar;$(RHINO_CLASSROOT)\jsdebug.jar
#RHINO_CLASSES = $(BUILD_DIR)\..\..\..\..\ns\js\rhino
!ENDIF
#these are used for CD
FROM_BUILD_TO_DIST_CLASSES = ..\dist\classes
FROM_DIST_CLASSES_TO_BUILD = ..\..\build
JSLOGGER_JARFILE = jslogger.jar
JSLOGGER_MAIN_DIR = $(BUILD_DIR)\..\jslogger
NETSCAPE_JSDEBUG_JARFILE = jsd11.jar
IFCUI_JARFILE = jsdeb12.jar
IFCUI_RUN_DIR = $(BUILD_DIR)\..\ifcui\run
OUR_CLASSPATH = $(DIST_CLASSES);$(IFC_DIST_FILE);$(RHINO_CLASSES);$(CLASSPATH)
STD_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(OUR_CLASSPATH)
CORBA_CLASSPATH = $(OUR_CLASSPATH);$(ES3_ROOT)\wai\java\nisb.zip;$(ES3_ROOT)\wai\java\WAI.zip;$(ES3_ROOT)\plugins\Java\classes\serv3_0.zip
CORBA_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(CORBA_CLASSPATH)
!IF "$(NO_CORBA)" == ""
JAVADOC_CLASSPATH = $(CORBA_CLASSPATH)
!ELSE
JAVADOC_CLASSPATH = $(OUR_CLASSPATH)
!ENDIF
!IF "$(BUILD_OPT)" != ""
JAVAFLAGS = $(STD_JAVA_FLAGS) -O
!ELSE
JAVAFLAGS = $(STD_JAVA_FLAGS) -g
!ENDIF
all: core jsdb ifcui ifcui_lanchers jslogger apitests tools \
dependency_checks jars netscape_applet javadoc_all
all_clean : clean all
help :
@echo targets:
@echo --------
@echo all
@echo all_clean
@echo help
@echo clean
@echo core
@echo jsdb
@echo apitests
@echo ifcui
@echo ifcui_fast
@echo ifcui_lanchers
@echo jslogger
@echo jslogger_fast
@echo depend_tool
@echo tools
@echo dependency_checks
@echo jars
@echo netscape_security
@echo netscape_jsdebug
@echo netscape_javascript
@echo netscape_applet
@echo com_netscape_nativejsengine
@echo com_netscape_jsdebugging_api
@echo com_netscape_jsdebugging_engine
@echo com_netscape_jsdebugging_api_local
@echo com_netscape_jsdebugging_engine_local
@echo com_netscape_jsdebugging_api_rhino
@echo com_netscape_jsdebugging_engine_rhino
@echo com_netscape_jsdebugging_jsdb
@echo com_netscape_jsdebugging_ifcui_palomar
@echo com_netscape_jsdebugging_ifcui
@echo com_netscape_jsdebugging_ifcui_launcher_local
@echo com_netscape_jsdebugging_ifcui_launcher_rhino
@echo com_netscape_jsdebugging_apitests
@echo com_netscape_jsdebugging_jslogger
@echo com_netscape_jsdebugging_tools_depend
@echo check_depend_jslogger
@echo jslogger_jar
@echo check_depend_netscape_jsdebug
@echo netscape_jsdebug_jar
core: initial_state \
netscape_security \
netscape_jsdebug \
com_netscape_jsdebugging_api \
com_netscape_jsdebugging_engine \
com_netscape_jsdebugging_api_local \
com_netscape_jsdebugging_engine_local \
!IF "$(NO_RHINO)" == ""
com_netscape_jsdebugging_api_rhino \
com_netscape_jsdebugging_engine_rhino \
!ENDIF
!IF "$(NO_CORBA)" == ""
com_netscape_jsdebugging_remote_corba \
com_netscape_jsdebugging_api_corba \
!ENDIF
jsdb : com_netscape_jsdebugging_jsdb
apitests : com_netscape_jsdebugging_apitests
ifcui : initial_state \
netscape_security \
netscape_javascript \
netscape_jsdebug \
com_netscape_jsdebugging_api \
com_netscape_jsdebugging_ifcui_palomar \
com_netscape_jsdebugging_ifcui \
CP_DIST_CLASSES_RESOURCES
ifcui_fast : com_netscape_jsdebugging_ifcui
ifcui_lanchers : com_netscape_jsdebugging_ifcui_launcher_local \
!IF "$(NO_RHINO)" == ""
com_netscape_jsdebugging_ifcui_launcher_rhino
!ENDIF
jslogger : ifcui com_netscape_jsdebugging_jslogger
jslogger_fast : com_netscape_jsdebugging_jslogger
depend_tool : initial_state com_netscape_jsdebugging_tools_depend
tools : depend_tool
dependency_checks : check_depend_jslogger \
check_depend_netscape_jsdebug \
check_depend_ifcui
jars : jslogger_jar \
netscape_jsdebug_jar \
ifcui_jar
netscape_security : initial_state
@echo building stubbed netscape.security classes
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\security\*.java
netscape_applet : initial_state
@echo building stubbed netscape.applet classes
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\applet\*.java
netscape_jsdebug : netscape_security
@echo building netscape.jsdebug
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\classes\netscape\jsdebug\*.java
netscape_javascript: netscape_security
@echo building netscape.javascript
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\javascript\*.java
com_netscape_jsdebugging_api : netscape_security
@echo building com.netscape.jsdebugging.api
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\*.java
com_netscape_jsdebugging_engine : com_netscape_jsdebugging_api
@echo building com.netscape.jsdebugging.engine
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\*.java
com_netscape_jsdebugging_api_local : com_netscape_jsdebugging_api netscape_jsdebug
@echo building com.netscape.jsdebugging.api.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\local\*.java
com_netscape_jsdebugging_engine_local : com_netscape_nativejsengine com_netscape_jsdebugging_engine netscape_jsdebug
@echo building com.netscape.jsdebugging.engine.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\local\*.java
com_netscape_nativejsengine :
@echo building com.netscape.nativejsengine
@sj $(JAVAFLAGS) $(CLASS_SRC)\com\netscape\nativejsengine\*.java
com_netscape_jsdebugging_api_rhino : com_netscape_jsdebugging_api
@echo building com.netscape.jsdebugging.api.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\rhino\*.java
com_netscape_jsdebugging_engine_rhino : com_netscape_jsdebugging_engine
@echo building com.netscape.jsdebugging.engine.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\rhino\*.java
com_netscape_jsdebugging_jsdb : core
@echo building com.netscape.jsdebugging.jsdb
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jsdb\*.java
com_netscape_jsdebugging_ifcui_palomar : initial_state
@echo building com.netscape.jsdebugging.ifcui.palomar etc...
@sj $(JAVAFLAGS)\
$(PALOMAR_DIR)\util\*.java\
$(PALOMAR_DIR)\widget\*.java\
$(PALOMAR_DIR)\widget\layout\*.java\
$(PALOMAR_DIR)\widget\layout\math\*.java\
$(PALOMAR_DIR)\widget\toolbar\*.java\
$(PALOMAR_DIR)\widget\toolTip\*.java
com_netscape_jsdebugging_ifcui :
@echo generating com.netscape.jsdebugging.ifcui.BuildDate
@gawk -f $(BUILD_DIR)\gen_date.awk -vpackage_name=com.netscape.jsdebugging.ifcui > $(JSDEBUGGING_DIR)\ifcui\BuildDate.java
@echo building com.netscape.jsdebugging.ifcui
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\*.java
com_netscape_jsdebugging_ifcui_launcher_local : ifcui
@echo building com.netscape.jsdebugging.ifcui.launcher.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\local\*.java
com_netscape_jsdebugging_ifcui_launcher_rhino : com_netscape_jsdebugging_api_rhino ifcui
@echo building com.netscape.jsdebugging.ifcui.launcher.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\rhino\*.java
com_netscape_jsdebugging_apitests : core
@echo building com.netscape.jsdebugging.apitests etc...
@sj $(JAVAFLAGS)\
$(JSDEBUGGING_DIR)\apitests\*.java\
$(JSDEBUGGING_DIR)\apitests\xml\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\desc\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\tests\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\analyzers\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\data\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\tree\*.java
com_netscape_jsdebugging_jslogger :
@echo building com.netscape.jsdebugging.jslogger
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jslogger\*.java
com_netscape_jsdebugging_tools_depend :
@echo building com.netscape.jsdebugging.tools.depend
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\tools\depend\*.java
com_netscape_jsdebugging_remote_corba : initial_state
@echo building com.netscape.jsdebugging.remote.corba
@if "$(ES3_ROOT)" == "" @echo !!! ES3_ROOT is not set !!!
@if not exist $(ES3_ROOT)\NUL @echo !!! $(ES3_ROOT) does not exist !!!
@sj $(CORBA_JAVA_FLAGS) \
$(JSDEBUGGING_DIR)\remote\corba\*.java \
$(JSDEBUGGING_DIR)\remote\corba\ISourceTextProviderPackage\*.java \
$(JSDEBUGGING_DIR)\remote\corba\TestInterfacePackage\*.java \
com_netscape_jsdebugging_api_corba : com_netscape_jsdebugging_api com_netscape_jsdebugging_remote_corba ifcui
@echo building com.netscape.jsdebugging.api.corba
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
api_corba_fast :
@echo building com.netscape.jsdebugging.api.corba
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
palomar_assert_on :
@echo generating com.netscape.jsdebugging.ifcui.palomar.util with assert on
@gawk -f $(BUILD_DIR)\gen_dbg.awk -vvalue=true -vpackage_name=com.netscape.jsdebugging.ifcui.palomar.util > $(JSDEBUGGING_DIR)\ifcui\palomar\util\AS.java
@echo building com.netscape.jsdebugging.ifcui.palomar.util
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\palomar\util\*.java
palomar_assert_off :
@echo generating com.netscape.jsdebugging.ifcui.palomar.util with assert on
@gawk -f $(BUILD_DIR)\gen_dbg.awk -vvalue=false -vpackage_name=com.netscape.jsdebugging.ifcui.palomar.util > $(JSDEBUGGING_DIR)\ifcui\palomar\util\AS.java
@echo building com.netscape.jsdebugging.ifcui.palomar.util
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\palomar\util\*.java
########## packaging #################
JSLOGGER_CLASS_FILES = \
com\netscape\jsdebugging\jslogger\*.class \
com\netscape\jsdebugging\ifcui\Log.class \
com\netscape\jsdebugging\ifcui\Env.class \
com\netscape\jsdebugging\ifcui\palomar\util\*.class
JSLOGGER_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/application \
-i netscape/util \
-i netscape/jsdebug \
-i netscape/security
check_depend_jslogger :
@echo checking for unexpected dependencies in jslogger
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(JSLOGGER_CLASS_FILES) $(JSLOGGER_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
jslogger_jar :
@echo building $(JSLOGGER_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(JSLOGGER_JARFILE) @del $(JSLOGGER_JARFILE) >NUL
@zip -q -r $(JSLOGGER_JARFILE) $(JSLOGGER_CLASS_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
@echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
@copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
##########
NETSCAPE_JSDEBUG_CLASS_FILES = netscape\jsdebug\*.class
NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/security \
-i netscape/util \
check_depend_netscape_jsdebug :
@echo checking for unexpected dependencies in netscape.jsdebug
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(NETSCAPE_JSDEBUG_CLASS_FILES) $(NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
netscape_jsdebug_jar :
@echo building $(NETSCAPE_JSDEBUG_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(NETSCAPE_JSDEBUG_JARFILE) @del $(NETSCAPE_JSDEBUG_JARFILE) >NUL
@zip -q -r $(NETSCAPE_JSDEBUG_JARFILE) $(NETSCAPE_JSDEBUG_CLASS_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
# @echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
# @copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
##########
IFCUI_CLASS_FILES = \
com\netscape\jsdebugging\ifcui\*.class \
com\netscape\jsdebugging\ifcui\palomar\util\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\layout\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\layout\math\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\toolbar\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\toolTip\*.class \
com\netscape\jsdebugging\api\*.class \
!IF "$(INCLUDE_SECURITY)" != ""
netscape\security\*.class \
!ENDIF
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
com\netscape\jsdebugging\api\local\*.class \
!ENDIF
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
com\netscape\jsdebugging\api\rhino\*.class \
!ENDIF
!IF "$(INCLUDE_CORBA_ADAPTER)" != ""
com\netscape\jsdebugging\api\corba\*.class \
!ENDIF
!IF "$(INCLUDE_LOCAL_LAUNCHER)" != ""
com\netscape\jsdebugging\ifcui\launcher\local\*.class \
!ENDIF
!IF "$(INCLUDE_RHINO_LAUNCHER)" != ""
com\netscape\jsdebugging\ifcui\launcher\rhino\*.class \
!ENDIF
IFCUI_OTHER_FILES = \
!IF "$(INCLUDE_IMAGES)" != ""
images\*.gif \
!ENDIF
!IF "$(INCLUDE_SOUNDS)" != ""
sounds\*.au \
!ENDIF
IFCUI_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/security \
-i netscape/util \
-i netscape/application \
-i netscape/javascript \
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
-i netscape/jsdebug \
!ENDIF
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
-i com/netscape/javascript \
!ENDIF
check_depend_ifcui :
@echo checking for unexpected dependencies for ifcui
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(IFCUI_CLASS_FILES) $(IFCUI_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
ifcui_jar :
@echo building $(IFCUI_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(IFCUI_JARFILE) @del $(IFCUI_JARFILE) >NUL
@zip -q -r $(IFCUI_JARFILE) $(IFCUI_CLASS_FILES) $(IFCUI_OTHER_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
@echo copying $(IFCUI_JARFILE) to $(IFCUI_RUN_DIR)
@copy $(DIST_CLASSES)\$(IFCUI_JARFILE) $(IFCUI_RUN_DIR) >NUL
########## javadoc stuff #################
ALL_PACKAGES = \
netscape.security \
netscape.jsdebug \
netscape.javascript \
netscape.applet \
com.netscape.jsdebugging.api \
com.netscape.jsdebugging.api.local \
com.netscape.jsdebugging.engine \
com.netscape.jsdebugging.engine.local \
com.netscape.jsdebugging.jsdb \
com.netscape.jsdebugging.ifcui \
com.netscape.jsdebugging.ifcui.palomar.util \
com.netscape.jsdebugging.ifcui.palomar.widget \
com.netscape.jsdebugging.ifcui.palomar.widget.layout \
com.netscape.jsdebugging.ifcui.palomar.widget.layout.math \
com.netscape.jsdebugging.ifcui.palomar.widget.toolbar \
com.netscape.jsdebugging.ifcui.palomar.widget.toolTip \
com.netscape.jsdebugging.ifcui.launcher.local \
com.netscape.jsdebugging.apitests \
com.netscape.jsdebugging.apitests.xml \
com.netscape.jsdebugging.apitests.testing \
com.netscape.jsdebugging.apitests.testing.desc \
com.netscape.jsdebugging.apitests.testing.tests \
com.netscape.jsdebugging.apitests.analyzing.analyzers \
com.netscape.jsdebugging.apitests.analyzing.data \
com.netscape.jsdebugging.apitests.analyzing.tree \
com.netscape.jsdebugging.jslogger \
com.netscape.jsdebugging.tools.depend \
com.netscape.nativejsengine \
!IF "$(NO_RHINO)" == ""
com.netscape.jsdebugging.api.rhino \
com.netscape.jsdebugging.engine.rhino \
com.netscape.jsdebugging.ifcui.launcher.rhino \
!ENDIF
!IF "$(NO_CORBA)" == ""
com.netscape.jsdebugging.api.corba \
com.netscape.jsdebugging.remote.corba \
com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage \
com.netscape.jsdebugging.remote.corba.TestInterfacePackage \
!ENDIF
javadoc_all : initial_state
@echo cleaning up old stuff in javadoc directory
@if exist $(DIST)\javadocs\*.html @del $(DIST)\javadocs\*.html > NUL
@echo copying javadoc images to the dist dir
@copy $(BUILD_DIR)\images\*.gif $(DIST)\javadocs\images > NUL
@echo building javadoc for EVERYTHING
@javadoc -sourcepath $(JAVADOC_CLASSPATH);$(CLASS_SRC);$(BUILD_DIR)\..\stub_classes -d $(DIST)\javadocs $(ALL_PACKAGES)
########## before anything can happen... #################
initial_state : MK_DIST_CLASSES_DIRS $(IFC_DIST_FILE)
$(IFC_DIST_FILE) :
@echo getting ifc11.jar -- if this fails you need to copy it to dist/classes yourself
copy ..\..\..\nav-java\stubs\classes\ifc11.jar $(DIST_CLASSES) > NUL
########## directory stuff #################
#
# This list got too long so I split it in two. If you need to add more items
# then add them to the second list...
#
DIST_CLASSES_DIRS_0 = \
$(DIST) \
$(DIST_CLASSES) \
$(DIST_CLASSES)\images \
$(DIST_CLASSES)\sounds \
$(DIST_CLASSES)\netscape \
$(DIST_CLASSES)\netscape\security \
$(DIST_CLASSES)\netscape\jsdebug \
$(DIST_CLASSES)\netscape\javascript \
$(DIST_CLASSES)\netscape\applet \
$(DIST_CLASSES)\com \
$(DIST_CLASSES)\com\netscape \
$(DIST_CLASSES)\com\netscape\jsdebugging \
$(DIST_CLASSES)\com\netscape\jsdebugging\api \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\corba \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\jsdb \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\util \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout\math \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolbar \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolTip \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\xml \
DIST_CLASSES_DIRS_1 = \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\desc \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\tests \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\analyzers \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\data \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\tree \
$(DIST_CLASSES)\com\netscape\jsdebugging\jslogger \
$(DIST_CLASSES)\com\netscape\jsdebugging\tools \
$(DIST_CLASSES)\com\netscape\jsdebugging\tools\depend \
$(DIST_CLASSES)\com\netscape\nativejsengine \
$(DIST)\javadocs \
$(DIST)\javadocs\images \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\ISourceTextProviderPackage \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\TestInterfacePackage \
MK_DIST_CLASSES_DIRS :
@echo making any non existent classfile output directories
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if not exist %i\NUL mkdir %i > NUL
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if not exist %i\NUL mkdir %i > NUL
CP_DIST_CLASSES_RESOURCES : initial_state
@echo copying images and sounds to dist directory
@xcopy $(BUILD_DIR)\..\ifcui\run\images\*.* $(DIST_CLASSES)\images > NUL
@xcopy $(BUILD_DIR)\..\ifcui\run\sounds\*.* $(DIST_CLASSES)\sounds > NUL
clean:
@echo deleting built classes
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if exist %i\*.class @del %i\*.class > NUL
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if exist %i\*.class @del %i\*.class > NUL
@echo deleting ifcui image and sound resources
@if exist $(DIST_CLASSES)\images\*.gif @del $(DIST_CLASSES)\images\*.gif > NUL
@if exist $(DIST_CLASSES)\sounds\*.au @del $(DIST_CLASSES)\sounds\*.au > NUL

View File

@@ -0,0 +1 @@
call mk_ifcui_std.bat ifcui_fast ifcui_jar INCLUDE_RHINO_ADAPTER=1 INCLUDE_RHINO_LAUNCHER=1

View File

@@ -0,0 +1,2 @@
nmake -f jsdj.mak INCLUDE_SECURITY=1 INCLUDE_LOCAL_ADAPTER=1 INCLUDE_LOCAL_LAUNCHER=1 INCLUDE_IMAGES=1 INCLUDE_SOUNDS=1 INCLUDE_RHINO_ADAPTER=1 INCLUDE_RHINO_LAUNCHER=1 NO_CORBA=1 %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@@ -0,0 +1,21 @@
/* generated by gen_date.awk to provide access to build date at runtime */
package com.netscape.jsdebugging.ifcui;
class BuildDate
{
// Wednesday, September 23, 1998 at 05:12 PM
public static final long buildDate = 906595979000L;
public static final java.util.Date date()
{
return new java.util.Date(buildDate);
}
public static final String display()
{
return date().toString();
}
}

View File

@@ -0,0 +1,91 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* helper class to trim a string and its rect to fit a clip rect width
*/
// when who what
// 09/23/98 jband created file
//
package com.netscape.jsdebugging.ifcui;
import netscape.application.*;
import netscape.util.*;
/* NOTE: results are in object vars -- caller must handle synchronization */
public class DrawStringClipper
{
public DrawStringClipper( int charWidth ) {_charWidth = charWidth;}
public void setCharWidth( int charWidth ) {_charWidth = charWidth;}
public int doClip(String str, Rect rect, Rect clipRect)
{
_str = str;
_rect = rect;
_len = _str.length();
int charsToTrim;
int space;
if( _len > 0 )
{
space = (_rect.x + _rect.width) - (clipRect.x + clipRect.width);
if( space > _charWidth )
{
space = (space/_charWidth)*_charWidth;
int trail = (_rect.width/_charWidth) - _len;
charsToTrim = Math.min(_len, (space/_charWidth)- trail);
if( charsToTrim > 0 )
{
_rect.width -= space;
_str = _str.substring(0, _len-charsToTrim);
_len -= charsToTrim;
}
}
}
if( _len > 0 )
{
space = clipRect.x - _rect.x;
if( space > _charWidth )
{
space = (space/_charWidth)*_charWidth;
charsToTrim = Math.min(_len, space / _charWidth);
if( charsToTrim > 0 )
{
_rect.x += space;
_rect.width -= space;
_str = _str.substring(charsToTrim);
_len -= charsToTrim;
}
}
}
return _len;
}
public String getString() {return _str;}
public int getStringLength() {return _len;}
public Rect getRect() {return _rect;}
private String _str;
private int _len;
private Rect _rect;
private int _charWidth;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
/* generated by gen_dbg.awk to set DEBUG on or off */
package com.netscape.jsdebugging.ifcui.palomar.util;
public interface AS
{
public static final boolean S = true;
public static final boolean DEBUG = true;
}

View File

@@ -0,0 +1,162 @@
<html>
<head>
<title>JSD Architecture</title>
</head>
<body bgcolor=white>
<h1><center>JSD Architecture</center></h1>
<a href="mailto:jband@netscape.com"><center>John Bandhauer</center></a>
<i><center>6 July 1998</center></i>
<p>
<center><img src="jsd_arch.jpg" border=1><br></center>
<center><i>Basic JSD architecture for both C and Java engines</i></center>
<p>
<table>
<tr>
<td valign=top><font color=red>(1)</font></td>
<td>
Spider Monkey JavaScript engine. This is an unmodified engine which exposes
a low-level debug interface via <code>js/src/jsdbgapi.h</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(2)</font></td>
<td>
Spider Monkey JavaScript debug support. This provides a wrapper and does
bookkeeping.
</td>
</tr>
<tr>
<td valign=top><font color=red>(3)</font></td>
<td>
Corba adapter. Using only public interfaces of JSD this module remotes
the debug interface over a Corba connection.
</td>
</tr>
<tr>
<td valign=top><font color=red>(4)</font></td>
<td>
JNI native adapter. This implements the natives of <code>netscape.debug</code>
using JNI natives.
</td>
</tr>
<tr>
<td valign=top><font color=red>(5)</font></td>
<td>
Old JDK native adapter. This implements the natives of <code>netscape.debug</code>
using old style JDK natives. This is currently in use in Communicator 4.x.
</td>
</tr>
<tr>
<td valign=top><font color=red>(6)</font></td>
<td>
Rhino <i>JavaScript for Java</i> engine. This is the unmodified Rhino engine.
It exposes the low-level debug interface via various interface classesand support
built into the Context and Codegen classes.
</td>
</tr>
<tr>
<td valign=top><font color=red>(7)</font></td>
<td>
Rhino debug support package. This exposes a higher level debug interface for
Rhino and includes a reference implementation of that interface.
</td>
</tr>
<tr>
<td valign=top><font color=red>(8)</font></td>
<td>
Client end of Corba adapter. This implements <code>com.netscape.jsdebugging.api</code>
to provide debugger clients access to an engine running in a different process
space.
</td>
</tr>
<tr>
<td valign=top><font color=red>(9)</font></td>
<td>
<code>netscape.debug</code> is a package included in Communiator 4.x.
The JNI and JDK natives supply the bridge from C to Java that is exposed on the
Java side by this package.
</td>
</tr>
<tr>
<td valign=top><font color=red>(10)</font></td>
<td>
The local adapter implements <code>com.netscape.jsdebugging.api</code> in a form that
allows the debugger client to connect to <code>netscape.debug</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(11)</font></td>
<td>
The rhino adapter implements <code>com.netscape.jsdebugging.api</code> in a form that
allows the debugger client to connect to <code>com.netscape.javascript.debug</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(12)</font></td>
<td>
<code>com.netscape.jsdebugging.api</code> is an interface only package that allows
debugger clients to talk to any of the adapters transparently and with no
compile-time coupling to the adapters.
</td>
</tr>
<tr>
<td valign=top><font color=red>(13)</font></td>
<td>
Java-based Graphical Debugger. Currently we have one debugger written using IFC
and shipping in it's 1.1 form. Version 1.2 is unfinished and under development
in the mozilla tree in <code>js/sjdj/classes</code> in the package
<code>com.netscape.jsdebugging.ifcui</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(14)</font></td>
<td>
Java-based Console Debugger. Currently we have a version of this checked in
to the mozilla tree in <code>com.netscape.jsdebugging.jsdb</code>. This version
will work with either Rhino or the C engine using engine abstraction classes in
<code>com.netscape.jsdebugging.engine</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(15)</font></td>
<td>
Java-based debug api tests are implemented in
<code>com.netscape.jsdebugging.apitests</code>.
</td>
</tr>
<tr>
<td valign=top><font color=red>(n/a)</font></td>
<td>
Not shown is a purely native console debugger which uses only js/src and js/jsd.
It can be found in js/jsd/jsdb. This debugger uses the JS shell and reflects
the JSD api into the JavaScript language. The actual debugger is written in
JavaScript. It can be modified and extended as it runs and can debug itself.
</td>
</tr>
</table>
<HR>
last updated: 28 September 1998 - jband
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -16,10 +16,13 @@
* Reserved.
*/
#ifndef nspr_win16_defs_h___
#define nspr_win16_defs_h___
/*
* global data definitions
*/
#define HAVE_DLL
#undef HAVE_LONG_LONG
#include "headers.h"
#endif /* nspr_win16_defs_h___ */
/* Globals */
HINSTANCE g_hInstance = 0;
HWND g_hMainDlg = 0;

View File

@@ -0,0 +1,104 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* drawing wrappers
*/
#include "headers.h"
static int _maxX;
static int _maxY;
static int _offsetX;
static int _offsetY;
static int _lastX;
static int _lastY;
static COLORREF _penColor = RGB(0,0,0);
static int _penWidth = 1;
static HPEN _pen = 0;
static void _newPen()
{
if( _pen )
DeleteObject(_pen);
_pen = CreatePen(PS_SOLID, _penWidth, _penColor);
}
void SetPenColor( COLORREF color )
{
_penColor = color;
_newPen();
}
void SetPenWidth( int width )
{
_penWidth = width;
_newPen();
}
void SetSurfaceSize( int dx, int dy )
{
_maxX = dx;
_maxY = dy;
}
void SetSurfaceOffset( int dx, int dy )
{
_offsetX = dx;
_offsetY = dy;
}
void DlgToSurface( POINT* ppt )
{
ppt->x -= _offsetX;
ppt->y -= _offsetY;
}
void SurfaceToDlg( POINT* ppt )
{
ppt->x += _offsetX;
ppt->y += _offsetY;
}
void DrawMoveTo(int x, int y)
{
x = min(_maxX-_penWidth/2,max(_penWidth/2,x));
y = min(_maxY-_penWidth/2,max(_penWidth/2,y));
_lastX = x;
_lastY = y;
}
void DrawLineTo(int x, int y)
{
HDC hdc;
HGDIOBJ oldPen;
x = min(_maxX-_penWidth/2,max(_penWidth/2,x));
y = min(_maxY-_penWidth/2,max(_penWidth/2,y));
hdc = GetDC(g_hMainDlg);
oldPen = SelectObject(hdc, _pen);
MoveToEx(hdc, _lastX + _offsetX, _lastY + _offsetY, NULL);
LineTo(hdc, x + _offsetX, y + _offsetY);
SelectObject(hdc, oldPen);
ReleaseDC(g_hMainDlg, hdc);
_lastX = x;
_lastY = y;
}

View File

@@ -16,15 +16,28 @@
* Reserved.
*/
#ifndef nspr_scoos5_defs_h___
#define nspr_scoos5_defs_h___
/*
* Windows header files
*/
#undef HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#define HAVE_DLL
#define USE_DLFCN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include "jsapi.h"
#ifdef JSDEBUGGER
#include "jsdebug.h"
#include "jsdjava.h"
#endif
#include "jsdraw.h"
#include "resource.h"
#define NEED_TIME_R
#endif /* nspr_scoos5_defs_h___ */

View File

@@ -0,0 +1,434 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Top-level windows code
*/
#include "headers.h"
static JSContext* _cx;
static JSObject* _glob;
#ifdef JSDEBUGGER
static JSDContext* _jsdc = NULL;
static JSDSourceText* _jsdsrc = NULL;
static JSDJContext* _jsdjc = NULL;
#endif
/********************************/
static char*
_readFile(const char* filename)
{
int fh;
int len;
char* buf;
fh = _open(filename, _O_RDONLY | _O_BINARY);
if(-1 ==fh)
return NULL;
len = _lseek(fh, 0, SEEK_END);
if(-1 == len)
{
_close(fh);
return NULL;
}
_lseek(fh, 0, SEEK_SET);
buf = malloc(len+1);
if(! buf)
{
_close(fh);
return NULL;
}
_read(fh, buf, len);
_close(fh);
buf[len] = 0;
return buf;
}
/********************************/
static void
ignore_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
}
static void
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
char buf[1024];
char bigBuf[2048];
bigBuf[0] = 0;
if(report && report->filename)
{
sprintf( buf, "FILE: %s\n", report->filename );
strcat( bigBuf, buf );
}
if(report && report->lineno)
{
sprintf( buf, "LINE: %d\n", report->lineno );
strcat( bigBuf, buf );
}
strcat( bigBuf, message );
strcat( bigBuf, "\n\n" );
if(report && report->linebuf)
strcat( bigBuf, report->linebuf );
MessageBox( g_hMainDlg, bigBuf, "JavaScript Error", MB_ICONHAND );
}
/********************************/
static JSBool
_MoveTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int x;
int y;
if( argc != 2 ||
! JS_ValueToInt32(cx, argv[0], &x) ||
! JS_ValueToInt32(cx, argv[1], &y) )
{
JS_ReportError(cx, "MoveTo requires 2 numerical args");
return JS_FALSE;
}
DrawMoveTo(x, y);
return JS_TRUE;
}
static JSBool
_LineTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
int x;
int y;
if( argc != 2 ||
! JS_ValueToInt32(cx, argv[0], &x) ||
! JS_ValueToInt32(cx, argv[1], &y) )
{
JS_ReportError(cx, "LineTo requires 2 numerical args");
return JS_FALSE;
}
DrawLineTo(x, y);
return JS_TRUE;
}
static JSBool
_Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* source;
const char* filename;
JSString* s;
if( argc != 1 )
{
JS_ReportError(cx, "requires 1 arg");
return JS_FALSE;
}
if( ! (s = JS_ValueToString(cx, argv[0])) )
{
JS_ReportError(cx, "param must be a string");
return JS_FALSE;
}
filename = JS_GetStringBytes(s);
source = _readFile(filename);
if(! source)
{
JS_ReportError(cx, "failed to load source");
return JS_FALSE;
}
#ifdef JSDEBUGGER
if(_jsdc)
JSD_AddFullSourceText(_jsdc, source, strlen(source), filename);
#endif
JS_EvaluateScript(cx, _glob, source, strlen(source), filename, 1, rval);
free(source);
return JS_TRUE;
}
static JSBool
_Save(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
const char* filename;
JSString* s;
if( DoingRedraw() )
return JS_TRUE;
if( argc != 1 )
{
JS_ReportError(cx, "requires 1 arg");
return JS_FALSE;
}
if( ! (s = JS_ValueToString(cx, argv[0])) )
{
JS_ReportError(cx, "param must be a string");
return JS_FALSE;
}
filename = JS_GetStringBytes(s);
if( ! SaveRecordedHistory(filename) )
{
JS_ReportError(cx, "failed to save recorded history");
return JS_FALSE;
}
return JS_TRUE;
}
static JSBool
_StartRecord(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
/* just the statement in the history is enough to get the action */
return JS_TRUE;
}
static JSBool
_SetPenWidth(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
jsdouble width;
if( argc != 1 )
{
JS_ReportError(cx, "requires 1 arg");
return JS_FALSE;
}
if( ! JS_ValueToNumber(cx, argv[0], &width) ||
width < 1 || width > 100 )
{
JS_ReportError(cx, "width must be set to a value between 1 and 100");
return JS_FALSE;
}
SetPenWidth( (int) width );
}
typedef struct
{
char* name;
COLORREF color;
} COLOR_DEF;
static COLOR_DEF colors[] =
{
{"white", RGB(255,255,255)},
{"black", RGB(0,0,0)},
{"red" , RGB(255,0,0)},
{"green", RGB(0,255,0)},
{"blue" , RGB(0,0,255)},
{NULL, 0}
};
static JSBool
_SetPenColor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
jsdouble dblColor;
COLORREF color;
int i;
if( argc != 1 )
{
JS_ReportError(cx, "requires 1 arg");
return JS_FALSE;
}
if( JSVAL_IS_NUMBER(argv[0]) && JS_ValueToNumber(cx, argv[0], &dblColor) )
{
color = (COLORREF) dblColor;
if( color < RGB(0,0,0) || color > RGB(255,255,255) )
{
JS_ReportError(cx, "color value is out of range");
return JS_FALSE;
}
}
else if( JSVAL_IS_STRING(argv[0]) )
{
JSString* s = JS_ValueToString(cx, argv[0]);
const char* colorname;
if(!s)
{
JS_ReportError(cx, "param must be a color string or value");
return JS_FALSE;
}
colorname = JS_GetStringBytes(s);
for( i = 0; colors[i].name; i++ )
{
if( 0 == strcmp(colors[i].name, colorname) )
{
color = colors[i].color;
break;
}
}
if( ! colors[i].name )
{
JS_ReportError(cx, "unknown color");
return JS_FALSE;
}
}
SetPenColor( color );
return JS_TRUE;
}
/********************************/
static JSFunctionSpec my_functions[] = {
{"MoveTo", _MoveTo, 2},
{"LineTo", _LineTo, 2},
{"load", _Load, 1},
{"save", _Save, 1},
{"start_record", _StartRecord, 0},
{"setPenWidth", _SetPenWidth, 1},
{"setPenColor", _SetPenColor, 1},
{0}
};
static JSClass global_class = {
"global", 0,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
};
BOOL Eval(char* str, int lineno)
{
jsval rval;
#ifdef JSDEBUGGER
if(_jsdc)
{
if(1 == lineno)
_jsdsrc = JSD_NewSourceText(_jsdc, "drawer");
if(_jsdsrc)
_jsdsrc = JSD_AppendSourceText(_jsdc, _jsdsrc, str, strlen(str),
JSD_SOURCE_PARTIAL);
}
#endif
return JS_EvaluateScript(_cx, _glob, str, strlen(str), "drawer", lineno, &rval);
}
static char autoload[] = "load(\"autoload.js\")";
#ifdef JSDEBUGGER
static void
_startStopCallback(JSDJContext* jsdjc, int event, void *closure)
{
*((int*)closure) = event;
}
#endif
int WINAPI
WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
JSRuntime* rt;
jsval rval;
#ifdef JSDEBUGGER
int startupFlag;
int timeoutCounter;
#endif
rt = JS_Init(8L * 1024L * 1024L);
if (!rt)
return 1;
_cx = JS_NewContext(rt, 8192);
if (!_cx)
return 1;
_glob = JS_NewObject(_cx, &global_class, NULL, NULL);
if (!_glob)
return 1;
if (!JS_InitStandardClasses(_cx, _glob))
return 1;
JS_SetErrorReporter(_cx, my_ErrorReporter);
if (!JS_DefineFunctions(_cx, _glob, my_functions))
return 1;
#ifdef JSDEBUGGER
if( strstr(lpCmdLine, "DEBUG") )
{
_jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
if(!_jsdc)
return 1;
_jsdjc = JSDJ_CreateContext();
if( ! _jsdjc )
return 1;
JSDJ_SetJSDContext(_jsdjc, _jsdc);
JSDJ_SetStartStopCallback(_jsdjc, _startStopCallback, &startupFlag);
JSD_JSContextInUse(_jsdc, _cx);
JSDJ_CreateJavaVMAndStartDebugger(_jsdjc);
// timout debugger startup after 30 seconds
startupFlag = 0;
for(timeoutCounter = 0; timeoutCounter < 300; timeoutCounter++)
{
if(startupFlag)
break;
Sleep(100);
}
/**
* XXX Hack here because current DebugController as no iterateScripts
* method and thus the debugger can only see the scripts created
* after *it* has set it's hooks. The debugger has code to iterate
* scripts and thus learn about scripts which were in place before
* the debugger has set its hooks. But, the underlying code does not
* yet support it.
* So... we wait for an arbitrary amount of time here to let the
* debugger get its hooks in before we load any scripts
*/
Sleep(2000);
JSDJ_SetStartStopCallback(_jsdjc, NULL, NULL);
}
#endif
g_hInstance = hInstance;
JS_SetErrorReporter(_cx, ignore_ErrorReporter);
JS_EvaluateScript(_cx, _glob, autoload, strlen(autoload), "autoload", 1, &rval);
JS_SetErrorReporter(_cx, my_ErrorReporter);
DialogBox(hInstance, MAKEINTRESOURCE(IDDIALOG_MAIN), NULL, MainDlgProc );
#ifdef JSDEBUGGER
if(_jsdc)
JSD_DebuggerOff(_jsdc);
#endif
JS_DestroyContext(_cx);
JS_Finish(rt);
return 0;
}

View File

@@ -16,26 +16,27 @@
* Reserved.
*/
#ifndef nspr_sunos_defs_h___
#define nspr_sunos_defs_h___
/* Globals */
#undef HAVE_LONG_LONG
#define HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS
#define HAVE_DLL
extern HINSTANCE g_hInstance;
extern HWND g_hMainDlg;
#define NEED_TIME_R
#define USE_DLFCN
BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam);
/*
** Missing function prototypes
*/
/* from prompt.c */
void Prompt( char* prompt, char* answer, int maxAnswer );
extern int socket (int domain, int type, int protocol);
extern int getsockname (int s, struct sockaddr *name, int *namelen);
extern int accept (int s, struct sockaddr *addr, int *addrlen);
extern int listen (int s, int backlog);
extern int brk(void *);
extern void *sbrk(int);
/* from draw.c */
void SetSurfaceSize( int dx, int dy );
void SetSurfaceOffset( int dx, int dy );
void DlgToSurface( POINT* ppt );
void SurfaceToDlg( POINT* ppt );
void SetPenColor( COLORREF color );
void SetPenWidth( int width );
void DrawMoveTo(int x, int y);
void DrawLineTo(int x, int y);
BOOL DoingRedraw();
#endif /* nspr_sunos_defs_h___ */
BOOL SaveRecordedHistory(const char* filename);
BOOL Eval(char* str, int lineno);

View File

@@ -0,0 +1,118 @@
#
# jband - 11/08/97 -
#
#
# jband - 22 Sept 1998 - ripped out JSD stuff just to get this compiling
#
PROJ = jsdraw
JSSRC = ..\..\SRC
OBJ = Debug
RUN = Run
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
/I $(JSSRC)\
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
LFLAGS = /nologo /subsystem:windows /entry:WinMainCRTStartup /incremental:no\
/machine:I386 /DEBUG\
/pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).exe
LLIBS = kernel32.lib advapi32.lib $(JSSRC)\Debug\js32.lib \
user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib
RCFLAGS = /r -DWIN32 -D_WIN32
CPP=cl.exe
LINK32=link.exe
RC=rc.exe
all: $(OBJ) $(RUN) $(RUN)\$(PROJ).exe $(RUN)\$(PROJ).pdb \
$(RUN)\js32.dll $(RUN)\js32.pdb
$(OBJ)\$(PROJ).exe: \
$(OBJ)\jsdraw.obj \
$(OBJ)\maindlg.obj \
$(OBJ)\prompt.obj \
$(OBJ)\data.obj \
$(OBJ)\draw.obj \
$(OBJ)\jsdraw.res
$(LINK32) $(LFLAGS) $** $(LLIBS)
$(OBJ)\$(PROJ).res: $(PROJ).rc resource.h
.rc{$(OBJ)}.res:
$(RC) $(RCFLAGS) /fo$@ $<
.c{$(OBJ)}.obj:
$(CPP) $(CFLAGS)
$(OBJ) :
mkdir $(OBJ)
$(RUN) :
mkdir $(RUN)
$(RUN)\$(PROJ).exe: $(OBJ)\$(PROJ).exe
copy $(OBJ)\$(PROJ).exe $(RUN)
$(RUN)\$(PROJ).pdb: $(OBJ)\$(PROJ).pdb
copy $(OBJ)\$(PROJ).pdb $(RUN)
$(RUN)\js32.dll :
copy $(JSSRC)\Debug\js32.dll $(RUN)
$(RUN)\js32.pdb :
copy $(JSSRC)\Debug\js32.pdb $(RUN)
clean:
del $(OBJ)\*.pch
del $(OBJ)\*.obj
del $(OBJ)\*.exp
del $(OBJ)\*.lib
del $(OBJ)\*.res
del $(OBJ)\*.idb
del $(OBJ)\*.pdb
del $(OBJ)\*.exe
del $(RUN)\*.pdb
del $(RUN)\*.exe
##
## jband - 11/08/97 -
##
#
#TARGETOS = WINNT
#
#!include <win32.mak>
#
#all: jsdraw.exe
#
## Update the resources if necessary
#
#jsdraw.res: jsdraw.rc resource.h
# $(rc) $(rcflags) $(rcvars) jsdraw.rc
#
#jsdraw.exe: \
# jsdraw.obj \
# maindlg.obj \
# prompt.obj \
# data.obj \
# draw.obj \
# jsdraw.res
# $(link) $(linkdebug) $(guiflags) -out:$*.exe $** ..\JSSRC\Debug\js32.lib $(guilibs)
#
#.c.obj:
# $(cc) $(cdebug) $(cflags) $(cvars) /I..\JSSRC /YX $*.c
#
#clean:
# del *.obj
# del *.pch
# del jsdraw.res
# del jsdraw.exe

View File

@@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* Windows resources
*/
#include <windows.h>
#include "resource.h"
IDDIALOG_MAIN DIALOG 59, 26, 281, 368
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX
CAPTION "JSDraw"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "", IDD_SURFACE, "Static", SS_BLACKFRAME, 6, 2, 268, 194
EDITTEXT IDD_CONSOLE, 2, 309, 230, 55, ES_MULTILINE |
ES_AUTOHSCROLL | WS_VSCROLL
LISTBOX IDD_HISTORY, 2, 201, 230, 114, WS_VSCROLL
PUSHBUTTON "Set Color", IDD_SET_COLOR, 237, 203, 40, 14
PUSHBUTTON "Set Width", IDD_SET_WIDTH, 237, 220, 40, 14
PUSHBUTTON "Record", IDD_RECORD, 237, 237, 40, 14
PUSHBUTTON "Save", IDD_SAVE, 237, 254, 40, 14
PUSHBUTTON "Load", IDD_LOAD, 237, 271, 40, 14
PUSHBUTTON "Clear",IDD_CLEAR, 237, 289, 40, 14
DEFPUSHBUTTON "Eval", IDD_EVAL, 237, 310, 40, 30
PUSHBUTTON "Exit", IDCANCEL, 237, 350, 40, 14
END
IDDIALOG_PROMPT DIALOG 143, 110, 182, 56
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "JSDraw - Prompt"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Prompt here..", IDD_PROMPT_PROMPT, 3, 5, 178, 8
EDITTEXT IDD_PROMPT_ANSWER, 1, 18, 179, 12, ES_AUTOHSCROLL
DEFPUSHBUTTON "OK", IDOK, 69, 35, 40, 14
END

View File

@@ -0,0 +1,423 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* main window code
*/
#include "headers.h"
static BOOL _doingRedraw = FALSE;
BOOL DoingRedraw()
{
return _doingRedraw;
}
void AddToHistory( char* str )
{
int len = strlen(str);
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
if(len && '\n' == str[len-1])
str[len-1] = 0;
SendMessage(list, LB_ADDSTRING, 0, (LPARAM) str );
SendMessage(list, LB_SETCURSEL,
(WPARAM) SendMessage(list, LB_GETCOUNT, 0, 0) - 1, 0 );
if(len && 0 == str[len-1])
str[len-1] = '\n';
}
void ClearHistory()
{
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
int i;
for( i = SendMessage(list, LB_GETCOUNT, 0, 0); i >= 0; i-- )
SendMessage(list, LB_DELETESTRING, i, 0 );
}
void EvalAllOfHistory()
{
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
int count = SendMessage(list, LB_GETCOUNT, 0, 0);
int cursize;
int size = 0;
int index = 0;
int i;
char* buf;
_doingRedraw = TRUE;
for( i = 0; i < count; i++ )
{
cursize = SendMessage(list, LB_GETTEXTLEN, i, 0);
if(-1 != cursize)
size += cursize+1;
}
if( ! size)
{
_doingRedraw = FALSE;
return;
}
buf = malloc(size+1);
if(! buf)
{
_doingRedraw = FALSE;
return;
}
for( i = 0; i < count; i++ )
{
cursize = SendMessage(list, LB_GETTEXT, i, (LPARAM)&buf[index]);
if(-1 != cursize)
{
index += cursize+1;
buf[index-1] = '\n';
}
}
buf[index] = 0;
if(index)
Eval(buf,1);
free(buf);
_doingRedraw = FALSE;
}
BOOL
SaveRecordedHistory(const char* filename)
{
HWND list = GetDlgItem(g_hMainDlg, IDD_HISTORY);
int count = SendMessage(list, LB_GETCOUNT, 0, 0);
int size = 0;
int start = 0;
char* buf;
int fh;
int i;
for( i = 0; i < count; i++ )
size = max(SendMessage(list, LB_GETTEXTLEN, i, 0),size);
if( ! size )
return FALSE;
buf = malloc(size+2);
if(! buf)
return FALSE;
for( i = 0; i < count; i++ )
{
if(-1 != SendMessage(list, LB_GETTEXT, i, (LPARAM)buf))
{
if( strstr(buf, "start_record") )
start = i+1;
}
}
if( start == count )
{
free(buf);
return FALSE;
}
fh = _open(filename, _O_CREAT | _O_TRUNC | _O_BINARY | _O_RDWR);
if(-1 ==fh)
{
free(buf);
return FALSE;
}
for( i = start; i < count; i++ )
{
if(-1 != SendMessage(list, LB_GETTEXT, i, (LPARAM)buf))
{
strcat(buf, "\n");
_write(fh, buf, strlen(buf));
}
}
_close(fh);
free(buf);
return TRUE;
}
static BOOL
EvalAndAddToHistory(char* expr, int* lineno)
{
if( Eval(expr, *(lineno)+1) )
{
AddToHistory(expr);
*(lineno)++;
return TRUE;
}
else
{
EvalAllOfHistory();
return FALSE;
}
}
BOOL WINAPI
MainDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam)
{
static BOOL _drawing = FALSE;
static RECT _rectSurface;
static lineno = 0;
switch(msg)
{
case WM_INITDIALOG:
{
RECT r;
POINT pt;
g_hMainDlg = hDlg;
SetPenColor(RGB(255,0,0));
SetPenWidth(2);
SendMessage( GetDlgItem(hDlg, IDD_CONSOLE), WM_SETFONT,
(WPARAM)GetStockObject(ANSI_FIXED_FONT),0);
SendMessage( GetDlgItem(hDlg, IDD_HISTORY), WM_SETFONT,
(WPARAM)GetStockObject(ANSI_FIXED_FONT),0);
/* Calc offsets for our drawing surface */
GetClientRect(hDlg, &r);
pt.x = r.left;
pt.y = r.top;
ClientToScreen(hDlg, &pt);
GetWindowRect(GetDlgItem(hDlg, IDD_SURFACE), &_rectSurface);
SetSurfaceSize(_rectSurface.right - _rectSurface.left,
_rectSurface.bottom - _rectSurface.top);
SetSurfaceOffset(_rectSurface.left - pt.x,
_rectSurface.top - pt.y);
OffsetRect(&_rectSurface, -pt.x, -pt.y);
SetForegroundWindow(hDlg);
return TRUE;
}
case WM_ERASEBKGND:
{
/* This is a hack to give us a white drawing surface */
static HRGN hrgnSurface = 0;
static HRGN hrgnTemp = 0;
RECT r;
if( 0 == hrgnSurface )
hrgnSurface = CreateRectRgn(_rectSurface.left,
_rectSurface.top,
_rectSurface.right,
_rectSurface.bottom);
if( 0 == hrgnTemp )
hrgnTemp = CreateRectRgn(0,0,1,1);
GetClipRgn( (HDC)wParam, hrgnTemp );
FillRect((HDC)wParam, &_rectSurface, GetStockObject(WHITE_BRUSH));
ExtSelectClipRgn((HDC)wParam,hrgnSurface,RGN_XOR);
GetClientRect(hDlg, &r);
FillRect((HDC)wParam, &r, GetStockObject(LTGRAY_BRUSH));
SelectClipRgn((HDC)wParam,hrgnTemp);
return TRUE;
}
case WM_PAINT:
{
EvalAllOfHistory();
return FALSE;
}
case WM_LBUTTONDOWN:
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
if( PtInRect(&_rectSurface, pt) )
{
char buf[32];
RECT r;
GetWindowRect(GetDlgItem(hDlg, IDD_SURFACE), &r);
ClipCursor(&r);
SetCapture(hDlg);
_drawing = TRUE;
DlgToSurface(&pt);
sprintf( buf, "MoveTo(%d,%d)\n", pt.x, pt.y );
EvalAndAddToHistory(buf,&lineno);
}
return TRUE;
}
case WM_MOUSEMOVE:
if( _drawing )
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
char buf[32];
DlgToSurface(&pt);
sprintf( buf, "LineTo(%d,%d)\n", pt.x, pt.y );
EvalAndAddToHistory(buf,&lineno);
}
return TRUE;
case WM_LBUTTONUP:
if( _drawing )
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
char buf[32];
DlgToSurface(&pt);
sprintf( buf, "LineTo(%d,%d)\n", pt.x, pt.y );
EvalAndAddToHistory(buf,&lineno);
ReleaseCapture();
ClipCursor(NULL);
_drawing = FALSE;
}
return TRUE;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, 0);
return TRUE;
case IDD_CLEAR:
if( BN_CLICKED == HIWORD(wParam) )
{
ClearHistory();
lineno = 0;
InvalidateRect(hDlg, NULL, TRUE);
}
return TRUE;
case IDD_EVAL:
if( BN_CLICKED == HIWORD(wParam) )
{
char* p;
int len;
HWND edit = GetDlgItem(hDlg, IDD_CONSOLE);
len = SendMessage(edit, WM_GETTEXTLENGTH, 0, 0 );
p = malloc(len+2);
SendMessage(edit, WM_GETTEXT, len+1, (LPARAM) p);
strcat(p,"\n");
if( EvalAndAddToHistory(p,&lineno) )
SendMessage(edit, WM_SETTEXT, 0, (LPARAM)"");
free(p);
SetFocus(edit);
}
return TRUE;
case IDD_SET_COLOR:
if( BN_CLICKED == HIWORD(wParam) )
{
char Buf[256];
char Buf2[256];
Prompt( "Enter value or quoted color name", (char*)&Buf, 256 );
sprintf(Buf2, "setPenColor(%s);\n", Buf);
EvalAndAddToHistory(Buf2,&lineno);
}
return TRUE;
case IDD_SET_WIDTH:
if( BN_CLICKED == HIWORD(wParam) )
{
char Buf[256];
char Buf2[256];
Prompt( "Enter New Width (1-100)", (char*)&Buf, 256 );
sprintf(Buf2, "setPenWidth(%s);\n", Buf);
EvalAndAddToHistory(Buf2,&lineno);
}
return TRUE;
case IDD_RECORD:
if( BN_CLICKED == HIWORD(wParam) )
{
EvalAndAddToHistory("start_record()\n",&lineno);
}
return TRUE;
case IDD_LOAD:
if( BN_CLICKED == HIWORD(wParam) )
{
char Buf[_MAX_PATH+1];
char Buf2[_MAX_PATH+32];
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
Buf[0] = 0;
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = "JavaScript Source (*.js)\0*.JS\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFile = Buf;
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrTitle = "Load";
ofn.lpstrDefExt = "JS";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if( GetOpenFileName(&ofn) )
{
// escape all backslashes
char c;
int i1 = 0;
int i2 = 0;
while( 0 != (c = Buf2[i2++] = Buf[i1++]) )
{
if( c == '\\' )
Buf2[i2++] = '\\';
}
sprintf(Buf, "load(\"%s\");\n", Buf2);
EvalAndAddToHistory(Buf,&lineno);
}
}
return TRUE;
case IDD_SAVE:
if( BN_CLICKED == HIWORD(wParam) )
{
char Buf[_MAX_PATH+1];
char Buf2[_MAX_PATH+32];
OPENFILENAME ofn;
memset(&ofn,0,sizeof(ofn));
Buf[0] = 0;
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = "JavaScript Source (*.js)\0*.JS\0All Files (*.*)\0*.*\0\0";
ofn.lpstrFile = Buf;
ofn.nMaxFile = _MAX_PATH;
ofn.lpstrTitle = "Save As";
ofn.lpstrDefExt = "JS";
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
if( GetSaveFileName(&ofn) )
{
// escape all backslashes
char c;
int i1 = 0;
int i2 = 0;
while( 0 != (c = Buf2[i2++] = Buf[i1++]) )
{
if( c == '\\' )
Buf2[i2++] = '\\';
}
sprintf(Buf, "save(\"%s\");\n", Buf2);
EvalAndAddToHistory(Buf,&lineno);
}
}
return TRUE;
default:
break;
}
break;
}
return FALSE;
}

View File

@@ -0,0 +1,76 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
* user prompting code
*/
#include "headers.h"
typedef struct
{
char* prompt;
char* answer;
int maxAnswer;
} PROMPTDATA;
BOOL WINAPI
PromptDlgProc(HWND hDlg, UINT msg, UINT wParam, LONG lParam)
{
static PROMPTDATA* pd;
switch(msg)
{
case WM_INITDIALOG:
{
pd = (PROMPTDATA*) lParam;
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_PROMPT),
WM_SETTEXT, 0, (LPARAM) pd->prompt );
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_ANSWER),
EM_LIMITTEXT, pd->maxAnswer, 0 );
return TRUE;
}
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDOK:
case IDCANCEL:
SendMessage(GetDlgItem(hDlg, IDD_PROMPT_ANSWER),
WM_GETTEXT, pd->maxAnswer,
(LPARAM) pd->answer );
EndDialog(hDlg, 0);
return TRUE;
default:
break;
}
break;
}
return FALSE;
}
void Prompt( char* prompt, char* answer, int maxAnswer )
{
PROMPTDATA pd;
pd.prompt = prompt;
pd.answer = answer;
pd.maxAnswer = maxAnswer;
DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDDIALOG_PROMPT),
NULL, PromptDlgProc, (LPARAM) &pd);
}

View File

@@ -16,15 +16,22 @@
* Reserved.
*/
#ifndef nspr_aix_defs_h___
#define nspr_aix_defs_h___
/*
* Windows resource ids
*/
#define HAVE_LONG_LONG
#undef HAVE_ALIGNED_DOUBLES
#undef HAVE_ALIGNED_LONGLONGS
#undef HAVE_WEAK_IO_SYMBOLS
#undef HAVE_WEAK_MALLOC_SYMBOLS
#undef HAVE_DLL
#undef USE_DLFCN
#define IDDIALOG_MAIN 100
#define IDD_SURFACE 101
#define IDD_CONSOLE 102
#define IDD_HISTORY 103
#define IDD_SET_COLOR 104
#define IDD_SET_WIDTH 105
#define IDD_RECORD 106
#define IDD_SAVE 107
#define IDD_LOAD 108
#define IDD_CLEAR 109
#define IDD_EVAL 110
#endif /* nspr_aix_defs_h___ */
#define IDDIALOG_PROMPT 200
#define IDD_PROMPT_PROMPT 201
#define IDD_PROMPT_ANSWER 202

View File

@@ -0,0 +1,17 @@
function drawRect(x,y,dx,dy)
{
MoveTo(x,y);
LineTo(x+dx,y);
LineTo(x+dx,y+dy);
LineTo(x,y+dy);
LineTo(x,y);
}
function drawSquare(x,y,d)
{
MoveTo(x,y);
LineTo(x+d,y);
LineTo(x+d,y+d);
LineTo(x,y+d);
LineTo(x,y);
}

View File

@@ -1,27 +1,38 @@
# This file is required for the Mac client mozilla build.
# This is a list of local files which get copied to the mozilla:dist directory
#
js.msg
jsapi.h
jsarena.h
jspubtd.h
jsarray.h
jsatom.h
jsbool.h
jsclist.h
jscntxt.h
jscompat.h
jsconfig.h
jscpucfg.h
jsdate.h
jsdbgapi.h
jsdtoa.h
jsemit.h
jsfun.h
jsgc.h
jshash.h
jsinterp.h
jslock.h
jslong.h
jsmath.h
jsnum.h
jsobj.h
jsopcode.def
jsopcode.tbl
jsopcode.h
jsosdep.h
jsotypes.h
jsparse.h
jsprf.h
jsprvtd.h
jspubtd.h
jsregexp.h
@@ -29,3 +40,8 @@ jsscan.h
jsscope.h
jsscript.h
jsstr.h
jstypes.h
jsutil.h
jsxdrapi.h

View File

@@ -1,236 +0,0 @@
#! gmake
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
include $(DEPTH)/config/config.mk
ifdef MOZ_OJI
DIRS = liveconnect
endif
LIBRARY_NAME = js
ifeq ($(subst /,_,$(shell uname -s)),OS2)
ifndef XCFLAGS
OS2_IMPLIB=1
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
DEF_FILE = jsos2$(VERSION_NUMBER).def
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA)
else
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
endif
endif
MODULE = js
CSRCS = jsapi.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsemit.c \
jsfun.c \
jsgc.c \
jsinterp.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsregexp.c \
jsscan.c \
jsscope.c \
jsscript.c \
jsstr.c \
jslock.c \
jsxdrapi.c \
prmjtime.c \
$(NULL)
EXPORTS = jsapi.h \
jsarray.h \
jsatom.h \
jsbool.h \
jscntxt.h \
jscompat.h \
jsconfig.h \
jsdate.h \
jsdbgapi.h \
jsemit.h \
jsfun.h \
jsgc.h \
jsinterp.h \
jslock.h \
jsmath.h \
jsnum.h \
jsobj.h \
jsopcode.def \
jsopcode.h \
jsparse.h \
jsprvtd.h \
jspubtd.h \
jsregexp.h \
jsscan.h \
jsscope.h \
jsscript.h \
jsstr.h \
jsxdrapi.h \
$(NULL)
# when using gcc the assembly is inlined in the C-file (see jslock.c)
ifdef NS_USE_NATIVE
ASFILES = $(wildcard *_$(OS_ARCH).s)
endif
JS_SAFE_ARENA = 1
ifdef JS_SAFE_ARENA
DEFINES += -DJS_USE_SAFE_ARENA
CSRCS += prarena.c
endif
include $(DEPTH)/config/rules.mk
ifndef BUILD_OPT
MOCHAFILE = 1
endif
ifdef JSFILE
DEFINES += -DJSFILE
endif
ifdef JS_THREADSAFE
DEFINES += -DJS_THREADSAFE
endif
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif
ifdef JS_VERSION
DEFINES += -DJS_VERSION=$(JS_VERSION)
endif
ifeq ($(CPU_ARCH),sparc)
ifndef JS_NO_ULTRA
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
ULTRA_OPTIONSCC := -DULTRA_SPARC
else
ULTRA_OPTIONS := -xarch=v8
ULTRA_OPTIONSCC :=
endif
ifeq ($(shell uname -m),sun4u)
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
else
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
endif
endif # sparc
INCLUDES += -I.
ifdef NSPR20
INCLUDES += -I$(DIST)/include/nspr20/pr
else
INCLUDES += -I$(XPDIST)/public/nspr
endif
ifndef NSBUILDROOT
JSJAVA_STUBHEADERS = -I$(DEPTH)/sun-java/include/_gen \
-I$(DEPTH)/sun-java/netscape/javascript/_jri \
-I$(DEPTH)/sun-java/netscape/security/_jri
else
JSJAVA_STUBHEADERS = -I$(JRI_GEN_DIR) -I$(JDK_GEN_DIR)
endif
JSJAVA_CFLAGS = -I$(DEPTH)/sun-java/md-include \
-I$(DEPTH)/sun-java/include \
$(JSJAVA_STUBHEADERS)
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
# etc. nicely.
LDFLAGS = $(LIBNSPR) -lm
ifeq ($(OS_ARCH), OSF1)
LDFLAGS += -lc_r
endif
ifeq ($(OS_ARCH), SunOS)
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
endif
ifeq ($(OS_ARCH), Linux)
LDFLAGS += -ldl
endif
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
js:
$(MAKE) clobber
$(MAKE) XCFLAGS=-DJSFILE $(OBJDIR)/js$(BIN_SUFFIX)
.PHONY: js$(BIN_SUFFIX)
ifneq ($(OS_ARCH),OS2)
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
@$(MAKE_OBJDIR)
$(CC) -o $@ $(OBJDIR)/js.o $(LIBRARY) $(LDFLAGS)
else
OS_CFLAGS += -tm-
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
@$(MAKE_OBJDIR)
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
endif
# hardwire dependencies on jsopcode.def
jsopcode.h jsopcode.c: jsopcode.def
# this section was put in the merged by danda into the
# JAVA_*_MERGE section and normally would have
# been removed. However it looks like it shouldn't have
# been put there in the first place, so we're leaving it
# here until danda can confirm (we don't have OS/2 machines
# to build on) - hshaw/sudu
#
ifeq ($(OS_ARCH),OS2)
$(OBJDIR)/js.o: js.c
@$(MAKE_OBJDIR)
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
endif
refdiff:
@for f in `cat commfiles`; do \
t=/tmp/refdiff.$$$$; \
trap 'rm -f $$t' 0 1 2 15; \
sed -f prconv.sed ../ref/$$f > $$t; \
cmp -s $$t $$f; \
if test $$? -ne 0; then \
echo "=== $$f"; \
diff $$f $$t; \
fi; \
rm -f $$t; \
done
refconv:
@for f in `cat commfiles`; do \
echo "=== $$f"; \
sed -f prconv.sed ../ref/$$f > $$f; \
done
.PHONY: refdiff refconv

View File

@@ -1,4 +1,4 @@
#! gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
@@ -13,63 +13,87 @@
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
FDLIBM_LIBRARY = fdlibm/libfdm.a
JSMATH_PRELINK = jsmathtemp.o
JS_SAFE_ARENA = 1
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
ifdef MOZ_OJI
DIRS = liveconnect
endif
LIBRARY_NAME = js
ifeq ($(subst /,_,$(shell uname -s)),OS2)
ifndef XCFLAGS
OS2_IMPLIB=1
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
DEF_FILE = jsos2$(VERSION_NUMBER).def
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA)
else
EXTRA_LIBS = $(LIBNSPR) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
endif
endif
LIBRARY_NAME = $(MOZ_LIB_JS_PREFIX)js
MODULE = js
SIMPLE_PROGRAMS = jscpucfg
ifdef MOZ_OJI
DIRS = liveconnect
endif
DIRS += fdlibm xpconnect
GARBAGE += $(JSMATH_PRELINK) $(OBJDIR)/jscpucfg.o $(OBJDIR)/jsautocfg.h
ifeq ($(OS_ARCH),OS2)
ifndef XCFLAGS
OS2_IMPLIB = 1
LIBRARY = js$(MOZ_BITS)$(VERSION_NUMBER).$(LIB_SUFFIX)
DEF_FILE = jsos2$(VERSION_NUMBER).def
EXTRA_LIBS = $(NSPR_LIBS) $(LIBNSJAVA)
else
EXTRA_LIBS = $(NSPR_LIBS) $(LIBNSJAVA) $(OBJDIR)/libjs.lib
endif
OS_CFLAGS += -tm-
endif
CSRCS = jsapi.c \
jsarena.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsdtoa.c \
jsemit.c \
jsexn.c \
jsfun.c \
jsgc.c \
jshash.c \
jsinterp.c \
jslock.c \
jslog2.c \
jslong.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsprf.c \
jsregexp.c \
jsscan.c \
jsscope.c \
jsscript.c \
jsstr.c \
jslock.c \
jsutil.c \
jsxdrapi.c \
prmjtime.c \
$(NULL)
EXPORTS = jsapi.h \
EXPORTS = js.msg \
jsapi.h \
jsarray.h \
jsarena.h \
jsatom.h \
jsbit.h \
jsbool.h \
jsclist.h \
jscntxt.h \
jscompat.h \
jsconfig.h \
@@ -78,14 +102,19 @@ EXPORTS = jsapi.h \
jsemit.h \
jsfun.h \
jsgc.h \
jshash.h \
jsinterp.h \
jslock.h \
jslong.h \
jsmath.h \
jsnum.h \
jsobj.h \
jsopcode.def \
jsopcode.tbl \
jsopcode.h \
jsosdep.h \
jsotypes.h \
jsparse.h \
jsprf.h \
jsprvtd.h \
jspubtd.h \
jsregexp.h \
@@ -93,71 +122,68 @@ EXPORTS = jsapi.h \
jsscope.h \
jsscript.h \
jsstr.h \
jstypes.h \
jsutil.h \
jsxdrapi.h \
jsstddef.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
# when using gcc the assembly is inlined in the C-file (see jslock.c)
# When using gcc the assembly is inlined in the C-file (see jslock.c)
ifdef NS_USE_NATIVE
ASFILES = $(wildcard $(srcdir)/*_$(OS_ARCH).s)
ASFILES = $(notdir $(wildcard $(srcdir)/*_$(OS_ARCH).s))
endif
JS_SAFE_ARENA = 1
ifdef JS_SAFE_ARENA
DEFINES += -DJS_USE_SAFE_ARENA
CSRCS += prarena.c
endif
include $(topsrcdir)/config/rules.mk
ifndef BUILD_OPT
MOCHAFILE = 1
endif
ifdef JSFILE
DEFINES += -DJSFILE
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)
ifneq ($(findstring -L,$(NSPR_LIBS)),)
NSPR_STATIC_PATH = $(subst -L,,$(findstring -L,$(NSPR_LIBS)))
else
NSPR_STATIC_PATH = $(DIST)/lib
endif
LDFLAGS = $(pathsubst -l%,$(NSPR_STATIC_PATH)/%.a,$(NSPR_LIBS)) -lm
ifdef JS_SAFE_ARENA
DEFINES += -DJS_USE_SAFE_ARENA
endif
ifdef JS_THREADSAFE
DEFINES += -DJS_THREADSAFE
DEFINES += -DJS_THREADSAFE
endif
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif
ifdef JS_VERSION
DEFINES += -DJS_VERSION=$(JS_VERSION)
DEFINES += -DJS_VERSION=$(JS_VERSION)
endif
ifeq ($(CPU_ARCH),sparc)
ifndef JS_NO_ULTRA
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
ULTRA_OPTIONSCC := -DULTRA_SPARC
ULTRA_OPTIONS := -xarch=v8plus,-DULTRA_SPARC
ULTRA_OPTIONSCC := -DULTRA_SPARC
else
ULTRA_OPTIONS := -xarch=v8
ULTRA_OPTIONSCC :=
ULTRA_OPTIONS := -xarch=v8
ULTRA_OPTIONSCC :=
endif
ifeq ($(shell uname -m),sun4u)
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
ASFLAGS += -Wa,$(ULTRA_OPTIONS),-P,-L,-D_ASM,-D__STDC__=0 $(ULTRA_OPTIONSCC)
else
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
ASFLAGS += -Wa,-xarch=v8,-P,-L,-D_ASM,-D__STDC__=0
endif
endif # sparc
INCLUDES += -I$(srcdir)
ifdef NSPR20
INCLUDES += -I$(DIST)/include/nspr20/pr
else
INCLUDES += -I$(XPDIST)/public/nspr
endif
ifndef NSBUILDROOT
JSJAVA_STUBHEADERS = -I$(topsrcdir)/sun-java/include/_gen \
-I$(topsrcdir)/sun-java/netscape/javascript/_jri \
@@ -170,72 +196,68 @@ JSJAVA_CFLAGS = -I$(topsrcdir)/sun-java/md-include \
-I$(topsrcdir)/sun-java/include \
$(JSJAVA_STUBHEADERS)
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
# etc. nicely.
LDFLAGS = $(LIBNSPR) -lm
DASH_R = -r
ifeq ($(OS_ARCH), OSF1)
LDFLAGS += -lc_r
endif
ifeq ($(OS_ARCH), SunOS)
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
ifeq ($(OS_ARCH), IRIX)
LDFLAGS += -n32
endif
ifeq ($(OS_ARCH), Linux)
LDFLAGS += -ldl
LDFLAGS += -ldl
endif
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
js:
$(MAKE) clobber
$(MAKE) XCFLAGS=-DJSFILE $(OBJDIR)/js$(BIN_SUFFIX)
.PHONY: js$(BIN_SUFFIX)
ifneq ($(OS_ARCH),OS2)
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
@$(MAKE_OBJDIR)
$(CC) -o $@ $(OBJDIR)/js.o $(LIBRARY) $(LDFLAGS)
ifeq ($(OS_ARCH), FreeBSD)
LDFLAGS += -pthread
endif
ifeq ($(OS_ARCH), OSF1)
LDFLAGS += -lc_r
endif
ifeq ($(OS_ARCH), QNX)
DASH_R =
endif
ifeq ($(OS_ARCH), SunOS)
ifeq ($(OS_RELEASE),4.1)
LDFLAGS += -ldl -lnsl
else
OS_CFLAGS += -tm-
$(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
@$(MAKE_OBJDIR)
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
LDFLAGS += -lposix4 -ldl -lnsl -lsocket
endif
endif
# hardwire dependencies on jsopcode.def
jsopcode.h jsopcode.c: jsopcode.def
# this section was put in the merged by danda into the
# JAVA_*_MERGE section and normally would have
# been removed. However it looks like it shouldn't have
# been put there in the first place, so we're leaving it
# here until danda can confirm (we don't have OS/2 machines
# to build on) - hshaw/sudu
#
ifeq ($(OS_ARCH),OS2)
$(OBJDIR)/js.o: js.c
# special rule for jsmath.o since we want to incrementally link
# against fdlibm to pull in only what is needed
jsmath.o: $(FDLIBM_LIBRARY) $(JSMATH_PRELINK)
@$(MAKE_OBJDIR)
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
$(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
$(JSMATH_PRELINK): jsmath.c
@$(MAKE_OBJDIR)
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
$(CC) -Fo$@ -c $(CFLAGS) $<
else
$(CC) -o $@ -c $(CFLAGS) $<
endif
# An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result.
# This suppresses optimization for this single compilation unit.
ifeq ($(OS_ARCH), AIX)
$(OBJDIR)/jsdtoa.o: jsdtoa.c
@$(MAKE_OBJDIR)
$(CC) -o $@ -c $(filter-out -O, $(CFLAGS)) $<
endif
refdiff:
@for f in `cat commfiles`; do \
t=/tmp/refdiff.$$$$; \
trap 'rm -f $$t' 0 1 2 15; \
sed -f prconv.sed ../ref/$$f > $$t; \
cmp -s $$t $$f; \
if test $$? -ne 0; then \
echo "=== $$f"; \
diff $$f $$t; \
fi; \
rm -f $$t; \
done
# ripped from $(topsrcdir)/config/rules.mk
$(FDLIBM_LIBRARY):
set -e; \
set $(EXIT_ON_ERROR); \
echo "cd $(@D); $(MAKE) $(@F)"; \
oldDir=`pwd`; \
cd $(@D); $(MAKE) $(@F); cd $$oldDir; \
set +e;
refconv:
@for f in `cat commfiles`; do \
echo "=== $$f"; \
sed -f prconv.sed ../ref/$$f > $$f; \
done
jsopcode.h jsopcode.c: jsopcode.tbl
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
rm -f $@
$(OBJDIR)/jscpucfg > $@
export:: $(OBJDIR)/jsautocfg.h
$(INSTALL) -m 444 $< $(DIST)/include
.PHONY: refdiff refconv

View File

@@ -18,86 +18,47 @@
# JSRef GNUmake makefile.
#
# Set os+release dependent make variables
OS_ARCH := $(subst /,_,$(shell uname -s))
DEPTH = .
# Attempt to differentiate between SunOS 5.4 and x86 5.4
OS_CPUARCH := $(shell uname -m)
ifeq ($(OS_CPUARCH),i86pc)
OS_RELEASE := $(shell uname -r)_$(OS_CPUARCH)
else
ifeq ($(OS_ARCH),AIX)
OS_RELEASE := $(shell uname -v).$(shell uname -r)
else
OS_RELEASE := $(shell uname -r)
endif
endif
# Virtually all Linux versions are identical.
# Any distinctions are handled in linux.h
ifeq ($(OS_ARCH),Linux)
OS_CONFIG := Linux_All
else
ifeq ($(OS_ARCH),dgux)
OS_CONFIG := dgux
else
OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
endif
endif
ASFLAGS =
DEFINES =
include config.mk
#NS_USE_NATIVE = 1
include config/$(OS_CONFIG).mk
ifdef BUILD_OPT
OPTIMIZER += -O
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
OBJDIR_TAG = _OPT
else
ifdef USE_MSVC
OPTIMIZER = -Zi
OTHER_LIBS += fdlibm/$(OBJDIR)/fdlibm.lib
else
OPTIMIZER = -g
endif
DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
OBJDIR_TAG = _DBG
OTHER_LIBS += -Lfdlibm/$(OBJDIR) -lfdm
endif
#DEFINES += -DJS_THREADSAFE
ifdef JS_THREADSAFE
DEFINES += -DJS_THREADSAFE
INCLUDES += -I../../dist/$(OBJDIR)/include
ifdef USE_MSVC
OTHER_LIBS += ../../dist/$(OBJDIR)/lib/libnspr3.lib
else
OTHER_LIBS += -L../../dist/$(OBJDIR)/lib -lnspr3
endif
endif
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif
# Name of the binary code directories
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
VPATH = $(OBJDIR)
# Automatic make dependencies file
DEPENDENCIES = $(OBJDIR)/.md
define MAKE_OBJDIR
if test ! -d $(@D); then rm -rf $(@D); mkdir $(@D); fi
endef
# Look in OBJDIR to find prcpucfg.h
INCLUDES = -I$(OBJDIR)
ifdef JS_HAS_FILE_OBJECT
DEFINES += -DJS_HAS_FILE_OBJECT
endif
#
# XCFLAGS may be set in the environment or on the gmake command line
#
CFLAGS = $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
-DJSFILE $(XCFLAGS)
CFLAGS += $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) $(XCFLAGS)
LDFLAGS = -lm $(XLDFLAGS)
#
# Ask perl what flags it was built with, so we can build js with similar flags
# and link properly. Viva gmake.
#
ifdef PERLCONNECT
ifdef JS_PERLCONNECT
DEFINES += -DPERLCONNECT
PERLCFLAGS := $(shell perl -MExtUtils::Embed -e ccopts)
@@ -107,6 +68,20 @@ CFLAGS += $(PERLCFLAGS)
LDFLAGS += $(PERLLDFLAGS)
endif
#
# Line editing support.
#
ifdef JS_READLINE
DEFINES += -DEDITLINE
PROG_LIBS += -lreadline
else
ifdef JS_EDITLINE
PREDIRS += editline
DEFINES += -DEDITLINE
PROG_LIBS += -Leditline/$(OBJDIR) -ledit
endif
endif
# For purify
PURE_CFLAGS = -DXP_UNIX $(OPTIMIZER) $(PURE_OS_CFLAGS) $(DEFINES) \
$(INCLUDES) $(XCFLAGS)
@@ -126,6 +101,7 @@ JS_HFILES = \
jsfun.h \
jsgc.h \
jsinterp.h \
jslibmath.h \
jslock.h \
jsmath.h \
jsnum.h \
@@ -137,11 +113,7 @@ JS_HFILES = \
jsdtoa.h \
jshash.h \
jslong.h \
jsmacos.h \
jsosdep.h \
jspcos.h \
jsprintf.h \
jstime.h \
jstypes.h \
jsprvtd.h \
jspubtd.h \
@@ -158,32 +130,50 @@ API_HFILES = \
jsdbgapi.h \
$(NULL)
HFILES = $(JS_HFILES) $(API_HFILES)
OTHER_HFILES = \
jsaddr.h \
jsbit.h \
jscompat.h \
jscpucfg.h \
jsotypes.h \
jsstddef.h \
prmjtime.h \
resource.h \
jsopcode.tbl \
js.msg \
jsshell.msg \
$(NULL)
ifndef PREBUILT_CPUCFG
OTHER_HFILES += $(OBJDIR)/jsautocfg.h
endif
HFILES = $(JS_HFILES) $(API_HFILES) $(OTHER_HFILES)
JS_CFILES = \
jsapi.c \
jsarena.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsdtoa.c \
jsemit.c \
jsexn.c \
jsfun.c \
jsgc.c \
jshash.c \
jsinterp.c \
jslock.c \
jslog2.c \
jslong.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsarena.c \
jsdtoa.c \
jshash.c \
jslog2.c \
jslong.c \
jsprf.c \
jsregexp.c \
jsscan.c \
@@ -195,106 +185,76 @@ JS_CFILES = \
prmjtime.c \
$(NULL)
ifdef PERLCONNECT
PREDIRS += fdlibm
ifdef JS_LIVECONNECT
DIRS += liveconnect
endif
ifdef JS_PERLCONNECT
JS_CFILES += jsperl.c
endif
ifdef JS_HAS_FILE_OBJECT
JS_CFILES += jsfile.c
JS_HFILES += jsfile.h
endif
LIB_CFILES = $(JS_CFILES)
LIB_ASFILES := $(wildcard *_$(OS_ARCH).s)
PROG_CFILES = js.c
ifdef USE_MSVC
LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.obj))
PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.obj))
else
LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.o))
LIB_OBJS += $(addprefix $(OBJDIR)/, $(LIB_ASFILES:.s=.o))
PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.o))
endif
CFILES = $(LIB_CFILES) $(PROG_CFILES)
OBJS = $(LIB_OBJS) $(PROG_OBJS)
ifdef USE_MSVC
LIBRARY = $(OBJDIR)/js32.dll
PROGRAM = $(OBJDIR)/js
LIBRARY = $(OBJDIR)/js32.lib
SHARED_LIBRARY = $(OBJDIR)/js32.dll
PROGRAM = $(OBJDIR)/js.exe
else
LIBRARY = $(OBJDIR)/libjs.a
SHARED_LIBRARY = $(OBJDIR)/libjs.$(SO_SUFFIX)
PROGRAM = $(OBJDIR)/js
endif
ifdef USE_MSVC
TARGETS = $(LIBRARY) # $(PROGRAM) not supported for MSVC yet
FDLIBM_LIBRARY = fdlibm.lib
else
TARGETS = $(LIBRARY) $(PROGRAM)
FDLIBM_LIBRARY = libfdm.a
endif
all: $(TARGETS)
include rules.mk
clean:
rm -rf $(OBJS)
MOZ_DEPTH = ../..
include jsconfig.mk
clobber:
rm -rf $(OBJS) $(TARGETS) $(DEPENDENCIES)
depend:
gcc -MM $(CFLAGS) $(JS_CFILES)
$(OBJDIR)/%: %.c
@$(MAKE_OBJDIR)
$(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
$(OBJDIR)/%.o: %.c
@$(MAKE_OBJDIR)
$(CC) -o $@ -c $(CFLAGS) $*.c
$(OBJDIR)/%.o: %.s
@$(MAKE_OBJDIR)
$(AS) -o $@ $(ASFLAGS) $*.s
# windows only
$(OBJDIR)/%.obj: %.c
@$(MAKE_OBJDIR)
$(CC) -Fo$(OBJDIR)/ -c $(CFLAGS) $*.c
ifeq ($(OS_ARCH),OS2)
$(LIBRARY): $(LIB_OBJS)
$(AR) $@ $? $(AR_OS2_SUFFIX)
$(RANLIB) $@
else
nsinstall-target:
cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR)
ifdef USE_MSVC
$(LIBRARY): $(LIB_OBJS)
link.exe $(LIB_LINK_FLAGS) /base:0x61000000 \
/out:"$@" /pdb:"$(OBJDIR)/js32.pdb" /implib:"$(OBJDIR)/js32.lib" $?
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY)
link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
else
$(LIBRARY): $(LIB_OBJS)
$(AR) rv $@ $?
$(RANLIB) $@
$(PROGRAM): $(PROG_OBJS) $(LIBRARY) fdlibm/$(OBJDIR)/$(FDLIBM_LIBRARY)
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \
$(PROG_LIBS)
endif
endif
#NSPR_LIBRARY = ../../dist/$(OBJDIR)/lib/libnspr21.so
NSPR_LIBRARY =
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(NSPR_LIBRARY) $(LDFLAGS)
$(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY)
purify $(PUREFLAGS) \
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS)
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) \
$(OTHER_LIBS) $(PROG_LIBS)
$(HFILES) $(CFILES): $(OBJDIR)/jscpucfg.h
ifndef PREBUILT_CPUCFG
all export libs $(HFILES) $(CFILES): $(OBJDIR)/jsautocfg.h
ifdef PREBUILT_CPUCFG
$(OBJDIR)/jscpucfg.h: jscpucfg.h
cp jscpucfg.h $(OBJDIR)
else
$(OBJDIR)/jscpucfg.h: $(OBJDIR)/jscpucfg
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
rm -f $@
$(OBJDIR)/jscpucfg > $@
$(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
$(CC) -o $@ $(OBJDIR)/jscpucfg.o
# Look in OBJDIR to find jsautocfg.h
INCLUDES += -I$(OBJDIR)
# Add to TARGETS for clobber rule
TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.o
endif
#
@@ -307,10 +267,6 @@ jsopcode.h jsopcode.c: jsopcode.tbl
TARNAME = jsref.tar
TARFILES = files `cat files`
tar:
tar cvf $(TARNAME) $(TARFILES)
gzip $(TARNAME)
SUFFIXES: .i
%.i: %.c
$(CC) -C -E $(CFLAGS) $< > $*.i

View File

@@ -1,17 +0,0 @@
The js/ref directory contains standalone ANSI-C source for the Netscape
JavaScript Reference implementation, JSRef, which was licensed to over 180
companies as part of Netscape ONE, starting in fall 1996. Now, JSRef is
available under NPL from http://www.mozilla.org.
The js/src directory contains source files listed in the file "commfiles",
that are derived via prconv.sed from counterparts in the js/ref directory.
It also contains files such as jscompat.h that are not needed in js/ref.
The Makefile in js/src has refconv and refdiff targets to help keep js/ref
and js/src in synch.
If you think you need to change a file listed in commfiles here, please
make the change in js/ref first and then use prconv.sed or gmake refconv to
get it into js/src. If you have trouble, please let us know by mailing the
JS owner and peers listed in http://www.mozilla.org/owners.html#JavaScript.
Brendan Eich (brendan@mozilla.org), 15-May-98

755
mozilla/js/src/README.html Normal file
View File

@@ -0,0 +1,755 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.5 [en] (WinNT; I) [Netscape]">
<title>JavaScript Reference Implementation (JSRef) README</title>
</head>
<body>
<h2>
Table of Contents</h2>
<ul>
<li>
<a href="#Introduction">Introduction</a></li>
<li>
<a href="#Build">Build conventions (standalone JS engine and shell)</a></li>
<li>
<a href="#Debugging">Debugging notes</a></li>
<li>
<a href="#Conventions">Naming and coding conventions</a></li>
<li>
<a href="#JSAPI">Using the JS API</a></li>
<li>
<a href="#Design">Design walk-through</a></li>
</ul>
<h2>
<a NAME="Introduction"></a>Introduction</h2>
This is the README file for the&nbsp;<span CLASS=LXRSHORTDESC>JavaScript
Reference (JSRef) implementation.</span> It consists of build conventions
and instructions, source code conventions, a design walk-through, and a
brief file-by-file description of the source.
<p><span CLASS=LXRLONGDESC>JSRef builds a library or DLL containing the
JavaScript runtime (compiler, interpreter, decompiler, garbage collector,
atom manager, standard classes). It then compiles a small "shell" program
and links that with the library to make an interpreter that can be used
interactively and with test .js files to run scripts.&nbsp; The code has
no dependencies on the Navigator code.</span>
<p><i>Quick start tip</i>: skip to "Using the JS API" below, build the
js shell, and play with the object named "it" (start by setting 'it.noisy
= true').
<h2>
<a NAME="Build"></a>Build conventions (standalone JS engine and shell)</h2>
These build directions refer only to building the standalone JavaScript
engine and shell.&nbsp; To build within the browser, refer to the <a href="http://www.mozilla.org/docs/">build
directions</a> on the mozilla.org website.
<p>By default, all platforms build a version of the JS engine that is <i>not</i>
threadsafe.&nbsp; If you require thread-safety, you must also populate
the <tt>mozilla/dist</tt> directory with <a href="http://www.mozilla.org/docs/tplist/catCode/nsprdesc.htm">NSPR</a>
headers and libraries.&nbsp; (NSPR implements a portable threading library,
among other things.&nbsp; The source is downloadable via <a href="http://www.mozilla.org/cvs.html">CVS</a>
from <tt><a href="http://cvs-mirror.mozilla.org/webtools/lxr/source/nsprpub">mozilla/nsprpub</a></tt>.)&nbsp;
Next, you must define <tt>JS_THREADSAFE</tt> when building the JS engine,
either on the command-line (gmake/nmake) or in a universal header file.
<h3>
Windows</h3>
<ul>
<li>
Use MSVC 4.2 or 5.0.</li>
<li>
For building from the IDE use <tt>js/src/js.mdp</tt>.&nbsp; (<tt>js.mdp</tt>
is an MSVC4.2 project file, but if you load it into MSVC5, it will be converted
to the newer project file format.)&nbsp; <font color="#CC0000">NOTE: makefile.win
is an nmake file used only for building the JS-engine in the Mozilla browser.&nbsp;
Don't attempt to use it to build the standalone JS-engine.</font></li>
<li>
If you prefer to build from the command-line, use '<tt>nmake -f js.mak</tt>'</li>
<li>
Executable shell <tt>js.exe</tt> and runtime library <tt>js32.dll</tt>
are created in either <tt>js/src/Debug</tt> or <tt>js/src/Release</tt>.</li>
</ul>
<h3>
Macintosh</h3>
<ul>
<li>
Use CodeWarrior 3.x</li>
<li>
Load the project file <tt>js:src:macbuild:JSRef.mcp </tt>and select "Make"
from the menu.</li>
</ul>
<h3>
Unix</h3>
<ul>
<li>
Use '<tt>gmake -f Makefile.ref</tt>' to build. To compile optimized code,
pass <tt>BUILD_OPT=1</tt> on the gmake command line or preset it in the
environment or <tt>Makefile.ref</tt>.&nbsp; <font color="#CC0000">NOTE:
Do not attempt to use Makefile to build the standalone JavaScript engine.&nbsp;
This file is used only for building the JS-engine in the Mozilla browser.</font></li>
<li>
<font color="#000000">Each platform on which JS is built must have a <tt>*.mk</tt>
configuration file in the <tt>js/src/config</tt> directory.&nbsp; The configuration
file specifies the compiler/linker to be used and allows for customization
of command-line options.&nbsp; To date, the build system has been tested
on Solaris, AIX, HP/UX, OSF, IRIX, x86 Linux and Windows NT.</font></li>
<li>
<font color="#000000">Most platforms will work with either the vendor compiler
</font>or
<a href="ftp://prep.ai.mit.edu/pub/gnu">gcc</a>.&nbsp;
(Except that HP builds only work using the native compiler.&nbsp; gcc won't
link correctly with shared libraries on that platform.&nbsp; If someone
knows a way to fix this, <a href="mailto:wynholds@netscape.com">let us
know</a>.)</li>
<li>
<font color="#000000">If you define <tt>JS_LIVECONNECT</tt>, gmake will
descend into the liveconnect directory and build <a href="http://cvs-mirror.mozilla.org/webtools/lxr/source/js/src/liveconnect/README.html">LiveConnect</a>
after building the JS engine.</font></li>
<li>
To build a binary drop (a zip'ed up file of headers, libraries, binaries),
check out <tt>mozilla/config</tt> and <tt>mozilla/nsprpub/config</tt>.&nbsp;
Use '<tt>gmake -f Makefile.ref nsinstall-target all export ship</tt>'</li>
</ul>
<h2>
<a NAME="Debugging"></a>Debugging notes</h2>
<ul>
<li>
To turn on GC instrumentation, define <tt>JS_GCMETER</tt>.</li>
<li>
To turn on the arena package's instrumentation, define <tt>JS_ARENAMETER</tt>.</li>
<li>
To turn on the hash table package's metering, define <tt>JS_HASHMETER</tt>.</li>
</ul>
<h2>
<a NAME="Conventions"></a>Naming and coding conventions</h2>
<ul>
<li>
Public function names begin with <tt>JS_</tt> followed by capitalized "intercaps",
e.g. <tt>JS_NewObject</tt>.</li>
<li>
Extern but library-private function names use a <tt>js_</tt> prefix and
mixed case, e.g. <tt>js_LookupSymbol</tt>.</li>
<li>
Most static function names have unprefixed, mixed-case names: <tt>GetChar</tt>.</li>
<li>
But static native methods of JS objects have lowercase, underscore-separated
or intercaps names, e.g., <tt>str_indexOf</tt>.</li>
<li>
And library-private and static data use underscores, not intercaps (but
library-private data do use a <tt>js_</tt> prefix).</li>
<li>
Scalar type names are lowercase and js-prefixed: <tt>jsdouble</tt>.</li>
<li>
Aggregate type names are JS-prefixed and mixed-case: <tt>JSObject.</tt></li>
<li>
Macros are generally <tt>ALL_CAPS </tt>and underscored, to call out potential
side effects, multiple uses of a formal argument, etc. - Four spaces of
indentation per statement nesting level.</li>
<li>
Tabs are taken to be eight spaces, and an Emacs magic comment at the top
of each file tries to help. If you're using MSVC or similar, you'll want
to set tab width to 8, or convert these files to be space-filled.</li>
<li>
DLL entry points have their return type expanded within a <tt>JS_PUBLIC_API()</tt>
macro call, to get the right Windows secret type qualifiers in the right
places for both 16- and 32-bit builds.</li>
<li>
Callback functions that might be called from a DLL are similarly macroized
with <tt>JS_STATIC_DLL_CALLBACK</tt> (if the function otherwise would be
static to hide its name) or <tt>JS_DLL_CALLBACK</tt> (this macro takes
no type argument; it should be used after the return type and before the
function name).</li>
</ul>
<h2>
<a NAME="JSAPI"></a>Using the JS API</h2>
<h4>
Starting up</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Tune this to avoid wasting space for shallow stacks, while saving on
&nbsp;&nbsp;&nbsp;&nbsp; * malloc overhead/fragmentation for deep or highly-variable stacks.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; #define STACK_CHUNK_SIZE&nbsp;&nbsp;&nbsp; 8192
&nbsp;&nbsp;&nbsp; JSRuntime *rt;
&nbsp;&nbsp;&nbsp; JSContext *cx;
&nbsp;&nbsp;&nbsp; /* You need a runtime and one or more contexts to do anything with JS. */
&nbsp;&nbsp;&nbsp; rt = JS_Init(1000000L);
&nbsp;&nbsp;&nbsp; if (!rt)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fail("can't create JavaScript runtime");
&nbsp;&nbsp;&nbsp; cx = JS_NewContext(rt, STACK_CHUNK_SIZE);
&nbsp;&nbsp;&nbsp; if (!cx)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fail("can't create JavaScript context");
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * The context definitely wants a global object, in order to have standard
&nbsp;&nbsp;&nbsp;&nbsp; * classes and functions like Date and parseInt.&nbsp; See below for details on
&nbsp;&nbsp;&nbsp;&nbsp; * JS_NewObject.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; JSObject *globalObj;
&nbsp;&nbsp;&nbsp; globalObj = JS_NewObject(cx, &amp;my_global_class, 0, 0);
&nbsp;&nbsp;&nbsp; JS_InitStandardClasses(cx, globalObj);</tt></pre>
<h4>
Defining objects and properties</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /* Statically initialize a class to make "one-off" objects. */
&nbsp;&nbsp;&nbsp; JSClass my_class = {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "MyClass",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* All of these can be replaced with the corresponding JS_*Stub
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function pointers. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_addProperty, my_delProperty, my_getProperty, my_setProperty,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_enumerate,&nbsp;&nbsp; my_resolve,&nbsp;&nbsp;&nbsp;&nbsp; my_convert,&nbsp;&nbsp;&nbsp;&nbsp; my_finalize
&nbsp;&nbsp;&nbsp; };
&nbsp;&nbsp;&nbsp; JSObject *obj;
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Define an object named in the global scope that can be enumerated by
&nbsp;&nbsp;&nbsp;&nbsp; * for/in loops.&nbsp; The parent object is passed as the second argument, as
&nbsp;&nbsp;&nbsp;&nbsp; * with all other API calls that take an object/name pair.&nbsp; The prototype
&nbsp;&nbsp;&nbsp;&nbsp; * passed in is null, so the default object prototype will be used.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; obj = JS_DefineObject(cx, globalObj, "myObject", &amp;my_class, 0,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE);
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Define a bunch of properties with a JSPropertySpec array statically
&nbsp;&nbsp;&nbsp;&nbsp; * initialized and terminated with a null-name entry.&nbsp; Besides its name,
&nbsp;&nbsp;&nbsp;&nbsp; * each property has a "tiny" identifier (MY_COLOR, e.g.) that can be used
&nbsp;&nbsp;&nbsp;&nbsp; * in switch statements (in a common my_getProperty function, for example).
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; enum my_tinyid {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_COLOR, MY_HEIGHT, MY_WIDTH, MY_FUNNY, MY_ARRAY, MY_RDONLY
&nbsp;&nbsp;&nbsp; };
&nbsp;&nbsp;&nbsp; static JSPropertySpec my_props[] = {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"color",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_COLOR,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"height",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_HEIGHT,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"width",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_WIDTH,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"funny",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_FUNNY,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"array",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_ARRAY,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_ENUMERATE},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"rdonly",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MY_RDONLY,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JSPROP_READONLY},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {0}
&nbsp;&nbsp;&nbsp; };
&nbsp;&nbsp;&nbsp; JS_DefineProperties(cx, obj, my_props);
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Given the above definitions and call to JS_DefineProperties, obj will
&nbsp;&nbsp;&nbsp;&nbsp; * need this sort of "getter" method in its class (my_class, above).&nbsp; See
&nbsp;&nbsp;&nbsp;&nbsp; * the example for the "It" class in js.c.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; static JSBool
&nbsp;&nbsp;&nbsp; my_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (JSVAL_IS_INT(id)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (JSVAL_TO_INT(id)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_COLOR:&nbsp; *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_HEIGHT: *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_WIDTH:&nbsp; *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_FUNNY:&nbsp; *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_ARRAY:&nbsp; *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case MY_RDONLY: *vp = . . .; break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return JS_TRUE;
&nbsp;&nbsp;&nbsp; }</tt></pre>
<h4>
Defining functions</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /* Define a bunch of native functions first: */
&nbsp;&nbsp;&nbsp; static JSBool
&nbsp;&nbsp;&nbsp; my_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jsdouble x, z;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!JS_ValueToNumber(cx, argv[0], &amp;x))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return JS_FALSE;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z = (x &lt; 0) ? -x : x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return JS_NewDoubleValue(cx, z, rval);
&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; . . .
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Use a JSFunctionSpec array terminated with a null name to define a
&nbsp;&nbsp;&nbsp;&nbsp; * bunch of native functions.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; static JSFunctionSpec my_functions[] = {
&nbsp;&nbsp;&nbsp; /*&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; native&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nargs&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"abs",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_abs,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"acos",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_acos,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {"asin",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_asin,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1},
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . . .
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {0}
&nbsp;&nbsp;&nbsp; };
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Pass a particular object to define methods for it alone.&nbsp; If you pass
&nbsp;&nbsp;&nbsp;&nbsp; * a prototype object, the methods will apply to all instances past and
&nbsp;&nbsp;&nbsp;&nbsp; * future of the prototype's class (see below for classes).
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; JS_DefineFunctions(cx, globalObj, my_functions);</tt></pre>
<h4>
Defining classes</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * This pulls together the above API elements by defining a constructor
&nbsp;&nbsp;&nbsp;&nbsp; * function, a prototype object, and properties of the prototype and of
&nbsp;&nbsp;&nbsp;&nbsp; * the constructor, all with one API call.
&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp; * Initialize a class by defining its constructor function, prototype, and
&nbsp;&nbsp;&nbsp;&nbsp; * per-instance and per-class properties.&nbsp; The latter are called "static"
&nbsp;&nbsp;&nbsp;&nbsp; * below by analogy to Java.&nbsp; They are defined in the constructor object's
&nbsp;&nbsp;&nbsp;&nbsp; * scope, so that 'MyClass.myStaticProp' works along with 'new MyClass()'.
&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp; * JS_InitClass takes a lot of arguments, but you can pass null for any of
&nbsp;&nbsp;&nbsp;&nbsp; * the last four if there are no such properties or methods.
&nbsp;&nbsp;&nbsp;&nbsp; *
&nbsp;&nbsp;&nbsp;&nbsp; * Note that you do not need to call JS_InitClass to make a new instance of
&nbsp;&nbsp;&nbsp;&nbsp; * that class -- otherwise there would be a chicken-and-egg problem making
&nbsp;&nbsp;&nbsp;&nbsp; * the global object -- but you should call JS_InitClass if you require a
&nbsp;&nbsp;&nbsp;&nbsp; * constructor function for script authors to call via new, and/or a class
&nbsp;&nbsp;&nbsp;&nbsp; * prototype object ('MyClass.prototype') for authors to extend with new
&nbsp;&nbsp;&nbsp;&nbsp; * properties at run-time.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; protoObj = JS_InitClass(cx, globalObj, &amp;my_class,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* native constructor function and min arg count */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyClass, 0,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* prototype object properties and methods -- these
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; will be "inherited" by all instances through
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delegation up the instance's prototype link. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_props, my_methods,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* class constructor properties and methods */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my_static_props, my_static_methods);</tt></pre>
<h4>
Running scripts</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /* These should indicate source location for diagnostics. */
&nbsp;&nbsp;&nbsp; char *filename;
&nbsp;&nbsp;&nbsp; uintN lineno;
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * The return value comes back here -- if it could be a GC thing, you must
&nbsp;&nbsp;&nbsp;&nbsp; * add it to the GC's "root set" with JS_AddRoot(cx, &amp;thing) where thing
&nbsp;&nbsp;&nbsp;&nbsp; * is a JSString *, JSObject *, or jsdouble *, and remove the root before
&nbsp;&nbsp;&nbsp;&nbsp; * rval goes out of scope, or when rval is no longer needed.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; jsval rval;
&nbsp;&nbsp;&nbsp; JSBool ok;
&nbsp;&nbsp;&nbsp; /*
&nbsp;&nbsp;&nbsp;&nbsp; * Some example source in a C string.&nbsp; Larger, non-null-terminated buffers
&nbsp;&nbsp;&nbsp;&nbsp; * can be used, if you pass the buffer length to JS_EvaluateScript.
&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp;&nbsp; char *source = "x * f(y)";
&nbsp;&nbsp;&nbsp; ok = JS_EvaluateScript(cx, globalObj, source, strlen(source),
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filename, lineno, &amp;rval);
&nbsp;&nbsp;&nbsp; if (ok) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Should get a number back from the example source. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jsdouble d;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ok = JS_ValueToNumber(cx, rval, &amp;d);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . . .
&nbsp;&nbsp;&nbsp; }</tt></pre>
<h4>
Calling functions</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /* Call a global function named "foo" that takes no arguments. */
&nbsp;&nbsp;&nbsp; ok = JS_CallFunctionName(cx, globalObj, "foo", 0, 0, &amp;rval);
&nbsp;&nbsp;&nbsp; jsval argv[2];
&nbsp;&nbsp;&nbsp; /* Call a function in obj's scope named "method", passing two arguments. */
&nbsp;&nbsp;&nbsp; argv[0] = . . .;
&nbsp;&nbsp;&nbsp; argv[1] = . . .;
&nbsp;&nbsp;&nbsp; ok = JS_CallFunctionName(cx, obj, "method", 2, argv, &amp;rval);</tt></pre>
<h4>
Shutting down</h4>
<pre><tt>&nbsp;&nbsp;&nbsp; /* For each context you've created: */
&nbsp;&nbsp;&nbsp; JS_DestroyContext(cx);
&nbsp;&nbsp;&nbsp; /* And finally: */
&nbsp;&nbsp;&nbsp; JS_Finish(rt);</tt></pre>
<h4>
Debugging API</h4>
See the<tt> trap, untrap, watch, unwatch, line2pc</tt>, and <tt>pc2line</tt>
commands in <tt>js.c</tt>. Also the (scant) comments in <i>jsdbgapi.h</i>.
<h2>
<a NAME="Design"></a>Design walk-through</h2>
This section must be brief for now -- it could easily turn into a book.
<h4>
JS "JavaScript Proper"</h4>
JS modules declare and implement the JavaScript compiler, interpreter,
decompiler, GC and atom manager, and standard classes.
<p>JavaScript uses untyped bytecode and runtime type tagging of data values.
The <tt>jsval</tt> type is a signed machine word that contains either a
signed integer value (if the low bit is set), or a type-tagged pointer
or boolean value (if the low bit is clear). Tagged pointers all refer to
8-byte-aligned things in the GC heap.
<p>Objects consist of a possibly shared structural description, called
the map or scope; and unshared property values in a vector, called the
slots. Object properties are associated with nonnegative integers stored
in <tt>jsval</tt>'s, or with atoms (unique string descriptors) if named
by an identifier or a non-integral index expression.
<p>Scripts contain bytecode, source annotations, and a pool of string,
number, and identifier literals. Functions are objects that extend scripts
or native functions with formal parameters, a literal syntax, and a distinct
primitive type ("function").
<p>The compiler consists of a recursive-descent parser and a random-logic
rather than table-driven lexical scanner. Semantic and lexical feedback
are used to disambiguate hard cases such as missing semicolons, assignable
expressions ("lvalues" in C parlance), etc. The parser generates bytecode
as it parses, using fixup lists for downward branches and code buffering
and rewriting for exceptional cases such as for loops. It attempts no error
recovery. The interpreter executes the bytecode of top-level scripts, and
calls itself indirectly to interpret function bodies (which are also scripts).
All state associated with an interpreter instance is passed through formal
parameters to the interpreter entry point; most implicit state is collected
in a type named JSContext. Therefore, all API and almost all other functions
in JSRef take a JSContext pointer as their first argument.
<p>The decompiler translates postfix bytecode into infix source by consulting
a separate byte-sized code, called source notes, to disambiguate bytecodes
that result from more than one grammatical production.
<p>The GC is a mark-and-sweep, non-conservative (perfect) collector. It
can allocate only fixed-sized things -- the current size is two machine
words. It is used to hold JS object and string descriptors (but not property
lists or string bytes), and double-precision floating point numbers. It
runs automatically only when maxbytes (as passed to <tt>JS_Init()</tt>)
bytes of GC things have been allocated and another thing-allocation request
is made. JS API users should call <tt>JS_GC()</tt> or <tt>JS_MaybeGC()</tt>
between script executions or from the branch callback, as often as necessary.
<p>An important point about the GC's "perfection": you must add roots for
new objects created by your native methods if you store references to them
into a non-JS structure in the malloc heap or in static data. Also, if
you make a new object in a native method, but do not store it through the
<tt>rval</tt>
result parameter (see math_abs in the "Using the JS API" section above)
so that it is in a known root, the object is guaranteed to survive only
until another new object is created. Either lock the first new object when
making two in a row, or store it in a root you've added, or store it via
rval.
<p>The atom manager consists of a hash table associating strings uniquely
with scanner/parser information such as keyword type, index in script or
function literal pool, etc. Atoms play three roles in JSRef: as literals
referred to by unaligned 16-bit immediate bytecode operands, as unique
string descriptors for efficient property name hashing, and as members
of the root GC set for perfect GC. This design therefore requires atoms
to be manually reference counted, from script literal pools (<tt>JSAtomMap</tt>)
and object symbol (<tt>JSSymbol</tt>) entry keys.
<p>Native objects and methods for arrays, booleans, dates, functions, numbers,
and strings are implemented using the JS API and certain internal interfaces
used as "fast paths".
<p>In general, errors are signaled by false or unoverloaded-null return
values, and are reported using <tt>JS_ReportError()</tt> or one of its
variants by the lowest level in order to provide the most detail. Client
code can substitute its own error reporting function and suppress errors,
or reflect them into Java or some other runtime system as exceptions, GUI
dialogs, etc..
<h2>
File walk-through (BADLY OUT OF DATE!)</h2>
<h4>
jsapi.c, jsapi.h</h4>
The public API to be used by almost all client code.&nbsp; If your client
code can't make do with <tt>jsapi.h</tt>, and must reach into a friend
or private js* file, please let us know so we can extend <tt>jsapi.h</tt>
to include what you need in a fashion that we can support over the long
run.
<h4>
jspubtd.h, jsprvtd.h</h4>
These files exist to group struct and scalar typedefs so they can be used
everywhere without dragging in struct definitions from N different files.
The <tt>jspubtd.h</tt> file contains public typedefs, and is included by
<tt>jsapi.h</tt>.
The <tt>jsprvtd.h</tt> file contains private typedefs and is included by
various .h files that need type names, but not type sizes or declarations.
<h4>
jsdbgapi.c, jsdbgapi.h</h4>
The Debugging API, still very much under development. Provided so far:
<ul>
<li>
Traps, with which breakpoints, single-stepping, step over, step out, and
so on can be implemented. The debugger will have to consult jsopcode.def
on its own to figure out where to plant trap instructions to implement
functions like step out, but a future jsdbgapi.h will provide convenience
interfaces to do these things. At most one trap per bytecode can be set.
When a script (<tt>JSScript</tt>) is destroyed, all traps set in its bytecode
are cleared.</li>
<li>
Watchpoints, for intercepting set operations on properties and running
a debugger-supplied function that receives the old value and a pointer
to the new one, which it can use to modify the new value being set.</li>
<li>
Line number to PC and back mapping functions. The line-to-PC direction
"rounds" toward the next bytecode generated from a line greater than or
equal to the input line, and may return the PC of a for-loop update part,
if given the line number of the loop body's closing brace. Any line after
the last one in a script or function maps to a PC one byte beyond the last
bytecode in the script. An example, from perfect.js:</li>
<pre><tt>14&nbsp;&nbsp; function perfect(n)
15&nbsp;&nbsp; {
16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("The perfect numbers up to " +&nbsp; n + " are:");
17
18&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // We build sumOfDivisors[i] to hold a string expression for
19&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the sum of the divisors of i, excluding i itself.
20&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var sumOfDivisors = new ExprArray(n+1,1);
21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var divisor = 2; divisor &lt;= n; divisor++) {
22&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var j = divisor + divisor; j &lt;= n; j += divisor) {
23&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sumOfDivisors[j] += " + " + divisor;
24&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // At this point everything up to 'divisor' has its sumOfDivisors
26&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // expression calculated, so we can determine whether it's perfect
27&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // already by evaluating.
28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (eval(sumOfDivisors[divisor]) == divisor) {
29&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("" + divisor + " = " + sumOfDivisors[divisor]);
30&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
31&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
32&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete sumOfDivisors;
33&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("That's all.");
34&nbsp;&nbsp; }</tt></pre>
The line number to PC and back mappings can be tested using the js program
with the following script:
<pre><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; load("perfect.js")
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(perfect)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dis(perfect)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print()
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (var ln = 0; ln &lt;= 40; ln++) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var pc = line2pc(perfect,ln)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var ln2 = pc2line(perfect,pc)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("\tline " + ln + " => pc " + pc + " => line " + ln2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</tt></pre>
The result of the for loop over lines 0 to 40 inclusive is:
<pre><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 0 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 1 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 2 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 3 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 4 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 5 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 6 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 7 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 8 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 9 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 10 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 11 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 12 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 13 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 14 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 15 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 16 => pc 0 => line 16
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 17 => pc 19 => line 20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 18 => pc 19 => line 20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 19 => pc 19 => line 20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 20 => pc 19 => line 20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 21 => pc 36 => line 21
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 22 => pc 53 => line 22
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 23 => pc 74 => line 23
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 24 => pc 92 => line 22
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 25 => pc 106 => line 28
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 26 => pc 106 => line 28
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 27 => pc 106 => line 28
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 28 => pc 106 => line 28
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 29 => pc 127 => line 29
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 30 => pc 154 => line 21
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 31 => pc 154 => line 21
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 32 => pc 161 => line 32
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 33 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 34 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 35 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 36 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 37 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 38 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 39 => pc 172 => line 33
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; line 40 => pc 172 => line 33</tt></pre>
</ul>
<h4>
jsconfig.h</h4>
Various configuration macros defined as 0 or 1 depending on how <tt>JS_VERSION</tt>
is defined (as 10 for JavaScript 1.0, 11 for JavaScript 1.1, etc.). Not
all macros are tested around related code yet. In particular, JS 1.0 support
is missing from JSRef. JS 1.2 support will appear in a future JSRef release.
<br>&nbsp;
<h4>
js.c</h4>
The "JS shell", a simple interpreter program that uses the JS API and more
than a few internal interfaces (some of these internal interfaces could
be replaced by <tt>jsapi.h</tt> calls). The js program built from this
source provides a test vehicle for evaluating scripts and calling functions,
trying out new debugger primitives, etc.
<h4>
jsarray.*, jsbool.*, jdsdate.*, jsfun.*, jsmath.*, jsnum.*, jsstr.*</h4>
These file pairs implement the standard classes and (where they exist)
their underlying primitive types. They have similar structure, generally
starting with class definitions and continuing with internal constructors,
finalizers, and helper functions.
<h4>
jsobj.*, jsscope.*</h4>
These two pairs declare and implement the JS object system. All of the
following happen here:
<ul>
<li>
creating objects by class and prototype, and finalizing objects;</li>
<li>
defining, looking up, getting, setting, and deleting properties;</li>
<li>
creating and destroying properties and binding names to them.</li>
</ul>
The details of an object map (scope) are mostly hidden in <tt>jsscope.[ch]</tt>,
where scopes start out as linked lists of symbols, and grow after some
threshold into PR hash tables.
<h4>
jsatom.c, jsatom.h</h4>
The atom manager. Contains well-known string constants, their atoms, the
global atom hash table and related state, the js_Atomize() function that
turns a counted string of bytes into an atom, and literal pool (<tt>JSAtomMap</tt>)
methods.
<h4>
jsgc.c, jsgc.h</h4>
[TBD]
<h4>
jsinterp.*, jscntxt.*</h4>
The bytecode interpreter, and related functions such as Call and AllocStack,
live in <i>jsinterp.c</i>. The JSContext constructor and destructor are
factored out into <i>jscntxt.c</i> for minimal linking when the compiler
part of JS is split from the interpreter part into a separate program.
<h4>
jsemit.*, jsopcode.tbl, jsopcode.*, jsparse.*, jsscan.*, jsscript.*</h4>
Compiler and decompiler modules. The <i>jsopcode.tbl</i> file is a C preprocessor
source that defines almost everything there is to know about JS bytecodes.
See its major comment for how to use it. For now, a debugger will use it
and its dependents such as <i>jsopcode.h</i> directly, but over time we
intend to extend <i>jsdbgapi.h</i> to hide uninteresting details and provide
conveniences. The code generator is split across paragraphs of code in
<i>jsparse.c</i>,
and the utility methods called on <tt>JSCodeGenerator</tt> appear in <i>jsemit.c</i>.
Source notes generated by <i>jsparse.c</i> and
<i>jsemit.c</i> are used
in <i>jsscript.c</i> to map line number to program counter and back.
<h4>
jstypes.h, jslog2.c</h4>
Fundamental representation types and utility macros. This file alone among
all .h files in JSRef must be included first by .c files. It is not nested
in .h files, as other prerequisite .h files generally are, since it is
also a direct dependency of most .c files and would be over-included if
nested in addition to being directly included. The one "not-quite-a-macro
macro" is the <tt>JS_CeilingLog2()</tt> function in <i>jslog2.c</i>.
<h4>
jsarena.c, jsarena.h</h4>
Last-In-First-Out allocation macros that amortize malloc costs and allow
for en-masse freeing. See the paper mentioned in prarena.h's major comment.
<h4>
jsutil.c, jsutil.h</h4>
The <tt>JS_ASSERT</tt> macro is used throughout JSRef source as a proof
device to make invariants and preconditions clear to the reader, and to
hold the line during maintenance and evolution against regressions or violations
of assumptions that it would be too expensive to test unconditionally at
run-time. Certain assertions are followed by run-time tests that cope with
assertion failure, but only where I'm too smart or paranoid to believe
the assertion will never fail...
<h4>
jsclist.h</h4>
Doubly-linked circular list struct and macros.
<h4>
jscpucfg.c</h4>
This standalone program generates <i>jscpucfg.h</i>, a header file containing
bytes per word and other constants that depend on CPU architecture and
C compiler type model. It tries to discover most of these constants by
running its own experiments on the build host, so if you are cross-compiling,
beware.
<h4>
prdtoa.c, prdtoa.h</h4>
David Gay's portable double-precision floating point to string conversion
code, with Permission To Use notice included.
<h4>
prhash.c, prhash.h</h4>
Portable, extensible hash tables. These use multiplicative hash for strength
reduction over division hash, yet with very good key distribution over
power of two table sizes. Collisions resolve via chaining, so each entry
burns a malloc and can fragment the heap.
<h4>
prlong.c, prlong.h</h4>
64-bit integer emulation, and compatible macros that use C's long long
type where it exists (my last company mapped long long to a 128-bit type,
but no real architecture does 128-bit ints yet).
<h4>
jsosdep.h</h4>
Annoying OS dependencies rationalized into a few "feature-test" macros
such as <tt>JS_HAVE_LONG_LONG</tt>.
<h4>
jsprf.*</h4>
Portable, buffer-overrun-resistant sprintf and friends. For no good reason
save lack of time, the %e, %f, and %g formats cause your system's native
sprintf, rather than <tt>JS_dtoa()</tt>, to be used. This bug doesn't affect
JSRef, because it uses its own <tt>JS_dtoa()</tt> call in <i>jsnum.c</i>
to convert from double to string, but it's a bug that we'll fix later,
and one you should be aware of if you intend to use a <tt>JS_*printf()</tt>&nbsp;
function with your own floating type arguments - various vendor sprintf's
mishandle NaN, +/-Inf, and some even print normal floating values inaccurately.
<h4>
prmjtime.c, prmjtime.h</h4>
Time functions. These interfaces are named in a way that makes local vs.
universal time confusion likely. Caveat emptor, and we're working on it.
To make matters worse, Java (and therefore JavaScript) uses "local" time
numbers (offsets from the epoch) in its Date class.
</body>
</html>

View File

@@ -0,0 +1,12 @@
mozilla/js/src/*
mozilla/js/src/config/*
mozilla/js/src/fdlibm/*
mozilla/js/src/liveconnect/*
mozilla/js/src/liveconnect/_jni/*
mozilla/js/src/liveconnect/classes/*
mozilla/js/src/liveconnect/classes/netscape/*
mozilla/js/src/liveconnect/classes/netscape/javascript/*
mozilla/js/src/liveconnect/config/*
mozilla/js/src/liveconnect/macbuild/*
mozilla/js/src/liveconnect/macbuild/JavaSession/*
mozilla/js/src/macbuild/*

View File

@@ -1,100 +0,0 @@
#! gmake
#
# Since everyone seems to need to have their own build configuration
# system these days, this is yet another makefile to build JavaScript.
# This makefile conforms to the NSPR20 build rules. If you have built
# NSPR20 this will build JS and stick the lib and bin files over in
# the dist area created by NSPR (which is different from the dist
# expected by the client and also the dist expected by LiveWire, but
# don't get me started).
#
# I don't currently know enough about what sort of JS-engine the Actra
# projects are going to expect so I don't know if we need to add
# to CFLAGS for -DJS_THREADSAFE or -DJSFILE
#
MOD_DEPTH = ../../nspr20
include $(MOD_DEPTH)/config/config.mk
INCLUDES = -I$(DIST)/include
CFLAGS += -DNSPR20
CSRCS = prmjtime.c \
jsapi.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsemit.c \
jsfun.c \
jsgc.c \
jsinterp.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsregexp.c \
jsscan.c \
jsscope.c \
jsscript.c \
jsstr.c \
jslock.c \
$(NULL)
HEADERS = jsapi.h \
jsarray.h \
jsatom.h \
jsbool.h \
jscntxt.h \
jscompat.h \
jsconfig.h \
jsdate.h \
jsdbgapi.h \
jsemit.h \
jsfun.h \
jsgc.h \
jsinterp.h \
jslock.h \
jsmath.h \
jsnum.h \
jsobj.h \
jsopcode.def \
jsopcode.h \
jsparse.h \
jsprvtd.h \
jspubtd.h \
jsregexp.h \
jsscan.h \
jsscope.h \
jsscript.h \
jsstr.h \
$(NULL)
ifeq ($(OS_ARCH), WINNT)
EXTRA_LIBS += $(DIST)/lib/libnspr$(MOD_VERSION).lib
EXTRA_LIBS += $(DIST)/lib/libplds$(MOD_VERSION).lib
else
EXTRA_LIBS += -L$(DIST)/lib -lnspr$(MOD_VERSION) -lnplds$(MOD_VERSION)
endif
LIBRARY_NAME = js
LIBRARY_VERSION = $(MOD_VERSION)
RELEASE_HEADERS = $(HEADERS)
RELEASE_HEADERS_DEST = $(RELEASE_INCLUDE_DIR)
RELEASE_LIBS = $(TARGETS)
include $(MOD_DEPTH)/config/rules.mk
export:: $(TARGETS)
$(INSTALL) -m 444 $(HEADERS) $(MOD_DEPTH)/../dist/public/$(LIBRARY_NAME)
$(INSTALL) -m 444 $(TARGETS) $(DIST)/lib
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(DIST)/bin
install:: export

View File

@@ -1,51 +0,0 @@
js.c
jsapi.c
jsapi.h
jsarray.c
jsarray.h
jsatom.c
jsatom.h
jsbool.c
jsbool.h
jscntxt.c
jscntxt.h
jsconfig.h
jsdate.c
jsdate.h
jsdbgapi.c
jsdbgapi.h
jsemit.c
jsemit.h
jsfun.c
jsfun.h
jsgc.c
jsgc.h
jsinterp.c
jsinterp.h
jslock.h
jslock.c
jsmath.c
jsmath.h
jsnum.c
jsnum.h
jsobj.c
jsobj.h
jsopcode.c
jsopcode.def
jsopcode.h
jsparse.c
jsparse.h
jsprvtd.h
jspubtd.h
jsregexp.c
jsregexp.h
jsscan.c
jsscan.h
jsscope.c
jsscope.h
jsscript.c
jsscript.h
jsstr.c
jsstr.h
jsxdrapi.h
jsxdrapi.c

92
mozilla/js/src/config.mk Normal file
View File

@@ -0,0 +1,92 @@
ifdef JS_DIST
DIST = $(JS_DIST)
else
DIST = $(DEPTH)/../../dist/$(OBJDIR)
endif
# Set os+release dependent make variables
OS_ARCH := $(subst /,_,$(shell uname -s))
# Attempt to differentiate between SunOS 5.4 and x86 5.4
OS_CPUARCH := $(shell uname -m)
ifeq ($(OS_CPUARCH),i86pc)
OS_RELEASE := $(shell uname -r)_$(OS_CPUARCH)
else
ifeq ($(OS_ARCH),AIX)
OS_RELEASE := $(shell uname -v).$(shell uname -r)
else
OS_RELEASE := $(shell uname -r)
endif
endif
ifeq ($(OS_ARCH),IRIX64)
OS_ARCH := IRIX
endif
# Virtually all Linux versions are identical.
# Any distinctions are handled in linux.h
ifeq ($(OS_ARCH),Linux)
OS_CONFIG := Linux_All
else
ifeq ($(OS_ARCH),dgux)
OS_CONFIG := dgux
else
OS_CONFIG := $(OS_ARCH)$(OS_OBJTYPE)$(OS_RELEASE)
endif
endif
ASFLAGS =
DEFINES =
ifeq ($(OS_ARCH), WINNT)
INSTALL = nsinstall
CP = cp
else
INSTALL = $(DEPTH)/../../dist/$(OBJDIR)/bin/nsinstall
CP = cp
endif
ifdef BUILD_OPT
OPTIMIZER = -O
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
OBJDIR_TAG = _OPT
else
ifdef USE_MSVC
OPTIMIZER = -Zi
else
OPTIMIZER = -g
endif
DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
OBJDIR_TAG = _DBG
endif
SO_SUFFIX = so
NS_USE_NATIVE = 1
# Java stuff
CLASSDIR = $(DEPTH)/liveconnect/classes
JAVA_CLASSES = $(patsubst %.java,%.class,$(JAVA_SRCS))
TARGETS += $(addprefix $(CLASSDIR)/$(OBJDIR)/$(JARPATH)/, $(JAVA_CLASSES))
JAVAC = $(JDK)/bin/javac
JAVAC_FLAGS = -classpath "$(CLASSPATH)" -d $(CLASSDIR)/$(OBJDIR)
ifeq ($(OS_ARCH), WINNT)
SEP = ;
else
SEP = :
endif
CLASSPATH = $(JDK)/lib/classes.zip$(SEP)$(CLASSDIR)/$(OBJDIR)
include $(DEPTH)/config/$(OS_CONFIG).mk
# Name of the binary code directories
ifdef BUILD_IDG
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJD
else
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
endif
VPATH = $(OBJDIR)
# Automatic make dependencies file
DEPENDENCIES = $(OBJDIR)/.md
LCJAR = js14lc30.jar

View File

@@ -35,3 +35,9 @@ OS_CFLAGS = -qarch=com -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
OS_LIBS = -lbsd -lsvld -lm
#-lpthreads -lc_r
MKSHLIB = $(LD) -bM:SRE -bh:4 -bnoentry -berok
XLDFLAGS += -lc
ifdef JS_THREADSAFE
XLDFLAGS += -lsvld
endif

View File

@@ -21,6 +21,7 @@
CC = xlC_r
CCC = xlC_r
CFLAGS += -qarch=com -qnoansialias -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
RANLIB = ranlib
@@ -31,7 +32,11 @@ CPU_ARCH = rs6000
GFX_ARCH = x
INLINES = js_compare_and_swap:js_fast_lock1:js_fast_unlock1:js_lock_get_slot:js_lock_set_slot:js_lock_scope1
OS_CFLAGS = -qarch=com -qinline+$(INLINES) -DXP_UNIX -DAIX -DAIXV3 -DSYSV
OS_LIBS = -lbsd -lsvld -lm
#-lpthreads -lc_r
MKSHLIB = /usr/lpp/xlC/bin/makeC++SharedLib_r -p 0 -G -berok
ifdef JS_THREADSAFE
XLDFLAGS += -ldl
endif

View File

@@ -19,10 +19,17 @@
# Config stuff for HPUX
#
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
# CC = gcc
# CCC = g++
# CFLAGS += -Wall -Wno-format -fPIC
CC = cc -Ae +Z
CCC = CC -Ae +a1 +eh +Z
RANLIB = echo
MKSHLIB = $(LD) -b
SO_SUFFIX = sl
#.c.o:
# $(CC) -c -MD $*.d $(CFLAGS) $<
@@ -30,7 +37,7 @@ RANLIB = echo
CPU_ARCH = hppa
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV
OS_LIBS = -ldld
ifeq ($(OS_RELEASE),B.10)

View File

@@ -0,0 +1,55 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# Config stuff for HPUX
#
# CC = gcc
# CCC = g++
# CFLAGS += -Wall -Wno-format -fPIC
CC = cc -Ae +Z
CCC = CC -Ae +a1 +eh +Z
RANLIB = echo
MKSHLIB = $(LD) -b
SO_SUFFIX = sl
#.c.o:
# $(CC) -c -MD $*.d $(CFLAGS) $<
CPU_ARCH = hppa
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV
OS_LIBS = -ldld
ifeq ($(OS_RELEASE),B.10)
PLATFORM_FLAGS += -DHPUX10 -Dhpux10
PORT_FLAGS += -DRW_NO_OVERLOAD_SCHAR -DHAVE_MODEL_H
ifeq ($(OS_VERSION),.10)
PLATFORM_FLAGS += -DHPUX10_10
endif
ifeq ($(OS_VERSION),.20)
PLATFORM_FLAGS += -DHPUX10_20
endif
ifeq ($(OS_VERSION),.30)
PLATFORM_FLAGS += -DHPUX10_30
endif
endif

View File

@@ -19,10 +19,18 @@
# Config stuff for HPUX
#
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
ifdef NS_USE_NATIVE
CC = cc +Z +DAportable +DS2.0 +u4
# LD = aCC +Z -b -Wl,+s -Wl,-B,symbolic
else
CC = gcc -Wall -Wno-format -fPIC
CCC = g++ -Wall -Wno-format -fPIC
endif
RANLIB = echo
MKSHLIB = $(LD) -b
SO_SUFFIX = sl
#.c.o:
# $(CC) -c -MD $*.d $(CFLAGS) $<
@@ -30,9 +38,11 @@ RANLIB = echo
CPU_ARCH = hppa
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_HPUX -DNATIVE -D_POSIX_C_SOURCE=199506L
OS_LIBS = -ldld
XLDFLAGS = -lpthread
ifeq ($(OS_RELEASE),B.10)
PLATFORM_FLAGS += -DHPUX10 -Dhpux10
PORT_FLAGS += -DRW_NO_OVERLOAD_SCHAR -DHAVE_MODEL_H

View File

@@ -26,7 +26,7 @@ RANLIB = /bin/true
#NS_USE_GCC = 1
ifdef NS_USE_GCC
ifndef NS_USE_NATIVE
CC = gcc
CCC = g++
AS = $(CC) -x assembler-with-cpp
@@ -36,13 +36,17 @@ OPTIMIZER = -O6
endif
else
ifeq ($(OS_RELEASE),6.2)
CC = cc -32 -DIRIX6_2
CC = cc -n32 -DIRIX6_2
endif
ifeq ($(OS_RELEASE),6.3)
CC = cc -32 -DIRIX6_3
CC = cc -n32 -DIRIX6_3
endif
ifeq ($(OS_RELEASE),6.5)
CC = cc -n32 -DIRIX6_5
endif
CCC = CC
ODD_CFLAGS = -fullwarn -xansi
# LD = CC
ODD_CFLAGS = -xansi
ifdef BUILD_OPT
OPTIMIZER += -Olimit 4000
endif
@@ -55,4 +59,7 @@ PURE_OS_CFLAGS = $(ODD_CFLAGS) -DXP_UNIX -DSVR4 -DSW_THREADS -DIRIX
OS_CFLAGS = $(PURE_OS_CFLAGS) -MDupdate $(DEPENDENCIES)
BSDECHO = echo
MKSHLIB = $(LD) -shared
MKSHLIB = $(LD) -n32 -shared
# Use the editline library to provide line-editing support.
JS_EDITLINE = 1

View File

@@ -19,4 +19,4 @@
# Config stuff for IRIX5.3
#
include config/IRIX.mk
include $(DEPTH)/config/IRIX.mk

View File

@@ -19,4 +19,4 @@
# Config stuff for IRIX6.3
#
include config/IRIX.mk
include $(DEPTH)/config/IRIX.mk

View File

@@ -16,7 +16,7 @@
#
#
# Config stuff for IRIX6.2
# Config stuff for IRIX6.3
#
include config/IRIX.mk
include $(DEPTH)/config/IRIX.mk

View File

@@ -19,4 +19,4 @@
# Config stuff for IRIX6.3
#
include config/IRIX.mk
include $(DEPTH)/config/IRIX.mk

View File

@@ -0,0 +1,22 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# Config stuff for IRIX6.3
#
include $(DEPTH)/config/IRIX.mk

View File

@@ -19,10 +19,12 @@
# Config for all versions of Linux
#
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
CC = /usr/bin/gcc
CCC = /usr/bin/g++
CFLAGS += -Wall -Wno-format
RANLIB = echo
MKSHLIB = $(LD) -shared $(XMKSHLIBOPTS)
#.c.o:
# $(CC) -c -MD $*.d $(CFLAGS) $<
@@ -33,7 +35,7 @@ CPU_ARCH = x86
endif
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DLINUX
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE
OS_LIBS = -lm -lc
ASFLAGS += -x assembler-with-cpp
@@ -45,3 +47,6 @@ ifeq ($(CPU_ARCH),alpha)
OS_CFLAGS += -mieee
endif
# Use the editline library to provide line-editing support.
JS_EDITLINE = 1

View File

@@ -0,0 +1,50 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# Config stuff for Data General DG/UX
#
#
# Initial DG/UX port by Marc Fraioli (fraioli@dg-rtp.dg.com)
#
ifndef NS_USE_NATIVE
CC = gcc
CCC = g++
CFLAGS += -mieee -Wall -Wno-format
else
CC = cc
CCC = cxx
CFLAGS += -ieee -std
# LD = cxx
endif
RANLIB = echo
MKSHLIB = $(LD) -shared -taso -all -expect_unresolved "*"
#
# _DGUX_SOURCE is needed to turn on a lot of stuff in the headers if
# you're not using DG's compiler. It shouldn't hurt if you are.
#
# _POSIX4A_DRAFT10_SOURCE is needed to pick up localtime_r, used in
# prtime.c
#
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DDGUX -D_DGUX_SOURCE -D_POSIX4A_DRAFT10_SOURCE -DOSF1
OS_LIBS = -lsocket -lnsl
NOSUCHFILE = /no-such-file

View File

@@ -19,8 +19,9 @@
# Config stuff for SunOS5.3
#
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
CC = gcc
CCC = g++
CFLAGS += -Wall -Wno-format
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
RANLIB = echo
@@ -64,3 +65,5 @@ else
ASFLAGS += -xarch=v8
endif
endif
MKSHLIB = $(LD) -G

View File

@@ -23,8 +23,9 @@ ifdef NS_USE_NATIVE
CC = cc
CCC = CC
else
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
CC = gcc
CCC = g++
CFLAGS += -Wall -Wno-format
endif
RANLIB = echo
@@ -65,3 +66,5 @@ else
ASFLAGS += -xarch=v8
endif
endif
MKSHLIB = $(LD) -G

View File

@@ -16,56 +16,7 @@
#
#
# Config stuff for SunOS5.5
# Config stuff for SunOS5.5.1
#
AS = as
ifndef NS_USE_NATIVE
CC = gcc -Wall -Wno-format
CCC = g++ -Wall
else
CC = cc
CCC = CC
endif
RANLIB = echo
#.c.o:
# $(CC) -c -MD $*.d $(CFLAGS) $<
CPU_ARCH = sparc
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS -D_SVID_GETTOD
OS_LIBS = -lsocket -lnsl -ldl
ASFLAGS += -P -L -K PIC -D_ASM -D__STDC__=0
HAVE_PURIFY = 1
NOSUCHFILE = /solaris-rm-f-sucks
ifndef JS_NO_ULTRA
ULTRA_OPTIONS := -xarch=v8plus
ULTRA_OPTIONSD := -DULTRA_SPARC
else
ULTRA_OPTIONS := -xarch=v8
ULTRA_OPTIONSD :=
endif
ifeq ($(OS_CPUARCH),sun4u)
DEFINES += $(ULTRA_OPTIONSD)
ifeq ($(findstring gcc,$(CC)),gcc)
DEFINES += -Wa,$(ULTRA_OPTIONS),$(ULTRA_OPTIONSD)
else
ASFLAGS += $(ULTRA_OPTIONS) $(ULTRA_OPTIONSD)
endif
endif
ifeq ($(OS_CPUARCH),sun4m)
ifeq ($(findstring gcc,$(CC)),gcc)
DEFINES += -Wa,-xarch=v8
else
ASFLAGS += -xarch=v8
endif
endif
include $(DEPTH)/config/SunOS5.5.mk

View File

@@ -20,10 +20,15 @@
#
AS = as
CC = gcc -Wall -Wno-format
CCC = g++ -Wall -Wno-format
ifndef NS_USE_NATIVE
CC = gcc
CCC = g++
CFLAGS += -Wall -Wno-format
else
CC = cc
CCC = CC
endif
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
RANLIB = echo
#.c.o:
@@ -32,7 +37,7 @@ RANLIB = echo
CPU_ARCH = sparc
GFX_ARCH = x
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS -D_SVID_GETTOD
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS
OS_LIBS = -lsocket -lnsl -ldl
ASFLAGS += -P -L -K PIC -D_ASM -D__STDC__=0
@@ -41,22 +46,20 @@ HAVE_PURIFY = 1
NOSUCHFILE = /solaris-rm-f-sucks
ifndef JS_NO_ULTRA
ULTRA_OPTIONS := -xarch=v8plus -DULTRA_SPARC
ifeq ($(OS_CPUARCH),sun4u) # ultra sparc?
ifeq ($(CC),gcc) # using gcc?
ifndef JS_NO_ULTRA # do we want ultra?
ifdef JS_THREADSAFE # only in thread-safe mode
DEFINES += -DULTRA_SPARC
DEFINES += -Wa,-xarch=v8plus,-DULTRA_SPARC
else
ULTRA_OPTIONS := -xarch=v8
ASFLAGS += -xarch=v8plus -DULTRA_SPARC
endif
endif
endif
endif
ifeq ($(OS_CPUARCH),sun4u)
ASFLAGS += $(ULTRA_OPTIONS)
ifeq ($(findstring gcc,$(CC)),gcc)
DEFINES += -Wa,$(ULTRA_OPTIONS)
endif
else
ifeq ($(OS_CPUARCH),sun4m)
ASFLAGS += -xarch=v8
ifeq ($(findstring gcc,$(CC)),gcc)
DEFINES += -Wa,-xarch=v8
endif
endif
endif
MKSHLIB = $(LD) -G
# Use the editline library to provide line-editing support.
JS_EDITLINE = 1

Some files were not shown because too many files have changed in this diff Show More