Compare commits

..

1 Commits

Author SHA1 Message Date
(no author)
e99fb1da7b This commit was manufactured by cvs2svn to create branch 'jsd'.
git-svn-id: svn://10.0.0.236/branches/jsd@10728 18797224-902f-48f8-a5cc-f745e15eee43
1998-09-22 23:39:14 +00:00
194 changed files with 20012 additions and 7298 deletions

View File

@@ -1,38 +1,27 @@
# 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.tbl
jsopcode.def
jsopcode.h
jsosdep.h
jsotypes.h
jsparse.h
jsprf.h
jsprvtd.h
jspubtd.h
jsregexp.h
@@ -40,8 +29,3 @@ jsscan.h
jsscope.h
jsscript.h
jsstr.h
jstypes.h
jsutil.h
jsxdrapi.h

View File

@@ -37,48 +37,36 @@ endif
MODULE = js
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)
CSRCS = jsapi.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsemit.c \
jsfun.c \
jsgc.c \
jsinterp.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsregexp.c \
jsscan.c \
jsscope.c \
jsscript.c \
jsstr.c \
jslock.c \
jsxdrapi.c \
prmjtime.c \
$(NULL)
EXPORTS = js.msg \
jsapi.h \
EXPORTS = jsapi.h \
jsarray.h \
jsarena.h \
jsatom.h \
jsbit.h \
jsbool.h \
jsclist.h \
jscntxt.h \
jscompat.h \
jsconfig.h \
@@ -87,19 +75,14 @@ EXPORTS = js.msg \
jsemit.h \
jsfun.h \
jsgc.h \
jshash.h \
jsinterp.h \
jslock.h \
jslong.h \
jsmath.h \
jsnum.h \
jsobj.h \
jsopcode.tbl \
jsopcode.def \
jsopcode.h \
jsosdep.h \
jsotypes.h \
jsparse.h \
jsprf.h \
jsprvtd.h \
jspubtd.h \
jsregexp.h \
@@ -107,8 +90,6 @@ EXPORTS = js.msg \
jsscope.h \
jsscript.h \
jsstr.h \
jstypes.h \
jsutil.h \
jsxdrapi.h \
$(NULL)
@@ -121,6 +102,7 @@ JS_SAFE_ARENA = 1
ifdef JS_SAFE_ARENA
DEFINES += -DJS_USE_SAFE_ARENA
CSRCS += prarena.c
endif
include $(DEPTH)/config/rules.mk
@@ -165,6 +147,12 @@ 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 \
@@ -177,7 +165,8 @@ JSJAVA_CFLAGS = -I$(DEPTH)/sun-java/md-include \
-I$(DEPTH)/sun-java/include \
$(JSJAVA_STUBHEADERS)
# LIBNSPR abstracts nspr version, etc. nicely.
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
# etc. nicely.
LDFLAGS = $(LIBNSPR) -lm
ifeq ($(OS_ARCH), OSF1)
@@ -190,30 +179,6 @@ 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
@@ -232,22 +197,8 @@ $(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
endif
# 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
# hardwire dependencies on jsopcode.def
jsopcode.h jsopcode.c: jsopcode.def
# this section was put in the merged by danda into the
# JAVA_*_MERGE section and normally would have
@@ -262,6 +213,24 @@ $(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

View File

@@ -40,48 +40,36 @@ endif
MODULE = js
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 \
CSRCS = jsapi.c \
jsarray.c \
jsatom.c \
jsbool.c \
jscntxt.c \
jsdate.c \
jsdbgapi.c \
jsemit.c \
jsfun.c \
jsgc.c \
jsinterp.c \
jsmath.c \
jsnum.c \
jsobj.c \
jsopcode.c \
jsparse.c \
jsregexp.c \
jsscan.c \
jsscope.c \
jsscript.c \
jsstr.c \
jslock.c \
jsxdrapi.c \
prmjtime.c \
$(NULL)
EXPORTS = js.msg \
jsapi.h \
EXPORTS = jsapi.h \
jsarray.h \
jsarena.h \
jsatom.h \
jsbit.h \
jsbool.h \
jsclist.h \
jscntxt.h \
jscompat.h \
jsconfig.h \
@@ -90,19 +78,14 @@ EXPORTS = js.msg \
jsemit.h \
jsfun.h \
jsgc.h \
jshash.h \
jsinterp.h \
jslock.h \
jslong.h \
jsmath.h \
jsnum.h \
jsobj.h \
jsopcode.tbl \
jsopcode.def \
jsopcode.h \
jsosdep.h \
jsotypes.h \
jsparse.h \
jsprf.h \
jsprvtd.h \
jspubtd.h \
jsregexp.h \
@@ -110,8 +93,6 @@ EXPORTS = js.msg \
jsscope.h \
jsscript.h \
jsstr.h \
jstypes.h \
jsutil.h \
jsxdrapi.h \
$(NULL)
@@ -126,6 +107,7 @@ JS_SAFE_ARENA = 1
ifdef JS_SAFE_ARENA
DEFINES += -DJS_USE_SAFE_ARENA
CSRCS += prarena.c
endif
include $(topsrcdir)/config/rules.mk
@@ -170,6 +152,12 @@ 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 \
@@ -182,7 +170,8 @@ JSJAVA_CFLAGS = -I$(topsrcdir)/sun-java/md-include \
-I$(topsrcdir)/sun-java/include \
$(JSJAVA_STUBHEADERS)
# LIBNSPR abstracts nspr version, etc. nicely.
# LIBNSPR includes unneeded libmsgc21.a, but abstracts nspr version,
# etc. nicely.
LDFLAGS = $(LIBNSPR) -lm
ifeq ($(OS_ARCH), OSF1)
@@ -195,30 +184,6 @@ 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
@@ -237,22 +202,8 @@ $(OBJDIR)/js$(BIN_SUFFIX): $(OBJDIR)/js.o $(LIBRARY)
$(LINK_EXE) -OUT:$@ $(OBJDIR)/js.o $(LIBRARIES) $(EXTRA_LIBS)
endif
# 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
# hardwire dependencies on jsopcode.def
jsopcode.h jsopcode.c: jsopcode.def
# this section was put in the merged by danda into the
# JAVA_*_MERGE section and normally would have
@@ -266,3 +217,25 @@ $(OBJDIR)/js.o: js.c
@$(MAKE_OBJDIR)
$(CC) -Fo$@ -c $(CFLAGS) $(JSJAVA_CFLAGS) js.c
endif
refdiff:
@for f in `cat commfiles`; do \
t=/tmp/refdiff.$$$$; \
trap 'rm -f $$t' 0 1 2 15; \
sed -f prconv.sed ../ref/$$f > $$t; \
cmp -s $$t $$f; \
if test $$? -ne 0; then \
echo "=== $$f"; \
diff $$f $$t; \
fi; \
rm -f $$t; \
done
refconv:
@for f in `cat commfiles`; do \
echo "=== $$f"; \
sed -f prconv.sed ../ref/$$f > $$f; \
done
.PHONY: refdiff refconv

View File

@@ -18,40 +18,78 @@
# JSRef GNUmake makefile.
#
DEPTH = .
# Set os+release dependent make variables
OS_ARCH := $(subst /,_,$(shell uname -s))
include config.mk
# 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 =
#NS_USE_NATIVE = 1
ifdef USE_MSVC
OTHER_LIBS += fdlibm/$(OBJDIR)/fdlibm.lib
include config/$(OS_CONFIG).mk
ifdef BUILD_OPT
OPTIMIZER += -O
DEFINES += -UDEBUG -DNDEBUG -UDEBUG_$(shell whoami)
OBJDIR_TAG = _OPT
else
OTHER_LIBS += -Lfdlibm/$(OBJDIR) -lfdm
ifdef USE_MSVC
OPTIMIZER = -Zi
else
OPTIMIZER = -g
endif
DEFINES += -DDEBUG -DDEBUG_$(shell whoami)
OBJDIR_TAG = _DBG
endif
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
#DEFINES += -DJS_THREADSAFE
ifdef JS_NO_THIN_LOCKS
DEFINES += -DJS_USE_ONLY_NSPR_LOCKS
endif
ifdef JS_HAS_FILE_OBJECT
DEFINES += -DJS_HAS_FILE_OBJECT
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)
#
# 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)
@@ -59,7 +97,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 JS_PERLCONNECT
ifdef PERLCONNECT
DEFINES += -DPERLCONNECT
PERLCFLAGS := $(shell perl -MExtUtils::Embed -e ccopts)
@@ -88,7 +126,6 @@ JS_HFILES = \
jsfun.h \
jsgc.h \
jsinterp.h \
jslibmath.h \
jslock.h \
jsmath.h \
jsnum.h \
@@ -100,7 +137,11 @@ JS_HFILES = \
jsdtoa.h \
jshash.h \
jslong.h \
jsmacos.h \
jsosdep.h \
jspcos.h \
jsprintf.h \
jstime.h \
jstypes.h \
jsprvtd.h \
jspubtd.h \
@@ -121,28 +162,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 \
@@ -154,74 +195,106 @@ JS_CFILES = \
prmjtime.c \
$(NULL)
PREDIRS += fdlibm
ifdef JS_LIVECONNECT
DIRS += liveconnect
endif
ifdef JS_PERLCONNECT
ifdef 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
LIBRARY = $(OBJDIR)/js32.lib
SHARED_LIBRARY = $(OBJDIR)/js32.dll
PROGRAM = $(OBJDIR)/js.exe
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
else
LIBRARY = $(OBJDIR)/libjs.a
SHARED_LIBRARY = $(OBJDIR)/libjs.so
PROGRAM = $(OBJDIR)/js
endif
ifdef USE_MSVC
FDLIBM_LIBRARY = fdlibm.lib
TARGETS = $(LIBRARY) # $(PROGRAM) not supported for MSVC yet
else
FDLIBM_LIBRARY = libfdm.a
TARGETS = $(LIBRARY) $(PROGRAM)
endif
include rules.mk
all: $(TARGETS)
MOZ_DEPTH = ../..
include jsconfig.mk
clean:
rm -rf $(OBJS)
nsinstall-target:
cd ../../config; $(MAKE) OBJDIR=$(OBJDIR) OBJDIR_NAME=$(OBJDIR)
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
ifdef USE_MSVC
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
link.exe -out:"$@" $(EXE_LINK_FLAGS) $^
$(LIBRARY): $(LIB_OBJS)
link.exe $(LIB_LINK_FLAGS) /base:0x61000000 \
/out:"$@" /pdb:"$(OBJDIR)/js32.pdb" /implib:"$(OBJDIR)/js32.lib" $?
else
$(PROGRAM): $(PROG_OBJS) $(LIBRARY)
$(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS)
$(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)
$(PROGRAM).pure: $(PROG_OBJS) $(LIBRARY)
purify $(PUREFLAGS) \
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS)
$(CC) -o $@ $(PURE_OS_CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS)
ifndef PREBUILT_CPUCFG
$(HFILES) $(CFILES): $(OBJDIR)/jsautocfg.h
$(HFILES) $(CFILES): $(OBJDIR)/jscpucfg.h
$(OBJDIR)/jsautocfg.h: $(OBJDIR)/jscpucfg
ifdef PREBUILT_CPUCFG
$(OBJDIR)/jscpucfg.h: jscpucfg.h
cp jscpucfg.h $(OBJDIR)
else
$(OBJDIR)/jscpucfg.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
#
@@ -234,6 +307,10 @@ 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

17
mozilla/js/src/README Normal file
View File

@@ -0,0 +1,17 @@
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

View File

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

View File

