Commit Graph

1262 Commits

Author SHA1 Message Date
igor%mir2.org
fe402a8124 Make all convertions from == to === to support JavaScript 1.2 to single place in Parser 2003-08-15 16:48:56 +00:00
igor%mir2.org
b96ac683c8 Added explicit IRFactory.createIncDec to create ++/-- subtree which removed need to have Token.PRE/Token.POST. 2003-08-15 11:19:47 +00:00
igor%mir2.org
9fce703481 Removal of Token.UNARYOP: after the previous patches parse tree used Token.UNARYOP only to group Token.TYPEOF and Token.VOID into the same node type. Since they are very different, it is simpler to use the tokens directly as node type.
To remove ambiguity caused by re-use of Token.VOID to denote no-operation node, a new Token.EMPTY is added to denote the former usage.
2003-08-15 10:21:09 +00:00
igor%mir2.org
b63333276d Added Token.TYPEOFNAME to denote explicitly parser nodes for typeof(name) to make code more explicit about this case compared with typeof(expression) which is denote by Token.TYPEOF. Previously the ambiguity was resolved by using (Token.UNARY.OP, Token.TYPEOF) for parser tree nodes denoting the later and simple Token.TYPEOF for the former. 2003-08-15 09:00:42 +00:00
igor%mir2.org
7fdd9e85d1 Another replace of (Token.UNARYOP, Token.X) -> Token.X: this time it is for Token.BITNOT and Token.NOT 2003-08-15 08:11:32 +00:00
igor%mir2.org
09c327adc3 Changing Token.POS, Token.NEG to represent their parser tree nodes by the token themselves, not via pair Token.UNARYOP, POS/NEG. It simplifies code especially in optimizer/Optimizer.java 2003-08-15 07:15:07 +00:00
igor%mir2.org
9a1fbf3def Removal of Token.TONUMBER: it had exactly the same semantics as Token.POS, that is to convert its argument to number. 2003-08-15 06:08:44 +00:00
igor%mir2.org
e1290d4dbb Removal of Token.PRIMARY: it was used in parser to group primary tokens such as false, true, null, this but since the semantic of them is very different it is simpler to create parse tree nodes directly from tokens and check only for node type, not for type and operation. 2003-08-14 14:49:46 +00:00
igor%mir2.org
13865e4143 Parser tree nodes of Token.CONVERT type are replaced by Token.TONUMBER and additional optimizer nodes to convert to double or object eliminating the need to distinguish them by Node.TYPE_PROPERTY. 2003-08-14 11:21:46 +00:00
igor%mir2.org
0dec223435 Removal of TypeEvent since its essential functionality beyond the declaration of few constants was used only to implement OptLocalVariable.assignType. Inlining that code eliminated need in TypeEvent. 2003-08-14 06:03:22 +00:00
igor%mir2.org
a5f9d59614 Change TokenStream to return operational tokens as is without grouping them through Token.UNARY, Token.PRIMARY etc. Instead do grouping only in parser. In this way exceptional cases when grouping of tokens has to be changed by parser (like reinterpretation of Token.IN) it is easy to deal with. Another advantage is decompiler simplification since it does not need to perform nested switches to unwrap tokens. 2003-08-13 14:21:39 +00:00
igor%mir2.org
6fa381d49b I replaced Token.ADD/Token.SUB by Token.POS/Token.NEG as operands of UNARY operation nodes in parse tree. This is mostly for readability and to catch ADD/SUB misuse earlier. 2003-08-13 11:57:33 +00:00
igor%mir2.org
593784cb96 Cosmetics: nodeOp as variable name is replaced by assignOp in methods related to construction of assignment nodes. 2003-08-13 11:53:14 +00:00
igor%mir2.org
a4742a5fe9 Change Parser to use IRFactory.createAssignment to create assignment nodes instead of calling createBinary only to handle assignments explicitly in IRFactory later. 2003-08-13 10:51:38 +00:00
igor%mir2.org
a692d990fc Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=215923 :
Search prototype chain of JS this until wrapped Java object is found that is compatible with Java this.
2003-08-13 06:04:41 +00:00
igor%mir2.org
9c0e1f0749 Making Decompiler.decompile public and changing NativeFunction.getSourceFunction() to return Object so it is easy to implement alternative presentation of encoded source. 2003-08-12 13:12:39 +00:00
igor%mir2.org
08560c4e86 Encoded source presentation changes.
Now encoded source does not encode sources of nested functions as external references. Rather they are encoded as any other source elements and to implement function.toString() runtime stores starting and ending offsets for function encoded source.

