Compare commits
324 Commits
jsd
...
tags/furte
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a617ee3a29 | ||
|
|
52d6b91235 | ||
|
|
55dc58958a | ||
|
|
682df8db3e | ||
|
|
8ed39db9a8 | ||
|
|
33d0464867 | ||
|
|
490b91850b | ||
|
|
25da940352 | ||
|
|
f0ca36ba7d | ||
|
|
480dbe043f | ||
|
|
19b9471938 | ||
|
|
68fe0d88b6 | ||
|
|
a6fcbc6e38 | ||
|
|
a0f85cea3a | ||
|
|
3f5735fcf7 | ||
|
|
0ab0796234 | ||
|
|
0e145d79c2 | ||
|
|
3e89c252c4 | ||
|
|
6e0204a004 | ||
|
|
4b9ed1baa8 | ||
|
|
b9f4c69e12 | ||
|
|
5f6a0b9c3a | ||
|
|
f68735a6bb | ||
|
|
8616bd54f5 | ||
|
|
09e0785f68 | ||
|
|
dd8953010a | ||
|
|
a67d8ed2fe | ||
|
|
935f0e5ac8 | ||
|
|
97aa1f7699 | ||
|
|
f399e21216 | ||
|
|
823cb6e29e | ||
|
|
84e135cd01 | ||
|
|
ac3516411a | ||
|
|
db237360fa | ||
|
|
92e443d317 | ||
|
|
87c9e8ae4d | ||
|
|
3fa38c1d6a | ||
|
|
ce487f127c | ||
|
|
cc1651828e | ||
|
|
22f7fd9b4a | ||
|
|
ad72e12927 | ||
|
|
b6ada3318c | ||
|
|
82ac5c4e2f | ||
|
|
5430e4b688 | ||
|
|
33219cbcb1 | ||
|
|
e10c7eb54b | ||
|
|
70bd48b576 | ||
|
|
6bc17963c7 | ||
|
|
168c0f6f50 | ||
|
|
eef72a91bc | ||
|
|
76e06e7e4d | ||
|
|
6d03a825d3 | ||
|
|
9a0cc72a2d | ||
|
|
6139484b7e | ||
|
|
b576db0575 | ||
|
|
1858d69e49 | ||
|
|
76326b2efb | ||
|
|
06a7abeacf | ||
|
|
2ae04afc70 | ||
|
|
754415d2a7 | ||
|
|
d719a6f851 | ||
|
|
cdcef88024 | ||
|
|
34fd322859 | ||
|
|
d848312079 | ||
|
|
cdc32c49b5 | ||
|
|
93a992bb20 | ||
|
|
256ad44f6c | ||
|
|
c76f45fb75 | ||
|
|
a7a3555cc8 | ||
|
|
3140821cd1 | ||
|
|
befd55d8ba | ||
|
|
3962bfda99 | ||
|
|
faca6b626e | ||
|
|
8c1af11605 | ||
|
|
6c8f42225c | ||
|
|
847bebb065 | ||
|
|
2c9b897958 | ||
|
|
b01cc3080f | ||
|
|
9cd7750dd1 | ||
|
|
ed9c4d7ee1 | ||
|
|
ceb34941c8 | ||
|
|
f20e53875b | ||
|
|
7c8275aae3 | ||
|
|
30e0d801a7 | ||
|
|
a899984e09 | ||
|
|
54e5a64304 | ||
|
|
4016979d0d | ||
|
|
663693cafe | ||
|
|
aed4dd4310 | ||
|
|
6c7c73d822 | ||
|
|
28c93d2218 | ||
|
|
ca95b9b63a | ||
|
|
67d738630a | ||
|
|
f018a06aa7 | ||
|
|
eb89b3d136 | ||
|
|
6c156d7134 | ||
|
|
7f123a804d | ||
|
|
ec0edbcba0 | ||
|
|
2687debc8e | ||
|
|
5fb184d473 | ||
|
|
4885772ba8 | ||
|
|
3d0da2df12 | ||
|
|
030655be79 | ||
|
|
c21e3de07e | ||
|
|
f654a47a49 | ||
|
|
c11ef38890 | ||
|
|
d8f121d794 | ||
|
|
47f4088f27 | ||
|
|
9d8444be44 | ||
|
|
0bd94e4384 | ||
|
|
e0a486e300 | ||
|
|
4bf9c6a227 | ||
|
|
3277bdac18 | ||
|
|
87c868ffbe | ||
|
|
5f6bbab561 | ||
|
|
55cebfe0cb | ||
|
|
26c815ff77 | ||
|
|
facfc365cb | ||
|
|
63ace590d6 | ||
|
|
31c250eee9 | ||
|
|
60b5308f58 | ||
|
|
d2b9c6a168 | ||
|
|
b6525cde8b | ||
|
|
c4741a81fe | ||
|
|
0649a670ac | ||
|
|
d418df2eb7 | ||
|
|
e86bd6fd57 | ||
|
|
6d79b5ec64 | ||
|
|
46800959c2 | ||
|
|
e29596b37b | ||
|
|
1419ca574a | ||
|
|
e5892b8370 | ||
|
|
60fe37f18d | ||
|
|
98c0f47746 | ||
|
|
55a926e2c4 | ||
|
|
f7387ecdae | ||
|
|
ecf83e4f36 | ||
|
|
7d02cdd1c2 | ||
|
|
0bd5df16b7 | ||
|
|
145eb6f922 | ||
|
|
f98b15d6d3 | ||
|
|
da9f65325b | ||
|
|
25bbd958a9 | ||
|
|
3e8f4b2074 | ||
|
|
6547ff01ff | ||
|
|
dd55af2615 | ||
|
|
619f867c2d | ||
|
|
2ffc6eb8cf | ||
|
|
444ed356ed | ||
|
|
ad709b1cfa | ||
|
|
90dc42fec0 | ||
|
|
7b3a25dde6 | ||
|
|
3b086e1130 | ||
|
|
43ea6c73ea | ||
|
|
8b37303301 | ||
|
|
a9d4091b08 | ||
|
|
0e74fd5849 | ||
|
|
9bbc9990a2 | ||
|
|
5cea729be2 | ||
|
|
c7838f766a | ||
|
|
d6adc823ec | ||
|
|
65fea2e956 | ||
|
|
bc6d33a86b | ||
|
|
f9446c3323 | ||
|
|
f2dde02af9 | ||
|
|
41ebf8c0e0 | ||
|
|
ab971b977f | ||
|
|
9c77f182aa | ||
|
|
b25aef6c55 | ||
|
|
a82b563a25 | ||
|
|
02314c78f6 | ||
|
|
425d07341a | ||
|
|
268dfb88cb | ||
|
|
bc2ec58a7b | ||
|
|
cf373daa53 | ||
|
|
7fe8465ded | ||
|
|
37ec2963c9 | ||
|
|
5ea0bc5e25 | ||
|
|
a492c3a964 | ||
|
|
a256793772 | ||
|
|
fa7759865b | ||
|
|
7a57c4b47a | ||
|
|
a2ebae060e | ||
|
|
a8dc44aaa9 | ||
|
|
3c18b0c3ba | ||
|
|
c122de69b8 | ||
|
|
4a3d57e324 | ||
|
|
a3f846bbf0 | ||
|
|
189fd42355 | ||
|
|
63410ef469 | ||
|
|
7f25afca90 | ||
|
|
81d08cb271 | ||
|
|
deefcc6b8d | ||
|
|
e9b1c82736 | ||
|
|
27a80cf6d2 | ||
|
|
1022f9e0ce | ||
|
|
c9bb9195dd | ||
|
|
095999e32b | ||
|
|
d76a5a9080 | ||
|
|
a70e9a2aaa | ||
|
|
e359fd71fc | ||
|
|
04e1b5c3d1 | ||
|
|
fa2407ee2e | ||
|
|
49bb4bd95c | ||
|
|
3c49adc57b | ||
|
|
3f7cdf786b | ||
|
|
78fba657bd | ||
|
|
5b6a656e48 | ||
|
|
fbbe5d2674 | ||
|
|
d9d717001f | ||
|
|
1dde42d623 | ||
|
|
1ed0446da5 | ||
|
|
3fd73fdffd | ||
|
|
cfa1a86909 | ||
|
|
6b78529f1f | ||
|
|
4fd0fc55ca | ||
|
|
b1e460a74a | ||
|
|
a5a20628a0 | ||
|
|
d9eb58cdec | ||
|
|
037c43596e | ||
|
|
79b38ca130 | ||
|
|
2f59039158 | ||
|
|
d32e31eda5 | ||
|
|
ccf4b130af | ||
|
|
c66acfa187 | ||
|
|
89d32f85be | ||
|
|
0f8d890868 | ||
|
|
3c8ae5aafe | ||
|
|
f909920e91 | ||
|
|
ad73f38c85 | ||
|
|
e18fa8a56f | ||
|
|
e81b4d3657 | ||
|
|
19c49a56be | ||
|
|
3e2489f92c | ||
|
|
b9e217c7e8 | ||
|
|
940ee6966f | ||
|
|
13337f0a89 | ||
|
|
aabb8920ae | ||
|
|
bd32e33753 | ||
|
|
c68e984b99 | ||
|
|
35b4a8183d | ||
|
|
f746d5d6c5 | ||
|
|
dccd95eeaa | ||
|
|
0dc9a5a868 | ||
|
|
f46f66eea8 | ||
|
|
8ade5f78d3 | ||
|
|
58a8a3d984 | ||
|
|
e539af4e6f | ||
|
|
27e172913a | ||
|
|
b54505be31 | ||
|
|
2433dae015 | ||
|
|
c2bcde8466 | ||
|
|
90fb1dfb90 | ||
|
|
132d1f5b26 | ||
|
|
4c69c950da | ||
|
|
d5329cfd00 | ||
|
|
83cb0cf419 | ||
|
|
d3eee3f5c6 | ||
|
|
c78787a61a | ||
|
|
fd99e42a1e | ||
|
|
f536714915 | ||
|
|
16977a5881 | ||
|
|
d58d92ba30 | ||
|
|
70aa311f1a | ||
|
|
d6d4547e60 | ||
|
|
cddb4bee49 | ||
|
|
215e4f521a | ||
|
|
b374ece734 | ||
|
|
db88d15e60 | ||
|
|
17a3a3fede | ||
|
|
802ea94da2 | ||
|
|
87987c22eb | ||
|
|
92e75b047c | ||
|
|
d72d172d7a | ||
|
|
8e7b173eef | ||
|
|
d898e8430d | ||
|
|
55edce6a15 | ||
|
|
f962f59ccc | ||
|
|
75187e5e57 | ||
|
|
3522f2112e | ||
|
|
b2bc5afac7 | ||
|
|
1b857628d4 | ||
|
|
4034d6af4c | ||
|
|
1d5e647e2c | ||
|
|
2aabababd7 | ||
|
|
024311a2ab | ||
|
|
55fcddec90 | ||
|
|
0c95c94909 | ||
|
|
8da98334c6 | ||
|
|
defa10fc43 | ||
|
|
f0cdddb20c | ||
|
|
a17e03c381 | ||
|
|
595794ecfe | ||
|
|
1a0b1b8a29 | ||
|
|
670d4d69fa | ||
|
|
c5a6bb1af7 | ||
|
|
00a574acf2 | ||
|
|
68900225d1 | ||
|
|
97a1eacae2 | ||
|
|
1061a7961a | ||
|
|
95f197f31a | ||
|
|
aeb19b804e | ||
|
|
22b83ef992 | ||
|
|
cf89f9dbea | ||
|
|
b9f52d961c | ||
|
|
b9b66713eb | ||
|
|
3287009b56 | ||
|
|
d0ad9c946c | ||
|
|
b3c707fd61 | ||
|
|
03332fd3ac | ||
|
|
ef97812295 | ||
|
|
ca0614a7b6 | ||
|
|
4c1594b677 | ||
|
|
914637bd3e | ||
|
|
91dbe3c171 | ||
|
|
c3bd0c5f7d | ||
|
|
cff140c431 | ||
|
|
923990dd99 | ||
|
|
45291c870a | ||
|
|
33d0d8a72b | ||
|
|
2066c6b9ce | ||
|
|
46e77ac0e1 | ||
|
|
7507e060b5 | ||
|
|
1cc86f1b54 |
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -37,36 +37,48 @@ 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)
|
||||
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 \
|
||||
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 \
|
||||
@@ -75,14 +87,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 \
|
||||
@@ -90,6 +107,8 @@ EXPORTS = jsapi.h \
|
||||
jsscope.h \
|
||||
jsscript.h \
|
||||
jsstr.h \
|
||||
jstypes.h \
|
||||
jsutil.h \
|
||||
jsxdrapi.h \
|
||||
$(NULL)
|
||||
|
||||
@@ -102,7 +121,6 @@ JS_SAFE_ARENA = 1
|
||||
|
||||
ifdef JS_SAFE_ARENA
|
||||
DEFINES += -DJS_USE_SAFE_ARENA
|
||||
CSRCS += prarena.c
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
@@ -147,12 +165,6 @@ 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 \
|
||||
@@ -165,8 +177,7 @@ 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.
|
||||
# LIBNSPR abstracts nspr version, etc. nicely.
|
||||
LDFLAGS = $(LIBNSPR) -lm
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
@@ -179,6 +190,30 @@ ifeq ($(OS_ARCH), Linux)
|
||||
LDFLAGS += -ldl
|
||||
endif
|
||||
|
||||
FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/libfdm.a
|
||||
JSMATH_PRELINK = $(OBJDIR)/jsmathtemp.o
|
||||
|
||||
# special rule for jsmath.o since we want to incrementally link
|
||||
# against fdlibm to pull in only what is needed
|
||||
$(OBJDIR)/jsmath.o: $(FDLIBM_LIBRARY) $(JSMATH_PRELINK)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
ld -r -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
||||
else
|
||||
ld -r -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
||||
endif
|
||||
|
||||
$(JSMATH_PRELINK): jsmath.c jslibmath.h
|
||||
@$(MAKE_OBJDIR)
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) $<
|
||||
endif
|
||||
|
||||
$(FDLIBM_LIBRARY):
|
||||
cd fdlibm; $(MAKE)
|
||||
|
||||
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
|
||||
js:
|
||||
$(MAKE) clobber
|
||||
@@ -197,8 +232,22 @@ $(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
|
||||
endif
|
||||
|
||||
# hardwire dependencies on jsopcode.def
|
||||
jsopcode.h jsopcode.c: jsopcode.def
|
||||
# hardwire dependencies on jsopcode.tbl
|
||||
jsopcode.h jsopcode.c: jsopcode.tbl
|
||||
|
||||
# Generate jsautocfg.h header
|
||||
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
|
||||
rm -f $@
|
||||
$(OBJDIR)/jscpucfg > $@
|
||||
|
||||
$(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
|
||||
$(CC) -o $@ $(OBJDIR)/jscpucfg.o
|
||||
|
||||
export:: $(OBJDIR)/jsautocfg.h
|
||||
$(INSTALL) -m 444 $(OBJDIR)/jsautocfg.h $(DIST)/include
|
||||
|
||||
# Add to TARGETS so clobber rule works
|
||||
TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.o
|
||||
|
||||
# this section was put in the merged by danda into the
|
||||
# JAVA_*_MERGE section and normally would have
|
||||
@@ -213,24 +262,6 @@ $(OBJDIR)/js.o: js.c
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
|
||||
endif
|
||||
|
||||
clobber::
|
||||
rm -f $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.h
|
||||
|
||||
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
|
||||
|
||||
@@ -40,36 +40,48 @@ 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 \
|
||||
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 \
|
||||
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 +90,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,6 +110,8 @@ EXPORTS = jsapi.h \
|
||||
jsscope.h \
|
||||
jsscript.h \
|
||||
jsstr.h \
|
||||
jstypes.h \
|
||||
jsutil.h \
|
||||
jsxdrapi.h \
|
||||
$(NULL)
|
||||
|
||||
@@ -107,7 +126,6 @@ JS_SAFE_ARENA = 1
|
||||
|
||||
ifdef JS_SAFE_ARENA
|
||||
DEFINES += -DJS_USE_SAFE_ARENA
|
||||
CSRCS += prarena.c
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -152,12 +170,6 @@ 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,8 +182,7 @@ 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.
|
||||
# LIBNSPR abstracts nspr version, etc. nicely.
|
||||
LDFLAGS = $(LIBNSPR) -lm
|
||||
|
||||
ifeq ($(OS_ARCH), OSF1)
|
||||
@@ -184,6 +195,30 @@ ifeq ($(OS_ARCH), Linux)
|
||||
LDFLAGS += -ldl
|
||||
endif
|
||||
|
||||
FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/libfdm.a
|
||||
JSMATH_PRELINK = $(OBJDIR)/jsmathtemp.o
|
||||
|
||||
# special rule for jsmath.o since we want to incrementally link
|
||||
# against fdlibm to pull in only what is needed
|
||||
$(OBJDIR)/jsmath.o: $(FDLIBM_LIBRARY) $(JSMATH_PRELINK)
|
||||
@$(MAKE_OBJDIR)
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
ld -r -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
||||
else
|
||||
ld -r -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY)
|
||||
endif
|
||||
|
||||
$(JSMATH_PRELINK): jsmath.c
|
||||
@$(MAKE_OBJDIR)
|
||||
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
|
||||
$(CC) -Fo$@ -c $(CFLAGS) $<
|
||||
else
|
||||
$(CC) -o $@ -c $(CFLAGS) $<
|
||||
endif
|
||||
|
||||
$(FDLIBM_LIBRARY):
|
||||
cd fdlibm; $(MAKE)
|
||||
|
||||
# this requires clobbering and recompiling with XCFLAGS=-DJSFILE
|
||||
js:
|
||||
$(MAKE) clobber
|
||||
@@ -202,8 +237,22 @@ $(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
|
||||
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
|
||||
endif
|
||||
|
||||
# hardwire dependencies on jsopcode.def
|
||||
jsopcode.h jsopcode.c: jsopcode.def
|
||||
# hardwire dependencies on jsopcode.tbl
|
||||
jsopcode.h jsopcode.c: jsopcode.tbl
|
||||
|
||||
# Generate jsautocfg.h header
|
||||
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
|
||||
rm -f $@
|
||||
$(OBJDIR)/jscpucfg > $@
|
||||
|
||||
$(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o
|
||||
$(CC) -o $@ $(OBJDIR)/jscpucfg.o
|
||||
|
||||
export:: $(OBJDIR)/jsautocfg.h
|
||||
$(INSTALL) -m 444 $(OBJDIR)/jsautocfg.h $(DIST)/include
|
||||
|
||||
# Add to TARGETS so clobber rule works
|
||||
TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg $(OBJDIR)/jscpucfg.o
|
||||
|
||||
# this section was put in the merged by danda into the
|
||||
# JAVA_*_MERGE section and normally would have
|
||||
@@ -217,25 +266,3 @@ $(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
|
||||
|
||||
@@ -18,78 +18,40 @@
|
||||
# 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/libnspr21.lib
|
||||
else
|
||||
OTHER_LIBS += -L../../dist/$(OBJDIR)/lib -lnspr21
|
||||
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) \
|
||||
CFLAGS += $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
|
||||
-DJSFILE $(XCFLAGS)
|
||||
LDFLAGS = -lm $(XLDFLAGS)
|
||||
|
||||
@@ -97,7 +59,7 @@ 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)
|
||||
@@ -126,6 +88,7 @@ JS_HFILES = \
|
||||
jsfun.h \
|
||||
jsgc.h \
|
||||
jsinterp.h \
|
||||
jslibmath.h \
|
||||
jslock.h \
|
||||
jsmath.h \
|
||||
jsnum.h \
|
||||
@@ -137,11 +100,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 \
|
||||
@@ -162,28 +121,28 @@ HFILES = $(JS_HFILES) $(API_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 +154,74 @@ 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
|
||||
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" $?
|
||||
else
|
||||
$(LIBRARY): $(LIB_OBJS)
|
||||
$(AR) rv $@ $?
|
||||
$(RANLIB) $@
|
||||
endif
|
||||
endif
|
||||
|
||||
#NSPR_LIBRARY = ../../dist/$(OBJDIR)/lib/libnspr21.so
|
||||
NSPR_LIBRARY =
|
||||
|
||||
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
|
||||
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(NSPR_LIBRARY) $(LDFLAGS)
|
||||
link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
|
||||
else
|
||||
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
|
||||
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS)
|
||||
endif
|
||||
|
||||
$(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)
|
||||
|
||||
$(HFILES) $(CFILES): $(OBJDIR)/jscpucfg.h
|
||||
ifndef PREBUILT_CPUCFG
|
||||
$(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 +234,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
|
||||
|
||||
@@ -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
755
mozilla/js/src/README.html
Normal 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 <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. 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. 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. 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. (NSPR implements a portable threading library,
|
||||
among other things. 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>.)
|
||||
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>. (<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.) <font color="#CC0000">NOTE: makefile.win
|
||||
is an nmake file used only for building the JS-engine in the Mozilla browser.
|
||||
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>. <font color="#CC0000">NOTE:
|
||||
Do not attempt to use Makefile to build the standalone JavaScript engine.
|
||||
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. The configuration
|
||||
file specifies the compiler/linker to be used and allows for customization
|
||||
of command-line options. 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>.
|
||||
(Except that HP builds only work using the native compiler. gcc won't
|
||||
link correctly with shared libraries on that platform. 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>.
|
||||
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> /*
|
||||
* Tune this to avoid wasting space for shallow stacks, while saving on
|
||||
* malloc overhead/fragmentation for deep or highly-variable stacks.
|
||||
*/
|
||||
#define STACK_CHUNK_SIZE 8192
|
||||
|
||||
JSRuntime *rt;
|
||||
JSContext *cx;
|
||||
|
||||
/* You need a runtime and one or more contexts to do anything with JS. */
|
||||
rt = JS_Init(1000000L);
|
||||
if (!rt)
|
||||
fail("can't create JavaScript runtime");
|
||||
cx = JS_NewContext(rt, STACK_CHUNK_SIZE);
|
||||
if (!cx)
|
||||
fail("can't create JavaScript context");
|
||||
|
||||
/*
|
||||
* The context definitely wants a global object, in order to have standard
|
||||
* classes and functions like Date and parseInt. See below for details on
|
||||
* JS_NewObject.
|
||||
*/
|
||||
JSObject *globalObj;
|
||||
|
||||
globalObj = JS_NewObject(cx, &my_global_class, 0, 0);
|
||||
JS_InitStandardClasses(cx, globalObj);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining objects and properties</h4>
|
||||
|
||||
<pre><tt> /* Statically initialize a class to make "one-off" objects. */
|
||||
JSClass my_class = {
|
||||
"MyClass",
|
||||
|
||||
/* All of these can be replaced with the corresponding JS_*Stub
|
||||
function pointers. */
|
||||
my_addProperty, my_delProperty, my_getProperty, my_setProperty,
|
||||
my_enumerate, my_resolve, my_convert, my_finalize
|
||||
};
|
||||
|
||||
JSObject *obj;
|
||||
|
||||
/*
|
||||
* Define an object named in the global scope that can be enumerated by
|
||||
* for/in loops. The parent object is passed as the second argument, as
|
||||
* with all other API calls that take an object/name pair. The prototype
|
||||
* passed in is null, so the default object prototype will be used.
|
||||
*/
|
||||
obj = JS_DefineObject(cx, globalObj, "myObject", &my_class, 0,
|
||||
JSPROP_ENUMERATE);
|
||||
|
||||
/*
|
||||
* Define a bunch of properties with a JSPropertySpec array statically
|
||||
* initialized and terminated with a null-name entry. Besides its name,
|
||||
* each property has a "tiny" identifier (MY_COLOR, e.g.) that can be used
|
||||
* in switch statements (in a common my_getProperty function, for example).
|
||||
*/
|
||||
enum my_tinyid {
|
||||
MY_COLOR, MY_HEIGHT, MY_WIDTH, MY_FUNNY, MY_ARRAY, MY_RDONLY
|
||||
};
|
||||
|
||||
static JSPropertySpec my_props[] = {
|
||||
{"color", MY_COLOR, JSPROP_ENUMERATE},
|
||||
{"height", MY_HEIGHT, JSPROP_ENUMERATE},
|
||||
{"width", MY_WIDTH, JSPROP_ENUMERATE},
|
||||
{"funny", MY_FUNNY, JSPROP_ENUMERATE},
|
||||
{"array", MY_ARRAY, JSPROP_ENUMERATE},
|
||||
{"rdonly", MY_RDONLY, JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
JS_DefineProperties(cx, obj, my_props);
|
||||
|
||||
/*
|
||||
* Given the above definitions and call to JS_DefineProperties, obj will
|
||||
* need this sort of "getter" method in its class (my_class, above). See
|
||||
* the example for the "It" class in js.c.
|
||||
*/
|
||||
static JSBool
|
||||
my_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch (JSVAL_TO_INT(id)) {
|
||||
case MY_COLOR: *vp = . . .; break;
|
||||
case MY_HEIGHT: *vp = . . .; break;
|
||||
case MY_WIDTH: *vp = . . .; break;
|
||||
case MY_FUNNY: *vp = . . .; break;
|
||||
case MY_ARRAY: *vp = . . .; break;
|
||||
case MY_RDONLY: *vp = . . .; break;
|
||||
}
|
||||
}
|
||||
return JS_TRUE;
|
||||
}</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining functions</h4>
|
||||
|
||||
<pre><tt> /* Define a bunch of native functions first: */
|
||||
static JSBool
|
||||
my_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
jsdouble x, z;
|
||||
|
||||
if (!JS_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = (x < 0) ? -x : x;
|
||||
return JS_NewDoubleValue(cx, z, rval);
|
||||
}
|
||||
|
||||
. . .
|
||||
|
||||
/*
|
||||
* Use a JSFunctionSpec array terminated with a null name to define a
|
||||
* bunch of native functions.
|
||||
*/
|
||||
static JSFunctionSpec my_functions[] = {
|
||||
/* name native nargs */
|
||||
{"abs", my_abs, 1},
|
||||
{"acos", my_acos, 1},
|
||||
{"asin", my_asin, 1},
|
||||
. . .
|
||||
{0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Pass a particular object to define methods for it alone. If you pass
|
||||
* a prototype object, the methods will apply to all instances past and
|
||||
* future of the prototype's class (see below for classes).
|
||||
*/
|
||||
JS_DefineFunctions(cx, globalObj, my_functions);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Defining classes</h4>
|
||||
|
||||
<pre><tt> /*
|
||||
* This pulls together the above API elements by defining a constructor
|
||||
* function, a prototype object, and properties of the prototype and of
|
||||
* the constructor, all with one API call.
|
||||
*
|
||||
* Initialize a class by defining its constructor function, prototype, and
|
||||
* per-instance and per-class properties. The latter are called "static"
|
||||
* below by analogy to Java. They are defined in the constructor object's
|
||||
* scope, so that 'MyClass.myStaticProp' works along with 'new MyClass()'.
|
||||
*
|
||||
* JS_InitClass takes a lot of arguments, but you can pass null for any of
|
||||
* the last four if there are no such properties or methods.
|
||||
*
|
||||
* Note that you do not need to call JS_InitClass to make a new instance of
|
||||
* that class -- otherwise there would be a chicken-and-egg problem making
|
||||
* the global object -- but you should call JS_InitClass if you require a
|
||||
* constructor function for script authors to call via new, and/or a class
|
||||
* prototype object ('MyClass.prototype') for authors to extend with new
|
||||
* properties at run-time.
|
||||
*/
|
||||
protoObj = JS_InitClass(cx, globalObj, &my_class,
|
||||
|
||||
/* native constructor function and min arg count */
|
||||
MyClass, 0,
|
||||
|
||||
/* prototype object properties and methods -- these
|
||||
will be "inherited" by all instances through
|
||||
delegation up the instance's prototype link. */
|
||||
my_props, my_methods,
|
||||
|
||||
/* class constructor properties and methods */
|
||||
my_static_props, my_static_methods);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Running scripts</h4>
|
||||
|
||||
<pre><tt> /* These should indicate source location for diagnostics. */
|
||||
char *filename;
|
||||
uintN lineno;
|
||||
|
||||
/*
|
||||
* The return value comes back here -- if it could be a GC thing, you must
|
||||
* add it to the GC's "root set" with JS_AddRoot(cx, &thing) where thing
|
||||
* is a JSString *, JSObject *, or jsdouble *, and remove the root before
|
||||
* rval goes out of scope, or when rval is no longer needed.
|
||||
*/
|
||||
jsval rval;
|
||||
JSBool ok;
|
||||
|
||||
/*
|
||||
* Some example source in a C string. Larger, non-null-terminated buffers
|
||||
* can be used, if you pass the buffer length to JS_EvaluateScript.
|
||||
*/
|
||||
char *source = "x * f(y)";
|
||||
|
||||
ok = JS_EvaluateScript(cx, globalObj, source, strlen(source),
|
||||
filename, lineno, &rval);
|
||||
|
||||
if (ok) {
|
||||
/* Should get a number back from the example source. */
|
||||
jsdouble d;
|
||||
|
||||
ok = JS_ValueToNumber(cx, rval, &d);
|
||||
. . .
|
||||
}</tt></pre>
|
||||
|
||||
<h4>
|
||||
Calling functions</h4>
|
||||
|
||||
<pre><tt> /* Call a global function named "foo" that takes no arguments. */
|
||||
ok = JS_CallFunctionName(cx, globalObj, "foo", 0, 0, &rval);
|
||||
|
||||
jsval argv[2];
|
||||
|
||||
/* Call a function in obj's scope named "method", passing two arguments. */
|
||||
argv[0] = . . .;
|
||||
argv[1] = . . .;
|
||||
ok = JS_CallFunctionName(cx, obj, "method", 2, argv, &rval);</tt></pre>
|
||||
|
||||
<h4>
|
||||
Shutting down</h4>
|
||||
|
||||
<pre><tt> /* For each context you've created: */
|
||||
JS_DestroyContext(cx);
|
||||
|
||||
/* And finally: */
|
||||
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. 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 function perfect(n)
|
||||
15 {
|
||||
16 print("The perfect numbers up to " + n + " are:");
|
||||
17
|
||||
18 // We build sumOfDivisors[i] to hold a string expression for
|
||||
19 // the sum of the divisors of i, excluding i itself.
|
||||
20 var sumOfDivisors = new ExprArray(n+1,1);
|
||||
21 for (var divisor = 2; divisor <= n; divisor++) {
|
||||
22 for (var j = divisor + divisor; j <= n; j += divisor) {
|
||||
23 sumOfDivisors[j] += " + " + divisor;
|
||||
24 }
|
||||
25 // At this point everything up to 'divisor' has its sumOfDivisors
|
||||
26 // expression calculated, so we can determine whether it's perfect
|
||||
27 // already by evaluating.
|
||||
28 if (eval(sumOfDivisors[divisor]) == divisor) {
|
||||
29 print("" + divisor + " = " + sumOfDivisors[divisor]);
|
||||
30 }
|
||||
31 }
|
||||
32 delete sumOfDivisors;
|
||||
33 print("That's all.");
|
||||
34 }</tt></pre>
|
||||
The line number to PC and back mappings can be tested using the js program
|
||||
with the following script:
|
||||
<pre><tt> load("perfect.js")
|
||||
print(perfect)
|
||||
dis(perfect)
|
||||
|
||||
print()
|
||||
for (var ln = 0; ln <= 40; ln++) {
|
||||
var pc = line2pc(perfect,ln)
|
||||
var ln2 = pc2line(perfect,pc)
|
||||
print("\tline " + ln + " => pc " + pc + " => line " + ln2)
|
||||
}</tt></pre>
|
||||
The result of the for loop over lines 0 to 40 inclusive is:
|
||||
<pre><tt> line 0 => pc 0 => line 16
|
||||
line 1 => pc 0 => line 16
|
||||
line 2 => pc 0 => line 16
|
||||
line 3 => pc 0 => line 16
|
||||
line 4 => pc 0 => line 16
|
||||
line 5 => pc 0 => line 16
|
||||
line 6 => pc 0 => line 16
|
||||
line 7 => pc 0 => line 16
|
||||
line 8 => pc 0 => line 16
|
||||
line 9 => pc 0 => line 16
|
||||
line 10 => pc 0 => line 16
|
||||
line 11 => pc 0 => line 16
|
||||
line 12 => pc 0 => line 16
|
||||
line 13 => pc 0 => line 16
|
||||
line 14 => pc 0 => line 16
|
||||
line 15 => pc 0 => line 16
|
||||
line 16 => pc 0 => line 16
|
||||
line 17 => pc 19 => line 20
|
||||
line 18 => pc 19 => line 20
|
||||
line 19 => pc 19 => line 20
|
||||
line 20 => pc 19 => line 20
|
||||
line 21 => pc 36 => line 21
|
||||
line 22 => pc 53 => line 22
|
||||
line 23 => pc 74 => line 23
|
||||
line 24 => pc 92 => line 22
|
||||
line 25 => pc 106 => line 28
|
||||
line 26 => pc 106 => line 28
|
||||
line 27 => pc 106 => line 28
|
||||
line 28 => pc 106 => line 28
|
||||
line 29 => pc 127 => line 29
|
||||
line 30 => pc 154 => line 21
|
||||
line 31 => pc 154 => line 21
|
||||
line 32 => pc 161 => line 32
|
||||
line 33 => pc 172 => line 33
|
||||
line 34 => pc 172 => line 33
|
||||
line 35 => pc 172 => line 33
|
||||
line 36 => pc 172 => line 33
|
||||
line 37 => pc 172 => line 33
|
||||
line 38 => pc 172 => line 33
|
||||
line 39 => pc 172 => line 33
|
||||
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>
|
||||
<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>
|
||||
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>
|
||||
12
mozilla/js/src/SpiderMonkey.rsp
Normal file
12
mozilla/js/src/SpiderMonkey.rsp
Normal 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/*
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
65
mozilla/js/src/config.mk
Normal file
65
mozilla/js/src/config.mk
Normal file
@@ -0,0 +1,65 @@
|
||||
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
|
||||
|
||||
# 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
|
||||
else
|
||||
INSTALL = $(DEPTH)/../../dist/$(OBJDIR)/bin/nsinstall
|
||||
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
|
||||
|
||||
include $(DEPTH)/config/$(OS_CONFIG).mk
|
||||
|
||||
# Name of the binary code directories
|
||||
OBJDIR = $(OS_CONFIG)$(OBJDIR_TAG).OBJ
|
||||
VPATH = $(OBJDIR)
|
||||
|
||||
# Automatic make dependencies file
|
||||
DEPENDENCIES = $(OBJDIR)/.md
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# 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 AIX
|
||||
#
|
||||
|
||||
CC = xlC_r
|
||||
CCC = xlC_r
|
||||
|
||||
RANLIB = ranlib
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
ARCH := aix
|
||||
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
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#
|
||||
# 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 AIX
|
||||
#
|
||||
|
||||
CC = xlC_r
|
||||
CCC = xlC_r
|
||||
|
||||
RANLIB = ranlib
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
ARCH := aix
|
||||
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
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#
|
||||
# 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 -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = hppa
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
|
||||
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
|
||||
@@ -1,48 +0,0 @@
|
||||
#
|
||||
# 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 -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = hppa
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DHPUX -DSYSV -D_SVID_GETTOD
|
||||
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
|
||||
@@ -1,58 +0,0 @@
|
||||
#
|
||||
# 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 IRIX
|
||||
#
|
||||
|
||||
CPU_ARCH = mips
|
||||
GFX_ARCH = x
|
||||
|
||||
RANLIB = /bin/true
|
||||
|
||||
#NS_USE_GCC = 1
|
||||
|
||||
ifdef NS_USE_GCC
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
AS = $(CC) -x assembler-with-cpp
|
||||
ODD_CFLAGS = -Wall -Wno-format
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER = -O6
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS_RELEASE),6.2)
|
||||
CC = cc -32 -DIRIX6_2
|
||||
endif
|
||||
ifeq ($(OS_RELEASE),6.3)
|
||||
CC = cc -32 -DIRIX6_3
|
||||
endif
|
||||
CCC = CC
|
||||
ODD_CFLAGS = -fullwarn -xansi
|
||||
ifdef BUILD_OPT
|
||||
OPTIMIZER += -Olimit 4000
|
||||
endif
|
||||
endif
|
||||
|
||||
# For purify
|
||||
HAVE_PURIFY = 1
|
||||
PURE_OS_CFLAGS = $(ODD_CFLAGS) -DXP_UNIX -DSVR4 -DSW_THREADS -DIRIX
|
||||
|
||||
OS_CFLAGS = $(PURE_OS_CFLAGS) -MDupdate $(DEPENDENCIES)
|
||||
|
||||
BSDECHO = echo
|
||||
MKSHLIB = $(LD) -shared
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# 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 IRIX5.3
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# 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 config/IRIX.mk
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# 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.2
|
||||
#
|
||||
|
||||
include config/IRIX.mk
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# 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 config/IRIX.mk
|
||||
@@ -1,47 +0,0 @@
|
||||
#
|
||||
# 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 for all versions of Linux
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = $(shell uname -m)
|
||||
ifeq (86,$(findstring 86,$(CPU_ARCH)))
|
||||
CPU_ARCH = x86
|
||||
endif
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DLINUX
|
||||
OS_LIBS = -lm -lc
|
||||
|
||||
ASFLAGS += -x assembler-with-cpp
|
||||
|
||||
ifeq ($(CPU_ARCH),alpha)
|
||||
|
||||
# Ask the C compiler on alpha linux to let us work with denormalized
|
||||
# double values, which are required by the ECMA spec.
|
||||
|
||||
OS_CFLAGS += -mieee
|
||||
endif
|
||||
@@ -1,79 +0,0 @@
|
||||
#
|
||||
# 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 SunOS4.1
|
||||
#
|
||||
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
RANLIB = ranlib
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = sparc
|
||||
GFX_ARCH = x
|
||||
|
||||
# A pile of -D's to build xfe on sunos
|
||||
MOZ_CFLAGS = -DSTRINGS_ALIGNED -DNO_REGEX -DNO_ISDIR -DUSE_RE_COMP \
|
||||
-DNO_REGCOMP -DUSE_GETWD -DNO_MEMMOVE -DNO_ALLOCA \
|
||||
-DBOGUS_MB_MAX -DNO_CONST
|
||||
|
||||
# Purify doesn't like -MDupdate
|
||||
NOMD_OS_CFLAGS = -DXP_UNIX -Wall -Wno-format -DSW_THREADS -DSUNOS4 -DNEED_SYSCALL \
|
||||
$(MOZ_CFLAGS)
|
||||
|
||||
OS_CFLAGS = $(NOMD_OS_CFLAGS) -MDupdate $(DEPENDENCIES)
|
||||
OS_LIBS = -ldl -lm
|
||||
|
||||
MKSHLIB = $(LD) -L$(MOTIF)/lib
|
||||
|
||||
HAVE_PURIFY = 1
|
||||
MOTIF = /home/motif/usr
|
||||
MOTIFLIB = -L$(MOTIF)/lib -lXm
|
||||
INCLUDES += -I/usr/X11R5/include -I$(MOTIF)/include
|
||||
|
||||
NOSUCHFILE = /solaris-rm-f-sucks
|
||||
|
||||
LOCALE_MAP = $(DEPTH)/cmd/xfe/intl/sunos.lm
|
||||
|
||||
EN_LOCALE = en_US
|
||||
DE_LOCALE = de
|
||||
FR_LOCALE = fr
|
||||
JP_LOCALE = ja
|
||||
SJIS_LOCALE = ja_JP.SJIS
|
||||
KR_LOCALE = ko
|
||||
CN_LOCALE = zh
|
||||
TW_LOCALE = zh_TW
|
||||
I2_LOCALE = i2
|
||||
IT_LOCALE = it
|
||||
SV_LOCALE = sv
|
||||
ES_LOCALE = es
|
||||
NL_LOCALE = nl
|
||||
PT_LOCALE = pt
|
||||
|
||||
LOC_LIB_DIR = /usr/openwin/lib/locale
|
||||
|
||||
BSDECHO = echo
|
||||
|
||||
#
|
||||
# These defines are for building unix plugins
|
||||
#
|
||||
BUILD_UNIX_PLUGINS = 1
|
||||
DSO_LDOPTS =
|
||||
DSO_LDFLAGS =
|
||||
@@ -1,66 +0,0 @@
|
||||
#
|
||||
# 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 SunOS5.3
|
||||
#
|
||||
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
|
||||
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = sparc
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS
|
||||
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
|
||||
@@ -1,67 +0,0 @@
|
||||
#
|
||||
# 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 SunOS5.4
|
||||
#
|
||||
|
||||
ifdef NS_USE_NATIVE
|
||||
CC = cc
|
||||
CCC = CC
|
||||
else
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
endif
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
CPU_ARCH = sparc
|
||||
GFX_ARCH = x
|
||||
|
||||
OS_CFLAGS = -DXP_UNIX -DSVR4 -DSYSV -D__svr4 -DSOLARIS
|
||||
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
|
||||
@@ -1,71 +0,0 @@
|
||||
#
|
||||
# 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 SunOS5.5
|
||||
#
|
||||
|
||||
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
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# 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 SunOS5.5
|
||||
#
|
||||
|
||||
AS = as
|
||||
CC = gcc -Wall -Wno-format
|
||||
CCC = g++ -Wall -Wno-format
|
||||
|
||||
#CC = /opt/SUNWspro/SC3.0.1/bin/cc
|
||||
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 -DULTRA_SPARC
|
||||
else
|
||||
ULTRA_OPTIONS := -xarch=v8
|
||||
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
|
||||
@@ -1,46 +0,0 @@
|
||||
#
|
||||
# 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 for Windows NT using MS Visual C++ (version?)
|
||||
#
|
||||
|
||||
CC = cl
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#.c.o:
|
||||
# $(CC) -c -MD $*.d $(CFLAGS) $<
|
||||
|
||||
CPU_ARCH = x86 # XXX fixme
|
||||
GFX_ARCH = win32
|
||||
|
||||
OS_CFLAGS = -DXP_PC -DWIN32 -D_WINDOWS -D_WIN32
|
||||
OS_LIBS = -lm -lc
|
||||
|
||||
PREBUILT_CPUCFG = 1
|
||||
USE_MSVC = 1
|
||||
|
||||
LIB_LINK_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib oldnames.lib /nologo\
|
||||
/subsystem:windows /dll /incremental:yes /debug\
|
||||
/machine:I386
|
||||
|
||||
CAFEDIR = t:/cafe
|
||||
JCLASSPATH = $(CAFEDIR)/Java/Lib/classes.zip
|
||||
JAVAC = $(CAFEDIR)/Bin/sj.exe
|
||||
JAVAH = $(CAFEDIR)/Java/Bin/javah.exe
|
||||
JCFLAGS = -I$(CAFEDIR)/Java/Include -I$(CAFEDIR)/Java/Include/win32
|
||||
@@ -1,42 +0,0 @@
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
|
||||
AS = as
|
||||
CC = gcc
|
||||
CCC = g++
|
||||
|
||||
RANLIB = echo
|
||||
|
||||
#
|
||||
# _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
|
||||
OS_LIBS = -lsocket -lnsl
|
||||
|
||||
NOSUCHFILE = /no-such-file
|
||||
@@ -1,30 +0,0 @@
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
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
|
||||
@@ -25,13 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsprf.h"
|
||||
@@ -74,8 +68,21 @@
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <io.h> /* for isatty() */
|
||||
#endif
|
||||
|
||||
FILE *gErrFile = NULL;
|
||||
FILE *gOutFile = NULL;
|
||||
|
||||
#ifdef XP_MAC
|
||||
#ifdef MAC_TEST_HACK
|
||||
/* this is the data file that all Print strings will be echoed into */
|
||||
FILE *gTestResultFile = NULL;
|
||||
#define isatty(f) 0
|
||||
#else
|
||||
#define isatty(f) 1
|
||||
#endif
|
||||
|
||||
#include <SIOUX.h>
|
||||
#include <MacTypes.h>
|
||||
@@ -161,7 +168,7 @@ Process(JSContext *cx, JSObject *obj, char *filename)
|
||||
js_InitCodeGenerator(cx, &cg, ts->filename, ts->lineno, ts->principals);
|
||||
do {
|
||||
if (ts->flags & TSF_INTERACTIVE)
|
||||
printf("js> ");
|
||||
fprintf(gOutFile, "js> ");
|
||||
ok = js_CompileTokenStream(cx, obj, ts, &cg);
|
||||
if (ts->flags & TSF_ERROR) {
|
||||
ts->flags &= ~TSF_ERROR;
|
||||
@@ -170,50 +177,51 @@ Process(JSContext *cx, JSObject *obj, char *filename)
|
||||
}
|
||||
} while (ok && !(ts->flags & TSF_EOF) && CG_OFFSET(&cg) == 0);
|
||||
if (ok) {
|
||||
/*
|
||||
* Clear any pending exception, either from previous failed
|
||||
* compiles, or from the last round of execution.
|
||||
*/
|
||||
/* Clear any pending exception from previous failed compiles. */
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
script = js_NewScriptFromCG(cx, &cg, NULL);
|
||||
if (script) {
|
||||
if (JS_ExecuteScript(cx, obj, script, &result) &&
|
||||
JSErrorReporter older;
|
||||
|
||||
ok = JS_ExecuteScript(cx, obj, script, &result);
|
||||
if (ok &&
|
||||
(ts->flags & TSF_INTERACTIVE) &&
|
||||
result != JSVAL_VOID) {
|
||||
/*
|
||||
* If JS_ValueToString generates an error, suppress
|
||||
* the report and print the exception below.
|
||||
*/
|
||||
older = JS_SetErrorReporter(cx, NULL);
|
||||
str = JS_ValueToString(cx, result);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
|
||||
if (str)
|
||||
printf("%s\n", JS_GetStringBytes(str));
|
||||
fprintf(gOutFile, "%s\n", JS_GetStringBytes(str));
|
||||
else
|
||||
ok = JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_IsExceptionPending(cx) &&
|
||||
JS_GetPendingException(cx, &result))
|
||||
{
|
||||
/*
|
||||
* Calling JS_ValueToString could cause another error (and
|
||||
* throw an associated exception) - so we disable the error
|
||||
* reporter so nothing gets reported, and we always clear
|
||||
* the pending exception... which might be different than
|
||||
* the one we just got in &result.
|
||||
*/
|
||||
JSErrorReporter older;
|
||||
older = JS_SetErrorReporter(cx, NULL);
|
||||
str = JS_ValueToString(cx, result);
|
||||
JS_SetErrorReporter(cx, older);
|
||||
#if JS_HAS_ERROR_EXCEPTIONS
|
||||
#if 0
|
||||
/*
|
||||
* Require that any time we return failure, an exception has
|
||||
* been set.
|
||||
*/
|
||||
JS_ASSERT(ok || JS_IsExceptionPending(cx));
|
||||
|
||||
/* XXX non-i18nized strings... */
|
||||
if (str) {
|
||||
fprintf(stderr, "Uncaught JavaScript exception:\n%s\n",
|
||||
JS_GetStringBytes(str));
|
||||
} else {
|
||||
fprintf(stderr, "Uncaught JavaScript exception\n");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Also that any time an exception has been set, we've
|
||||
* returned failure.
|
||||
*/
|
||||
JS_ASSERT(!JS_IsExceptionPending(cx) || !ok);
|
||||
#endif
|
||||
#endif /* JS_HAS_ERROR_EXCEPTIONS */
|
||||
JS_DestroyScript(cx, script);
|
||||
}
|
||||
}
|
||||
cg.firstLine = ts->lineno;
|
||||
js_ResetCodeGenerator(cx, &cg);
|
||||
js_FinishCodeGenerator(cx, &cg);
|
||||
RESET_TOKENBUF(ts);
|
||||
} while (!(ts->flags & TSF_EOF));
|
||||
|
||||
@@ -227,8 +235,8 @@ out:
|
||||
static int
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "%s\n", JS_GetImplementationVersion());
|
||||
fprintf(stderr, "usage: js [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n");
|
||||
fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
|
||||
fprintf(gErrFile, "usage: js [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -241,6 +249,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
||||
jsval *vector;
|
||||
jsval *p;
|
||||
JSObject *argsObj;
|
||||
JSBool isInteractive = JS_TRUE;
|
||||
|
||||
for (i=0; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
@@ -265,6 +274,12 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
||||
if (filename[0] == '-' && filename[1] == '\0')
|
||||
filename = NULL;
|
||||
Process(cx, obj, filename);
|
||||
filename = NULL;
|
||||
/* XXX: js -f foo.js should interpret foo.js and then
|
||||
* drop into interactive mode, but that breaks test
|
||||
* harness. Just execute foo.js for now.
|
||||
*/
|
||||
isInteractive = JS_FALSE;
|
||||
i++;
|
||||
break;
|
||||
default:
|
||||
@@ -272,6 +287,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
||||
}
|
||||
} else {
|
||||
filename = argv[i++];
|
||||
isInteractive = JS_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -299,7 +315,8 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
|
||||
OBJECT_TO_JSVAL(argsObj), NULL, NULL, 0))
|
||||
return 1;
|
||||
|
||||
Process(cx, obj, filename);
|
||||
if (filename || isInteractive)
|
||||
Process(cx, obj, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -314,6 +331,9 @@ Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
my_LoadErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
|
||||
static void
|
||||
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);
|
||||
|
||||
@@ -329,6 +349,7 @@ Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
JSScript *script;
|
||||
JSBool ok;
|
||||
jsval result;
|
||||
JSErrorReporter older;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
@@ -337,14 +358,19 @@ Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
errno = 0;
|
||||
older = JS_SetErrorReporter(cx, my_LoadErrorReporter);
|
||||
script = JS_CompileFile(cx, obj, filename);
|
||||
if (!script)
|
||||
continue;
|
||||
ok = JS_ExecuteScript(cx, obj, script, &result);
|
||||
JS_DestroyScript(cx, script);
|
||||
ok = JS_FALSE;
|
||||
else {
|
||||
ok = JS_ExecuteScript(cx, obj, script, &result);
|
||||
JS_DestroyScript(cx, script);
|
||||
}
|
||||
JS_SetErrorReporter(cx, older);
|
||||
if (!ok)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -358,11 +384,11 @@ Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
printf("%s%s", i ? " " : "", JS_GetStringBytes(str));
|
||||
n++;
|
||||
fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
|
||||
}
|
||||
n++;
|
||||
if (n)
|
||||
putchar('\n');
|
||||
fputc('\n', gOutFile);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -396,7 +422,7 @@ GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
char *name = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
|
||||
FILE *file = fopen(name, "w");
|
||||
if (!file) {
|
||||
fprintf(stderr, "gc: can't open %s: %s\n", strerror(errno));
|
||||
fprintf(gErrFile, "gc: can't open %s: %s\n", strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
js_DumpGCHeap = file;
|
||||
@@ -410,7 +436,7 @@ GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
fclose(js_DumpGCHeap);
|
||||
js_DumpGCHeap = NULL;
|
||||
#endif
|
||||
printf("before %lu, after %lu, break %08lx\n",
|
||||
fprintf(gOutFile, "before %lu, after %lu, break %08lx\n",
|
||||
(unsigned long)preBytes, (unsigned long)rt->gcBytes,
|
||||
#ifdef XP_UNIX
|
||||
(unsigned long)sbrk(0)
|
||||
@@ -555,27 +581,27 @@ SrcNotes(JSContext *cx, JSFunction *fun )
|
||||
|
||||
notes = fun->script->notes;
|
||||
if (notes) {
|
||||
printf("\nSource notes:\n");
|
||||
fprintf(gOutFile, "\nSource notes:\n");
|
||||
offset = 0;
|
||||
for (sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
|
||||
delta = SN_DELTA(sn);
|
||||
offset += delta;
|
||||
printf("%3u: %5u [%4u] %-8s",
|
||||
fprintf(gOutFile, "%3u: %5u [%4u] %-8s",
|
||||
sn - notes, offset, delta, js_SrcNoteName[SN_TYPE(sn)]);
|
||||
type = SN_TYPE(sn);
|
||||
switch (type) {
|
||||
case SRC_SETLINE:
|
||||
printf(" lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
fprintf(gOutFile, " lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
break;
|
||||
case SRC_FOR:
|
||||
printf(" cond %u update %u tail %u",
|
||||
fprintf(gOutFile, " cond %u update %u tail %u",
|
||||
(uintN) js_GetSrcNoteOffset(sn, 0),
|
||||
(uintN) js_GetSrcNoteOffset(sn, 1),
|
||||
(uintN) js_GetSrcNoteOffset(sn, 2));
|
||||
break;
|
||||
case SRC_PCBASE:
|
||||
case SRC_PCDELTA:
|
||||
printf(" offset %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
fprintf(gOutFile, " offset %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
break;
|
||||
case SRC_LABEL:
|
||||
case SRC_LABELBRACE:
|
||||
@@ -584,22 +610,22 @@ SrcNotes(JSContext *cx, JSFunction *fun )
|
||||
case SRC_FUNCDEF:
|
||||
atomIndex = (jsatomid) js_GetSrcNoteOffset(sn, 0);
|
||||
atom = js_GetAtom(cx, &fun->script->atomMap, atomIndex);
|
||||
printf(" atom %u (%s)", (uintN)atomIndex, ATOM_BYTES(atom));
|
||||
fprintf(gOutFile, " atom %u (%s)", (uintN)atomIndex, ATOM_BYTES(atom));
|
||||
break;
|
||||
case SRC_SWITCH:
|
||||
printf(" length %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
fprintf(gOutFile, " length %u", (uintN) js_GetSrcNoteOffset(sn, 0));
|
||||
caseOff = (uintN) js_GetSrcNoteOffset(sn, 1);
|
||||
if (caseOff)
|
||||
printf(" first case offset %u", caseOff);
|
||||
fprintf(gOutFile, " first case offset %u", caseOff);
|
||||
break;
|
||||
case SRC_CATCH:
|
||||
delta = (uintN) js_GetSrcNoteOffset(sn, 0);
|
||||
if (delta)
|
||||
printf(" guard size %u", delta);
|
||||
fprintf(gOutFile, " guard size %u", delta);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
putchar('\n');
|
||||
fputc('\n', gOutFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,9 +653,9 @@ TryNotes(JSContext *cx, JSFunction *fun)
|
||||
|
||||
if (!tn)
|
||||
return JS_TRUE;
|
||||
printf("\nException table:\nstart\tend\tcatch\n");
|
||||
fprintf(gOutFile, "\nException table:\nstart\tend\tcatch\n");
|
||||
while (tn->start && tn->catchStart) {
|
||||
printf(" %d\t%d\t%d\n",
|
||||
fprintf(gOutFile, " %d\t%d\t%d\n",
|
||||
tn->start, tn->length, tn->catchStart);
|
||||
tn++;
|
||||
}
|
||||
@@ -708,11 +734,11 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
||||
if (line2 < line1) {
|
||||
if (bupline != line2) {
|
||||
bupline = line2;
|
||||
printf("%s %3u: BACKUP\n", sep, line2);
|
||||
fprintf(gOutFile, "%s %3u: BACKUP\n", sep, line2);
|
||||
}
|
||||
} else {
|
||||
if (bupline && line1 == line2)
|
||||
printf("%s %3u: RESTORE\n", sep, line2);
|
||||
fprintf(gOutFile, "%s %3u: RESTORE\n", sep, line2);
|
||||
bupline = 0;
|
||||
while (line1 < line2) {
|
||||
if (!fgets(linebuf, LINE_BUF_LEN, file)) {
|
||||
@@ -722,7 +748,7 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
||||
goto bail;
|
||||
}
|
||||
line1++;
|
||||
printf("%s %3u: %s", sep, line1, linebuf);
|
||||
fprintf(gOutFile, "%s %3u: %s", sep, line1, linebuf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,7 +790,7 @@ Tracing(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
str = JS_ValueToString(cx, argv[0]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
fprintf(stderr, "tracing: illegal argument %s\n",
|
||||
fprintf(gErrFile, "tracing: illegal argument %s\n",
|
||||
JS_GetStringBytes(str));
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -827,8 +853,8 @@ DumpScope(JSContext *cx, JSObject *obj, JSHashEnumerator dump, FILE *fp)
|
||||
}
|
||||
|
||||
/* These are callable from gdb. */
|
||||
void Dsym(JSSymbol *sym) { if (sym) DumpSymbol(&sym->entry, 0, stderr); }
|
||||
void Datom(JSAtom *atom) { if (atom) DumpAtom(&atom->entry, 0, stderr); }
|
||||
void Dsym(JSSymbol *sym) { if (sym) DumpSymbol(&sym->entry, 0, gErrFile); }
|
||||
void Datom(JSAtom *atom) { if (atom) DumpAtom(&atom->entry, 0, gErrFile); }
|
||||
|
||||
static JSBool
|
||||
DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
@@ -851,7 +877,7 @@ DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
JS_DumpArenaStats(stdout);
|
||||
#endif
|
||||
} else if (strcmp(bytes, "atom") == 0) {
|
||||
printf("\natom table contents:\n");
|
||||
fprintf(gOutFile, "\natom table contents:\n");
|
||||
JS_HashTableDump(cx->runtime->atomState.table, DumpAtom, stdout);
|
||||
} else if (strcmp(bytes, "global") == 0) {
|
||||
DumpScope(cx, cx->globalObject, DumpSymbol, stdout);
|
||||
@@ -867,7 +893,7 @@ DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!prop || !JSVAL_IS_OBJECT(value)) {
|
||||
fprintf(stderr, "js: invalid stats argument %s\n",
|
||||
fprintf(gErrFile, "js: invalid stats argument %s\n",
|
||||
bytes);
|
||||
continue;
|
||||
}
|
||||
@@ -938,8 +964,8 @@ ConvertArgs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
&v)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
printf("b %u, c %x (%c), i %ld, u %lu, j %ld\n", b, c, (char)c, i, u, j);
|
||||
printf("d %g, I %g, s %s, S %s, obj %s, fun %s, v %s\n",
|
||||
fprintf(gOutFile, "b %u, c %x (%c), i %ld, u %lu, j %ld\n", b, c, (char)c, i, u, j);
|
||||
fprintf(gOutFile, "d %g, I %g, s %s, S %s, obj %s, fun %s, v %s\n",
|
||||
d, I, s, JS_GetStringBytes(str),
|
||||
JS_GetStringBytes(JS_ValueToString(cx, OBJECT_TO_JSVAL(obj))),
|
||||
JS_GetStringBytes(JS_DecompileFunction(cx, fun, 4)),
|
||||
@@ -948,6 +974,13 @@ ConvertArgs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSBool
|
||||
BuildDate(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
fprintf(gOutFile, "built on %s at %s\n", __DATE__, __TIME__);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec shell_functions[] = {
|
||||
{"version", Version, 0},
|
||||
{"load", Load, 1},
|
||||
@@ -972,6 +1005,7 @@ static JSFunctionSpec shell_functions[] = {
|
||||
#ifdef TEST_CVTARGS
|
||||
{"cvtargs", ConvertArgs, 0, 0, 12},
|
||||
#endif
|
||||
{"build", BuildDate, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
@@ -1001,20 +1035,21 @@ static char *shell_help_messages[] = {
|
||||
#ifdef TEST_CVTARGS
|
||||
"cvtargs b c ... Test JS_ConvertArguments",
|
||||
#endif
|
||||
"build Show build date and time",
|
||||
0
|
||||
};
|
||||
|
||||
static void
|
||||
ShowHelpHeader(void)
|
||||
{
|
||||
printf("%-9s %-22s %s\n", "Command", "Usage", "Description");
|
||||
printf("%-9s %-22s %s\n", "=======", "=====", "===========");
|
||||
fprintf(gOutFile, "%-9s %-22s %s\n", "Command", "Usage", "Description");
|
||||
fprintf(gOutFile, "%-9s %-22s %s\n", "=======", "=====", "===========");
|
||||
}
|
||||
|
||||
static void
|
||||
ShowHelpForCommand(uintN n)
|
||||
{
|
||||
printf("%-9.9s %s\n", shell_functions[n].name, shell_help_messages[n]);
|
||||
fprintf(gOutFile, "%-9.9s %s\n", shell_functions[n].name, shell_help_messages[n]);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -1027,7 +1062,7 @@ Help(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
JSString *str;
|
||||
const char *bytes;
|
||||
|
||||
printf("%s\n", JS_GetImplementationVersion());
|
||||
fprintf(gOutFile, "%s\n", JS_GetImplementationVersion());
|
||||
if (argc == 0) {
|
||||
ShowHelpHeader();
|
||||
for (i = 0; shell_functions[i].name; i++)
|
||||
@@ -1063,7 +1098,7 @@ Help(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
fprintf(stderr, "Sorry, no help for %s\n",
|
||||
fprintf(gErrFile, "Sorry, no help for %s\n",
|
||||
JS_GetStringBytes(str));
|
||||
}
|
||||
}
|
||||
@@ -1096,9 +1131,6 @@ static JSPropertySpec its_props[] = {
|
||||
* 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.
|
||||
*
|
||||
* XXX At some future point JSD will understand Unicode source and the
|
||||
* *very* ugly conversion below will be unnecessary.
|
||||
*/
|
||||
static void
|
||||
SendSourceToJSDebugger(const char *filename, uintN lineno,
|
||||
@@ -1121,26 +1153,8 @@ SendSourceToJSDebugger(const char *filename, uintN lineno,
|
||||
}
|
||||
}
|
||||
if (jsdsrc) {
|
||||
/* here we convert our Unicode into a C string to pass to JSD */
|
||||
#define JSD_BUF_SIZE 1024
|
||||
static char* buf = NULL;
|
||||
int remaining = length;
|
||||
|
||||
if (!buf)
|
||||
buf = malloc(JSD_BUF_SIZE);
|
||||
if (buf)
|
||||
{
|
||||
while (remaining && jsdsrc) {
|
||||
int bytes = JS_MIN(remaining, JSD_BUF_SIZE);
|
||||
int i;
|
||||
for (i = 0; i < bytes; i++)
|
||||
buf[i] = (const char) *(str++);
|
||||
jsdsrc = JSD_AppendSourceText(jsdc,jsdsrc,
|
||||
buf, bytes,
|
||||
JSD_SOURCE_PARTIAL);
|
||||
remaining -= bytes;
|
||||
}
|
||||
}
|
||||
jsdsrc = JSD_AppendUCSourceText(jsdc,jsdsrc, str, length,
|
||||
JSD_SOURCE_PARTIAL);
|
||||
}
|
||||
*listenerTSData = jsdsrc;
|
||||
}
|
||||
@@ -1152,9 +1166,9 @@ static JSBool
|
||||
its_addProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (its_noisy) {
|
||||
printf("adding its property %s,",
|
||||
fprintf(gOutFile, "adding its property %s,",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, id)));
|
||||
printf(" initial value %s\n",
|
||||
fprintf(gOutFile, " initial value %s\n",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
|
||||
}
|
||||
return JS_TRUE;
|
||||
@@ -1164,9 +1178,9 @@ static JSBool
|
||||
its_delProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (its_noisy) {
|
||||
printf("deleting its property %s,",
|
||||
fprintf(gOutFile, "deleting its property %s,",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, id)));
|
||||
printf(" current value %s\n",
|
||||
fprintf(gOutFile, " current value %s\n",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
|
||||
}
|
||||
return JS_TRUE;
|
||||
@@ -1176,9 +1190,9 @@ static JSBool
|
||||
its_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (its_noisy) {
|
||||
printf("getting its property %s,",
|
||||
fprintf(gOutFile, "getting its property %s,",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, id)));
|
||||
printf(" current value %s\n",
|
||||
fprintf(gOutFile, " current value %s\n",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
|
||||
}
|
||||
return JS_TRUE;
|
||||
@@ -1188,9 +1202,9 @@ static JSBool
|
||||
its_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
if (its_noisy) {
|
||||
printf("setting its property %s,",
|
||||
fprintf(gOutFile, "setting its property %s,",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, id)));
|
||||
printf(" new value %s\n",
|
||||
fprintf(gOutFile, " new value %s\n",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
|
||||
}
|
||||
if (JSVAL_IS_STRING(id) &&
|
||||
@@ -1204,7 +1218,7 @@ static JSBool
|
||||
its_enumerate(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
if (its_noisy)
|
||||
printf("enumerate its properties\n");
|
||||
fprintf(gOutFile, "enumerate its properties\n");
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1226,7 @@ static JSBool
|
||||
its_resolve(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
if (its_noisy) {
|
||||
printf("resolving its property %s\n",
|
||||
fprintf(gOutFile, "resolving its property %s\n",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, id)));
|
||||
}
|
||||
return JS_TRUE;
|
||||
@@ -1222,7 +1236,7 @@ static JSBool
|
||||
its_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||
{
|
||||
if (its_noisy)
|
||||
printf("converting it to %s type\n", JS_GetTypeName(cx, type));
|
||||
fprintf(gOutFile, "converting it to %s type\n", JS_GetTypeName(cx, type));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -1230,7 +1244,7 @@ static void
|
||||
its_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
if (its_noisy)
|
||||
printf("finalizing it\n");
|
||||
fprintf(gOutFile, "finalizing it\n");
|
||||
}
|
||||
|
||||
static JSClass its_class = {
|
||||
@@ -1260,6 +1274,22 @@ my_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
my_LoadErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
if (!report) {
|
||||
fprintf(gErrFile, "%s\n", message);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ignore any exceptions */
|
||||
if (JSREPORT_IS_EXCEPTION(report->flags))
|
||||
return;
|
||||
|
||||
/* Otherwise, fall back to the ordinary error reporter. */
|
||||
my_ErrorReporter(cx, message, report);
|
||||
}
|
||||
|
||||
static void
|
||||
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
@@ -1267,19 +1297,13 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
char *prefix = NULL, *tmp;
|
||||
|
||||
if (!report) {
|
||||
fprintf(stderr, "%s\n", message);
|
||||
fprintf(gErrFile, "%s\n", message);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Conditionally ignore reported warnings, and ignore error reports for
|
||||
* which a JavaScript exception has been thrown, except when we're in
|
||||
* a toplevel compile.
|
||||
*/
|
||||
if ((JSREPORT_IS_WARNING(report->flags) && !reportWarnings) ||
|
||||
(JSREPORT_IS_EXCEPTION(report->flags) && cx->interpLevel > 0)) {
|
||||
/* Conditionally ignore reported warnings. */
|
||||
if ((JSREPORT_IS_WARNING(report->flags) && !reportWarnings))
|
||||
return;
|
||||
}
|
||||
|
||||
if (report->filename)
|
||||
prefix = JS_smprintf("%s:", report->filename);
|
||||
@@ -1295,33 +1319,35 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
}
|
||||
|
||||
/* embedded newlines -- argh! */
|
||||
while ((tmp = strchr(message, '\n'))) {
|
||||
while ((tmp = strchr(message, '\n')) != 0) {
|
||||
tmp++;
|
||||
if (prefix) fputs(prefix, stderr);
|
||||
fwrite(message, 1, tmp - message, stderr);
|
||||
if (prefix) fputs(prefix, gErrFile);
|
||||
fwrite(message, 1, tmp - message, gErrFile);
|
||||
message = tmp;
|
||||
}
|
||||
/* If there were no filename or lineno, the prefix might be empty */
|
||||
if (prefix) fputs(prefix, stderr);
|
||||
fputs(message, stderr);
|
||||
if (prefix)
|
||||
fputs(prefix, gErrFile);
|
||||
fputs(message, gErrFile);
|
||||
|
||||
if (!report->linebuf) {
|
||||
putc('\n', stderr);
|
||||
fputc('\n', gErrFile);
|
||||
goto out;
|
||||
}
|
||||
|
||||
fprintf(stderr, ":\n%s%s\n%s", prefix, report->linebuf, prefix);
|
||||
fprintf(gErrFile, ":\n%s%s\n%s", prefix, report->linebuf, prefix);
|
||||
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);
|
||||
for (k = (j + 8) & ~7; j < k; j++) {
|
||||
fputc('.', gErrFile);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
putc('.', stderr);
|
||||
fputc('.', gErrFile);
|
||||
j++;
|
||||
}
|
||||
fputs("^\n", stderr);
|
||||
fputs("^\n", gErrFile);
|
||||
out:
|
||||
JS_free(cx, prefix);
|
||||
}
|
||||
@@ -1454,10 +1480,44 @@ main(int argc, char **argv)
|
||||
setbuf(stderr,0);
|
||||
#endif
|
||||
|
||||
gErrFile = stderr;
|
||||
gOutFile = stdout;
|
||||
|
||||
#ifdef XP_MAC
|
||||
initConsole("\pJavaScript Shell", "Welcome to js shell.", &argc, &argv);
|
||||
#endif
|
||||
|
||||
#ifdef MAC_TEST_HACK
|
||||
/*
|
||||
Open a file "testArgs.txt" and read each line into argc/argv.
|
||||
Re-direct all output to "results.txt"
|
||||
*/
|
||||
{
|
||||
char argText[256];
|
||||
FILE *f = fopen("testargs.txt", "r");
|
||||
if (f != NULL) {
|
||||
int maxArgs = 32; /* arbitrary max !!! */
|
||||
argc = 1;
|
||||
argv = malloc(sizeof(char *) * maxArgs);
|
||||
argv[0] = NULL;
|
||||
while (fgets(argText, 255, f) != NULL) {
|
||||
/* argText includes '\n' */
|
||||
argv[argc] = malloc(strlen(argText));
|
||||
strncpy(argv[argc], argText,
|
||||
strlen(argText) - 1);
|
||||
argv[argc][strlen(argText) - 1] = '\0';
|
||||
argc++;
|
||||
if (argc >= maxArgs) break;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
gTestResultFile = fopen("results.txt", "w");
|
||||
}
|
||||
|
||||
gErrFile = gTestResultFile;
|
||||
gOutFile = gTestResultFile;
|
||||
#endif
|
||||
|
||||
version = JSVERSION_DEFAULT;
|
||||
|
||||
argc--;
|
||||
@@ -1538,6 +1598,10 @@ main(int argc, char **argv)
|
||||
JSD_DebuggerOff(_jsdc);
|
||||
#endif /* JSDEBUGGER */
|
||||
|
||||
#ifdef MAC_TEST_HACK
|
||||
fclose(gTestResultFile);
|
||||
#endif
|
||||
|
||||
JS_DestroyContext(cx);
|
||||
JS_DestroyRuntime(rt);
|
||||
JS_ShutDown();
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="jsshell" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=jsshell - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js.mak" CFG="jsshell - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "jsshell - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "jsshell - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "jsshell - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\jsshell_"
|
||||
# PROP BASE Intermediate_Dir ".\jsshell_"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "mininspr" /D "NDEBUG" /D "_CONSOLE" /D "_WIN32" /D "WIN32" /D "XP_PC" /D "_WINDOWS" /D "JSFILE" /D "MINI_NSPR" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:".\Release\jsshell.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "jsshell - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\jsshell0"
|
||||
# PROP BASE Intermediate_Dir ".\jsshell0"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "mininspr" /D "_DEBUG" /D "DEBUG" /D "_CONSOLE" /D "_WIN32" /D "WIN32" /D "XP_PC" /D "_WINDOWS" /D "JSFILE" /D "MINI_NSPR" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:".\Debug\jsshell.exe"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "jsshell - Win32 Release"
|
||||
# Name "jsshell - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\js.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsatom.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jscntxt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsdbgapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsemit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsfun.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsgc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsinterp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jslock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsobj.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsopcode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsparse.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsprvtd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jspubtd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsregexp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscan.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscope.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscript.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsstddef.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsstr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prarena.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -1,56 +0,0 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 5.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "js32"=.\js32.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "jsshell"=.\js.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name js32
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "miniNSPR"=.\miniNSPR.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -192,3 +192,15 @@ MSG_DEF(JSMSG_RESERVED_ID, 132, 1, JSEXN_SYNTAXERR, "{0} is a reserve
|
||||
MSG_DEF(JSMSG_SYNTAX_ERROR, 133, 0, JSEXN_SYNTAXERR, "syntax error")
|
||||
MSG_DEF(JSMSG_BAD_SHARP_VAR_DEF, 134, 0, JSEXN_SYNTAXERR, "invalid sharp variable definition")
|
||||
MSG_DEF(JSMSG_BAD_PROTOTYPE, 135, 1, JSEXN_ERR, "'prototype' property of {0} is not an object")
|
||||
MSG_DEF(JSMSG_MISSING_EXPONENT, 136, 0, JSEXN_SYNTAXERR, "missing exponent")
|
||||
MSG_DEF(JSMSG_OUT_OF_MEMORY, 137, 0, JSEXN_ERR, "out of memory")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_STRING, 138, 0, JSEXN_SYNTAXERR, "unterminated string literal")
|
||||
MSG_DEF(JSMSG_NESTED_COMMENT, 139, 0, JSEXN_SYNTAXERR, "nested comment")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 140, 0, JSEXN_SYNTAXERR, "unterminated comment")
|
||||
MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal")
|
||||
MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 142, 0, JSEXN_SYNTAXERR, "invalid flag after regular expression")
|
||||
MSG_DEF(JSMSG_SHARPVAR_TOO_BIG, 143, 0, JSEXN_SYNTAXERR, "overlarge sharp variable number")
|
||||
MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 144, 0, JSEXN_SYNTAXERR, "illegal character")
|
||||
MSG_DEF(JSMSG_BAD_OCTAL, 145, 1, JSEXN_NONE, "{0} is not a legal ECMA-262 numeric constant")
|
||||
MSG_DEF(JSMSG_BAD_INDIRECT_CALL, 146, 1, JSEXN_CALLERR, "function {0} must be called directly, and not by way of a function of another name.")
|
||||
MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 147, 1, JSEXN_NONE, "uncaught exception: {0}")
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
; 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.
|
||||
LIBRARY JS1640.DLL
|
||||
EXETYPE WINDOWS
|
||||
PROTMODE
|
||||
|
||||
DESCRIPTION 'Netscape 16-bit JavaScript Library'
|
||||
|
||||
CODE LOADONCALL MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE SINGLE
|
||||
|
||||
HEAPSIZE 8192
|
||||
|
||||
EXPORTS
|
||||
WEP @1 RESIDENTNAME NONAME
|
||||
_JS_Init = _JS_Init @2
|
||||
_JS_Finish = _JS_Finish @3
|
||||
_JS_GetNaNValue
|
||||
_JS_GetNegativeInfinityValue
|
||||
_JS_GetPositiveInfinityValue
|
||||
_JS_GetEmptyStringValue
|
||||
_JS_ConvertValue
|
||||
_JS_ValueToObject
|
||||
_JS_ValueToFunction
|
||||
_JS_ValueToString
|
||||
_JS_ValueToNumber
|
||||
_JS_ValueToBoolean
|
||||
_JS_TypeOfValue
|
||||
_JS_GetTypeName
|
||||
_JS_Lock
|
||||
_JS_Unlock
|
||||
_JS_NewContext
|
||||
_JS_DestroyContext
|
||||
_JS_ContextIterator
|
||||
_JS_GetGlobalObject
|
||||
_JS_SetGlobalObject
|
||||
_JS_InitStandardClasses
|
||||
; _JS_GetStaticLink
|
||||
_JS_malloc
|
||||
_JS_realloc
|
||||
_JS_free
|
||||
_JS_strdup
|
||||
_JS_NewDouble
|
||||
_JS_NewDoubleValue
|
||||
_JS_AddRoot
|
||||
_JS_RemoveRoot
|
||||
_JS_LockGCThing
|
||||
_JS_UnlockGCThing
|
||||
_JS_GC
|
||||
_JS_PropertyStub
|
||||
_JS_EnumerateStub
|
||||
_JS_ResolveStub
|
||||
_JS_ConvertStub
|
||||
_JS_FinalizeStub
|
||||
_JS_InitClass
|
||||
_JS_GetClass
|
||||
_JS_InstanceOf
|
||||
_JS_GetPrivate
|
||||
_JS_SetPrivate
|
||||
_JS_GetInstancePrivate
|
||||
_JS_GetPrototype
|
||||
_JS_GetParent
|
||||
_JS_SetParent
|
||||
_JS_GetConstructor
|
||||
_JS_NewObject
|
||||
_JS_DefineObject
|
||||
_JS_DefineConstDoubles
|
||||
_JS_DefineProperties
|
||||
_JS_DefineProperty
|
||||
_JS_DefinePropertyWithTinyId
|
||||
_JS_AliasProperty
|
||||
_JS_LookupProperty
|
||||
_JS_GetProperty
|
||||
_JS_SetProperty
|
||||
_JS_DeleteProperty
|
||||
_JS_NewArrayObject
|
||||
_JS_DefineElement
|
||||
_JS_AliasElement
|
||||
_JS_LookupElement
|
||||
_JS_GetElement
|
||||
_JS_SetElement
|
||||
_JS_DeleteElement
|
||||
_JS_ClearScope
|
||||
_JS_NewFunction
|
||||
_JS_GetFunctionObject
|
||||
_JS_GetFunctionName
|
||||
_JS_DefineFunctions
|
||||
_JS_DefineFunction
|
||||
_JS_CompileScript
|
||||
_JS_DestroyScript
|
||||
_JS_CompileFunction
|
||||
_JS_DecompileScript
|
||||
_JS_DecompileFunction
|
||||
_JS_DecompileFunctionBody
|
||||
_JS_ExecuteScript
|
||||
_JS_EvaluateScript
|
||||
_JS_CallFunction
|
||||
_JS_CallFunctionName
|
||||
_JS_CallFunctionValue
|
||||
_JS_SetBranchCallback
|
||||
_JS_IsRunning
|
||||
_JS_NewString
|
||||
_JS_NewStringCopyN
|
||||
_JS_NewStringCopyZ
|
||||
_JS_InternString
|
||||
_JS_GetStringBytes
|
||||
_JS_GetStringLength
|
||||
_JS_CompareStrings
|
||||
_JS_ReportError
|
||||
_JS_ReportOutOfMemory
|
||||
_JS_SetErrorReporter
|
||||
_JS_NewRegExpObject
|
||||
_JS_SetRegExpInput
|
||||
_JS_ClearRegExpStatics
|
||||
|
||||
IMPORTS
|
||||
_printf = nspr21.11
|
||||
_strftime = nspr21.13
|
||||
@@ -1,137 +0,0 @@
|
||||
LIBRARY JS1640.DLL
|
||||
EXETYPE WINDOWS
|
||||
PROTMODE
|
||||
|
||||
DESCRIPTION 'Netscape 16-bit JavaScript Library'
|
||||
|
||||
CODE LOADONCALL MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE SINGLE
|
||||
|
||||
HEAPSIZE 8192
|
||||
|
||||
EXPORTS
|
||||
WEP @1 RESIDENTNAME NONAME
|
||||
_JS_Init = _JS_Init @2
|
||||
_JS_Finish = _JS_Finish @3
|
||||
_JS_GetNaNValue
|
||||
_JS_GetNegativeInfinityValue
|
||||
_JS_GetPositiveInfinityValue
|
||||
_JS_GetEmptyStringValue
|
||||
_JS_ConvertValue
|
||||
_JS_ValueToObject
|
||||
_JS_ValueToFunction
|
||||
_JS_ValueToString
|
||||
_JS_ValueToNumber
|
||||
_JS_ValueToBoolean
|
||||
_JS_TypeOfValue
|
||||
_JS_GetTypeName
|
||||
_JS_Lock
|
||||
_JS_Unlock
|
||||
_JS_NewContext
|
||||
_JS_DestroyContext
|
||||
_JS_ContextIterator
|
||||
_JS_GetGlobalObject
|
||||
_JS_SetGlobalObject
|
||||
_JS_InitStandardClasses
|
||||
; _JS_GetStaticLink
|
||||
_JS_malloc
|
||||
_JS_realloc
|
||||
_JS_free
|
||||
_JS_strdup
|
||||
_JS_NewDouble
|
||||
_JS_NewDoubleValue
|
||||
_JS_AddRoot
|
||||
_JS_RemoveRoot
|
||||
_JS_LockGCThing
|
||||
_JS_UnlockGCThing
|
||||
_JS_GC
|
||||
_JS_PropertyStub
|
||||
_JS_EnumerateStub
|
||||
_JS_ResolveStub
|
||||
_JS_ConvertStub
|
||||
_JS_FinalizeStub
|
||||
_JS_InitClass
|
||||
_JS_GetClass
|
||||
_JS_InstanceOf
|
||||
_JS_GetPrivate
|
||||
_JS_SetPrivate
|
||||
_JS_GetInstancePrivate
|
||||
_JS_GetPrototype
|
||||
_JS_GetParent
|
||||
_JS_SetParent
|
||||
_JS_GetConstructor
|
||||
_JS_NewObject
|
||||
_JS_DefineObject
|
||||
_JS_DefineConstDoubles
|
||||
_JS_DefineProperties
|
||||
_JS_DefineProperty
|
||||
_JS_DefinePropertyWithTinyId
|
||||
_JS_AliasProperty
|
||||
_JS_LookupProperty
|
||||
_JS_GetProperty
|
||||
_JS_SetProperty
|
||||
_JS_DeleteProperty
|
||||
_JS_NewArrayObject
|
||||
_JS_DefineElement
|
||||
_JS_AliasElement
|
||||
_JS_LookupElement
|
||||
_JS_GetElement
|
||||
_JS_SetElement
|
||||
_JS_DeleteElement
|
||||
_JS_ClearScope
|
||||
_JS_NewFunction
|
||||
_JS_GetFunctionObject
|
||||
_JS_GetFunctionName
|
||||
_JS_DefineFunctions
|
||||
_JS_DefineFunction
|
||||
_JS_CompileScript
|
||||
_JS_DestroyScript
|
||||
_JS_CompileFunction
|
||||
_JS_DecompileScript
|
||||
_JS_DecompileFunction
|
||||
_JS_DecompileFunctionBody
|
||||
_JS_ExecuteScript
|
||||
_JS_EvaluateScript
|
||||
_JS_CallFunction
|
||||
_JS_CallFunctionName
|
||||
_JS_CallFunctionValue
|
||||
_JS_SetBranchCallback
|
||||
_JS_IsRunning
|
||||
_JS_NewString
|
||||
_JS_NewStringCopyN
|
||||
_JS_NewStringCopyZ
|
||||
_JS_InternString
|
||||
_JS_GetStringBytes
|
||||
_JS_GetStringLength
|
||||
_JS_CompareStrings
|
||||
_JS_ReportError
|
||||
_JS_ReportOutOfMemory
|
||||
_JS_SetErrorReporter
|
||||
_JS_NewRegExpObject
|
||||
_JS_SetRegExpInput
|
||||
_JS_ClearRegExpStatics
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Version stamp for this .DLL
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ver.h>
|
||||
|
||||
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
|
||||
FILEVERSION 4 // major, minor, release (alpha 1), build #
|
||||
|
||||
PRODUCTVERSION 4
|
||||
|
||||
FILEFLAGSMASK 0
|
||||
|
||||
FILEFLAGS 0 // final version
|
||||
|
||||
FILEOS VOS_DOS_WINDOWS16
|
||||
|
||||
FILETYPE VFT_DLL
|
||||
|
||||
FILESUBTYPE 0 // not used
|
||||
|
||||
BEGIN
|
||||
|
||||
BLOCK "StringFileInfo"
|
||||
|
||||
BEGIN
|
||||
|
||||
BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
|
||||
|
||||
BEGIN
|
||||
|
||||
VALUE "CompanyName", "Netscape Communications Corporation\0"
|
||||
|
||||
VALUE "FileDescription", "Netscape 16-bit JavaScript Module\0"
|
||||
|
||||
VALUE "FileVersion", "4.0\0"
|
||||
|
||||
VALUE "InternalName", "JS1640\0"
|
||||
|
||||
VALUE "LegalCopyright", "Copyright Netscape Communications. 1994-96\0"
|
||||
|
||||
VALUE "LegalTrademarks", "Netscape, Mozilla\0"
|
||||
|
||||
VALUE "OriginalFilename","JS1640.DLL\0"
|
||||
|
||||
VALUE "ProductName", "NETSCAPE\0"
|
||||
|
||||
VALUE "ProductVersion", "4.0\0"
|
||||
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
# Microsoft Developer Studio Project File - Name="js32" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=js32 - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js32.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "js32.mak" CFG="js32 - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "js32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "js32 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "js32 - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\js32\Release"
|
||||
# PROP BASE Intermediate_Dir ".\js32\Release"
|
||||
# PROP BASE Target_Dir ".\js32"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ".\js32"
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /I "mininspr" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "WIN32" /D "XP_PC" /D "JSFILE" /D "EXPORT_JS_API" /D "MINI_NSPR" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
# ADD LINK32 H:\ns\dist\WINNT4.0_OPT.OBJ\lib\libnspr21_s.lib H:\ns\dist\WINNT4.0_OPT.OBJ\lib\libplds21_s.lib winmm.lib mswsock.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "js32 - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\js32\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\js32\Debug"
|
||||
# PROP BASE Target_Dir ".\js32"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ".\js32"
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "mininspr" /D "_DEBUG" /D "DEBUG" /D "_WINDOWS" /D "_WIN32" /D "WIN32" /D "XP_PC" /D "JSFILE" /D "EXPORT_JS_API" /D "MINI_NSPR" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
# ADD LINK32 H:\ns\dist\WINNT4.0_DBG.OBJ\lib\libnspr21_s.lib H:\ns\dist\WINNT4.0_DBG.OBJ\lib\libplds21_s.lib winmm.lib mswsock.lib ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "js32 - Win32 Release"
|
||||
# Name "js32 - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsapi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsarray.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsatom.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsbool.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jscntxt.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsdate.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsdbgapi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsemit.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsfun.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsgc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsinterp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jslock.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsmath.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsnum.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsobj.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsopcode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsparse.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsregexp.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscan.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscope.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscript.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsstr.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsxdrapi.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prarena.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prmjtime.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsarray.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsatom.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsbool.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jscntxt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsconfig.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsdate.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsdbgapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsemit.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsfun.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsgc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsinterp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jslock.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsmath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsnum.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsobj.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsopcode.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsparse.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsprvtd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jspubtd.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsregexp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscan.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscope.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsscript.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsstddef.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsstr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\jsxdrapi.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prarena.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\prdtoa.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -17,25 +17,25 @@
|
||||
* in the importing module's import address table.
|
||||
*/
|
||||
|
||||
IMPLEMENT(JSPropertyOp)
|
||||
JS_EXPORT_API(JSPropertyOp)
|
||||
js_GetArgumentAddress()
|
||||
{
|
||||
return ((void *)js_GetArgument);
|
||||
}
|
||||
|
||||
IMPLEMENT(JSPropertyOp)
|
||||
JS_EXPORT_API(JSPropertyOp)
|
||||
js_SetArgumentAddress()
|
||||
{
|
||||
return ((void *)js_SetArgument);
|
||||
}
|
||||
|
||||
IMPLEMENT(JSPropertyOp)
|
||||
JS_EXPORT_API(JSPropertyOp)
|
||||
js_GetLocalVariableAddress()
|
||||
{
|
||||
return ((void *)js_GetLocalVariable);
|
||||
}
|
||||
|
||||
IMPLEMENT(JSPropertyOp)
|
||||
JS_EXPORT_API(JSPropertyOp)
|
||||
js_SetLocalVariableAddress()
|
||||
{
|
||||
return ((void *)js_SetLocalVariable);
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
#ifndef jsaddr_h___
|
||||
#define jsaddr_h___
|
||||
|
||||
EXTERN(JSPropertyOp)
|
||||
JS_EXTERN_API(JSPropertyOp)
|
||||
js_GetArgumentAddress();
|
||||
|
||||
EXTERN(JSPropertyOp)
|
||||
JS_EXTERN_API(JSPropertyOp)
|
||||
js_SetArgumentAddress();
|
||||
|
||||
EXTERN(JSPropertyOp)
|
||||
JS_EXTERN_API(JSPropertyOp)
|
||||
js_GetLocalVariableAddress();
|
||||
|
||||
EXTERN(JSPropertyOp)
|
||||
JS_EXTERN_API(JSPropertyOp)
|
||||
js_SetLocalVariableAddress();
|
||||
|
||||
#endif /* jsaddr_h___ */
|
||||
|
||||
@@ -25,14 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsclist.h"
|
||||
#include "jsprf.h"
|
||||
@@ -60,6 +53,10 @@
|
||||
#include "jsscript.h"
|
||||
#include "jsstr.h"
|
||||
|
||||
#if JS_HAS_FILE_OBJECT
|
||||
#include "jsfile.h"
|
||||
#endif
|
||||
|
||||
#if defined(JS_PARANOID_REQUEST) && defined(JS_THREADSAFE)
|
||||
#define CHECK_REQUEST(cx) JS_ASSERT(cx->requestDepth)
|
||||
#else
|
||||
@@ -503,7 +500,7 @@ JS_YieldRequest(JSContext *cx)
|
||||
JSRuntime *rt;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
|
||||
rt = cx->runtime;
|
||||
JS_ASSERT(rt->requestCount > 0);
|
||||
rt->requestCount--;
|
||||
JS_NOTIFY_REQUEST_DONE(rt);
|
||||
@@ -612,6 +609,9 @@ JS_SetVersion(JSContext *cx, JSVersion version)
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
oldVersion = cx->version;
|
||||
if (version == oldVersion)
|
||||
return oldVersion;
|
||||
|
||||
cx->version = version;
|
||||
|
||||
#if !JS_BUG_FALLIBLE_EQOPS
|
||||
@@ -635,7 +635,7 @@ JS_SetVersion(JSContext *cx, JSVersion version)
|
||||
JS_PUBLIC_API(const char *)
|
||||
JS_GetImplementationVersion(void)
|
||||
{
|
||||
return "JavaScript-C 1.3 1998 06 30";
|
||||
return "JavaScript-C 1.4 release 1 1998 10 31";
|
||||
}
|
||||
|
||||
|
||||
@@ -688,7 +688,7 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
||||
|
||||
/* Initialize the rest of the standard objects and functions. */
|
||||
return (array_proto = js_InitArrayClass(cx, obj)) != NULL &&
|
||||
js_InitArgsCallClosureClasses(cx, obj, array_proto) &&
|
||||
js_InitArgsCallClosureClasses(cx, obj, obj_proto) &&
|
||||
js_InitBooleanClass(cx, obj) &&
|
||||
js_InitMathClass(cx, obj) &&
|
||||
js_InitNumberClass(cx, obj) &&
|
||||
@@ -701,6 +701,9 @@ JS_InitStandardClasses(JSContext *cx, JSObject *obj)
|
||||
#endif
|
||||
#if JS_HAS_ERROR_EXCEPTIONS
|
||||
js_InitExceptionClasses(cx, obj) &&
|
||||
#endif
|
||||
#if JS_HAS_FILE_OBJECT
|
||||
js_InitFileClass(cx, obj) &&
|
||||
#endif
|
||||
js_InitDateClass(cx, obj);
|
||||
}
|
||||
@@ -717,7 +720,7 @@ JS_malloc(JSContext *cx, size_t nbytes)
|
||||
{
|
||||
void *p;
|
||||
|
||||
#if defined(XP_OS2) || defined(XP_MAC) || defined(AIX)
|
||||
#if defined(XP_OS2) || defined(XP_MAC) || defined(AIX) || defined(OSF1)
|
||||
if (nbytes == 0) /*DSR072897 - Windows allows this, OS/2 & Mac don't*/
|
||||
nbytes = 1;
|
||||
#endif
|
||||
@@ -796,20 +799,14 @@ JS_AddNamedRoot(JSContext *cx, void *rp, const char *name)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
|
||||
typedef struct NamedRootDumpArgs {
|
||||
void (*dump)(const char *name, void *rp, void *data);
|
||||
void *data;
|
||||
} NamedRootDumpArgs;
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_named_root_dumper(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
NamedRootDumpArgs *args = arg;
|
||||
@@ -954,8 +951,7 @@ JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||
if (type == JSTYPE_STRING)
|
||||
return JS_TRUE;
|
||||
#endif
|
||||
js_TryValueOf(cx, obj, type, vp);
|
||||
return JS_TRUE;
|
||||
return js_TryValueOf(cx, obj, type, vp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
@@ -999,6 +995,13 @@ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
|
||||
if (!fun)
|
||||
goto bad;
|
||||
|
||||
/*
|
||||
* Remember the class this function is a constructor for so that
|
||||
* we know to create an object of this class when we call the
|
||||
* constructor.
|
||||
*/
|
||||
fun->clasp = clasp;
|
||||
|
||||
/* Connect constructor and prototype by named properties. */
|
||||
ctor = fun->object;
|
||||
if (!js_SetClassPrototype(cx, ctor, proto,
|
||||
@@ -1876,8 +1879,10 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
|
||||
JSObject *newfunobj;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
if (OBJ_GET_CLASS(cx, funobj) != &js_FunctionClass)
|
||||
return NULL;
|
||||
if (OBJ_GET_CLASS(cx, funobj) != &js_FunctionClass) {
|
||||
/* Indicate we cannot clone this object */
|
||||
return funobj;
|
||||
}
|
||||
fun = JS_GetPrivate(cx, funobj);
|
||||
|
||||
newfunobj = js_NewObject(cx, &js_FunctionClass, funobj, parent);
|
||||
@@ -1954,15 +1959,14 @@ CompileTokenStream(JSContext *cx, JSObject *obj, JSTokenStream *ts,
|
||||
goto out;
|
||||
}
|
||||
script = js_NewScriptFromCG(cx, &cg, NULL);
|
||||
if (!script)
|
||||
goto out;
|
||||
out:
|
||||
if (!js_CloseTokenStream(cx, ts)) {
|
||||
js_DestroyScript(cx, script);
|
||||
if (script)
|
||||
js_DestroyScript(cx, script);
|
||||
script = NULL;
|
||||
}
|
||||
out:
|
||||
cg.tempMark = tempMark;
|
||||
js_ResetCodeGenerator(cx, &cg);
|
||||
js_FinishCodeGenerator(cx, &cg);
|
||||
return script;
|
||||
}
|
||||
|
||||
@@ -2224,15 +2228,32 @@ JS_DecompileFunction(JSContext *cx, JSFunction *fun, uintN indent)
|
||||
JS_PUBLIC_API(JSString *)
|
||||
JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, uintN indent)
|
||||
{
|
||||
JSPrinter *jp;
|
||||
JSString *str;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
return JS_DecompileScript(cx, fun->script, JS_GetFunctionName(fun), indent);
|
||||
jp = js_NewPrinter(cx, JS_GetFunctionName(fun), indent);
|
||||
if (!jp)
|
||||
return NULL;
|
||||
if (js_DecompileFunctionBody(jp, fun, JS_TRUE))
|
||||
str = js_GetPrinterOutput(jp);
|
||||
else
|
||||
str = NULL;
|
||||
js_DestroyPrinter(jp);
|
||||
return str;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_Execute(cx, obj, script, NULL, NULL, JS_FALSE, rval);
|
||||
if (!js_Execute(cx, obj, script, NULL, NULL, JS_FALSE, rval)) {
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
js_ReportUncaughtException(cx);
|
||||
#endif
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
@@ -2300,6 +2321,10 @@ JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
|
||||
if (!script)
|
||||
return JS_FALSE;
|
||||
ok = js_Execute(cx, obj, script, NULL, NULL, JS_FALSE, rval);
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
if (!ok)
|
||||
js_ReportUncaughtException(cx);
|
||||
#endif
|
||||
JS_DestroyScript(cx, script);
|
||||
return ok;
|
||||
}
|
||||
@@ -2309,8 +2334,14 @@ JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc,
|
||||
jsval *argv, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(fun->object),
|
||||
argc, argv, rval);
|
||||
if (!js_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(fun->object),
|
||||
argc, argv, rval)) {
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
js_ReportUncaughtException(cx);
|
||||
#endif
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
@@ -2322,7 +2353,13 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
|
||||
CHECK_REQUEST(cx);
|
||||
if (!JS_GetProperty(cx, obj, name, &fval))
|
||||
return JS_FALSE;
|
||||
return js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
|
||||
if (!js_CallFunctionValue(cx, obj, fval, argc, argv, rval)) {
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
js_ReportUncaughtException(cx);
|
||||
#endif
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
@@ -2330,7 +2367,13 @@ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc,
|
||||
jsval *argv, jsval *rval)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
return js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
|
||||
if (!js_CallFunctionValue(cx, obj, fval, argc, argv, rval)) {
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
js_ReportUncaughtException(cx);
|
||||
#endif
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBranchCallback)
|
||||
@@ -2520,11 +2563,24 @@ JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
|
||||
CHECK_REQUEST(cx);
|
||||
va_start(ap, errorNumber);
|
||||
js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef,
|
||||
errorNumber, ap);
|
||||
errorNumber, JS_TRUE, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback,
|
||||
void *userRef, const uintN errorNumber, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
CHECK_REQUEST(cx);
|
||||
va_start(ap, errorNumber);
|
||||
js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef,
|
||||
errorNumber, JS_FALSE, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_ReportWarning(JSContext *cx, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -2674,6 +2730,60 @@ JS_ClearPendingException(JSContext *cx)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
struct JSExceptionState
|
||||
{
|
||||
JSBool throwing;
|
||||
jsval exception;
|
||||
};
|
||||
#endif
|
||||
|
||||
JS_PUBLIC_API(JSExceptionState *)
|
||||
JS_SaveExceptionState(JSContext *cx)
|
||||
{
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
JSExceptionState *state;
|
||||
CHECK_REQUEST(cx);
|
||||
state = (JSExceptionState*) JS_malloc(cx, sizeof(JSExceptionState));
|
||||
if (state) {
|
||||
state->throwing = JS_GetPendingException(cx, &state->exception);
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
JS_AddRoot(cx, &state->exception);
|
||||
}
|
||||
return state;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state)
|
||||
{
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
CHECK_REQUEST(cx);
|
||||
if (state) {
|
||||
if (state->throwing)
|
||||
JS_SetPendingException(cx, state->exception);
|
||||
else
|
||||
JS_ClearPendingException(cx);
|
||||
JS_DropExceptionState(cx, state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
JS_DropExceptionState(JSContext *cx, JSExceptionState *state)
|
||||
{
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
CHECK_REQUEST(cx);
|
||||
if (state) {
|
||||
if (state->throwing && JSVAL_IS_GCTHING(state->exception))
|
||||
JS_RemoveRoot(cx, &state->exception);
|
||||
JS_free(cx, state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JS_PUBLIC_API(intN)
|
||||
JS_GetContextThread(JSContext *cx)
|
||||
@@ -2700,8 +2810,7 @@ JS_ClearContextThread(JSContext *cx)
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef NETSCAPE_INTERNAL
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_FRIEND_API(JSBool)
|
||||
JS_IsAssigning(JSContext *cx)
|
||||
{
|
||||
JSStackFrame *fp;
|
||||
@@ -2711,7 +2820,6 @@ JS_IsAssigning(JSContext *cx)
|
||||
return JS_FALSE;
|
||||
return (js_CodeSpec[*pc].format & JOF_SET) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
|
||||
@@ -269,10 +269,10 @@ JS_NewContext(JSRuntime *rt, size_t stacksize);
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_DestroyContext(JSContext *cx);
|
||||
|
||||
EXTERN(void*)
|
||||
JS_EXTERN_API(void*)
|
||||
JS_GetContextPrivate(JSContext *cx);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_SetContextPrivate(JSContext *cx, void *data);
|
||||
|
||||
extern JS_PUBLIC_API(JSRuntime *)
|
||||
@@ -500,7 +500,7 @@ JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
|
||||
extern JS_PUBLIC_API(JSClass *)
|
||||
JS_GetClass(JSContext *cx, JSObject *obj);
|
||||
#else
|
||||
JS_PUBLIC_API(JSClass *)
|
||||
extern JS_PUBLIC_API(JSClass *)
|
||||
JS_GetClass(JSObject *obj);
|
||||
#endif
|
||||
|
||||
@@ -928,16 +928,23 @@ extern JS_PUBLIC_API(void)
|
||||
JS_ReportError(JSContext *cx, const char *format, ...);
|
||||
|
||||
/*
|
||||
* As above, but use an errorNumber for the format string
|
||||
* Use an errorNumber to retrieve the format string, args are char *
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
|
||||
void *userRef, const uintN errorNumber, ...);
|
||||
|
||||
/*
|
||||
* Use an errorNumber to retrieve the format string, args are jschar *
|
||||
*/
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback,
|
||||
void *userRef, const uintN errorNumber, ...);
|
||||
|
||||
/*
|
||||
* As above, but report a warning instead (JSREPORT_IS_WARNING(report->flags)).
|
||||
*/
|
||||
EXTERN(void)
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ReportWarning(JSContext *cx, const char *format, ...);
|
||||
|
||||
/*
|
||||
@@ -955,8 +962,8 @@ struct JSErrorReport {
|
||||
const jschar *uctokenptr; /* unicode (original) token pointer */
|
||||
uintN flags; /* error/warning, etc. */
|
||||
uintN errorNumber; /* the error number, e.g. see js.msg */
|
||||
JSString *ucmessage; /* the (default) error message */
|
||||
JSString **messageArgs; /* arguments for the error message */
|
||||
const jschar *ucmessage; /* the (default) error message */
|
||||
const jschar **messageArgs; /* arguments for the error message */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -970,7 +977,7 @@ struct JSErrorReport {
|
||||
/*
|
||||
* If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception
|
||||
* has been thrown for this runtime error, and the host should ignore it.
|
||||
* Exception-aware hosts should also check for JS_IsPendingException if
|
||||
* Exception-aware hosts should also check for JS_IsExceptionPending if
|
||||
* JS_ExecuteScript returns failure, and signal or propagate the exception, as
|
||||
* appropriate.
|
||||
*/
|
||||
@@ -1021,6 +1028,27 @@ JS_SetPendingException(JSContext *cx, jsval v);
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_ClearPendingException(JSContext *cx);
|
||||
|
||||
/*
|
||||
* Save the current exception state. This takes a snapshot of the current
|
||||
* exception state without making any change to that state.
|
||||
*
|
||||
* The returned object MUST be later passed to either JS_RestoreExceptionState
|
||||
* (to restore that saved state) or JS_DropExceptionState (to cleanup the state
|
||||
* object in case it is not desireable to restore to that state). Both
|
||||
* JS_RestoreExceptionState and JS_DropExceptionState will destroy the
|
||||
* JSExceptionState object -- so that object can not be referenced again
|
||||
* after making either of those calls.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API(JSExceptionState *)
|
||||
JS_SaveExceptionState(JSContext *cx);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state);
|
||||
|
||||
extern JS_PUBLIC_API(void)
|
||||
JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
/*
|
||||
* Associate the current thread with the given context. This is done
|
||||
@@ -1044,14 +1072,15 @@ JS_ClearContextThread(JSContext *cx);
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
#ifdef NETSCAPE_INTERNAL
|
||||
/*
|
||||
* Returns true if a script is executing and its current bytecode is a set
|
||||
* (assignment) operation.
|
||||
*
|
||||
* NOTE: Previously conditional on NETSCAPE_INTERNAL. This function may
|
||||
* be removed in the future.
|
||||
*/
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
extern JS_FRIEND_API(JSBool)
|
||||
JS_IsAssigning(JSContext *cx);
|
||||
#endif
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
@@ -26,14 +26,7 @@
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#include "jsbit.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
@@ -52,7 +45,7 @@ static JSArenaStats *arena_stats_list;
|
||||
|
||||
#define JS_ARENA_DEFAULT_ALIGN sizeof(double)
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size, JSUint32 align)
|
||||
{
|
||||
if (align == 0)
|
||||
@@ -71,7 +64,7 @@ JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size, JSUint32 al
|
||||
#endif
|
||||
}
|
||||
|
||||
IMPLEMENT(void *)
|
||||
JS_EXPORT_API(void *)
|
||||
JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb)
|
||||
{
|
||||
JSArena **ap, *a, *b;
|
||||
@@ -127,7 +120,7 @@ JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb)
|
||||
return p;
|
||||
}
|
||||
|
||||
IMPLEMENT(void *)
|
||||
JS_EXPORT_API(void *)
|
||||
JS_ArenaGrow(JSArenaPool *pool, void *p, JSUint32 size, JSUint32 incr)
|
||||
{
|
||||
void *newp;
|
||||
@@ -189,7 +182,7 @@ FreeArenaList(JSArenaPool *pool, JSArena *head, JSBool reallyFree)
|
||||
pool->current = head;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaRelease(JSArenaPool *pool, char *mark)
|
||||
{
|
||||
JSArena *a;
|
||||
@@ -203,14 +196,14 @@ JS_ArenaRelease(JSArenaPool *pool, char *mark)
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_FreeArenaPool(JSArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, JS_FALSE);
|
||||
COUNT(pool, ndeallocs);
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_FinishArenaPool(JSArenaPool *pool)
|
||||
{
|
||||
FreeArenaList(pool, &pool->first, JS_TRUE);
|
||||
@@ -231,7 +224,7 @@ JS_FinishArenaPool(JSArenaPool *pool)
|
||||
#endif
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_CompactArenaPool(JSArenaPool *pool)
|
||||
{
|
||||
#if 0 /* XP_MAC */
|
||||
@@ -245,7 +238,7 @@ JS_CompactArenaPool(JSArenaPool *pool)
|
||||
#endif
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaFinish()
|
||||
{
|
||||
JSArena *a, *next;
|
||||
@@ -267,7 +260,7 @@ JS_ArenaFinish()
|
||||
}
|
||||
|
||||
#ifdef JS_ARENAMETER
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb)
|
||||
{
|
||||
pool->stats.nallocs++;
|
||||
@@ -277,13 +270,13 @@ JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb)
|
||||
pool->stats.variance += nb * nb;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaCountInplaceGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
|
||||
{
|
||||
pool->stats.ninplace++;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
|
||||
{
|
||||
pool->stats.ngrows++;
|
||||
@@ -295,13 +288,13 @@ JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
|
||||
pool->stats.variance += size * size;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaCountRelease(JSArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nreleases++;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_ArenaCountRetract(JSArenaPool *pool, char *mark)
|
||||
{
|
||||
pool->stats.nfastrels++;
|
||||
@@ -310,7 +303,7 @@ JS_ArenaCountRetract(JSArenaPool *pool, char *mark)
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_DumpArenaStats(FILE *fp)
|
||||
{
|
||||
JSArenaStats *stats;
|
||||
|
||||
@@ -167,7 +167,7 @@ struct JSArenaPool {
|
||||
* Initialize an arena pool with the given name for debugging and metering,
|
||||
* with a minimum size per arena of size bytes.
|
||||
*/
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size,
|
||||
JSUint32 align);
|
||||
|
||||
@@ -176,59 +176,59 @@ JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size,
|
||||
* after calling this function. There is no need to call JS_InitArenaPool()
|
||||
* again unless JS_FinishArenaPool(pool) has been called.
|
||||
*/
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_FreeArenaPool(JSArenaPool *pool);
|
||||
|
||||
/*
|
||||
* Free the arenas in pool and finish using it altogether.
|
||||
*/
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_FinishArenaPool(JSArenaPool *pool);
|
||||
|
||||
/*
|
||||
* Compact all of the arenas in a pool so that no space is wasted.
|
||||
*/
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_CompactArenaPool(JSArenaPool *pool);
|
||||
|
||||
/*
|
||||
* Finish using arenas, freeing all memory associated with them.
|
||||
*/
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaFinish(void);
|
||||
|
||||
/*
|
||||
* Friend functions used by the JS_ARENA_*() macros.
|
||||
*/
|
||||
EXTERN(void *)
|
||||
JS_EXTERN_API(void *)
|
||||
JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb);
|
||||
|
||||
EXTERN(void *)
|
||||
JS_EXTERN_API(void *)
|
||||
JS_ArenaGrow(JSArenaPool *pool, void *p, JSUint32 size, JSUint32 incr);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaRelease(JSArenaPool *pool, char *mark);
|
||||
|
||||
#ifdef JS_ARENAMETER
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaCountInplaceGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32incr);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaCountRelease(JSArenaPool *pool, char *mark);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_ArenaCountRetract(JSArenaPool *pool, char *mark);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_DumpArenaStats(FILE *fp);
|
||||
|
||||
#else /* !JS_ARENAMETER */
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
@@ -79,7 +78,7 @@ IdIsIndex(jsid id, jsuint *indexp)
|
||||
if (JS7_ISDEC(*cp) && str->length < sizeof(MAXSTR)) {
|
||||
jsuint index = JS7_UNDEC(*cp++);
|
||||
jsuint oldIndex = 0;
|
||||
jsint c;
|
||||
jsint c = 0;
|
||||
if (index != 0) {
|
||||
while (JS7_ISDEC(*cp)) {
|
||||
oldIndex = index;
|
||||
@@ -298,8 +297,7 @@ array_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
js_TryValueOf(cx, obj, type, vp);
|
||||
return JS_TRUE;
|
||||
return js_TryValueOf(cx, obj, type, vp);
|
||||
}
|
||||
|
||||
JSClass js_ArrayClass = {
|
||||
@@ -1017,20 +1015,20 @@ array_splice(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
if (!obj2)
|
||||
return JS_FALSE;
|
||||
*rval = OBJECT_TO_JSVAL(obj2);
|
||||
}
|
||||
|
||||
/* If there are elements to remove, put them into the return value. */
|
||||
if (count > 0) {
|
||||
for (last = begin; last < end; last++) {
|
||||
if (!IndexToId(cx, last, &id))
|
||||
return JS_FALSE;
|
||||
if (!IndexToId(cx, last - begin, &id2))
|
||||
return JS_FALSE;
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, id, &v))
|
||||
return JS_FALSE;
|
||||
if (!OBJ_SET_PROPERTY(cx, obj2, id2, &v))
|
||||
return JS_FALSE;
|
||||
}
|
||||
/* If there are elements to remove, put them into the return value. */
|
||||
if (count > 0) {
|
||||
for (last = begin; last < end; last++) {
|
||||
if (!IndexToId(cx, last, &id))
|
||||
return JS_FALSE;
|
||||
if (!IndexToId(cx, last - begin, &id2))
|
||||
return JS_FALSE;
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, id, &v))
|
||||
return JS_FALSE;
|
||||
if (!OBJ_SET_PROPERTY(cx, obj2, id2, &v))
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
@@ -88,7 +81,7 @@ char js_valueOf_str[] = "valueOf";
|
||||
#define HASH_DOUBLE(dp) ((JSHashNumber)(((uint32*)(dp))[0] ^ ((uint32*)(dp))[1]))
|
||||
#define HASH_BOOLEAN(b) ((JSHashNumber)(b))
|
||||
|
||||
STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
JS_STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
js_hash_atom_key(const void *key)
|
||||
{
|
||||
jsval v;
|
||||
@@ -111,7 +104,7 @@ js_hash_atom_key(const void *key)
|
||||
return (JSHashNumber)v;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_compare_atom_keys(const void *k1, const void *k2)
|
||||
{
|
||||
jsval v1, v2;
|
||||
@@ -134,25 +127,25 @@ js_compare_atom_keys(const void *k1, const void *k2)
|
||||
return v1 == v2;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(int)
|
||||
JS_STATIC_DLL_CALLBACK(int)
|
||||
js_compare_stub(const void *v1, const void *v2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(void *)
|
||||
JS_STATIC_DLL_CALLBACK(void *)
|
||||
js_alloc_atom_space(void *priv, size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(void)
|
||||
JS_STATIC_DLL_CALLBACK(void)
|
||||
js_free_atom_space(void *priv, void *item)
|
||||
{
|
||||
free(item);
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(JSHashEntry *)
|
||||
JS_STATIC_DLL_CALLBACK(JSHashEntry *)
|
||||
js_alloc_atom(void *priv, const void *key)
|
||||
{
|
||||
JSAtomState *state = priv;
|
||||
@@ -172,7 +165,7 @@ js_alloc_atom(void *priv, const void *key)
|
||||
return &atom->entry;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(void)
|
||||
JS_STATIC_DLL_CALLBACK(void)
|
||||
js_free_atom(void *priv, JSHashEntry *he, uintN flag)
|
||||
{
|
||||
if (flag != HT_FREE_ENTRY)
|
||||
@@ -245,6 +238,7 @@ js_InitAtomState(JSContext *cx, JSAtomState *state)
|
||||
FROB(toSourceAtom, js_toSource_str);
|
||||
FROB(toStringAtom, js_toString_str);
|
||||
FROB(valueOfAtom, js_valueOf_str);
|
||||
FROB(evalAtom, js_eval_str);
|
||||
|
||||
#undef FROB
|
||||
|
||||
@@ -268,7 +262,7 @@ typedef struct MarkArgs {
|
||||
JSGCThingMarker mark;
|
||||
} MarkArgs;
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_atom_marker(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JSAtom *atom;
|
||||
@@ -297,7 +291,7 @@ js_MarkAtomState(JSAtomState *state, JSGCThingMarker mark)
|
||||
JS_HashTableEnumerateEntries(state->table, js_atom_marker, &args);
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_atom_sweeper(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JSAtom *atom;
|
||||
@@ -319,7 +313,7 @@ js_SweepAtomState(JSAtomState *state)
|
||||
JS_HashTableEnumerateEntries(state->table, js_atom_sweeper, NULL);
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
js_atom_unpinner(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JSAtom *atom;
|
||||
@@ -407,16 +401,13 @@ js_AtomizeDouble(JSContext *cx, jsdouble d, uintN flags)
|
||||
JSHashTable *table;
|
||||
JSHashEntry *he, **hep;
|
||||
JSAtom *atom;
|
||||
|
||||
#if JS_ALIGN_OF_DOUBLE == 8
|
||||
dp = &d;
|
||||
#else
|
||||
char alignbuf[16];
|
||||
|
||||
dp = (jsdouble *)&alignbuf[8 - ((jsuword)&alignbuf & 7)];
|
||||
#define ALIGNNUM ((1<<JSVAL_TAGBITS) < sizeof(double) ? sizeof(double) : (1<<JSVAL_TAGBITS))
|
||||
char alignbuf[2*ALIGNNUM];
|
||||
jsuword alignint = (jsuword)alignbuf;
|
||||
jsuword xtra = ALIGNNUM-(alignint%ALIGNNUM);
|
||||
#undef ALIGNNUM
|
||||
dp = (jsdouble *)&alignbuf[xtra];
|
||||
*dp = d;
|
||||
#endif
|
||||
|
||||
keyHash = HASH_DOUBLE(dp);
|
||||
key = DOUBLE_TO_JSVAL(dp);
|
||||
state = &cx->runtime->atomState;
|
||||
@@ -519,16 +510,12 @@ js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
|
||||
jschar *chars;
|
||||
JSString *str;
|
||||
JSAtom *atom;
|
||||
#if JS_ALIGN_OF_DOUBLE == 8
|
||||
union { jsdouble d; JSString s; } u;
|
||||
|
||||
str = &u.s;
|
||||
#else
|
||||
char alignbuf[16];
|
||||
|
||||
str = (JSString *)&alignbuf[8 - ((jsuword)&alignbuf & 7)];
|
||||
#endif
|
||||
|
||||
#define ALIGNNUM ((1<<JSVAL_TAGBITS) < sizeof(JSString) ? sizeof(JSString) : (1<<JSVAL_TAGBITS))
|
||||
char alignbuf[2*ALIGNNUM];
|
||||
jsuword alignint = (jsuword)alignbuf;
|
||||
jsuword xtra = ALIGNNUM-(alignint%ALIGNNUM);
|
||||
#undef ALIGNNUM
|
||||
str = (JSString *)&alignbuf[xtra];
|
||||
chars = js_InflateString(cx, bytes, length);
|
||||
if (!chars)
|
||||
return NULL;
|
||||
@@ -544,16 +531,12 @@ JS_FRIEND_API(JSAtom *)
|
||||
js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN flags)
|
||||
{
|
||||
JSString *str;
|
||||
#if JS_ALIGN_OF_DOUBLE == 8
|
||||
union { jsdouble d; JSString s; } u;
|
||||
|
||||
str = &u.s;
|
||||
#else
|
||||
char alignbuf[16];
|
||||
|
||||
str = (JSString *)&alignbuf[8 - ((jsuword)&alignbuf & 7)];
|
||||
#endif
|
||||
|
||||
#define ALIGNNUM ((1<<JSVAL_TAGBITS) < sizeof(JSString) ? sizeof(JSString) : (1<<JSVAL_TAGBITS))
|
||||
char alignbuf[2*ALIGNNUM];
|
||||
jsuword alignint = (jsuword)alignbuf;
|
||||
jsuword xtra = ALIGNNUM-(alignint%ALIGNNUM);
|
||||
#undef ALIGNNUM
|
||||
str = (JSString *)&alignbuf[xtra];
|
||||
str->chars = (jschar *)chars;
|
||||
str->length = length;
|
||||
return js_AtomizeString(cx, str, ATOM_TMPSTR | flags);
|
||||
|
||||
@@ -23,13 +23,7 @@
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#include "jsapi.h"
|
||||
#include "jsprvtd.h"
|
||||
#include "jspubtd.h"
|
||||
@@ -130,6 +124,7 @@ struct JSAtomState {
|
||||
JSAtom *toSourceAtom;
|
||||
JSAtom *toStringAtom;
|
||||
JSAtom *valueOfAtom;
|
||||
JSAtom *evalAtom;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
JSThinLock lock;
|
||||
|
||||
@@ -37,12 +37,12 @@ typedef unsigned long jsbitmap_t;
|
||||
/*
|
||||
** Compute the log of the least power of 2 greater than or equal to n
|
||||
*/
|
||||
EXTERN(JSIntn) JS_CeilingLog2(JSUint32 i);
|
||||
JS_EXTERN_API(JSIntn) JS_CeilingLog2(JSUint32 i);
|
||||
|
||||
/*
|
||||
** Compute the log of the greatest power of 2 less than or equal to n
|
||||
*/
|
||||
EXTERN(JSIntn) JS_FloorLog2(JSUint32 i);
|
||||
JS_EXTERN_API(JSIntn) JS_FloorLog2(JSUint32 i);
|
||||
|
||||
/*
|
||||
** Macro version of JS_CeilingLog2: Compute the log of the least power of
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
#include "jsstddef.h"
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
@@ -170,13 +169,16 @@ js_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp)
|
||||
JSBool b;
|
||||
jsdouble d;
|
||||
|
||||
#if defined XP_PC && defined _MSC_VER &&_MSC_VER <= 800
|
||||
#if defined XP_PC && defined _MSC_VER && _MSC_VER <= 800
|
||||
/* MSVC1.5 coredumps */
|
||||
if (!bp)
|
||||
return JS_TRUE;
|
||||
/* This should be an if-else chain, but MSVC1.5 crashes if it is. */
|
||||
#define ELSE
|
||||
#else
|
||||
#define ELSE else
|
||||
#endif
|
||||
|
||||
/* XXX this should be an if-else chain, but MSVC1.5 crashes if it is. */
|
||||
if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
|
||||
/* Must return early to avoid falling thru to JSVAL_IS_OBJECT case. */
|
||||
*bp = JS_FALSE;
|
||||
@@ -192,20 +194,29 @@ js_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp)
|
||||
} else {
|
||||
b = JS_TRUE;
|
||||
}
|
||||
}
|
||||
} ELSE
|
||||
if (JSVAL_IS_STRING(v)) {
|
||||
b = JSVAL_TO_STRING(v)->length ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
} ELSE
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
b = JSVAL_TO_INT(v) ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
} ELSE
|
||||
if (JSVAL_IS_DOUBLE(v)) {
|
||||
d = *JSVAL_TO_DOUBLE(v);
|
||||
b = (!JSDOUBLE_IS_NaN(d) && d != 0) ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
} ELSE
|
||||
#if defined XP_PC && defined _MSC_VER && _MSC_VER <= 800
|
||||
if (JSVAL_IS_BOOLEAN(v)) {
|
||||
b = JSVAL_TO_BOOLEAN(v);
|
||||
}
|
||||
#else
|
||||
{
|
||||
JS_ASSERT(JSVAL_IS_BOOLEAN(v));
|
||||
b = JSVAL_TO_BOOLEAN(v);
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef ELSE
|
||||
*bp = b;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -21,15 +21,13 @@
|
||||
|
||||
#include "jstypes.h"
|
||||
|
||||
typedef struct JSCListStr JSCList;
|
||||
|
||||
/*
|
||||
** Circular linked list
|
||||
*/
|
||||
struct JSCListStr {
|
||||
JSCList *next;
|
||||
JSCList *prev;
|
||||
};
|
||||
typedef struct JSCListStr {
|
||||
struct JSCListStr *next;
|
||||
struct JSCListStr *prev;
|
||||
} JSCList;
|
||||
|
||||
/*
|
||||
** Insert element "_e" into the list, before "_l".
|
||||
|
||||
@@ -24,14 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsclist.h"
|
||||
#include "jsprf.h"
|
||||
@@ -85,6 +78,10 @@ js_NewContext(JSRuntime *rt, size_t stacksize)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
cx->throwing = JS_FALSE;
|
||||
#endif
|
||||
|
||||
return cx;
|
||||
}
|
||||
|
||||
@@ -204,7 +201,8 @@ js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap)
|
||||
JSBool
|
||||
js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
void *userRef, const uintN errorNumber,
|
||||
char **messagep, JSErrorReport *reportp, va_list ap)
|
||||
char **messagep, JSErrorReport *reportp,
|
||||
JSBool charArgs, va_list ap)
|
||||
{
|
||||
const JSErrorFormatString *fmtData;
|
||||
int i;
|
||||
@@ -214,18 +212,35 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
if (callback) {
|
||||
fmtData = (*callback)(userRef, "Mountain View", errorNumber);
|
||||
if (fmtData != NULL) {
|
||||
int totalArgsLength = 0;
|
||||
int argLengths[10]; /* only {0} thru {9} supported */
|
||||
argCount = fmtData->argCount;
|
||||
JS_ASSERT(argCount <= 10);
|
||||
if (argCount > 0) {
|
||||
/*
|
||||
* Gather the arguments into a char * array, the
|
||||
* messageArgs field is supposed to be an array of
|
||||
* JSString's and we'll convert them later.
|
||||
* Gather the arguments into an array, and accumulate
|
||||
* their sizes. We allocate 1 more than necessary and
|
||||
* null it out to act as the caboose when we free the
|
||||
* pointers later.
|
||||
*/
|
||||
reportp->messageArgs = malloc(sizeof(char *) * argCount);
|
||||
reportp->messageArgs
|
||||
= JS_malloc(cx, sizeof(jschar *) * (argCount + 1));
|
||||
if (!reportp->messageArgs)
|
||||
return JS_FALSE;
|
||||
for (i = 0; i < argCount; i++)
|
||||
reportp->messageArgs[i] = (JSString *) va_arg(ap, char *);
|
||||
reportp->messageArgs[argCount] = NULL;
|
||||
for (i = 0; i < argCount; i++) {
|
||||
if (charArgs) {
|
||||
char *charArg = va_arg(ap, char *);
|
||||
reportp->messageArgs[i]
|
||||
= js_InflateString(cx, charArg, strlen(charArg));
|
||||
}
|
||||
else
|
||||
reportp->messageArgs[i] = va_arg(ap, jschar *);
|
||||
argLengths[i] = js_strlen(reportp->messageArgs[i]);
|
||||
totalArgsLength += argLengths[i];
|
||||
}
|
||||
/* NULL-terminate for easy copying. */
|
||||
reportp->messageArgs[i] = NULL;
|
||||
}
|
||||
/*
|
||||
* Parse the error format, substituting the argument X
|
||||
@@ -233,21 +248,22 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
*/
|
||||
if (argCount > 0) {
|
||||
if (fmtData->format) {
|
||||
const char *fmt, *arg;
|
||||
char *out;
|
||||
const char *fmt;
|
||||
const jschar *arg;
|
||||
jschar *out;
|
||||
int expandedArgs = 0;
|
||||
int expandedLength
|
||||
= strlen(fmtData->format)
|
||||
- (3 * argCount); /* exclude the {n} */
|
||||
|
||||
for (i = 0; i < argCount; i++) {
|
||||
expandedLength
|
||||
+= strlen((char *)reportp->messageArgs[i]);
|
||||
}
|
||||
*messagep = out = malloc(expandedLength + 1);
|
||||
- (3 * argCount) /* exclude the {n} */
|
||||
+ totalArgsLength;
|
||||
/* Note - the above calculation assumes that each argument
|
||||
* is used once and only once in the expansion !!!
|
||||
*/
|
||||
reportp->ucmessage = out
|
||||
= JS_malloc(cx, (expandedLength + 1) * sizeof(jschar));
|
||||
if (!out) {
|
||||
if (reportp->messageArgs) {
|
||||
free(reportp->messageArgs);
|
||||
JS_free(cx, (void *)reportp->messageArgs);
|
||||
reportp->messageArgs = NULL;
|
||||
}
|
||||
return JS_FALSE;
|
||||
@@ -258,33 +274,32 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
if (isdigit(fmt[1])) {
|
||||
int d = JS7_UNDEC(fmt[1]);
|
||||
JS_ASSERT(expandedArgs < argCount);
|
||||
arg = (char *)reportp->messageArgs[d];
|
||||
strcpy(out, arg);
|
||||
out += strlen(arg);
|
||||
arg = reportp->messageArgs[d];
|
||||
js_strncpy(out, arg, argLengths[d]);
|
||||
out += argLengths[d];
|
||||
fmt += 3;
|
||||
expandedArgs++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
*out++ = *fmt++;
|
||||
/*
|
||||
* is this kosher?
|
||||
*/
|
||||
*out++ = (unsigned char)(*fmt++);
|
||||
}
|
||||
JS_ASSERT(expandedArgs == argCount);
|
||||
*out = '\0';
|
||||
*out = 0;
|
||||
*messagep = js_DeflateString(cx, reportp->ucmessage,
|
||||
out - reportp->ucmessage);
|
||||
}
|
||||
/*
|
||||
* Now convert all the arguments to JSStrings.
|
||||
*/
|
||||
for (i = 0; i < argCount; i++) {
|
||||
reportp->messageArgs[i] =
|
||||
JS_NewStringCopyZ(cx, (char *)reportp->messageArgs[i]);
|
||||
}
|
||||
} else {
|
||||
*messagep = JS_strdup(cx, fmtData->format);
|
||||
} else { /* 0 arguments, the format string
|
||||
(if it exists) is the entire message */
|
||||
if (fmtData->format) {
|
||||
*messagep = JS_strdup(cx, fmtData->format);
|
||||
reportp->ucmessage
|
||||
= js_InflateString(cx, *messagep, strlen(*messagep));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* And finally convert the message.
|
||||
*/
|
||||
reportp->ucmessage = JS_NewStringCopyZ(cx, *messagep);
|
||||
}
|
||||
}
|
||||
if (*messagep == NULL) {
|
||||
@@ -292,7 +307,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
const char *defaultErrorMessage
|
||||
= "No error message available for error number %d";
|
||||
size_t nbytes = strlen(defaultErrorMessage) + 16;
|
||||
*messagep = (char *)malloc(nbytes);
|
||||
*messagep = (char *)JS_malloc(cx, nbytes);
|
||||
JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);
|
||||
}
|
||||
return JS_TRUE;
|
||||
@@ -300,7 +315,8 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
|
||||
void
|
||||
js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
||||
void *userRef, const uintN errorNumber, va_list ap)
|
||||
void *userRef, const uintN errorNumber,
|
||||
JSBool charArgs, va_list ap)
|
||||
{
|
||||
JSStackFrame *fp;
|
||||
JSErrorReport report;
|
||||
@@ -326,7 +342,7 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
||||
report.errorNumber = errorNumber;
|
||||
|
||||
if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber,
|
||||
&message, &report, ap))
|
||||
&message, &report, charArgs, ap))
|
||||
return;
|
||||
|
||||
#if JS_HAS_ERROR_EXCEPTIONS
|
||||
@@ -335,16 +351,43 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
||||
* if the error is defined to have an associated exception. If an
|
||||
* exception is thrown, then the JSREPORT_EXCEPTION flag will be set
|
||||
* on the error report, and exception-aware hosts should ignore it.
|
||||
|
||||
* We set the JSREPORT_EXCEPTION flag for the special case of
|
||||
* user-thrown exeptions.
|
||||
*/
|
||||
js_ErrorToException(cx, &report, message);
|
||||
if (errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
|
||||
report.flags |= JSREPORT_EXCEPTION;
|
||||
|
||||
/*
|
||||
* Only call the error reporter if an exception wasn't raised.
|
||||
*
|
||||
* If an exception was raised, then we call the debugErrorHook
|
||||
* (if present) to give it a chance to see the error before it
|
||||
* propigates out of scope. This is needed for compatability with
|
||||
* the old scheme.
|
||||
*/
|
||||
if (!js_ErrorToException(cx, message, &report))
|
||||
js_ReportErrorAgain(cx, message, &report);
|
||||
else if (cx->runtime->debugErrorHook && cx->errorReporter) {
|
||||
JSDebugErrorHook hook = cx->runtime->debugErrorHook;
|
||||
/* test local in case debugErrorHook changed on another thread */
|
||||
if (hook)
|
||||
hook(cx, message, &report, cx->runtime->debugErrorHookData);
|
||||
}
|
||||
#else
|
||||
js_ReportErrorAgain(cx, message, &report);
|
||||
#endif
|
||||
|
||||
js_ReportErrorAgain(cx, message, &report);
|
||||
|
||||
if (message)
|
||||
free(message);
|
||||
if (report.messageArgs)
|
||||
free(report.messageArgs);
|
||||
JS_free(cx, message);
|
||||
if (report.messageArgs) {
|
||||
int i = 0;
|
||||
while (report.messageArgs[i])
|
||||
JS_free(cx, (void *)report.messageArgs[i++]);
|
||||
JS_free(cx, (void *)report.messageArgs);
|
||||
}
|
||||
if (report.ucmessage)
|
||||
JS_free(cx, (void *)report.ucmessage);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
@@ -360,6 +403,18 @@ js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *reportp)
|
||||
if (!cx->lastMessage)
|
||||
return;
|
||||
onError = cx->errorReporter;
|
||||
/*
|
||||
* If debugErrorHook is present then we give it a chance to veto
|
||||
* sending the error on to the regular ErrorReporter.
|
||||
*/
|
||||
if (cx->runtime->debugErrorHook && onError) {
|
||||
JSDebugErrorHook hook = cx->runtime->debugErrorHook;
|
||||
/* test local in case debugErrorHook changed on another thread */
|
||||
if (hook && !hook(cx, message, reportp,
|
||||
cx->runtime->debugErrorHookData)) {
|
||||
onError = NULL;
|
||||
}
|
||||
}
|
||||
if (onError)
|
||||
(*onError)(cx, cx->lastMessage, reportp);
|
||||
}
|
||||
|
||||
@@ -21,16 +21,11 @@
|
||||
/*
|
||||
* JS execution context.
|
||||
*/
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#include "jsclist.h"
|
||||
#include "jslong.h"
|
||||
#include "jsatom.h"
|
||||
#include "jsconfig.h"
|
||||
#include "jsgc.h"
|
||||
#include "jsinterp.h"
|
||||
#include "jsobj.h"
|
||||
@@ -94,6 +89,12 @@ struct JSRuntime {
|
||||
void *executeHookData;
|
||||
JSInterpreterHook callHook;
|
||||
void *callHookData;
|
||||
JSObjectHook objectHook;
|
||||
void *objectHookData;
|
||||
JSTrapHandler throwHook;
|
||||
void *throwHookData;
|
||||
JSDebugErrorHook debugErrorHook;
|
||||
void *debugErrorHookData;
|
||||
|
||||
/* More debugging state, see jsdbgapi.c. */
|
||||
JSCList trapList;
|
||||
@@ -205,13 +206,14 @@ extern void
|
||||
js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap);
|
||||
extern void
|
||||
js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
|
||||
void *userRef, const uintN errorNumber, va_list ap);
|
||||
void *userRef, const uintN errorNumber,
|
||||
JSBool charArgs, va_list ap);
|
||||
|
||||
extern JSBool
|
||||
js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
|
||||
void *userRef, const uintN errorNumber,
|
||||
char **message, JSErrorReport *reportp,
|
||||
va_list ap);
|
||||
JSBool charArgs, va_list ap);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
|
||||
#elif JS_VERSION == 110
|
||||
|
||||
@@ -116,6 +118,8 @@
|
||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
|
||||
#elif JS_VERSION == 120
|
||||
|
||||
@@ -163,6 +167,8 @@
|
||||
#define JS_HAS_ARGS_OBJECT 0 /* has minimal ECMA arguments object */
|
||||
#define JS_HAS_DEBUGGER_KEYWORD 0 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
|
||||
#elif JS_VERSION == 130
|
||||
|
||||
@@ -210,6 +216,8 @@
|
||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* has error object hierarchy */
|
||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
|
||||
#elif JS_VERSION == 140
|
||||
|
||||
@@ -256,7 +264,9 @@
|
||||
#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */
|
||||
#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */
|
||||
#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
|
||||
#define JS_HAS_ERROR_EXCEPTIONS 0 /* rt errors reflected as exceptions */
|
||||
#define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */
|
||||
#define JS_HAS_NEW_OBJ_METHODS 0 /* has Object.prototype query methods */
|
||||
|
||||
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */
|
||||
|
||||
|
||||
135
mozilla/js/src/jsconfig.mk
Normal file
135
mozilla/js/src/jsconfig.mk
Normal file
@@ -0,0 +1,135 @@
|
||||
ifndef OBJDIR
|
||||
ifdef OBJDIR_NAME
|
||||
OBJDIR = $(OBJDIR_NAME)
|
||||
endif
|
||||
endif
|
||||
|
||||
NSPR_VERSION = 19980120
|
||||
NSPR_LOCAL = $(MOZ_DEPTH)/dist/$(OBJDIR)/nspr
|
||||
NSPR_DIST = $(MOZ_DEPTH)/dist/$(OBJDIR)
|
||||
NSPR_OBJDIR = $(OBJDIR)
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
NSPR_OBJDIR := $(subst _sparc,,$(NSPR_OBJDIR))
|
||||
endif
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
NSPR_OBJDIR := $(subst _All,ELF2.0,$(NSPR_OBJDIR))
|
||||
endif
|
||||
ifeq ($(OS_ARCH), AIX)
|
||||
NSPR_OBJDIR := $(subst 4.1,4.2,$(NSPR_OBJDIR))
|
||||
endif
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
NSPR_OBJDIR := $(subst WINNT,WIN95,$(NSPR_OBJDIR))
|
||||
ifeq ($(OBJDIR), WIN32_D.OBJ)
|
||||
NSPR_OBJDIR = WIN954.0_DBG.OBJ
|
||||
endif
|
||||
ifeq ($(OBJDIR), WIN32_O.OBJ)
|
||||
NSPR_OBJDIR = WIN954.0_OPT.OBJ
|
||||
endif
|
||||
endif
|
||||
NSPR_SHARED = /share/builds/components/nspr20/$(NSPR_VERSION)/$(NSPR_OBJDIR)
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
NSPR_SHARED = nspr20/$(NSPR_VERSION)/$(NSPR_OBJDIR)
|
||||
endif
|
||||
NSPR_VERSIONFILE = $(NSPR_LOCAL)/Version
|
||||
NSPR_CURVERSION := $(shell cat $(NSPR_VERSIONFILE))
|
||||
|
||||
get_nspr:
|
||||
@echo "Grabbing NSPR component..."
|
||||
ifeq ($(NSPR_VERSION), $(NSPR_CURVERSION))
|
||||
@echo "No need, NSPR is up to date in this tree (ver=$(NSPR_VERSION))."
|
||||
else
|
||||
mkdir -p $(NSPR_LOCAL)
|
||||
mkdir -p $(NSPR_DIST)
|
||||
ifneq ($(OS_ARCH), WINNT)
|
||||
cp $(NSPR_SHARED)/*.jar $(NSPR_LOCAL)
|
||||
else
|
||||
sh $(MOZ_DEPTH)/../reltools/compftp.sh $(NSPR_SHARED) $(NSPR_LOCAL) *.jar
|
||||
endif
|
||||
unzip -o $(NSPR_LOCAL)/mdbinary.jar -d $(NSPR_DIST)
|
||||
mkdir -p $(NSPR_DIST)/include
|
||||
unzip -o $(NSPR_LOCAL)/mdheader.jar -d $(NSPR_DIST)/include
|
||||
rm -rf $(NSPR_DIST)/META-INF
|
||||
rm -rf $(NSPR_DIST)/include/META-INF
|
||||
echo $(NSPR_VERSION) > $(NSPR_VERSIONFILE)
|
||||
endif
|
||||
|
||||
SHIP_DIST = $(MOZ_DEPTH)/dist/$(OBJDIR)
|
||||
SHIP_DIR = $(SHIP_DIST)/SHIP
|
||||
|
||||
SHIP_LIBS = libjs.so
|
||||
ifdef JS_LIVECONNECT
|
||||
SHIP_LIBS += jsj.so
|
||||
endif
|
||||
ifdef JS_THREADSAFE
|
||||
ifeq ($(OS_ARCH), HP-UX)
|
||||
SHIP_LIBS += libnspr21.sl
|
||||
else
|
||||
SHIP_LIBS += libnspr21.so
|
||||
endif
|
||||
endif
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
SHIP_LIBS = js32.dll
|
||||
ifdef JS_LIVECONNECT
|
||||
SHIP_LIBS += jsj.dll
|
||||
endif
|
||||
ifdef JS_THREADSAFE
|
||||
SHIP_LIBS += libnspr21.dll
|
||||
endif
|
||||
endif
|
||||
SHIP_LIBS := $(addprefix $(SHIP_DIST)/lib/, $(SHIP_LIBS))
|
||||
|
||||
SHIP_INCS = js*.h
|
||||
ifdef JS_LIVECONNECT
|
||||
SHIP_INCS += netscape*.h
|
||||
endif
|
||||
SHIP_INCS := $(addprefix $(SHIP_DIST)/include/, $(SHIP_INCS))
|
||||
|
||||
SHIP_BINS = js
|
||||
ifdef JS_LIVECONNECT
|
||||
SHIP_BINS += jsj
|
||||
endif
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
SHIP_BINS := $(addsuffix .exe, $(SHIP_BINS))
|
||||
endif
|
||||
SHIP_BINS := $(addprefix $(SHIP_DIST)/bin/, $(SHIP_BINS))
|
||||
|
||||
ifdef BUILD_OPT
|
||||
JSREFJAR = jsref_opt.jar
|
||||
else
|
||||
JSREFJAR = jsref_dbg.jar
|
||||
endif
|
||||
|
||||
ship:
|
||||
mkdir -p $(SHIP_DIR)/lib
|
||||
mkdir -p $(SHIP_DIR)/include
|
||||
mkdir -p $(SHIP_DIR)/bin
|
||||
cp $(SHIP_LIBS) $(SHIP_DIR)/lib
|
||||
cp $(SHIP_INCS) $(SHIP_DIR)/include
|
||||
cp $(SHIP_BINS) $(SHIP_DIR)/bin
|
||||
cd $(SHIP_DIR); \
|
||||
zip -r $(JSREFJAR) bin lib include
|
||||
ifdef BUILD_SHIP
|
||||
cp $(SHIP_DIR)/$(JSREFJAR) $(BUILD_SHIP)
|
||||
endif
|
||||
|
||||
CWD = $(shell pwd)
|
||||
shipSource: $(SHIP_DIR)/jsref_src.lst .FORCE
|
||||
mkdir -p $(SHIP_DIR)
|
||||
cd $(MOZ_DEPTH)/.. ; \
|
||||
zip $(CWD)/$(SHIP_DIR)/jsref_src.jar -@ < $(CWD)/$(SHIP_DIR)/jsref_src.lst
|
||||
ifdef BUILD_SHIP
|
||||
cp $(SHIP_DIR)/jsref_src.jar $(BUILD_SHIP)
|
||||
endif
|
||||
|
||||
JSREFSRCDIRS := $(shell cat $(DEPTH)/SpiderMonkey.rsp)
|
||||
$(SHIP_DIR)/jsref_src.lst: .FORCE
|
||||
mkdir -p $(SHIP_DIR)
|
||||
rm -f $@
|
||||
touch $@
|
||||
for d in $(JSREFSRCDIRS); do \
|
||||
cd $(MOZ_DEPTH)/..; \
|
||||
ls -1 -d $$d | grep -v CVS | grep -v \.OBJ >> $(CWD)/$@; \
|
||||
cd $(CWD); \
|
||||
done
|
||||
|
||||
.FORCE:
|
||||
@@ -21,13 +21,13 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(sgi)
|
||||
#ifdef sgi
|
||||
#ifndef IRIX
|
||||
# error "IRIX is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__sun)
|
||||
#ifdef __sun
|
||||
#if defined(__svr4) || defined(__svr4__)
|
||||
#ifndef SOLARIS
|
||||
# error "SOLARIS is not defined"
|
||||
@@ -39,37 +39,31 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__hpux)
|
||||
#ifdef __hpux
|
||||
#ifndef HPUX
|
||||
# error "HPUX is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__osf__)
|
||||
#ifdef __osf__
|
||||
#ifndef OSF1
|
||||
# error "OSF1 is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_IBMR2)
|
||||
#ifdef _IBMR2
|
||||
#ifndef AIX
|
||||
# error "AIX is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(linux)
|
||||
#ifndef LINUX
|
||||
# error "LINUX is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(bsdi)
|
||||
#ifdef bsdi
|
||||
#ifndef BSDI
|
||||
# error "BSDI is not defined"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(M_UNIX)
|
||||
#ifdef M_UNIX
|
||||
#ifndef SCO
|
||||
# error "SCO is not defined"
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "jsosdep.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "jsmacos.h"
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
|
||||
@@ -66,7 +65,8 @@
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
#endif /* XP_MAC */
|
||||
|
||||
#elif defined(XP_PC)
|
||||
|
||||
#ifdef _WIN32
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
@@ -160,543 +160,16 @@
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
#endif /* defined(_WINDOWS) && !defined(_WIN32) */
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#elif defined(XP_UNIX)
|
||||
|
||||
#ifdef AIXV3
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
#error "This file is supposed to be auto-generated on UNIX platforms, but the"
|
||||
#error "static version for Mac and Windows platforms is being used."
|
||||
#error "Something's probably wrong with paths/headers/dependencies/Makefiles."
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(BSDI)
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#undef IS_BIG_ENDIAN
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(HPUX)
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(IRIX)
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(LINUX)
|
||||
|
||||
#ifdef __powerpc__
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
#elif __i386__
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#undef IS_BIG_ENDIAN
|
||||
#else
|
||||
#error "linux cpu architecture not supported by jscpucfg.h"
|
||||
#endif
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(OSF1)
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#undef IS_BIG_ENDIAN
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 8L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 8L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 64L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 64L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 6L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 6L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 8L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 8L
|
||||
#define JS_ALIGN_OF_WORD 8L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 3L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 0L
|
||||
|
||||
|
||||
#elif defined(SOLARIS)
|
||||
|
||||
#ifdef i386
|
||||
/* PC-based */
|
||||
#undef IS_BIG_ENDIAN
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#else
|
||||
/* Sparc-based */
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#ifdef i386
|
||||
#undef JS_ALIGN_OF_INT64
|
||||
#undef JS_ALIGN_OF_DOUBLE
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#endif
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(SUNOS4)
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(SNI)
|
||||
#undef IS_LITTLE_ENDIAN
|
||||
#define IS_BIG_ENDIAN 1
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 8L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 8L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(SONY)
|
||||
/* Don't have it */
|
||||
|
||||
#elif defined(NECSVR4)
|
||||
/* Don't have it */
|
||||
|
||||
#elif defined(SCO)
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#undef IS_BIG_ENDIAN
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
|
||||
|
||||
#elif defined(UNIXWARE)
|
||||
#define IS_LITTLE_ENDIAN 1
|
||||
#undef IS_BIG_ENDIAN
|
||||
|
||||
#define JS_BYTES_PER_BYTE 1L
|
||||
#define JS_BYTES_PER_SHORT 2L
|
||||
#define JS_BYTES_PER_INT 4L
|
||||
#define JS_BYTES_PER_INT64 8L
|
||||
#define JS_BYTES_PER_LONG 4L
|
||||
#define JS_BYTES_PER_FLOAT 4L
|
||||
#define JS_BYTES_PER_DOUBLE 8L
|
||||
#define JS_BYTES_PER_WORD 4L
|
||||
#define JS_BYTES_PER_DWORD 8L
|
||||
|
||||
#define JS_BITS_PER_BYTE 8L
|
||||
#define JS_BITS_PER_SHORT 16L
|
||||
#define JS_BITS_PER_INT 32L
|
||||
#define JS_BITS_PER_INT64 64L
|
||||
#define JS_BITS_PER_LONG 32L
|
||||
#define JS_BITS_PER_FLOAT 32L
|
||||
#define JS_BITS_PER_DOUBLE 64L
|
||||
#define JS_BITS_PER_WORD 32L
|
||||
|
||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
||||
#define JS_BITS_PER_INT_LOG2 5L
|
||||
#define JS_BITS_PER_INT64_LOG2 6L
|
||||
#define JS_BITS_PER_LONG_LOG2 5L
|
||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
||||
#define JS_BITS_PER_WORD_LOG2 5L
|
||||
|
||||
#define JS_ALIGN_OF_SHORT 2L
|
||||
#define JS_ALIGN_OF_INT 4L
|
||||
#define JS_ALIGN_OF_LONG 4L
|
||||
#define JS_ALIGN_OF_INT64 4L
|
||||
#define JS_ALIGN_OF_FLOAT 4L
|
||||
#define JS_ALIGN_OF_DOUBLE 4L
|
||||
#define JS_ALIGN_OF_POINTER 4L
|
||||
#define JS_ALIGN_OF_WORD 4L
|
||||
|
||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
||||
#error "Must define one of XP_MAC, XP_PC or XP_UNIX"
|
||||
|
||||
#endif
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
#endif /* js_cpucfg___ */
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "jstypes.h"
|
||||
#include "jsprf.h"
|
||||
#include "prmjtime.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsconfig.h"
|
||||
@@ -306,7 +305,7 @@ static jsdouble LocalTZA;
|
||||
static jsdouble
|
||||
DaylightSavingTA(jsdouble t)
|
||||
{
|
||||
int64 PR_t;
|
||||
volatile int64 PR_t;
|
||||
int64 ms2us;
|
||||
int64 offset;
|
||||
jsdouble result;
|
||||
@@ -1558,7 +1557,7 @@ date_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
if (!date)
|
||||
return JS_FALSE;
|
||||
|
||||
PR_cnvtf(buf, sizeof buf, 20, *date);
|
||||
JS_cnvtf(buf, sizeof buf, 20, *date);
|
||||
bytes = JS_smprintf("(new %s(%s))", date_class.name, buf);
|
||||
if (!bytes) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "jsstddef.h"
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsclist.h"
|
||||
#include "jsapi.h"
|
||||
@@ -270,7 +269,7 @@ js_FindWatchPoint(JSRuntime *rt, JSObject *obj, jsval userid)
|
||||
return wp->sprop;
|
||||
}
|
||||
|
||||
JSBool DLL_CALLBACK
|
||||
JSBool JS_DLL_CALLBACK
|
||||
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
@@ -838,7 +837,7 @@ JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure)
|
||||
rt->sourceHandler = handler;
|
||||
rt->sourceHandlerData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
|
||||
@@ -846,14 +845,36 @@ JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
|
||||
rt->executeHook = hook;
|
||||
rt->executeHookData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
|
||||
{
|
||||
rt->callHook = hook;
|
||||
rt->callHookData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure)
|
||||
{
|
||||
rt->objectHook = hook;
|
||||
rt->objectHookData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSTrapHandler hook, void *closure)
|
||||
{
|
||||
rt->throwHook = hook;
|
||||
rt->throwHookData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure)
|
||||
{
|
||||
rt->debugErrorHook = hook;
|
||||
rt->debugErrorHookData = closure;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ JS_ClearAllWatchPoints(JSContext *cx);
|
||||
extern JSScopeProperty *
|
||||
js_FindWatchPoint(JSRuntime *rt, JSObject *obj, jsval userid);
|
||||
|
||||
extern JSBool DLL_CALLBACK
|
||||
extern JSBool JS_DLL_CALLBACK
|
||||
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
#endif
|
||||
|
||||
@@ -240,6 +240,15 @@ JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetObjectHook(JSRuntime *rt, JSObjectHook hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetThrowHook(JSRuntime *rt, JSTrapHandler hook, void *closure);
|
||||
|
||||
extern JS_PUBLIC_API(JSBool)
|
||||
JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdbgapi_h___ */
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "jstypes.h"
|
||||
#include "jsdtoa.h"
|
||||
#include "jsprf.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
@@ -100,7 +99,7 @@
|
||||
* #define VAX for VAX-style floating-point arithmetic.
|
||||
* #define Unsigned_Shifts if >> does treats its left operand as unsigned.
|
||||
* #define No_leftright to omit left-right logic in fast floating-point
|
||||
* computation of PR_dtoa.
|
||||
* computation of JS_dtoa.
|
||||
* #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
|
||||
* #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
|
||||
* that use extended-precision instructions to compute rounded
|
||||
@@ -1199,8 +1198,8 @@ static void InitDtoa(void)
|
||||
|
||||
/* nspr2 watcom bug ifdef omitted */
|
||||
|
||||
PUBLIC_API(double)
|
||||
PR_strtod(CONST char *s00, char **se)
|
||||
JS_FRIEND_API(double)
|
||||
JS_strtod(CONST char *s00, char **se)
|
||||
{
|
||||
int32 bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
|
||||
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
|
||||
@@ -1214,6 +1213,7 @@ PR_strtod(CONST char *s00, char **se)
|
||||
if (!initialized) InitDtoa();
|
||||
#endif
|
||||
|
||||
bb = bd = bs = delta = NULL;
|
||||
sign = nz0 = nz = 0;
|
||||
rv = 0.;
|
||||
for(s = s00;;s++) switch(*s) {
|
||||
@@ -1874,7 +1874,7 @@ quorem(Bigint *b, Bigint *S)
|
||||
*/
|
||||
|
||||
static JSBool
|
||||
PR_dtoa(double d, int mode, int ndigits,
|
||||
JS_dtoa(double d, int mode, int ndigits,
|
||||
int *decpt, int *sign, char **rve, char *buf, size_t bufsize)
|
||||
{
|
||||
/* Arguments ndigits, decpt, sign are similar to those
|
||||
@@ -1927,6 +1927,10 @@ PR_dtoa(double d, int mode, int ndigits,
|
||||
JSBool retval;
|
||||
size_t strsize;
|
||||
|
||||
spec_case = 0; /* Not a power-of-two special case */
|
||||
ilim = ilim1 = 0;
|
||||
mlo = NULL;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
if (!initialized) InitDtoa();
|
||||
#endif
|
||||
@@ -2520,8 +2524,8 @@ ret1:
|
||||
** Also, the ECMA spec says that there should always be a
|
||||
** '+' or '-' after the 'e' in scientific notation
|
||||
*/
|
||||
PUBLIC_API(void)
|
||||
PR_cnvtf(char *buf,int bufsz, int prcsn,double fval)
|
||||
JS_FRIEND_API(void)
|
||||
JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
|
||||
{
|
||||
intN decpt,sign,numdigits;
|
||||
char *num, *nump;
|
||||
@@ -2535,7 +2539,7 @@ PR_cnvtf(char *buf,int bufsz, int prcsn,double fval)
|
||||
return;
|
||||
}
|
||||
/* XXX Why use mode 1? */
|
||||
if (PR_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz)
|
||||
if (JS_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz)
|
||||
== JS_FALSE) {
|
||||
buf[0] = '\0';
|
||||
goto done;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* PR_strtod() returns as a double-precision floating-point number
|
||||
* JS_strtod() returns as a double-precision floating-point number
|
||||
* the value represented by the character string pointed to by
|
||||
* s00. The string is scanned up to the first unrecognized
|
||||
* character.
|
||||
@@ -37,17 +37,17 @@ JS_BEGIN_EXTERN_C
|
||||
* to by se. If no number can be formed, se is set to s00r, and
|
||||
* zero is returned.
|
||||
*/
|
||||
extern PUBLIC_API(double)
|
||||
PR_strtod(const char *s00, char **se);
|
||||
JS_FRIEND_API(double)
|
||||
JS_strtod(const char *s00, char **se);
|
||||
|
||||
/*
|
||||
* PR_cnvtf()
|
||||
* JS_cnvtf()
|
||||
* conversion routines for floating point
|
||||
* prcsn - number of digits of precision to generate floating
|
||||
* point value.
|
||||
*/
|
||||
extern PUBLIC_API(void)
|
||||
PR_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
|
||||
JS_FRIEND_API(void)
|
||||
JS_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
@@ -23,14 +23,7 @@
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
@@ -71,7 +64,7 @@ js_InitCodeGenerator(JSContext *cx, JSCodeGenerator *cg,
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
js_ResetCodeGenerator(JSContext *cx, JSCodeGenerator *cg)
|
||||
js_FinishCodeGenerator(JSContext *cx, JSCodeGenerator *cg)
|
||||
{
|
||||
JS_ARENA_RELEASE(&cx->codePool, cg->codeMark);
|
||||
JS_ARENA_RELEASE(&cx->tempPool, cg->tempMark);
|
||||
@@ -506,11 +499,44 @@ FixupCatchJumps(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t tryStart,
|
||||
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
|
||||
|
||||
/* a macro for inlining at the top of js_EmitTree (from whence it came) */
|
||||
#define UPDATE_LINENO_NOTES(cx, cg, pn) \
|
||||
JS_BEGIN_MACRO \
|
||||
uintN lineno, delta; \
|
||||
lineno = pn->pn_pos.begin.lineno; \
|
||||
delta = lineno - cg->currentLine; \
|
||||
cg->currentLine = lineno; \
|
||||
if (delta) { \
|
||||
/* \
|
||||
* Encode any change in the current source line number by using \
|
||||
* either several SRC_NEWLINE notes or one SRC_SETLINE note, \
|
||||
* whichever consumes less space. \
|
||||
*/ \
|
||||
if (delta >= (uintN)(2 + ((lineno > SN_3BYTE_OFFSET_MASK) << 1))) { \
|
||||
if (js_NewSrcNote2(cx, cg, SRC_SETLINE, (ptrdiff_t)lineno) < 0) \
|
||||
return JS_FALSE; \
|
||||
} else { \
|
||||
do { \
|
||||
if (js_NewSrcNote(cx, cg, SRC_NEWLINE) < 0) \
|
||||
return JS_FALSE; \
|
||||
} while (--delta != 0); \
|
||||
} \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
/* a function so that we can make the (few) less frequent calls */
|
||||
static JSBool
|
||||
UpdateLinenoNotes(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
{
|
||||
UPDATE_LINENO_NOTES(cx, cg, pn);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
{
|
||||
JSBool ok;
|
||||
uintN lineno, delta;
|
||||
JSCodeGenerator cg2;
|
||||
JSStmtInfo *stmt, stmtInfo;
|
||||
ptrdiff_t top, off, tmp, beq, jmp;
|
||||
@@ -525,25 +551,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
pn->pn_offset = top = CG_OFFSET(cg);
|
||||
|
||||
/* Emit notes to tell the current bytecode's source line number. */
|
||||
lineno = pn->pn_pos.begin.lineno;
|
||||
delta = lineno - cg->currentLine;
|
||||
cg->currentLine = lineno;
|
||||
if (delta) {
|
||||
/*
|
||||
* Encode any change in the current source line number by using either
|
||||
* several SRC_NEWLINE notes or one SRC_SETLINE note, whichever
|
||||
* consumes less space.
|
||||
*/
|
||||
if (delta >= (uintN)(2 + ((lineno > SN_3BYTE_OFFSET_MASK) << 1))) {
|
||||
if (js_NewSrcNote2(cx, cg, SRC_SETLINE, (ptrdiff_t)lineno) < 0)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
do {
|
||||
if (js_NewSrcNote(cx, cg, SRC_NEWLINE) < 0)
|
||||
return JS_FALSE;
|
||||
} while (--delta != 0);
|
||||
}
|
||||
}
|
||||
UPDATE_LINENO_NOTES(cx, cg, pn);
|
||||
|
||||
switch (pn->pn_type) {
|
||||
case TOK_FUNCTION:
|
||||
@@ -563,7 +571,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
fun = pn->pn_fun;
|
||||
if (!js_EmitFunctionBody(cx, &cg2, pn2, fun))
|
||||
return JS_FALSE;
|
||||
js_ResetCodeGenerator(cx, &cg2);
|
||||
js_FinishCodeGenerator(cx, &cg2);
|
||||
|
||||
/* Make the function object a literal in the outer script's pool. */
|
||||
atom = js_AtomizeObject(cx, fun->object, 0);
|
||||
@@ -747,14 +755,10 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
}
|
||||
} else {
|
||||
/* Pre-ECMAv2 switch evals case exprs at compile time. */
|
||||
if (!cg2.base) {
|
||||
if (!js_InitCodeGenerator(cx, &cg2, cg->filename,
|
||||
pn3->pn_pos.begin.lineno,
|
||||
cg->principals)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
js_ResetCodeGenerator(cx, &cg2);
|
||||
if (!js_InitCodeGenerator(cx, &cg2, cg->filename,
|
||||
pn3->pn_pos.begin.lineno,
|
||||
cg->principals)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
cg2.currentLine = pn4->pn_pos.begin.lineno;
|
||||
if (!js_EmitTree(cx, &cg2, pn4))
|
||||
@@ -804,7 +808,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
JS_ASSERT(!cg2.base);
|
||||
} else {
|
||||
if (cg2.base)
|
||||
js_ResetCodeGenerator(cx, &cg2);
|
||||
js_FinishCodeGenerator(cx, &cg2);
|
||||
if (switchop == JSOP_TABLESWITCH) {
|
||||
tablen = (uint32)(high - low + 1);
|
||||
if (tablen >= JS_BIT(16) || tablen > 2 * ncases)
|
||||
@@ -844,6 +848,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
if (js_EmitN(cx, cg, switchop, switchsize) < 0)
|
||||
return JS_FALSE;
|
||||
|
||||
off = -1;
|
||||
if (switchop == JSOP_CONDSWITCH) {
|
||||
intN caseNoteIndex = -1;
|
||||
|
||||
@@ -900,7 +905,11 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
off = CG_OFFSET(cg) - top;
|
||||
}
|
||||
|
||||
/* We better have set "off" by now. */
|
||||
JS_ASSERT(off != -1);
|
||||
|
||||
/* Set the default offset (to end of switch if no default). */
|
||||
pc = NULL;
|
||||
if (switchop == JSOP_CONDSWITCH) {
|
||||
JS_ASSERT(defaultOffset != -1);
|
||||
if (!js_SetJumpOffset(cx, cg, CG_CODE(cg, defaultOffset),
|
||||
@@ -1217,11 +1226,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
stmt = cg->treeContext.topStmt;
|
||||
atom = pn->pn_atom;
|
||||
if (atom) {
|
||||
/* Find the loop statement enclosed by the matching label. */
|
||||
JSStmtInfo *loop = NULL;
|
||||
ale = js_IndexAtom(cx, atom, &cg->atomList);
|
||||
if (!ale)
|
||||
return JS_FALSE;
|
||||
while (stmt->type != STMT_LABEL || stmt->label != atom)
|
||||
while (stmt->type != STMT_LABEL || stmt->label != atom) {
|
||||
if (STMT_IS_LOOP(stmt))
|
||||
loop = stmt;
|
||||
stmt = stmt->down;
|
||||
}
|
||||
stmt = loop;
|
||||
} else {
|
||||
ale = NULL;
|
||||
while (!STMT_IS_LOOP(stmt))
|
||||
@@ -1248,7 +1263,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
|
||||
case TOK_TRY: {
|
||||
ptrdiff_t start, end, catchStart, finallyCatch, catchjmp = -1;
|
||||
ptrdiff_t start, end;
|
||||
ptrdiff_t catchStart = -1, finallyCatch = -1, catchjmp = -1;
|
||||
JSParseNode *iter = pn;
|
||||
uint16 depth;
|
||||
|
||||
@@ -1344,6 +1360,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
iter = iter->pn_kid2;
|
||||
disc = iter->pn_kid1;
|
||||
|
||||
if (!UpdateLinenoNotes(cx, cg, iter))
|
||||
return JS_FALSE;
|
||||
|
||||
if (catchjmp != -1) {
|
||||
/* fix up and clean up previous catch block */
|
||||
CHECK_AND_SET_JUMP_OFFSET_AT(cx, cg, catchjmp);
|
||||
@@ -1353,7 +1372,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
js_Emit1(cx, cg, JSOP_LEAVEWITH) < 0)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
/* set stack to orig depth (see SETSP comment above) */
|
||||
/* set stack to original depth (see SETSP comment above) */
|
||||
EMIT_ATOM_INDEX_OP(JSOP_SETSP, (jsatomid)depth);
|
||||
}
|
||||
|
||||
@@ -1438,7 +1457,6 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
*/
|
||||
if (pn->pn_kid3 ||
|
||||
(catchjmp != -1 && iter->pn_kid1->pn_expr)) {
|
||||
|
||||
/*
|
||||
* Emit another stack fix, because the catch could itself
|
||||
* throw an exception in an unbalanced state, and the finally
|
||||
@@ -1446,7 +1464,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
*/
|
||||
EMIT_ATOM_INDEX_OP(JSOP_SETSP, (jsatomid)depth);
|
||||
|
||||
if (catchjmp != -1) {
|
||||
if (catchjmp != -1 && iter->pn_kid1->pn_expr) {
|
||||
CHECK_AND_SET_JUMP_OFFSET_AT(cx, cg, catchjmp);
|
||||
}
|
||||
/* last discriminant jumps to rethrow if none match */
|
||||
@@ -1478,6 +1496,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
if (!FixupFinallyJumps(cx, cg, start, finallyIndex))
|
||||
return JS_FALSE;
|
||||
js_PopStatementCG(cx, cg);
|
||||
if (!UpdateLinenoNotes(cx, cg, pn->pn_kid3))
|
||||
return JS_FALSE;
|
||||
if (js_NewSrcNote2(cx, cg, SRC_TRYFIN, 1) < 0 ||
|
||||
js_Emit1(cx, cg, JSOP_NOP) < 0 ||
|
||||
!js_EmitTree(cx, cg, pn->pn_kid3) ||
|
||||
@@ -1517,7 +1537,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
|
||||
case TOK_VAR:
|
||||
noteIndex = -1;
|
||||
off = noteIndex = -1;
|
||||
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
|
||||
JS_ASSERT(pn2->pn_type == TOK_NAME);
|
||||
op = pn2->pn_op;
|
||||
@@ -1628,7 +1648,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
* These notes help the decompiler bracket the bytecodes generated
|
||||
* from each sub-expression that follows a comma.
|
||||
*/
|
||||
noteIndex = -1;
|
||||
off = noteIndex = -1;
|
||||
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
|
||||
if (!js_EmitTree(cx, cg, pn2))
|
||||
return JS_FALSE;
|
||||
@@ -1656,6 +1676,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
*/
|
||||
pn2 = pn->pn_left;
|
||||
JS_ASSERT(pn2->pn_type != TOK_RP);
|
||||
atomIndex = -1;
|
||||
switch (pn2->pn_type) {
|
||||
case TOK_NAME:
|
||||
if (pn2->pn_slot >= 0) {
|
||||
@@ -1935,6 +1956,15 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
||||
op = JSOP_CALL;
|
||||
emit_call:
|
||||
pn2 = pn->pn_head;
|
||||
if ((cx->version == JSVERSION_DEFAULT || cx->version >= JSVERSION_1_4)
|
||||
&& (pn2->pn_op == JSOP_NAME)
|
||||
/*
|
||||
* below, is it sufficient to compare the atom values ?
|
||||
*/
|
||||
&& (ATOM_KEY(pn2->pn_atom)
|
||||
== ATOM_KEY(cx->runtime->atomState.evalAtom)))
|
||||
op = JSOP_CALLSPECIAL;
|
||||
|
||||
if (!js_EmitTree(cx, cg, pn2))
|
||||
return JS_FALSE;
|
||||
|
||||
@@ -2474,6 +2504,7 @@ js_NewTryNote(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t start,
|
||||
JSTryNote *tn;
|
||||
|
||||
JS_ASSERT(cg->tryBase <= cg->tryNext);
|
||||
JS_ASSERT(catchStart >= 0);
|
||||
tn = cg->tryNext++;
|
||||
tn->start = start;
|
||||
tn->length = end - start;
|
||||
|
||||
@@ -115,9 +115,12 @@ js_InitCodeGenerator(JSContext *cx, JSCodeGenerator *cg,
|
||||
|
||||
/*
|
||||
* Release cx->codePool and cx->tempPool to marks set by js_InitCodeGenerator.
|
||||
* Note that cgs are magic: they own tempPool and codePool "tops-of-stack"
|
||||
* above their codeMark and tempMark points. This means you cannot alloc
|
||||
* from tempPool and save the pointer beyond the next JS_FinishCodeGenerator.
|
||||
*/
|
||||
extern JS_FRIEND_API(void)
|
||||
js_ResetCodeGenerator(JSContext *cx, JSCodeGenerator *cg);
|
||||
js_FinishCodeGenerator(JSContext *cx, JSCodeGenerator *cg);
|
||||
|
||||
/*
|
||||
* Emit one bytecode.
|
||||
@@ -295,7 +298,7 @@ typedef enum JSSrcNoteType {
|
||||
|
||||
extern JS_FRIEND_DATA(const char *) js_SrcNoteName[];
|
||||
extern JS_FRIEND_DATA(uint8) js_SrcNoteArity[];
|
||||
extern JS_FRIEND_DATA(uintN) js_SrcNoteLength(jssrcnote *sn);
|
||||
extern JS_FRIEND_API(uintN) js_SrcNoteLength(jssrcnote *sn);
|
||||
|
||||
#define SN_LENGTH(sn) ((js_SrcNoteArity[SN_TYPE(sn)] == 0) ? 1 \
|
||||
: js_SrcNoteLength(sn))
|
||||
@@ -342,7 +345,7 @@ js_FinishTakingSrcNotes(JSContext *cx, JSCodeGenerator *cg);
|
||||
/*
|
||||
* Allocate cg->treeContext.tryCount notes (plus one for the end sentinel)
|
||||
* from cx->tempPool and set up cg->tryBase/tryNext for exactly tryCount
|
||||
* js_NewTryNote calls. The storage is freed by js_ResetCodeGenerator.
|
||||
* js_NewTryNote calls. The storage is freed by js_FinishCodeGenerator.
|
||||
*/
|
||||
extern JSBool
|
||||
js_AllocTryNotes(JSContext *cx, JSCodeGenerator *cg);
|
||||
|
||||
@@ -20,70 +20,60 @@
|
||||
* JS standard exception implementation.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* This is currently very messy, and in flux. Don't anybody think
|
||||
* I'm going to leave it like this. No no.
|
||||
*/
|
||||
|
||||
|
||||
#include "jsstddef.h"
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
#include "jscntxt.h"
|
||||
#include "jsconfig.h"
|
||||
#include "jsexn.h"
|
||||
#include "jsfun.h"
|
||||
|
||||
#if JS_HAS_ERROR_EXCEPTIONS
|
||||
#if !JS_HAS_EXCEPTIONS
|
||||
# error "JS_HAS_EXCEPTIONS must be defined to use JS_HAS_ERROR_EXCEPTIONS"
|
||||
#endif
|
||||
|
||||
JSObject *tlobj;
|
||||
/* Declaration to resolve circular reference of exn_class by Exception. */
|
||||
static JSBool
|
||||
Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
|
||||
|
||||
static void
|
||||
exn_finalize(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSClass exn_class = {
|
||||
"Exception",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize,
|
||||
NULL, NULL, NULL, Exception
|
||||
};
|
||||
|
||||
/*
|
||||
* This could end up just being the error report, but I
|
||||
* want to learn how to support random garbage here.
|
||||
*
|
||||
* If I go with it, a rambling comment mentioning GC, memory management etc. is
|
||||
* needed.
|
||||
*
|
||||
* I'd rather have the errorReport inline, to avoid the extra malloc'd object
|
||||
* dangle. But I'll figure that out later, if I still need it.
|
||||
* A copy of the JSErrorReport originally generated.
|
||||
*/
|
||||
typedef struct JSExnPrivate {
|
||||
JSErrorReport *errorReport;
|
||||
const char *message;
|
||||
} JSExnPrivate;
|
||||
|
||||
|
||||
/*
|
||||
* Copy everything interesting about an error into allocated memory.
|
||||
*/
|
||||
static JSExnPrivate *
|
||||
exn_initPrivate(JSContext *cx, JSErrorReport *report, const char *message)
|
||||
exn_initPrivate(JSContext *cx, JSErrorReport *report)
|
||||
{
|
||||
JSExnPrivate *newPrivate;
|
||||
JSErrorReport * newReport;
|
||||
char *newMessage;
|
||||
JSErrorReport *newReport;
|
||||
|
||||
newPrivate = (JSExnPrivate *)JS_malloc(cx, sizeof (JSExnPrivate));
|
||||
|
||||
JS_ASSERT(message);
|
||||
newMessage = (char *)JS_malloc(cx, strlen(message)+1);
|
||||
strcpy(newMessage, message);
|
||||
newPrivate->message = newMessage;
|
||||
|
||||
/* Copy the error report */
|
||||
newReport = (JSErrorReport *)JS_malloc(cx, sizeof (JSErrorReport));
|
||||
|
||||
if (report->filename) {
|
||||
if (report->filename != NULL) {
|
||||
newReport->filename =
|
||||
(const char *)JS_malloc(cx, strlen(report->filename)+1);
|
||||
/* Ack. Const! */
|
||||
strcpy((char *)newReport->filename, report->filename);
|
||||
} else {
|
||||
newReport->filename = NULL;
|
||||
@@ -101,19 +91,17 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report, const char *message)
|
||||
/*
|
||||
* But we do need to copy uclinebuf, uctokenptr, because they're
|
||||
* pointers into internal tokenstream structs, and may go away.
|
||||
* But only if they're non-null...
|
||||
*
|
||||
* NOTE nothing uses this and I'm not really maintaining it until
|
||||
* I know it's the desired API.
|
||||
*
|
||||
* Temporarily disabled, because uclinebuf is 0x10 when I evaluate 'Math()'!
|
||||
*/
|
||||
|
||||
#if 0
|
||||
if (report->uclinebuf) {
|
||||
size_t len = js_strlen(report->uclinebuf)+1;
|
||||
if (report->uclinebuf != NULL) {
|
||||
len = js_strlen(report->uclinebuf) + 1;
|
||||
newReport->uclinebuf =
|
||||
(const jschar *)JS_malloc(cx, len);
|
||||
(const jschar *)JS_malloc(cx, len * sizeof(jschar));
|
||||
js_strncpy(newReport->uclinebuf, report->uclinebuf, len);
|
||||
newReport->uctokenptr = newReport->uclinebuf + (report->uctokenptr -
|
||||
report->uclinebuf);
|
||||
@@ -121,18 +109,45 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report, const char *message)
|
||||
#endif
|
||||
newReport->uclinebuf = newReport->uctokenptr = NULL;
|
||||
|
||||
/* Executing the code below makes a seg fault where JS_malloc fails!? */
|
||||
#if 0
|
||||
if (report->ucmessage != NULL) {
|
||||
len = js_strlen(report->ucmessage) + 1;
|
||||
newReport->ucmessage = (const jschar *)JS_malloc(cx, len);
|
||||
js_strncpy((jschar *)newReport->ucmessage, report->ucmessage, len);
|
||||
|
||||
if (report->messageArgs) {
|
||||
int i;
|
||||
|
||||
for (i = 0; report->messageArgs[i] != NULL; i++)
|
||||
;
|
||||
JS_ASSERT(i);
|
||||
newReport->messageArgs =
|
||||
(const jschar **)JS_malloc(cx, (i + 1) * sizeof(jschar *));
|
||||
for (i = 0; report->messageArgs[i] != NULL; i++) {
|
||||
len = js_strlen(report->messageArgs[i]) + 1;
|
||||
newReport->messageArgs[i] =
|
||||
(const jschar *)JS_malloc(cx, len * sizeof(jschar));
|
||||
js_strncpy((jschar *)(newReport->messageArgs[i]),
|
||||
report->messageArgs[i], len);
|
||||
}
|
||||
report->messageArgs[i] = NULL;
|
||||
} else {
|
||||
report->messageArgs = NULL;
|
||||
}
|
||||
} else {
|
||||
newReport->ucmessage = NULL;
|
||||
newReport->messageArgs = NULL;
|
||||
}
|
||||
#else
|
||||
newReport->ucmessage = NULL;
|
||||
newReport->messageArgs = NULL;
|
||||
#endif
|
||||
|
||||
/* Note that this is before it gets flagged with JSREPORT_EXCEPTION */
|
||||
newReport->flags = report->flags;
|
||||
|
||||
/* Skipping *ucmessage, **messageArgs for now. My guess is that it'll just
|
||||
* mean copying the pointers, and adding another GC root. Then de-rooting
|
||||
* them in the finalizer. Dunno if they're rooted in the first place -
|
||||
* maybe it's only relevant for an exception that goes where it pleases,
|
||||
* and not for the formerly stack-bound use of the error report.
|
||||
*/
|
||||
|
||||
newPrivate->errorReport = newReport;
|
||||
|
||||
return newPrivate;
|
||||
}
|
||||
|
||||
@@ -142,36 +157,65 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report, const char *message)
|
||||
static void
|
||||
exn_destroyPrivate(JSContext *cx, JSExnPrivate *privateData)
|
||||
{
|
||||
JS_ASSERT(privateData->message);
|
||||
/* ! what does const do? */
|
||||
JS_free(cx, (void *)privateData->message);
|
||||
|
||||
JS_ASSERT(privateData->errorReport);
|
||||
if (privateData->errorReport->uclinebuf)
|
||||
JS_free(cx, (void *)privateData->errorReport->uclinebuf);
|
||||
|
||||
if (privateData->errorReport->filename)
|
||||
JS_free(cx, (void *)privateData->errorReport->filename);
|
||||
|
||||
JS_free(cx, privateData->errorReport);
|
||||
|
||||
JSErrorReport *report;
|
||||
const jschar **args;
|
||||
|
||||
report = privateData->errorReport;
|
||||
JS_ASSERT(report);
|
||||
if (report->uclinebuf)
|
||||
JS_free(cx, (void *)report->uclinebuf);
|
||||
if (report->filename)
|
||||
JS_free(cx, (void *)report->filename);
|
||||
if (report->ucmessage)
|
||||
JS_free(cx, (void *)report->ucmessage);
|
||||
if (report->ucmessage)
|
||||
JS_free(cx, (void *)report->ucmessage);
|
||||
if (report->messageArgs) {
|
||||
args = report->messageArgs;
|
||||
while(*args++ != NULL)
|
||||
JS_free(cx, (void *)*args);
|
||||
JS_free(cx, (void *)report->messageArgs);
|
||||
}
|
||||
JS_free(cx, report);
|
||||
JS_free(cx, privateData);
|
||||
}
|
||||
|
||||
/* Destroy associated data... */
|
||||
static void
|
||||
exn_finalize(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSExnPrivate *privateData;
|
||||
jsval private;
|
||||
|
||||
privateData = (JSExnPrivate *)
|
||||
JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE));
|
||||
private = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
|
||||
|
||||
if (privateData) {
|
||||
exn_destroyPrivate(cx, privateData);
|
||||
if (private != JSVAL_NULL) {
|
||||
privateData = JSVAL_TO_PRIVATE(private);
|
||||
if (privateData)
|
||||
exn_destroyPrivate(cx, privateData);
|
||||
}
|
||||
}
|
||||
|
||||
static JSErrorReport *
|
||||
js_ErrorFromException(JSContext *cx, jsval exn)
|
||||
{
|
||||
JSObject *obj;
|
||||
JSExnPrivate *privateData;
|
||||
jsval private;
|
||||
|
||||
if (!JSVAL_IS_OBJECT(exn))
|
||||
return NULL;
|
||||
obj = JSVAL_TO_OBJECT(exn);
|
||||
if (OBJ_GET_CLASS(cx, obj) != &exn_class)
|
||||
return NULL;
|
||||
private = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
|
||||
privateData = JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE));
|
||||
if (!privateData)
|
||||
return NULL;
|
||||
|
||||
JS_ASSERT(privateData->errorReport);
|
||||
return privateData->errorReport;
|
||||
}
|
||||
|
||||
/* This must be kept in synch with the exceptions array below. */
|
||||
typedef enum JSExnType {
|
||||
JSEXN_NONE = -1,
|
||||
@@ -191,160 +235,169 @@ typedef enum JSExnType {
|
||||
JSEXN_LIMIT
|
||||
} JSExnType;
|
||||
|
||||
#define FLAGS JSCLASS_HAS_PRIVATE
|
||||
|
||||
/* Maybe #define RANDOM_CLASS(name, prototype) 4 here? */
|
||||
struct JSExnSpec {
|
||||
int protoIndex;
|
||||
JSClass theclass;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/*
|
||||
* I want to replace all of these with just one class. All we really care
|
||||
* about is the prototypes, and the constructor names.
|
||||
*/
|
||||
static struct JSExnSpec exceptions[] = {
|
||||
{ JSEXN_NONE, /* No proto? */ {
|
||||
"Exception", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_EXCEPTION, {
|
||||
"Error", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"InternalError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"SyntaxError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"ReferenceError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"CallError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_CALLERR, {
|
||||
"TargetError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"ConstructorError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"ConversionError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_CONVERSIONERR, {
|
||||
"ToObjectError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_CONVERSIONERR, {
|
||||
"ToPrimitiveError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_CONVERSIONERR, {
|
||||
"DefaultValueError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_ERR, {
|
||||
"ArrayError", FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, exn_finalize
|
||||
} },
|
||||
{ JSEXN_NONE, "Exception" },
|
||||
{ JSEXN_EXCEPTION, "Error" },
|
||||
{ JSEXN_ERR, "InternalError" },
|
||||
{ JSEXN_ERR, "SyntaxError" },
|
||||
{ JSEXN_ERR, "ReferenceError" },
|
||||
{ JSEXN_ERR, "CallError" },
|
||||
{ JSEXN_CALLERR, "TargetError" },
|
||||
{ JSEXN_ERR, "ConstructorError" },
|
||||
{ JSEXN_ERR, "ConversionError" },
|
||||
{ JSEXN_CONVERSIONERR, "ToObjectError" },
|
||||
{ JSEXN_CONVERSIONERR, "ToPrimitiveError" },
|
||||
{ JSEXN_CONVERSIONERR, "DefaultValueError" },
|
||||
{ JSEXN_ERR, "ArrayError" },
|
||||
{0}
|
||||
};
|
||||
|
||||
static JSBool
|
||||
Exception(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSString *message;
|
||||
|
||||
/*
|
||||
* Does it make sense to throw a not-a-function-error here?
|
||||
* A constructor that was not a function would be novel.
|
||||
*/
|
||||
if (!cx->fp->constructing) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* gotta null out that private data */
|
||||
OBJ_SET_SLOT(cx, obj, JSSLOT_PRIVATE, JSVAL_NULL);
|
||||
/*
|
||||
* If it's a new object of class Exception, then null out the private
|
||||
* data so that the finalizer doesn't attempt to free it.
|
||||
*/
|
||||
if (OBJ_GET_CLASS(cx, obj) == &exn_class)
|
||||
OBJ_SET_SLOT(cx, obj, JSSLOT_PRIVATE, JSVAL_NULL);
|
||||
|
||||
/*
|
||||
* Set the 'message' property.
|
||||
*/
|
||||
if (argc > 0) {
|
||||
message = js_ValueToString(cx, argv[0]);
|
||||
if (!message)
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
message = cx->runtime->emptyString;
|
||||
}
|
||||
if (!JS_DefineProperty(cx, obj, "message", STRING_TO_JSVAL(message),
|
||||
NULL, NULL, JSPROP_ENUMERATE));
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to string. Much of this is taken from js.c.
|
||||
* Convert to string.
|
||||
*
|
||||
* I should rewrite this to use message, line, file etc. from
|
||||
* javascript-modifiable properties (which might be lazily created
|
||||
* from the encapsulated error report.)
|
||||
* This method only uses JavaScript-modifiable properties name, message; it is
|
||||
* left to the host to check for private data and report filename and line
|
||||
* number information along with this message.
|
||||
*/
|
||||
static JSBool
|
||||
exn_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSString *str;
|
||||
JSExnPrivate *privateData;
|
||||
JSErrorReport *report;
|
||||
jsval v;
|
||||
char *name;
|
||||
JSClass *theclass;
|
||||
JSString *name, *message, *result;
|
||||
jschar *chars, *cp;
|
||||
size_t length;
|
||||
jsid id;
|
||||
|
||||
/* Check needed against incompatible target... */
|
||||
id = (jsid) cx->runtime->atomState.nameAtom;
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, id, &v) || !(name = js_ValueToString(cx, v)))
|
||||
return JS_FALSE;
|
||||
|
||||
/* Try to include the exception name in the error message. */
|
||||
theclass = OBJ_GET_CLASS(cx, obj);
|
||||
name = theclass->name;
|
||||
if (!JS_GetProperty(cx, obj, "message", &v) ||
|
||||
!(message = js_ValueToString(cx, v)))
|
||||
return JS_FALSE;
|
||||
|
||||
v = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
|
||||
|
||||
if (!JSVAL_IS_NULL(v)) {
|
||||
char *msgbuf, *tmp;
|
||||
|
||||
privateData = JSVAL_TO_PRIVATE(v);
|
||||
report = privateData->errorReport;
|
||||
|
||||
msgbuf = JS_smprintf("%s:", name);
|
||||
|
||||
if (report->filename) {
|
||||
tmp = msgbuf;
|
||||
msgbuf = JS_smprintf("%s%s:", tmp, report->filename);
|
||||
JS_free(cx, tmp);
|
||||
}
|
||||
if (report->lineno) {
|
||||
tmp = msgbuf;
|
||||
msgbuf = JS_smprintf("%s%u: ", tmp ? tmp : "", report->lineno);
|
||||
if (tmp)
|
||||
JS_free(cx, tmp);
|
||||
}
|
||||
JS_ASSERT(privateData->message);
|
||||
tmp = msgbuf;
|
||||
msgbuf = JS_smprintf("%s%s", tmp ? tmp : "", privateData->message);
|
||||
if(tmp)
|
||||
JS_free(cx, tmp);
|
||||
|
||||
str = JS_NewStringCopyZ(cx, msgbuf);
|
||||
if (message->length > 0) {
|
||||
length = name->length + message->length + 2;
|
||||
cp = chars = JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
|
||||
js_strncpy(cp, name->chars, name->length);
|
||||
cp += name->length;
|
||||
*cp++ = ':'; *cp++ = ' ';
|
||||
js_strncpy(cp, message->chars, message->length);
|
||||
cp += message->length;
|
||||
*cp = 0;
|
||||
|
||||
result = js_NewString(cx, chars, length, 0);
|
||||
if (!result) {
|
||||
JS_free(cx, chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
} else {
|
||||
str = JS_NewStringCopyZ(cx, "some non-engine-thrown exception");
|
||||
result = name;
|
||||
}
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
|
||||
*rval = STRING_TO_JSVAL(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#if JS_HAS_TOSOURCE
|
||||
/*
|
||||
* Return a string that may eval to something similar to the original object.
|
||||
*/
|
||||
static JSBool
|
||||
exn_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSString *name, *message, *result;
|
||||
jschar *chars, *cp;
|
||||
jsid id;
|
||||
size_t length;
|
||||
jsval v;
|
||||
|
||||
id = (jsid) cx->runtime->atomState.nameAtom;
|
||||
if (!OBJ_GET_PROPERTY(cx, obj, id, &v) || !(name = js_ValueToString(cx, v)))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JS_GetProperty(cx, obj, "message", &v) ||
|
||||
!(message = js_ValueToString(cx, v)))
|
||||
return JS_FALSE;
|
||||
|
||||
length = (message->length > 0) ? name->length + message->length + 10
|
||||
: name->length + 8;
|
||||
|
||||
cp = chars = JS_malloc(cx, (length + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
return JS_FALSE;
|
||||
|
||||
*cp++ = '('; *cp++ = 'n'; *cp++ = 'e'; *cp++ = 'w'; *cp++ = ' ';
|
||||
js_strncpy(cp, name->chars, name->length);
|
||||
cp += name->length;
|
||||
*cp++ = '(';
|
||||
if (message->length > 0) {
|
||||
*cp++ = '"';
|
||||
js_strncpy(cp, message->chars, message->length);
|
||||
cp += message->length;
|
||||
*cp++ = '"';
|
||||
}
|
||||
*cp++ = ')'; *cp++ = ')'; *cp = 0;
|
||||
|
||||
result = js_NewString(cx, chars, length, 0);
|
||||
if (!result) {
|
||||
JS_free(cx, chars);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = STRING_TO_JSVAL(result);
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSFunctionSpec exception_methods[] = {
|
||||
#if JS_HAS_TOSOURCE
|
||||
{js_toSource_str, exn_toSource, 0},
|
||||
#endif
|
||||
{js_toString_str, exn_toString, 0},
|
||||
{0}
|
||||
};
|
||||
@@ -352,58 +405,77 @@ static JSFunctionSpec exception_methods[] = {
|
||||
JSObject *
|
||||
js_InitExceptionClasses(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
|
||||
JSObject *protos[JSEXN_LIMIT];
|
||||
int i;
|
||||
JSObject *protos[JSEXN_LIMIT];
|
||||
|
||||
for (i = 0; exceptions[i].theclass.name != 0; i++) {
|
||||
int protoidx = exceptions[i].protoIndex;
|
||||
protos[i] = JS_InitClass(cx, obj,
|
||||
((protoidx >= 0) ? protos[protoidx] : NULL),
|
||||
&(exceptions[i].theclass),
|
||||
Exception, 1,
|
||||
NULL,
|
||||
exception_methods,
|
||||
NULL,
|
||||
NULL);
|
||||
/* Initialize the prototypes first. */
|
||||
for (i = 0; exceptions[i].name != 0; i++) {
|
||||
JSAtom *atom;
|
||||
JSFunction *fun;
|
||||
JSString *nameString;
|
||||
int protoidx = exceptions[i].protoIndex;
|
||||
|
||||
/* Make the prototype for the current constructor name. */
|
||||
protos[i] = js_NewObject(cx, &exn_class,
|
||||
protoidx >= 0 ? protos[protoidx] : NULL,
|
||||
obj);
|
||||
if (!protos[i])
|
||||
return NULL;
|
||||
|
||||
/* So finalize knows whether to. */
|
||||
OBJ_SET_SLOT(cx, protos[i], JSSLOT_PRIVATE, JSVAL_NULL);
|
||||
atom = js_Atomize(cx, exceptions[i].name, strlen(exceptions[i].name), 0);
|
||||
|
||||
/* Make a constructor function for the current name. */
|
||||
fun = js_DefineFunction(cx, obj, atom, Exception, 1, 0);
|
||||
if (!fun)
|
||||
return NULL; /* XXX also remove named property from obj... */
|
||||
|
||||
/* Make this constructor make objects of class Exception. */
|
||||
fun->clasp = &exn_class;
|
||||
|
||||
/* Make the prototype and constructor links. */
|
||||
if (!js_SetClassPrototype(cx, fun->object, protos[i],
|
||||
JSPROP_READONLY | JSPROP_PERMANENT))
|
||||
return NULL;
|
||||
|
||||
/* proto bootstrap bit from JS_InitClass omitted. */
|
||||
nameString = JS_NewStringCopyZ(cx, exceptions[i].name);
|
||||
if (nameString == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Add the name property to the prototype. */
|
||||
if (!JS_DefineProperty(cx, protos[i], js_name_str,
|
||||
STRING_TO_JSVAL(nameString),
|
||||
NULL, NULL,
|
||||
JSPROP_ENUMERATE)) {
|
||||
/* release it? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* So finalize knows whether to. */
|
||||
OBJ_SET_SLOT(cx, protos[i], JSSLOT_PRIVATE, JSVAL_NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* JS_InitClass magically replaces a null prototype with Object.prototype,
|
||||
* so we need to explicitly assign to the proto slot to get null.
|
||||
*
|
||||
* Temporarily disabled until I do toString for Exception.
|
||||
* Add an empty message property. (To Exception.prototype only,
|
||||
* because this property will be the same for all the exception
|
||||
* protos.)
|
||||
*/
|
||||
|
||||
/* protos[0]->slots[JSSLOT_PROTO] = JSVAL_NULL; */
|
||||
if (!JS_DefineProperty(cx, protos[0], "message",
|
||||
STRING_TO_JSVAL(cx->runtime->emptyString),
|
||||
NULL, NULL, JSPROP_ENUMERATE))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* Add methods only to Exception.prototype, because ostensibly all
|
||||
* exception types delegate to that.
|
||||
*/
|
||||
if (!JS_DefineFunctions(cx, protos[0], exception_methods))
|
||||
return NULL;
|
||||
|
||||
return protos[0];
|
||||
}
|
||||
|
||||
static JSErrorReport *
|
||||
js_GetErrorFromException(JSContext *cx, JSObject *errobj)
|
||||
{
|
||||
JSExnPrivate *privateData;
|
||||
#if 0
|
||||
{
|
||||
JSClass *errobjclass;
|
||||
/* Assert that we have an Exception object */
|
||||
/* This assert does the right thing, but we can't use it yet, because
|
||||
* we're throwing lots of different exception classes. */
|
||||
errobjclass = OBJ_GET_CLASS(cx, errobj);
|
||||
JS_ASSERT(errobjclass == &(exceptions[JSEXN_CALLERR].theclass));
|
||||
}
|
||||
#endif
|
||||
privateData = JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, errobj, JSSLOT_PRIVATE));
|
||||
|
||||
/* Still OK to return NULL, tho. */
|
||||
return privateData->errorReport;
|
||||
}
|
||||
|
||||
static JSExnType errorToException[] = {
|
||||
static JSExnType errorToExceptionNum[] = {
|
||||
#define MSG_DEF(name, number, count, exception, format) \
|
||||
exception,
|
||||
#include "js.msg"
|
||||
@@ -421,16 +493,18 @@ static struct exnname { char *name; char *exception; } errortoexnname[] = {
|
||||
#endif /* DEBUG */
|
||||
|
||||
JSBool
|
||||
js_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message)
|
||||
js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp)
|
||||
{
|
||||
JSErrNum errorNumber;
|
||||
JSObject *errobj;
|
||||
JSObject *errObject, *errProto;
|
||||
JSExnType exn;
|
||||
JSExnPrivate *privateData;
|
||||
JSString *msgstr;
|
||||
|
||||
/* Find the exception index associated with this error. */
|
||||
JS_ASSERT(reportp);
|
||||
errorNumber = reportp->errorNumber;
|
||||
exn = errorToException[errorNumber];
|
||||
exn = errorToExceptionNum[errorNumber];
|
||||
JS_ASSERT(exn < JSEXN_LIMIT);
|
||||
|
||||
#if defined( DEBUG_mccabe ) && defined ( PRINTNAMES )
|
||||
@@ -448,14 +522,26 @@ js_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message)
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* Should (?) be js_ConstructObject... switching to NewObject
|
||||
* in the speculation that it won't require a frame. DefaultValue trouble.
|
||||
* And it seems to work???? For the record, the trouble was that
|
||||
* cx->fp was null when trying to construct the object...
|
||||
* Try to get an appropriate prototype by looking up the corresponding
|
||||
* exception constructor name in the current context. If the constructor
|
||||
* has been deleted or overwritten, this may fail or return NULL, and
|
||||
* js_NewObject will fall back to using Object.prototype.
|
||||
*/
|
||||
errobj = js_NewObject(cx,
|
||||
&(exceptions[exn].theclass),
|
||||
NULL, NULL);
|
||||
if (!js_GetClassPrototype(cx, exceptions[exn].name, &errProto))
|
||||
errProto = NULL;
|
||||
|
||||
/*
|
||||
* Use js_NewObject instead of js_ConstructObject, because
|
||||
* js_ConstructObject seems to require a frame.
|
||||
*/
|
||||
errObject = js_NewObject(cx, &exn_class, errProto, NULL);
|
||||
|
||||
/* Store 'message' as a javascript-visible value. */
|
||||
msgstr = JS_NewStringCopyZ(cx, message);
|
||||
if (!JS_DefineProperty(cx, errObject, "message", STRING_TO_JSVAL(msgstr),
|
||||
NULL, NULL,
|
||||
JSPROP_ENUMERATE))
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* Construct a new copy of the error report, and store it in the
|
||||
@@ -463,15 +549,71 @@ js_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message)
|
||||
* handed in, because it's stack-allocated, and may point to transient
|
||||
* data in the JSTokenStream.
|
||||
*/
|
||||
privateData = exn_initPrivate(cx, reportp);
|
||||
OBJ_SET_SLOT(cx, errObject, JSSLOT_PRIVATE, PRIVATE_TO_JSVAL(privateData));
|
||||
|
||||
/* XXX report failure? */
|
||||
privateData = exn_initPrivate(cx, reportp, message);
|
||||
OBJ_SET_SLOT(cx, errobj, JSSLOT_PRIVATE, PRIVATE_TO_JSVAL(privateData));
|
||||
/* Set the generated Exception object as the current exception. */
|
||||
JS_SetPendingException(cx, OBJECT_TO_JSVAL(errObject));
|
||||
|
||||
JS_SetPendingException(cx, OBJECT_TO_JSVAL(errobj));
|
||||
/* Flag the error report passed in to indicate an exception was raised. */
|
||||
reportp->flags |= JSREPORT_EXCEPTION;
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* JS_HAS_ERROR_EXCEPTIONS */
|
||||
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
|
||||
extern JSBool
|
||||
js_ReportUncaughtException(JSContext *cx)
|
||||
{
|
||||
JSObject *exnObject;
|
||||
JSString *str;
|
||||
jsval exn;
|
||||
JSErrorReport *reportp;
|
||||
|
||||
if (!JS_IsExceptionPending(cx))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JS_GetPendingException(cx, &exn))
|
||||
return JS_FALSE;
|
||||
|
||||
/*
|
||||
* Because js_ValueToString below could error and an exception object
|
||||
* could become unrooted, we root it here.
|
||||
*/
|
||||
if (JSVAL_IS_OBJECT(exn)) {
|
||||
exnObject = JSVAL_TO_OBJECT(exn);
|
||||
if (!js_AddRoot(cx, exnObject, "exn.report.root"))
|
||||
return JS_FALSE;
|
||||
} else {
|
||||
exnObject = NULL;
|
||||
}
|
||||
str = js_ValueToString(cx, exn);
|
||||
|
||||
#if JS_HAS_ERROR_EXCEPTIONS
|
||||
reportp = js_ErrorFromException(cx, exn);
|
||||
#else
|
||||
reportp = NULL;
|
||||
#endif
|
||||
|
||||
if (reportp == NULL) {
|
||||
/*
|
||||
* XXXmccabe todo: Instead of doing this, synthesize an error report
|
||||
* struct that includes the filename, lineno where the exception was
|
||||
* originally thrown.
|
||||
*/
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_UNCAUGHT_EXCEPTION, js_GetStringBytes(str));
|
||||
} else {
|
||||
/* Flag the error as an exception. */
|
||||
reportp->flags |= JSREPORT_EXCEPTION;
|
||||
js_ReportErrorAgain(cx, js_GetStringBytes(str), reportp);
|
||||
}
|
||||
|
||||
if (exnObject != NULL)
|
||||
js_RemoveRoot(cx, exnObject);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
#endif /* JS_HAS_ERROR_EXCEPTIONS */
|
||||
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
|
||||
@@ -32,15 +32,34 @@ extern JSObject *
|
||||
js_InitExceptionClasses(JSContext *cx, JSObject *obj);
|
||||
|
||||
/*
|
||||
* Given a JSErrorReport, check to see if there is an exception associated
|
||||
* with the error number. If there is, then create an appropriate exception
|
||||
* object, set it as the pending exception, and set the JSREPORT_EXCEPTION
|
||||
* flag on the error report. Exception-aware host error reporters will
|
||||
* know to ignore error reports so flagged. Returns JS_TRUE if an associated
|
||||
* exception is found, JS_FALSE if none.
|
||||
* Given a JSErrorReport, check to see if there is an exception associated with
|
||||
* the error number. If there is, then create an appropriate exception object,
|
||||
* set it as the pending exception, and set the JSREPORT_EXCEPTION flag on the
|
||||
* error report. Exception-aware host error reporters should probably ignore
|
||||
* error reports so flagged. Returns JS_TRUE if an associated exception is
|
||||
* found and set, JS_FALSE otherwise..
|
||||
*/
|
||||
extern JSBool
|
||||
js_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message);
|
||||
js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp);
|
||||
|
||||
/*
|
||||
* Called if an api call to js_Execute or js_CallFunctionValue fails; calls the
|
||||
* error reporter with the error report associated with any uncaught exception
|
||||
* that has been raised. Returns true if there was an exception pending, and
|
||||
* the error reporter was actually called.
|
||||
*
|
||||
* The JSErrorReport * that the error reporter is called with is currently
|
||||
* associated with a JavaScript object, and is not guaranteed to persist after
|
||||
* the object is collected. Any persistent uses of the JSErrorReport contents
|
||||
* should make their own copy.
|
||||
*
|
||||
* The flags field of the JSErrorReport will have the JSREPORT_EXCEPTION flag
|
||||
* set; embeddings that want to silently propagate JavaScript exceptions to
|
||||
* other contexts may want to use an error reporter that ignores errors with
|
||||
* this flag.
|
||||
*/
|
||||
extern JSBool
|
||||
js_ReportUncaughtException(JSContext *cx);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
2265
mozilla/js/src/jsfile.c
Normal file
2265
mozilla/js/src/jsfile.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,10 +16,12 @@
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nspr_win32_defs_h___
|
||||
#define nspr_win32_defs_h___
|
||||
#ifndef _jsfile_h__
|
||||
#define _jsfile_h__
|
||||
|
||||
#define HAVE_DLL
|
||||
#define HAVE_LONG_LONG
|
||||
extern JSObject*
|
||||
js_InitFileClass(JSContext *cx, JSObject* obj);
|
||||
|
||||
|
||||
#endif /* _jsfile_h__ */
|
||||
|
||||
#endif /* nspr_win32_defs_h___ */
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "jsstddef.h"
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
@@ -539,18 +538,17 @@ call_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
|
||||
propid = sprop->id;
|
||||
symid = (jsid) sym_atom(sprop->symbols);
|
||||
OBJ_DROP_PROPERTY(cx, obj2, (JSProperty *)sprop);
|
||||
vp = NULL;
|
||||
if (getter == js_GetArgument) {
|
||||
vp = fp->argv;
|
||||
nslots = fp->argc;
|
||||
getter = setter = NULL;
|
||||
} else if (getter == js_GetLocalVariable) {
|
||||
vp = fp->vars;
|
||||
nslots = fp->nvars;
|
||||
getter = js_GetCallVariable;
|
||||
setter = js_SetCallVariable;
|
||||
}
|
||||
if (vp) {
|
||||
if (getter == js_GetArgument || getter == js_GetLocalVariable) {
|
||||
if (getter == js_GetArgument) {
|
||||
vp = fp->argv;
|
||||
nslots = fp->argc;
|
||||
getter = setter = NULL;
|
||||
} else {
|
||||
vp = fp->vars;
|
||||
nslots = fp->nvars;
|
||||
getter = js_GetCallVariable;
|
||||
setter = js_SetCallVariable;
|
||||
}
|
||||
slot = (uintN)JSVAL_TO_INT(propid);
|
||||
if (!js_DefineProperty(cx, obj, symid,
|
||||
(slot < nslots) ? vp[slot] : JSVAL_VOID,
|
||||
@@ -1087,7 +1085,10 @@ fun_xdrObject(JSXDRState *xdr, JSObject **objp)
|
||||
getter = js_GetLocalVariable;
|
||||
setter = js_SetLocalVariable;
|
||||
JS_ASSERT(nvars++ <= fun->nvars);
|
||||
}
|
||||
} else {
|
||||
getter = NULL;
|
||||
setter = NULL;
|
||||
}
|
||||
atom = js_Atomize(xdr->cx, propname, strlen(propname), 0);
|
||||
if (!atom ||
|
||||
!OBJ_DEFINE_PROPERTY(xdr->cx, fun->object, (jsid)atom,
|
||||
@@ -1190,11 +1191,27 @@ fun_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
uint32 indent;
|
||||
JSString *str;
|
||||
|
||||
if (!OBJ_DEFAULT_VALUE(cx, obj, JSTYPE_FUNCTION, &argv[-1]))
|
||||
return JS_FALSE;
|
||||
fval = argv[-1];
|
||||
if (!JSVAL_IS_FUNCTION(cx, fval))
|
||||
return js_obj_toString(cx, obj, argc, argv, rval);
|
||||
fval = argv[-1];
|
||||
if (!JSVAL_IS_FUNCTION(cx, fval)) {
|
||||
/*
|
||||
if we don't have a function to start off with, try converting the
|
||||
object to a function. If that doesn't work, complain.
|
||||
*/
|
||||
if (JSVAL_IS_OBJECT(fval)) {
|
||||
obj = JSVAL_TO_OBJECT(fval);
|
||||
if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj,
|
||||
JSTYPE_FUNCTION, &fval))
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!JSVAL_IS_FUNCTION(cx, fval)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
"Function", "toString",
|
||||
JS_GetTypeName(cx, JS_TypeOfValue(cx, fval)));
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
obj = JSVAL_TO_OBJECT(fval);
|
||||
fun = JS_GetPrivate(cx, obj);
|
||||
if (!fun)
|
||||
@@ -1223,6 +1240,14 @@ fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
fval = argv[-1];
|
||||
|
||||
if (!JSVAL_IS_FUNCTION(cx, fval)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
"Function", "call",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, fval)));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
/* Call fun with its parent as the 'this' parameter if no args. */
|
||||
obj = OBJ_GET_PARENT(cx, obj);
|
||||
@@ -1282,6 +1307,13 @@ fun_apply(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
fval = argv[-1];
|
||||
|
||||
if (!JSVAL_IS_FUNCTION(cx, fval)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_INCOMPATIBLE_PROTO,
|
||||
"Function", "apply",
|
||||
JS_GetStringBytes(JS_ValueToString(cx, fval)));
|
||||
return JS_FALSE;
|
||||
}
|
||||
/* Convert the first arg to 'this' and skip over it. */
|
||||
if (!js_ValueToObject(cx, argv[0], &obj))
|
||||
return JS_FALSE;
|
||||
@@ -1558,7 +1590,7 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
if (argv) {
|
||||
/* Use the last arg (or this if argc == 0) as a local GC root. */
|
||||
argv[argc-1] = STRING_TO_JSVAL(str);
|
||||
argv[(intn)(argc-1)] = STRING_TO_JSVAL(str);
|
||||
}
|
||||
|
||||
if ((fp = cx->fp) != NULL && (fp = fp->down) != NULL && fp->script) {
|
||||
@@ -1630,10 +1662,10 @@ bad:
|
||||
|
||||
JSBool
|
||||
js_InitArgsCallClosureClasses(JSContext *cx, JSObject *obj,
|
||||
JSObject *arrayProto)
|
||||
JSObject *objProto)
|
||||
{
|
||||
#if JS_HAS_ARGS_OBJECT
|
||||
if (!JS_InitClass(cx, obj, arrayProto, &js_ArgumentsClass, Arguments, 0,
|
||||
if (!JS_InitClass(cx, obj, objProto, &js_ArgumentsClass, Arguments, 0,
|
||||
args_props, NULL, NULL, NULL)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
@@ -1696,6 +1728,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
|
||||
fun->spare = 0;
|
||||
fun->atom = atom;
|
||||
fun->script = NULL;
|
||||
fun->clasp = NULL;
|
||||
return fun;
|
||||
}
|
||||
|
||||
@@ -1753,15 +1786,27 @@ void
|
||||
js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing)
|
||||
{
|
||||
JSStackFrame *fp;
|
||||
jsval *sp;
|
||||
JSString *str;
|
||||
const char *typeName;
|
||||
JSString *fallback;
|
||||
|
||||
fp = cx->fp;
|
||||
if (fp)
|
||||
sp = fp->sp, fp->sp = vp;
|
||||
str = js_DecompileValueGenerator(cx, *vp, NULL);
|
||||
if (fp)
|
||||
fp->sp = sp;
|
||||
/*
|
||||
* We provide the typename as the fallback to handle the case
|
||||
* when valueOf is not a function, which prevents ValueToString
|
||||
* from being called as the default case inside
|
||||
* js_DecompileValueGenerator (and so recursing back to here).
|
||||
*/
|
||||
typeName = JS_GetTypeName(cx, JS_TypeOfValue(cx, *vp));
|
||||
fallback = JS_InternString(cx, typeName);
|
||||
if (fp) {
|
||||
jsval *sp = fp->sp;
|
||||
fp->sp = vp;
|
||||
str = js_DecompileValueGenerator(cx, *vp, fallback);
|
||||
fp->sp = sp;
|
||||
} else {
|
||||
str = js_DecompileValueGenerator(cx, *vp, fallback);
|
||||
}
|
||||
if (str) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
constructing ? JSMSG_NOT_CONSTRUCTOR
|
||||
|
||||
@@ -37,6 +37,8 @@ struct JSFunction {
|
||||
uint8 spare; /* reserved for future use */
|
||||
JSAtom *atom; /* name for diagnostics and decompiling */
|
||||
JSScript *script; /* interpreted bytecode descriptor or null */
|
||||
JSClass *clasp; /* this function is a constructor for objects
|
||||
* of this class */
|
||||
};
|
||||
|
||||
extern JSClass js_ArgumentsClass;
|
||||
@@ -60,7 +62,7 @@ js_InitFunctionClass(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern JSBool
|
||||
js_InitArgsCallClosureClasses(JSContext *cx, JSObject *obj,
|
||||
JSObject *arrayProto);
|
||||
JSObject *objProto);
|
||||
|
||||
extern JSFunction *
|
||||
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
|
||||
|
||||
@@ -30,22 +30,9 @@
|
||||
#include <stdlib.h> /* for free, called by JS_ARENA_DESTROY */
|
||||
#include <string.h> /* for memset, called by jsarena.h macros if DEBUG */
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
#include "jscntxt.h"
|
||||
@@ -183,7 +170,7 @@ js_AllocGCThing(JSContext *cx, uintN flags)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
JSGCThing *thing;
|
||||
uint8 *flagp;
|
||||
uint8 *flagp = NULL;
|
||||
#ifdef TOO_MUCH_GC
|
||||
JSBool tried_gc = JS_TRUE;
|
||||
js_GC(cx);
|
||||
@@ -591,7 +578,7 @@ gc_hash_root(const void *key)
|
||||
return num >> 2;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(intN)
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
gc_root_marker(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
void **rp = (void **)he->key;
|
||||
@@ -600,11 +587,17 @@ gc_root_marker(JSHashEntry *he, intN i, void *arg)
|
||||
#ifdef DEBUG
|
||||
JSArena *a;
|
||||
JSRuntime *rt = (JSRuntime *)arg;
|
||||
JSBool root_points_to_gcArenaPool = JS_FALSE;
|
||||
|
||||
for (a = rt->gcArenaPool.first.next; a; a = a->next) {
|
||||
JS_ASSERT(!rp ||
|
||||
(*rp >= (void *)a->base && *rp <= (void *)a->avail));
|
||||
}
|
||||
if (rp && *rp) {
|
||||
for (a = rt->gcArenaPool.first.next; a; a = a->next) {
|
||||
if (*rp >= (void *)a->base && *rp <= (void *)a->avail) {
|
||||
root_points_to_gcArenaPool = JS_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JS_ASSERT(root_points_to_gcArenaPool);
|
||||
}
|
||||
#endif
|
||||
GC_MARK(arg, *rp, he->value ? he->value : "root", NULL);
|
||||
}
|
||||
@@ -778,8 +771,8 @@ restart:
|
||||
GC_MARK(rt, acx->newborn[GCX_STRING], "newborn string", NULL);
|
||||
GC_MARK(rt, acx->newborn[GCX_DOUBLE], "newborn double", NULL);
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
if (acx->throwing)
|
||||
GC_MARK(rt, acx->exception, "exception", NULL);
|
||||
if (acx->throwing && JSVAL_IS_GCTHING(acx->exception))
|
||||
GC_MARK(rt, JSVAL_TO_GCTHING(acx->exception), "exception", NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -23,18 +23,11 @@
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#include "jsbit.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
|
||||
/* Compute the number of buckets in ht */
|
||||
#define NBUCKETS(ht) JS_BIT(PR_HASH_BITS - (ht)->shift)
|
||||
#define NBUCKETS(ht) JS_BIT(JS_HASH_BITS - (ht)->shift)
|
||||
|
||||
/* The smallest table has 16 buckets */
|
||||
#define MINBUCKETSLOG2 4
|
||||
@@ -79,7 +72,7 @@ static JSHashAllocOps defaultHashAllocOps = {
|
||||
DefaultAllocEntry, DefaultFreeEntry
|
||||
};
|
||||
|
||||
IMPLEMENT(JSHashTable *)
|
||||
JS_EXPORT_API(JSHashTable *)
|
||||
JS_NewHashTable(uint32 n, JSHashFunction keyHash,
|
||||
JSHashComparator keyCompare, JSHashComparator valueCompare,
|
||||
JSHashAllocOps *allocOps, void *allocPriv)
|
||||
@@ -101,7 +94,7 @@ JS_NewHashTable(uint32 n, JSHashFunction keyHash,
|
||||
if (!ht)
|
||||
return NULL;
|
||||
memset(ht, 0, sizeof *ht);
|
||||
ht->shift = PR_HASH_BITS - n;
|
||||
ht->shift = JS_HASH_BITS - n;
|
||||
n = JS_BIT(n);
|
||||
#if defined(XP_PC) && defined _MSC_VER && _MSC_VER <= 800
|
||||
if (n > 16000) {
|
||||
@@ -125,7 +118,7 @@ JS_NewHashTable(uint32 n, JSHashFunction keyHash,
|
||||
return ht;
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_HashTableDestroy(JSHashTable *ht)
|
||||
{
|
||||
uint32 i, n;
|
||||
@@ -153,7 +146,7 @@ JS_HashTableDestroy(JSHashTable *ht)
|
||||
/*
|
||||
** Multiplicative hash, from Knuth 6.4.
|
||||
*/
|
||||
IMPLEMENT(JSHashEntry **)
|
||||
JS_EXPORT_API(JSHashEntry **)
|
||||
JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
|
||||
{
|
||||
JSHashEntry *he, **hep, **hep0;
|
||||
@@ -162,7 +155,7 @@ JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
|
||||
#ifdef HASHMETER
|
||||
ht->nlookups++;
|
||||
#endif
|
||||
h = keyHash * PR_GOLDEN_RATIO;
|
||||
h = keyHash * JS_GOLDEN_RATIO;
|
||||
h >>= ht->shift;
|
||||
hep = hep0 = &ht->buckets[h];
|
||||
while ((he = *hep) != NULL) {
|
||||
@@ -183,7 +176,7 @@ JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
|
||||
return hep;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSHashEntry *)
|
||||
JS_EXPORT_API(JSHashEntry *)
|
||||
JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep,
|
||||
JSHashNumber keyHash, const void *key, void *value)
|
||||
{
|
||||
@@ -240,7 +233,7 @@ JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep,
|
||||
return he;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSHashEntry *)
|
||||
JS_EXPORT_API(JSHashEntry *)
|
||||
JS_HashTableAdd(JSHashTable *ht, const void *key, void *value)
|
||||
{
|
||||
JSHashNumber keyHash;
|
||||
@@ -262,7 +255,7 @@ JS_HashTableAdd(JSHashTable *ht, const void *key, void *value)
|
||||
return JS_HashTableRawAdd(ht, hep, keyHash, key, value);
|
||||
}
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he)
|
||||
{
|
||||
uint32 i, n;
|
||||
@@ -304,7 +297,7 @@ JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he)
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT(JSBool)
|
||||
JS_EXPORT_API(JSBool)
|
||||
JS_HashTableRemove(JSHashTable *ht, const void *key)
|
||||
{
|
||||
JSHashNumber keyHash;
|
||||
@@ -320,7 +313,7 @@ JS_HashTableRemove(JSHashTable *ht, const void *key)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
IMPLEMENT(void *)
|
||||
JS_EXPORT_API(void *)
|
||||
JS_HashTableLookup(JSHashTable *ht, const void *key)
|
||||
{
|
||||
JSHashNumber keyHash;
|
||||
@@ -339,7 +332,7 @@ JS_HashTableLookup(JSHashTable *ht, const void *key)
|
||||
** entry found. Stop if "f" says to (return value & JS_ENUMERATE_STOP).
|
||||
** Return a count of the number of elements scanned.
|
||||
*/
|
||||
IMPLEMENT(int)
|
||||
JS_EXPORT_API(int)
|
||||
JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg)
|
||||
{
|
||||
JSHashEntry *he, **hep;
|
||||
@@ -380,7 +373,7 @@ out:
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
IMPLEMENT(void)
|
||||
JS_EXPORT_API(void)
|
||||
JS_HashTableDumpMeter(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
double mean, variance;
|
||||
@@ -426,7 +419,7 @@ JS_HashTableDumpMeter(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
|
||||
}
|
||||
#endif /* HASHMETER */
|
||||
|
||||
IMPLEMENT(int)
|
||||
JS_EXPORT_API(int)
|
||||
JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
|
||||
{
|
||||
int count;
|
||||
@@ -438,7 +431,7 @@ JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
|
||||
return count;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSHashNumber)
|
||||
JS_EXPORT_API(JSHashNumber)
|
||||
JS_HashString(const void *key)
|
||||
{
|
||||
JSHashNumber h;
|
||||
@@ -450,7 +443,7 @@ JS_HashString(const void *key)
|
||||
return h;
|
||||
}
|
||||
|
||||
IMPLEMENT(int)
|
||||
JS_EXPORT_API(int)
|
||||
JS_CompareValues(const void *v1, const void *v2)
|
||||
{
|
||||
return v1 == v2;
|
||||
|
||||
@@ -32,8 +32,8 @@ typedef uint32 JSHashNumber;
|
||||
typedef struct JSHashEntry JSHashEntry;
|
||||
typedef struct JSHashTable JSHashTable;
|
||||
|
||||
#define PR_HASH_BITS 32
|
||||
#define PR_GOLDEN_RATIO 0x9E3779B9U
|
||||
#define JS_HASH_BITS 32
|
||||
#define JS_GOLDEN_RATIO 0x9E3779B9U
|
||||
|
||||
typedef JSHashNumber (*JSHashFunction)(const void *key);
|
||||
typedef intN (*JSHashComparator)(const void *v1, const void *v2);
|
||||
@@ -83,47 +83,47 @@ struct JSHashTable {
|
||||
* Create a new hash table.
|
||||
* If allocOps is null, use default allocator ops built on top of malloc().
|
||||
*/
|
||||
EXTERN(JSHashTable *)
|
||||
JS_EXTERN_API(JSHashTable *)
|
||||
JS_NewHashTable(uint32 n, JSHashFunction keyHash,
|
||||
JSHashComparator keyCompare, JSHashComparator valueCompare,
|
||||
JSHashAllocOps *allocOps, void *allocPriv);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_HashTableDestroy(JSHashTable *ht);
|
||||
|
||||
/* Low level access methods */
|
||||
EXTERN(JSHashEntry **)
|
||||
JS_EXTERN_API(JSHashEntry **)
|
||||
JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key);
|
||||
|
||||
EXTERN(JSHashEntry *)
|
||||
JS_EXTERN_API(JSHashEntry *)
|
||||
JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep, JSHashNumber keyHash,
|
||||
const void *key, void *value);
|
||||
|
||||
EXTERN(void)
|
||||
JS_EXTERN_API(void)
|
||||
JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he);
|
||||
|
||||
/* Higher level access methods */
|
||||
EXTERN(JSHashEntry *)
|
||||
JS_EXTERN_API(JSHashEntry *)
|
||||
JS_HashTableAdd(JSHashTable *ht, const void *key, void *value);
|
||||
|
||||
EXTERN(JSBool)
|
||||
JS_EXTERN_API(JSBool)
|
||||
JS_HashTableRemove(JSHashTable *ht, const void *key);
|
||||
|
||||
EXTERN(intN)
|
||||
JS_EXTERN_API(intN)
|
||||
JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg);
|
||||
|
||||
EXTERN(void *)
|
||||
JS_EXTERN_API(void *)
|
||||
JS_HashTableLookup(JSHashTable *ht, const void *key);
|
||||
|
||||
EXTERN(intN)
|
||||
JS_EXTERN_API(intN)
|
||||
JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp);
|
||||
|
||||
/* General-purpose C string hash function. */
|
||||
EXTERN(JSHashNumber)
|
||||
JS_EXTERN_API(JSHashNumber)
|
||||
JS_HashString(const void *key);
|
||||
|
||||
/* Stub function just returns v1 == v2 */
|
||||
IMPLEMENT(intN)
|
||||
JS_EXTERN_API(intN)
|
||||
JS_CompareValues(const void *v1, const void *v2);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
@@ -75,8 +75,14 @@
|
||||
"PR_MapEvents",
|
||||
"PR_RevokeEvents",
|
||||
|
||||
"PR_cnvtf",
|
||||
"PR_dtoa",
|
||||
"PR_strtod",
|
||||
|
||||
"PRFileDesc",
|
||||
|
||||
"PR_HASH_BITS",
|
||||
"PR_GOLDEN_RATIO",
|
||||
"PRHashAllocOps",
|
||||
"PRHashComparator",
|
||||
"PRHashEntry",
|
||||
@@ -390,17 +396,13 @@ sub convert_includes {
|
||||
}
|
||||
|
||||
if ($line =~ /prlog\.h/) {
|
||||
chop $line;
|
||||
$line = "/* Removed by JSIFY: $line */\n";
|
||||
$line .= '#include "jsutil.h"'. " /* Added by JSIFY */\n";
|
||||
$line = '#include "jsutil.h"'. " /* Added by JSIFY */\n";
|
||||
} elsif ($line =~ /plhash\.h/) {
|
||||
$line = "/* Removed by JSIFY: $line */\n";
|
||||
$line .= '#include "jshash.h"'. " /* Added by JSIFY */\n";
|
||||
$line = '#include "jshash.h"'. " /* Added by JSIFY */\n";
|
||||
} elsif ($line =~ /plarena\.h/) {
|
||||
$line = "/* Removed by JSIFY: $line */\n";
|
||||
$line .= '#include "jsarena.h"'. " /* Added by JSIFY */\n";
|
||||
$line = '#include "jsarena.h"'. " /* Added by JSIFY */\n";
|
||||
} elsif ($line =~ /prmem\.h/) {
|
||||
$line = "/* Removed by JSIFY: $line */\n";
|
||||
$line = "";
|
||||
} elsif ($line =~ /jsmsg\.def/) {
|
||||
$line = '#include "js.msg"' . "\n";
|
||||
} elsif ($line =~ /shellmsg\.def/) {
|
||||
@@ -413,13 +415,14 @@ sub convert_includes {
|
||||
|
||||
sub convert_declarations {
|
||||
($line) = @_;
|
||||
$line =~ s/PR_EXTERN/EXTERN/g;
|
||||
$line =~ s/PR_IMPLEMENT/IMPLEMENT/g;
|
||||
$line =~ s/PR_CALLBACK/DLL_CALLBACK/g;
|
||||
$line =~ s/PR_STATIC_CALLBACK/STATIC_DLL_CALLBACK/g;
|
||||
$line =~ s/PR_IMPORT/IMPORT/g;
|
||||
$line =~ s/PR_PUBLIC_API/PUBLIC_API/g;
|
||||
$line =~ s/PR_PUBLIC_DATA/PUBLIC_DATA/g;
|
||||
$line =~ s/PR_EXTERN/JS_EXTERN_API/g;
|
||||
$line =~ s/PR_IMPLEMENT_DATA/JS_EXPORT_DATA/g;
|
||||
$line =~ s/PR_IMPLEMENT/JS_EXPORT_API/g;
|
||||
$line =~ s/PR_CALLBACK/JS_DLL_CALLBACK/g;
|
||||
$line =~ s/PR_STATIC_CALLBACK/JS_STATIC_DLL_CALLBACK/g;
|
||||
$line =~ s/PR_IMPORT/JS_IMPORT/g;
|
||||
$line =~ s/PR_PUBLIC_API/JS_EXPORT_API/g;
|
||||
$line =~ s/PR_PUBLIC_DATA/JS_EXPORT_DATA/g;
|
||||
return $line;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
@@ -451,10 +444,19 @@ js_Invoke(JSContext *cx, uintN argc, JSBool constructing)
|
||||
/* Function is inlined, all other classes use object ops. */
|
||||
ops = funobj->map->ops;
|
||||
|
||||
/* Try converting to function, for closure and API compatibility. */
|
||||
ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v);
|
||||
if (!ok)
|
||||
goto out2;
|
||||
/* Try converting to function, for closure and API compatibility. */
|
||||
/*
|
||||
* We attempt the conversion under all circumstances for 1.2, but
|
||||
* only if there is a call op defined otherwise.
|
||||
*/
|
||||
if ((cx->version == JSVERSION_1_2)
|
||||
|| ((ops == &js_ObjectOps) ?
|
||||
(clasp->call != 0) : (ops->call != 0)) ) {
|
||||
ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v);
|
||||
if (!ok)
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_FUNCTION(cx, v)) {
|
||||
fun = NULL;
|
||||
script = NULL;
|
||||
@@ -755,6 +757,7 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script, JSFunction *fun,
|
||||
void *hookData;
|
||||
|
||||
hook = cx->runtime->executeHook;
|
||||
hookData = NULL;
|
||||
oldfp = cx->fp;
|
||||
frame.callobj = frame.argsobj = NULL;
|
||||
frame.script = script;
|
||||
@@ -845,9 +848,9 @@ ImportProperty(JSContext *cx, JSObject *obj, jsid id)
|
||||
ida = JS_Enumerate(cx, obj);
|
||||
if (!ida)
|
||||
return JS_FALSE;
|
||||
ok = JS_TRUE;
|
||||
if (ida->length == 0)
|
||||
goto out;
|
||||
ok = JS_TRUE;
|
||||
} else {
|
||||
ida = NULL;
|
||||
if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop))
|
||||
@@ -1031,6 +1034,10 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
} \
|
||||
}
|
||||
|
||||
pc = script->code;
|
||||
endpc = pc + script->length;
|
||||
len = -1;
|
||||
|
||||
/*
|
||||
* Allocate operand and pc stack slots for the script's worst-case depth.
|
||||
*/
|
||||
@@ -1038,14 +1045,12 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
newsp = js_AllocStack(cx, (uintN)(2 * depth), &mark);
|
||||
if (!newsp) {
|
||||
ok = JS_FALSE;
|
||||
sp = NULL;
|
||||
goto out;
|
||||
}
|
||||
newsp += depth;
|
||||
fp->sp = sp = newsp;
|
||||
|
||||
pc = script->code;
|
||||
endpc = pc + script->length;
|
||||
|
||||
while (pc < endpc) {
|
||||
fp->pc = pc;
|
||||
op = (JSOp)*pc;
|
||||
@@ -1079,7 +1084,7 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
#endif
|
||||
|
||||
if (rt->interruptHandler) {
|
||||
JSTrapHandler handler = (JSTrapHandler) rt->interruptHandler;
|
||||
JSTrapHandler handler = rt->interruptHandler;
|
||||
/* check copy of pointer for safety in multithreaded situation */
|
||||
if (handler) {
|
||||
switch (handler(cx, script, pc, &rval,
|
||||
@@ -1092,6 +1097,13 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
case JSTRAP_RETURN:
|
||||
fp->rval = rval;
|
||||
goto out;
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
case JSTRAP_THROW:
|
||||
cx->throwing = JS_TRUE;
|
||||
cx->exception = rval;
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
default:;
|
||||
}
|
||||
}
|
||||
@@ -1462,6 +1474,7 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
ok = SPROP_SET(cx, sprop, obj, obj, &rval); \
|
||||
if (ok) { \
|
||||
SET_ENUMERATE_ATTR(sprop); \
|
||||
GC_POKE(cx, NULL); /* second arg ignored! */ \
|
||||
OBJ_SET_SLOT(cx, obj, sprop->slot, rval); \
|
||||
} \
|
||||
} else { \
|
||||
@@ -1909,7 +1922,8 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
/* XXX clean up to avoid special cases above ObjectOps layer */
|
||||
(clasp = OBJ_GET_CLASS(cx, obj2),
|
||||
clasp == &js_FunctionClass || clasp == &js_ClosureClass) ||
|
||||
!obj2->map->ops->construct) {
|
||||
!obj2->map->ops->construct)
|
||||
{
|
||||
fun = js_ValueToFunction(cx, vp, JS_TRUE);
|
||||
if (!fun) {
|
||||
ok = JS_FALSE;
|
||||
@@ -1918,10 +1932,13 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
obj2 = fun->object;
|
||||
}
|
||||
|
||||
clasp = &js_ObjectClass;
|
||||
if (!obj2) {
|
||||
proto = parent = NULL;
|
||||
fun = NULL;
|
||||
} else {
|
||||
JSClass *cl;
|
||||
|
||||
/* Get the constructor prototype object for this function. */
|
||||
ok = OBJ_GET_PROPERTY(cx, obj2,
|
||||
(jsid)rt->atomState.classPrototypeAtom,
|
||||
@@ -1930,13 +1947,14 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
goto out;
|
||||
proto = JSVAL_IS_OBJECT(rval) ? JSVAL_TO_OBJECT(rval) : NULL;
|
||||
parent = OBJ_GET_PARENT(cx, obj2);
|
||||
}
|
||||
|
||||
/* If there is no class prototype, use js_ObjectClass. */
|
||||
if (!proto)
|
||||
obj = js_NewObject(cx, &js_ObjectClass, NULL, parent);
|
||||
else
|
||||
obj = js_NewObject(cx, OBJ_GET_CLASS(cx, proto), proto, parent);
|
||||
if ((OBJ_GET_CLASS(cx, obj2) == &js_FunctionClass) &&
|
||||
(cl = ((JSFunction *)JS_GetPrivate(cx, obj2))->clasp) != 0)
|
||||
{
|
||||
clasp = cl;
|
||||
}
|
||||
}
|
||||
obj = js_NewObject(cx, clasp, proto, parent);
|
||||
if (!obj) {
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
@@ -1949,10 +1967,6 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
RESTORE_SP(fp);
|
||||
if (!ok) {
|
||||
cx->newborn[GCX_OBJECT] = NULL;
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
if (cx->throwing)
|
||||
goto do_throw;
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -2162,16 +2176,13 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
PUSH_OPND(OBJECT_TO_JSVAL(obj));
|
||||
break;
|
||||
|
||||
case JSOP_CALLSPECIAL:
|
||||
case JSOP_CALL:
|
||||
argc = GET_ARGC(pc);
|
||||
SAVE_SP(fp);
|
||||
ok = js_Invoke(cx, argc, JS_FALSE);
|
||||
RESTORE_SP(fp);
|
||||
if (!ok) {
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
if (cx->throwing)
|
||||
goto do_throw;
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
obj = NULL;
|
||||
@@ -2278,7 +2289,6 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
* ECMAv2 forbids conversion of discriminant, so we will skip to
|
||||
* the default case if the discriminant isn't an int jsval.
|
||||
* (This opcode is emitted only for dense jsint-domain switches.)
|
||||
* XXX don't use JSVERSION_IS_ECMAv2, it's wrong and overloaded
|
||||
*/
|
||||
if (cx->version == JSVERSION_DEFAULT ||
|
||||
cx->version >= JSVERSION_1_4) {
|
||||
@@ -2519,6 +2529,13 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
case JSTRAP_RETURN:
|
||||
fp->rval = rval;
|
||||
goto out;
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
case JSTRAP_THROW:
|
||||
cx->throwing = JS_TRUE;
|
||||
cx->exception = rval;
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
default:;
|
||||
}
|
||||
break;
|
||||
@@ -2677,22 +2694,8 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
case JSOP_THROW:
|
||||
cx->throwing = JS_TRUE;
|
||||
cx->exception = POP();
|
||||
do_throw:
|
||||
tn = script->trynotes;
|
||||
offset = PTRDIFF(pc, script->code, jsbytecode);
|
||||
if (tn) {
|
||||
while (JS_UPTRDIFF(offset, tn->start) >= (jsuword)tn->length)
|
||||
tn++;
|
||||
if (tn->catchStart) {
|
||||
pc = script->code + tn->catchStart;
|
||||
len = 0;
|
||||
cx->throwing = JS_FALSE; /* caught */
|
||||
goto advance_pc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Not in a catch block, so propagate the exception. */
|
||||
ok = JS_FALSE;
|
||||
/* let the code at out try to catch the exception. */
|
||||
goto out;
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
|
||||
@@ -2725,7 +2728,7 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
#if JS_HAS_DEBUGGER_KEYWORD
|
||||
case JSOP_DEBUGGER:
|
||||
if (rt->debuggerHandler) {
|
||||
JSTrapHandler handler = (JSTrapHandler) rt->debuggerHandler;
|
||||
JSTrapHandler handler = rt->debuggerHandler;
|
||||
/* check copy of pointer for safety in multithread situation */
|
||||
if (handler) {
|
||||
switch (handler(cx, script, pc, &rval,
|
||||
@@ -2738,6 +2741,13 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
case JSTRAP_RETURN:
|
||||
fp->rval = rval;
|
||||
goto out;
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
case JSTRAP_THROW:
|
||||
cx->throwing = JS_TRUE;
|
||||
cx->exception = rval;
|
||||
ok = JS_FALSE;
|
||||
goto out;
|
||||
#endif /* JS_HAS_EXCEPTIONS */
|
||||
default:;
|
||||
}
|
||||
}
|
||||
@@ -2780,6 +2790,60 @@ js_Interpret(JSContext *cx, jsval *result)
|
||||
#endif
|
||||
}
|
||||
out:
|
||||
|
||||
#if JS_HAS_EXCEPTIONS
|
||||
/*
|
||||
* Has an exception been raised?
|
||||
*/
|
||||
if (!ok && cx->throwing) {
|
||||
/*
|
||||
* call hook if set
|
||||
*/
|
||||
if (rt->throwHook) {
|
||||
JSTrapHandler handler = rt->throwHook;
|
||||
/* check copy of pointer for safety in multithreaded situation */
|
||||
if (handler) {
|
||||
switch (handler(cx, script, pc, &rval,
|
||||
rt->throwHookData)) {
|
||||
case JSTRAP_ERROR:
|
||||
cx->throwing = JS_FALSE;
|
||||
goto no_catch;
|
||||
case JSTRAP_CONTINUE:
|
||||
cx->throwing = JS_FALSE;
|
||||
ok = JS_TRUE;
|
||||
goto advance_pc;
|
||||
case JSTRAP_RETURN:
|
||||
ok = JS_TRUE;
|
||||
cx->throwing = JS_FALSE;
|
||||
fp->rval = rval;
|
||||
goto no_catch;
|
||||
case JSTRAP_THROW:
|
||||
cx->exception = rval;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for a try block within this frame that can catch the exception.
|
||||
*/
|
||||
tn = script->trynotes;
|
||||
if (tn) {
|
||||
offset = PTRDIFF(pc, script->code, jsbytecode);
|
||||
while (JS_UPTRDIFF(offset, tn->start) >= (jsuword)tn->length)
|
||||
tn++;
|
||||
if (tn->catchStart) {
|
||||
pc = script->code + tn->catchStart;
|
||||
len = 0;
|
||||
cx->throwing = JS_FALSE; /* caught */
|
||||
ok = JS_TRUE;
|
||||
goto advance_pc;
|
||||
}
|
||||
}
|
||||
}
|
||||
no_catch:
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Restore the previous frame's execution state.
|
||||
*/
|
||||
|
||||
272
mozilla/js/src/jslibmath.h
Normal file
272
mozilla/js/src/jslibmath.h
Normal file
@@ -0,0 +1,272 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* By default all math calls go to fdlibm. The defines for each platform
|
||||
* remap the math calls to native routines.
|
||||
*/
|
||||
|
||||
#ifndef _LIBMATH_H
|
||||
#define _LIBMATH_H
|
||||
|
||||
#include <math.h>
|
||||
#include "jsconfig.h"
|
||||
|
||||
/*
|
||||
* Define which platforms on which to use fdlibm. Not used
|
||||
* by default since there can be problems with endian-ness and such.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(SUNOS4)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(IRIX)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(SOLARIS)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(HPUX)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(linux)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#elif defined(OSF1)
|
||||
/* Want to use some fdlibm functions but fdlibm broken on OSF1/alpha. */
|
||||
#define JS_USE_FDLIBM_MATH 0
|
||||
|
||||
#elif defined(AIX)
|
||||
#define JS_USE_FDLIBM_MATH 1
|
||||
|
||||
#else
|
||||
#define JS_USE_FDLIBM_MATH 0
|
||||
#endif
|
||||
|
||||
#if !JS_USE_FDLIBM_MATH
|
||||
|
||||
/*
|
||||
* Use system provided math routines.
|
||||
*/
|
||||
|
||||
#define fd_acos acos
|
||||
#define fd_asin asin
|
||||
#define fd_atan atan
|
||||
#define fd_atan2 atan2
|
||||
#define fd_ceil ceil
|
||||
#define fd_copysign copysign
|
||||
#define fd_cos cos
|
||||
#define fd_exp exp
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
#define fd_log log
|
||||
#define fd_pow pow
|
||||
#define fd_sin sin
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_tan tan
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Use math routines in fdlibm.
|
||||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
#define __P(p) p
|
||||
#else
|
||||
#define __P(p) ()
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined SUNOS4
|
||||
|
||||
#define fd_acos acos
|
||||
#define fd_asin asin
|
||||
#define fd_atan atan
|
||||
#define fd_cos cos
|
||||
#define fd_sin sin
|
||||
#define fd_tan tan
|
||||
#define fd_exp exp
|
||||
#define fd_log log
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_ceil ceil
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#ifdef DEBUG
|
||||
extern double fd_pow __P((double, double));
|
||||
#else
|
||||
#define fd_pow pow
|
||||
#endif
|
||||
|
||||
#elif defined IRIX
|
||||
|
||||
#define fd_acos acos
|
||||
#define fd_asin asin
|
||||
#define fd_atan atan
|
||||
#define fd_exp exp
|
||||
#define fd_log log
|
||||
#define fd_log10 log10
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
|
||||
extern double fd_cos __P((double));
|
||||
extern double fd_sin __P((double));
|
||||
extern double fd_tan __P((double));
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_pow __P((double, double));
|
||||
extern double fd_ceil __P((double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#elif defined SOLARIS
|
||||
|
||||
#define fd_atan atan
|
||||
#define fd_cos cos
|
||||
#define fd_sin sin
|
||||
#define fd_tan tan
|
||||
#define fd_exp exp
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_ceil ceil
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
|
||||
extern double fd_acos __P((double));
|
||||
extern double fd_asin __P((double));
|
||||
extern double fd_log __P((double));
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_pow __P((double, double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#elif defined HPUX
|
||||
|
||||
#define fd_cos cos
|
||||
#define fd_sin sin
|
||||
#define fd_exp exp
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
|
||||
extern double fd_ceil __P((double));
|
||||
extern double fd_acos __P((double));
|
||||
extern double fd_log __P((double));
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_tan __P((double));
|
||||
extern double fd_pow __P((double, double));
|
||||
extern double fd_asin __P((double));
|
||||
extern double fd_atan __P((double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#elif defined(linux)
|
||||
|
||||
#define fd_atan atan
|
||||
#define fd_atan2 atan2
|
||||
#define fd_ceil ceil
|
||||
#define fd_cos cos
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
#define fd_sin sin
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_tan tan
|
||||
|
||||
extern double fd_asin __P((double));
|
||||
extern double fd_acos __P((double));
|
||||
extern double fd_exp __P((double));
|
||||
extern double fd_log __P((double));
|
||||
extern double fd_pow __P((double, double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#elif defined(OSF1)
|
||||
|
||||
#define fd_acos acos
|
||||
#define fd_asin asin
|
||||
#define fd_atan atan
|
||||
#define fd_copysign copysign
|
||||
#define fd_cos cos
|
||||
#define fd_exp exp
|
||||
#define fd_fabs fabs
|
||||
#define fd_fmod fmod
|
||||
#define fd_sin sin
|
||||
#define fd_sqrt sqrt
|
||||
#define fd_tan tan
|
||||
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_ceil __P((double));
|
||||
extern double fd_floor __P((double));
|
||||
extern double fd_log __P((double));
|
||||
extern double fd_pow __P((double, double));
|
||||
|
||||
#elif defined(AIX)
|
||||
|
||||
#define fd_acos acos
|
||||
#define fd_asin asin
|
||||
#define fd_atan2 atan2
|
||||
#define fd_copysign copysign
|
||||
#define fd_cos cos
|
||||
#define fd_exp exp
|
||||
#define fd_fabs fabs
|
||||
#define fd_floor floor
|
||||
#define fd_fmod fmod
|
||||
#define fd_log log
|
||||
#define fd_sin sin
|
||||
#define fd_sqrt sqrt
|
||||
|
||||
extern double fd_atan __P((double));
|
||||
extern double fd_ceil __P((double));
|
||||
extern double fd_pow __P((double,double));
|
||||
extern double fd_tan __P((double));
|
||||
|
||||
#else /* other platform.. generic paranoid slow fdlibm */
|
||||
|
||||
extern double fd_acos __P((double));
|
||||
extern double fd_asin __P((double));
|
||||
extern double fd_atan __P((double));
|
||||
extern double fd_cos __P((double));
|
||||
extern double fd_sin __P((double));
|
||||
extern double fd_tan __P((double));
|
||||
|
||||
extern double fd_exp __P((double));
|
||||
extern double fd_log __P((double));
|
||||
extern double fd_sqrt __P((double));
|
||||
|
||||
extern double fd_ceil __P((double));
|
||||
extern double fd_fabs __P((double));
|
||||
extern double fd_floor __P((double));
|
||||
extern double fd_fmod __P((double, double));
|
||||
|
||||
extern double fd_atan2 __P((double, double));
|
||||
extern double fd_pow __P((double, double));
|
||||
extern double fd_copysign __P((double, double));
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* JS_USE_FDLIBM_MATH */
|
||||
|
||||
#endif /* _LIBMATH_H */
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "jspubtd.h"
|
||||
#include "prthread.h"
|
||||
#include "pratom.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jscntxt.h"
|
||||
#include "jsscope.h"
|
||||
@@ -102,32 +101,32 @@ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
|
||||
#if defined(__GNUC__)
|
||||
unsigned int res;
|
||||
#ifndef ULTRA_SPARC
|
||||
JS_ASSERT(nv >= 0);
|
||||
asm volatile ("
|
||||
stbar
|
||||
swap [%1],%4
|
||||
1: tst %4
|
||||
bneg,a 1b
|
||||
swap [%1],%4
|
||||
cmp %2,%4
|
||||
be,a 2f
|
||||
swap [%1],%3
|
||||
swap [%1],%4
|
||||
ba 3f
|
||||
mov 0,%0
|
||||
2: mov 1,%0
|
||||
JS_ASSERT(nv != -1);
|
||||
asm volatile ("\
|
||||
stbar\n\
|
||||
swap [%1],%4\n\
|
||||
1: cmp %4,-1\n\
|
||||
be,a 1b\n\
|
||||
swap [%1],%4\n\
|
||||
cmp %2,%4\n\
|
||||
be,a 2f\n\
|
||||
swap [%1],%3\n\
|
||||
swap [%1],%4\n\
|
||||
ba 3f\n\
|
||||
mov 0,%0\n\
|
||||
2: mov 1,%0\n\
|
||||
3:"
|
||||
: "=r" (res)
|
||||
: "r" (w), "r" (ov), "r" (nv), "r" (-1));
|
||||
#else /* ULTRA_SPARC */
|
||||
JS_ASSERT(ov != nv);
|
||||
asm volatile ("
|
||||
stbar
|
||||
cas [%1],%2,%3
|
||||
cmp %2,%3
|
||||
be,a 1f
|
||||
mov 1,%0
|
||||
mov 0,%0
|
||||
asm volatile ("\
|
||||
stbar\n\
|
||||
cas [%1],%2,%3\n\
|
||||
cmp %2,%3\n\
|
||||
be,a 1f\n\
|
||||
mov 1,%0\n\
|
||||
mov 0,%0\n\
|
||||
1:"
|
||||
: "=r" (res)
|
||||
: "r" (w), "r" (ov), "r" (nv));
|
||||
@@ -136,7 +135,7 @@ mov 0,%0
|
||||
#else /* !__GNUC__ */
|
||||
extern int compare_and_swap(jsword*,jsword,jsword);
|
||||
#ifndef ULTRA_SPARC
|
||||
JS_ASSERT(nv >= 0);
|
||||
JS_ASSERT(nv != -1);
|
||||
#else
|
||||
JS_ASSERT(ov != nv);
|
||||
#endif
|
||||
@@ -189,7 +188,7 @@ js_AtomicAdd(jsword *p, jsword i)
|
||||
AtomicAddBody(p,i);
|
||||
}
|
||||
|
||||
JS_INLINE jsword
|
||||
static JS_INLINE jsword
|
||||
js_AtomicSet(jsword *p, jsword n)
|
||||
{
|
||||
jsword o;
|
||||
@@ -308,7 +307,7 @@ mallocFatlock()
|
||||
fl->next = NULL;
|
||||
fl->prev = NULL;
|
||||
fl->slock = PR_NewLock();
|
||||
fl->svar = JS_NewCondVar(fl->slock);
|
||||
fl->svar = PR_NewCondVar(fl->slock);
|
||||
return fl;
|
||||
}
|
||||
|
||||
@@ -327,7 +326,7 @@ js_SuspendThread(JSThinLock *p)
|
||||
JSStatus stat;
|
||||
|
||||
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1) /* busy wait */
|
||||
PR_Sleep(JS_INTERVAL_NO_WAIT);
|
||||
PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
if (fl == NULL)
|
||||
return 1;
|
||||
PR_Lock(fl->slock);
|
||||
@@ -337,7 +336,7 @@ js_SuspendThread(JSThinLock *p)
|
||||
PR_Unlock(fl->slock);
|
||||
return 1;
|
||||
}
|
||||
stat = PR_WaitCondVar(fl->svar,JS_INTERVAL_NO_TIMEOUT);
|
||||
stat = PR_WaitCondVar(fl->svar,PR_INTERVAL_NO_TIMEOUT);
|
||||
if (stat == JS_FAILURE) {
|
||||
fl->susp--;
|
||||
return 0;
|
||||
@@ -353,7 +352,7 @@ js_ResumeThread(JSThinLock *p)
|
||||
JSStatus stat;
|
||||
|
||||
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1)
|
||||
PR_Sleep(JS_INTERVAL_NO_WAIT);
|
||||
PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
if (fl == NULL)
|
||||
return;
|
||||
PR_Lock(fl->slock);
|
||||
@@ -396,7 +395,7 @@ deleteListOfFatlocks(JSFatLock *m)
|
||||
|
||||
static JSFatLockTable _fl_table;
|
||||
|
||||
JSFatLock *
|
||||
static JSFatLock *
|
||||
allocateFatlock()
|
||||
{
|
||||
JSFatLock *m;
|
||||
@@ -421,7 +420,7 @@ allocateFatlock()
|
||||
return m;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
deallocateFatlock(JSFatLock *m)
|
||||
{
|
||||
if (m == NULL)
|
||||
@@ -438,7 +437,7 @@ deallocateFatlock(JSFatLock *m)
|
||||
js_UnlockGlobal();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(int)
|
||||
int
|
||||
js_SetupLocks(int l)
|
||||
{
|
||||
if (l > 10000) /* l equals number of initially allocated fat locks */
|
||||
@@ -462,7 +461,7 @@ js_SetupLocks(int l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
void
|
||||
js_CleanupLocks()
|
||||
{
|
||||
if (_global_lock != NULL) {
|
||||
@@ -512,7 +511,7 @@ js_InitContextForLocking(JSContext *cx)
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
static int
|
||||
emptyFatlock(JSThinLock *p)
|
||||
{
|
||||
JSFatLock *fl;
|
||||
@@ -520,7 +519,7 @@ emptyFatlock(JSThinLock *p)
|
||||
PRLock* lck;
|
||||
|
||||
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1)
|
||||
PR_Sleep(JS_INTERVAL_NO_WAIT);
|
||||
PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
if (fl == NULL) {
|
||||
js_AtomicSet((jsword*)&p->fat,(jsword)fl);
|
||||
return 1;
|
||||
@@ -585,7 +584,7 @@ js_Enqueue(JSThinLock *p, jsword me)
|
||||
if (o != 0 && js_CompareAndSwap(&p->owner,o,n)) {
|
||||
JSFatLock* fl;
|
||||
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1)
|
||||
PR_Sleep(JS_INTERVAL_NO_WAIT);
|
||||
PR_Sleep(PR_INTERVAL_NO_WAIT);
|
||||
if (fl == NULL)
|
||||
fl = allocateFatlock();
|
||||
js_AtomicSet((jsword*)&p->fat,(jsword)fl);
|
||||
@@ -661,7 +660,7 @@ js_UnlockRuntime(JSRuntime *rt)
|
||||
JS_UNLOCK0(p,me);
|
||||
}
|
||||
|
||||
JS_INLINE void
|
||||
static JS_INLINE void
|
||||
js_LockScope1(JSContext *cx, JSScope *scope, jsword me)
|
||||
{
|
||||
JSThinLock *p;
|
||||
|
||||
@@ -23,13 +23,7 @@
|
||||
#include "jstypes.h"
|
||||
#include "prlock.h"
|
||||
#include "prcvar.h"
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
|
||||
#define Thin_GetWait(W) ((jsword)(W) & 0x1)
|
||||
#define Thin_SetWait(W) ((jsword)(W) | 0x1)
|
||||
@@ -66,10 +60,10 @@ typedef struct JSFatLockTable {
|
||||
#define JS_LOCK0(P,M) js_Lock(P,M)
|
||||
#define JS_UNLOCK0(P,M) js_Unlock(P,M)
|
||||
|
||||
#define JS_NEW_CONDVAR(l) JS_NewCondVar(l)
|
||||
#define JS_NEW_CONDVAR(l) PR_NewCondVar(l)
|
||||
#define JS_DESTROY_CONDVAR(cv) PR_DestroyCondVar(cv)
|
||||
#define JS_WAIT_CONDVAR(cv,to) PR_WaitCondVar(cv,to)
|
||||
#define JS_NO_TIMEOUT JS_INTERVAL_NO_TIMEOUT
|
||||
#define JS_NO_TIMEOUT PR_INTERVAL_NO_TIMEOUT
|
||||
#define JS_NOTIFY_CONDVAR(cv) PR_NotifyCondVar(cv)
|
||||
#define JS_NOTIFY_ALL_CONDVAR(cv) PR_NotifyAllCondVar(cv)
|
||||
|
||||
@@ -106,8 +100,8 @@ extern void js_LockObj(JSContext *cx, JSObject *obj);
|
||||
extern void js_UnlockObj(JSContext *cx, JSObject *obj);
|
||||
extern void js_LockScope(JSContext *cx, JSScope *scope);
|
||||
extern void js_UnlockScope(JSContext *cx, JSScope *scope);
|
||||
extern JS_PUBLIC_API(int) js_SetupLocks(int);
|
||||
extern JS_PUBLIC_API(void) js_CleanupLocks();
|
||||
extern int js_SetupLocks(int);
|
||||
extern void js_CleanupLocks();
|
||||
extern JS_PUBLIC_API(void) js_InitContextForLocking(JSContext *);
|
||||
extern void js_TransferScopeLock(JSContext *, JSScope *, JSScope *);
|
||||
extern JS_PUBLIC_API(jsval) js_GetSlotWhileLocked(JSContext *, JSObject *, uint32);
|
||||
@@ -146,7 +140,7 @@ extern JSBool js_IsScopeLocked(JSScope *scope);
|
||||
JS_LOCK_RUNTIME_VOID(_rt, e); \
|
||||
JS_END_MACRO
|
||||
|
||||
#if defined(JS_ONLY_NSPR_LOCKS) || !(defined(_WIN32) || defined(SOLARIS) || defined(AIX))
|
||||
#if defined(JS_USE_ONLY_NSPR_LOCKS) || !(defined(_WIN32) || defined(SOLARIS) || defined(AIX))
|
||||
|
||||
#undef JS_LOCK0
|
||||
#undef JS_UNLOCK0
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef jslog_h___
|
||||
#define jslog_h___
|
||||
|
||||
#include "jstypes.h"
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
/* Removed by JSIFY: ** prlog.h -- Declare interfaces to NSPR's Logging service */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
**
|
||||
** NSPR provides a logging service that is used by NSPR itself and is
|
||||
** available to client programs.
|
||||
**
|
||||
** To use the service from a client program, you should create a
|
||||
** PRLogModuleInfo structure by calling JS_NewLogModule(). After
|
||||
** creating the LogModule, you can write to the log using the JS_LOG()
|
||||
** macro.
|
||||
**
|
||||
** Initialization of the log service is handled by NSPR initialization.
|
||||
**
|
||||
** At execution time, you must enable the log service. To enable the
|
||||
** log service, set the environment variable: NSPR_LOG_MODULES
|
||||
** variable.
|
||||
**
|
||||
** NSPR_LOG_MODULES variable has the form:
|
||||
**
|
||||
** <moduleName>:<value>[, <moduleName>:<value>]*
|
||||
**
|
||||
** Where:
|
||||
** <moduleName> is the name passed to JS_NewLogModule().
|
||||
** <value> is a numeric constant, e.g. 5. This value is the maximum
|
||||
** value of a log event, enumerated by PRLogModuleLevel, that you want
|
||||
** written to the log.
|
||||
**
|
||||
** For example: to record all events of greater value than or equal to
|
||||
** JS_LOG_ERROR for a LogModule names "gizmo", say:
|
||||
**
|
||||
** set NSPR_LOG_MODULES=gizmo:2
|
||||
**
|
||||
** Note that you must specify the numeric value of JS_LOG_ERROR.
|
||||
**
|
||||
** Special LogModule names are provided for controlling NSPR's log
|
||||
** service at execution time. These controls should be set in the
|
||||
** NSPR_LOG_MODULES environment variable at execution time to affect
|
||||
** NSPR's log service for your application.
|
||||
**
|
||||
** The special LogModule "all" enables all LogModules. To enable all
|
||||
** LogModule calls to JS_LOG(), say:
|
||||
**
|
||||
** set NSPR_LOG_MODULES=all:5
|
||||
**
|
||||
** The special LogModule name "sync" tells the NSPR log service to do
|
||||
** unbuffered logging.
|
||||
**
|
||||
** The special LogModule name "buffsize:<size>" tells NSPR to set the
|
||||
** log buffer to <size>.
|
||||
**
|
||||
** The environment variable NSPR_LOG_FILE specifies the log file to use
|
||||
** unless the default of "stderr" is acceptable.
|
||||
**
|
||||
** To put log messages in your programs, use the JS_LOG macro:
|
||||
**
|
||||
** JS_LOG(<module>, <level>, (<printfString>, <args>*));
|
||||
**
|
||||
** Where <module> is the address of a PRLogModuleInfo structure, and
|
||||
** <level> is one of the levels defined by the enumeration:
|
||||
** PRLogModuleLevel. <args> is a printf() style of argument list. That
|
||||
** is: (fmtstring, ...).
|
||||
**
|
||||
** Example:
|
||||
**
|
||||
** main() {
|
||||
** JSIntn one = 1;
|
||||
** PRLogModuleInfo * myLm = JS_NewLogModule("gizmo");
|
||||
** JS_LOG( myLm, JS_LOG_ALWAYS, ("Log this! %d\n", one));
|
||||
** return;
|
||||
** }
|
||||
**
|
||||
** Note the use of printf() style arguments as the third agrument(s) to
|
||||
** JS_LOG().
|
||||
**
|
||||
** After compiling and linking you application, set the environment:
|
||||
**
|
||||
** SET NSPR_LOGMODULES=gizmo:5
|
||||
** SET NSPR_LOG_FILE=logfile.txt
|
||||
**
|
||||
** When you execute your application, the string "Log this! 1" will be
|
||||
** written to the file "logfile.txt".
|
||||
**
|
||||
** Note to NSPR engineers: a number of PRLogModuleInfo structures are
|
||||
** defined and initialized in prinit.c. See this module for ideas on
|
||||
** what to log where.
|
||||
**
|
||||
*/
|
||||
|
||||
typedef enum PRLogModuleLevel {
|
||||
JS_LOG_NONE = 0, /* nothing */
|
||||
JS_LOG_ALWAYS = 1, /* always printed */
|
||||
JS_LOG_ERROR = 2, /* error messages */
|
||||
JS_LOG_WARNING = 3, /* warning messages */
|
||||
JS_LOG_DEBUG = 4, /* debug messages */
|
||||
|
||||
JS_LOG_NOTICE = JS_LOG_DEBUG, /* notice messages */
|
||||
JS_LOG_WARN = JS_LOG_WARNING, /* warning messages */
|
||||
JS_LOG_MIN = JS_LOG_DEBUG, /* minimal debugging messages */
|
||||
JS_LOG_MAX = JS_LOG_DEBUG /* maximal debugging messages */
|
||||
} PRLogModuleLevel;
|
||||
|
||||
/*
|
||||
** One of these structures is created for each module that uses logging.
|
||||
** "name" is the name of the module
|
||||
** "level" is the debugging level selected for that module
|
||||
*/
|
||||
typedef struct PRLogModuleInfo {
|
||||
const char *name;
|
||||
PRLogModuleLevel level;
|
||||
struct PRLogModuleInfo *next;
|
||||
} PRLogModuleInfo;
|
||||
|
||||
/*
|
||||
** Create a new log module.
|
||||
*/
|
||||
EXTERN(PRLogModuleInfo*) JS_NewLogModule(const char *name);
|
||||
|
||||
/*
|
||||
** Set the file to use for logging. Returns JS_FALSE if the file cannot
|
||||
** be created
|
||||
*/
|
||||
EXTERN(JSBool) JS_SetLogFile(const char *name);
|
||||
|
||||
/*
|
||||
** Set the size of the logging buffer. If "buffer_size" is zero then the
|
||||
** logging becomes "synchronous" (or unbuffered).
|
||||
*/
|
||||
EXTERN(void) JS_SetLogBuffering(JSIntn buffer_size);
|
||||
|
||||
/*
|
||||
** Print a string to the log. "fmt" is a PR_snprintf format type. All
|
||||
** messages printed to the log are preceeded by the name of the thread
|
||||
** and a time stamp. Also, the routine provides a missing newline if one
|
||||
** is not provided.
|
||||
*/
|
||||
EXTERN(void) JS_LogPrint(const char *fmt, ...);
|
||||
|
||||
/*
|
||||
** Flush the log to its file.
|
||||
*/
|
||||
EXTERN(void) JS_LogFlush(void);
|
||||
|
||||
/*
|
||||
** Windoze 16 can't support a large static string space for all of the
|
||||
** various debugging strings so logging is not enabled for it.
|
||||
*/
|
||||
#if (defined(DEBUG) || defined(FORCE_PR_LOG)) && !defined(WIN16)
|
||||
#define JS_LOGGING 1
|
||||
|
||||
#define JS_LOG_TEST(_module,_level) \
|
||||
((_module)->level >= (_level))
|
||||
|
||||
/*
|
||||
** Log something.
|
||||
** "module" is the address of a PRLogModuleInfo structure
|
||||
** "level" is the desired logging level
|
||||
** "args" is a variable length list of arguments to print, in the following
|
||||
** format: ("printf style format string", ...)
|
||||
*/
|
||||
#define JS_LOG(_module,_level,_args) \
|
||||
JS_BEGIN_MACRO \
|
||||
if (JS_LOG_TEST(_module,_level)) { \
|
||||
JS_LogPrint _args; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#else /* (defined(DEBUG) || defined(FORCE_PR_LOG)) && !defined(WIN16) */
|
||||
|
||||
#undef JS_LOGGING
|
||||
#define JS_LOG_TEST(module,level) 0
|
||||
#define JS_LOG(module,level,args)
|
||||
|
||||
#endif /* (defined(DEBUG) || defined(FORCE_PR_LOG)) && !defined(WIN16) */
|
||||
|
||||
#ifndef NO_NSPR_10_SUPPORT
|
||||
|
||||
#ifdef JS_LOGGING
|
||||
#define JS_LOG_BEGIN JS_LOG
|
||||
#define JS_LOG_END JS_LOG
|
||||
#define JS_LOG_DEFINE JS_NewLogModule
|
||||
#else
|
||||
#define JS_LOG_BEGIN(module,level,args)
|
||||
#define JS_LOG_END(module,level,args)
|
||||
#define JS_LOG_DEFINE(_name) NULL
|
||||
#endif /* JS_LOGGING */
|
||||
|
||||
#endif /* NO_NSPR_10_SUPPORT */
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
EXTERN(void) JS_Assert(const char *s, const char *file, JSIntn ln);
|
||||
#define JS_ASSERT(_expr) \
|
||||
((_expr)?((void)0):JS_Assert(# _expr,__FILE__,__LINE__))
|
||||
|
||||
#define JS_NOT_REACHED(_reasonStr) \
|
||||
JS_Assert(_reasonStr,__FILE__,__LINE__)
|
||||
|
||||
#else
|
||||
|
||||
#define JS_ASSERT(expr) ((void) 0)
|
||||
#define JS_NOT_REACHED(reasonStr)
|
||||
|
||||
#endif /* defined(DEBUG) */
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jslog_h___ */
|
||||
@@ -21,7 +21,7 @@
|
||||
/*
|
||||
** Compute the log of the least power of 2 greater than or equal to n
|
||||
*/
|
||||
IMPLEMENT(JSIntn) JS_CeilingLog2(JSUint32 n)
|
||||
JS_EXPORT_API(JSIntn) JS_CeilingLog2(JSUint32 n)
|
||||
{
|
||||
JSIntn log2 = 0;
|
||||
|
||||
@@ -44,7 +44,7 @@ IMPLEMENT(JSIntn) JS_CeilingLog2(JSUint32 n)
|
||||
** Compute the log of the greatest power of 2 less than or equal to n.
|
||||
** This really just finds the highest set bit in the word.
|
||||
*/
|
||||
IMPLEMENT(JSIntn) JS_FloorLog2(JSUint32 n)
|
||||
JS_EXPORT_API(JSIntn) JS_FloorLog2(JSUint32 n)
|
||||
{
|
||||
JSIntn log2 = 0;
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ JSInt64 __pascal __loadds __export
|
||||
JSInt64 __pascal __loadds __export
|
||||
JSLL_MinInt(void) { return ll_minint; }
|
||||
#else
|
||||
IMPLEMENT(JSInt64) JSLL_Zero(void) { return ll_zero; }
|
||||
IMPLEMENT(JSInt64) JSLL_MaxInt(void) { return ll_maxint; }
|
||||
IMPLEMENT(JSInt64) JSLL_MinInt(void) { return ll_minint; }
|
||||
JS_EXPORT_API(JSInt64) JSLL_Zero(void) { return ll_zero; }
|
||||
JS_EXPORT_API(JSInt64) JSLL_MaxInt(void) { return ll_maxint; }
|
||||
JS_EXPORT_API(JSInt64) JSLL_MinInt(void) { return ll_minint; }
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LONG_LONG
|
||||
#ifndef JS_HAVE_LONG_LONG
|
||||
/*
|
||||
** Divide 64-bit a by 32-bit b, which must be normalized so its high bit is 1.
|
||||
*/
|
||||
@@ -45,12 +45,12 @@ static void norm_udivmod32(JSUint32 *qp, JSUint32 *rp, JSUint64 a, JSUint32 b)
|
||||
JSUint32 d1, d0, q1, q0;
|
||||
JSUint32 r1, r0, m;
|
||||
|
||||
d1 = _hi16(b);
|
||||
d0 = _lo16(b);
|
||||
d1 = jshi16(b);
|
||||
d0 = jslo16(b);
|
||||
r1 = a.hi % d1;
|
||||
q1 = a.hi / d1;
|
||||
m = q1 * d0;
|
||||
r1 = (r1 << 16) | _hi16(a.lo);
|
||||
r1 = (r1 << 16) | jshi16(a.lo);
|
||||
if (r1 < m) {
|
||||
q1--, r1 += b;
|
||||
if (r1 >= b /* i.e., we didn't get a carry when adding to r1 */
|
||||
@@ -62,7 +62,7 @@ static void norm_udivmod32(JSUint32 *qp, JSUint32 *rp, JSUint64 a, JSUint32 b)
|
||||
r0 = r1 % d1;
|
||||
q0 = r1 / d1;
|
||||
m = q0 * d0;
|
||||
r0 = (r0 << 16) | _lo16(a.lo);
|
||||
r0 = (r0 << 16) | jslo16(a.lo);
|
||||
if (r0 < m) {
|
||||
q0--, r0 += b;
|
||||
if (r0 >= b
|
||||
@@ -94,7 +94,7 @@ static JSUint32 CountLeadingZeros(JSUint32 a)
|
||||
return r;
|
||||
}
|
||||
|
||||
IMPLEMENT(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
|
||||
JS_EXPORT_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
|
||||
{
|
||||
JSUint32 n0, n1, n2;
|
||||
JSUint32 q0, q1;
|
||||
@@ -257,4 +257,4 @@ IMPLEMENT(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
|
||||
qp->hi = q1;
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_LONG_LONG */
|
||||
#endif /* !JS_HAVE_LONG_LONG */
|
||||
|
||||
@@ -47,16 +47,16 @@ JSInt64 __pascal __loadds __export
|
||||
JSInt64 __pascal __loadds __export
|
||||
JSLL_Zero(void);
|
||||
#else
|
||||
EXTERN(JSInt64) JSLL_MaxInt(void);
|
||||
EXTERN(JSInt64) JSLL_MinInt(void);
|
||||
EXTERN(JSInt64) JSLL_Zero(void);
|
||||
JS_EXTERN_API(JSInt64) JSLL_MaxInt(void);
|
||||
JS_EXTERN_API(JSInt64) JSLL_MinInt(void);
|
||||
JS_EXTERN_API(JSInt64) JSLL_Zero(void);
|
||||
#endif
|
||||
|
||||
#define JSLL_MAXINT JSLL_MaxInt()
|
||||
#define JSLL_MININT JSLL_MinInt()
|
||||
#define JSLL_ZERO JSLL_Zero()
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef JS_HAVE_LONG_LONG
|
||||
|
||||
#if JS_BYTES_PER_LONG == 8
|
||||
#define JSLL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
|
||||
@@ -175,7 +175,7 @@ EXTERN(JSInt64) JSLL_Zero(void);
|
||||
(*(qp) = ((JSUint64)(a) / (b)), \
|
||||
*(rp) = ((JSUint64)(a) % (b)))
|
||||
|
||||
#else /* !HAVE_LONG_LONG */
|
||||
#else /* !JS_HAVE_LONG_LONG */
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define JSLL_INIT(hi, lo) {JS_INT32(lo), JS_INT32(hi)}
|
||||
@@ -227,28 +227,28 @@ EXTERN(JSInt64) JSLL_Zero(void);
|
||||
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
|
||||
}
|
||||
|
||||
#define _lo16(a) ((a) & JS_BITMASK(16))
|
||||
#define _hi16(a) ((a) >> 16)
|
||||
#define jslo16(a) ((a) & JS_BITMASK(16))
|
||||
#define jshi16(a) ((a) >> 16)
|
||||
|
||||
#define JSLL_MUL32(r, a, b) { \
|
||||
JSUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
|
||||
_a1 = _hi16(a), _a0 = _lo16(a); \
|
||||
_b1 = _hi16(b), _b0 = _lo16(b); \
|
||||
_a1 = jshi16(a), _a0 = jslo16(a); \
|
||||
_b1 = jshi16(b), _b0 = jslo16(b); \
|
||||
_y0 = _a0 * _b0; \
|
||||
_y1 = _a0 * _b1; \
|
||||
_y2 = _a1 * _b0; \
|
||||
_y3 = _a1 * _b1; \
|
||||
_y1 += _hi16(_y0); /* can't carry */ \
|
||||
_y1 += jshi16(_y0); /* can't carry */ \
|
||||
_y1 += _y2; /* might carry */ \
|
||||
if (_y1 < _y2) \
|
||||
_y3 += (JSUint32)(JS_BIT(16)); /* propagate */ \
|
||||
(r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \
|
||||
(r).hi = _y3 + _hi16(_y1); \
|
||||
(r).lo = (jslo16(_y1) << 16) + jslo16(_y0); \
|
||||
(r).hi = _y3 + jshi16(_y1); \
|
||||
}
|
||||
|
||||
#define JSLL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)
|
||||
#define JSLL_UDIVMOD(qp, rp, a, b) jsll_udivmod(qp, rp, a, b)
|
||||
|
||||
EXTERN(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
|
||||
JS_EXTERN_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
|
||||
|
||||
#define JSLL_DIV(r, a, b) { \
|
||||
JSInt64 _a, _b; \
|
||||
@@ -402,7 +402,7 @@ EXTERN(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
|
||||
JSLL_NEG(l, l); \
|
||||
}
|
||||
|
||||
#endif /* !HAVE_LONG_LONG */
|
||||
#endif /* !JS_HAVE_LONG_LONG */
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#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.
|
||||
//
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern void* reallocSmaller(void* block, size_t newSize);
|
||||
|
||||
extern char* strdup(const char* str);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsmacos_h___ */
|
||||
@@ -20,7 +20,7 @@
|
||||
* JS math package.
|
||||
*/
|
||||
#include "jsstddef.h"
|
||||
#include <math.h>
|
||||
#include "jslibmath.h"
|
||||
#include <stdlib.h>
|
||||
#include "jstypes.h"
|
||||
#include "jslong.h"
|
||||
@@ -84,8 +84,8 @@ math_abs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = (x < 0) ? -x : x;
|
||||
return JS_FALSE;
|
||||
z = fd_fabs(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ math_acos(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = acos(x);
|
||||
return JS_FALSE;
|
||||
z = fd_acos(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ math_asin(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = asin(x);
|
||||
return JS_FALSE;
|
||||
z = fd_asin(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ math_atan(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = atan(x);
|
||||
return JS_FALSE;
|
||||
z = fd_atan(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ math_atan2(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
return JS_FALSE;
|
||||
if (!js_ValueToNumber(cx, argv[1], &y))
|
||||
return JS_FALSE;
|
||||
z = atan2(x, y);
|
||||
z = fd_atan2(x, y);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ math_ceil(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = ceil(x);
|
||||
return JS_FALSE;
|
||||
z = fd_ceil(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ math_cos(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = cos(x);
|
||||
return JS_FALSE;
|
||||
z = fd_cos(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -163,8 +163,8 @@ math_exp(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = exp(x);
|
||||
return JS_FALSE;
|
||||
z = fd_exp(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@ math_floor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = floor(x);
|
||||
return JS_FALSE;
|
||||
z = fd_floor(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -185,8 +185,8 @@ math_log(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = log(x);
|
||||
return JS_FALSE;
|
||||
z = fd_log(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -196,10 +196,18 @@ math_max(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, y, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
return JS_FALSE;
|
||||
if (!js_ValueToNumber(cx, argv[1], &y))
|
||||
return JS_FALSE;
|
||||
z = (x > y) ? x : y;
|
||||
return JS_FALSE;
|
||||
if (JSDOUBLE_IS_NaN(y)||JSDOUBLE_IS_NaN(x))
|
||||
{
|
||||
*rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
|
||||
return JS_TRUE;
|
||||
}
|
||||
if ((x==0)&&(x==y)&&(fd_copysign(1,y)==-1))
|
||||
z = x;
|
||||
else
|
||||
z = (x > y) ? x : y;
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -211,8 +219,16 @@ math_min(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
if (!js_ValueToNumber(cx, argv[1], &y))
|
||||
return JS_FALSE;
|
||||
z = (x < y) ? x : y;
|
||||
return JS_FALSE;
|
||||
if (JSDOUBLE_IS_NaN(y)||JSDOUBLE_IS_NaN(x))
|
||||
{
|
||||
*rval = DOUBLE_TO_JSVAL(cx->runtime->jsNaN);
|
||||
return JS_TRUE;
|
||||
}
|
||||
if ((x==0)&&(x==y)&&(fd_copysign(1,y)==-1))
|
||||
z = y;
|
||||
else
|
||||
z = (x < y) ? x : y;
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -224,8 +240,8 @@ math_pow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
if (!js_ValueToNumber(cx, argv[1], &y))
|
||||
return JS_FALSE;
|
||||
z = pow(x, y);
|
||||
return JS_FALSE;
|
||||
z = fd_pow(x, y);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -322,8 +338,8 @@ math_round(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = floor(x + 0.5);
|
||||
return JS_FALSE;
|
||||
z = fd_copysign(fd_floor(x + 0.5), x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -333,8 +349,8 @@ math_sin(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = sin(x);
|
||||
return JS_FALSE;
|
||||
z = fd_sin(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -344,8 +360,8 @@ math_sqrt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = sqrt(x);
|
||||
return JS_FALSE;
|
||||
z = fd_sqrt(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
@@ -355,12 +371,25 @@ math_tan(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
jsdouble x, z;
|
||||
|
||||
if (!js_ValueToNumber(cx, argv[0], &x))
|
||||
return JS_FALSE;
|
||||
z = tan(x);
|
||||
return JS_FALSE;
|
||||
z = fd_tan(x);
|
||||
return js_NewNumberValue(cx, z, rval);
|
||||
}
|
||||
|
||||
#if JS_HAS_TOSOURCE
|
||||
static JSBool
|
||||
math_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
*rval = ATOM_KEY(cx->runtime->atomState.MathAtom);
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSFunctionSpec math_static_methods[] = {
|
||||
#ifdef JS_HAS_TOSOURCE
|
||||
{js_toSource_str, math_toSource, 0},
|
||||
#endif
|
||||
{"abs", math_abs, 1},
|
||||
{"acos", math_acos, 1},
|
||||
{"asin", math_asin, 1},
|
||||
@@ -382,33 +411,17 @@ static JSFunctionSpec math_static_methods[] = {
|
||||
{0}
|
||||
};
|
||||
|
||||
#if JS_HAS_TOSOURCE
|
||||
static JSBool
|
||||
math_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
*rval = ATOM_KEY(cx->runtime->atomState.MathAtom);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec math_methods[] = {
|
||||
{js_toSource_str, math_toSource, 0},
|
||||
{0}
|
||||
};
|
||||
#else
|
||||
#define math_methods NULL
|
||||
#endif
|
||||
|
||||
JSObject *
|
||||
js_InitMathClass(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSObject *proto;
|
||||
|
||||
proto = JS_InitClass(cx, obj, NULL, &math_class, NULL, 0,
|
||||
NULL, math_methods, NULL, math_static_methods);
|
||||
if (!proto)
|
||||
return NULL;
|
||||
if (!JS_DefineConstDoubles(cx, proto, math_constants))
|
||||
return NULL;
|
||||
return proto;
|
||||
JSObject *Math;
|
||||
|
||||
Math = JS_DefineObject(cx, obj, "Math", &math_class, NULL, 0);
|
||||
if (!Math)
|
||||
return NULL;
|
||||
if (!JS_DefineFunctions(cx, Math, math_static_methods))
|
||||
return NULL;
|
||||
if (!JS_DefineConstDoubles(cx, Math, math_constants))
|
||||
return NULL;
|
||||
return Math;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
/* -*- 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.
|
||||
/* -*- Mode: C; tab-width: 8 -*-
|
||||
* Copyright (C) 1998 Netscape Communications Corporation, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef jsmath_h___
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsdtoa.h"
|
||||
#include "jsprf.h"
|
||||
@@ -183,7 +182,7 @@ num_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
d = JSVAL_IS_INT(v) ? (jsdouble)JSVAL_TO_INT(v) : *JSVAL_TO_DOUBLE(v);
|
||||
i = JS_snprintf(buf, sizeof buf, "(new %s(", number_class.name);
|
||||
|
||||
PR_cnvtf(buf + i, sizeof buf - i, 20, d);
|
||||
JS_cnvtf(buf + i, sizeof buf - i, 20, d);
|
||||
i = strlen(buf);
|
||||
JS_snprintf(buf + i, sizeof buf - i, "))");
|
||||
str = JS_NewStringCopyZ(cx, buf);
|
||||
@@ -433,7 +432,7 @@ js_NumberToString(JSContext *cx, jsdouble d)
|
||||
if (JSDOUBLE_IS_INT(d, i)) {
|
||||
JS_snprintf(buf, sizeof buf, "%ld", (long)i);
|
||||
} else {
|
||||
PR_cnvtf(buf, sizeof buf, 20, d);
|
||||
JS_cnvtf(buf, sizeof buf, 20, d);
|
||||
}
|
||||
return JS_NewStringCopyZ(cx, buf);
|
||||
}
|
||||
@@ -648,7 +647,7 @@ js_strtod(JSContext *cx, const jschar *s, const jschar **ep, jsdouble *dp)
|
||||
estr = istr + 8;
|
||||
} else {
|
||||
errno = 0;
|
||||
d = PR_strtod(cstr, &estr);
|
||||
d = JS_strtod(cstr, &estr);
|
||||
if (errno == ERANGE)
|
||||
if (d == HUGE_VAL)
|
||||
d = *cx->runtime->jsPositiveInfinity;
|
||||
@@ -758,7 +757,7 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar **ep, jsint base, j
|
||||
if (base == 10) {
|
||||
/* If we're accumulating a decimal number and the number is >= 2^53, then
|
||||
* the result from the repeated multiply-add above may be inaccurate. Call
|
||||
* PR_strtod to get the correct answer.
|
||||
* JS_strtod to get the correct answer.
|
||||
*/
|
||||
size_t i;
|
||||
size_t length = s1 - start;
|
||||
@@ -772,7 +771,7 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar **ep, jsint base, j
|
||||
cstr[length] = 0;
|
||||
|
||||
errno = 0;
|
||||
value = PR_strtod(cstr, &estr);
|
||||
value = JS_strtod(cstr, &estr);
|
||||
if (errno == ERANGE && value == HUGE_VAL)
|
||||
value = *cx->runtime->jsPositiveInfinity;
|
||||
free(cstr);
|
||||
|
||||
@@ -23,22 +23,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#include "jsprf.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
@@ -104,7 +91,7 @@ JSClass js_ObjectClass = {
|
||||
static JSBool
|
||||
obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
STATIC_DLL_CALLBACK(JSBool)
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
|
||||
|
||||
static JSBool
|
||||
@@ -139,7 +126,7 @@ obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
STATIC_DLL_CALLBACK(JSBool)
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
JSObject *obj2;
|
||||
@@ -191,7 +178,7 @@ error:
|
||||
|
||||
#endif /* !JS_HAS_OBJ_PROTO_PROP */
|
||||
|
||||
STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
JS_STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
js_hash_object(const void *key)
|
||||
{
|
||||
return (JSHashNumber)key >> JSVAL_TAGBITS;
|
||||
@@ -305,6 +292,7 @@ js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
|
||||
if (!he)
|
||||
JS_ReportOutOfMemory(cx);
|
||||
*sp = NULL;
|
||||
sharpid = 0;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -404,16 +392,16 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
/* Allocate 2 + 1 for "{}" and the terminator. */
|
||||
if (!chars) {
|
||||
chars = malloc((2 + 1) * sizeof(jschar));
|
||||
if (!chars)
|
||||
goto done;
|
||||
nchars = 0;
|
||||
if (!chars)
|
||||
goto error;
|
||||
} else {
|
||||
MAKE_SHARP(he);
|
||||
nchars = js_strlen(chars);
|
||||
chars = realloc((ochars = chars), (nchars + 2 + 1) * sizeof(jschar));
|
||||
if (!chars) {
|
||||
free(ochars);
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
chars[nchars++] = '{';
|
||||
@@ -425,14 +413,14 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
id = ida->vector[i];
|
||||
ok = OBJ_GET_PROPERTY(cx, obj, id, &val);
|
||||
if (!ok)
|
||||
goto done;
|
||||
goto error;
|
||||
|
||||
/* Convert id to a jsval and then to a string. */
|
||||
id = js_IdToValue(id);
|
||||
idstr = js_ValueToString(cx, id);
|
||||
if (!idstr) {
|
||||
ok = JS_FALSE;
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
argv[0] = STRING_TO_JSVAL(idstr);
|
||||
|
||||
@@ -441,7 +429,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
idstr = js_QuoteString(cx, idstr, '\'');
|
||||
if (!idstr) {
|
||||
ok = JS_FALSE;
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
argv[0] = STRING_TO_JSVAL(idstr);
|
||||
}
|
||||
@@ -450,7 +438,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
valstr = js_ValueToSource(cx, val);
|
||||
if (!valstr) {
|
||||
ok = JS_FALSE;
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
argv[1] = STRING_TO_JSVAL(valstr);
|
||||
vchars = valstr->chars;
|
||||
@@ -464,7 +452,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
he = js_EnterSharpObject(cx, JSVAL_TO_OBJECT(val), NULL, &vsharp);
|
||||
if (!he) {
|
||||
ok = JS_FALSE;
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
if (IS_SHARP(he)) {
|
||||
vchars = vsharp;
|
||||
@@ -488,7 +476,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
/* Save code space on error: let JS_free ignore null vsharp. */
|
||||
JS_free(cx, vsharp);
|
||||
free(ochars);
|
||||
goto done;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (comma) {
|
||||
@@ -512,11 +500,12 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
JS_free(cx, vsharp);
|
||||
}
|
||||
|
||||
done:
|
||||
if (chars) {
|
||||
chars[nchars++] = '}';
|
||||
chars[nchars] = 0;
|
||||
}
|
||||
|
||||
error:
|
||||
js_LeaveSharpObject(cx, &ida);
|
||||
|
||||
if (!ok) {
|
||||
@@ -601,13 +590,21 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
JSBool implicitWith;
|
||||
#endif
|
||||
|
||||
caller = cx->fp->down;
|
||||
implicitWith = JS_FALSE; /* Unnecessary init to kill gcc warning */
|
||||
|
||||
if ((cx->version == JSVERSION_DEFAULT || cx->version >= JSVERSION_1_4)
|
||||
&& (*caller->pc != JSOP_CALLSPECIAL)) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
|
||||
JSMSG_BAD_INDIRECT_CALL, js_eval_str);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_STRING(argv[0])) {
|
||||
*rval = argv[0];
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
caller = cx->fp->down;
|
||||
|
||||
#if JS_HAS_SCRIPT_OBJECT
|
||||
/*
|
||||
* Script.prototype.compile/exec and Object.prototype.eval all take an
|
||||
@@ -743,6 +740,69 @@ obj_unwatch(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
|
||||
#endif /* JS_HAS_OBJ_WATCHPOINT */
|
||||
|
||||
#if JS_HAS_NEW_OBJ_METHODS
|
||||
/*
|
||||
* Prototype and property query methods, to complement the 'in' and
|
||||
* 'instanceof' operators.
|
||||
*/
|
||||
|
||||
/* Proposed ECMA 15.2.4.5. */
|
||||
static JSBool
|
||||
obj_hasOwnProperty(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
JSObject *obj2;
|
||||
JSProperty *prop;
|
||||
JSAtom *atom;
|
||||
|
||||
atom = js_ValueToStringAtom(cx, *argv);
|
||||
if (atom == NULL || !OBJ_LOOKUP_PROPERTY(cx, obj, (jsid)atom, &obj2, &prop))
|
||||
return JS_FALSE;
|
||||
*rval = (!prop || obj2 != obj) ? JSVAL_FALSE : JSVAL_TRUE;
|
||||
if (prop)
|
||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* Proposed ECMA 15.2.4.6. */
|
||||
static JSBool
|
||||
obj_isPrototypeOf(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
JSBool b;
|
||||
|
||||
if (!js_IsDelegate(cx, obj, *argv, &b))
|
||||
return JS_FALSE;
|
||||
*rval = b ? JSVAL_TRUE : JSVAL_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/* Proposed ECMA 15.2.4.7. */
|
||||
static JSBool
|
||||
obj_propertyIsEnumerable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
||||
jsval *rval)
|
||||
{
|
||||
JSObject *obj2;
|
||||
JSProperty *prop;
|
||||
JSAtom *atom;
|
||||
uintN attrs;
|
||||
JSBool ok;
|
||||
|
||||
atom = js_ValueToStringAtom(cx, *argv);
|
||||
if (atom == NULL || !OBJ_LOOKUP_PROPERTY(cx, obj, (jsid)atom, &obj2, &prop))
|
||||
return JS_FALSE;
|
||||
if (!prop) {
|
||||
*rval = JSVAL_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
ok = OBJ_GET_ATTRIBUTES(cx, obj2, (jsid)atom, prop, &attrs);
|
||||
if (ok)
|
||||
*rval = (attrs & JSPROP_ENUMERATE) != 0 ? JSVAL_TRUE : JSVAL_FALSE;
|
||||
OBJ_DROP_PROPERTY(cx, obj2, prop);
|
||||
return ok;
|
||||
}
|
||||
#endif /* JS_HAS_NEW_OBJ_METHODS */
|
||||
|
||||
static JSFunctionSpec object_methods[] = {
|
||||
#if JS_HAS_TOSOURCE
|
||||
{js_toSource_str, js_obj_toSource, 0, 0, OBJ_TOSTRING_EXTRA},
|
||||
@@ -753,6 +813,11 @@ static JSFunctionSpec object_methods[] = {
|
||||
#if JS_HAS_OBJ_WATCHPOINT
|
||||
{"watch", obj_watch, 2},
|
||||
{"unwatch", obj_unwatch, 1},
|
||||
#endif
|
||||
#if JS_HAS_NEW_OBJ_METHODS
|
||||
{"hasOwnProperty", obj_hasOwnProperty, 1},
|
||||
{"isPrototypeOf", obj_isPrototypeOf, 1},
|
||||
{"propertyIsEnumerable", obj_propertyIsEnumerable, 1},
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
@@ -1062,6 +1127,11 @@ js_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent)
|
||||
obj->slots[JSSLOT_CLASS] = PRIVATE_TO_JSVAL(clasp);
|
||||
for (i = JSSLOT_CLASS+1; i < JS_INITIAL_NSLOTS; i++)
|
||||
obj->slots[i] = JSVAL_VOID;
|
||||
|
||||
if (cx->runtime->objectHook) {
|
||||
cx->runtime->objectHook(cx, obj, JS_TRUE, cx->runtime->objectHookData);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
||||
bad:
|
||||
@@ -1177,6 +1247,10 @@ js_FinalizeObject(JSContext *cx, JSObject *obj)
|
||||
if (!map)
|
||||
return;
|
||||
|
||||
if (cx->runtime->objectHook) {
|
||||
cx->runtime->objectHook(cx, obj, JS_FALSE, cx->runtime->objectHookData);
|
||||
}
|
||||
|
||||
#if JS_HAS_OBJ_WATCHPOINT
|
||||
/* Remove all watchpoints with weak links to obj. */
|
||||
JS_ClearWatchPointsForObject(cx, obj);
|
||||
@@ -1285,7 +1359,7 @@ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot)
|
||||
{ \
|
||||
jsuint _index = JS7_UNDEC(*_cp++); \
|
||||
jsuint _oldIndex = 0; \
|
||||
jsuint _c; \
|
||||
jsuint _c = 0; \
|
||||
if (_index != 0) { \
|
||||
while (JS7_ISDEC(*_cp)) { \
|
||||
_oldIndex = _index; \
|
||||
@@ -1471,6 +1545,7 @@ js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp,
|
||||
|
||||
rt = cx->runtime;
|
||||
|
||||
lastobj = NULL; /* Suppress gcc warning */
|
||||
for (obj = cx->fp->scopeChain; obj; obj = parent) {
|
||||
/* Try the property cache and return immediately on cache hit. */
|
||||
PROPERTY_CACHE_TEST(&rt->propertyCache, obj, id, prop);
|
||||
@@ -1596,7 +1671,7 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
CHECK_FOR_FUNNY_INDEX(id);
|
||||
|
||||
#if JS_BUG_NULL_INDEX_PROPS
|
||||
/* Indexd properties defaulted to null in old versions. */
|
||||
/* Indexed properties defaulted to null in old versions. */
|
||||
*vp = (JSVAL_IS_INT(id) && JSVAL_TO_INT(id) >= 0)
|
||||
? JSVAL_NULL
|
||||
: JSVAL_VOID;
|
||||
@@ -1650,6 +1725,8 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
|
||||
|
||||
rt = cx->runtime;
|
||||
JS_LOCK_OBJ(cx, obj);
|
||||
protoid = protoattrs = 0; /* Suppress use-before-set gcc warning */
|
||||
protogetter = protosetter = NULL; /* Suppress use-before-set gcc warning */
|
||||
|
||||
scope = js_GetMutableScope(cx, obj);
|
||||
if (!scope) {
|
||||
@@ -2021,7 +2098,14 @@ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
|
||||
v = OBJECT_TO_JSVAL(obj);
|
||||
switch (hint) {
|
||||
case JSTYPE_STRING:
|
||||
js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL, &v);
|
||||
/*
|
||||
* Propagate the exception if js_TryMethod finds an appropriate
|
||||
* method, and calling that method returned failure.
|
||||
*/
|
||||
if (!js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL,
|
||||
&v))
|
||||
return JS_FALSE;
|
||||
|
||||
if (!JSVAL_IS_PRIMITIVE(v)) {
|
||||
if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))
|
||||
return JS_FALSE;
|
||||
@@ -2056,8 +2140,9 @@ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
|
||||
/* Don't convert to string (source object literal) for JS1.2. */
|
||||
if (cx->version == JSVERSION_1_2 && hint == JSTYPE_BOOLEAN)
|
||||
goto out;
|
||||
js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL,
|
||||
&v);
|
||||
if (!js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0,
|
||||
NULL, &v))
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2413,33 +2498,45 @@ js_ValueToNonNullObject(JSContext *cx, jsval v)
|
||||
return obj;
|
||||
}
|
||||
|
||||
void
|
||||
JSBool
|
||||
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval)
|
||||
{
|
||||
#if JS_HAS_VALUEOF_HINT
|
||||
jsval argv[1];
|
||||
|
||||
argv[0] = ATOM_KEY(cx->runtime->atomState.typeAtoms[type]);
|
||||
js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv, rval);
|
||||
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv,
|
||||
rval);
|
||||
#else
|
||||
js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 0, NULL, rval);
|
||||
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 0, NULL,
|
||||
rval);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
JSBool
|
||||
js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
|
||||
uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
JSErrorReporter older;
|
||||
jsval fval;
|
||||
JSBool ok;
|
||||
|
||||
/*
|
||||
* Report failure only if an appropriate method was found, and calling it
|
||||
* returned failure. We propagate failure in this case to make exceptions
|
||||
* behave properly.
|
||||
*/
|
||||
|
||||
older = JS_SetErrorReporter(cx, NULL);
|
||||
if (OBJ_GET_PROPERTY(cx, obj, (jsid)atom, &fval) &&
|
||||
JSVAL_IS_OBJECT(fval) &&
|
||||
fval != JSVAL_NULL) {
|
||||
(void) js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
|
||||
ok = js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
|
||||
} else {
|
||||
ok = JS_TRUE;
|
||||
}
|
||||
JS_SetErrorReporter(cx, older);
|
||||
return ok;
|
||||
}
|
||||
|
||||
#if JS_HAS_XDR
|
||||
@@ -2467,6 +2564,7 @@ js_XDRObject(JSXDRState *xdr, JSObject **objp)
|
||||
} else {
|
||||
classDef = 0;
|
||||
className = NULL;
|
||||
clasp = NULL; /* quell GCC overwarning */
|
||||
}
|
||||
|
||||
/* XDR a flag word followed (if true) by the class name. */
|
||||
@@ -2517,12 +2615,13 @@ out:
|
||||
|
||||
#endif /* JS_HAS_XDR */
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
/* Routines to print out values during debugging. */
|
||||
|
||||
void printChar(jschar *cp) {
|
||||
fprintf(stderr, "jschar* (0x%x) \"", cp);
|
||||
fprintf(stderr, "jschar* (0x%p) \"", cp);
|
||||
while (*cp)
|
||||
fputc(*cp++, stderr);
|
||||
fputc('"', stderr);
|
||||
@@ -2531,22 +2630,41 @@ void printChar(jschar *cp) {
|
||||
|
||||
void printString(JSString *str) {
|
||||
jsuint i;
|
||||
fprintf(stderr, "string (0x%x) \"", str);
|
||||
fprintf(stderr, "string (0x%p) \"", str);
|
||||
for (i=0; i < str->length; i++)
|
||||
fputc(str->chars[i], stderr);
|
||||
fputc('"', stderr);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
||||
void printVal(jsval val);
|
||||
|
||||
void printObj(JSObject *jsobj) {
|
||||
jsuint i;
|
||||
jsval val;
|
||||
JSClass *clasp;
|
||||
|
||||
fprintf(stderr, "object 0x%p\n", jsobj);
|
||||
clasp = OBJ_GET_CLASS(NULL, jsobj);
|
||||
fprintf(stderr, "class 0x%p %s\n", clasp, clasp->name);
|
||||
for (i=0; i < jsobj->map->nslots; i++) {
|
||||
fprintf(stderr, "slot %3d ", i);
|
||||
val = jsobj->slots[i];
|
||||
if (JSVAL_IS_OBJECT(val))
|
||||
fprintf(stderr, "object 0x%p\n", JSVAL_TO_OBJECT(val));
|
||||
else
|
||||
printVal(val);
|
||||
}
|
||||
}
|
||||
|
||||
void printVal(jsval val) {
|
||||
fprintf(stderr, "val %d (0x%x) = ", val, val);
|
||||
fprintf(stderr, "val %d (0x%p) = ", val, val);
|
||||
if (JSVAL_IS_NULL(val)) {
|
||||
fprintf(stderr, "null\n");
|
||||
} else if (JSVAL_IS_VOID(val)) {
|
||||
fprintf(stderr, "undefined\n");
|
||||
} else if (JSVAL_IS_OBJECT(val)) {
|
||||
/* XXX can do more here */
|
||||
fprintf(stderr, "object\n");
|
||||
printObj(JSVAL_TO_OBJECT(val));
|
||||
} else if (JSVAL_IS_INT(val)) {
|
||||
fprintf(stderr, "(int) %d\n", JSVAL_TO_INT(val));
|
||||
} else if (JSVAL_IS_STRING(val)) {
|
||||
@@ -2562,7 +2680,7 @@ void printVal(jsval val) {
|
||||
}
|
||||
|
||||
void printId(jsid id) {
|
||||
fprintf(stderr, "id %d (0x%x) is ", id, id);
|
||||
fprintf(stderr, "id %d (0x%p) is ", id, id);
|
||||
printVal(js_IdToValue(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,15 +26,7 @@
|
||||
* values, called slots. The map/slot pointer pair is GC'ed, while the map
|
||||
* is reference counted and the slot vector is malloc'ed.
|
||||
*/
|
||||
#ifdef NETSCAPE_INTERNAL
|
||||
#ifndef NSPR20
|
||||
#include "jshash.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "JShash.h"
|
||||
*/
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#endif
|
||||
#endif
|
||||
#include "jsprvtd.h"
|
||||
#include "jspubtd.h"
|
||||
|
||||
@@ -317,10 +309,10 @@ js_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
|
||||
extern JSObject *
|
||||
js_ValueToNonNullObject(JSContext *cx, jsval v);
|
||||
|
||||
extern void
|
||||
extern JSBool
|
||||
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval);
|
||||
|
||||
extern void
|
||||
extern JSBool
|
||||
js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
|
||||
uintN argc, jsval *argv, jsval *rval);
|
||||
|
||||
|
||||
@@ -26,14 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsdtoa.h"
|
||||
#include "jsprf.h"
|
||||
@@ -71,9 +64,9 @@ char *js_incop_str[] = {"++", "--"};
|
||||
#undef FAR
|
||||
#endif
|
||||
#else /* !__WINDOWS_386__ */
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
#ifndef FAR
|
||||
#define FAR
|
||||
#endif
|
||||
#endif /* !__WINDOWS_386__ */
|
||||
|
||||
JSCodeSpec FAR js_CodeSpec[] = {
|
||||
@@ -83,7 +76,7 @@ JSCodeSpec FAR js_CodeSpec[] = {
|
||||
#undef OPDEF
|
||||
};
|
||||
|
||||
uintN js_NumCodeSpecs = sizeof js_CodeSpec / sizeof js_CodeSpec[0];
|
||||
uintN js_NumCodeSpecs = sizeof (js_CodeSpec) / sizeof js_CodeSpec[0];
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
@@ -601,8 +594,9 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
|
||||
jp->indent -= 4;
|
||||
}
|
||||
|
||||
if (isCondSwitch)
|
||||
caseExprOff = (ptrdiff_t) js_CodeSpec[JSOP_CONDSWITCH].length;
|
||||
caseExprOff = isCondSwitch
|
||||
? (ptrdiff_t) js_CodeSpec[JSOP_CONDSWITCH].length
|
||||
: 0;
|
||||
|
||||
for (i = 0; i < tableLength; i++) {
|
||||
off = table[i].offset;
|
||||
@@ -953,10 +947,12 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
||||
if (!lval)
|
||||
return JS_FALSE;
|
||||
|
||||
/* The offset tells distance to next comma, or to end. */
|
||||
/*
|
||||
* The offset tells distance to the end of the right-hand
|
||||
* operand of the comma operator.
|
||||
*/
|
||||
done = pc + len;
|
||||
pc += js_GetSrcNoteOffset(sn, 0);
|
||||
LOCAL_ASSERT(pc == endpc || *pc == JSOP_POP);
|
||||
len = 0;
|
||||
|
||||
if (!Decompile(ss, done, pc - done)) {
|
||||
@@ -1559,7 +1555,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
|
||||
todo = Sprint(&ss->sprinter, "%ld", ival);
|
||||
} else if (JSVAL_IS_DOUBLE(key)) {
|
||||
char buf[32];
|
||||
PR_cnvtf(buf, sizeof buf, 20, *JSVAL_TO_DOUBLE(key));
|
||||
JS_cnvtf(buf, sizeof buf, 20, *JSVAL_TO_DOUBLE(key));
|
||||
todo = Sprint(&ss->sprinter, buf);
|
||||
} else if (JSVAL_IS_STRING(key)) {
|
||||
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
|
||||
@@ -2002,6 +1998,26 @@ js_DecompileScript(JSPrinter *jp, JSScript *script)
|
||||
return js_DecompileCode(jp, script, script->code, (uintN)script->length);
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_DecompileFunctionBody(JSPrinter *jp, JSFunction *fun, JSBool newlines)
|
||||
{
|
||||
JSScript *script = fun->script;
|
||||
if (script) {
|
||||
JSScope *oldScope, *scope = NULL;
|
||||
JSBool ok;
|
||||
if (fun->object) scope = (JSScope *)fun->object->map;
|
||||
oldScope = jp->scope;
|
||||
jp->scope = scope;
|
||||
ok = js_DecompileCode(jp, script, script->code, (uintN)script->length);
|
||||
jp->scope = oldScope;
|
||||
return ok;
|
||||
}
|
||||
else {
|
||||
js_printf(jp, "\t[native code]\n");
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
JSBool
|
||||
js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines)
|
||||
{
|
||||
@@ -2018,6 +2034,7 @@ js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines)
|
||||
}
|
||||
js_printf(jp, "function %s(", fun->atom ? ATOM_BYTES(fun->atom) : "");
|
||||
|
||||
scope = NULL;
|
||||
if (fun->script && fun->object) {
|
||||
/* Print the parameters.
|
||||
*
|
||||
@@ -2053,7 +2070,7 @@ js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines)
|
||||
js_puts(jp, ") {\n");
|
||||
indent = jp->indent;
|
||||
jp->indent += 4;
|
||||
if (fun->script) {
|
||||
if (fun->script && fun->object) {
|
||||
oldscope = jp->scope;
|
||||
jp->scope = scope;
|
||||
ok = js_DecompileScript(jp, fun->script);
|
||||
@@ -2134,7 +2151,12 @@ js_DecompileValueGenerator(JSContext *cx, jsval v, JSString *fallback)
|
||||
/* Be paranoid about loading an invalid pc from sp[-depth]. */
|
||||
if (!pc)
|
||||
goto do_fallback;
|
||||
JS_ASSERT(JS_UPTRDIFF(pc, script->code) < (jsuword)script->length);
|
||||
|
||||
/*
|
||||
* Using an object for which js_DefaultValue fails as part of an expression
|
||||
* blows this assert. Disabled for now.
|
||||
* JS_ASSERT(JS_UPTRDIFF(pc, script->code) < (jsuword)script->length);
|
||||
*/
|
||||
if (JS_UPTRDIFF(pc, script->code) >= (jsuword)script->length) {
|
||||
pc = fp->pc;
|
||||
if (!pc)
|
||||
|
||||
@@ -172,6 +172,9 @@ js_DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len);
|
||||
extern JSBool
|
||||
js_DecompileScript(JSPrinter *jp, JSScript *script);
|
||||
|
||||
extern JSBool
|
||||
js_DecompileFunctionBody(JSPrinter *jp, JSFunction *fun, JSBool newlines);
|
||||
|
||||
extern JSBool
|
||||
js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines);
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ OPDEF(JSOP_EXPORTALL, 75, "exportall", NULL, 1, 0, 0, 0, JOF_BYTE)
|
||||
OPDEF(JSOP_EXPORTNAME,76, "exportname", NULL, 3, 0, 0, 0, JOF_CONST|JOF_NAME)
|
||||
OPDEF(JSOP_IMPORTALL, 77, "importall", NULL, 1, 1, 0, 0, JOF_BYTE)
|
||||
OPDEF(JSOP_IMPORTPROP,78, "importprop", NULL, 3, 1, 0, 0, JOF_CONST|JOF_PROP|JOF_IMPORT)
|
||||
OPDEF(JSOP_IMPORTELEM,79, "importelem", NULL, 3, 2, 0, 0, JOF_BYTE |JOF_ELEM|JOF_IMPORT)
|
||||
OPDEF(JSOP_IMPORTELEM,79, "importelem", NULL, 1, 2, 0, 0, JOF_BYTE |JOF_ELEM|JOF_IMPORT)
|
||||
|
||||
/* Push object literal. */
|
||||
OPDEF(JSOP_OBJECT, 80, "object", NULL, 3, 0, 1, 12, JOF_CONST)
|
||||
@@ -210,3 +210,8 @@ OPDEF(JSOP_SETSP, 117,"setsp", NULL, 3, 0, 0, 0, JOF_UINT16
|
||||
OPDEF(JSOP_CONDSWITCH,118,"condswitch", NULL, 1, 0, 0, 0, JOF_BYTE)
|
||||
OPDEF(JSOP_CASE, 119,"case", NULL, 3, 1, 0, 0, JOF_JUMP)
|
||||
OPDEF(JSOP_DEFAULT, 120,"default", NULL, 3, 1, 0, 0, JOF_JUMP)
|
||||
|
||||
/*
|
||||
* ECMA-compliant call to eval op
|
||||
*/
|
||||
OPDEF(JSOP_CALLSPECIAL,121,"callspecial",NULL, 3, -1, 1, 11, JOF_UINT16)
|
||||
|
||||
@@ -25,15 +25,25 @@
|
||||
#ifdef XP_PC
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "os/win32.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
#else
|
||||
#include "os/win16.h"
|
||||
#undef JS_HAVE_LONG_LONG
|
||||
#endif
|
||||
#endif /* XP_PC */
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "jsmacos.h"
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern void* reallocSmaller(void* block, size_t newSize);
|
||||
|
||||
extern char* strdup(const char* str);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* XP_MAC */
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
||||
@@ -41,34 +51,40 @@
|
||||
* Get OS specific header information.
|
||||
*/
|
||||
#if defined(AIXV3)
|
||||
#include "os/aix.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(BSDI)
|
||||
#include "os/bsdi.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(HPUX)
|
||||
#include "os/hpux.h"
|
||||
#undef JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(IRIX)
|
||||
#include "os/irix.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(LINUX)
|
||||
#include "os/linux.h"
|
||||
#elif defined(linux)
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(OSF1)
|
||||
#include "os/osf1.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(SCO)
|
||||
#include "os/scoos.h"
|
||||
#undef JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(SOLARIS)
|
||||
#include "os/solaris.h"
|
||||
#define JS_HAVE_LONG_LONG
|
||||
|
||||
#elif defined(SUNOS4)
|
||||
#include "os/sunos.h"
|
||||
#undef JS_HAVE_LONG_LONG
|
||||
|
||||
/*
|
||||
** Missing function prototypes
|
||||
*/
|
||||
|
||||
extern void *sbrk(int);
|
||||
|
||||
#elif defined(UNIXWARE)
|
||||
#include "os/unixware.h"
|
||||
#undef JS_HAVE_LONG_LONG
|
||||
#endif
|
||||
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
@@ -23,11 +23,18 @@
|
||||
* the new definitions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note that we test for PROTYPES_H, not JSOTYPES_H. This is to avoid
|
||||
* double-definitions of scalar types such as uint32, if NSPR's
|
||||
* protypes.h is also included.
|
||||
*/
|
||||
#ifndef PROTYPES_H
|
||||
#define PROTYPES_H
|
||||
|
||||
/* SVR4 typedef of uint is commonly found on UNIX machines. */
|
||||
#ifndef XP_UNIX
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/types.h>
|
||||
#else
|
||||
typedef JSUintn uint;
|
||||
#endif
|
||||
|
||||
@@ -79,6 +86,84 @@ typedef JSFloat64 float64;
|
||||
#define SET_BIT JS_SET_BIT
|
||||
#define CLEAR_BIT JS_CLEAR_BIT
|
||||
|
||||
/* Re: prarena.h->plarena.h */
|
||||
#define PRArena PLArena
|
||||
#define PRArenaPool PLArenaPool
|
||||
#define PRArenaStats PLArenaStats
|
||||
#define PR_ARENA_ALIGN PL_ARENA_ALIGN
|
||||
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL
|
||||
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE
|
||||
#define PR_ARENA_GROW PL_ARENA_GROW
|
||||
#define PR_ARENA_MARK PL_ARENA_MARK
|
||||
#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED
|
||||
#define PR_CLEAR_ARENA PL_CLEAR_ARENA
|
||||
#define PR_ARENA_RELEASE PL_ARENA_RELEASE
|
||||
#define PR_COUNT_ARENA PL_COUNT_ARENA
|
||||
#define PR_ARENA_DESTROY PL_ARENA_DESTROY
|
||||
#define PR_InitArenaPool PL_InitArenaPool
|
||||
#define PR_FreeArenaPool PL_FreeArenaPool
|
||||
#define PR_FinishArenaPool PL_FinishArenaPool
|
||||
#define PR_CompactArenaPool PL_CompactArenaPool
|
||||
#define PR_ArenaFinish PL_ArenaFinish
|
||||
#define PR_ArenaAllocate PL_ArenaAllocate
|
||||
#define PR_ArenaGrow PL_ArenaGrow
|
||||
#define PR_ArenaRelease PL_ArenaRelease
|
||||
#define PR_ArenaCountAllocation PL_ArenaCountAllocation
|
||||
#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth
|
||||
#define PR_ArenaCountGrowth PL_ArenaCountGrowth
|
||||
#define PR_ArenaCountRelease PL_ArenaCountRelease
|
||||
#define PR_ArenaCountRetract PL_ArenaCountRetract
|
||||
|
||||
/* Re: prevent.h->plevent.h */
|
||||
#define PREvent PLEvent
|
||||
#define PREventQueue PLEventQueue
|
||||
#define PR_CreateEventQueue PL_CreateEventQueue
|
||||
#define PR_DestroyEventQueue PL_DestroyEventQueue
|
||||
#define PR_GetEventQueueMonitor PL_GetEventQueueMonitor
|
||||
#define PR_ENTER_EVENT_QUEUE_MONITOR PL_ENTER_EVENT_QUEUE_MONITOR
|
||||
#define PR_EXIT_EVENT_QUEUE_MONITOR PL_EXIT_EVENT_QUEUE_MONITOR
|
||||
#define PR_PostEvent PL_PostEvent
|
||||
#define PR_PostSynchronousEvent PL_PostSynchronousEvent
|
||||
#define PR_GetEvent PL_GetEvent
|
||||
#define PR_EventAvailable PL_EventAvailable
|
||||
#define PREventFunProc PLEventFunProc
|
||||
#define PR_MapEvents PL_MapEvents
|
||||
#define PR_RevokeEvents PL_RevokeEvents
|
||||
#define PR_ProcessPendingEvents PL_ProcessPendingEvents
|
||||
#define PR_WaitForEvent PL_WaitForEvent
|
||||
#define PR_EventLoop PL_EventLoop
|
||||
#define PR_GetEventQueueSelectFD PL_GetEventQueueSelectFD
|
||||
#define PRHandleEventProc PLHandleEventProc
|
||||
#define PRDestroyEventProc PLDestroyEventProc
|
||||
#define PR_InitEvent PL_InitEvent
|
||||
#define PR_GetEventOwner PL_GetEventOwner
|
||||
#define PR_HandleEvent PL_HandleEvent
|
||||
#define PR_DestroyEvent PL_DestroyEvent
|
||||
#define PR_DequeueEvent PL_DequeueEvent
|
||||
#define PR_GetMainEventQueue PL_GetMainEventQueue
|
||||
|
||||
/* Re: prhash.h->plhash.h */
|
||||
#define PRHashEntry PLHashEntry
|
||||
#define PRHashTable PLHashTable
|
||||
#define PRHashNumber PLHashNumber
|
||||
#define PRHashFunction PLHashFunction
|
||||
#define PRHashComparator PLHashComparator
|
||||
#define PRHashEnumerator PLHashEnumerator
|
||||
#define PRHashAllocOps PLHashAllocOps
|
||||
#define PR_NewHashTable PL_NewHashTable
|
||||
#define PR_HashTableDestroy PL_HashTableDestroy
|
||||
#define PR_HashTableRawLookup PL_HashTableRawLookup
|
||||
#define PR_HashTableRawAdd PL_HashTableRawAdd
|
||||
#define PR_HashTableRawRemove PL_HashTableRawRemove
|
||||
#define PR_HashTableAdd PL_HashTableAdd
|
||||
#define PR_HashTableRemove PL_HashTableRemove
|
||||
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries
|
||||
#define PR_HashTableLookup PL_HashTableLookup
|
||||
#define PR_HashTableDump PL_HashTableDump
|
||||
#define PR_HashString PL_HashString
|
||||
#define PR_CompareStrings PL_CompareStrings
|
||||
#define PR_CompareValues PL_CompareValues
|
||||
|
||||
#ifdef XP_MAC
|
||||
#ifndef TRUE /* Mac standard is lower case true */
|
||||
#define TRUE 1
|
||||
|
||||
@@ -36,14 +36,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsatom.h"
|
||||
@@ -260,6 +253,7 @@ js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
|
||||
} while (ok);
|
||||
|
||||
out:
|
||||
ts->flags &= ~TSF_BADCOMPILE;
|
||||
cx->gcDisabled--;
|
||||
cx->fp = fp;
|
||||
if (!ok)
|
||||
@@ -385,7 +379,7 @@ js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun)
|
||||
}
|
||||
|
||||
cx->gcDisabled--;
|
||||
js_ResetCodeGenerator(cx, &funcg);
|
||||
js_FinishCodeGenerator(cx, &funcg);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -727,18 +721,9 @@ ImportExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
pn2->pn_pos.begin = pn->pn_pos.begin;
|
||||
pn2->pn_pos.end = ts->token.pos.end;
|
||||
|
||||
/* Optimize o['p'] to o.p by rewriting pn2. */
|
||||
if (pn3->pn_type == TOK_STRING) {
|
||||
pn2->pn_type = TOK_DOT;
|
||||
pn2->pn_op = JSOP_GETPROP;
|
||||
pn2->pn_arity = PN_NAME;
|
||||
pn2->pn_expr = pn;
|
||||
pn2->pn_atom = pn3->pn_atom;
|
||||
} else {
|
||||
pn2->pn_op = JSOP_GETELEM;
|
||||
pn2->pn_left = pn;
|
||||
pn2->pn_right = pn3;
|
||||
}
|
||||
pn2->pn_op = JSOP_GETELEM;
|
||||
pn2->pn_left = pn;
|
||||
pn2->pn_right = pn3;
|
||||
}
|
||||
|
||||
pn = pn2;
|
||||
@@ -1144,15 +1129,13 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
catchtail = pn;
|
||||
while(js_PeekToken(cx, ts) == TOK_CATCH) {
|
||||
/*
|
||||
* legal catch forms are:
|
||||
* legal catch form is:
|
||||
* catch (v)
|
||||
*
|
||||
* The form
|
||||
* catch (v : <boolean_expression>)
|
||||
* has been pulled pending resolution in ECMA.
|
||||
*/
|
||||
if (!catchtail->pn_kid1->pn_expr) {
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_WARNING,
|
||||
JSMSG_CATCH_AFTER_GENERAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* catch node */
|
||||
pn2 = NewParseNode(cx, &ts->token, PN_TERNARY);
|
||||
@@ -1171,14 +1154,15 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_CATCH);
|
||||
MUST_MATCH_TOKEN(TOK_NAME, JSMSG_CATCH_IDENTIFIER);
|
||||
pn3->pn_atom = ts->token.t_atom;
|
||||
pn3->pn_expr = NULL;
|
||||
#if JS_HAS_CATCH_GUARD
|
||||
if (js_PeekToken(cx, ts) == TOK_COLON) {
|
||||
(void)js_GetToken(cx, ts); /* eat `:' */
|
||||
pn3->pn_expr = Expr(cx, ts, tc);
|
||||
if (!pn3->pn_expr)
|
||||
return NULL;
|
||||
} else {
|
||||
pn3->pn_expr = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
pn2->pn_kid1 = pn3;
|
||||
|
||||
MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_CATCH);
|
||||
@@ -1489,7 +1473,7 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
JSObject *obj, *pobj;
|
||||
JSFunction *fun;
|
||||
JSClass *clasp;
|
||||
JSPropertyOp getter, setter;
|
||||
JSPropertyOp getter, setter, currentGetter, currentSetter;
|
||||
JSAtom *atom;
|
||||
JSProperty *prop;
|
||||
JSScopeProperty *sprop;
|
||||
@@ -1531,6 +1515,8 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
}
|
||||
|
||||
do {
|
||||
currentGetter = getter;
|
||||
currentSetter = setter;
|
||||
MUST_MATCH_TOKEN(TOK_NAME, JSMSG_NO_VARIABLE_NAME);
|
||||
atom = ts->token.t_atom;
|
||||
|
||||
@@ -1549,7 +1535,7 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
OBJ_IS_NATIVE(pobj) &&
|
||||
(sprop = (JSScopeProperty *)prop) != NULL) {
|
||||
if (sprop->getter == js_GetArgument) {
|
||||
getter = sprop->getter;
|
||||
currentGetter = sprop->getter;
|
||||
#ifdef CHECK_ARGUMENT_HIDING
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_WARNING,
|
||||
JSMSG_VAR_HIDES_ARG,
|
||||
@@ -1581,16 +1567,16 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
* don't use the special getters and setters
|
||||
* since we can't allocate a slot in the frame.
|
||||
*/
|
||||
getter = sprop->getter;
|
||||
setter = sprop->setter;
|
||||
currentGetter = sprop->getter;
|
||||
currentSetter = sprop->setter;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Global var: (re-)set id a la js_DefineProperty. */
|
||||
sprop->id = ATOM_KEY(atom);
|
||||
}
|
||||
sprop->getter = getter;
|
||||
sprop->setter = setter;
|
||||
sprop->getter = currentGetter;
|
||||
sprop->setter = currentSetter;
|
||||
sprop->attrs |= JSPROP_ENUMERATE | JSPROP_PERMANENT;
|
||||
sprop->attrs &= ~JSPROP_READONLY;
|
||||
}
|
||||
@@ -1606,18 +1592,18 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
OBJ_DROP_PROPERTY(cx, pobj, prop);
|
||||
prop = NULL;
|
||||
}
|
||||
if (getter == js_GetCallVariable) {
|
||||
if (currentGetter == js_GetCallVariable) {
|
||||
/* Can't increase fun->nvars in an active frame! */
|
||||
getter = clasp->getProperty;
|
||||
setter = clasp->setProperty;
|
||||
currentGetter = clasp->getProperty;
|
||||
currentSetter = clasp->setProperty;
|
||||
}
|
||||
ok = OBJ_DEFINE_PROPERTY(cx, obj, (jsid)atom, JSVAL_VOID,
|
||||
getter, setter,
|
||||
currentGetter, currentSetter,
|
||||
JSPROP_ENUMERATE | JSPROP_PERMANENT,
|
||||
&prop);
|
||||
if (ok && prop) {
|
||||
pobj = obj;
|
||||
if (getter == js_GetLocalVariable) {
|
||||
if (currentGetter == js_GetLocalVariable) {
|
||||
/*
|
||||
* Allocate more room for variables in the
|
||||
* function's frame. We can do this only
|
||||
@@ -1650,14 +1636,14 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
/* Depending on the value of the getter, change the
|
||||
* opcodes to the forms for arguments and variables.
|
||||
*/
|
||||
if (getter == js_GetArgument) {
|
||||
if (currentGetter == js_GetArgument) {
|
||||
JS_ASSERT(sprop && JSVAL_IS_INT(sprop->id));
|
||||
pn2->pn_op = (pn2->pn_op == JSOP_NAME)
|
||||
? JSOP_GETARG
|
||||
: JSOP_SETARG;
|
||||
pn2->pn_slot = JSVAL_TO_INT(sprop->id);
|
||||
} else if (getter == js_GetLocalVariable ||
|
||||
getter == js_GetCallVariable)
|
||||
} else if (currentGetter == js_GetLocalVariable ||
|
||||
currentGetter == js_GetCallVariable)
|
||||
{
|
||||
JS_ASSERT(sprop && JSVAL_IS_INT(sprop->id));
|
||||
pn2->pn_op = (pn2->pn_op == JSOP_NAME)
|
||||
@@ -2214,18 +2200,9 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||
pn2->pn_pos.begin = pn->pn_pos.begin;
|
||||
pn2->pn_pos.end = ts->token.pos.end;
|
||||
|
||||
/* Optimize o['p'] to o.p by rewriting pn2. */
|
||||
if (pn3->pn_type == TOK_STRING) {
|
||||
pn2->pn_type = TOK_DOT;
|
||||
pn2->pn_op = JSOP_GETPROP;
|
||||
pn2->pn_arity = PN_NAME;
|
||||
pn2->pn_expr = pn;
|
||||
pn2->pn_atom = pn3->pn_atom;
|
||||
} else {
|
||||
pn2->pn_op = JSOP_GETELEM;
|
||||
pn2->pn_left = pn;
|
||||
pn2->pn_right = pn3;
|
||||
}
|
||||
pn2->pn_op = JSOP_GETELEM;
|
||||
pn2->pn_left = pn;
|
||||
pn2->pn_right = pn3;
|
||||
} else if (allowCallSyntax && tt == TOK_LP) {
|
||||
pn2 = NewParseNode(cx, &ts->token, PN_LIST);
|
||||
if (!pn2)
|
||||
@@ -2522,7 +2499,7 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
JSBool
|
||||
js_FoldConstants(JSContext *cx, JSParseNode *pn)
|
||||
{
|
||||
JSParseNode *pn1, *pn2, *pn3;
|
||||
JSParseNode *pn1=NULL, *pn2=NULL, *pn3=NULL;
|
||||
|
||||
switch (pn->pn_arity) {
|
||||
case PN_FUNC:
|
||||
|
||||
@@ -28,20 +28,17 @@
|
||||
#include <stdlib.h>
|
||||
#include "jsprf.h"
|
||||
#include "jslong.h"
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
/* Removed by JSIFY: #include "jsmem.h"
|
||||
*/
|
||||
|
||||
/*
|
||||
** Note: on some platforms va_list is defined as an array,
|
||||
** and requires array notation.
|
||||
*/
|
||||
#if defined(MKLINUX) || defined(WIN16)
|
||||
#if (defined(linux) && defined(__powerpc__)) || defined(WIN16)
|
||||
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
|
||||
#else
|
||||
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
|
||||
#endif /*MKLINUX*/
|
||||
#endif /* Linux/PPC || WIN16 */
|
||||
|
||||
/*
|
||||
** WARNING: This code may *NOT* call JS_LOG (because JS_LOG calls it)
|
||||
@@ -1023,7 +1020,7 @@ static int FuncStuff(SprintfState *ss, const char *sp, JSUint32 len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
|
||||
JS_EXPORT_API(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -1035,7 +1032,7 @@ IMPLEMENT(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
|
||||
return rv;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSUint32) JS_vsxprintf(JSStuffFunc func, void *arg,
|
||||
JS_EXPORT_API(JSUint32) JS_vsxprintf(JSStuffFunc func, void *arg,
|
||||
const char *fmt, va_list ap)
|
||||
{
|
||||
SprintfState ss;
|
||||
@@ -1089,7 +1086,7 @@ static int GrowStuff(SprintfState *ss, const char *sp, JSUint32 len)
|
||||
/*
|
||||
** sprintf into a malloc'd buffer
|
||||
*/
|
||||
IMPLEMENT(char *) JS_smprintf(const char *fmt, ...)
|
||||
JS_EXPORT_API(char *) JS_smprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *rv;
|
||||
@@ -1103,12 +1100,12 @@ IMPLEMENT(char *) JS_smprintf(const char *fmt, ...)
|
||||
/*
|
||||
** Free memory allocated, for the caller, by JS_smprintf
|
||||
*/
|
||||
IMPLEMENT(void) JS_smprintf_free(char *mem)
|
||||
JS_EXPORT_API(void) JS_smprintf_free(char *mem)
|
||||
{
|
||||
JS_DELETE(mem);
|
||||
}
|
||||
|
||||
IMPLEMENT(char *) JS_vsmprintf(const char *fmt, va_list ap)
|
||||
JS_EXPORT_API(char *) JS_vsmprintf(const char *fmt, va_list ap)
|
||||
{
|
||||
SprintfState ss;
|
||||
int rv;
|
||||
@@ -1148,7 +1145,7 @@ static int LimitStuff(SprintfState *ss, const char *sp, JSUint32 len)
|
||||
** sprintf into a fixed size buffer. Make sure there is a NUL at the end
|
||||
** when finished.
|
||||
*/
|
||||
IMPLEMENT(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...)
|
||||
JS_EXPORT_API(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv;
|
||||
@@ -1164,7 +1161,7 @@ IMPLEMENT(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...
|
||||
return rv;
|
||||
}
|
||||
|
||||
IMPLEMENT(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
|
||||
JS_EXPORT_API(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
|
||||
va_list ap)
|
||||
{
|
||||
SprintfState ss;
|
||||
@@ -1189,7 +1186,7 @@ IMPLEMENT(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
|
||||
return n ? n - 1 : n;
|
||||
}
|
||||
|
||||
IMPLEMENT(char *) JS_sprintf_append(char *last, const char *fmt, ...)
|
||||
JS_EXPORT_API(char *) JS_sprintf_append(char *last, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *rv;
|
||||
@@ -1200,7 +1197,7 @@ IMPLEMENT(char *) JS_sprintf_append(char *last, const char *fmt, ...)
|
||||
return rv;
|
||||
}
|
||||
|
||||
IMPLEMENT(char *) JS_vsprintf_append(char *last, const char *fmt, va_list ap)
|
||||
JS_EXPORT_API(char *) JS_vsprintf_append(char *last, const char *fmt, va_list ap)
|
||||
{
|
||||
SprintfState ss;
|
||||
int rv;
|
||||
|
||||
@@ -46,19 +46,19 @@ JS_BEGIN_EXTERN_C
|
||||
** of the buffer. Returns the length of the written output, NOT including
|
||||
** the NUL, or (JSUint32)-1 if an error occurs.
|
||||
*/
|
||||
EXTERN(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...);
|
||||
JS_EXTERN_API(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
** sprintf into a malloc'd buffer. Return a pointer to the malloc'd
|
||||
** buffer on success, NULL on failure. Call "JS_smprintf_free" to release
|
||||
** the memory returned.
|
||||
*/
|
||||
EXTERN(char*) JS_smprintf(const char *fmt, ...);
|
||||
JS_EXTERN_API(char*) JS_smprintf(const char *fmt, ...);
|
||||
|
||||
/*
|
||||
** Free the memory allocated, for the caller, by JS_smprintf
|
||||
*/
|
||||
EXTERN(void) JS_smprintf_free(char *mem);
|
||||
JS_EXTERN_API(void) JS_smprintf_free(char *mem);
|
||||
|
||||
/*
|
||||
** "append" sprintf into a malloc'd buffer. "last" is the last value of
|
||||
@@ -67,7 +67,7 @@ EXTERN(void) JS_smprintf_free(char *mem);
|
||||
** will allocate the initial string. The return value is the new value of
|
||||
** last for subsequent calls, or NULL if there is a malloc failure.
|
||||
*/
|
||||
EXTERN(char*) JS_sprintf_append(char *last, const char *fmt, ...);
|
||||
JS_EXTERN_API(char*) JS_sprintf_append(char *last, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
** sprintf into a function. The function "f" is called with a string to
|
||||
@@ -78,15 +78,15 @@ EXTERN(char*) JS_sprintf_append(char *last, const char *fmt, ...);
|
||||
*/
|
||||
typedef JSIntn (*JSStuffFunc)(void *arg, const char *s, JSUint32 slen);
|
||||
|
||||
EXTERN(JSUint32) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...);
|
||||
JS_EXTERN_API(JSUint32) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
** va_list forms of the above.
|
||||
*/
|
||||
EXTERN(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen, const char *fmt, va_list ap);
|
||||
EXTERN(char*) JS_vsmprintf(const char *fmt, va_list ap);
|
||||
EXTERN(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap);
|
||||
EXTERN(JSUint32) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap);
|
||||
JS_EXTERN_API(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen, const char *fmt, va_list ap);
|
||||
JS_EXTERN_API(char*) JS_vsmprintf(const char *fmt, va_list ap);
|
||||
JS_EXTERN_API(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap);
|
||||
JS_EXTERN_API(JSUint32) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap);
|
||||
|
||||
/*
|
||||
***************************************************************************
|
||||
@@ -121,7 +121,7 @@ EXTERN(JSUint32) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
EXTERN(JSInt32) JS_sscanf(const char *buf, const char *fmt, ...);
|
||||
JS_EXTERN_API(JSInt32) JS_sscanf(const char *buf, const char *fmt, ...);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ typedef struct JSPRHashEntry JSPRHashEntry;
|
||||
typedef struct JSPRHashTable JSPRHashTable;
|
||||
typedef JSPRUint32 JSPRHashNumber;
|
||||
#define JSPR_HASH_BITS 32
|
||||
typedef JSPRHashNumber (JSCALLBACK *JSPRHashFunction)(const void *key);
|
||||
typedef JSPRIntn (JSCALLBACK *JSPRHashComparator)(const void *v1, const void *v2);
|
||||
typedef JSPRIntn (JSCALLBACK *JSPRHashEnumerator)(JSPRHashEntry *he, JSPRIntn i, void *arg);
|
||||
typedef JSPRHashNumber (JSJS_DLL_CALLBACK *JSPRHashFunction)(const void *key);
|
||||
typedef JSPRIntn (JSJS_DLL_CALLBACK *JSPRHashComparator)(const void *v1, const void *v2);
|
||||
typedef JSPRIntn (JSJS_DLL_CALLBACK *JSPRHashEnumerator)(JSPRHashEntry *he, JSPRIntn i, void *arg);
|
||||
|
||||
/* Flag bits in JSPRHashEnumerator's return value */
|
||||
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
|
||||
@@ -42,10 +42,10 @@ typedef JSPRIntn (JSCALLBACK *JSPRHashEnumerator)(JSPRHashEntry *he, JSPRIntn i,
|
||||
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
|
||||
|
||||
typedef struct JSPRHashAllocOps {
|
||||
void * (JSCALLBACK *allocTable)(void *pool, JSPRSize size);
|
||||
void (JSCALLBACK *freeTable)(void *pool, void *item);
|
||||
JSPRHashEntry * (JSCALLBACK *allocEntry)(void *pool, const void *key);
|
||||
void (JSCALLBACK *freeEntry)(void *pool, JSPRHashEntry *he, JSPRUintn flag);
|
||||
void * (JSJS_DLL_CALLBACK *allocTable)(void *pool, JSPRSize size);
|
||||
void (JSJS_DLL_CALLBACK *freeTable)(void *pool, void *item);
|
||||
JSPRHashEntry * (JSJS_DLL_CALLBACK *allocEntry)(void *pool, const void *key);
|
||||
void (JSJS_DLL_CALLBACK *freeEntry)(void *pool, JSPRHashEntry *he, JSPRUintn flag);
|
||||
} JSPRHashAllocOps;
|
||||
|
||||
#define HT_FREE_VALUE 0 /* just free the entry's value */
|
||||
@@ -79,51 +79,51 @@ struct JSPRHashTable {
|
||||
* Create a new hash table.
|
||||
* If allocOps is null, use default allocator ops built on top of malloc().
|
||||
*/
|
||||
JSEXTERN(JSPRHashTable *)
|
||||
JSJS_EXTERN_API(JSPRHashTable *)
|
||||
JSPR_NewHashTable(JSPRUint32 n, JSPRHashFunction keyHash,
|
||||
JSPRHashComparator keyCompare, JSPRHashComparator valueCompare,
|
||||
JSPRHashAllocOps *allocOps, void *allocPriv);
|
||||
|
||||
JSEXTERN(void)
|
||||
JSJS_EXTERN_API(void)
|
||||
JSPR_HashTableDestroy(JSPRHashTable *ht);
|
||||
|
||||
/* Low level access methods */
|
||||
JSEXTERN(JSPRHashEntry **)
|
||||
JSJS_EXTERN_API(JSPRHashEntry **)
|
||||
JSPR_HashTableRawLookup(JSPRHashTable *ht, JSPRHashNumber keyHash, const void *key);
|
||||
|
||||
JSEXTERN(JSPRHashEntry *)
|
||||
JSJS_EXTERN_API(JSPRHashEntry *)
|
||||
JSPR_HashTableRawAdd(JSPRHashTable *ht, JSPRHashEntry **hep, JSPRHashNumber keyHash,
|
||||
const void *key, void *value);
|
||||
|
||||
JSEXTERN(void)
|
||||
JSJS_EXTERN_API(void)
|
||||
JSPR_HashTableRawRemove(JSPRHashTable *ht, JSPRHashEntry **hep, JSPRHashEntry *he);
|
||||
|
||||
/* Higher level access methods */
|
||||
JSEXTERN(JSPRHashEntry *)
|
||||
JSJS_EXTERN_API(JSPRHashEntry *)
|
||||
JSPR_HashTableAdd(JSPRHashTable *ht, const void *key, void *value);
|
||||
|
||||
JSEXTERN(JSPRBool)
|
||||
JSJS_EXTERN_API(JSPRBool)
|
||||
JSPR_HashTableRemove(JSPRHashTable *ht, const void *key);
|
||||
|
||||
JSEXTERN(JSPRIntn)
|
||||
JSJS_EXTERN_API(JSPRIntn)
|
||||
JSPR_HashTableEnumerateEntries(JSPRHashTable *ht, JSPRHashEnumerator f, void *arg);
|
||||
|
||||
JSEXTERN(void *)
|
||||
JSJS_EXTERN_API(void *)
|
||||
JSPR_HashTableLookup(JSPRHashTable *ht, const void *key);
|
||||
|
||||
JSEXTERN(JSPRIntn)
|
||||
JSJS_EXTERN_API(JSPRIntn)
|
||||
JSPR_HashTableDump(JSPRHashTable *ht, JSPRHashEnumerator dump, FILE *fp);
|
||||
|
||||
/* General-purpose C string hash function. */
|
||||
JSEXTERN(JSPRHashNumber)
|
||||
JSJS_EXTERN_API(JSPRHashNumber)
|
||||
JSPR_HashString(const void *key);
|
||||
|
||||
/* Compare strings using strcmp(), return true if equal. */
|
||||
JSEXTERN(int)
|
||||
JSJS_EXTERN_API(int)
|
||||
JSPR_CompareStrings(const void *v1, const void *v2);
|
||||
|
||||
/* Stub function just returns v1 == v2 */
|
||||
JSEXTERN(JSPRIntn)
|
||||
JSJS_EXTERN_API(JSPRIntn)
|
||||
JSPR_CompareValues(const void *v1, const void *v2);
|
||||
|
||||
JSPR_END_EXTERN_C
|
||||
|
||||
@@ -74,6 +74,7 @@ typedef enum JSTrapStatus {
|
||||
JSTRAP_ERROR,
|
||||
JSTRAP_CONTINUE,
|
||||
JSTRAP_RETURN,
|
||||
JSTRAP_THROW,
|
||||
JSTRAP_LIMIT
|
||||
} JSTrapStatus;
|
||||
|
||||
@@ -145,4 +146,12 @@ typedef void *
|
||||
(* CRT_CALL JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
|
||||
JSBool *ok, void *closure);
|
||||
|
||||
typedef void
|
||||
(* CRT_CALL JSObjectHook)(JSContext *cx, JSObject *obj, JSBool isNew,
|
||||
void *closure);
|
||||
|
||||
typedef JSBool
|
||||
(* CRT_CALL JSDebugErrorHook)(JSContext *cx, const char *message,
|
||||
JSErrorReport *report, void *closure);
|
||||
|
||||
#endif /* jsprvtd_h___ */
|
||||
|
||||
@@ -22,63 +22,9 @@
|
||||
* JS public API typedefs.
|
||||
*/
|
||||
#include "jstypes.h"
|
||||
#define NETSCAPE_INTERNAL 1
|
||||
#include "jscompat.h"
|
||||
|
||||
#ifndef JS_INLINE
|
||||
# ifdef _WIN32
|
||||
# define JS_INLINE __inline
|
||||
# elif defined(__GNUC__)
|
||||
# define JS_INLINE inline
|
||||
# else
|
||||
# define JS_INLINE
|
||||
# endif
|
||||
#endif /* JS_INLINE */
|
||||
|
||||
/*
|
||||
* Downrev NSPR versions of jstypes.h do not define these linkage-related
|
||||
* PR_* macros, so we define them if necessary. Eventually, we should be
|
||||
* able to remove these local definitions (move them to js/ref/jstypes.h,
|
||||
* and get them from an uprev NSPR's jstypes.h for js/src).
|
||||
*/
|
||||
#ifndef IMPORT_API
|
||||
# ifdef _WIN32
|
||||
# define IMPORT_API(__x) _declspec(dllimport) __x
|
||||
# else
|
||||
# define IMPORT_API(__x) IMPLEMENT(__x)
|
||||
# endif
|
||||
#endif /* IMPORT_API */
|
||||
#ifndef IMPORT_DATA
|
||||
# ifdef _WIN32
|
||||
# define IMPORT_DATA(__x) _declspec(dllimport) __x
|
||||
# else
|
||||
# define IMPORT_DATA(__x) __x
|
||||
# endif
|
||||
#endif /* IMPORT_DATA */
|
||||
#ifndef PUBLIC_DATA
|
||||
# ifdef _WIN32
|
||||
# define PUBLIC_DATA(__x) _declspec(dllexport) __x
|
||||
# else
|
||||
# define PUBLIC_DATA(__x) __x
|
||||
# endif
|
||||
#endif /* PUBLIC_DATA */
|
||||
|
||||
/*
|
||||
* The linkage of JS API functions differs depending on whether the file is
|
||||
* used within the JS library or not. Any source file within the JS
|
||||
* interpreter should define EXPORT_JS_API whereas any client of the library
|
||||
* should not.
|
||||
*/
|
||||
#ifdef EXPORT_JS_API
|
||||
#define JS_PUBLIC_API(t) IMPLEMENT(t)
|
||||
#define JS_PUBLIC_DATA(t) PUBLIC_DATA(t)
|
||||
#else
|
||||
#define JS_PUBLIC_API(t) IMPORT_API(t)
|
||||
#define JS_PUBLIC_DATA(t) IMPORT_DATA(t)
|
||||
#endif
|
||||
|
||||
#define JS_FRIEND_API(t) JS_PUBLIC_API(t)
|
||||
#define JS_FRIEND_DATA(t) JS_PUBLIC_DATA(t)
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/* Scalar typedefs. */
|
||||
typedef uint16 jschar;
|
||||
@@ -101,8 +47,6 @@ typedef enum JSVersion {
|
||||
|
||||
#define JSVERSION_IS_ECMA(version) \
|
||||
((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
|
||||
#define JSVERSION_IS_ECMAv2(version) \
|
||||
((version) >= JSVERSION_1_3)
|
||||
|
||||
/* Result of typeof operator enumeration. */
|
||||
typedef enum JSType {
|
||||
@@ -152,6 +96,7 @@ typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
|
||||
typedef struct JSScript JSScript;
|
||||
typedef struct JSString JSString;
|
||||
typedef struct JSXDRState JSXDRState;
|
||||
typedef struct JSExceptionState JSExceptionState;
|
||||
|
||||
#ifndef CRT_CALL
|
||||
#ifdef XP_OS2
|
||||
@@ -293,4 +238,6 @@ typedef const JSErrorFormatString *
|
||||
(* CRT_CALL JSErrorCallback)(void *userRef, const char *locale,
|
||||
const uintN errorNumber);
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jspubtd_h___ */
|
||||
|
||||
@@ -23,14 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsapi.h"
|
||||
#include "jsarray.h"
|
||||
@@ -1187,6 +1180,7 @@ AnchorRegExp(CompilerState *state, RENode *ren)
|
||||
|
||||
for (ren2 = ren; REOP(ren2) == REOP_LPAREN; ren2 = ren2->kid)
|
||||
;
|
||||
len = 0; /* Avoid warning. */
|
||||
switch (REOP(ren2)) {
|
||||
case REOP_ALT:
|
||||
len = CountFirstChars(ren2);
|
||||
@@ -1483,7 +1477,7 @@ OptimizeRegExp(CompilerState *state, RENode *ren)
|
||||
len = 1;
|
||||
}
|
||||
cx = state->context;
|
||||
JS_ARENA_ALLOCATE(cp, &cx->tempPool, len + 2);
|
||||
JS_ARENA_ALLOCATE(cp, &cx->tempPool, (len+2) * sizeof(jschar));
|
||||
if (!cp) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return JS_FALSE;
|
||||
@@ -1920,7 +1914,7 @@ EmitRegExp(CompilerState *state, RENode *ren, JSRegExp *re)
|
||||
pc[j] = (jsbytecode)c;
|
||||
#if IS_LITTLE_ENDIAN
|
||||
if (op == REOP_UCFLAT)
|
||||
pc[j++] = (jsbytecode)(c >> 8);
|
||||
pc[++j] = (jsbytecode)(c >> 8);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@@ -2102,6 +2096,9 @@ MatchRegExp(MatchState *state, jsbytecode *pc, const jschar *cp)
|
||||
while (pc < pcend) {
|
||||
op = (REOp) *pc;
|
||||
oplen = reopsize[op];
|
||||
|
||||
matched = JS_FALSE; /* Avoid warnings. */
|
||||
matchlen = 0;
|
||||
|
||||
switch (op) {
|
||||
case REOP_EMPTY:
|
||||
@@ -2488,7 +2485,7 @@ MatchRegExp(MatchState *state, jsbytecode *pc, const jschar *cp)
|
||||
|
||||
case REOP_UCFLATi:
|
||||
matchlen = (ptrdiff_t)pc[1];
|
||||
oplen += matchlen;
|
||||
oplen += 2 * matchlen;
|
||||
matched = (cp + matchlen <= cpend);
|
||||
if (matched) {
|
||||
pc2 = pc + 2;
|
||||
@@ -2658,6 +2655,9 @@ js_ExecuteRegExp(JSContext *cx, JSRegExp *re, JSString *str, size_t *indexp,
|
||||
* an array object, do return true.
|
||||
*/
|
||||
*rval = JSVAL_TRUE;
|
||||
|
||||
/* Avoid warning. (gcc doesn't detect that obj is needed iff !test); */
|
||||
obj = NULL;
|
||||
} else {
|
||||
/*
|
||||
* The array returned on match has element 0 bound to the matched
|
||||
|
||||
@@ -30,14 +30,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jstypes.h"
|
||||
#ifndef NSPR20
|
||||
#include "jsarena.h"
|
||||
#else
|
||||
/* Removed by JSIFY: #include "plarena.h"
|
||||
*/
|
||||
#include "jsarena.h" /* Added by JSIFY */
|
||||
#endif
|
||||
/* Removed by JSIFY: #include "prlog.h" */
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jsdtoa.h"
|
||||
#include "jsprf.h"
|
||||
@@ -445,6 +438,8 @@ MatchChar(JSTokenStream *ts, int32 expect)
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* XXX js_ReportCompileError is unused */
|
||||
void
|
||||
js_ReportCompileError(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
const char *format, ...)
|
||||
@@ -483,6 +478,8 @@ js_ReportCompileError(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
report.uclinebuf = ts->linebuf.base;
|
||||
report.uctokenptr = ts->token.ptr;
|
||||
report.flags = flags;
|
||||
report.errorNumber = 0;
|
||||
|
||||
(*onError)(cx, message, &report);
|
||||
#if !defined XP_PC || !defined _MSC_VER || _MSC_VER > 800
|
||||
} else {
|
||||
@@ -502,6 +499,7 @@ js_ReportCompileError(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
limit[-1] = lastc;
|
||||
free(message);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
@@ -521,7 +519,8 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
|
||||
va_start(ap, errorNumber);
|
||||
if (!js_ExpandErrorArguments(cx, js_GetErrorMessage, NULL,
|
||||
errorNumber, &message, &report, ap))
|
||||
errorNumber, &message, &report,
|
||||
JS_TRUE, ap))
|
||||
return;
|
||||
va_end(ap);
|
||||
|
||||
@@ -554,16 +553,39 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
* report.flags. Proper behavior for error reporters is probably to
|
||||
* ignore this for all but toplevel compilation errors.
|
||||
|
||||
* XXXmccabe it's still at issue if there's a public API to distinguish
|
||||
* between toplevel compilation and other types.
|
||||
|
||||
* XXX it'd probably be best if there was only one call to this
|
||||
* function, but there seem to be two error reporter call points.
|
||||
*/
|
||||
(void)js_ErrorToException(cx, &report, message);
|
||||
#endif
|
||||
|
||||
(*onError)(cx, message, &report);
|
||||
/*
|
||||
* Only try to raise an exception if there isn't one already set -
|
||||
* otherwise the exception will describe only the last compile error,
|
||||
* which is likely spurious.
|
||||
*/
|
||||
if (!(ts->flags & TSF_BADCOMPILE))
|
||||
if (js_ErrorToException(cx, message, &report)) {
|
||||
ts->flags |= TSF_BADCOMPILE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Suppress any compiletime errors that don't occur at the top level.
|
||||
* This may still fail, as interplevel may be zero in contexts where we
|
||||
* don't really want to call the error reporter, as when js is called
|
||||
* by other code which could catch the error.
|
||||
*/
|
||||
if (cx->interpLevel != 0)
|
||||
onError = NULL;
|
||||
#endif
|
||||
if (cx->runtime->debugErrorHook && onError) {
|
||||
JSDebugErrorHook hook = cx->runtime->debugErrorHook;
|
||||
/* test local in case debugErrorHook changed on another thread */
|
||||
if (hook && !hook(cx, message, &report,
|
||||
cx->runtime->debugErrorHookData)) {
|
||||
onError = NULL;
|
||||
}
|
||||
}
|
||||
if (onError)
|
||||
(*onError)(cx, message, &report);
|
||||
|
||||
#if !defined XP_PC || !defined _MSC_VER || _MSC_VER > 800
|
||||
} else {
|
||||
@@ -581,8 +603,8 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
|
||||
}
|
||||
if (lastc == '\n')
|
||||
limit[-1] = lastc;
|
||||
if (message) free(message);
|
||||
if (report.messageArgs) free(report.messageArgs);
|
||||
if (message) JS_free(cx, message);
|
||||
if (report.messageArgs) JS_free(cx, (void *)report.messageArgs);
|
||||
}
|
||||
|
||||
JSTokenType
|
||||
@@ -741,12 +763,13 @@ retry:
|
||||
} else if (JS7_ISDEC(c)) {
|
||||
/*
|
||||
* We permit 08 and 09 as decimal numbers, which makes our
|
||||
* behaviour superset of the ECMA numeric grammar. We might
|
||||
* behaviour a superset of the ECMA numeric grammar. We might
|
||||
* not always be so permissive, so we warn about it.
|
||||
*/
|
||||
if (c > '7' && JSVERSION_IS_ECMA(cx->version)) {
|
||||
js_ReportCompileError(cx, ts, JSREPORT_WARNING,
|
||||
"0%c is not a legal ECMA-262 numeric constant", c);
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_WARNING,
|
||||
JSMSG_BAD_OCTAL,
|
||||
c == '8' ? "08" : "09");
|
||||
radix = 10;
|
||||
} else {
|
||||
radix = 8;
|
||||
@@ -780,8 +803,8 @@ retry:
|
||||
c = GetChar(ts);
|
||||
}
|
||||
if (!JS7_ISDEC(c)) {
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"missing exponent");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_MISSING_EXPONENT);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
do {
|
||||
@@ -797,14 +820,14 @@ retry:
|
||||
|
||||
if (radix == 10) {
|
||||
if (!js_strtod(cx, ts->tokenbuf.base, &endptr, &dval)) {
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"out of memory");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_OUT_OF_MEMORY);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (!js_strtointeger(cx, ts->tokenbuf.base, &endptr, radix, &dval)) {
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"out of memory");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_OUT_OF_MEMORY);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -819,8 +842,8 @@ retry:
|
||||
while ((c = GetChar(ts)) != qc) {
|
||||
if (c == '\n' || c == EOF) {
|
||||
UngetChar(ts, c);
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"unterminated string literal");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_STRING);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
if (c == '\\') {
|
||||
@@ -1009,13 +1032,13 @@ skipline:
|
||||
if (c == '/' && MatchChar(ts, '*')) {
|
||||
if (MatchChar(ts, '/'))
|
||||
goto retry;
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"nested comment");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_NESTED_COMMENT);
|
||||
}
|
||||
}
|
||||
if (c == EOF) {
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"unterminated comment");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_COMMENT);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
goto retry;
|
||||
@@ -1030,8 +1053,8 @@ skipline:
|
||||
while ((c = GetChar(ts)) != '/') {
|
||||
if (c == '\n' || c == EOF) {
|
||||
UngetChar(ts, c);
|
||||
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
|
||||
"unterminated regular expression literal");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_REGEXP);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
if (c == '\\') {
|
||||
@@ -1054,8 +1077,8 @@ skipline:
|
||||
c = PeekChar(ts);
|
||||
if (JS7_ISLET(c)) {
|
||||
ts->token.ptr = ts->linebuf.ptr - 1;
|
||||
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
|
||||
"invalid flag after regular expression");
|
||||
js_ReportCompileErrorNumber(cx, ts,JSREPORT_ERROR,
|
||||
JSMSG_BAD_REGEXP_FLAG);
|
||||
(void) GetChar(ts);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
@@ -1121,8 +1144,8 @@ skipline:
|
||||
break;
|
||||
n = 10 * n + JS7_UNDEC(c);
|
||||
if (n >= ATOM_INDEX_LIMIT) {
|
||||
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
|
||||
"overlarge sharp variable number");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_SHARPVAR_TOO_BIG);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -1138,8 +1161,8 @@ skipline:
|
||||
#endif /* JS_HAS_SHARP_VARS */
|
||||
|
||||
default:
|
||||
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
|
||||
"illegal character");
|
||||
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
|
||||
JSMSG_ILLEGAL_CHARACTER);
|
||||
RETURN(TOK_ERROR);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user