@@ -1,12 +0,0 @@
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/*

100
mozilla/js/src/actra.mk Normal file
View File

@@ -0,0 +1,100 @@
#! 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

51
mozilla/js/src/commfiles Normal file
View File

@@ -0,0 +1,51 @@
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

View File

@@ -1,65 +0,0 @@
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

View File

@@ -0,0 +1,37 @@
#
# 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

View File

@@ -0,0 +1,37 @@
#
# 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

View File

@@ -0,0 +1,48 @@
#
# 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

View File

@@ -0,0 +1,48 @@
#
# 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

View File

@@ -0,0 +1,58 @@
#
# 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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,47 @@
#
# 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

View File

@@ -0,0 +1,79 @@
#
# 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 =

View File

@@ -0,0 +1,66 @@
#
# 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

View File

@@ -0,0 +1,67 @@
#
# 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

View File

@@ -0,0 +1,71 @@
#
# 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

View File

@@ -0,0 +1,62 @@
#
# 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

View File

@@ -0,0 +1,46 @@
#
# 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

View File

@@ -0,0 +1,42 @@
#
# 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

30
mozilla/js/src/export.mac Normal file
View File

@@ -0,0 +1,30 @@
# 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

View File

@@ -25,7 +25,13 @@
#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"
@@ -68,21 +74,8 @@
#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>
@@ -168,7 +161,7 @@ Process(JSContext *cx, JSObject *obj, char *filename)
js_InitCodeGenerator(cx, &cg, ts->filename, ts->lineno, ts->principals);
do {
if (ts->flags & TSF_INTERACTIVE)
fprintf(gOutFile, "js> ");
printf("js> ");
ok = js_CompileTokenStream(cx, obj, ts, &cg);
if (ts->flags & TSF_ERROR) {
ts->flags &= ~TSF_ERROR;
@@ -177,51 +170,50 @@ Process(JSContext *cx, JSObject *obj, char *filename)
}
} while (ok && !(ts->flags & TSF_EOF) && CG_OFFSET(&cg) == 0);
if (ok) {
/* Clear any pending exception from previous failed compiles. */
/*
* Clear any pending exception, either from previous failed
* compiles, or from the last round of execution.
*/
JS_ClearPendingException(cx);
script = js_NewScriptFromCG(cx, &cg, NULL);
if (script) {
JSErrorReporter older;
ok = JS_ExecuteScript(cx, obj, script, &result);
if (ok &&
if (JS_ExecuteScript(cx, obj, script, &result) &&
(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)
fprintf(gOutFile, "%s\n", JS_GetStringBytes(str));
else
ok = JS_FALSE;
printf("%s\n", JS_GetStringBytes(str));
}
#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));
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);
/*
* 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 */
/* XXX non-i18nized strings... */
if (str) {
fprintf(stderr, "Uncaught JavaScript exception:\n%s\n",
JS_GetStringBytes(str));
} else {
fprintf(stderr, "Uncaught JavaScript exception\n");
}
}
JS_DestroyScript(cx, script);
}
}
cg.firstLine = ts->lineno;
js_FinishCodeGenerator(cx, &cg);
js_ResetCodeGenerator(cx, &cg);
RESET_TOKENBUF(ts);
} while (!(ts->flags & TSF_EOF));
@@ -235,8 +227,8 @@ out:
static int
usage(void)
{
fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
fprintf(gErrFile, "usage: js [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n");
fprintf(stderr, "%s\n", JS_GetImplementationVersion());
fprintf(stderr, "usage: js [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n");
return 2;
}
@@ -249,7 +241,6 @@ 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] == '-') {
@@ -274,12 +265,6 @@ 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:
@@ -287,7 +272,6 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
}
} else {
filename = argv[i++];
isInteractive = JS_FALSE;
break;
}
}
@@ -315,8 +299,7 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc)
OBJECT_TO_JSVAL(argsObj), NULL, NULL, 0))
return 1;
if (filename || isInteractive)
Process(cx, obj, filename);
Process(cx, obj, filename);
return 0;
}
@@ -331,9 +314,6 @@ 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);
@@ -349,7 +329,6 @@ 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]);
@@ -358,19 +337,14 @@ 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)
ok = JS_FALSE;
else {
ok = JS_ExecuteScript(cx, obj, script, &result);
JS_DestroyScript(cx, script);
}
JS_SetErrorReporter(cx, older);
continue;
ok = JS_ExecuteScript(cx, obj, script, &result);
JS_DestroyScript(cx, script);
if (!ok)
return JS_FALSE;
}
return JS_TRUE;
}
@@ -384,11 +358,11 @@ Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
fprintf(gOutFile, "%s%s", i ? " " : "", JS_GetStringBytes(str));
printf("%s%s", i ? " " : "", JS_GetStringBytes(str));
n++;
}
n++;
if (n)
fputc('\n', gOutFile);
putchar('\n');
return JS_TRUE;
}
@@ -422,7 +396,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(gErrFile, "gc: can't open %s: %s\n", strerror(errno));
fprintf(stderr, "gc: can't open %s: %s\n", strerror(errno));
return JS_FALSE;
}
js_DumpGCHeap = file;
@@ -436,7 +410,7 @@ GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
fclose(js_DumpGCHeap);
js_DumpGCHeap = NULL;
#endif
fprintf(gOutFile, "before %lu, after %lu, break %08lx\n",
printf("before %lu, after %lu, break %08lx\n",
(unsigned long)preBytes, (unsigned long)rt->gcBytes,
#ifdef XP_UNIX
(unsigned long)sbrk(0)
@@ -581,27 +555,27 @@ SrcNotes(JSContext *cx, JSFunction *fun )
notes = fun->script->notes;
if (notes) {
fprintf(gOutFile, "\nSource notes:\n");
printf("\nSource notes:\n");
offset = 0;
for (sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
delta = SN_DELTA(sn);
offset += delta;
fprintf(gOutFile, "%3u: %5u [%4u] %-8s",
printf("%3u: %5u [%4u] %-8s",
sn - notes, offset, delta, js_SrcNoteName[SN_TYPE(sn)]);
type = SN_TYPE(sn);
switch (type) {
case SRC_SETLINE:
fprintf(gOutFile, " lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0));
printf(" lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0));
break;
case SRC_FOR:
fprintf(gOutFile, " cond %u update %u tail %u",
printf(" 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:
fprintf(gOutFile, " offset %u", (uintN) js_GetSrcNoteOffset(sn, 0));
printf(" offset %u", (uintN) js_GetSrcNoteOffset(sn, 0));
break;
case SRC_LABEL:
case SRC_LABELBRACE:
@@ -610,22 +584,22 @@ SrcNotes(JSContext *cx, JSFunction *fun )
case SRC_FUNCDEF:
atomIndex = (jsatomid) js_GetSrcNoteOffset(sn, 0);
atom = js_GetAtom(cx, &fun->script->atomMap, atomIndex);
fprintf(gOutFile, " atom %u (%s)", (uintN)atomIndex, ATOM_BYTES(atom));
printf(" atom %u (%s)", (uintN)atomIndex, ATOM_BYTES(atom));
break;
case SRC_SWITCH:
fprintf(gOutFile, " length %u", (uintN) js_GetSrcNoteOffset(sn, 0));
printf(" length %u", (uintN) js_GetSrcNoteOffset(sn, 0));
caseOff = (uintN) js_GetSrcNoteOffset(sn, 1);
if (caseOff)
fprintf(gOutFile, " first case offset %u", caseOff);
printf(" first case offset %u", caseOff);
break;
case SRC_CATCH:
delta = (uintN) js_GetSrcNoteOffset(sn, 0);
if (delta)
fprintf(gOutFile, " guard size %u", delta);
printf(" guard size %u", delta);
break;
default:;
}
fputc('\n', gOutFile);
putchar('\n');
}
}
}
@@ -653,9 +627,9 @@ TryNotes(JSContext *cx, JSFunction *fun)
if (!tn)
return JS_TRUE;
fprintf(gOutFile, "\nException table:\nstart\tend\tcatch\n");
printf("\nException table:\nstart\tend\tcatch\n");
while (tn->start && tn->catchStart) {
fprintf(gOutFile, " %d\t%d\t%d\n",
printf(" %d\t%d\t%d\n",
tn->start, tn->length, tn->catchStart);
tn++;
}
@@ -734,11 +708,11 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
if (line2 < line1) {
if (bupline != line2) {
bupline = line2;
fprintf(gOutFile, "%s %3u: BACKUP\n", sep, line2);
printf("%s %3u: BACKUP\n", sep, line2);
}
} else {
if (bupline && line1 == line2)
fprintf(gOutFile, "%s %3u: RESTORE\n", sep, line2);
printf("%s %3u: RESTORE\n", sep, line2);
bupline = 0;
while (line1 < line2) {
if (!fgets(linebuf, LINE_BUF_LEN, file)) {
@@ -748,7 +722,7 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
goto bail;
}
line1++;
fprintf(gOutFile, "%s %3u: %s", sep, line1, linebuf);
printf("%s %3u: %s", sep, line1, linebuf);
}
}
@@ -790,7 +764,7 @@ Tracing(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
str = JS_ValueToString(cx, argv[0]);
if (!str)
return JS_FALSE;
fprintf(gErrFile, "tracing: illegal argument %s\n",
fprintf(stderr, "tracing: illegal argument %s\n",
JS_GetStringBytes(str));
return JS_TRUE;
}
@@ -853,8 +827,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, gErrFile); }
void Datom(JSAtom *atom) { if (atom) DumpAtom(&atom->entry, 0, gErrFile); }
void Dsym(JSSymbol *sym) { if (sym) DumpSymbol(&sym->entry, 0, stderr); }
void Datom(JSAtom *atom) { if (atom) DumpAtom(&atom->entry, 0, stderr); }
static JSBool
DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
@@ -877,7 +851,7 @@ DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JS_DumpArenaStats(stdout);
#endif
} else if (strcmp(bytes, "atom") == 0) {
fprintf(gOutFile, "\natom table contents:\n");
printf("\natom table contents:\n");
JS_HashTableDump(cx->runtime->atomState.table, DumpAtom, stdout);
} else if (strcmp(bytes, "global") == 0) {
DumpScope(cx, cx->globalObject, DumpSymbol, stdout);
@@ -893,7 +867,7 @@ DumpStats(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_FALSE;
}
if (!prop || !JSVAL_IS_OBJECT(value)) {
fprintf(gErrFile, "js: invalid stats argument %s\n",
fprintf(stderr, "js: invalid stats argument %s\n",
bytes);
continue;
}
@@ -964,8 +938,8 @@ ConvertArgs(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
&v)) {
return JS_FALSE;
}
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",
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",
d, I, s, JS_GetStringBytes(str),
JS_GetStringBytes(JS_ValueToString(cx, OBJECT_TO_JSVAL(obj))),
JS_GetStringBytes(JS_DecompileFunction(cx, fun, 4)),
@@ -974,13 +948,6 @@ 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},
@@ -1005,7 +972,6 @@ static JSFunctionSpec shell_functions[] = {
#ifdef TEST_CVTARGS
{"cvtargs", ConvertArgs, 0, 0, 12},
#endif
{"build", BuildDate, 0},
{0}
};
@@ -1035,21 +1001,20 @@ 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)
{
fprintf(gOutFile, "%-9s %-22s %s\n", "Command", "Usage", "Description");
fprintf(gOutFile, "%-9s %-22s %s\n", "=======", "=====", "===========");
printf("%-9s %-22s %s\n", "Command", "Usage", "Description");
printf("%-9s %-22s %s\n", "=======", "=====", "===========");
}
static void
ShowHelpForCommand(uintN n)
{
fprintf(gOutFile, "%-9.9s %s\n", shell_functions[n].name, shell_help_messages[n]);
printf("%-9.9s %s\n", shell_functions[n].name, shell_help_messages[n]);
}
static JSBool
@@ -1062,7 +1027,7 @@ Help(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSString *str;
const char *bytes;
fprintf(gOutFile, "%s\n", JS_GetImplementationVersion());
printf("%s\n", JS_GetImplementationVersion());
if (argc == 0) {
ShowHelpHeader();
for (i = 0; shell_functions[i].name; i++)
@@ -1098,7 +1063,7 @@ Help(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
str = JS_ValueToString(cx, argv[i]);
if (!str)
return JS_FALSE;
fprintf(gErrFile, "Sorry, no help for %s\n",
fprintf(stderr, "Sorry, no help for %s\n",
JS_GetStringBytes(str));
}
}
@@ -1131,6 +1096,9 @@ 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,
@@ -1153,8 +1121,26 @@ SendSourceToJSDebugger(const char *filename, uintN lineno,
}
}
if (jsdsrc) {
jsdsrc = JSD_AppendUCSourceText(jsdc,jsdsrc, str, length,
JSD_SOURCE_PARTIAL);
/* 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;
}
}
}
*listenerTSData = jsdsrc;
}
@@ -1166,9 +1152,9 @@ static JSBool
its_addProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
if (its_noisy) {
fprintf(gOutFile, "adding its property %s,",
printf("adding its property %s,",
JS_GetStringBytes(JS_ValueToString(cx, id)));
fprintf(gOutFile, " initial value %s\n",
printf(" initial value %s\n",
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
}
return JS_TRUE;
@@ -1178,9 +1164,9 @@ static JSBool
its_delProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
if (its_noisy) {
fprintf(gOutFile, "deleting its property %s,",
printf("deleting its property %s,",
JS_GetStringBytes(JS_ValueToString(cx, id)));
fprintf(gOutFile, " current value %s\n",
printf(" current value %s\n",
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
}
return JS_TRUE;
@@ -1190,9 +1176,9 @@ static JSBool
its_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
if (its_noisy) {
fprintf(gOutFile, "getting its property %s,",
printf("getting its property %s,",
JS_GetStringBytes(JS_ValueToString(cx, id)));
fprintf(gOutFile, " current value %s\n",
printf(" current value %s\n",
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
}
return JS_TRUE;
@@ -1202,9 +1188,9 @@ static JSBool
its_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
if (its_noisy) {
fprintf(gOutFile, "setting its property %s,",
printf("setting its property %s,",
JS_GetStringBytes(JS_ValueToString(cx, id)));
fprintf(gOutFile, " new value %s\n",
printf(" new value %s\n",
JS_GetStringBytes(JS_ValueToString(cx, *vp)));
}
if (JSVAL_IS_STRING(id) &&
@@ -1218,7 +1204,7 @@ static JSBool
its_enumerate(JSContext *cx, JSObject *obj)
{
if (its_noisy)
fprintf(gOutFile, "enumerate its properties\n");
printf("enumerate its properties\n");
return JS_TRUE;
}
@@ -1226,7 +1212,7 @@ static JSBool
its_resolve(JSContext *cx, JSObject *obj, jsval id)
{
if (its_noisy) {
fprintf(gOutFile, "resolving its property %s\n",
printf("resolving its property %s\n",
JS_GetStringBytes(JS_ValueToString(cx, id)));
}
return JS_TRUE;
@@ -1236,7 +1222,7 @@ static JSBool
its_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
if (its_noisy)
fprintf(gOutFile, "converting it to %s type\n", JS_GetTypeName(cx, type));
printf("converting it to %s type\n", JS_GetTypeName(cx, type));
return JS_TRUE;
}
@@ -1244,7 +1230,7 @@ static void
its_finalize(JSContext *cx, JSObject *obj)
{
if (its_noisy)
fprintf(gOutFile, "finalizing it\n");
printf("finalizing it\n");
}
static JSClass its_class = {
@@ -1274,22 +1260,6 @@ 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)
{
@@ -1297,13 +1267,19 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
char *prefix = NULL, *tmp;
if (!report) {
fprintf(gErrFile, "%s\n", message);
fprintf(stderr, "%s\n", message);
return;
}
/* Conditionally ignore reported warnings. */
if ((JSREPORT_IS_WARNING(report->flags) && !reportWarnings))
/*
* 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)) {
return;
}
if (report->filename)
prefix = JS_smprintf("%s:", report->filename);
@@ -1319,35 +1295,33 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
}
/* embedded newlines -- argh! */
while ((tmp = strchr(message, '\n')) != 0) {
while ((tmp = strchr(message, '\n'))) {
tmp++;
if (prefix) fputs(prefix, gErrFile);
fwrite(message, 1, tmp - message, gErrFile);
if (prefix) fputs(prefix, stderr);
fwrite(message, 1, tmp - message, stderr);
message = tmp;
}
/* If there were no filename or lineno, the prefix might be empty */
if (prefix)
fputs(prefix, gErrFile);
fputs(message, gErrFile);
if (prefix) fputs(prefix, stderr);
fputs(message, stderr);
if (!report->linebuf) {
fputc('\n', gErrFile);
putc('\n', stderr);
goto out;
}
fprintf(gErrFile, ":\n%s%s\n%s", prefix, report->linebuf, prefix);
fprintf(stderr, ":\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++) {
fputc('.', gErrFile);
}
for (k = (j + 8) & ~7; j < k; j++)
putc('.', stderr);
continue;
}
fputc('.', gErrFile);
putc('.', stderr);
j++;
}
fputs("^\n", gErrFile);
fputs("^\n", stderr);
out:
JS_free(cx, prefix);
}
@@ -1480,44 +1454,10 @@ 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--;
@@ -1598,10 +1538,6 @@ 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();

184
mozilla/js/src/js.dsp Normal file
View File

@@ -0,0 +1,184 @@
# 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

56
mozilla/js/src/js.dsw Normal file
View File

@@ -0,0 +1,56 @@
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.

View File

@@ -192,15 +192,3 @@ 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}")

130
mozilla/js/src/js11640.def Normal file
View File

@@ -0,0 +1,130 @@
; 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

137
mozilla/js/src/js1640.def Normal file
View File

@@ -0,0 +1,137 @@
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

60
mozilla/js/src/js1640.rc Normal file
View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////
// 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

318
mozilla/js/src/js32.dsp Normal file
View File

@@ -0,0 +1,318 @@
# 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

View File

@@ -17,25 +17,25 @@
* in the importing module's import address table.
*/
JS_EXPORT_API(JSPropertyOp)
IMPLEMENT(JSPropertyOp)
js_GetArgumentAddress()
{
return ((void *)js_GetArgument);
}
JS_EXPORT_API(JSPropertyOp)
IMPLEMENT(JSPropertyOp)
js_SetArgumentAddress()
{
return ((void *)js_SetArgument);
}
JS_EXPORT_API(JSPropertyOp)
IMPLEMENT(JSPropertyOp)
js_GetLocalVariableAddress()
{
return ((void *)js_GetLocalVariable);
}
JS_EXPORT_API(JSPropertyOp)
IMPLEMENT(JSPropertyOp)
js_SetLocalVariableAddress()
{
return ((void *)js_SetLocalVariable);

View File

@@ -5,16 +5,16 @@
#ifndef jsaddr_h___
#define jsaddr_h___
JS_EXTERN_API(JSPropertyOp)
EXTERN(JSPropertyOp)
js_GetArgumentAddress();
JS_EXTERN_API(JSPropertyOp)
EXTERN(JSPropertyOp)
js_SetArgumentAddress();
JS_EXTERN_API(JSPropertyOp)
EXTERN(JSPropertyOp)
js_GetLocalVariableAddress();
JS_EXTERN_API(JSPropertyOp)
EXTERN(JSPropertyOp)
js_SetLocalVariableAddress();
#endif /* jsaddr_h___ */

View File

@@ -25,7 +25,14 @@
#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"
@@ -53,10 +60,6 @@
#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
@@ -500,7 +503,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);
@@ -609,9 +612,6 @@ 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.4 release 1 1998 10 31";
return "JavaScript-C 1.3 1998 06 30";
}
@@ -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, obj_proto) &&
js_InitArgsCallClosureClasses(cx, obj, array_proto) &&
js_InitBooleanClass(cx, obj) &&
js_InitMathClass(cx, obj) &&
js_InitNumberClass(cx, obj) &&
@@ -701,9 +701,6 @@ 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);
}
@@ -720,7 +717,7 @@ JS_malloc(JSContext *cx, size_t nbytes)
{
void *p;
#if defined(XP_OS2) || defined(XP_MAC) || defined(AIX) || defined(OSF1)
#if defined(XP_OS2) || defined(XP_MAC) || defined(AIX)
if (nbytes == 0) /*DSR072897 - Windows allows this, OS/2 & Mac don't*/
nbytes = 1;
#endif
@@ -799,14 +796,20 @@ 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;
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
js_named_root_dumper(JSHashEntry *he, intN i, void *arg)
{
NamedRootDumpArgs *args = arg;
@@ -951,7 +954,8 @@ JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
if (type == JSTYPE_STRING)
return JS_TRUE;
#endif
return js_TryValueOf(cx, obj, type, vp);
js_TryValueOf(cx, obj, type, vp);
return JS_TRUE;
}
JS_PUBLIC_API(void)
@@ -995,13 +999,6 @@ 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,
@@ -1879,10 +1876,8 @@ JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent)
JSObject *newfunobj;
CHECK_REQUEST(cx);
if (OBJ_GET_CLASS(cx, funobj) != &js_FunctionClass) {
/* Indicate we cannot clone this object */
return funobj;
}
if (OBJ_GET_CLASS(cx, funobj) != &js_FunctionClass)
return NULL;
fun = JS_GetPrivate(cx, funobj);
newfunobj = js_NewObject(cx, &js_FunctionClass, funobj, parent);
@@ -1959,14 +1954,15 @@ CompileTokenStream(JSContext *cx, JSObject *obj, JSTokenStream *ts,
goto out;
}
script = js_NewScriptFromCG(cx, &cg, NULL);
out:
if (!script)
goto out;
if (!js_CloseTokenStream(cx, ts)) {
if (script)
js_DestroyScript(cx, script);
js_DestroyScript(cx, script);
script = NULL;
}
out:
cg.tempMark = tempMark;
js_FinishCodeGenerator(cx, &cg);
js_ResetCodeGenerator(cx, &cg);
return script;
}
@@ -2228,32 +2224,15 @@ 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);
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;
return JS_DecompileScript(cx, fun->script, JS_GetFunctionName(fun), indent);
}
JS_PUBLIC_API(JSBool)
JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval)
{
CHECK_REQUEST(cx);
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;
return js_Execute(cx, obj, script, NULL, NULL, JS_FALSE, rval);
}
JS_PUBLIC_API(JSBool)
@@ -2321,10 +2300,6 @@ 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;
}
@@ -2334,14 +2309,8 @@ JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc,
jsval *argv, jsval *rval)
{
CHECK_REQUEST(cx);
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;
return js_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(fun->object),
argc, argv, rval);
}
JS_PUBLIC_API(JSBool)
@@ -2353,13 +2322,7 @@ JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
CHECK_REQUEST(cx);
if (!JS_GetProperty(cx, obj, name, &fval))
return JS_FALSE;
if (!js_CallFunctionValue(cx, obj, fval, argc, argv, rval)) {
#if JS_HAS_EXCEPTIONS
js_ReportUncaughtException(cx);
#endif
return JS_FALSE;
}
return JS_TRUE;
return js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
}
JS_PUBLIC_API(JSBool)
@@ -2367,13 +2330,7 @@ JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc,
jsval *argv, jsval *rval)
{
CHECK_REQUEST(cx);
if (!js_CallFunctionValue(cx, obj, fval, argc, argv, rval)) {
#if JS_HAS_EXCEPTIONS
js_ReportUncaughtException(cx);
#endif
return JS_FALSE;
}
return JS_TRUE;
return js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
}
JS_PUBLIC_API(JSBranchCallback)
@@ -2563,24 +2520,11 @@ JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
CHECK_REQUEST(cx);
va_start(ap, errorNumber);
js_ReportErrorNumberVA(cx, JSREPORT_ERROR, errorCallback, userRef,
errorNumber, JS_TRUE, ap);
errorNumber, ap);
va_end(ap);
}
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)
IMPLEMENT(void)
JS_ReportWarning(JSContext *cx, const char *format, ...)
{
va_list ap;
@@ -2730,60 +2674,6 @@ 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)
@@ -2810,7 +2700,8 @@ JS_ClearContextThread(JSContext *cx)
/************************************************************************/
JS_FRIEND_API(JSBool)
#ifdef NETSCAPE_INTERNAL
JS_PUBLIC_API(JSBool)
JS_IsAssigning(JSContext *cx)
{
JSStackFrame *fp;
@@ -2820,6 +2711,7 @@ JS_IsAssigning(JSContext *cx)
return JS_FALSE;
return (js_CodeSpec[*pc].format & JOF_SET) != 0;
}
#endif
/************************************************************************/