In this way decompiler is separated from the rest of runtime and external applications can access the encoded source with less efforts.
2003-08-12 11:50:48 +00:00
igor%mir2.org
a9944948f9 Using ScriptRuntime.emptyStrings to return emoty var array 2003-08-12 11:50:45 +00:00
igor%mir2.org
e725b9c0be Switching to use ClassFileWriter.addPush(String) instead of ClassFileWriter.addLoadConstant(String) to support string constants with JVM UTF8 encoding exceeding 64k. 2003-08-11 14:54:19 +00:00
igor%mir2.org
93e05fffaa Fixing bugs in the initial implementation of ClassFileWriter.addPush(String): now it works 2003-08-11 14:14:12 +00:00
igor%mir2.org
3594eb4b6b Use special token to encode function escape in Decompiler instead of using elaborated code to distinguish between start of function and function escape. 2003-08-11 11:06:21 +00:00
igor%mir2.org
8a8ca75068 Adding readFile function to the shell to read file context. 2003-08-11 10:54:40 +00:00
igor%mir2.org
af20fbe788 making decompiler class public so public method Parser.parser still can be called from outside omj. 2003-08-08 16:42:41 +00:00
igor%mir2.org
5523fffb09 Pass Decompiler object as an argument for Parser.parse instead of creating an instance there for better flexibility. 2003-08-08 15:42:19 +00:00
igor%mir2.org
6d6c104572 Calling Decompiler.decompile directly instead of calling Parser.decompile 2003-08-08 15:36:48 +00:00
igor%mir2.org
dda5331153 Decompiler class is moved to a separated file 2003-08-08 10:35:57 +00:00
igor%mir2.org
1c08dda3b8 1. Fixing Decompler.decopile for a function body when justBody is true Token.LC is added to the list of tokens to skip in function header.
2. Various cleanups in Decompiler to finalize Parser/Decompler split.
2003-08-08 09:35:36 +00:00
igor%mir2.org
0148813038 push(int/double) simply calls now ClassFileWriter.addPush() 2003-08-08 09:32:40 +00:00
igor%mir2.org
9ad008dd30 Added addPush(String) to generate code to push the given String into stack even if String does not fit the class file format restriction that JVM utf-8 encoding of strings in constant pool can not exceed 64K - 1.
Also added addPush(int/double) for symmetry, they are copied here from omj/optimizer/Codegen.java.
2003-08-08 09:30:57 +00:00
igor%mir2.org
99e484ca5b Restoring from bad commit of development uncompilable code 2003-08-07 15:10:10 +00:00
igor%mir2.org
666483b96d Notification of debugger about finished compilation of script/top-level-function is moved to a separated function. In this way Interpreter and ScriptOrFnNode does not need to pass original source around just to throw it away if debugger is not present. 2003-08-07 15:08:00 +00:00
igor%mir2.org
74d4f30e0e Replace anonymous/empty name play for functions constructed through Function in NativeFunction/Parser by using anonymous when necessary when assembling function source from Function arguments. 2003-08-07 10:46:41 +00:00
igor%mir2.org
954158fd2c Less generic code for interactioon between Parser and Decompiler 2003-08-07 07:19:16 +00:00
igor%mir2.org
db59f1d230 Code to generate/decode encoded source presentation is factored to a separated class Decompiler. 2003-08-06 16:18:28 +00:00
igor%mir2.org
2b68f1745e 1. Add Token.NOT as a byte code instead of generating if code to push false/true as "!" is frequent enough and interpreter does not have optimized mode to remove most of its usage in logical context.
2. When dumping icode, print it to System.out instead of icode.txt file for more convenient development.
2003-08-06 11:37:14 +00:00
igor%mir2.org
d153c65a1b build.xml reorganization to add deepclean, clean and help targets and making help a default target, see for details http://bugzilla.mozilla.org/show_bug.cgi?id=214997 2003-08-06 07:47:58 +00:00
igor%mir2.org
faf2a30c39 More tokens used only in Interpreter are moved from Token to Interpreter. I also added addToken/addIcode to be used instead of simple addByte to catch bugs about wrong byte code as soon as possible. 2003-08-06 07:39:37 +00:00
igor%mir2.org
f95ae1ab5b I changed Context.codeBug to return RuntimeException instead of void to be able to wright "throw Context.codeBug()" when simple "Context.codeBug()" leads to a compile error about unreachable code or missed return. 2003-08-06 07:37:27 +00:00
igor%mir2.org
87aeaade82 1. Constants in Token that are used only as Interpreter bytecode are moved to Interpreter.
2. LAST_BYTECODE_TOKEN is added to Token to server as a base for internal Interpreter bytecodes instead of Token.LAST_TOKEN. In this way compiler can generate more denser code for switches over interpreter bytecode.
2003-08-05 15:58:39 +00:00
igor%mir2.org
fa6d86fba0 SOURCEFILE bytecode used to restore interpreter source information is replaced by setting cx.interpreterSourceFile at the beginning of Interpreter.interpreter and restoring the old value at the end. 2003-08-05 11:16:14 +00:00
igor%mir2.org
61cd64260c I moved definitions of tokens in Tokenstream to separated class Token. In this way minimal Rhino distribution way remove Token class since it only necessary during compilation and strings with constant names would not be loaded into JVM. 2003-08-04 15:00:06 +00:00
igor%mir2.org
fb9ac64c2e Initialize cx.interpreterSourceFile with script o r function source name before starting bytecode execution so this information for the first script throw/runtime exception 2003-08-04 13:01:06 +00:00
igor%mir2.org
040a93626e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=214945 :
Optimize away empty try block only if finally is empty as well.
2003-08-04 12:57:15 +00:00
igor%mir2.org
30718f5ece <center><h1>... is replaced by <h1 align=center> to avoid warning from javadoc 2003-08-04 07:51:19 +00:00
igor%mir2.org
86bdaa37fc Fixing /** coments to remove JavaDoc errors/warnings 2003-08-03 21:40:22 +00:00
igor%mir2.org
9d44b5410e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=214608 :
The reason for the regression is that now JavaMembers.lookupClass never
attempts to reflect package-private classes. But this is wrong since even with
SecirutyManager installed JVM allows to call Class.getMethos()( and returns
list of all public methods in the class and its super classes.

The patch removes the restrictions while making JavaMembers.lookupClass much
simpler.
2003-07-31 17:08:58 +00:00
igor%mir2.org
3bad6fe1f8 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=213231 :
All information about exception handlers are stored in exception table eliminating the need to have TRY bytecode.
2003-07-24 10:50:29 +00:00
igor%mir2.org
6a3aad3989 Work in progress on http://bugzilla.mozilla.org/show_bug.cgi?id=213231 :
Replacing try stack by static table of exception handlers
2003-07-24 10:46:46 +00:00
igor%mir2.org
7625f8b519 Work in progress on http://bugzilla.mozilla.org/show_bug.cgi?id=213231 :
When handling exceptions, restore proper scope without using try stack
2003-07-24 10:45:30 +00:00
igor%mir2.org
dfd7e9d362 Restoring NativeJavaMethod(Method, String) for backward compatibility. 2003-07-24 09:06:44 +00:00
igor%mir2.org
e0de8aab17 Move code to adjust stack depth for finally handler from TARGET case of the main switch in generateICode to TRY switch generating all the code for try. It allows to remove special marking of JSR targets with FINALLY_PROP and make stack handling for catch and finally block uniform. 2003-07-22 13:41:35 +00:00
igor%mir2.org
687dff0fe1 Removal of JTHROW byte code: instead of generation byte code pair [GOSUB exception handler], JTHROW, RETSUB from finally now supports re-throwing of exception object directly when called from exception handler.
Now the exception handler invokes finally code with the exception object on the stack top, not PC to return which allows RETSUB to distinguish between this and GOSUB invocation.
2003-07-22 13:04:07 +00:00
igor%mir2.org
ebe60fb675 Move ENDTRY, JTHROW, GOSUB and RETSUB from TokenStream to Interpreter as they specific only to Interpreter implementation. 2003-07-22 11:16:54 +00:00
igor%mir2.org
cef7d514f9 Removal of code to handle stack chages when generationg GOSUB to finally code for finally handler: the stack size adjustments is done during FINALLY code generation already. 2003-07-22 08:58:08 +00:00
igor%mir2.org
a6ec3480e3 When generating code to invoke finally block from exception handler, do not store exception object in the local slot but rather leave it on JS stack and update finally block generation to expect potentially 2 objects on stack, not single return pc address. 2003-07-21 16:27:48 +00:00
igor%mir2.org
004397fe5e Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=201893 :
New class MemberBox wraps Method or Constructor instances to cache results of getParameterType() and other information and to to replace Method instance by more accessible one recovery from IllegalAccessException is possible.
2003-07-15 20:47:29 +00:00
igor%mir2.org
697f7be97f Cosmetics: layot fixes 2003-07-15 20:44:17 +00:00
igor%mir2.org
6f97ac4088 Throw IllegalArgumentException from compileString/compileReader if script line number is negative instead of catching it much later via Context.codeBug(). 2003-07-09 19:27:46 +00:00
igor%mir2.org
5188320068 1. To evaluate script represented by String, use Context.evaluateString to avoid the need to create StringReader instances.
2. Catch VirtualMachineError so on out-of-memory/stack-overflow the shell will exit with System.exit(EXITCODE_RUNTIME_ERROR), not with 1. It will allow to distinguish cases when script tried to consume all available stack/memory with bugs in Rhino itself leading to NullPointerException etc.

3. Remove code to rethrow ThreadDeath from JavaScriptExcception since ThreadDeath is re-thrown by the engine itself.
2003-07-06 19:21:42 +00:00
igor%mir2.org
dd893acd8d Caching of Method/Constructor.getParameterType()
To avoid constant calling of Method/Constructor.getParameterType() which creates a new Class array on each call, NativeJavaMethod stores the parameter types for its methods in methodTypes array and similarly JavaMembers holds all constructor types in ctorTypes array. The cached Class arrays are passed explicitly to methods that previously called getParameterType().
2003-07-06 19:07:00 +00:00
igor%mir2.org
c1add24197 Cosmetics: use
import java.lang.reflect.*;
import java.io.*;

instead of explicit importing multiple classes.
2003-07-06 19:02:03 +00:00
igor%mir2.org
32619aac8e NativeJavaMethod.add is removed. It allows to assume that after NativeJavaMethod constructor methods array will remain the same, which I will use in the following patch to add caching of Method.getParameterTypes.
Instead of calling NativeJavaMethod.add, JavaMembers assemble the method list directly and then pass it to NativeJavaMethod when done.
2003-07-06 18:59:30 +00:00
igor%mir2.org
2dd779b626 Pass staticType to wrapAsJavaObject to restore an option to use it for reflection instead of dynamicType if a security manager prevents the later 2003-07-06 18:51:54 +00:00
igor%mir2.org
4b42da1dbb More JavaMembers cosmetics:
1. All its methods package private methods that are not accesible outside the class itself are made private.

2. Various package-private getters are removed in favor of direct field access.
2003-07-06 18:51:53 +00:00
igor%mir2.org
1c181334c2 1. Changing NativeJavaMethod.findFunction to return index of found method instead of the method itself to make smaller the following optimizations of findFunction.
2. Removal of NativeJavaMethod.getMethod that simply returned package-private field NativeJavaMethod.methods since the filed itself was accessed directly by other files.
2003-07-05 22:13:33 +00:00
igor%mir2.org
4fdc22f62d Added reportRuntimeError4 and getMessage4 to build 4-argument messages 2003-07-05 22:05:55 +00:00
igor%mir2.org
922f49f971 For compatibility, resurrect unwrap as deprecated method. 2003-07-03 18:51:16 +00:00
igor%mir2.org
c922b2359b Added public FunctionObject.getMethodOrConstructor() to resolve
http://bugzilla.mozilla.org/show_bug.cgi?id=108719
2003-07-02 21:07:44 +00:00
igor%mir2.org
b5dd8750a1 Do not store dynamic scope flag in the object. Instead when checking thisObj against Java this type use scope != getParentScope() to detect such usage. 2003-07-02 19:41:48 +00:00
igor%mir2.org
df5af91220 Updating exception debugging to reflect changes due to http://bugzilla.mozilla.org/show_bug.cgi?id=210605 . 2003-07-02 16:37:29 +00:00
igor%mir2.org
10e5abd5a1 Reorganization of Java and JavaScript exception iteraction. See http://bugzilla.mozilla.org/show_bug.cgi?id=210605 for details. 2003-07-02 16:35:51 +00:00
igor%mir2.org
50093185e7 1. Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=102093 :
In NativeCall constructor adds argument object only if there is no parameters with this name and similarly do not set arguments to undefined if the function has "var arguments".

2. Split NativeCall into NativeCall and NativeCallPrototype to allow for smaller activation objects with faster property access.
2003-07-02 16:31:54 +00:00
igor%mir2.org
e168d3f93a Cosmetics: end-of-line junk space removal 2003-07-01 07:18:07 +00:00
igor%mir2.org
78167b2c67 Teach Committing.generateCatchBlock() to generate catch blocks for EcmaError exceptions to avoid code duplication. 2003-06-30 20:21:32 +00:00
igor%mir2.org
0ca2f9239b The code to deal with caught Java exceptions and transfer control to script finally/catch is transfered to CATCH bytecode which is now always added to the and of script bytecode. In this way if Context.observeInstructionCount throws an exception, a proper cleanup to restore Interpreter runtime will still be carried out. It also allowed to transfer control directly to catch/finally code when script call throw instead of throwing Java exception just to capture it immediately.
This special CATCH bytecode is a simple way to workaround lack of goto in Java which makes writing interpreters more complex then necessary...
2003-06-30 19:31:44 +00:00
igor%mir2.org
387b707f61 Added ScriptRuntime.getCatchObject() for extracting JS object to pass as the argument to JS catch statement. 2003-06-30 19:21:41 +00:00
igor%mir2.org
6d1229405a Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=210682 :
A slightly modified version of Brian Gugliemetti fix for bad interaction in TokenStream.getToken()/peekTokenSameLine() when dealing with EOL.
2003-06-30 19:18:31 +00:00
igor%mir2.org
90c20109d8 Removal of deprecated DefiningClassLoader 2003-06-29 22:32:52 +00:00
igor%mir2.org
b4b7524a24 Exception handling cleanup: use CATCH bytecode to extract JS object from Trowable so any exception that happens during this process will be handled properly. 2003-06-29 22:12:48 +00:00
igor%mir2.org
f1f70ebd4e Cosmetics: removal of unused import 2003-06-29 21:58:01 +00:00
igor%mir2.org
31641ef33a Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=208293 :
Patch from Steve Beal to fix my bug in Context.readReader.
2003-06-11 13:27:23 +00:00
igor%mir2.org
12a288b564 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=207999 :
EcmaError constructor now takes a generic Scriptable and not NativeError so classes outside org.mozilla.javascript can use it.
2003-06-11 07:36:11 +00:00
igor%mir2.org
4b523296c6 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=207968 :
As suggested by Roland Knight, WrappedException does not call exception.fillInStackTrace() to prevent hiding of the original stack trace.
2003-06-11 07:33:22 +00:00
igor%mir2.org
db16eb9355 To store properties, replace UintMap by a linked list. The former creates 2 objects (UintMap itself and int array) to store int properties and 3 objects (additional object array) to store object properties but vast majority of Nodes has no more then 2 properties with single-property-node contributing most to the majority. 2003-06-02 06:35:57 +00:00
igor%mir2.org
d1ca7cd329 Pass IRFactory to Parser.parse instead of Parser constructor so Parser initialization would not require IRFactory which needs Interpreter in turn . 2003-05-21 12:09:08 +00:00
igor%mir2.org
f46fd7f3b0 Layout cosmetics 2003-05-21 11:48:32 +00:00
igor%mir2.org
6b6368d8c8 Added WrapFactory.wrapAsJavaObject to simplify customization of LiveConnect 2003-05-20 12:46:09 +00:00
igor%mir2.org
e449bd5853 Adding missed final qualifier to the declaration of js_NaN_date_str field 2003-05-20 08:10:48 +00:00
igor%mir2.org
fde9643eed Addition of seal function to Rhino shell to seal all supplied arguments. 2003-05-19 15:53:23 +00:00
igor%mir2.org
3f84d7fe70 Resolving http://bugzilla.mozilla.org/show_bug.cgi?id=203013 :
Changing behavior of sealed objects to throw an exception on any attempt to modify them including changing values of existing properties. In the same time making object sealed does not affect read-only status of its properties which allows to override properties of objects with a sealed object as a prototype.

Rhino shell now accepts -sealedlib option to seal all standard objects.
2003-05-16 14:25:57 +00:00
igor%mir2.org
6fb4e51cdf Optimizations in NativeDate mostly to reduce amount of various format strings runtime has to initialize. 2003-05-16 08:32:58 +00:00
igor%mir2.org
d6229c666d NativeObject is split into NativeObject and NativeObjectPrototype subclass not to have prototypeFlag field in each and every object instance. 2003-05-15 13:12:41 +00:00
igor%mir2.org
3fb9f1b2ab Resolving http://bugzilla.mozilla.org/show_bug.cgi?id=205661 :
In setBySetter when start != this setters with delegators and setters without one if start is not an instance of this class are not invoked on start. Instead the standard JS rules applies so x.a = 1 would not change a in x.__proto__ if a in x.__proto__ is controlled by setter.
2003-05-15 07:29:46 +00:00
igor%mir2.org
9e9108a091 In getByGetter/setBySetter with slot.delegateTo avoid potentially expensive checks for start type if this == start. 2003-05-14 14:51:00 +00:00
igor%mir2.org
7f65f9ebed Changing JavaAdapter not to define JavaAdapter.prototype since new JavaAdapter create JS objects with __proto__ pointing to Object.prototype. It removes the need to extend from ScriptableObject in JavaAdapter and effectively makes it a collection of static methods.
To implement JavaAdapter JS call I used JIFunction subclass so the method implementing this functionality can be package private.
2003-05-14 12:44:24 +00:00
igor%mir2.org
6e6a6e7226 More layout fixes and renames to make the following commit smaller. 2003-05-14 09:45:59 +00:00
igor%mir2.org
36b6f85b95 In jsConstructor catch reflection exceptions and rethrow them as WrappedException not to create InvocationTargetException proxy that will be converted to WrappedException by the runtime in any case. 2003-05-14 09:37:39 +00:00
igor%mir2.org
f88a99c04b Removal of overridden equals that simply calls super.equals since JavaAdapter does not need to define the method for ScriptableObject.defineClass to work and layout cosmetics. 2003-05-14 06:24:00 +00:00
igor%mir2.org
65e85a6cc2 Replace catch for various exceptions that reflection methods can throw by single catch (Exception ex) to have smaller code. 2003-05-13 10:07:44 +00:00
igor%mir2.org
d0fc67bca5 Fixing http://bugzilla.mozilla.org/show_bug.cgi?id=205297 2003-05-12 16:54:41 +00:00