View File

@@ -269,10 +269,10 @@ JS_NewContext(JSRuntime *rt, size_t stacksize);
extern JS_PUBLIC_API(void)
JS_DestroyContext(JSContext *cx);
JS_EXTERN_API(void*)
EXTERN(void*)
JS_GetContextPrivate(JSContext *cx);
JS_EXTERN_API(void)
EXTERN(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
extern JS_PUBLIC_API(JSClass *)
JS_PUBLIC_API(JSClass *)
JS_GetClass(JSObject *obj);
#endif
@@ -928,23 +928,16 @@ extern JS_PUBLIC_API(void)
JS_ReportError(JSContext *cx, const char *format, ...);
/*
* Use an errorNumber to retrieve the format string, args are char *
* As above, but use an errorNumber for the format string
*/
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 JS_PUBLIC_API(void)
EXTERN(void)
JS_ReportWarning(JSContext *cx, const char *format, ...);
/*
@@ -962,8 +955,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 */
const jschar *ucmessage; /* the (default) error message */
const jschar **messageArgs; /* arguments for the error message */
JSString *ucmessage; /* the (default) error message */
JSString **messageArgs; /* arguments for the error message */
};
/*
@@ -977,7 +970,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_IsExceptionPending if
* Exception-aware hosts should also check for JS_IsPendingException if
* JS_ExecuteScript returns failure, and signal or propagate the exception, as
* appropriate.
*/
@@ -1028,27 +1021,6 @@ 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
@@ -1072,15 +1044,14 @@ 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_FRIEND_API(JSBool)
extern JS_PUBLIC_API(JSBool)
JS_IsAssigning(JSContext *cx);
#endif
JS_END_EXTERN_C

View File

@@ -26,7 +26,14 @@
#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
@@ -45,7 +52,7 @@ static JSArenaStats *arena_stats_list;
#define JS_ARENA_DEFAULT_ALIGN sizeof(double)
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size, JSUint32 align)
{
if (align == 0)
@@ -64,7 +71,7 @@ JS_InitArenaPool(JSArenaPool *pool, const char *name, JSUint32 size, JSUint32 al
#endif
}
JS_EXPORT_API(void *)
IMPLEMENT(void *)
JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb)
{
JSArena **ap, *a, *b;
@@ -120,7 +127,7 @@ JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb)
return p;
}
JS_EXPORT_API(void *)
IMPLEMENT(void *)
JS_ArenaGrow(JSArenaPool *pool, void *p, JSUint32 size, JSUint32 incr)
{
void *newp;
@@ -182,7 +189,7 @@ FreeArenaList(JSArenaPool *pool, JSArena *head, JSBool reallyFree)
pool->current = head;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaRelease(JSArenaPool *pool, char *mark)
{
JSArena *a;
@@ -196,14 +203,14 @@ JS_ArenaRelease(JSArenaPool *pool, char *mark)
}
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_FreeArenaPool(JSArenaPool *pool)
{
FreeArenaList(pool, &pool->first, JS_FALSE);
COUNT(pool, ndeallocs);
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_FinishArenaPool(JSArenaPool *pool)
{
FreeArenaList(pool, &pool->first, JS_TRUE);
@@ -224,7 +231,7 @@ JS_FinishArenaPool(JSArenaPool *pool)
#endif
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_CompactArenaPool(JSArenaPool *pool)
{
#if 0 /* XP_MAC */
@@ -238,7 +245,7 @@ JS_CompactArenaPool(JSArenaPool *pool)
#endif
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaFinish()
{
JSArena *a, *next;
@@ -260,7 +267,7 @@ JS_ArenaFinish()
}
#ifdef JS_ARENAMETER
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb)
{
pool->stats.nallocs++;
@@ -270,13 +277,13 @@ JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb)
pool->stats.variance += nb * nb;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaCountInplaceGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
{
pool->stats.ninplace++;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
{
pool->stats.ngrows++;
@@ -288,13 +295,13 @@ JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr)
pool->stats.variance += size * size;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaCountRelease(JSArenaPool *pool, char *mark)
{
pool->stats.nreleases++;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_ArenaCountRetract(JSArenaPool *pool, char *mark)
{
pool->stats.nfastrels++;
@@ -303,7 +310,7 @@ JS_ArenaCountRetract(JSArenaPool *pool, char *mark)
#include <math.h>
#include <stdio.h>
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_DumpArenaStats(FILE *fp)
{
JSArenaStats *stats;

View File

@@ -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.
*/
JS_EXTERN_API(void)
EXTERN(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.
*/
JS_EXTERN_API(void)
EXTERN(void)
JS_FreeArenaPool(JSArenaPool *pool);
/*
* Free the arenas in pool and finish using it altogether.
*/
JS_EXTERN_API(void)
EXTERN(void)
JS_FinishArenaPool(JSArenaPool *pool);
/*
* Compact all of the arenas in a pool so that no space is wasted.
*/
JS_EXTERN_API(void)
EXTERN(void)
JS_CompactArenaPool(JSArenaPool *pool);
/*
* Finish using arenas, freeing all memory associated with them.
*/
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaFinish(void);
/*
* Friend functions used by the JS_ARENA_*() macros.
*/
JS_EXTERN_API(void *)
EXTERN(void *)
JS_ArenaAllocate(JSArenaPool *pool, JSUint32 nb);
JS_EXTERN_API(void *)
EXTERN(void *)
JS_ArenaGrow(JSArenaPool *pool, void *p, JSUint32 size, JSUint32 incr);
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaRelease(JSArenaPool *pool, char *mark);
#ifdef JS_ARENAMETER
#include <stdio.h>
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaCountAllocation(JSArenaPool *pool, JSUint32 nb);
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaCountInplaceGrowth(JSArenaPool *pool, JSUint32 size, JSUint32 incr);
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaCountGrowth(JSArenaPool *pool, JSUint32 size, JSUint32incr);
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaCountRelease(JSArenaPool *pool, char *mark);
JS_EXTERN_API(void)
EXTERN(void)
JS_ArenaCountRetract(JSArenaPool *pool, char *mark);
JS_EXTERN_API(void)
EXTERN(void)
JS_DumpArenaStats(FILE *fp);
#else /* !JS_ARENAMETER */

View File

@@ -23,6 +23,7 @@
#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"
@@ -78,7 +79,7 @@ IdIsIndex(jsid id, jsuint *indexp)
if (JS7_ISDEC(*cp) && str->length < sizeof(MAXSTR)) {
jsuint index = JS7_UNDEC(*cp++);
jsuint oldIndex = 0;
jsint c = 0;
jsint c;
if (index != 0) {
while (JS7_ISDEC(*cp)) {
oldIndex = index;
@@ -297,7 +298,8 @@ array_convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
return JS_TRUE;
}
}
return js_TryValueOf(cx, obj, type, vp);
js_TryValueOf(cx, obj, type, vp);
return JS_TRUE;
}
JSClass js_ArrayClass = {
@@ -1015,20 +1017,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;
}
}
}

View File

@@ -23,8 +23,15 @@
#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"
@@ -81,7 +88,7 @@ char js_valueOf_str[] = "valueOf";
#define HASH_DOUBLE(dp) ((JSHashNumber)(((uint32*)(dp))[0] ^ ((uint32*)(dp))[1]))
#define HASH_BOOLEAN(b) ((JSHashNumber)(b))
JS_STATIC_DLL_CALLBACK(JSHashNumber)
STATIC_DLL_CALLBACK(JSHashNumber)
js_hash_atom_key(const void *key)
{
jsval v;
@@ -104,7 +111,7 @@ js_hash_atom_key(const void *key)
return (JSHashNumber)v;
}
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
js_compare_atom_keys(const void *k1, const void *k2)
{
jsval v1, v2;
@@ -127,25 +134,25 @@ js_compare_atom_keys(const void *k1, const void *k2)
return v1 == v2;
}
JS_STATIC_DLL_CALLBACK(int)
STATIC_DLL_CALLBACK(int)
js_compare_stub(const void *v1, const void *v2)
{
return 1;
}
JS_STATIC_DLL_CALLBACK(void *)
STATIC_DLL_CALLBACK(void *)
js_alloc_atom_space(void *priv, size_t size)
{
return malloc(size);
}
JS_STATIC_DLL_CALLBACK(void)
STATIC_DLL_CALLBACK(void)
js_free_atom_space(void *priv, void *item)
{
free(item);
}
JS_STATIC_DLL_CALLBACK(JSHashEntry *)
STATIC_DLL_CALLBACK(JSHashEntry *)
js_alloc_atom(void *priv, const void *key)
{
JSAtomState *state = priv;
@@ -165,7 +172,7 @@ js_alloc_atom(void *priv, const void *key)
return &atom->entry;
}
JS_STATIC_DLL_CALLBACK(void)
STATIC_DLL_CALLBACK(void)
js_free_atom(void *priv, JSHashEntry *he, uintN flag)
{
if (flag != HT_FREE_ENTRY)
@@ -238,7 +245,6 @@ 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
@@ -262,7 +268,7 @@ typedef struct MarkArgs {
JSGCThingMarker mark;
} MarkArgs;
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
js_atom_marker(JSHashEntry *he, intN i, void *arg)
{
JSAtom *atom;
@@ -291,7 +297,7 @@ js_MarkAtomState(JSAtomState *state, JSGCThingMarker mark)
JS_HashTableEnumerateEntries(state->table, js_atom_marker, &args);
}
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
js_atom_sweeper(JSHashEntry *he, intN i, void *arg)
{
JSAtom *atom;
@@ -313,7 +319,7 @@ js_SweepAtomState(JSAtomState *state)
JS_HashTableEnumerateEntries(state->table, js_atom_sweeper, NULL);
}
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
js_atom_unpinner(JSHashEntry *he, intN i, void *arg)
{
JSAtom *atom;
@@ -401,13 +407,16 @@ js_AtomizeDouble(JSContext *cx, jsdouble d, uintN flags)
JSHashTable *table;
JSHashEntry *he, **hep;
JSAtom *atom;
#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];
#if JS_ALIGN_OF_DOUBLE == 8
dp = &d;
#else
char alignbuf[16];
dp = (jsdouble *)&alignbuf[8 - ((jsuword)&alignbuf & 7)];
*dp = d;
#endif
keyHash = HASH_DOUBLE(dp);
key = DOUBLE_TO_JSVAL(dp);
state = &cx->runtime->atomState;
@@ -510,12 +519,16 @@ js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
jschar *chars;
JSString *str;
JSAtom *atom;
#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];
#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
chars = js_InflateString(cx, bytes, length);
if (!chars)
return NULL;
@@ -531,12 +544,16 @@ JS_FRIEND_API(JSAtom *)
js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN flags)
{
JSString *str;
#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];
#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
str->chars = (jschar *)chars;
str->length = length;
return js_AtomizeString(cx, str, ATOM_TMPSTR | flags);

View File

@@ -23,7 +23,13 @@
*/
#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"
@@ -124,7 +130,6 @@ struct JSAtomState {
JSAtom *toSourceAtom;
JSAtom *toStringAtom;
JSAtom *valueOfAtom;
JSAtom *evalAtom;
#ifdef JS_THREADSAFE
JSThinLock lock;

View File

@@ -37,12 +37,12 @@ typedef unsigned long jsbitmap_t;
/*
** Compute the log of the least power of 2 greater than or equal to n
*/
JS_EXTERN_API(JSIntn) JS_CeilingLog2(JSUint32 i);
EXTERN(JSIntn) JS_CeilingLog2(JSUint32 i);
/*
** Compute the log of the greatest power of 2 less than or equal to n
*/
JS_EXTERN_API(JSIntn) JS_FloorLog2(JSUint32 i);
EXTERN(JSIntn) JS_FloorLog2(JSUint32 i);
/*
** Macro version of JS_CeilingLog2: Compute the log of the least power of

View File

@@ -21,6 +21,7 @@
*/
#include "jsstddef.h"
#include "jstypes.h"
/* Removed by JSIFY: #include "prlog.h" */
#include "jsutil.h" /* Added by JSIFY */
#include "jsapi.h"
#include "jsatom.h"
@@ -169,16 +170,13 @@ 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;
@@ -194,29 +192,20 @@ 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;
}

View File

@@ -21,13 +21,15 @@
#include "jstypes.h"
typedef struct JSCListStr JSCList;
/*
** Circular linked list
*/
typedef struct JSCListStr {
struct JSCListStr *next;
struct JSCListStr *prev;
} JSCList;
struct JSCListStr {
JSCList *next;
JSCList *prev;
};
/*
** Insert element "_e" into the list, before "_l".

View File

@@ -24,7 +24,14 @@
#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"
@@ -78,10 +85,6 @@ js_NewContext(JSRuntime *rt, size_t stacksize)
return NULL;
}
#endif
#if JS_HAS_EXCEPTIONS
cx->throwing = JS_FALSE;
#endif
return cx;
}
@@ -201,8 +204,7 @@ 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,
JSBool charArgs, va_list ap)
char **messagep, JSErrorReport *reportp, va_list ap)
{
const JSErrorFormatString *fmtData;
int i;
@@ -212,35 +214,18 @@ 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 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.
* 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.
*/
reportp->messageArgs
= JS_malloc(cx, sizeof(jschar *) * (argCount + 1));
reportp->messageArgs = malloc(sizeof(char *) * argCount);
if (!reportp->messageArgs)
return JS_FALSE;
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;
for (i = 0; i < argCount; i++)
reportp->messageArgs[i] = (JSString *) va_arg(ap, char *);
}
/*
* Parse the error format, substituting the argument X
@@ -248,22 +233,21 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
*/
if (argCount > 0) {
if (fmtData->format) {
const char *fmt;
const jschar *arg;
jschar *out;
const char *fmt, *arg;
char *out;
int expandedArgs = 0;
int expandedLength
= strlen(fmtData->format)
- (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));
- (3 * argCount); /* exclude the {n} */
for (i = 0; i < argCount; i++) {
expandedLength
+= strlen((char *)reportp->messageArgs[i]);
}
*messagep = out = malloc(expandedLength + 1);
if (!out) {
if (reportp->messageArgs) {
JS_free(cx, (void *)reportp->messageArgs);
free(reportp->messageArgs);
reportp->messageArgs = NULL;
}
return JS_FALSE;
@@ -274,32 +258,33 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
if (isdigit(fmt[1])) {
int d = JS7_UNDEC(fmt[1]);
JS_ASSERT(expandedArgs < argCount);
arg = reportp->messageArgs[d];
js_strncpy(out, arg, argLengths[d]);
out += argLengths[d];
arg = (char *)reportp->messageArgs[d];
strcpy(out, arg);
out += strlen(arg);
fmt += 3;
expandedArgs++;
continue;
}
}
/*
* is this kosher?
*/
*out++ = (unsigned char)(*fmt++);
*out++ = *fmt++;
}
JS_ASSERT(expandedArgs == argCount);
*out = 0;
*messagep = js_DeflateString(cx, reportp->ucmessage,
out - reportp->ucmessage);
*out = '\0';
}
} 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));
}
/*
* 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);
}
/*
* And finally convert the message.
*/
reportp->ucmessage = JS_NewStringCopyZ(cx, *messagep);
}
}
if (*messagep == NULL) {
@@ -307,7 +292,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 *)JS_malloc(cx, nbytes);
*messagep = (char *)malloc(nbytes);
JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);
}
return JS_TRUE;
@@ -315,8 +300,7 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
void
js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
void *userRef, const uintN errorNumber,
JSBool charArgs, va_list ap)
void *userRef, const uintN errorNumber, va_list ap)
{
JSStackFrame *fp;
JSErrorReport report;
@@ -342,7 +326,7 @@ js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
report.errorNumber = errorNumber;
if (!js_ExpandErrorArguments(cx, callback, userRef, errorNumber,
&message, &report, charArgs, ap))
&message, &report, ap))
return;
#if JS_HAS_ERROR_EXCEPTIONS
@@ -351,43 +335,16 @@ 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.
*/
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);
js_ErrorToException(cx, &report, message);
#endif
js_ReportErrorAgain(cx, message, &report);
if (message)
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);
free(message);
if (report.messageArgs)
free(report.messageArgs);
}
JS_FRIEND_API(void)
@@ -403,18 +360,6 @@ 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);
}

View File

@@ -21,11 +21,16 @@
/*
* 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"
@@ -89,12 +94,6 @@ 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;
@@ -206,14 +205,13 @@ 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,
JSBool charArgs, va_list ap);
void *userRef, const uintN errorNumber, va_list ap);
extern JSBool
js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
void *userRef, const uintN errorNumber,
char **message, JSErrorReport *reportp,
JSBool charArgs, va_list ap);
va_list ap);
#endif
/*

View File

@@ -69,8 +69,6 @@
#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
@@ -118,8 +116,6 @@
#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
@@ -167,8 +163,6 @@
#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
@@ -216,8 +210,6 @@
#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
@@ -264,9 +256,7 @@
#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 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_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */
#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */

View File

@@ -1,135 +0,0 @@
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:

View File

@@ -21,13 +21,13 @@
*/
#include <stdio.h>
#ifdef sgi
#if defined(sgi)
#ifndef IRIX
# error "IRIX is not defined"
#endif
#endif
#ifdef __sun
#if defined(__sun)
#if defined(__svr4) || defined(__svr4__)
#ifndef SOLARIS
# error "SOLARIS is not defined"
@@ -39,31 +39,37 @@
#endif
#endif
#ifdef __hpux
#if defined(__hpux)
#ifndef HPUX
# error "HPUX is not defined"
#endif
#endif
#ifdef __osf__
#if defined(__osf__)
#ifndef OSF1
# error "OSF1 is not defined"
#endif
#endif
#ifdef _IBMR2
#if defined(_IBMR2)
#ifndef AIX
# error "AIX is not defined"
#endif
#endif
#ifdef bsdi
#if defined(linux)
#ifndef LINUX
# error "LINUX is not defined"
#endif
#endif
#if defined(bsdi)
#ifndef BSDI
# error "BSDI is not defined"
#endif
#endif
#ifdef M_UNIX
#if defined(M_UNIX)
#ifndef SCO
# error "SCO is not defined"
#endif

View File

@@ -22,6 +22,7 @@
#include "jsosdep.h"
#ifdef XP_MAC
#include "jsmacos.h"
#undef IS_LITTLE_ENDIAN
#define IS_BIG_ENDIAN 1
@@ -65,8 +66,7 @@
#define JS_BYTES_PER_WORD_LOG2 2L
#define JS_BYTES_PER_DWORD_LOG2 3L
#define PR_WORDS_PER_DWORD_LOG2 1L
#elif defined(XP_PC)
#endif /* XP_MAC */
#ifdef _WIN32
#define IS_LITTLE_ENDIAN 1
@@ -160,16 +160,543 @@
#define PR_WORDS_PER_DWORD_LOG2 1L
#endif /* defined(_WINDOWS) && !defined(_WIN32) */
#elif defined(XP_UNIX)
#ifdef XP_UNIX
#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."
#ifdef AIXV3
#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 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 "Must define one of XP_MAC, XP_PC or XP_UNIX"
#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
#endif
#endif /* XP_UNIX */
#endif /* js_cpucfg___ */

View File

@@ -26,6 +26,7 @@
#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"
@@ -305,7 +306,7 @@ static jsdouble LocalTZA;
static jsdouble
DaylightSavingTA(jsdouble t)
{
volatile int64 PR_t;
int64 PR_t;
int64 ms2us;
int64 offset;
jsdouble result;
@@ -1557,7 +1558,7 @@ date_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
if (!date)
return JS_FALSE;
JS_cnvtf(buf, sizeof buf, 20, *date);
PR_cnvtf(buf, sizeof buf, 20, *date);
bytes = JS_smprintf("(new %s(%s))", date_class.name, buf);
if (!bytes) {
JS_ReportOutOfMemory(cx);

View File

@@ -22,6 +22,7 @@
#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"
@@ -269,7 +270,7 @@ js_FindWatchPoint(JSRuntime *rt, JSObject *obj, jsval userid)
return wp->sprop;
}
JSBool JS_DLL_CALLBACK
JSBool DLL_CALLBACK
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JSRuntime *rt;
@@ -837,7 +838,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)
@@ -845,36 +846,14 @@ JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
rt->executeHook = hook;
rt->executeHookData = closure;
return JS_TRUE;
}
}
JS_PUBLIC_API(JSBool)
extern 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;
}

View File

@@ -80,7 +80,7 @@ JS_ClearAllWatchPoints(JSContext *cx);
extern JSScopeProperty *
js_FindWatchPoint(JSRuntime *rt, JSObject *obj, jsval userid);
extern JSBool JS_DLL_CALLBACK
extern JSBool DLL_CALLBACK
js_watch_set(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
#endif
@@ -240,15 +240,6 @@ 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___ */

View File

@@ -23,6 +23,7 @@
#include "jstypes.h"
#include "jsdtoa.h"
#include "jsprf.h"
/* Removed by JSIFY: #include "prlog.h" */
#include "jsutil.h" /* Added by JSIFY */
#ifdef JS_THREADSAFE
@@ -99,7 +100,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 JS_dtoa.
* computation of PR_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
@@ -1198,8 +1199,8 @@ static void InitDtoa(void)
/* nspr2 watcom bug ifdef omitted */
JS_FRIEND_API(double)
JS_strtod(CONST char *s00, char **se)
PUBLIC_API(double)
PR_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;
@@ -1213,7 +1214,6 @@ JS_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
JS_dtoa(double d, int mode, int ndigits,
PR_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,10 +1927,6 @@ JS_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
@@ -2524,8 +2520,8 @@ ret1:
** Also, the ECMA spec says that there should always be a
** '+' or '-' after the 'e' in scientific notation
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
PUBLIC_API(void)
PR_cnvtf(char *buf,int bufsz, int prcsn,double fval)
{
intN decpt,sign,numdigits;
char *num, *nump;
@@ -2539,7 +2535,7 @@ JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
return;
}
/* XXX Why use mode 1? */
if (JS_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz)
if (PR_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz)
== JS_FALSE) {
buf[0] = '\0';
goto done;

View File

@@ -28,7 +28,7 @@
JS_BEGIN_EXTERN_C
/*
* JS_strtod() returns as a double-precision floating-point number
* PR_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.
*/
JS_FRIEND_API(double)
JS_strtod(const char *s00, char **se);
extern PUBLIC_API(double)
PR_strtod(const char *s00, char **se);
/*
* JS_cnvtf()
* PR_cnvtf()
* conversion routines for floating point
* prcsn - number of digits of precision to generate floating
* point value.
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
extern PUBLIC_API(void)
PR_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
JS_END_EXTERN_C

View File

@@ -23,7 +23,14 @@
#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"
@@ -64,7 +71,7 @@ js_InitCodeGenerator(JSContext *cx, JSCodeGenerator *cg,
}
JS_FRIEND_API(void)
js_FinishCodeGenerator(JSContext *cx, JSCodeGenerator *cg)
js_ResetCodeGenerator(JSContext *cx, JSCodeGenerator *cg)
{
JS_ARENA_RELEASE(&cx->codePool, cg->codeMark);
JS_ARENA_RELEASE(&cx->tempPool, cg->tempMark);
@@ -499,44 +506,11 @@ 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;
@@ -551,7 +525,25 @@ 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. */
UPDATE_LINENO_NOTES(cx, cg, pn);
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);
}
}
switch (pn->pn_type) {
case TOK_FUNCTION:
@@ -571,7 +563,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
fun = pn->pn_fun;
if (!js_EmitFunctionBody(cx, &cg2, pn2, fun))
return JS_FALSE;
js_FinishCodeGenerator(cx, &cg2);
js_ResetCodeGenerator(cx, &cg2);
/* Make the function object a literal in the outer script's pool. */
atom = js_AtomizeObject(cx, fun->object, 0);
@@ -755,10 +747,14 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
}
} else {
/* Pre-ECMAv2 switch evals case exprs at compile time. */
if (!js_InitCodeGenerator(cx, &cg2, cg->filename,
pn3->pn_pos.begin.lineno,
cg->principals)) {
return JS_FALSE;
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);
}
cg2.currentLine = pn4->pn_pos.begin.lineno;
if (!js_EmitTree(cx, &cg2, pn4))
@@ -808,7 +804,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JS_ASSERT(!cg2.base);
} else {
if (cg2.base)
js_FinishCodeGenerator(cx, &cg2);
js_ResetCodeGenerator(cx, &cg2);
if (switchop == JSOP_TABLESWITCH) {
tablen = (uint32)(high - low + 1);
if (tablen >= JS_BIT(16) || tablen > 2 * ncases)
@@ -848,7 +844,6 @@ 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;
@@ -905,11 +900,7 @@ 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),
@@ -1226,17 +1217,11 @@ 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) {
if (STMT_IS_LOOP(stmt))
loop = stmt;
while (stmt->type != STMT_LABEL || stmt->label != atom)
stmt = stmt->down;
}
stmt = loop;
} else {
ale = NULL;
while (!STMT_IS_LOOP(stmt))
@@ -1263,8 +1248,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#if JS_HAS_EXCEPTIONS
case TOK_TRY: {
ptrdiff_t start, end;
ptrdiff_t catchStart = -1, finallyCatch = -1, catchjmp = -1;
ptrdiff_t start, end, catchStart, finallyCatch, catchjmp = -1;
JSParseNode *iter = pn;
uint16 depth;
@@ -1360,9 +1344,6 @@ 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);
@@ -1372,7 +1353,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
js_Emit1(cx, cg, JSOP_LEAVEWITH) < 0)
return JS_FALSE;
} else {
/* set stack to original depth (see SETSP comment above) */
/* set stack to orig depth (see SETSP comment above) */
EMIT_ATOM_INDEX_OP(JSOP_SETSP, (jsatomid)depth);
}
@@ -1457,6 +1438,7 @@ 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
@@ -1464,7 +1446,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
*/
EMIT_ATOM_INDEX_OP(JSOP_SETSP, (jsatomid)depth);
if (catchjmp != -1 && iter->pn_kid1->pn_expr) {
if (catchjmp != -1) {
CHECK_AND_SET_JUMP_OFFSET_AT(cx, cg, catchjmp);
}
/* last discriminant jumps to rethrow if none match */
@@ -1496,8 +1478,6 @@ 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) ||
@@ -1537,7 +1517,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#endif /* JS_HAS_EXCEPTIONS */
case TOK_VAR:
off = noteIndex = -1;
noteIndex = -1;
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
JS_ASSERT(pn2->pn_type == TOK_NAME);
op = pn2->pn_op;
@@ -1648,7 +1628,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.
*/
off = noteIndex = -1;
noteIndex = -1;
for (pn2 = pn->pn_head; ; pn2 = pn2->pn_next) {
if (!js_EmitTree(cx, cg, pn2))
return JS_FALSE;
@@ -1676,7 +1656,6 @@ 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) {
@@ -1956,15 +1935,6 @@ 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;
@@ -2504,7 +2474,6 @@ 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;

View File

@@ -115,12 +115,9 @@ 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_FinishCodeGenerator(JSContext *cx, JSCodeGenerator *cg);
js_ResetCodeGenerator(JSContext *cx, JSCodeGenerator *cg);
/*
* Emit one bytecode.
@@ -298,7 +295,7 @@ typedef enum JSSrcNoteType {
extern JS_FRIEND_DATA(const char *) js_SrcNoteName[];
extern JS_FRIEND_DATA(uint8) js_SrcNoteArity[];
extern JS_FRIEND_API(uintN) js_SrcNoteLength(jssrcnote *sn);
extern JS_FRIEND_DATA(uintN) js_SrcNoteLength(jssrcnote *sn);
#define SN_LENGTH(sn) ((js_SrcNoteArity[SN_TYPE(sn)] == 0) ? 1 \
: js_SrcNoteLength(sn))
@@ -345,7 +342,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_FinishCodeGenerator.
* js_NewTryNote calls. The storage is freed by js_ResetCodeGenerator.
*/
extern JSBool
js_AllocTryNotes(JSContext *cx, JSCodeGenerator *cg);

View File

@@ -20,60 +20,70 @@
* 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
/* 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
};
JSObject *tlobj;
/*
* A copy of the JSErrorReport originally generated.
* 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.
*/
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)
exn_initPrivate(JSContext *cx, JSErrorReport *report, const char *message)
{
JSExnPrivate *newPrivate;
JSErrorReport *newReport;
JSErrorReport * newReport;
char *newMessage;
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 != NULL) {
if (report->filename) {
newReport->filename =
(const char *)JS_malloc(cx, strlen(report->filename)+1);
/* Ack. Const! */
strcpy((char *)newReport->filename, report->filename);
} else {
newReport->filename = NULL;
@@ -91,17 +101,19 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report)
/*
* 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 != NULL) {
len = js_strlen(report->uclinebuf) + 1;
if (report->uclinebuf) {
size_t len = js_strlen(report->uclinebuf)+1;
newReport->uclinebuf =
(const jschar *)JS_malloc(cx, len * sizeof(jschar));
(const jschar *)JS_malloc(cx, len);
js_strncpy(newReport->uclinebuf, report->uclinebuf, len);
newReport->uctokenptr = newReport->uclinebuf + (report->uctokenptr -
report->uclinebuf);
@@ -109,45 +121,18 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report)
#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;
}
@@ -157,65 +142,36 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report)
static void
exn_destroyPrivate(JSContext *cx, JSExnPrivate *privateData)
{
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_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);
JS_free(cx, privateData);
}
/* Destroy associated data... */
static void
exn_finalize(JSContext *cx, JSObject *obj)
{
JSExnPrivate *privateData;
jsval private;
private = OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE);
privateData = (JSExnPrivate *)
JSVAL_TO_PRIVATE(OBJ_GET_SLOT(cx, obj, JSSLOT_PRIVATE));
if (private != JSVAL_NULL) {
privateData = JSVAL_TO_PRIVATE(private);
if (privateData)
exn_destroyPrivate(cx, privateData);
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,
@@ -235,169 +191,160 @@ typedef enum JSExnType {
JSEXN_LIMIT
} JSExnType;
#define FLAGS JSCLASS_HAS_PRIVATE
/* Maybe #define RANDOM_CLASS(name, prototype) 4 here? */
struct JSExnSpec {
int protoIndex;
const char *name;
JSClass theclass;
};
/*
* 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, "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" },
{ 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
} },
{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;
}
/*
* 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));
/* gotta null out that private data */
OBJ_SET_SLOT(cx, obj, JSSLOT_PRIVATE, JSVAL_NULL);
return JS_TRUE;
}
/*
* Convert to string.
* Convert to string. Much of this is taken from js.c.
*
* 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.
* I should rewrite this to use message, line, file etc. from
* javascript-modifiable properties (which might be lazily created
* from the encapsulated error report.)
*/
static JSBool
exn_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSString *str;
JSExnPrivate *privateData;
JSErrorReport *report;
jsval v;
JSString *name, *message, *result;
jschar *chars, *cp;
size_t length;
jsid id;
char *name;
JSClass *theclass;
id = (jsid) cx->runtime->atomState.nameAtom;
if (!OBJ_GET_PROPERTY(cx, obj, id, &v) || !(name = js_ValueToString(cx, v)))
return JS_FALSE;
/* Check needed against incompatible target... */
if (!JS_GetProperty(cx, obj, "message", &v) ||
!(message = 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 (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;
}
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);
} else {
result = name;
str = JS_NewStringCopyZ(cx, "some non-engine-thrown exception");
}
*rval = STRING_TO_JSVAL(result);
if (!str)
return JS_FALSE;
*rval = STRING_TO_JSVAL(str);
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}
};
@@ -405,77 +352,58 @@ static JSFunctionSpec exception_methods[] = {
JSObject *
js_InitExceptionClasses(JSContext *cx, JSObject *obj)
{
int i;
JSObject *protos[JSEXN_LIMIT];
int i;
/* 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;
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);
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);
/* So finalize knows whether to. */
OBJ_SET_SLOT(cx, protos[i], JSSLOT_PRIVATE, JSVAL_NULL);
}
/*
* Add an empty message property. (To Exception.prototype only,
* because this property will be the same for all the exception
* protos.)
* 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.
*/
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;
/* protos[0]->slots[JSSLOT_PROTO] = JSVAL_NULL; */
return protos[0];
}
static JSExnType errorToExceptionNum[] = {
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[] = {
#define MSG_DEF(name, number, count, exception, format) \
exception,
#include "js.msg"
@@ -493,18 +421,16 @@ static struct exnname { char *name; char *exception; } errortoexnname[] = {
#endif /* DEBUG */
JSBool
js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp)
js_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message)
{
JSErrNum errorNumber;
JSObject *errObject, *errProto;
JSObject *errobj;
JSExnType exn;
JSExnPrivate *privateData;
JSString *msgstr;
/* Find the exception index associated with this error. */
JS_ASSERT(reportp);
errorNumber = reportp->errorNumber;
exn = errorToExceptionNum[errorNumber];
exn = errorToException[errorNumber];
JS_ASSERT(exn < JSEXN_LIMIT);
#if defined( DEBUG_mccabe ) && defined ( PRINTNAMES )
@@ -522,26 +448,14 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp)
return JS_FALSE;
/*
* 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.
* 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...
*/
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;
errobj = js_NewObject(cx,
&(exceptions[exn].theclass),
NULL, NULL);
/*
* Construct a new copy of the error report, and store it in the
@@ -549,71 +463,15 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp)
* 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));
/* Set the generated Exception object as the current exception. */
JS_SetPendingException(cx, OBJECT_TO_JSVAL(errObject));
/* XXX report failure? */
privateData = exn_initPrivate(cx, reportp, message);
OBJ_SET_SLOT(cx, errobj, JSSLOT_PRIVATE, PRIVATE_TO_JSVAL(privateData));
/* Flag the error report passed in to indicate an exception was raised. */
JS_SetPendingException(cx, OBJECT_TO_JSVAL(errobj));
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_EXCEPTIONS */

View File

@@ -32,34 +32,15 @@ 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 should probably ignore
* error reports so flagged. Returns JS_TRUE if an associated exception is
* found and set, JS_FALSE otherwise..
* 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.
*/
extern JSBool
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_ErrorToException(JSContext *cx, JSErrorReport *reportp, const char *message);
JS_END_EXTERN_C

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@
#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"
@@ -538,17 +539,18 @@ 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);
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;
}
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) {
slot = (uintN)JSVAL_TO_INT(propid);
if (!js_DefineProperty(cx, obj, symid,
(slot < nslots) ? vp[slot] : JSVAL_VOID,
@@ -1085,10 +1087,7 @@ 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,
@@ -1191,27 +1190,11 @@ fun_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
uint32 indent;
JSString *str;
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;
}
}
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);
obj = JSVAL_TO_OBJECT(fval);
fun = JS_GetPrivate(cx, obj);
if (!fun)
@@ -1240,14 +1223,6 @@ 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);
@@ -1307,13 +1282,6 @@ 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;
@@ -1590,7 +1558,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[(intn)(argc-1)] = STRING_TO_JSVAL(str);
argv[argc-1] = STRING_TO_JSVAL(str);
}
if ((fp = cx->fp) != NULL && (fp = fp->down) != NULL && fp->script) {
@@ -1662,10 +1630,10 @@ bad:
JSBool
js_InitArgsCallClosureClasses(JSContext *cx, JSObject *obj,
JSObject *objProto)
JSObject *arrayProto)
{
#if JS_HAS_ARGS_OBJECT
if (!JS_InitClass(cx, obj, objProto, &js_ArgumentsClass, Arguments, 0,
if (!JS_InitClass(cx, obj, arrayProto, &js_ArgumentsClass, Arguments, 0,
args_props, NULL, NULL, NULL)) {
return JS_FALSE;
}
@@ -1728,7 +1696,6 @@ js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
fun->spare = 0;
fun->atom = atom;
fun->script = NULL;
fun->clasp = NULL;
return fun;
}
@@ -1786,27 +1753,15 @@ void
js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing)
{
JSStackFrame *fp;
jsval *sp;
JSString *str;
const char *typeName;
JSString *fallback;
fp = cx->fp;
/*
* 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 (fp)
sp = fp->sp, fp->sp = vp;
str = js_DecompileValueGenerator(cx, *vp, NULL);
if (fp)
fp->sp = sp;
if (str) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
constructing ? JSMSG_NOT_CONSTRUCTOR

View File

@@ -37,8 +37,6 @@ 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;
@@ -62,7 +60,7 @@ js_InitFunctionClass(JSContext *cx, JSObject *obj);
extern JSBool
js_InitArgsCallClosureClasses(JSContext *cx, JSObject *obj,
JSObject *objProto);
JSObject *arrayProto);
extern JSFunction *
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,

View File

@@ -30,9 +30,22 @@
#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"
@@ -170,7 +183,7 @@ js_AllocGCThing(JSContext *cx, uintN flags)
{
JSRuntime *rt;
JSGCThing *thing;
uint8 *flagp = NULL;
uint8 *flagp;
#ifdef TOO_MUCH_GC
JSBool tried_gc = JS_TRUE;
js_GC(cx);
@@ -578,7 +591,7 @@ gc_hash_root(const void *key)
return num >> 2;
}
JS_STATIC_DLL_CALLBACK(intN)
STATIC_DLL_CALLBACK(intN)
gc_root_marker(JSHashEntry *he, intN i, void *arg)
{
void **rp = (void **)he->key;
@@ -587,17 +600,11 @@ gc_root_marker(JSHashEntry *he, intN i, void *arg)
#ifdef DEBUG
JSArena *a;
JSRuntime *rt = (JSRuntime *)arg;
JSBool root_points_to_gcArenaPool = JS_FALSE;
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);
}
for (a = rt->gcArenaPool.first.next; a; a = a->next) {
JS_ASSERT(!rp ||
(*rp >= (void *)a->base && *rp <= (void *)a->avail));
}
#endif
GC_MARK(arg, *rp, he->value ? he->value : "root", NULL);
}
@@ -771,8 +778,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 && JSVAL_IS_GCTHING(acx->exception))
GC_MARK(rt, JSVAL_TO_GCTHING(acx->exception), "exception", NULL);
if (acx->throwing)
GC_MARK(rt, acx->exception, "exception", NULL);
#endif
}

View File

@@ -23,11 +23,18 @@
#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(JS_HASH_BITS - (ht)->shift)
#define NBUCKETS(ht) JS_BIT(PR_HASH_BITS - (ht)->shift)
/* The smallest table has 16 buckets */
#define MINBUCKETSLOG2 4
@@ -72,7 +79,7 @@ static JSHashAllocOps defaultHashAllocOps = {
DefaultAllocEntry, DefaultFreeEntry
};
JS_EXPORT_API(JSHashTable *)
IMPLEMENT(JSHashTable *)
JS_NewHashTable(uint32 n, JSHashFunction keyHash,
JSHashComparator keyCompare, JSHashComparator valueCompare,
JSHashAllocOps *allocOps, void *allocPriv)
@@ -94,7 +101,7 @@ JS_NewHashTable(uint32 n, JSHashFunction keyHash,
if (!ht)
return NULL;
memset(ht, 0, sizeof *ht);
ht->shift = JS_HASH_BITS - n;
ht->shift = PR_HASH_BITS - n;
n = JS_BIT(n);
#if defined(XP_PC) && defined _MSC_VER && _MSC_VER <= 800
if (n > 16000) {
@@ -118,7 +125,7 @@ JS_NewHashTable(uint32 n, JSHashFunction keyHash,
return ht;
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_HashTableDestroy(JSHashTable *ht)
{
uint32 i, n;
@@ -146,7 +153,7 @@ JS_HashTableDestroy(JSHashTable *ht)
/*
** Multiplicative hash, from Knuth 6.4.
*/
JS_EXPORT_API(JSHashEntry **)
IMPLEMENT(JSHashEntry **)
JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
{
JSHashEntry *he, **hep, **hep0;
@@ -155,7 +162,7 @@ JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
#ifdef HASHMETER
ht->nlookups++;
#endif
h = keyHash * JS_GOLDEN_RATIO;
h = keyHash * PR_GOLDEN_RATIO;
h >>= ht->shift;
hep = hep0 = &ht->buckets[h];
while ((he = *hep) != NULL) {
@@ -176,7 +183,7 @@ JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key)
return hep;
}
JS_EXPORT_API(JSHashEntry *)
IMPLEMENT(JSHashEntry *)
JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep,
JSHashNumber keyHash, const void *key, void *value)
{
@@ -233,7 +240,7 @@ JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep,
return he;
}
JS_EXPORT_API(JSHashEntry *)
IMPLEMENT(JSHashEntry *)
JS_HashTableAdd(JSHashTable *ht, const void *key, void *value)
{
JSHashNumber keyHash;
@@ -255,7 +262,7 @@ JS_HashTableAdd(JSHashTable *ht, const void *key, void *value)
return JS_HashTableRawAdd(ht, hep, keyHash, key, value);
}
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he)
{
uint32 i, n;
@@ -297,7 +304,7 @@ JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he)
}
}
JS_EXPORT_API(JSBool)
IMPLEMENT(JSBool)
JS_HashTableRemove(JSHashTable *ht, const void *key)
{
JSHashNumber keyHash;
@@ -313,7 +320,7 @@ JS_HashTableRemove(JSHashTable *ht, const void *key)
return JS_TRUE;
}
JS_EXPORT_API(void *)
IMPLEMENT(void *)
JS_HashTableLookup(JSHashTable *ht, const void *key)
{
JSHashNumber keyHash;
@@ -332,7 +339,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.
*/
JS_EXPORT_API(int)
IMPLEMENT(int)
JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg)
{
JSHashEntry *he, **hep;
@@ -373,7 +380,7 @@ out:
#include <math.h>
#include <stdio.h>
JS_EXPORT_API(void)
IMPLEMENT(void)
JS_HashTableDumpMeter(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
{
double mean, variance;
@@ -419,7 +426,7 @@ JS_HashTableDumpMeter(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
}
#endif /* HASHMETER */
JS_EXPORT_API(int)
IMPLEMENT(int)
JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
{
int count;
@@ -431,7 +438,7 @@ JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp)
return count;
}
JS_EXPORT_API(JSHashNumber)
IMPLEMENT(JSHashNumber)
JS_HashString(const void *key)
{
JSHashNumber h;
@@ -443,7 +450,7 @@ JS_HashString(const void *key)
return h;
}
JS_EXPORT_API(int)
IMPLEMENT(int)
JS_CompareValues(const void *v1, const void *v2)
{
return v1 == v2;

View File

@@ -32,8 +32,8 @@ typedef uint32 JSHashNumber;
typedef struct JSHashEntry JSHashEntry;
typedef struct JSHashTable JSHashTable;
#define JS_HASH_BITS 32
#define JS_GOLDEN_RATIO 0x9E3779B9U
#define PR_HASH_BITS 32
#define PR_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().
*/
JS_EXTERN_API(JSHashTable *)
EXTERN(JSHashTable *)
JS_NewHashTable(uint32 n, JSHashFunction keyHash,
JSHashComparator keyCompare, JSHashComparator valueCompare,
JSHashAllocOps *allocOps, void *allocPriv);
JS_EXTERN_API(void)
EXTERN(void)
JS_HashTableDestroy(JSHashTable *ht);
/* Low level access methods */
JS_EXTERN_API(JSHashEntry **)
EXTERN(JSHashEntry **)
JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key);
JS_EXTERN_API(JSHashEntry *)
EXTERN(JSHashEntry *)
JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **hep, JSHashNumber keyHash,
const void *key, void *value);
JS_EXTERN_API(void)
EXTERN(void)
JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he);
/* Higher level access methods */
JS_EXTERN_API(JSHashEntry *)
EXTERN(JSHashEntry *)
JS_HashTableAdd(JSHashTable *ht, const void *key, void *value);
JS_EXTERN_API(JSBool)
EXTERN(JSBool)
JS_HashTableRemove(JSHashTable *ht, const void *key);
JS_EXTERN_API(intN)
EXTERN(intN)
JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg);
JS_EXTERN_API(void *)
EXTERN(void *)
JS_HashTableLookup(JSHashTable *ht, const void *key);
JS_EXTERN_API(intN)
EXTERN(intN)
JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp);
/* General-purpose C string hash function. */
JS_EXTERN_API(JSHashNumber)
EXTERN(JSHashNumber)
JS_HashString(const void *key);
/* Stub function just returns v1 == v2 */
JS_EXTERN_API(intN)
IMPLEMENT(intN)
JS_CompareValues(const void *v1, const void *v2);
JS_END_EXTERN_C

View File

@@ -75,14 +75,8 @@
"PR_MapEvents",
"PR_RevokeEvents",
"PR_cnvtf",
"PR_dtoa",
"PR_strtod",
"PRFileDesc",
"PR_HASH_BITS",
"PR_GOLDEN_RATIO",
"PRHashAllocOps",
"PRHashComparator",
"PRHashEntry",
@@ -396,13 +390,17 @@ sub convert_includes {
}
if ($line =~ /prlog\.h/) {
$line = '#include "jsutil.h"'. " /* Added by JSIFY */\n";
chop $line;
$line = "/* Removed by JSIFY: $line */\n";
$line .= '#include "jsutil.h"'. " /* Added by JSIFY */\n";
} elsif ($line =~ /plhash\.h/) {
$line = '#include "jshash.h"'. " /* Added by JSIFY */\n";
$line = "/* Removed by JSIFY: $line */\n";
$line .= '#include "jshash.h"'. " /* Added by JSIFY */\n";
} elsif ($line =~ /plarena\.h/) {
$line = '#include "jsarena.h"'. " /* Added by JSIFY */\n";
$line = "/* Removed by JSIFY: $line */\n";
$line .= '#include "jsarena.h"'. " /* Added by JSIFY */\n";
} elsif ($line =~ /prmem\.h/) {
$line = "";
$line = "/* Removed by JSIFY: $line */\n";
} elsif ($line =~ /jsmsg\.def/) {
$line = '#include "js.msg"' . "\n";
} elsif ($line =~ /shellmsg\.def/) {
@@ -415,14 +413,13 @@ sub convert_includes {
sub convert_declarations {
($line) = @_;
$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;
$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;
return $line;
}

View File

@@ -24,7 +24,14 @@
#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"
@@ -444,19 +451,10 @@ 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. */
/*
* 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;
}
/* Try converting to function, for closure and API compatibility. */
ok = clasp->convert(cx, funobj, JSTYPE_FUNCTION, &v);
if (!ok)
goto out2;
if (!JSVAL_IS_FUNCTION(cx, v)) {
fun = NULL;
script = NULL;
@@ -757,7 +755,6 @@ 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;
@@ -848,9 +845,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))
@@ -1034,10 +1031,6 @@ 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.
*/
@@ -1045,12 +1038,14 @@ 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;
@@ -1084,7 +1079,7 @@ js_Interpret(JSContext *cx, jsval *result)
#endif
if (rt->interruptHandler) {
JSTrapHandler handler = rt->interruptHandler;
JSTrapHandler handler = (JSTrapHandler) rt->interruptHandler;
/* check copy of pointer for safety in multithreaded situation */
if (handler) {
switch (handler(cx, script, pc, &rval,
@@ -1097,13 +1092,6 @@ 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:;
}
}
@@ -1474,7 +1462,6 @@ 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 { \
@@ -1922,8 +1909,7 @@ 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;
@@ -1932,13 +1918,10 @@ 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,
@@ -1947,14 +1930,13 @@ 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 ((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 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) {
ok = JS_FALSE;
goto out;
@@ -1967,6 +1949,10 @@ 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;
}
@@ -2176,13 +2162,16 @@ 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;
@@ -2289,6 +2278,7 @@ 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) {
@@ -2529,13 +2519,6 @@ 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;
@@ -2694,8 +2677,22 @@ 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 */
@@ -2728,7 +2725,7 @@ js_Interpret(JSContext *cx, jsval *result)
#if JS_HAS_DEBUGGER_KEYWORD
case JSOP_DEBUGGER:
if (rt->debuggerHandler) {
JSTrapHandler handler = rt->debuggerHandler;
JSTrapHandler handler = (JSTrapHandler) rt->debuggerHandler;
/* check copy of pointer for safety in multithread situation */
if (handler) {
switch (handler(cx, script, pc, &rval,
@@ -2741,13 +2738,6 @@ 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:;
}
}
@@ -2790,60 +2780,6 @@ 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.
*/

View File

@@ -1,272 +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.
*/
/*
* 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 */

View File

@@ -26,6 +26,7 @@
#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"
@@ -101,32 +102,32 @@ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
#if defined(__GNUC__)
unsigned int res;
#ifndef ULTRA_SPARC
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\
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
3:"
: "=r" (res)
: "r" (w), "r" (ov), "r" (nv), "r" (-1));
#else /* ULTRA_SPARC */
JS_ASSERT(ov != nv);
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\
asm volatile ("
stbar
cas [%1],%2,%3
cmp %2,%3
be,a 1f
mov 1,%0
mov 0,%0
1:"
: "=r" (res)
: "r" (w), "r" (ov), "r" (nv));
@@ -135,7 +136,7 @@ mov 0,%0\n\
#else /* !__GNUC__ */
extern int compare_and_swap(jsword*,jsword,jsword);
#ifndef ULTRA_SPARC
JS_ASSERT(nv != -1);
JS_ASSERT(nv >= 0);
#else
JS_ASSERT(ov != nv);
#endif
@@ -188,7 +189,7 @@ js_AtomicAdd(jsword *p, jsword i)
AtomicAddBody(p,i);
}
static JS_INLINE jsword
JS_INLINE jsword
js_AtomicSet(jsword *p, jsword n)
{
jsword o;
@@ -307,7 +308,7 @@ mallocFatlock()
fl->next = NULL;
fl->prev = NULL;
fl->slock = PR_NewLock();
fl->svar = PR_NewCondVar(fl->slock);
fl->svar = JS_NewCondVar(fl->slock);
return fl;
}
@@ -326,7 +327,7 @@ js_SuspendThread(JSThinLock *p)
JSStatus stat;
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1) /* busy wait */
PR_Sleep(PR_INTERVAL_NO_WAIT);
PR_Sleep(JS_INTERVAL_NO_WAIT);
if (fl == NULL)
return 1;
PR_Lock(fl->slock);
@@ -336,7 +337,7 @@ js_SuspendThread(JSThinLock *p)
PR_Unlock(fl->slock);
return 1;
}
stat = PR_WaitCondVar(fl->svar,PR_INTERVAL_NO_TIMEOUT);
stat = PR_WaitCondVar(fl->svar,JS_INTERVAL_NO_TIMEOUT);
if (stat == JS_FAILURE) {
fl->susp--;
return 0;
@@ -352,7 +353,7 @@ js_ResumeThread(JSThinLock *p)
JSStatus stat;
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1)
PR_Sleep(PR_INTERVAL_NO_WAIT);
PR_Sleep(JS_INTERVAL_NO_WAIT);
if (fl == NULL)
return;
PR_Lock(fl->slock);
@@ -395,7 +396,7 @@ deleteListOfFatlocks(JSFatLock *m)
static JSFatLockTable _fl_table;
static JSFatLock *
JSFatLock *
allocateFatlock()
{
JSFatLock *m;
@@ -420,7 +421,7 @@ allocateFatlock()
return m;
}
static void
void
deallocateFatlock(JSFatLock *m)
{
if (m == NULL)
@@ -437,7 +438,7 @@ deallocateFatlock(JSFatLock *m)
js_UnlockGlobal();
}
int
JS_PUBLIC_API(int)
js_SetupLocks(int l)
{
if (l > 10000) /* l equals number of initially allocated fat locks */
@@ -461,7 +462,7 @@ js_SetupLocks(int l)
return 1;
}
void
JS_PUBLIC_API(void)
js_CleanupLocks()
{
if (_global_lock != NULL) {
@@ -511,7 +512,7 @@ js_InitContextForLocking(JSContext *cx)
*/
static int
int
emptyFatlock(JSThinLock *p)
{
JSFatLock *fl;
@@ -519,7 +520,7 @@ emptyFatlock(JSThinLock *p)
PRLock* lck;
while ((fl = (JSFatLock*)js_AtomicSet((jsword*)&p->fat,1)) == (JSFatLock*)1)
PR_Sleep(PR_INTERVAL_NO_WAIT);
PR_Sleep(JS_INTERVAL_NO_WAIT);
if (fl == NULL) {
js_AtomicSet((jsword*)&p->fat,(jsword)fl);
return 1;
@@ -584,7 +585,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(PR_INTERVAL_NO_WAIT);
PR_Sleep(JS_INTERVAL_NO_WAIT);
if (fl == NULL)
fl = allocateFatlock();
js_AtomicSet((jsword*)&p->fat,(jsword)fl);
@@ -660,7 +661,7 @@ js_UnlockRuntime(JSRuntime *rt)
JS_UNLOCK0(p,me);
}
static JS_INLINE void
JS_INLINE void
js_LockScope1(JSContext *cx, JSScope *scope, jsword me)
{
JSThinLock *p;

View File

@@ -23,7 +23,13 @@
#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)
@@ -60,10 +66,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) PR_NewCondVar(l)
#define JS_NEW_CONDVAR(l) JS_NewCondVar(l)
#define JS_DESTROY_CONDVAR(cv) PR_DestroyCondVar(cv)
#define JS_WAIT_CONDVAR(cv,to) PR_WaitCondVar(cv,to)
#define JS_NO_TIMEOUT PR_INTERVAL_NO_TIMEOUT
#define JS_NO_TIMEOUT JS_INTERVAL_NO_TIMEOUT
#define JS_NOTIFY_CONDVAR(cv) PR_NotifyCondVar(cv)
#define JS_NOTIFY_ALL_CONDVAR(cv) PR_NotifyAllCondVar(cv)
@@ -100,8 +106,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 int js_SetupLocks(int);
extern void js_CleanupLocks();
extern JS_PUBLIC_API(int) js_SetupLocks(int);
extern JS_PUBLIC_API(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);
@@ -140,7 +146,7 @@ extern JSBool js_IsScopeLocked(JSScope *scope);
JS_LOCK_RUNTIME_VOID(_rt, e); \
JS_END_MACRO
#if defined(JS_USE_ONLY_NSPR_LOCKS) || !(defined(_WIN32) || defined(SOLARIS) || defined(AIX))
#if defined(JS_ONLY_NSPR_LOCKS) || !(defined(_WIN32) || defined(SOLARIS) || defined(AIX))
#undef JS_LOCK0
#undef JS_UNLOCK0

233
mozilla/js/src/jslog.h Normal file
View File

@@ -0,0 +1,233 @@
/* -*- 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___ */

View File

@@ -21,7 +21,7 @@
/*
** Compute the log of the least power of 2 greater than or equal to n
*/
JS_EXPORT_API(JSIntn) JS_CeilingLog2(JSUint32 n)
IMPLEMENT(JSIntn) JS_CeilingLog2(JSUint32 n)
{
JSIntn log2 = 0;
@@ -44,7 +44,7 @@ JS_EXPORT_API(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.
*/
JS_EXPORT_API(JSIntn) JS_FloorLog2(JSUint32 n)
IMPLEMENT(JSIntn) JS_FloorLog2(JSUint32 n)
{
JSIntn log2 = 0;

View File

@@ -31,12 +31,12 @@ JSInt64 __pascal __loadds __export
JSInt64 __pascal __loadds __export
JSLL_MinInt(void) { return ll_minint; }
#else
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; }
IMPLEMENT(JSInt64) JSLL_Zero(void) { return ll_zero; }
IMPLEMENT(JSInt64) JSLL_MaxInt(void) { return ll_maxint; }
IMPLEMENT(JSInt64) JSLL_MinInt(void) { return ll_minint; }
#endif
#ifndef JS_HAVE_LONG_LONG
#ifndef 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 = jshi16(b);
d0 = jslo16(b);
d1 = _hi16(b);
d0 = _lo16(b);
r1 = a.hi % d1;
q1 = a.hi / d1;
m = q1 * d0;
r1 = (r1 << 16) | jshi16(a.lo);
r1 = (r1 << 16) | _hi16(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) | jslo16(a.lo);
r0 = (r0 << 16) | _lo16(a.lo);
if (r0 < m) {
q0--, r0 += b;
if (r0 >= b
@@ -94,7 +94,7 @@ static JSUint32 CountLeadingZeros(JSUint32 a)
return r;
}
JS_EXPORT_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
IMPLEMENT(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
{
JSUint32 n0, n1, n2;
JSUint32 q0, q1;
@@ -257,4 +257,4 @@ JS_EXPORT_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint6
qp->hi = q1;
}
}
#endif /* !JS_HAVE_LONG_LONG */
#endif /* !HAVE_LONG_LONG */

View File

@@ -47,16 +47,16 @@ JSInt64 __pascal __loadds __export
JSInt64 __pascal __loadds __export
JSLL_Zero(void);
#else
JS_EXTERN_API(JSInt64) JSLL_MaxInt(void);
JS_EXTERN_API(JSInt64) JSLL_MinInt(void);
JS_EXTERN_API(JSInt64) JSLL_Zero(void);
EXTERN(JSInt64) JSLL_MaxInt(void);
EXTERN(JSInt64) JSLL_MinInt(void);
EXTERN(JSInt64) JSLL_Zero(void);
#endif
#define JSLL_MAXINT JSLL_MaxInt()
#define JSLL_MININT JSLL_MinInt()
#define JSLL_ZERO JSLL_Zero()
#ifdef JS_HAVE_LONG_LONG
#ifdef HAVE_LONG_LONG
#if JS_BYTES_PER_LONG == 8
#define JSLL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
@@ -175,7 +175,7 @@ JS_EXTERN_API(JSInt64) JSLL_Zero(void);
(*(qp) = ((JSUint64)(a) / (b)), \
*(rp) = ((JSUint64)(a) % (b)))
#else /* !JS_HAVE_LONG_LONG */
#else /* !HAVE_LONG_LONG */
#ifdef IS_LITTLE_ENDIAN
#define JSLL_INIT(hi, lo) {JS_INT32(lo), JS_INT32(hi)}
@@ -227,28 +227,28 @@ JS_EXTERN_API(JSInt64) JSLL_Zero(void);
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
}
#define jslo16(a) ((a) & JS_BITMASK(16))
#define jshi16(a) ((a) >> 16)
#define _lo16(a) ((a) & JS_BITMASK(16))
#define _hi16(a) ((a) >> 16)
#define JSLL_MUL32(r, a, b) { \
JSUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
_a1 = jshi16(a), _a0 = jslo16(a); \
_b1 = jshi16(b), _b0 = jslo16(b); \
_a1 = _hi16(a), _a0 = _lo16(a); \
_b1 = _hi16(b), _b0 = _lo16(b); \
_y0 = _a0 * _b0; \
_y1 = _a0 * _b1; \
_y2 = _a1 * _b0; \
_y3 = _a1 * _b1; \
_y1 += jshi16(_y0); /* can't carry */ \
_y1 += _hi16(_y0); /* can't carry */ \
_y1 += _y2; /* might carry */ \
if (_y1 < _y2) \
_y3 += (JSUint32)(JS_BIT(16)); /* propagate */ \
(r).lo = (jslo16(_y1) << 16) + jslo16(_y0); \
(r).hi = _y3 + jshi16(_y1); \
(r).lo = (_lo16(_y1) << 16) + _lo16(_y0); \
(r).hi = _y3 + _hi16(_y1); \
}
#define JSLL_UDIVMOD(qp, rp, a, b) jsll_udivmod(qp, rp, a, b)
#define JSLL_UDIVMOD(qp, rp, a, b) ll_udivmod(qp, rp, a, b)
JS_EXTERN_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
EXTERN(void) ll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
#define JSLL_DIV(r, a, b) { \
JSInt64 _a, _b; \
@@ -402,7 +402,7 @@ JS_EXTERN_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint6
JSLL_NEG(l, l); \
}
#endif /* !JS_HAVE_LONG_LONG */
#endif /* !HAVE_LONG_LONG */
JS_END_EXTERN_C

37
mozilla/js/src/jsmacos.h Normal file
View File

@@ -0,0 +1,37 @@
/* -*- 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___ */

View File

@@ -20,7 +20,7 @@
* JS math package.
*/
#include "jsstddef.h"
#include "jslibmath.h"
#include <math.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 = fd_fabs(x);
return JS_FALSE;
z = (x < 0) ? -x : 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 = fd_acos(x);
return JS_FALSE;
z = 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 = fd_asin(x);
return JS_FALSE;
z = 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 = fd_atan(x);
return JS_FALSE;
z = 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 = fd_atan2(x, y);
z = 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 = fd_ceil(x);
return JS_FALSE;
z = 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 = fd_cos(x);
return JS_FALSE;
z = 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 = fd_exp(x);
return JS_FALSE;
z = 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 = fd_floor(x);
return JS_FALSE;
z = 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 = fd_log(x);
return JS_FALSE;
z = log(x);
return js_NewNumberValue(cx, z, rval);
}
@@ -196,18 +196,10 @@ 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;
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_FALSE;
z = (x > y) ? x : y;
return js_NewNumberValue(cx, z, rval);
}
@@ -219,16 +211,8 @@ 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;
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_FALSE;
z = (x < y) ? x : y;
return js_NewNumberValue(cx, z, rval);
}
@@ -240,8 +224,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 = fd_pow(x, y);
return JS_FALSE;
z = pow(x, y);
return js_NewNumberValue(cx, z, rval);
}
@@ -338,8 +322,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 = fd_copysign(fd_floor(x + 0.5), x);
return JS_FALSE;
z = floor(x + 0.5);
return js_NewNumberValue(cx, z, rval);
}
@@ -349,8 +333,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 = fd_sin(x);
return JS_FALSE;
z = sin(x);
return js_NewNumberValue(cx, z, rval);
}
@@ -360,8 +344,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 = fd_sqrt(x);
return JS_FALSE;
z = sqrt(x);
return js_NewNumberValue(cx, z, rval);
}
@@ -371,25 +355,12 @@ 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 = fd_tan(x);
return JS_FALSE;
z = 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},
@@ -411,17 +382,33 @@ 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 *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;
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;
}

View File

@@ -1,5 +1,19 @@
/* -*- Mode: C; tab-width: 8 -*-
* Copyright (C) 1998 Netscape Communications Corporation, All Rights Reserved.
/* -*- 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 jsmath_h___

View File

@@ -28,6 +28,7 @@
#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"
@@ -182,7 +183,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);
JS_cnvtf(buf + i, sizeof buf - i, 20, d);
PR_cnvtf(buf + i, sizeof buf - i, 20, d);
i = strlen(buf);
JS_snprintf(buf + i, sizeof buf - i, "))");
str = JS_NewStringCopyZ(cx, buf);
@@ -432,7 +433,7 @@ js_NumberToString(JSContext *cx, jsdouble d)
if (JSDOUBLE_IS_INT(d, i)) {
JS_snprintf(buf, sizeof buf, "%ld", (long)i);
} else {
JS_cnvtf(buf, sizeof buf, 20, d);
PR_cnvtf(buf, sizeof buf, 20, d);
}
return JS_NewStringCopyZ(cx, buf);
}
@@ -647,7 +648,7 @@ js_strtod(JSContext *cx, const jschar *s, const jschar **ep, jsdouble *dp)
estr = istr + 8;
} else {
errno = 0;
d = JS_strtod(cstr, &estr);
d = PR_strtod(cstr, &estr);
if (errno == ERANGE)
if (d == HUGE_VAL)
d = *cx->runtime->jsPositiveInfinity;
@@ -757,7 +758,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
* JS_strtod to get the correct answer.
* PR_strtod to get the correct answer.
*/
size_t i;
size_t length = s1 - start;
@@ -771,7 +772,7 @@ js_strtointeger(JSContext *cx, const jschar *s, const jschar **ep, jsint base, j
cstr[length] = 0;
errno = 0;
value = JS_strtod(cstr, &estr);
value = PR_strtod(cstr, &estr);
if (errno == ERANGE && value == HUGE_VAL)
value = *cx->runtime->jsPositiveInfinity;
free(cstr);

View File

@@ -23,9 +23,22 @@
#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"
@@ -91,7 +104,7 @@ JSClass js_ObjectClass = {
static JSBool
obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
JS_STATIC_DLL_CALLBACK(JSBool)
STATIC_DLL_CALLBACK(JSBool)
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
static JSBool
@@ -126,7 +139,7 @@ obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return JS_TRUE;
}
JS_STATIC_DLL_CALLBACK(JSBool)
STATIC_DLL_CALLBACK(JSBool)
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *obj2;
@@ -178,7 +191,7 @@ error:
#endif /* !JS_HAS_OBJ_PROTO_PROP */
JS_STATIC_DLL_CALLBACK(JSHashNumber)
STATIC_DLL_CALLBACK(JSHashNumber)
js_hash_object(const void *key)
{
return (JSHashNumber)key >> JSVAL_TAGBITS;
@@ -292,7 +305,6 @@ js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
if (!he)
JS_ReportOutOfMemory(cx);
*sp = NULL;
sharpid = 0;
goto out;
}
}
@@ -392,16 +404,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));
nchars = 0;
if (!chars)
goto error;
goto done;
nchars = 0;
} else {
MAKE_SHARP(he);
nchars = js_strlen(chars);
chars = realloc((ochars = chars), (nchars + 2 + 1) * sizeof(jschar));
if (!chars) {
free(ochars);
goto error;
goto done;
}
}
chars[nchars++] = '{';
@@ -413,14 +425,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 error;
goto done;
/* 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 error;
goto done;
}
argv[0] = STRING_TO_JSVAL(idstr);
@@ -429,7 +441,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
idstr = js_QuoteString(cx, idstr, '\'');
if (!idstr) {
ok = JS_FALSE;
goto error;
goto done;
}
argv[0] = STRING_TO_JSVAL(idstr);
}
@@ -438,7 +450,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
valstr = js_ValueToSource(cx, val);
if (!valstr) {
ok = JS_FALSE;
goto error;
goto done;
}
argv[1] = STRING_TO_JSVAL(valstr);
vchars = valstr->chars;
@@ -452,7 +464,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 error;
goto done;
}
if (IS_SHARP(he)) {
vchars = vsharp;
@@ -476,7 +488,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 error;
goto done;
}
if (comma) {
@@ -500,12 +512,11 @@ 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) {
@@ -590,21 +601,13 @@ 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
@@ -740,69 +743,6 @@ 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},
@@ -813,11 +753,6 @@ 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}
};
@@ -1127,11 +1062,6 @@ 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:
@@ -1247,10 +1177,6 @@ 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);
@@ -1359,7 +1285,7 @@ js_FreeSlot(JSContext *cx, JSObject *obj, uint32 slot)
{ \
jsuint _index = JS7_UNDEC(*_cp++); \
jsuint _oldIndex = 0; \
jsuint _c = 0; \
jsuint _c; \
if (_index != 0) { \
while (JS7_ISDEC(*_cp)) { \
_oldIndex = _index; \
@@ -1545,7 +1471,6 @@ 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);
@@ -1671,7 +1596,7 @@ js_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
CHECK_FOR_FUNNY_INDEX(id);
#if JS_BUG_NULL_INDEX_PROPS
/* Indexed properties defaulted to null in old versions. */
/* Indexd properties defaulted to null in old versions. */
*vp = (JSVAL_IS_INT(id) && JSVAL_TO_INT(id) >= 0)
? JSVAL_NULL
: JSVAL_VOID;
@@ -1725,8 +1650,6 @@ 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) {
@@ -2098,14 +2021,7 @@ js_DefaultValue(JSContext *cx, JSObject *obj, JSType hint, jsval *vp)
v = OBJECT_TO_JSVAL(obj);
switch (hint) {
case JSTYPE_STRING:
/*
* 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;
js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL, &v);
if (!JSVAL_IS_PRIMITIVE(v)) {
if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, hint, &v))
return JS_FALSE;
@@ -2140,9 +2056,8 @@ 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;
if (!js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0,
NULL, &v))
return JS_FALSE;
js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, NULL,
&v);
}
break;
}
@@ -2498,45 +2413,33 @@ js_ValueToNonNullObject(JSContext *cx, jsval v)
return obj;
}
JSBool
void
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]);
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv,
rval);
js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 1, argv, rval);
#else
return js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 0, NULL,
rval);
js_TryMethod(cx, obj, cx->runtime->atomState.valueOfAtom, 0, NULL, rval);
#endif
}
JSBool
void
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) {
ok = js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
} else {
ok = JS_TRUE;
(void) js_CallFunctionValue(cx, obj, fval, argc, argv, rval);
}
JS_SetErrorReporter(cx, older);
return ok;
}
#if JS_HAS_XDR
@@ -2564,7 +2467,6 @@ 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. */
@@ -2615,13 +2517,12 @@ out:
#endif /* JS_HAS_XDR */
#ifdef DEBUG
/* Routines to print out values during debugging. */
void printChar(jschar *cp) {
fprintf(stderr, "jschar* (0x%p) \"", cp);
fprintf(stderr, "jschar* (0x%x) \"", cp);
while (*cp)
fputc(*cp++, stderr);
fputc('"', stderr);
@@ -2630,41 +2531,22 @@ void printChar(jschar *cp) {
void printString(JSString *str) {
jsuint i;
fprintf(stderr, "string (0x%p) \"", str);
fprintf(stderr, "string (0x%x) \"", 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%p) = ", val, val);
fprintf(stderr, "val %d (0x%x) = ", 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)) {
printObj(JSVAL_TO_OBJECT(val));
/* XXX can do more here */
fprintf(stderr, "object\n");
} else if (JSVAL_IS_INT(val)) {
fprintf(stderr, "(int) %d\n", JSVAL_TO_INT(val));
} else if (JSVAL_IS_STRING(val)) {
@@ -2680,7 +2562,7 @@ void printVal(jsval val) {
}
void printId(jsid id) {
fprintf(stderr, "id %d (0x%p) is ", id, id);
fprintf(stderr, "id %d (0x%x) is ", id, id);
printVal(js_IdToValue(id));
}

View File

@@ -26,7 +26,15 @@
* 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"
@@ -309,10 +317,10 @@ js_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
extern JSObject *
js_ValueToNonNullObject(JSContext *cx, jsval v);
extern JSBool
extern void
js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, jsval *rval);
extern JSBool
extern void
js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
uintN argc, jsval *argv, jsval *rval);

View File

@@ -26,7 +26,14 @@
#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"
@@ -64,9 +71,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[] = {
@@ -76,7 +83,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];
/************************************************************************/
@@ -594,9 +601,8 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
jp->indent -= 4;
}
caseExprOff = isCondSwitch
? (ptrdiff_t) js_CodeSpec[JSOP_CONDSWITCH].length
: 0;
if (isCondSwitch)
caseExprOff = (ptrdiff_t) js_CodeSpec[JSOP_CONDSWITCH].length;
for (i = 0; i < tableLength; i++) {
off = table[i].offset;
@@ -947,12 +953,10 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
if (!lval)
return JS_FALSE;
/*
* The offset tells distance to the end of the right-hand
* operand of the comma operator.
*/
/* The offset tells distance to next comma, or to end. */
done = pc + len;
pc += js_GetSrcNoteOffset(sn, 0);
LOCAL_ASSERT(pc == endpc || *pc == JSOP_POP);
len = 0;
if (!Decompile(ss, done, pc - done)) {
@@ -1555,7 +1559,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
todo = Sprint(&ss->sprinter, "%ld", ival);
} else if (JSVAL_IS_DOUBLE(key)) {
char buf[32];
JS_cnvtf(buf, sizeof buf, 20, *JSVAL_TO_DOUBLE(key));
PR_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),
@@ -1998,26 +2002,6 @@ 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)
{
@@ -2034,7 +2018,6 @@ 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.
*
@@ -2070,7 +2053,7 @@ js_DecompileFunction(JSPrinter *jp, JSFunction *fun, JSBool newlines)
js_puts(jp, ") {\n");
indent = jp->indent;
jp->indent += 4;
if (fun->script && fun->object) {
if (fun->script) {
oldscope = jp->scope;
jp->scope = scope;
ok = js_DecompileScript(jp, fun->script);
@@ -2151,12 +2134,7 @@ js_DecompileValueGenerator(JSContext *cx, jsval v, JSString *fallback)
/* Be paranoid about loading an invalid pc from sp[-depth]. */
if (!pc)
goto do_fallback;
/*
* 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);
*/
JS_ASSERT(JS_UPTRDIFF(pc, script->code) < (jsuword)script->length);
if (JS_UPTRDIFF(pc, script->code) >= (jsuword)script->length) {
pc = fp->pc;
if (!pc)

View File

@@ -172,9 +172,6 @@ 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);

View File

@@ -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, 1, 2, 0, 0, JOF_BYTE |JOF_ELEM|JOF_IMPORT)
OPDEF(JSOP_IMPORTELEM,79, "importelem", NULL, 3, 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,8 +210,3 @@ 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)

View File

@@ -25,25 +25,15 @@
#ifdef XP_PC
#ifdef _WIN32
#define JS_HAVE_LONG_LONG
#include "os/win32.h"
#else
#undef JS_HAVE_LONG_LONG
#include "os/win16.h"
#endif
#endif /* XP_PC */
#ifdef XP_MAC
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 */
#include "jsmacos.h"
#endif
#ifdef XP_UNIX
@@ -51,40 +41,34 @@ JS_END_EXTERN_C
* Get OS specific header information.
*/
#if defined(AIXV3)
#define JS_HAVE_LONG_LONG
#include "os/aix.h"
#elif defined(BSDI)
#define JS_HAVE_LONG_LONG
#include "os/bsdi.h"
#elif defined(HPUX)
#undef JS_HAVE_LONG_LONG
#include "os/hpux.h"
#elif defined(IRIX)
#define JS_HAVE_LONG_LONG
#include "os/irix.h"
#elif defined(linux)
#define JS_HAVE_LONG_LONG
#elif defined(LINUX)
#include "os/linux.h"
#elif defined(OSF1)
#define JS_HAVE_LONG_LONG
#include "os/osf1.h"
#elif defined(SCO)
#undef JS_HAVE_LONG_LONG
#include "os/scoos.h"
#elif defined(SOLARIS)
#define JS_HAVE_LONG_LONG
#include "os/solaris.h"
#elif defined(SUNOS4)
#undef JS_HAVE_LONG_LONG
/*
** Missing function prototypes
*/
extern void *sbrk(int);
#include "os/sunos.h"
#elif defined(UNIXWARE)
#undef JS_HAVE_LONG_LONG
#include "os/unixware.h"
#endif
#endif /* XP_UNIX */

View File

@@ -23,18 +23,11 @@
* 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. */
#ifdef XP_UNIX
#include <sys/types.h>
#else
#ifndef XP_UNIX
typedef JSUintn uint;
#endif
@@ -86,84 +79,6 @@ 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

View File

@@ -36,7 +36,14 @@
#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"
@@ -253,7 +260,6 @@ js_CompileTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
} while (ok);
out:
ts->flags &= ~TSF_BADCOMPILE;
cx->gcDisabled--;
cx->fp = fp;
if (!ok)
@@ -379,7 +385,7 @@ js_CompileFunctionBody(JSContext *cx, JSTokenStream *ts, JSFunction *fun)
}
cx->gcDisabled--;
js_FinishCodeGenerator(cx, &funcg);
js_ResetCodeGenerator(cx, &funcg);
return ok;
}
@@ -721,9 +727,18 @@ ImportExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
pn2->pn_pos.begin = pn->pn_pos.begin;
pn2->pn_pos.end = ts->token.pos.end;
pn2->pn_op = JSOP_GETELEM;
pn2->pn_left = pn;
pn2->pn_right = pn3;
/* 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;
}
}
pn = pn2;
@@ -1129,13 +1144,15 @@ Statement(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
catchtail = pn;
while(js_PeekToken(cx, ts) == TOK_CATCH) {
/*
* legal catch form is:
* legal catch forms are:
* 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);
@@ -1154,15 +1171,14 @@ 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;
}
#endif
} else {
pn3->pn_expr = NULL;
}
pn2->pn_kid1 = pn3;
MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_CATCH);
@@ -1473,7 +1489,7 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
JSObject *obj, *pobj;
JSFunction *fun;
JSClass *clasp;
JSPropertyOp getter, setter, currentGetter, currentSetter;
JSPropertyOp getter, setter;
JSAtom *atom;
JSProperty *prop;
JSScopeProperty *sprop;
@@ -1515,8 +1531,6 @@ 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;
@@ -1535,7 +1549,7 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
OBJ_IS_NATIVE(pobj) &&
(sprop = (JSScopeProperty *)prop) != NULL) {
if (sprop->getter == js_GetArgument) {
currentGetter = sprop->getter;
getter = sprop->getter;
#ifdef CHECK_ARGUMENT_HIDING
js_ReportCompileErrorNumber(cx, ts, JSREPORT_WARNING,
JSMSG_VAR_HIDES_ARG,
@@ -1567,16 +1581,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.
*/
currentGetter = sprop->getter;
currentSetter = sprop->setter;
getter = sprop->getter;
setter = sprop->setter;
}
}
} else {
/* Global var: (re-)set id a la js_DefineProperty. */
sprop->id = ATOM_KEY(atom);
}
sprop->getter = currentGetter;
sprop->setter = currentSetter;
sprop->getter = getter;
sprop->setter = setter;
sprop->attrs |= JSPROP_ENUMERATE | JSPROP_PERMANENT;
sprop->attrs &= ~JSPROP_READONLY;
}
@@ -1592,18 +1606,18 @@ Variables(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
OBJ_DROP_PROPERTY(cx, pobj, prop);
prop = NULL;
}
if (currentGetter == js_GetCallVariable) {
if (getter == js_GetCallVariable) {
/* Can't increase fun->nvars in an active frame! */
currentGetter = clasp->getProperty;
currentSetter = clasp->setProperty;
getter = clasp->getProperty;
setter = clasp->setProperty;
}
ok = OBJ_DEFINE_PROPERTY(cx, obj, (jsid)atom, JSVAL_VOID,
currentGetter, currentSetter,
getter, setter,
JSPROP_ENUMERATE | JSPROP_PERMANENT,
&prop);
if (ok && prop) {
pobj = obj;
if (currentGetter == js_GetLocalVariable) {
if (getter == js_GetLocalVariable) {
/*
* Allocate more room for variables in the
* function's frame. We can do this only
@@ -1636,14 +1650,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 (currentGetter == js_GetArgument) {
if (getter == 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 (currentGetter == js_GetLocalVariable ||
currentGetter == js_GetCallVariable)
} else if (getter == js_GetLocalVariable ||
getter == js_GetCallVariable)
{
JS_ASSERT(sprop && JSVAL_IS_INT(sprop->id));
pn2->pn_op = (pn2->pn_op == JSOP_NAME)
@@ -2200,9 +2214,18 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
pn2->pn_pos.begin = pn->pn_pos.begin;
pn2->pn_pos.end = ts->token.pos.end;
pn2->pn_op = JSOP_GETELEM;
pn2->pn_left = pn;
pn2->pn_right = pn3;
/* 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;
}
} else if (allowCallSyntax && tt == TOK_LP) {
pn2 = NewParseNode(cx, &ts->token, PN_LIST);
if (!pn2)
@@ -2499,7 +2522,7 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
JSBool
js_FoldConstants(JSContext *cx, JSParseNode *pn)
{
JSParseNode *pn1=NULL, *pn2=NULL, *pn3=NULL;
JSParseNode *pn1, *pn2, *pn3;
switch (pn->pn_arity) {
case PN_FUNC:

View File

@@ -28,17 +28,20 @@
#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(linux) && defined(__powerpc__)) || defined(WIN16)
#if defined(MKLINUX) || defined(WIN16)
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
#endif /* Linux/PPC || WIN16 */
#endif /*MKLINUX*/
/*
** WARNING: This code may *NOT* call JS_LOG (because JS_LOG calls it)
@@ -1020,7 +1023,7 @@ static int FuncStuff(SprintfState *ss, const char *sp, JSUint32 len)
return 0;
}
JS_EXPORT_API(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
IMPLEMENT(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
const char *fmt, ...)
{
va_list ap;
@@ -1032,7 +1035,7 @@ JS_EXPORT_API(JSUint32) JS_sxprintf(JSStuffFunc func, void *arg,
return rv;
}
JS_EXPORT_API(JSUint32) JS_vsxprintf(JSStuffFunc func, void *arg,
IMPLEMENT(JSUint32) JS_vsxprintf(JSStuffFunc func, void *arg,
const char *fmt, va_list ap)
{
SprintfState ss;
@@ -1086,7 +1089,7 @@ static int GrowStuff(SprintfState *ss, const char *sp, JSUint32 len)
/*
** sprintf into a malloc'd buffer
*/
JS_EXPORT_API(char *) JS_smprintf(const char *fmt, ...)
IMPLEMENT(char *) JS_smprintf(const char *fmt, ...)
{
va_list ap;
char *rv;
@@ -1100,12 +1103,12 @@ JS_EXPORT_API(char *) JS_smprintf(const char *fmt, ...)
/*
** Free memory allocated, for the caller, by JS_smprintf
*/
JS_EXPORT_API(void) JS_smprintf_free(char *mem)
IMPLEMENT(void) JS_smprintf_free(char *mem)
{
JS_DELETE(mem);
}
JS_EXPORT_API(char *) JS_vsmprintf(const char *fmt, va_list ap)
IMPLEMENT(char *) JS_vsmprintf(const char *fmt, va_list ap)
{
SprintfState ss;
int rv;
@@ -1145,7 +1148,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.
*/
JS_EXPORT_API(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...)
IMPLEMENT(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...)
{
va_list ap;
int rv;
@@ -1161,7 +1164,7 @@ JS_EXPORT_API(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt,
return rv;
}
JS_EXPORT_API(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
IMPLEMENT(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
va_list ap)
{
SprintfState ss;
@@ -1186,7 +1189,7 @@ JS_EXPORT_API(JSUint32) JS_vsnprintf(char *out, JSUint32 outlen,const char *fmt,
return n ? n - 1 : n;
}
JS_EXPORT_API(char *) JS_sprintf_append(char *last, const char *fmt, ...)
IMPLEMENT(char *) JS_sprintf_append(char *last, const char *fmt, ...)
{
va_list ap;
char *rv;
@@ -1197,7 +1200,7 @@ JS_EXPORT_API(char *) JS_sprintf_append(char *last, const char *fmt, ...)
return rv;
}
JS_EXPORT_API(char *) JS_vsprintf_append(char *last, const char *fmt, va_list ap)
IMPLEMENT(char *) JS_vsprintf_append(char *last, const char *fmt, va_list ap)
{
SprintfState ss;
int rv;

View File

@@ -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.
*/
JS_EXTERN_API(JSUint32) JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...);
EXTERN(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.
*/
JS_EXTERN_API(char*) JS_smprintf(const char *fmt, ...);
EXTERN(char*) JS_smprintf(const char *fmt, ...);
/*
** Free the memory allocated, for the caller, by JS_smprintf
*/
JS_EXTERN_API(void) JS_smprintf_free(char *mem);
EXTERN(void) JS_smprintf_free(char *mem);
/*
** "append" sprintf into a malloc'd buffer. "last" is the last value of
@@ -67,7 +67,7 @@ JS_EXTERN_API(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.
*/
JS_EXTERN_API(char*) JS_sprintf_append(char *last, const char *fmt, ...);
EXTERN(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 @@ JS_EXTERN_API(char*) JS_sprintf_append(char *last, const char *fmt, ...);
*/
typedef JSIntn (*JSStuffFunc)(void *arg, const char *s, JSUint32 slen);
JS_EXTERN_API(JSUint32) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...);
EXTERN(JSUint32) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...);
/*
** va_list forms of the above.
*/
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);
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);
/*
***************************************************************************
@@ -121,7 +121,7 @@ JS_EXTERN_API(JSUint32) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt,
***************************************************************************
*/
JS_EXTERN_API(JSInt32) JS_sscanf(const char *buf, const char *fmt, ...);
EXTERN(JSInt32) JS_sscanf(const char *buf, const char *fmt, ...);
JS_END_EXTERN_C

View File

@@ -31,9 +31,9 @@ typedef struct JSPRHashEntry JSPRHashEntry;
typedef struct JSPRHashTable JSPRHashTable;
typedef JSPRUint32 JSPRHashNumber;
#define JSPR_HASH_BITS 32
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);
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);
/* Flag bits in JSPRHashEnumerator's return value */
#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */
@@ -42,10 +42,10 @@ typedef JSPRIntn (JSJS_DLL_CALLBACK *JSPRHashEnumerator)(JSPRHashEntry *he, JSPR
#define HT_ENUMERATE_UNHASH 4 /* just unhash the current entry */
typedef struct JSPRHashAllocOps {
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);
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);
} 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().
*/
JSJS_EXTERN_API(JSPRHashTable *)
JSEXTERN(JSPRHashTable *)
JSPR_NewHashTable(JSPRUint32 n, JSPRHashFunction keyHash,
JSPRHashComparator keyCompare, JSPRHashComparator valueCompare,
JSPRHashAllocOps *allocOps, void *allocPriv);
JSJS_EXTERN_API(void)
JSEXTERN(void)
JSPR_HashTableDestroy(JSPRHashTable *ht);
/* Low level access methods */
JSJS_EXTERN_API(JSPRHashEntry **)
JSEXTERN(JSPRHashEntry **)
JSPR_HashTableRawLookup(JSPRHashTable *ht, JSPRHashNumber keyHash, const void *key);
JSJS_EXTERN_API(JSPRHashEntry *)
JSEXTERN(JSPRHashEntry *)
JSPR_HashTableRawAdd(JSPRHashTable *ht, JSPRHashEntry **hep, JSPRHashNumber keyHash,
const void *key, void *value);
JSJS_EXTERN_API(void)
JSEXTERN(void)
JSPR_HashTableRawRemove(JSPRHashTable *ht, JSPRHashEntry **hep, JSPRHashEntry *he);
/* Higher level access methods */
JSJS_EXTERN_API(JSPRHashEntry *)
JSEXTERN(JSPRHashEntry *)
JSPR_HashTableAdd(JSPRHashTable *ht, const void *key, void *value);
JSJS_EXTERN_API(JSPRBool)
JSEXTERN(JSPRBool)
JSPR_HashTableRemove(JSPRHashTable *ht, const void *key);
JSJS_EXTERN_API(JSPRIntn)
JSEXTERN(JSPRIntn)
JSPR_HashTableEnumerateEntries(JSPRHashTable *ht, JSPRHashEnumerator f, void *arg);
JSJS_EXTERN_API(void *)
JSEXTERN(void *)
JSPR_HashTableLookup(JSPRHashTable *ht, const void *key);
JSJS_EXTERN_API(JSPRIntn)
JSEXTERN(JSPRIntn)
JSPR_HashTableDump(JSPRHashTable *ht, JSPRHashEnumerator dump, FILE *fp);
/* General-purpose C string hash function. */
JSJS_EXTERN_API(JSPRHashNumber)
JSEXTERN(JSPRHashNumber)
JSPR_HashString(const void *key);
/* Compare strings using strcmp(), return true if equal. */
JSJS_EXTERN_API(int)
JSEXTERN(int)
JSPR_CompareStrings(const void *v1, const void *v2);
/* Stub function just returns v1 == v2 */
JSJS_EXTERN_API(JSPRIntn)
JSEXTERN(JSPRIntn)
JSPR_CompareValues(const void *v1, const void *v2);
JSPR_END_EXTERN_C

View File

@@ -74,7 +74,6 @@ typedef enum JSTrapStatus {
JSTRAP_ERROR,
JSTRAP_CONTINUE,
JSTRAP_RETURN,
JSTRAP_THROW,
JSTRAP_LIMIT
} JSTrapStatus;
@@ -146,12 +145,4 @@ 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___ */

View File

@@ -22,9 +22,63 @@
* JS public API typedefs.
*/
#include "jstypes.h"
#define NETSCAPE_INTERNAL 1
#include "jscompat.h"
JS_BEGIN_EXTERN_C
#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)
/* Scalar typedefs. */
typedef uint16 jschar;
@@ -47,6 +101,8 @@ 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 {
@@ -96,7 +152,6 @@ 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
@@ -238,6 +293,4 @@ typedef const JSErrorFormatString *
(* CRT_CALL JSErrorCallback)(void *userRef, const char *locale,
const uintN errorNumber);
JS_END_EXTERN_C
#endif /* jspubtd_h___ */

View File

@@ -23,7 +23,14 @@
#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"
@@ -1180,7 +1187,6 @@ 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);
@@ -1477,7 +1483,7 @@ OptimizeRegExp(CompilerState *state, RENode *ren)
len = 1;
}
cx = state->context;
JS_ARENA_ALLOCATE(cp, &cx->tempPool, (len+2) * sizeof(jschar));
JS_ARENA_ALLOCATE(cp, &cx->tempPool, len + 2);
if (!cp) {
JS_ReportOutOfMemory(cx);
return JS_FALSE;
@@ -1914,7 +1920,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;
@@ -2096,9 +2102,6 @@ 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:
@@ -2485,7 +2488,7 @@ MatchRegExp(MatchState *state, jsbytecode *pc, const jschar *cp)
case REOP_UCFLATi:
matchlen = (ptrdiff_t)pc[1];
oplen += 2 * matchlen;
oplen += matchlen;
matched = (cp + matchlen <= cpend);
if (matched) {
pc2 = pc + 2;
@@ -2655,9 +2658,6 @@ 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

View File

@@ -30,7 +30,14 @@
#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"
@@ -438,8 +445,6 @@ 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, ...)
@@ -478,8 +483,6 @@ 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 {
@@ -499,7 +502,6 @@ js_ReportCompileError(JSContext *cx, JSTokenStream *ts, uintN flags,
limit[-1] = lastc;
free(message);
}
#endif
void
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
@@ -519,8 +521,7 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
va_start(ap, errorNumber);
if (!js_ExpandErrorArguments(cx, js_GetErrorMessage, NULL,
errorNumber, &message, &report,
JS_TRUE, ap))
errorNumber, &message, &report, ap))
return;
va_end(ap);
@@ -553,39 +554,16 @@ 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.
*/
/*
* 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;
(void)js_ErrorToException(cx, &report, message);
#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);
(*onError)(cx, message, &report);
#if !defined XP_PC || !defined _MSC_VER || _MSC_VER > 800
} else {
@@ -603,8 +581,8 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,
}
if (lastc == '\n')
limit[-1] = lastc;
if (message) JS_free(cx, message);
if (report.messageArgs) JS_free(cx, (void *)report.messageArgs);
if (message) free(message);
if (report.messageArgs) free(report.messageArgs);
}
JSTokenType
@@ -763,13 +741,12 @@ retry:
} else if (JS7_ISDEC(c)) {
/*
* We permit 08 and 09 as decimal numbers, which makes our
* behaviour a superset of the ECMA numeric grammar. We might
* behaviour 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_ReportCompileErrorNumber(cx, ts, JSREPORT_WARNING,
JSMSG_BAD_OCTAL,
c == '8' ? "08" : "09");
js_ReportCompileError(cx, ts, JSREPORT_WARNING,
"0%c is not a legal ECMA-262 numeric constant", c);
radix = 10;
} else {
radix = 8;
@@ -803,8 +780,8 @@ retry:
c = GetChar(ts);
}
if (!JS7_ISDEC(c)) {
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_MISSING_EXPONENT);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"missing exponent");
RETURN(TOK_ERROR);
}
do {
@@ -820,14 +797,14 @@ retry:
if (radix == 10) {
if (!js_strtod(cx, ts->tokenbuf.base, &endptr, &dval)) {
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_OUT_OF_MEMORY);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"out of memory");
RETURN(TOK_ERROR);
}
} else {
if (!js_strtointeger(cx, ts->tokenbuf.base, &endptr, radix, &dval)) {
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_OUT_OF_MEMORY);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"out of memory");
RETURN(TOK_ERROR);
}
}
@@ -842,8 +819,8 @@ retry:
while ((c = GetChar(ts)) != qc) {
if (c == '\n' || c == EOF) {
UngetChar(ts, c);
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_UNTERMINATED_STRING);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"unterminated string literal");
RETURN(TOK_ERROR);
}
if (c == '\\') {
@@ -1032,13 +1009,13 @@ skipline:
if (c == '/' && MatchChar(ts, '*')) {
if (MatchChar(ts, '/'))
goto retry;
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_NESTED_COMMENT);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"nested comment");
}
}
if (c == EOF) {
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_UNTERMINATED_COMMENT);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"unterminated comment");
RETURN(TOK_ERROR);
}
goto retry;
@@ -1053,8 +1030,8 @@ skipline:
while ((c = GetChar(ts)) != '/') {
if (c == '\n' || c == EOF) {
UngetChar(ts, c);
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_UNTERMINATED_REGEXP);
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
"unterminated regular expression literal");
RETURN(TOK_ERROR);
}
if (c == '\\') {
@@ -1077,8 +1054,8 @@ skipline:
c = PeekChar(ts);
if (JS7_ISLET(c)) {
ts->token.ptr = ts->linebuf.ptr - 1;
js_ReportCompileErrorNumber(cx, ts,JSREPORT_ERROR,
JSMSG_BAD_REGEXP_FLAG);
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
"invalid flag after regular expression");
(void) GetChar(ts);
RETURN(TOK_ERROR);
}
@@ -1144,8 +1121,8 @@ skipline:
break;
n = 10 * n + JS7_UNDEC(c);
if (n >= ATOM_INDEX_LIMIT) {
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_SHARPVAR_TOO_BIG);
js_ReportCompileError(cx, ts,JSREPORT_ERROR,
"overlarge sharp variable number");
RETURN(TOK_ERROR);
}
}
@@ -1161,8 +1138,8 @@ skipline:
#endif /* JS_HAS_SHARP_VARS */
default:
js_ReportCompileErrorNumber(cx, ts, JSREPORT_ERROR,
JSMSG_ILLEGAL_CHARACTER);
js_ReportCompileError(cx, ts, JSREPORT_ERROR,
"illegal character");
RETURN(TOK_ERROR);
}

View File

@@ -161,7 +161,6 @@ struct JSTokenStream {
#define TSF_INTERACTIVE 0x10 /* interactive parsing mode */
#define TSF_NLFLAG 0x20 /* last linebuf ended with \n */
#define TSF_CRFLAG 0x40 /* linebuf would have ended with \r */
#define TSF_BADCOMPILE 0x80 /* compile failed, stop throwing exns */
/*
* At most one non-EOF token can be pushed back onto a TokenStream between
@@ -221,12 +220,9 @@ js_MapKeywords(void (*mapfun)(const char *));
* Report an error found while scanning ts to a window or other output device
* associated with cx.
*/
#if 0
/* XXX js_ReportCompileError is unused */
extern void
js_ReportCompileError(JSContext *cx, JSTokenStream *ts, uintN flags,
const char *format, ...);
#endif
void
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, uintN flags,

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